/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{k as l}from"./RPU6VCJ4.js";var b=(e,n)=>{let t=e;for(;t;){if(t===n)return!0;if(!t.parentNode)return!1;t.parentNode instanceof ShadowRoot?t=t.parentNode.host:t=t.parentNode}return!1},h=(e,n,t)=>{let s=E(n).subscribe;return s(o=>{o.some(r=>b(e,r.target))&&t()})},u={},E=e=>{let n=e.join(","),t=u[n];if(t!==void 0)return t;let s=new Set,o=new MutationObserver(r=>s.forEach(a=>a(r)));globalThis.document&&o.observe(document.documentElement,{attributes:!0,attributeFilter:e,subtree:!0});let i={subscribe:r=>(s.add(r),()=>{s.delete(r),s.size===0&&(o.disconnect(),u[n]=void 0)})};return u[n]=i,i},g=(e,n)=>{let t=e;for(;t;){let s=t.closest?.(n);if(s)return s;let o=t.getRootNode?.();if(o===globalThis.document)return;t=o.host}};function A(e){let n=g(e,".calcite-mode-dark, .calcite-mode-light, .calcite-mode-auto");return n?.classList.contains("calcite-mode-dark")||n?.classList.contains("calcite-mode-auto")&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var T=e=>d(e,"dir","ltr"),d=(e,n,t)=>g(e,`[${n}]`)?.getAttribute(n)??t;var v="ar,bg,bs,ca,cs,da,de,el,en,es,et,fi,fr,he,hr,hu,id,it,ja,ko,lt,lv,nl,nb,no,pl,pt-BR,pt-PT,ro,ru,sk,sl,sr,sv,th,tr,uk,vi,zh-CN,zh-HK,zh-TW".split(","),C=new Set(v),c="en",N={pt:"pt-PT",nb:"no",nn:"no",zh:"zh-CN"},y=async(e,n,t="")=>{let s=`${n}/${t}`,o=`${s}${e}.json`;return f[o]??(f[o]=m(e,s)),await f[o]},f={},m=async(e,n)=>{let t=`${n}${e}.json`;try{let s=await fetch(t);if(s.ok)return await s.json()}catch(s){return l("error","intl",`An unknown error occurred while fetching localization strings at ${t}`,{detail:{error:s}}),{}}return e===c?{}:await m(c,n)},L=e=>{let n=d(e,"lang",globalThis.navigator?.language||c);return{lang:n,t9nLocale:p(n)}},p=e=>{let[n,t]=e.split("-"),s=n.toLowerCase(),o=s;return t&&(o=`${s}-${t.toUpperCase()}`),o=N[o]??o,C.has(o)?o:t?p(s):c},z=(e,n,t,s)=>{let o,i=()=>w(e,n(),s).then(r=>{(o?.lang!==r.lang||o.t9nLocale!==r.t9nLocale||o.t9nStrings!==r.t9nStrings)&&t(r),o=r}).catch(r=>{l("error","intl","Error updating component locale state",{detail:{error:r}})});return queueMicrotask(i),h(e,["lang"],i)},w=async(e,n,t=e.localName.split("-").slice(1).join("-"))=>{let{lang:s,t9nLocale:o}=L(e),i=`${n}/${t}/t9n`,a=t===null?{}:await y(o,i,"messages.");return{lang:s,t9nLocale:o,t9nStrings:a}};export{h as a,A as b,T as c,C as d,c as e,y as f,L as g,p as h,z as i};
