import{G as H,q as $,h as j,_ as I,p as x,F as k,d as A}from"./preact.js";function B(){if(console&&console.warn){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];typeof e[0]=="string"&&(e[0]=`react-i18next:: ${e[0]}`),console.warn(...e)}}const T={};function w(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];typeof e[0]=="string"&&T[e[0]]||(typeof e[0]=="string"&&(T[e[0]]=new Date),B(...e))}const P=(n,e)=>()=>{if(n.isInitialized)e();else{const t=()=>{setTimeout(()=>{n.off("initialized",t)},0),e()};n.on("initialized",t)}};function E(n,e,t){n.loadNamespaces(e,P(n,t))}function F(n,e,t,i){typeof t=="string"&&(t=[t]),t.forEach(r=>{n.options.ns.indexOf(r)<0&&n.options.ns.push(r)}),n.loadLanguages(e,P(n,i))}function O(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=e.languages[0],r=e.options?e.options.fallbackLng:!1,s=e.languages[e.languages.length-1];if(i.toLowerCase()==="cimode")return!0;const l=(y,b)=>{const a=e.services.backendConnector.state[`${y}|${b}`];return a===-1||a===2};return t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&e.services.backendConnector.backend&&e.isLanguageChangingTo&&!l(e.isLanguageChangingTo,n)?!1:!!(e.hasResourceBundle(i,n)||!e.services.backendConnector.backend||e.options.resources&&!e.options.partialBundledLanguages||l(i,n)&&(!r||l(s,n)))}function U(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!e.languages||!e.languages.length?(w("i18n.languages were undefined or empty",e.languages),!0):e.options.ignoreJSONStructure!==void 0?e.hasLoadedNamespace(n,{lng:t.lng,precheck:(r,s)=>{if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&r.services.backendConnector.backend&&r.isLanguageChangingTo&&!s(r.isLanguageChangingTo,n))return!1}}):O(n,e,t)}const q=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,J={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},M=n=>J[n],W=n=>n.replace(q,M);let C={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:W};function G(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};C={...C,...n}}function K(){return C}let R;function Y(n){R=n}function Q(){return R}const V={type:"3rdParty",init(n){G(n.options.react),Y(n)}},z=H();class X{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(t=>{this.usedNamespaces[t]||(this.usedNamespaces[t]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const Z=(n,e)=>{const t=I();return x(()=>{t.current=e?t.current:n},[n,e]),t.current};function _(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:t}=e,{i18n:i,defaultNS:r}=$(z)||{},s=t||i||Q();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new X),!s){w("You will need to pass in an i18next instance by using initReactI18next");const o=(d,u)=>typeof u=="string"?u:u&&typeof u=="object"&&typeof u.defaultValue=="string"?u.defaultValue:Array.isArray(d)?d[d.length-1]:d,c=[o,{},!1];return c.t=o,c.i18n={},c.ready=!1,c}s.options.react&&s.options.react.wait!==void 0&&w("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const l={...K(),...s.options.react,...e},{useSuspense:y,keyPrefix:b}=l;let a=n||r||s.options&&s.options.defaultNS;a=typeof a=="string"?[a]:a||["translation"],s.reportNamespaces.addUsedNamespaces&&s.reportNamespaces.addUsedNamespaces(a);const g=(s.isInitialized||s.initializedStoreOnce)&&a.every(o=>U(o,s,l));function p(){return s.getFixedT(e.lng||null,l.nsMode==="fallback"?a:a[0],b)}const[S,m]=j(p);let h=a.join();e.lng&&(h=`${e.lng}${h}`);const L=Z(h),f=I(!0);x(()=>{const{bindI18n:o,bindI18nStore:c}=l;f.current=!0,!g&&!y&&(e.lng?F(s,e.lng,a,()=>{f.current&&m(p)}):E(s,a,()=>{f.current&&m(p)})),g&&L&&L!==h&&f.current&&m(p);function d(){f.current&&m(p)}return o&&s&&s.on(o,d),c&&s&&s.store.on(c,d),()=>{f.current=!1,o&&s&&o.split(" ").forEach(u=>s.off(u,d)),c&&s&&c.split(" ").forEach(u=>s.store.off(u,d))}},[s,h]);const v=I(!0);x(()=>{f.current&&!v.current&&m(p),v.current=!1},[s,b]);const N=[S,s,g];if(N.t=S,N.i18n=s,N.ready=g,g||!g&&!y)return N;throw new Promise(o=>{e.lng?F(s,e.lng,a,()=>o()):E(s,a,()=>o())})}function ee(n){let{i18n:e,defaultNS:t,children:i}=n;const r=k(()=>({i18n:e,defaultNS:t}),[e,t]);return A(z.Provider,{value:r},i)}export{ee as I,V as i,_ as u};
