import{s as m}from"./chunk-LvLJmgfZ.js";import{t as g}from"./react-Bj1aDYRI.js";import{t as p}from"./SSRProvider-BUSmWJKC.js";var w=new Set(["Arab","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),v=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function c(e){if(Intl.Locale){let t=new Intl.Locale(e).maximize(),o=typeof t.getTextInfo=="function"?t.getTextInfo():t.textInfo;if(o)return o.direction==="rtl";if(t.script)return w.has(t.script)}let n=e.split("-")[0];return v.has(n)}var r=m(g(),1),u=Symbol.for("react-aria.i18n.locale");function f(){let e=typeof window<"u"&&window[u]||typeof navigator<"u"&&(navigator.language||navigator.userLanguage)||"en-US";try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{e="en-US"}return{locale:e,direction:c(e)?"rtl":"ltr"}}var l=f(),a=new Set;function d(){l=f();for(let e of a)e(l)}function s(){let e=p(),[n,t]=(0,r.useState)(l);return(0,r.useEffect)(()=>(a.size===0&&window.addEventListener("languagechange",d),a.add(t),()=>{a.delete(t),a.size===0&&window.removeEventListener("languagechange",d)}),[]),e?{locale:typeof window<"u"&&window[u]||"en-US",direction:"ltr"}:n}var i=r.createContext(null);function h(e){let{locale:n,children:t}=e,o=r.useMemo(()=>({locale:n,direction:c(n)?"rtl":"ltr"}),[n]);return r.createElement(i.Provider,{value:o},t)}function S(e){let{children:n}=e,t=s();return r.createElement(i.Provider,{value:t},n)}function y(e){let{locale:n,children:t}=e;return n?r.createElement(h,{locale:n,children:t}):r.createElement(S,{children:t})}function b(){let e=s();return(0,r.useContext)(i)||e}export{y as n,b as t};
