import{gy as u,hj as F,hk as M,J as x,hl as I,K as S,hm as y,hn as _,ho as H,hp as d,hq as b,hr as k}from"./index-_eM6l4Nf.js";function C(t,e){const s=u(t),n=u(e);return s.getFullYear()-n.getFullYear()}function N(t,e){const s=u(t),n=u(e),r=D(s,n),o=Math.abs(F(s,n));s.setDate(s.getDate()-r*o);const a=+(D(s,n)===-r),c=r*(o-a);return c===0?0:c}function D(t,e){const s=t.getFullYear()-e.getFullYear()||t.getMonth()-e.getMonth()||t.getDate()-e.getDate()||t.getHours()-e.getHours()||t.getMinutes()-e.getMinutes()||t.getSeconds()-e.getSeconds()||t.getMilliseconds()-e.getMilliseconds();return s<0?-1:s>0?1:s}function T(t,e,s){const n=M(t,e)/x;return I()(n)}function j(t,e,s){const n=M(t,e)/S;return I()(n)}function z(t,e){const s=u(t),n=u(e),r=y(s,n),o=Math.abs(C(s,n));s.setFullYear(1584),n.setFullYear(1584);const a=y(s,n)===-r,c=r*(o-+a);return c===0?0:c}const A=["years","months","weeks","days","hours","minutes","seconds"];function O(t,e){const s=_(),n=(e==null?void 0:e.locale)??s.locale??H,r=(e==null?void 0:e.format)??A,o=(e==null?void 0:e.zero)??!1,a=(e==null?void 0:e.delimiter)??" ";return n.formatDistance?r.reduce((f,i)=>{const m=`x${i.replace(/(^.)/,h=>h.toUpperCase())}`,l=t[i];return l!==void 0&&(o||t[i])?f.concat(n.formatDistance(m,l)):f},[]).join(a):""}function U(t){const e=u(t.start),s=u(t.end),n={},r=z(s,e);r&&(n.years=r);const o=d(e,{years:n.years}),a=b(s,o);a&&(n.months=a);const c=d(o,{months:n.months}),f=N(s,c);f&&(n.days=f);const i=d(c,{days:n.days}),m=T(s,i);m&&(n.hours=m);const l=d(i,{hours:n.hours}),h=j(s,l);h&&(n.minutes=h);const Y=d(l,{minutes:n.minutes}),g=k(s,Y);return g&&(n.seconds=g),n}const q=t=>t===0?"0s":O(U({start:0,end:t}),{format:["years","months","days","hours","minutes","seconds"],locale:{formatDistance:(e,s,n)=>v[e].replace("{{count}}",String(s))}}),J=t=>q(t*1e3),v={xSeconds:"{{count}}s",xMinutes:"{{count}}m",xHours:"{{count}}h",xDays:"{{count}}d",xMonths:"{{count}}m",xYears:"{{count}}y"};export{q as m,J as s};
