import{s as x}from"./chunk-DZLz74EQ.js";import{t as E}from"./react-BcIddLXZ.js";var n=x(E(),1),m={prefix:String(Math.round(Math.random()*1e10)),current:0},S=n.createContext(m),h=n.createContext(!1);typeof window<"u"&&window.document&&window.document.createElement;var c=new WeakMap;function y(e=!1){var a,s;let r=(0,n.useContext)(S),t=(0,n.useRef)(null);if(t.current===null&&!e){let o=(s=(a=n.default.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED)==null?void 0:a.ReactCurrentOwner)==null?void 0:s.current;if(o){let u=c.get(o);u==null?c.set(o,{id:r.current,state:o.memoizedState}):o.memoizedState!==u.state&&(r.current=u.id,c.delete(o))}t.current=++r.current}return t.current}function _(e){let r=(0,n.useContext)(S),t=y(!!e),a=`react-aria${r.prefix}`;return e||`${a}-${t}`}function I(e){let r=n.useId(),[t]=(0,n.useState)(l()),a=t?"react-aria":`react-aria${m.prefix}`;return e||`${a}-${r}`}var C=typeof n.useId=="function"?I:_;function L(){return!1}function b(){return!0}function T(e){return()=>{}}function l(){return typeof n.useSyncExternalStore=="function"?n.useSyncExternalStore(T,L,b):(0,n.useContext)(h)}var O=new Set(["Arab","Syrc","Samr","Mand","Thaa","Mend","Nkoo","Adlm","Rohg","Hebr"]),R=new Set(["ae","ar","arc","bcc","bqi","ckb","dv","fa","glk","he","ku","mzn","nqo","pnb","ps","sd","ug","ur","yi"]);function g(e){if(Intl.Locale){let t=new Intl.Locale(e).maximize(),a=typeof t.getTextInfo=="function"?t.getTextInfo():t.textInfo;if(a)return a.direction==="rtl";if(t.script)return O.has(t.script)}let r=e.split("-")[0];return R.has(r)}var z=Symbol.for("react-aria.i18n.locale");function p(){let e=typeof window<"u"&&window[z]||typeof navigator<"u"&&(navigator.language||navigator.userLanguage)||"en-US";try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{e="en-US"}return{locale:e,direction:g(e)?"rtl":"ltr"}}var f=p(),i=new Set;function w(){f=p();for(let e of i)e(f)}function v(){let e=l(),[r,t]=(0,n.useState)(f);return(0,n.useEffect)(()=>(i.size===0&&window.addEventListener("languagechange",w),i.add(t),()=>{i.delete(t),i.size===0&&window.removeEventListener("languagechange",w)}),[]),e?{locale:"en-US",direction:"ltr"}:r}var d=n.createContext(null);function M(e){let{locale:r,children:t}=e,a=n.useMemo(()=>({locale:r,direction:g(r)?"rtl":"ltr"}),[r]);return n.createElement(d.Provider,{value:a},t)}function $(e){let{children:r}=e,t=v();return n.createElement(d.Provider,{value:t},r)}function k(e){let{locale:r,children:t}=e;return r?n.createElement(M,{locale:r,children:t}):n.createElement($,{children:t})}function U(){let e=v();return(0,n.useContext)(d)||e}export{C as i,k as n,l as r,U as t};
