import{a as e}from"./i18n-BaLR3UdQ.js";import{t}from"./options-CDXBc9UM.js";var n=60,r=3600,i=86400;function a(t,a){if(!Number.isFinite(t)||t<0)return null;let o=a>0?a:i,s=Math.round(t/o);switch(o){case 1:return e(`time_interval.seconds`,{count:s});case n:return e(`time_interval.minutes`,{count:s});case r:return e(`time_interval.hours`,{count:s});case i:return e(`time_interval.days`,{count:s});default:return e(`time_interval.days`,{count:Math.round(t/i)})}}function o(e,n=`medium`,r=`medium`){if(!e)return``;let i=s(t.get(`formattingLocale`)||t.get(`locale`)||navigator.language),a;if(typeof e==`string`||typeof e==`number`){let t=typeof e==`string`&&/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(t){let[,e,n,r]=t;a=new Date(Number(e),Number(n)-1,Number(r))}else a=new Date(e)}else if(e instanceof Date)a=e;else throw TypeError(`Invalid type for the "date" argument.`);if(r!==`none`&&n!==`none`)try{return new Intl.DateTimeFormat(i,{dateStyle:n,timeStyle:r}).format(a)}catch{return new Intl.DateTimeFormat(void 0,{dateStyle:n,timeStyle:r}).format(a)}else if(r===`none`&&n!==`none`)try{return a.toLocaleDateString(i,{dateStyle:n})}catch{return a.toLocaleDateString(void 0,{dateStyle:n})}else if(n===`none`&&r!==`none`)try{return a.toLocaleTimeString(i,{timeStyle:r})}catch{return a.toLocaleTimeString(void 0,{timeStyle:r})}throw Error(`Incorrect state.`)}function s(e){switch(e=e.replaceAll(`_`,`-`),e){case`cn`:return`zh-CN`;case`tw`:return`zh-TW`;default:return e}}export{a as n,o as t};