import{cf as V,cg as _,q as P,b as W}from"./v5WcX6fg.js";var m=t=>Math.abs(t%1),R=(t,r)=>Math.abs(t-r)t>r||R(t,r),q=t=>Math.abs(t)%2<1,k=t=>Object.is(t,-0)?0:t,f=t=>k(Math.ceil(t)),a=t=>k(Math.floor(t)),Y=t=>t>=0?f(t):a(t),$=t=>t>=0?a(t):f(t),v=t=>{var r=m(t);return t>=0?x(r,.5)?f(t):a(t):r>.5?a(t):f(t)},B=t=>{var r=m(t);return t>=0?r>.5?f(t):a(t):x(r,.5)?a(t):f(t)},K=t=>{var r=m(t);return t>=0?x(r,.5)?f(t):a(t):x(r,.5)?a(t):f(t)},Q=t=>{var r=m(t);return t>0?r>.5?f(t):a(t):r>.5?a(t):f(t)},Z=t=>{var r=m(t);return t>=0?R(r,.5)?q(t)?a(t):f(t):r>.5?f(t):a(t):R(r,.5)?q(t)?f(t):a(t):r>.5?a(t):f(t)};const F={__proto__:null,ceil:f,expand:Y,floor:a,halfCeil:v,halfEven:Z,halfExpand:K,halfFloor:B,halfTrunc:Q,trunc:$},C=1e3,j=60*C,z=60*j,y=24*z,J=7*y,G=30*y,X=3*G,tt=365*y,b=[["year",tt],["quarter",X],["month",G],["week",J],["day",y],["hour",z],["minute",j],["second",0,C]];function w(t){for(const[r]of b)if(r+"s"===t)return r;return t}function g(t){return t instanceof Date?t.getTime():typeof t=="string"?new Date(t).getTime():Number(t)}function rt(t){let r,n;if(typeof t=="object")if(t instanceof Date)r=g(t),n=Date.now();else{const[o,e]=Array.isArray(t)?t:[t.from,t.to];r=g(o),n=e==null?Date.now():g(e)}else r=g(t),n=Date.now();return[r,n]}function et({excludedUnits:t}){if(t==null)return["quarter"];if(!Array.isArray(t))throw new TypeError("Value is not of array type for formatTimeDifference options property excludedUnits");return[...t]}function nt(t){const r=et(t);if(r.length===0)return b;const n=[...b];for(const o of r){const e=w(o),c=n.findIndex(l=>l[0]===e);c===-1&&M("excludedUnits",o),n.splice(c,1)}return n}const u="none";function ot({minimumUnit:t,maximumUnit:r}){return t??(t=u),r??(r=u),t!==u&&(t=w(String(t))),r!==u&&(r=w(String(r))),[t,r]}function M(t,r){throw new RangeError(`Value ${r} out of range for formatTimeDifference options property ${t}`)}function it(t,r,n){const o=n===u?0:t.findIndex(s=>s[0]===n);let e;r===u?e=t.length>0?t.length-1:0:e=t.findIndex(s=>s[0]===r);const c=e2?2:1],D=E/S,I=c(T<0?-D:D);if(l&&d!==A){const N=e[d-1],H=N[N.length>2?2:1]/S;if(Math.abs(I)>=H){const U=E/D*I;T=U,E=Math.abs(U),d-=2;continue}}return t(I,p[0],{numeric:"auto",...o})}return null}function st({onError:t},r,n,o,e={}){const[c,l]=rt(o);try{const i=ct(r,c,l,e);if(i!=null)return i}catch(i){t(new V("Error formatting time difference as a relative time",_.INVALID_VALUE,i instanceof Error?i.message:String(i)))}try{return n(c,e.dateTimeOptions??{dateStyle:"long",timeStyle:"short"})}catch(i){t(new V("Error formatting time difference as a date",_.INVALID_VALUE,i instanceof Error?i.message:String(i)))}return""}function lt(t){return function(...n){return st(t,t.formatRelativeTime,t.formatDate,...n)}}const L=new WeakMap;function ht(){const t=P();let r=L.get(t);if(r==null){const n=W(()=>lt(t.intl)),o={roundingMode:"halfExpand"};r=(e,c)=>n.value(e,{...c,...o}),L.set(t,r)}return r}export{ht as u};