@betterstore/react
Version:
1 lines • 988 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),m=require("react/jsx-runtime"),cs=require("react-dom");function Hc(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const n=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(e,a,n.get?n:{enumerable:!0,get:()=>t[a]})}}return e.default=t,Object.freeze(e)}const g=Hc(i),jc=Hc(cs),x1=t=>{let e;const a=new Set,n=(c,h)=>{const u=typeof c=="function"?c(e):c;if(!Object.is(u,e)){const p=e;e=h??(typeof u!="object"||u===null)?u:Object.assign({},e,u),a.forEach(f=>f(e,p))}},r=()=>e,s={setState:n,getState:r,getInitialState:()=>d,subscribe:c=>(a.add(c),()=>a.delete(c))},d=e=t(n,r,s);return s},pp=(t=>t?x1(t):x1),mp=t=>t;function fp(t,e=mp){const a=i.useSyncExternalStore(t.subscribe,i.useCallback(()=>e(t.getState()),[t,e]),i.useCallback(()=>e(t.getInitialState()),[t,e]));return i.useDebugValue(a),a}const w1=t=>{const e=pp(t),a=n=>fp(e,n);return Object.assign(a,e),a},us=(t=>t?w1(t):w1);function vp(t,e){let a;try{a=t()}catch{return}return{getItem:r=>{var l;const o=d=>d===null?null:JSON.parse(d,void 0),s=(l=a.getItem(r))!=null?l:null;return s instanceof Promise?s.then(o):o(s)},setItem:(r,l)=>a.setItem(r,JSON.stringify(l,void 0)),removeItem:r=>a.removeItem(r)}}const po=t=>e=>{try{const a=t(e);return a instanceof Promise?a:{then(n){return po(n)(a)},catch(n){return this}}}catch(a){return{then(n){return this},catch(n){return po(n)(a)}}}},gp=(t,e)=>(a,n,r)=>{let l={storage:vp(()=>localStorage),partialize:v=>v,version:0,merge:(v,$)=>({...$,...v}),...e},o=!1,s=0;const d=new Set,c=new Set;let h=l.storage;if(!h)return t((...v)=>{console.warn(`[zustand persist middleware] Unable to update item '${l.name}', the given storage is currently unavailable.`),a(...v)},n,r);const u=()=>{const v=l.partialize({...n()});return h.setItem(l.name,{state:v,version:l.version})},p=r.setState;r.setState=(v,$)=>(p(v,$),u());const f=t((...v)=>(a(...v),u()),n,r);r.getInitialState=()=>f;let b;const y=()=>{var v,$;if(!h)return;const C=++s;o=!1,d.forEach(z=>{var x;return z((x=n())!=null?x:f)});const F=(($=l.onRehydrateStorage)==null?void 0:$.call(l,(v=n())!=null?v:f))||void 0;return po(h.getItem.bind(h))(l.name).then(z=>{if(z)if(typeof z.version=="number"&&z.version!==l.version){if(l.migrate){const x=l.migrate(z.state,z.version);return x instanceof Promise?x.then(M=>[!0,M]):[!0,x]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,z.state];return[!1,void 0]}).then(z=>{var x;if(C!==s)return;const[M,k]=z;if(b=l.merge(k,(x=n())!=null?x:f),a(b,!0),M)return u()}).then(()=>{C===s&&(F?.(b,void 0),b=n(),o=!0,c.forEach(z=>z(b)))}).catch(z=>{C===s&&F?.(void 0,z)})};return r.persist={setOptions:v=>{l={...l,...v},v.storage&&(h=v.storage)},clearStorage:()=>{h?.removeItem(l.name)},getOptions:()=>l,rehydrate:()=>y(),hasHydrated:()=>o,onHydrate:v=>(d.add(v),()=>{d.delete(v)}),onFinishHydration:v=>(c.add(v),()=>{c.delete(v)})},l.skipHydration||y(),b||f},Bc=gp,yp=t=>btoa(JSON.stringify({productId:t.productId,variantOptions:t.variantOptions,metadata:t.metadata})),bp=(t,e)=>!e||e.length===0?null:t.find(a=>a.variantOptions?.every(n=>e.some(r=>n.name===r.name&&n.value===r.value)))||null,xp=(t,e)=>{const a=bp(t.productVariants??[],e?.variantOptions);return{productId:t.id,productData:t,quantity:e?.quantity??1,selectedVariant:a,variantOptions:e?.variantOptions??[],metadata:e?.metadata}},wp=(t,e)=>t.findIndex(a=>a.id===e),Ep=(t,e,a)=>{const n=[...t];return n[e]={...n[e],quantity:n[e].quantity+a},n},$p=(t,e)=>[...t,e],Cp=()=>us()(Bc((t,e)=>({lineItems:[],addItem:(a,n)=>t(r=>{const l=xp(a,n),o=yp(l),s=wp(r.lineItems,o);if(s!==-1)return{lineItems:Ep(r.lineItems,s,l.quantity)};const d={...l,id:o};return{lineItems:$p(r.lineItems,d)}}),removeItem:a=>t(n=>({lineItems:n.lineItems.filter(r=>r.id!==a)})),updateQuantity:(a,n)=>t(r=>({lineItems:r.lineItems.map(l=>l.id===a?{...l,quantity:n}:l)})),getProductQuantity:a=>e().lineItems.filter(r=>r.productId===a).reduce((r,l)=>r+l.quantity,0),clearCart:()=>t({lineItems:[]})}),{name:"cart"})),Sp=()=>Cp()(),ye=t=>typeof t=="string",Rn=()=>{let t,e;const a=new Promise((n,r)=>{t=n,e=r});return a.resolve=t,a.reject=e,a},E1=t=>t==null?"":""+t,zp=(t,e,a)=>{t.forEach(n=>{e[n]&&(a[n]=e[n])})},Mp=/###/g,$1=t=>t&&t.indexOf("###")>-1?t.replace(Mp,"."):t,C1=t=>!t||ye(t),Un=(t,e,a)=>{const n=ye(e)?e.split("."):e;let r=0;for(;r<n.length-1;){if(C1(t))return{};const l=$1(n[r]);!t[l]&&a&&(t[l]=new a),Object.prototype.hasOwnProperty.call(t,l)?t=t[l]:t={},++r}return C1(t)?{}:{obj:t,k:$1(n[r])}},S1=(t,e,a)=>{const{obj:n,k:r}=Un(t,e,Object);if(n!==void 0||e.length===1){n[r]=a;return}let l=e[e.length-1],o=e.slice(0,e.length-1),s=Un(t,o,Object);for(;s.obj===void 0&&o.length;)l=`${o[o.length-1]}.${l}`,o=o.slice(0,o.length-1),s=Un(t,o,Object),s?.obj&&typeof s.obj[`${s.k}.${l}`]<"u"&&(s.obj=void 0);s.obj[`${s.k}.${l}`]=a},kp=(t,e,a,n)=>{const{obj:r,k:l}=Un(t,e,Object);r[l]=r[l]||[],r[l].push(a)},Yr=(t,e)=>{const{obj:a,k:n}=Un(t,e);if(a&&Object.prototype.hasOwnProperty.call(a,n))return a[n]},Fp=(t,e,a)=>{const n=Yr(t,a);return n!==void 0?n:Yr(e,a)},Vc=(t,e,a)=>{for(const n in e)n!=="__proto__"&&n!=="constructor"&&(n in t?ye(t[n])||t[n]instanceof String||ye(e[n])||e[n]instanceof String?a&&(t[n]=e[n]):Vc(t[n],e[n],a):t[n]=e[n]);return t},Ba=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Np={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Pp=t=>ye(t)?t.replace(/[&<>"'\/]/g,e=>Np[e]):t;class Ap{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const a=this.regExpMap.get(e);if(a!==void 0)return a;const n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}}const _p=[" ",",","?","!",";"],Op=new Ap(20),Tp=(t,e,a)=>{e=e||"",a=a||"";const n=_p.filter(o=>e.indexOf(o)<0&&a.indexOf(o)<0);if(n.length===0)return!0;const r=Op.getRegExp(`(${n.map(o=>o==="?"?"\\?":o).join("|")})`);let l=!r.test(t);if(!l){const o=t.indexOf(a);o>0&&!r.test(t.substring(0,o))&&(l=!0)}return l},mo=function(t,e){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const n=e.split(a);let r=t;for(let l=0;l<n.length;){if(!r||typeof r!="object")return;let o,s="";for(let d=l;d<n.length;++d)if(d!==l&&(s+=a),s+=n[d],o=r[s],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&d<n.length-1)continue;l+=d-l+1;break}r=o}return r},Xr=t=>t?.replace("_","-"),Rp={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){console?.[t]?.apply?.(console,e)}};class Jr{constructor(e){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,a)}init(e){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=a.prefix||"i18next:",this.logger=e||Rp,this.options=a,this.debug=a.debug}log(){for(var e=arguments.length,a=new Array(e),n=0;n<e;n++)a[n]=arguments[n];return this.forward(a,"log","",!0)}warn(){for(var e=arguments.length,a=new Array(e),n=0;n<e;n++)a[n]=arguments[n];return this.forward(a,"warn","",!0)}error(){for(var e=arguments.length,a=new Array(e),n=0;n<e;n++)a[n]=arguments[n];return this.forward(a,"error","")}deprecate(){for(var e=arguments.length,a=new Array(e),n=0;n<e;n++)a[n]=arguments[n];return this.forward(a,"warn","WARNING DEPRECATED: ",!0)}forward(e,a,n,r){return r&&!this.debug?null:(ye(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[a](e))}create(e){return new Jr(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Jr(this.logger,e)}}var Vt=new Jr;class _i{constructor(){this.observers={}}on(e,a){return e.split(" ").forEach(n=>{this.observers[n]||(this.observers[n]=new Map);const r=this.observers[n].get(a)||0;this.observers[n].set(a,r+1)}),this}off(e,a){if(this.observers[e]){if(!a){delete this.observers[e];return}this.observers[e].delete(a)}}emit(e){for(var a=arguments.length,n=new Array(a>1?a-1:0),r=1;r<a;r++)n[r-1]=arguments[r];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(o=>{let[s,d]=o;for(let c=0;c<d;c++)s(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(o=>{let[s,d]=o;for(let c=0;c<d;c++)s.apply(s,[e,...n])})}}class z1 extends _i{constructor(e){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=a,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const a=this.options.ns.indexOf(e);a>-1&&this.options.ns.splice(a,1)}getResource(e,a,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const l=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,o=r.ignoreJSONStructure!==void 0?r.ignoreJSONStructure:this.options.ignoreJSONStructure;let s;e.indexOf(".")>-1?s=e.split("."):(s=[e,a],n&&(Array.isArray(n)?s.push(...n):ye(n)&&l?s.push(...n.split(l)):s.push(n)));const d=Yr(this.data,s);return!d&&!a&&!n&&e.indexOf(".")>-1&&(e=s[0],a=s[1],n=s.slice(2).join(".")),d||!o||!ye(n)?d:mo(this.data?.[e]?.[a],n,l)}addResource(e,a,n,r){let l=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const o=l.keySeparator!==void 0?l.keySeparator:this.options.keySeparator;let s=[e,a];n&&(s=s.concat(o?n.split(o):n)),e.indexOf(".")>-1&&(s=e.split("."),r=a,a=s[1]),this.addNamespaces(a),S1(this.data,s,r),l.silent||this.emit("added",e,a,n,r)}addResources(e,a,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const l in n)(ye(n[l])||Array.isArray(n[l]))&&this.addResource(e,a,l,n[l],{silent:!0});r.silent||this.emit("added",e,a,n)}addResourceBundle(e,a,n,r,l){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},s=[e,a];e.indexOf(".")>-1&&(s=e.split("."),r=n,n=a,a=s[1]),this.addNamespaces(a);let d=Yr(this.data,s)||{};o.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?Vc(d,n,l):d={...d,...n},S1(this.data,s,d),o.silent||this.emit("added",e,a,n)}removeResourceBundle(e,a){this.hasResourceBundle(e,a)&&delete this.data[e][a],this.removeNamespaces(a),this.emit("removed",e,a)}hasResourceBundle(e,a){return this.getResource(e,a)!==void 0}getResourceBundle(e,a){return a||(a=this.options.defaultNS),this.getResource(e,a)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const a=this.getDataByLanguage(e);return!!(a&&Object.keys(a)||[]).find(r=>a[r]&&Object.keys(a[r]).length>0)}toJSON(){return this.data}}var Uc={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,a,n,r){return t.forEach(l=>{e=this.processors[l]?.process(e,a,n,r)??e}),e}};const M1={},k1=t=>!ye(t)&&typeof t!="boolean"&&typeof t!="number";class Qr extends _i{constructor(e){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),zp(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=a,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Vt.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};return e==null?!1:this.resolve(e,a)?.res!==void 0}extractFromKey(e,a){let n=a.nsSeparator!==void 0?a.nsSeparator:this.options.nsSeparator;n===void 0&&(n=":");const r=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let l=a.ns||this.options.defaultNS||[];const o=n&&e.indexOf(n)>-1,s=!this.options.userDefinedKeySeparator&&!a.keySeparator&&!this.options.userDefinedNsSeparator&&!a.nsSeparator&&!Tp(e,n,r);if(o&&!s){const d=e.match(this.interpolator.nestingRegexp);if(d&&d.length>0)return{key:e,namespaces:ye(l)?[l]:l};const c=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(c[0])>-1)&&(l=c.shift()),e=c.join(r)}return{key:e,namespaces:ye(l)?[l]:l}}translate(e,a,n){if(typeof a!="object"&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),typeof a=="object"&&(a={...a}),a||(a={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const r=a.returnDetails!==void 0?a.returnDetails:this.options.returnDetails,l=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,{key:o,namespaces:s}=this.extractFromKey(e[e.length-1],a),d=s[s.length-1],c=a.lng||this.language,h=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(c?.toLowerCase()==="cimode"){if(h){const ee=a.nsSeparator||this.options.nsSeparator;return r?{res:`${d}${ee}${o}`,usedKey:o,exactUsedKey:o,usedLng:c,usedNS:d,usedParams:this.getUsedParamsDetails(a)}:`${d}${ee}${o}`}return r?{res:o,usedKey:o,exactUsedKey:o,usedLng:c,usedNS:d,usedParams:this.getUsedParamsDetails(a)}:o}const u=this.resolve(e,a);let p=u?.res;const f=u?.usedKey||o,b=u?.exactUsedKey||o,y=["[object Number]","[object Function]","[object RegExp]"],v=a.joinArrays!==void 0?a.joinArrays:this.options.joinArrays,$=!this.i18nFormat||this.i18nFormat.handleAsObject,C=a.count!==void 0&&!ye(a.count),F=Qr.hasDefaultValue(a),z=C?this.pluralResolver.getSuffix(c,a.count,a):"",x=a.ordinal&&C?this.pluralResolver.getSuffix(c,a.count,{ordinal:!1}):"",M=C&&!a.ordinal&&a.count===0,k=M&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${z}`]||a[`defaultValue${x}`]||a.defaultValue;let O=p;$&&!p&&F&&(O=k);const B=k1(O),K=Object.prototype.toString.apply(O);if($&&O&&B&&y.indexOf(K)<0&&!(ye(v)&&Array.isArray(O))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const ee=this.options.returnedObjectHandler?this.options.returnedObjectHandler(f,O,{...a,ns:s}):`key '${o} (${this.language})' returned an object instead of string.`;return r?(u.res=ee,u.usedParams=this.getUsedParamsDetails(a),u):ee}if(l){const ee=Array.isArray(O),V=ee?[]:{},G=ee?b:f;for(const W in O)if(Object.prototype.hasOwnProperty.call(O,W)){const Z=`${G}${l}${W}`;F&&!p?V[W]=this.translate(Z,{...a,defaultValue:k1(k)?k[W]:void 0,joinArrays:!1,ns:s}):V[W]=this.translate(Z,{...a,joinArrays:!1,ns:s}),V[W]===Z&&(V[W]=O[W])}p=V}}else if($&&ye(v)&&Array.isArray(p))p=p.join(v),p&&(p=this.extendTranslation(p,e,a,n));else{let ee=!1,V=!1;!this.isValidLookup(p)&&F&&(ee=!0,p=k),this.isValidLookup(p)||(V=!0,p=o);const W=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&V?void 0:p,Z=F&&k!==p&&this.options.updateMissing;if(V||ee||Z){if(this.logger.log(Z?"updateKey":"missingKey",c,d,o,Z?k:p),l){const le=this.resolve(o,{...a,keySeparator:!1});le&&le.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let j=[];const D=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo==="fallback"&&D&&D[0])for(let le=0;le<D.length;le++)j.push(D[le]);else this.options.saveMissingTo==="all"?j=this.languageUtils.toResolveHierarchy(a.lng||this.language):j.push(a.lng||this.language);const H=(le,P,T)=>{const A=F&&T!==p?T:W;this.options.missingKeyHandler?this.options.missingKeyHandler(le,d,P,A,Z,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(le,d,P,A,Z,a),this.emit("missingKey",le,d,P,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&C?j.forEach(le=>{const P=this.pluralResolver.getSuffixes(le,a);M&&a[`defaultValue${this.options.pluralSeparator}zero`]&&P.indexOf(`${this.options.pluralSeparator}zero`)<0&&P.push(`${this.options.pluralSeparator}zero`),P.forEach(T=>{H([le],o+T,a[`defaultValue${T}`]||k)})}):H(j,o,k))}p=this.extendTranslation(p,e,a,u,n),V&&p===o&&this.options.appendNamespaceToMissingKey&&(p=`${d}:${o}`),(V||ee)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}:${o}`:o,ee?p:void 0))}return r?(u.res=p,u.usedParams=this.getUsedParamsDetails(a),u):p}extendTranslation(e,a,n,r,l){var o=this;if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});const c=ye(e)&&(n?.interpolation?.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let h;if(c){const p=e.match(this.interpolator.nestingRegexp);h=p&&p.length}let u=n.replace&&!ye(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(u={...this.options.interpolation.defaultVariables,...u}),e=this.interpolator.interpolate(e,u,n.lng||this.language||r.usedLng,n),c){const p=e.match(this.interpolator.nestingRegexp),f=p&&p.length;h<f&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),n.nest!==!1&&(e=this.interpolator.nest(e,function(){for(var p=arguments.length,f=new Array(p),b=0;b<p;b++)f[b]=arguments[b];return l?.[0]===f[0]&&!n.context?(o.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${a[0]}`),null):o.translate(...f,a)},n)),n.interpolation&&this.interpolator.reset()}const s=n.postProcess||this.options.postProcess,d=ye(s)?[s]:s;return e!=null&&d?.length&&n.applyPostProcessor!==!1&&(e=Uc.handle(d,e,a,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n,r,l,o,s;return ye(e)&&(e=[e]),e.forEach(d=>{if(this.isValidLookup(n))return;const c=this.extractFromKey(d,a),h=c.key;r=h;let u=c.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));const p=a.count!==void 0&&!ye(a.count),f=p&&!a.ordinal&&a.count===0,b=a.context!==void 0&&(ye(a.context)||typeof a.context=="number")&&a.context!=="",y=a.lngs?a.lngs:this.languageUtils.toResolveHierarchy(a.lng||this.language,a.fallbackLng);u.forEach(v=>{this.isValidLookup(n)||(s=v,!M1[`${y[0]}-${v}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(s)&&(M1[`${y[0]}-${v}`]=!0,this.logger.warn(`key "${r}" for languages "${y.join(", ")}" won't get resolved as namespace "${s}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),y.forEach($=>{if(this.isValidLookup(n))return;o=$;const C=[h];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(C,h,$,v,a);else{let z;p&&(z=this.pluralResolver.getSuffix($,a.count,a));const x=`${this.options.pluralSeparator}zero`,M=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(C.push(h+z),a.ordinal&&z.indexOf(M)===0&&C.push(h+z.replace(M,this.options.pluralSeparator)),f&&C.push(h+x)),b){const k=`${h}${this.options.contextSeparator}${a.context}`;C.push(k),p&&(C.push(k+z),a.ordinal&&z.indexOf(M)===0&&C.push(k+z.replace(M,this.options.pluralSeparator)),f&&C.push(k+x))}}let F;for(;F=C.pop();)this.isValidLookup(n)||(l=F,n=this.getResource($,v,F,a))}))})}),{res:n,usedKey:r,exactUsedKey:l,usedLng:o,usedNS:s}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,a,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,a,n,r):this.resourceStore.getResource(e,a,n,r)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const a=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],n=e.replace&&!ye(e.replace);let r=n?e.replace:e;if(n&&typeof e.count<"u"&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!n){r={...r};for(const l of a)delete r[l]}return r}static hasDefaultValue(e){const a="defaultValue";for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&a===n.substring(0,a.length)&&e[n]!==void 0)return!0;return!1}}class F1{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Vt.create("languageUtils")}getScriptPartFromCode(e){if(e=Xr(e),!e||e.indexOf("-")<0)return null;const a=e.split("-");return a.length===2||(a.pop(),a[a.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(a.join("-"))}getLanguagePartFromCode(e){if(e=Xr(e),!e||e.indexOf("-")<0)return e;const a=e.split("-");return this.formatLanguageCode(a[0])}formatLanguageCode(e){if(ye(e)&&e.indexOf("-")>-1){let a;try{a=Intl.getCanonicalLocales(e)[0]}catch{}return a&&this.options.lowerCaseLng&&(a=a.toLowerCase()),a||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let a;return e.forEach(n=>{if(a)return;const r=this.formatLanguageCode(n);(!this.options.supportedLngs||this.isSupportedCode(r))&&(a=r)}),!a&&this.options.supportedLngs&&e.forEach(n=>{if(a)return;const r=this.getLanguagePartFromCode(n);if(this.isSupportedCode(r))return a=r;a=this.options.supportedLngs.find(l=>{if(l===r)return l;if(!(l.indexOf("-")<0&&r.indexOf("-")<0)&&(l.indexOf("-")>0&&r.indexOf("-")<0&&l.substring(0,l.indexOf("-"))===r||l.indexOf(r)===0&&r.length>1))return l})}),a||(a=this.getFallbackCodes(this.options.fallbackLng)[0]),a}getFallbackCodes(e,a){if(!e)return[];if(typeof e=="function"&&(e=e(a)),ye(e)&&(e=[e]),Array.isArray(e))return e;if(!a)return e.default||[];let n=e[a];return n||(n=e[this.getScriptPartFromCode(a)]),n||(n=e[this.formatLanguageCode(a)]),n||(n=e[this.getLanguagePartFromCode(a)]),n||(n=e.default),n||[]}toResolveHierarchy(e,a){const n=this.getFallbackCodes(a||this.options.fallbackLng||[],e),r=[],l=o=>{o&&(this.isSupportedCode(o)?r.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return ye(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&l(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&l(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&l(this.getLanguagePartFromCode(e))):ye(e)&&l(this.formatLanguageCode(e)),n.forEach(o=>{r.indexOf(o)<0&&l(this.formatLanguageCode(o))}),r}}const N1={zero:0,one:1,two:2,few:3,many:4,other:5},P1={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Ip{constructor(e){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=a,this.logger=Vt.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,a){this.rules[e]=a}clearCache(){this.pluralRulesCache={}}getRule(e){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=Xr(e==="dev"?"en":e),r=a.ordinal?"ordinal":"cardinal",l=JSON.stringify({cleanedCode:n,type:r});if(l in this.pluralRulesCache)return this.pluralRulesCache[l];let o;try{o=new Intl.PluralRules(n,{type:r})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),P1;if(!e.match(/-|_/))return P1;const d=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(d,a)}return this.pluralRulesCache[l]=o,o}needsPlural(e){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=this.getRule(e,a);return n||(n=this.getRule("dev",a)),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,a){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,n).map(r=>`${a}${r}`)}getSuffixes(e){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=this.getRule(e,a);return n||(n=this.getRule("dev",a)),n?n.resolvedOptions().pluralCategories.sort((r,l)=>N1[r]-N1[l]).map(r=>`${this.options.prepend}${a.ordinal?`ordinal${this.options.prepend}`:""}${r}`):[]}getSuffix(e,a){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${r.select(a)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",a,n))}}const A1=function(t,e,a){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",r=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,l=Fp(t,e,a);return!l&&r&&ye(a)&&(l=mo(t,a,n),l===void 0&&(l=mo(e,a,n))),l},ml=t=>t.replace(/\$/g,"$$$$");class Dp{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Vt.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(a=>a),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});const{escape:a,escapeValue:n,useRawValueToEscape:r,prefix:l,prefixEscaped:o,suffix:s,suffixEscaped:d,formatSeparator:c,unescapeSuffix:h,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:f,nestingSuffix:b,nestingSuffixEscaped:y,nestingOptionsSeparator:v,maxReplaces:$,alwaysFormat:C}=e.interpolation;this.escape=a!==void 0?a:Pp,this.escapeValue=n!==void 0?n:!0,this.useRawValueToEscape=r!==void 0?r:!1,this.prefix=l?Ba(l):o||"{{",this.suffix=s?Ba(s):d||"}}",this.formatSeparator=c||",",this.unescapePrefix=h?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=p?Ba(p):f||Ba("$t("),this.nestingSuffix=b?Ba(b):y||Ba(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=$||1e3,this.alwaysFormat=C!==void 0?C:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(a,n)=>a?.source===n?(a.lastIndex=0,a):new RegExp(n,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(e,a,n,r){let l,o,s;const d=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=f=>{if(f.indexOf(this.formatSeparator)<0){const $=A1(a,d,f,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format($,void 0,n,{...r,...a,interpolationkey:f}):$}const b=f.split(this.formatSeparator),y=b.shift().trim(),v=b.join(this.formatSeparator).trim();return this.format(A1(a,d,y,this.options.keySeparator,this.options.ignoreJSONStructure),v,n,{...r,...a,interpolationkey:y})};this.resetRegExp();const h=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:f=>ml(f)},{regex:this.regexp,safeValue:f=>this.escapeValue?ml(this.escape(f)):ml(f)}].forEach(f=>{for(s=0;l=f.regex.exec(e);){const b=l[1].trim();if(o=c(b),o===void 0)if(typeof h=="function"){const v=h(e,l,r);o=ye(v)?v:""}else if(r&&Object.prototype.hasOwnProperty.call(r,b))o="";else if(u){o=l[0];continue}else this.logger.warn(`missed to pass in variable ${b} for interpolating ${e}`),o="";else!ye(o)&&!this.useRawValueToEscape&&(o=E1(o));const y=f.safeValue(o);if(e=e.replace(l[0],y),u?(f.regex.lastIndex+=o.length,f.regex.lastIndex-=l[0].length):f.regex.lastIndex=0,s++,s>=this.maxReplaces)break}}),e}nest(e,a){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r,l,o;const s=(d,c)=>{const h=this.nestingOptionsSeparator;if(d.indexOf(h)<0)return d;const u=d.split(new RegExp(`${h}[ ]*{`));let p=`{${u[1]}`;d=u[0],p=this.interpolate(p,o);const f=p.match(/'/g),b=p.match(/"/g);((f?.length??0)%2===0&&!b||b.length%2!==0)&&(p=p.replace(/'/g,'"'));try{o=JSON.parse(p),c&&(o={...c,...o})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${d}`,y),`${d}${h}${p}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,d};for(;r=this.nestingRegexp.exec(e);){let d=[];o={...n},o=o.replace&&!ye(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;let c=!1;if(r[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(r[1])){const h=r[1].split(this.formatSeparator).map(u=>u.trim());r[1]=h.shift(),d=h,c=!0}if(l=a(s.call(this,r[1].trim(),o),o),l&&r[0]===e&&!ye(l))return l;ye(l)||(l=E1(l)),l||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),l=""),c&&(l=d.reduce((h,u)=>this.format(h,u,n.lng,{...n,interpolationkey:r[1].trim()}),l.trim())),e=e.replace(r[0],l),this.regexp.lastIndex=0}return e}}const Lp=t=>{let e=t.toLowerCase().trim();const a={};if(t.indexOf("(")>-1){const n=t.split("(");e=n[0].toLowerCase().trim();const r=n[1].substring(0,n[1].length-1);e==="currency"&&r.indexOf(":")<0?a.currency||(a.currency=r.trim()):e==="relativetime"&&r.indexOf(":")<0?a.range||(a.range=r.trim()):r.split(";").forEach(o=>{if(o){const[s,...d]=o.split(":"),c=d.join(":").trim().replace(/^'+|'+$/g,""),h=s.trim();a[h]||(a[h]=c),c==="false"&&(a[h]=!1),c==="true"&&(a[h]=!0),isNaN(c)||(a[h]=parseInt(c,10))}})}return{formatName:e,formatOptions:a}},Va=t=>{const e={};return(a,n,r)=>{let l=r;r&&r.interpolationkey&&r.formatParams&&r.formatParams[r.interpolationkey]&&r[r.interpolationkey]&&(l={...l,[r.interpolationkey]:void 0});const o=n+JSON.stringify(l);let s=e[o];return s||(s=t(Xr(n),r),e[o]=s),s(a)}};class Hp{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Vt.create("formatter"),this.options=e,this.formats={number:Va((a,n)=>{const r=new Intl.NumberFormat(a,{...n});return l=>r.format(l)}),currency:Va((a,n)=>{const r=new Intl.NumberFormat(a,{...n,style:"currency"});return l=>r.format(l)}),datetime:Va((a,n)=>{const r=new Intl.DateTimeFormat(a,{...n});return l=>r.format(l)}),relativetime:Va((a,n)=>{const r=new Intl.RelativeTimeFormat(a,{...n});return l=>r.format(l,n.range||"day")}),list:Va((a,n)=>{const r=new Intl.ListFormat(a,{...n});return l=>r.format(l)})},this.init(e)}init(e){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=a.interpolation.formatSeparator||","}add(e,a){this.formats[e.toLowerCase().trim()]=a}addCached(e,a){this.formats[e.toLowerCase().trim()]=Va(a)}format(e,a,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const l=a.split(this.formatSeparator);if(l.length>1&&l[0].indexOf("(")>1&&l[0].indexOf(")")<0&&l.find(s=>s.indexOf(")")>-1)){const s=l.findIndex(d=>d.indexOf(")")>-1);l[0]=[l[0],...l.splice(1,s)].join(this.formatSeparator)}return l.reduce((s,d)=>{const{formatName:c,formatOptions:h}=Lp(d);if(this.formats[c]){let u=s;try{const p=r?.formatParams?.[r.interpolationkey]||{},f=p.locale||p.lng||r.locale||r.lng||n;u=this.formats[c](s,f,{...h,...r,...p})}catch(p){this.logger.warn(p)}return u}else this.logger.warn(`there was no format function for ${c}`);return s},e)}}const jp=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Bp extends _i{constructor(e,a,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=a,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=Vt.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,a,n,r){const l={},o={},s={},d={};return e.forEach(c=>{let h=!0;a.forEach(u=>{const p=`${c}|${u}`;!n.reload&&this.store.hasResourceBundle(c,u)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?o[p]===void 0&&(o[p]=!0):(this.state[p]=1,h=!1,o[p]===void 0&&(o[p]=!0),l[p]===void 0&&(l[p]=!0),d[u]===void 0&&(d[u]=!0)))}),h||(s[c]=!0)}),(Object.keys(l).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(l),pending:Object.keys(o),toLoadLanguages:Object.keys(s),toLoadNamespaces:Object.keys(d)}}loaded(e,a,n){const r=e.split("|"),l=r[0],o=r[1];a&&this.emit("failedLoading",l,o,a),!a&&n&&this.store.addResourceBundle(l,o,n,void 0,void 0,{skipCopy:!0}),this.state[e]=a?-1:2,a&&n&&(this.state[e]=0);const s={};this.queue.forEach(d=>{kp(d.loaded,[l],o),jp(d,e),a&&d.errors.push(a),d.pendingCount===0&&!d.done&&(Object.keys(d.loaded).forEach(c=>{s[c]||(s[c]={});const h=d.loaded[c];h.length&&h.forEach(u=>{s[c][u]===void 0&&(s[c][u]=!0)})}),d.done=!0,d.errors.length?d.callback(d.errors):d.callback())}),this.emit("loaded",s),this.queue=this.queue.filter(d=>!d.done)}read(e,a,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,l=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:a,fcName:n,tried:r,wait:l,callback:o});return}this.readingCalls++;const s=(c,h)=>{if(this.readingCalls--,this.waitingReads.length>0){const u=this.waitingReads.shift();this.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback)}if(c&&h&&r<this.maxRetries){setTimeout(()=>{this.read.call(this,e,a,n,r+1,l*2,o)},l);return}o(c,h)},d=this.backend[n].bind(this.backend);if(d.length===2){try{const c=d(e,a);c&&typeof c.then=="function"?c.then(h=>s(null,h)).catch(s):s(null,c)}catch(c){s(c)}return}return d(e,a,s)}prepareLoading(e,a){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();ye(e)&&(e=this.languageUtils.toResolveHierarchy(e)),ye(a)&&(a=[a]);const l=this.queueLoad(e,a,n,r);if(!l.toLoad.length)return l.pending.length||r(),null;l.toLoad.forEach(o=>{this.loadOne(o)})}load(e,a,n){this.prepareLoading(e,a,{},n)}reload(e,a,n){this.prepareLoading(e,a,{reload:!0},n)}loadOne(e){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const n=e.split("|"),r=n[0],l=n[1];this.read(r,l,"read",void 0,void 0,(o,s)=>{o&&this.logger.warn(`${a}loading namespace ${l} for language ${r} failed`,o),!o&&s&&this.logger.log(`${a}loaded namespace ${l} for language ${r}`,s),this.loaded(e,o,s)})}saveMissing(e,a,n,r,l){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},s=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(a)){this.logger.warn(`did not save key "${n}" as the namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(n==null||n==="")){if(this.backend?.create){const d={...o,isUpdate:l},c=this.backend.create.bind(this.backend);if(c.length<6)try{let h;c.length===5?h=c(e,a,n,r,d):h=c(e,a,n,r),h&&typeof h.then=="function"?h.then(u=>s(null,u)).catch(s):s(null,h)}catch(h){s(h)}else c(e,a,n,r,s,d)}!e||!e[0]||this.store.addResource(e[0],a,n,r)}}}const _1=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),ye(t[1])&&(e.defaultValue=t[1]),ye(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const a=t[3]||t[2];Object.keys(a).forEach(n=>{e[n]=a[n]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),O1=t=>(ye(t.ns)&&(t.ns=[t.ns]),ye(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),ye(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs?.indexOf?.("cimode")<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t),kr=()=>{},Vp=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(a=>{typeof t[a]=="function"&&(t[a]=t[a].bind(t))})};class qn extends _i{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},a=arguments.length>1?arguments[1]:void 0;if(super(),this.options=O1(e),this.services={},this.logger=Vt,this.modules={external:[]},Vp(this),a&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,a),this;setTimeout(()=>{this.init(e,a)},0)}}init(){var e=this;let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof a=="function"&&(n=a,a={}),a.defaultNS==null&&a.ns&&(ye(a.ns)?a.defaultNS=a.ns:a.ns.indexOf("translation")<0&&(a.defaultNS=a.ns[0]));const r=_1();this.options={...r,...this.options,...O1(a)},this.options.interpolation={...r.interpolation,...this.options.interpolation},a.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=a.keySeparator),a.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=a.nsSeparator);const l=h=>h?typeof h=="function"?new h:h:null;if(!this.options.isClone){this.modules.logger?Vt.init(l(this.modules.logger),this.options):Vt.init(null,this.options);let h;this.modules.formatter?h=this.modules.formatter:h=Hp;const u=new F1(this.options);this.store=new z1(this.options.resources,this.options);const p=this.services;p.logger=Vt,p.resourceStore=this.store,p.languageUtils=u,p.pluralResolver=new Ip(u,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),h&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(p.formatter=l(h),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new Dp(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new Bp(l(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(f){for(var b=arguments.length,y=new Array(b>1?b-1:0),v=1;v<b;v++)y[v-1]=arguments[v];e.emit(f,...y)}),this.modules.languageDetector&&(p.languageDetector=l(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=l(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new Qr(this.services,this.options),this.translator.on("*",function(f){for(var b=arguments.length,y=new Array(b>1?b-1:0),v=1;v<b;v++)y[v-1]=arguments[v];e.emit(f,...y)}),this.modules.external.forEach(f=>{f.init&&f.init(this)})}if(this.format=this.options.interpolation.format,n||(n=kr),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const h=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);h.length>0&&h[0]!=="dev"&&(this.options.lng=h[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(h=>{this[h]=function(){return e.store[h](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(h=>{this[h]=function(){return e.store[h](...arguments),e}});const d=Rn(),c=()=>{const h=(u,p)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),d.resolve(p),n(u,p)};if(this.languages&&!this.isInitialized)return h(null,this.t.bind(this));this.changeLanguage(this.options.lng,h)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),d}loadResources(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:kr;const r=ye(e)?e:this.language;if(typeof e=="function"&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return n();const l=[],o=s=>{if(!s||s==="cimode")return;this.services.languageUtils.toResolveHierarchy(s).forEach(c=>{c!=="cimode"&&l.indexOf(c)<0&&l.push(c)})};r?o(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(d=>o(d)),this.options.preload?.forEach?.(s=>o(s)),this.services.backendConnector.load(l,this.options.ns,s=>{!s&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(s)})}else n(null)}reloadResources(e,a,n){const r=Rn();return typeof e=="function"&&(n=e,e=void 0),typeof a=="function"&&(n=a,a=void 0),e||(e=this.languages),a||(a=this.options.ns),n||(n=kr),this.services.backendConnector.reload(e,a,l=>{r.resolve(),n(l)}),r}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Uc.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1))for(let a=0;a<this.languages.length;a++){const n=this.languages[a];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}changeLanguage(e,a){var n=this;this.isLanguageChangingTo=e;const r=Rn();this.emit("languageChanging",e);const l=d=>{this.language=d,this.languages=this.services.languageUtils.toResolveHierarchy(d),this.resolvedLanguage=void 0,this.setResolvedLanguage(d)},o=(d,c)=>{c?(l(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve(function(){return n.t(...arguments)}),a&&a(d,function(){return n.t(...arguments)})},s=d=>{!e&&!d&&this.services.languageDetector&&(d=[]);const c=ye(d)?d:this.services.languageUtils.getBestMatchFromCodes(d);c&&(this.language||l(c),this.translator.language||this.translator.changeLanguage(c),this.services.languageDetector?.cacheUserLanguage?.(c)),this.loadResources(c,h=>{o(h,c)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?s(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(e),r}getFixedT(e,a,n){var r=this;const l=function(o,s){let d;if(typeof s!="object"){for(var c=arguments.length,h=new Array(c>2?c-2:0),u=2;u<c;u++)h[u-2]=arguments[u];d=r.options.overloadTranslationOptionHandler([o,s].concat(h))}else d={...s};d.lng=d.lng||l.lng,d.lngs=d.lngs||l.lngs,d.ns=d.ns||l.ns,d.keyPrefix!==""&&(d.keyPrefix=d.keyPrefix||n||l.keyPrefix);const p=r.options.keySeparator||".";let f;return d.keyPrefix&&Array.isArray(o)?f=o.map(b=>`${d.keyPrefix}${p}${b}`):f=d.keyPrefix?`${d.keyPrefix}${p}${o}`:o,r.t(f,d)};return ye(e)?l.lng=e:l.lngs=e,l.ns=a,l.keyPrefix=n,l}t(){for(var e=arguments.length,a=new Array(e),n=0;n<e;n++)a[n]=arguments[n];return this.translator?.translate(...a)}exists(){for(var e=arguments.length,a=new Array(e),n=0;n<e;n++)a[n]=arguments[n];return this.translator?.exists(...a)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const n=a.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,l=this.languages[this.languages.length-1];if(n.toLowerCase()==="cimode")return!0;const o=(s,d)=>{const c=this.services.backendConnector.state[`${s}|${d}`];return c===-1||c===0||c===2};if(a.precheck){const s=a.precheck(this,o);if(s!==void 0)return s}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(n,e)&&(!r||o(l,e)))}loadNamespaces(e,a){const n=Rn();return this.options.ns?(ye(e)&&(e=[e]),e.forEach(r=>{this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}),this.loadResources(r=>{n.resolve(),a&&a(r)}),n):(a&&a(),Promise.resolve())}loadLanguages(e,a){const n=Rn();ye(e)&&(e=[e]);const r=this.options.preload||[],l=e.filter(o=>r.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return l.length?(this.options.preload=r.concat(l),this.loadResources(o=>{n.resolve(),a&&a(o)}),n):(a&&a(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";const a=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],n=this.services?.languageUtils||new F1(_1());return a.indexOf(n.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},a=arguments.length>1?arguments[1]:void 0;return new qn(e,a)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:kr;const n=e.forkResourceStore;n&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},l=new qn(r);if((e.debug!==void 0||e.prefix!==void 0)&&(l.logger=l.logger.clone(e)),["store","services","language"].forEach(s=>{l[s]=this[s]}),l.services={...this.services},l.services.utils={hasLoadedNamespace:l.hasLoadedNamespace.bind(l)},n){const s=Object.keys(this.store.data).reduce((d,c)=>(d[c]={...this.store.data[c]},Object.keys(d[c]).reduce((h,u)=>(h[u]={...d[c][u]},h),{})),{});l.store=new z1(s,r),l.services.resourceStore=l.store}return l.translator=new Qr(l.services,r),l.translator.on("*",function(s){for(var d=arguments.length,c=new Array(d>1?d-1:0),h=1;h<d;h++)c[h-1]=arguments[h];l.emit(s,...c)}),l.init(r,a),l.translator.options=r,l.translator.backendConnector.services.utils={hasLoadedNamespace:l.hasLoadedNamespace.bind(l)},l}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Je=qn.createInstance();Je.createInstance=qn.createInstance;Je.createInstance;Je.dir;Je.init;Je.loadResources;Je.reloadResources;Je.use;Je.changeLanguage;Je.getFixedT;Je.t;Je.exists;Je.setDefaultNamespace;Je.hasLoadedNamespace;Je.loadNamespaces;Je.loadLanguages;const{slice:Up,forEach:Gp}=[];function Wp(t){return Gp.call(Up.call(arguments,1),e=>{if(e)for(const a in e)t[a]===void 0&&(t[a]=e[a])}),t}function Kp(t){return typeof t!="string"?!1:[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(a=>a.test(t))}const T1=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,qp=function(t,e){const n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},r=encodeURIComponent(e);let l=`${t}=${r}`;if(n.maxAge>0){const o=n.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");l+=`; Max-Age=${Math.floor(o)}`}if(n.domain){if(!T1.test(n.domain))throw new TypeError("option domain is invalid");l+=`; Domain=${n.domain}`}if(n.path){if(!T1.test(n.path))throw new TypeError("option path is invalid");l+=`; Path=${n.path}`}if(n.expires){if(typeof n.expires.toUTCString!="function")throw new TypeError("option expires is invalid");l+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(l+="; HttpOnly"),n.secure&&(l+="; Secure"),n.sameSite)switch(typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite){case!0:l+="; SameSite=Strict";break;case"lax":l+="; SameSite=Lax";break;case"strict":l+="; SameSite=Strict";break;c