import{l as i,m as h,c as w,j as d,n as f,o as L,q as y}from"./preload-helper-B5suVMXI.chunk.mjs";import{r as T,k,t as m,m as D}from"./index-jVniDJU4.chunk.mjs";function N(){if(typeof globalThis.firstDay<"u")return globalThis.firstDay;const e=new Intl.Locale(i()),o=e.getWeekInfo?.()??e.weekInfo;return o?o.firstDay%7:1}function I(){if(typeof globalThis.dayNames<"u")return globalThis.dayNames;const e=i();return[new Date(1970,0,4).toLocaleDateString(e,{weekday:"long"}),new Date(1970,0,5).toLocaleDateString(e,{weekday:"long"}),new Date(1970,0,6).toLocaleDateString(e,{weekday:"long"}),new Date(1970,0,7).toLocaleDateString(e,{weekday:"long"}),new Date(1970,0,8).toLocaleDateString(e,{weekday:"long"}),new Date(1970,0,9).toLocaleDateString(e,{weekday:"long"}),new Date(1970,0,10).toLocaleDateString(e,{weekday:"long"})]}function F(){if(typeof globalThis.dayNamesShort<"u")return globalThis.dayNamesShort;const e=i();return[new Date(1970,0,4).toLocaleDateString(e,{weekday:"short"}),new Date(1970,0,5).toLocaleDateString(e,{weekday:"short"}),new Date(1970,0,6).toLocaleDateString(e,{weekday:"short"}),new Date(1970,0,7).toLocaleDateString(e,{weekday:"short"}),new Date(1970,0,8).toLocaleDateString(e,{weekday:"short"}),new Date(1970,0,9).toLocaleDateString(e,{weekday:"short"}),new Date(1970,0,10).toLocaleDateString(e,{weekday:"short"})]}function R(){if(typeof globalThis.dayNamesMin<"u")return globalThis.dayNamesMin;const e=i();return[new Date(1970,0,4).toLocaleDateString(e,{weekday:"narrow"}),new Date(1970,0,5).toLocaleDateString(e,{weekday:"narrow"}),new Date(1970,0,6).toLocaleDateString(e,{weekday:"narrow"}),new Date(1970,0,7).toLocaleDateString(e,{weekday:"narrow"}),new Date(1970,0,8).toLocaleDateString(e,{weekday:"narrow"}),new Date(1970,0,9).toLocaleDateString(e,{weekday:"narrow"}),new Date(1970,0,10).toLocaleDateString(e,{weekday:"narrow"})]}function W(){if(typeof globalThis.monthNames<"u")return globalThis.monthNames;const e=i();return[new Date(1970,0).toLocaleDateString(e,{month:"long"}),new Date(1970,1).toLocaleDateString(e,{month:"long"}),new Date(1970,2).toLocaleDateString(e,{month:"long"}),new Date(1970,3).toLocaleDateString(e,{month:"long"}),new Date(1970,4).toLocaleDateString(e,{month:"long"}),new Date(1970,5).toLocaleDateString(e,{month:"long"}),new Date(1970,6).toLocaleDateString(e,{month:"long"}),new Date(1970,7).toLocaleDateString(e,{month:"long"}),new Date(1970,8).toLocaleDateString(e,{month:"long"}),new Date(1970,9).toLocaleDateString(e,{month:"long"}),new Date(1970,10).toLocaleDateString(e,{month:"long"}),new Date(1970,11).toLocaleDateString(e,{month:"long"})]}function j(){if(typeof globalThis.monthNamesShort<"u")return globalThis.monthNamesShort;const e=i();return[new Date(1970,0).toLocaleDateString(e,{month:"short"}),new Date(1970,1).toLocaleDateString(e,{month:"short"}),new Date(1970,2).toLocaleDateString(e,{month:"short"}),new Date(1970,3).toLocaleDateString(e,{month:"short"}),new Date(1970,4).toLocaleDateString(e,{month:"short"}),new Date(1970,5).toLocaleDateString(e,{month:"short"}),new Date(1970,6).toLocaleDateString(e,{month:"short"}),new Date(1970,7).toLocaleDateString(e,{month:"short"}),new Date(1970,8).toLocaleDateString(e,{month:"short"}),new Date(1970,9).toLocaleDateString(e,{month:"short"}),new Date(1970,10).toLocaleDateString(e,{month:"short"}),new Date(1970,11).toLocaleDateString(e,{month:"short"})]}function b(e=Date.now(),o={}){const t={ignoreSeconds:!1,language:h(),relativeTime:"long",...o},l=new Date(e),r=new Intl.RelativeTimeFormat([t.language,h()],{numeric:"auto",style:t.relativeTime}),s=(l.getTime()-Date.now())/1e3;if(Math.abs(s)<59.5)return t.ignoreSeconds||r.format(Math.round(s),"second");const g=s/60;if(Math.abs(g)<=59)return r.format(Math.round(g),"minute");const n=g/60;if(Math.abs(n)<23.5)return r.format(Math.round(n),"hour");const a=n/24;if(Math.abs(a)<6.5)return r.format(Math.round(a),"day");if(Math.abs(a)<27.5){const S=a/7;return r.format(Math.round(S),"week")}const c=a/30,u=Math.abs(c)<11?{month:t.relativeTime,day:"numeric"}:{year:t.relativeTime==="narrow"?"2-digit":"numeric",month:t.relativeTime};return new Intl.DateTimeFormat([t.language,h()],u).format(l)}T(k);const v={long:m("a few seconds ago"),short:m("seconds ago"),narrow:m("sec. ago")};function q(e=Date.now(),o={}){let t;const l=w(()=>new Date(D(e))),r=w(()=>{const{language:n,relativeTime:a,ignoreSeconds:c}=D(o);return{...n&&{language:n},...a&&{relativeTime:a},ignoreSeconds:c?v[a||"long"]:!1}}),s=d("");f(()=>g());function g(){if(s.value=b(l.value,r.value),D(o).update!==!1){const n=Math.abs(Date.now()-new Date(D(e)).getTime()),a=n>12e4||r.value.ignoreSeconds?Math.min(n/60,18e5):1e3;t=window.setTimeout(g,a)}}return L(()=>t&&window.clearTimeout(t)),y(s)}function x(e,o){const t=w(()=>({locale:i(),format:{dateStyle:"short",timeStyle:"medium"},...D(o)})),l=w(()=>new Intl.DateTimeFormat(t.value.locale,t.value.format));return w(()=>l.value.format(D(e)))}export{q as a,R as b,F as c,I as d,j as e,W as f,N as g,x as u};
//# sourceMappingURL=useFormatDateTime-CcJ-Psjy.chunk.mjs.map
