import{s as e}from"./chunk-Bj-mKKzh.js";import{n as t,t as n}from"./jsx-runtime-CiQ1k8xo.js";import{lt as r}from"./vscode-api-DjORcpSo.js";import{c as i}from"./lib-MoKmYgcO.js";var a=e(t(),1),o=6e4,s=new Date,c=new Set,l=null;function u(){return(0,a.useSyncExternalStore)(h,g,g)}function d(){for(let e of c)e()}function f(){s=new Date,d()}function p(){l!=null||typeof window>`u`||(f(),l=window.setInterval(()=>{f()},o))}function m(){l!=null&&(window.clearInterval(l),l=null)}function h(e){return c.add(e),c.size===1&&p(),()=>{c.delete(e),c.size===0&&m()}}function g(){return s}var _=r(),v=n(),y=7,b=30,x=365,S=(0,a.createContext)(null);function C(e,t){return Math.floor((e.getTime()-t.getTime())/6e4)}function w(e,t){let n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(t.getFullYear(),t.getMonth(),t.getDate());return Math.round((n.getTime()-r.getTime())/864e5)}function T(e){let t=(0,_.c)(7),{dateString:n}=e,r=(0,a.useContext)(S);if(r!=null){let e;t[0]===r?e=t[1]:(e=new Date(r),t[0]=r,t[1]=e);let i;return t[2]!==n||t[3]!==e?(i=(0,v.jsx)(D,{dateString:n,now:e}),t[2]=n,t[3]=e,t[4]=i):i=t[4],i}let i;return t[5]===n?i=t[6]:(i=(0,v.jsx)(E,{dateString:n}),t[5]=n,t[6]=i),i}function E(e){let t=(0,_.c)(3),{dateString:n}=e,r=u(),i;return t[0]!==n||t[1]!==r?(i=(0,v.jsx)(D,{dateString:n,now:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function D(e){let t=(0,_.c)(22),{dateString:n,now:r}=e,a=i(),o,s;if(t[0]!==n||t[1]!==r){let e=new Date(n);o=w(r,e),s=C(r,e),t[0]=n,t[1]=r,t[2]=o,t[3]=s}else o=t[2],s=t[3];let c=s,l=Math.max(1,c);if(l<60){let e;return t[4]!==a||t[5]!==l?(e=a.formatMessage({id:`wham.formattedRelativeDateTime.compactMinutesAgo`,defaultMessage:`{value}m`,description:`Compact minutes-ago format`},{value:l}),t[4]=a,t[5]=l,t[6]=e):e=t[6],e}let u=Math.floor(l/60);if(u<24){let e;return t[7]!==u||t[8]!==a?(e=a.formatMessage({id:`wham.formattedRelativeDateTime.compactHoursAgo`,defaultMessage:`{value}h`,description:`Compact hours-ago format`},{value:u}),t[7]=u,t[8]=a,t[9]=e):e=t[9],e}let d=Math.max(1,o);if(d<y){let e;return t[10]!==d||t[11]!==a?(e=a.formatMessage({id:`wham.formattedRelativeDateTime.compactDaysAgo`,defaultMessage:`{value}d`,description:`Compact days-ago format`},{value:d}),t[10]=d,t[11]=a,t[12]=e):e=t[12],e}if(d<b){let e=Math.floor(d/y),n;return t[13]!==a||t[14]!==e?(n=a.formatMessage({id:`wham.formattedRelativeDateTime.compactWeeksAgo`,defaultMessage:`{value}w`,description:`Compact weeks-ago format`},{value:e}),t[13]=a,t[14]=e,t[15]=n):n=t[15],n}if(d<x){let e=Math.floor(d/b),n;return t[16]!==a||t[17]!==e?(n=a.formatMessage({id:`wham.formattedRelativeDateTime.compactMonthsAgo`,defaultMessage:`{value}mo`,description:`Compact months-ago format`},{value:e}),t[16]=a,t[17]=e,t[18]=n):n=t[18],n}let f=Math.floor(d/x),p;return t[19]!==a||t[20]!==f?(p=a.formatMessage({id:`wham.formattedRelativeDateTime.compactYearsAgo`,defaultMessage:`{value}y`,description:`Compact years-ago format`},{value:f}),t[19]=a,t[20]=f,t[21]=p):p=t[21],p}export{T as t};
//# sourceMappingURL=format-relative-date-time-CvBoa_2A.js.map