import{C as e,S as t,_ as n,f as r,g as i,h as a,p as o,v as s}from"./format-OWwbgYKQ.js";function c(e,t){let r=n(e)-+n(t);return r<0?-1:r>0?1:r}function l(e){return s(e,Date.now())}function u(e,t,n){let[r,i]=a(n?.in,e,t),o=r.getFullYear()-i.getFullYear(),s=r.getMonth()-i.getMonth();return o*12+s}function d(e,t){return n(e)-+n(t)}function f(e,t){let r=n(e,t?.in);return r.setHours(23,59,59,999),r}function p(e,t){let r=n(e,t?.in),i=r.getMonth();return r.setFullYear(r.getFullYear(),i+1,0),r.setHours(23,59,59,999),r}function m(e,t){let r=n(e,t?.in);return+f(r,t)==+p(r,t)}function h(e,t,n){let[r,i,o]=a(n?.in,e,e,t),s=c(i,o),l=Math.abs(u(i,o));if(l<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-s*l);let d=c(i,o)===-s;m(r)&&l===1&&c(r,o)===1&&(d=!1);let f=s*(l-+d);return f===0?0:f}function g(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function _(e,t,n){let r=d(e,t)/1e3;return g(n?.roundingMethod)(r)}function v(n,s,l){let u=r(),d=l?.locale??u.locale??o,f=c(n,s);if(isNaN(f))throw RangeError(`Invalid time value`);let p=Object.assign({},l,{addSuffix:l?.addSuffix,comparison:f}),[m,g]=a(l?.in,...f>0?[s,n]:[n,s]),v=_(g,m),y=(i(g)-i(m))/1e3,b=Math.round((v-y)/60),x;if(b<2)return l?.includeSeconds?v<5?d.formatDistance(`lessThanXSeconds`,5,p):v<10?d.formatDistance(`lessThanXSeconds`,10,p):v<20?d.formatDistance(`lessThanXSeconds`,20,p):v<40?d.formatDistance(`halfAMinute`,0,p):v<60?d.formatDistance(`lessThanXMinutes`,1,p):d.formatDistance(`xMinutes`,1,p):b===0?d.formatDistance(`lessThanXMinutes`,1,p):d.formatDistance(`xMinutes`,b,p);if(b<45)return d.formatDistance(`xMinutes`,b,p);if(b<90)return d.formatDistance(`aboutXHours`,1,p);if(b<1440){let e=Math.round(b/60);return d.formatDistance(`aboutXHours`,e,p)}else if(b<2520)return d.formatDistance(`xDays`,1,p);else if(b<43200){let e=Math.round(b/t);return d.formatDistance(`xDays`,e,p)}else if(b<43200*2)return x=Math.round(b/e),d.formatDistance(`aboutXMonths`,x,p);if(x=h(g,m),x<12){let t=Math.round(b/e);return d.formatDistance(`xMonths`,t,p)}else{let e=x%12,t=Math.trunc(x/12);return e<3?d.formatDistance(`aboutXYears`,t,p):e<9?d.formatDistance(`overXYears`,t,p):d.formatDistance(`almostXYears`,t+1,p)}}function y(e,t){return v(e,l(e),t)}export{l as n,y as t};