import{C as e,D as t,O as n,S as r,_ as i,d as a,f as o,l as s,v as c,x as l}from"./format-BR6pbdjm.js";function u(e,t){let n=r(e)-+r(t);return n<0?-1:n>0?1:n}function d(t){return e(t,Date.now())}function f(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function p(e,t){return r(e)-+r(t)}function m(e,t){let n=r(e,t?.in);return n.setHours(23,59,59,999),n}function h(e,t){let n=r(e,t?.in);return+m(n,t)==+a(n,t)}function g(e,t,n){let[r,a,s]=i(n?.in,e,e,t),c=u(a,s),l=Math.abs(o(a,s));if(l<1)return 0;a.getMonth()===1&&a.getDate()>27&&a.setDate(30),a.setMonth(a.getMonth()-c*l);let d=u(a,s)===-c;h(r)&&l===1&&u(r,s)===1&&(d=!1);let f=c*(l-+d);return f===0?0:f}function _(e,t,n){let r=p(e,t)/1e3;return f(n?.roundingMethod)(r)}function v(e,r,a){let o=l(),d=a?.locale??o.locale??s,f=u(e,r);if(isNaN(f))throw RangeError(`Invalid time value`);let p=Object.assign({},a,{addSuffix:a?.addSuffix,comparison:f}),[m,h]=i(a?.in,...f>0?[r,e]:[e,r]),v=_(h,m),y=(c(h)-c(m))/1e3,b=Math.round((v-y)/60),x;if(b<2)return a?.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/n),d.formatDistance(`aboutXMonths`,x,p);if(x=g(h,m),x<12){let e=Math.round(b/n);return d.formatDistance(`xMonths`,e,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,d(e),t)}export{d as n,y as t};