import{s as c}from"./chunk-LvLJmgfZ.js";import{t as p}from"./react-Bj1aDYRI.js";import{t as d}from"./context-BFPaAUK_.js";var s=c(p(),1);function i(r,t){let e=(0,s.useRef)(null);return r&&e.current&&t(r,e.current)&&(r=e.current),e.current=r,r}var u=new Map,f=class{format(r){return this.formatter.format(r)}formatToParts(r){return this.formatter.formatToParts(r)}formatRange(r,t){if(typeof this.formatter.formatRange=="function")return this.formatter.formatRange(r,t);if(t<r)throw RangeError("End date must be >= start date");return`${this.formatter.format(r)} \u2013 ${this.formatter.format(t)}`}formatRangeToParts(r,t){if(typeof this.formatter.formatRangeToParts=="function")return this.formatter.formatRangeToParts(r,t);if(t<r)throw RangeError("End date must be >= start date");let e=this.formatter.formatToParts(r),n=this.formatter.formatToParts(t);return[...e.map(o=>({...o,source:"startRange"})),{type:"literal",value:" \u2013 ",source:"shared"},...n.map(o=>({...o,source:"endRange"}))]}resolvedOptions(){let r=this.formatter.resolvedOptions();return g()&&(this.resolvedHourCycle||(this.resolvedHourCycle=T(r.locale,this.options)),r.hourCycle=this.resolvedHourCycle,r.hour12=this.resolvedHourCycle==="h11"||this.resolvedHourCycle==="h12"),r.calendar==="ethiopic-amete-alem"&&(r.calendar="ethioaa"),r}constructor(r,t={}){this.formatter=l(r,t),this.options=t}},y={true:{ja:"h11"},false:{}};function l(r,t={}){if(typeof t.hour12=="boolean"&&v()){t={...t};let o=y[String(t.hour12)][r.split("-")[0]],a=t.hour12?"h12":"h23";t.hourCycle=o??a,delete t.hour12}let e=r+(t?Object.entries(t).sort((o,a)=>o[0]<a[0]?-1:1).join():"");if(u.has(e))return u.get(e);let n=new Intl.DateTimeFormat(r,t);return u.set(e,n),n}var h=null;function v(){return h??(h=new Intl.DateTimeFormat("en-US",{hour:"numeric",hour12:!1}).format(new Date(2020,2,3,0))==="24"),h}var m=null;function g(){return m??(m=new Intl.DateTimeFormat("fr",{hour:"numeric",hour12:!1}).resolvedOptions().hourCycle==="h12"),m}function T(r,t){if(!t.timeStyle&&!t.hour)return;r=r.replace(/(-u-)?-nu-[a-zA-Z0-9]+/,""),r+=(r.includes("-u-")?"":"-u")+"-nu-latn";let e=l(r,{...t,timeZone:void 0}),n=parseInt(e.formatToParts(new Date(2020,2,3,0)).find(a=>a.type==="hour").value,10),o=parseInt(e.formatToParts(new Date(2020,2,3,23)).find(a=>a.type==="hour").value,10);if(n===0&&o===23)return"h23";if(n===24&&o===23)return"h24";if(n===0&&o===11)return"h11";if(n===12&&o===11)return"h12";throw Error("Unexpected hour cycle result")}function w(r){r=i(r??{},R);let{locale:t}=d();return(0,s.useMemo)(()=>new f(t,r),[t,r])}function R(r,t){if(r===t)return!0;let e=Object.keys(r),n=Object.keys(t);if(e.length!==n.length)return!1;for(let o of e)if(t[o]!==r[o])return!1;return!0}export{f as n,i as r,w as t};
