@sv-print/plugin-i18n 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ import type { PluginOptions } from "sv-print";
2
+ import type { i18n, InitOptions, TFunction } from "i18next";
3
+ import { translateBySelector } from "./translate-option";
4
+ export type i18nOptions = InitOptions & {};
5
+ export type i18nCallback = (i18next: i18n, t: TFunction, err: any) => void;
6
+ export { translateBySelector };
7
+ export default function plugin(config?: i18nOptions, callBack?: i18nCallback): PluginOptions;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var $e=Object.defineProperty,Pe=Object.defineProperties;var Re=Object.getOwnPropertyDescriptors;var ne=Object.getOwnPropertySymbols;var ke=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable;var re=(o,e,t)=>e in o?$e(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,p=(o,e)=>{for(var t in e||(e={}))ke.call(e,t)&&re(o,t,e[t]);if(ne)for(var t of ne(e))Ne.call(e,t)&&re(o,t,e[t]);return o},O=(o,e)=>Pe(o,Re(e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=o=>typeof o=="string",U=()=>{let o,e;const t=new Promise((i,s)=>{o=i,e=s});return t.resolve=o,t.reject=e,t},ae=o=>o==null?"":""+o,Ee=(o,e,t)=>{o.forEach(i=>{e[i]&&(t[i]=e[i])})},Fe=/###/g,oe=o=>o&&o.indexOf("###")>-1?o.replace(Fe,"."):o,le=o=>!o||g(o),B=(o,e,t)=>{const i=g(e)?e.split("."):e;let s=0;for(;s<i.length-1;){if(le(o))return{};const n=oe(i[s]);!o[n]&&t&&(o[n]=new t),Object.prototype.hasOwnProperty.call(o,n)?o=o[n]:o={},++s}return le(o)?{}:{obj:o,k:oe(i[s])}},ue=(o,e,t)=>{const{obj:i,k:s}=B(o,e,Object);if(i!==void 0||e.length===1){i[s]=t;return}let n=e[e.length-1],r=e.slice(0,e.length-1),a=B(o,r,Object);for(;a.obj===void 0&&r.length;)n=`${r[r.length-1]}.${n}`,r=r.slice(0,r.length-1),a=B(o,r,Object),(a==null?void 0:a.obj)&&typeof a.obj[`${a.k}.${n}`]!="undefined"&&(a.obj=void 0);a.obj[`${a.k}.${n}`]=t},Te=(o,e,t,i)=>{const{obj:s,k:n}=B(o,e,Object);s[n]=s[n]||[],s[n].push(t)},Y=(o,e)=>{const{obj:t,k:i}=B(o,e);if(!!t&&!!Object.prototype.hasOwnProperty.call(t,i))return t[i]},je=(o,e,t)=>{const i=Y(o,t);return i!==void 0?i:Y(e,t)},Oe=(o,e,t)=>{for(const i in e)i!=="__proto__"&&i!=="constructor"&&(i in o?g(o[i])||o[i]instanceof String||g(e[i])||e[i]instanceof String?t&&(o[i]=e[i]):Oe(o[i],e[i],t):o[i]=e[i]);return o},I=o=>o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var De={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Ie=o=>g(o)?o.replace(/[&<>"'\/]/g,e=>De[e]):o;class Ae{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)return t;const i=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,i),this.regExpQueue.push(e),i}}const Ve=[" ",",","?","!",";"],Ke=new Ae(20),Ue=(o,e,t)=>{e=e||"",t=t||"";const i=Ve.filter(r=>e.indexOf(r)<0&&t.indexOf(r)<0);if(i.length===0)return!0;const s=Ke.getRegExp(`(${i.map(r=>r==="?"?"\\?":r).join("|")})`);let n=!s.test(o);if(!n){const r=o.indexOf(t);r>0&&!s.test(o.substring(0,r))&&(n=!0)}return n},q=(o,e,t=".")=>{if(!o)return;if(o[e])return Object.prototype.hasOwnProperty.call(o,e)?o[e]:void 0;const i=e.split(t);let s=o;for(let n=0;n<i.length;){if(!s||typeof s!="object")return;let r,a="";for(let l=n;l<i.length;++l)if(l!==n&&(a+=t),a+=i[l],r=s[a],r!==void 0){if(["string","number","boolean"].indexOf(typeof r)>-1&&l<i.length-1)continue;n+=l-n+1;break}s=r}return s},H=o=>o==null?void 0:o.replace("_","-"),Me={type:"logger",log(o){this.output("log",o)},warn(o){this.output("warn",o)},error(o){this.output("error",o)},output(o,e){var t,i;(i=(t=console==null?void 0:console[o])==null?void 0:t.apply)==null||i.call(t,console,e)}};class Q{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||Me,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,i,s){return s&&!this.debug?null:(g(e[0])&&(e[0]=`${i}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new Q(this.logger,p({prefix:`${this.prefix}:${e}:`},this.options))}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Q(this.logger,e)}}var N=new Q;class Z{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(i=>{this.observers[i]||(this.observers[i]=new Map);const s=this.observers[i].get(t)||0;this.observers[i].set(t,s+1)}),this}off(e,t){if(!!this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([s,n])=>{for(let r=0;r<n;r++)s(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,n])=>{for(let r=0;r<n;r++)s.apply(s,[e,...t])})}}class fe extends Z{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,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 t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,i,s={}){var u,h;const n=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,r=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],i&&(Array.isArray(i)?a.push(...i):g(i)&&n?a.push(...i.split(n)):a.push(i)));const l=Y(this.data,a);return!l&&!t&&!i&&e.indexOf(".")>-1&&(e=a[0],t=a[1],i=a.slice(2).join(".")),l||!r||!g(i)?l:q((h=(u=this.data)==null?void 0:u[e])==null?void 0:h[t],i,n)}addResource(e,t,i,s,n={silent:!1}){const r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=[e,t];i&&(a=a.concat(r?i.split(r):i)),e.indexOf(".")>-1&&(a=e.split("."),s=t,t=a[1]),this.addNamespaces(t),ue(this.data,a,s),n.silent||this.emit("added",e,t,i,s)}addResources(e,t,i,s={silent:!1}){for(const n in i)(g(i[n])||Array.isArray(i[n]))&&this.addResource(e,t,n,i[n],{silent:!0});s.silent||this.emit("added",e,t,i)}addResourceBundle(e,t,i,s,n,r={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),s=i,i=t,t=a[1]),this.addNamespaces(t);let l=Y(this.data,a)||{};r.skipCopy||(i=JSON.parse(JSON.stringify(i))),s?Oe(l,i,n):l=p(p({},l),i),ue(this.data,a,l),r.silent||this.emit("added",e,t,i)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(s=>t[s]&&Object.keys(t[s]).length>0)}toJSON(){return this.data}}var we={processors:{},addPostProcessor(o){this.processors[o.name]=o},handle(o,e,t,i,s){return o.forEach(n=>{var r,a;e=(a=(r=this.processors[n])==null?void 0:r.process(e,t,i,s))!=null?a:e}),e}};const he={},ce=o=>!g(o)&&typeof o!="boolean"&&typeof o!="number";class G extends Z{constructor(e,t={}){super(),Ee(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=N.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const i=p({},t);if(e==null)return!1;const s=this.resolve(e,i);return(s==null?void 0:s.res)!==void 0}extractFromKey(e,t){let i=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;i===void 0&&(i=":");const s=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const r=i&&e.indexOf(i)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Ue(e,i,s);if(r&&!a){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:g(n)?[n]:n};const u=e.split(i);(i!==s||i===s&&this.options.ns.indexOf(u[0])>-1)&&(n=u.shift()),e=u.join(s)}return{key:e,namespaces:g(n)?[n]:n}}translate(e,t,i){let s=typeof t=="object"?p({},t):t;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof options=="object"&&(s=p({},s)),s||(s={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const n=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,r=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(e[e.length-1],s),u=l[l.length-1];let h=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const f=s.lng||this.language,m=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((f==null?void 0:f.toLowerCase())==="cimode")return m?n?{res:`${u}${h}${a}`,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(s)}:`${u}${h}${a}`:n?{res:a,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(s)}:a;const d=this.resolve(e,s);let c=d==null?void 0:d.res;const x=(d==null?void 0:d.usedKey)||a,S=(d==null?void 0:d.exactUsedKey)||a,$=["[object Number]","[object Function]","[object RegExp]"],v=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,j=!this.i18nFormat||this.i18nFormat.handleAsObject,L=s.count!==void 0&&!g(s.count),E=G.hasDefaultValue(s),J=L?this.pluralResolver.getSuffix(f,s.count,s):"",F=s.ordinal&&L?this.pluralResolver.getSuffix(f,s.count,{ordinal:!1}):"",A=L&&!s.ordinal&&s.count===0,w=A&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${J}`]||s[`defaultValue${F}`]||s.defaultValue;let b=c;j&&!c&&E&&(b=w);const Ce=ce(b),ve=Object.prototype.toString.apply(b);if(j&&b&&Ce&&$.indexOf(ve)<0&&!(g(v)&&Array.isArray(b))){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,b,O(p({},s),{ns:l})):`key '${a} (${this.language})' returned an object instead of string.`;return n?(d.res=R,d.usedParams=this.getUsedParamsDetails(s),d):R}if(r){const R=Array.isArray(b),P=R?[]:{},ee=R?S:x;for(const k in b)if(Object.prototype.hasOwnProperty.call(b,k)){const T=`${ee}${r}${k}`;E&&!c?P[k]=this.translate(T,O(p({},s),{defaultValue:ce(w)?w[k]:void 0,joinArrays:!1,ns:l})):P[k]=this.translate(T,O(p({},s),{joinArrays:!1,ns:l})),P[k]===T&&(P[k]=b[k])}c=P}}else if(j&&g(v)&&Array.isArray(c))c=c.join(v),c&&(c=this.extendTranslation(c,e,s,i));else{let R=!1,P=!1;!this.isValidLookup(c)&&E&&(R=!0,c=w),this.isValidLookup(c)||(P=!0,c=a);const k=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&P?void 0:c,T=E&&w!==c&&this.options.updateMissing;if(P||R||T){if(this.logger.log(T?"updateKey":"missingKey",f,u,a,T?w:c),r){const C=this.resolve(a,O(p({},s),{keySeparator:!1}));C&&C.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 V=[];const W=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&W&&W[0])for(let C=0;C<W.length;C++)V.push(W[C]);else this.options.saveMissingTo==="all"?V=this.languageUtils.toResolveHierarchy(s.lng||this.language):V.push(s.lng||this.language);const te=(C,D,K)=>{var se;const ie=E&&K!==c?K:k;this.options.missingKeyHandler?this.options.missingKeyHandler(C,u,D,ie,T,s):(se=this.backendConnector)!=null&&se.saveMissing&&this.backendConnector.saveMissing(C,u,D,ie,T,s),this.emit("missingKey",C,u,D,c)};this.options.saveMissing&&(this.options.saveMissingPlurals&&L?V.forEach(C=>{const D=this.pluralResolver.getSuffixes(C,s);A&&s[`defaultValue${this.options.pluralSeparator}zero`]&&D.indexOf(`${this.options.pluralSeparator}zero`)<0&&D.push(`${this.options.pluralSeparator}zero`),D.forEach(K=>{te([C],a+K,s[`defaultValue${K}`]||w)})}):te(V,a,w))}c=this.extendTranslation(c,e,s,d,i),P&&c===a&&this.options.appendNamespaceToMissingKey&&(c=`${u}${h}${a}`),(P||R)&&this.options.parseMissingKeyHandler&&(c=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${h}${a}`:a,R?c:void 0,s))}return n?(d.res=c,d.usedParams=this.getUsedParamsDetails(s),d):c}extendTranslation(e,t,i,s,n){var l,u;if((l=this.i18nFormat)!=null&&l.parse)e=this.i18nFormat.parse(e,p(p({},this.options.interpolation.defaultVariables),i),i.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init(O(p({},i),{interpolation:p(p({},this.options.interpolation),i.interpolation)}));const h=g(e)&&(((u=i==null?void 0:i.interpolation)==null?void 0:u.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(h){const d=e.match(this.interpolator.nestingRegexp);f=d&&d.length}let m=i.replace&&!g(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(m=p(p({},this.options.interpolation.defaultVariables),m)),e=this.interpolator.interpolate(e,m,i.lng||this.language||s.usedLng,i),h){const d=e.match(this.interpolator.nestingRegexp),c=d&&d.length;f<c&&(i.nest=!1)}!i.lng&&s&&s.res&&(i.lng=this.language||s.usedLng),i.nest!==!1&&(e=this.interpolator.nest(e,(...d)=>(n==null?void 0:n[0])===d[0]&&!i.context?(this.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${t[0]}`),null):this.translate(...d,t),i)),i.interpolation&&this.interpolator.reset()}const r=i.postProcess||this.options.postProcess,a=g(r)?[r]:r;return e!=null&&(a==null?void 0:a.length)&&i.applyPostProcessor!==!1&&(e=we.handle(a,e,t,this.options&&this.options.postProcessPassResolved?p({i18nResolved:O(p({},s),{usedParams:this.getUsedParamsDetails(i)})},i):i,this)),e}resolve(e,t={}){let i,s,n,r,a;return g(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(i))return;const u=this.extractFromKey(l,t),h=u.key;s=h;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const m=t.count!==void 0&&!g(t.count),d=m&&!t.ordinal&&t.count===0,c=t.context!==void 0&&(g(t.context)||typeof t.context=="number")&&t.context!=="",x=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);f.forEach(S=>{var $,v;this.isValidLookup(i)||(a=S,!he[`${x[0]}-${S}`]&&(($=this.utils)==null?void 0:$.hasLoadedNamespace)&&!((v=this.utils)!=null&&v.hasLoadedNamespace(a))&&(he[`${x[0]}-${S}`]=!0,this.logger.warn(`key "${s}" for languages "${x.join(", ")}" won't get resolved as 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!!!")),x.forEach(j=>{var J;if(this.isValidLookup(i))return;r=j;const L=[h];if((J=this.i18nFormat)!=null&&J.addLookupKeys)this.i18nFormat.addLookupKeys(L,h,j,S,t);else{let F;m&&(F=this.pluralResolver.getSuffix(j,t.count,t));const A=`${this.options.pluralSeparator}zero`,w=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(L.push(h+F),t.ordinal&&F.indexOf(w)===0&&L.push(h+F.replace(w,this.options.pluralSeparator)),d&&L.push(h+A)),c){const b=`${h}${this.options.contextSeparator}${t.context}`;L.push(b),m&&(L.push(b+F),t.ordinal&&F.indexOf(w)===0&&L.push(b+F.replace(w,this.options.pluralSeparator)),d&&L.push(b+A))}}let E;for(;E=L.pop();)this.isValidLookup(i)||(n=E,i=this.getResource(j,S,E,t))}))})}),{res:i,usedKey:s,exactUsedKey:n,usedLng:r,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,i,s={}){var n;return(n=this.i18nFormat)!=null&&n.getResource?this.i18nFormat.getResource(e,t,i,s):this.resourceStore.getResource(e,t,i,s)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=e.replace&&!g(e.replace);let s=i?e.replace:e;if(i&&typeof e.count!="undefined"&&(s.count=e.count),this.options.interpolation.defaultVariables&&(s=p(p({},this.options.interpolation.defaultVariables),s)),!i){s=p({},s);for(const n of t)delete s[n]}return s}static hasDefaultValue(e){const t="defaultValue";for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t===i.substring(0,t.length)&&e[i]!==void 0)return!0;return!1}}class de{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=N.create("languageUtils")}getScriptPartFromCode(e){if(e=H(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=H(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(g(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(i){}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(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 t;return e.forEach(i=>{if(t)return;const s=this.formatLanguageCode(i);(!this.options.supportedLngs||this.isSupportedCode(s))&&(t=s)}),!t&&this.options.supportedLngs&&e.forEach(i=>{if(t)return;const s=this.getScriptPartFromCode(i);if(this.isSupportedCode(s))return t=s;const n=this.getLanguagePartFromCode(i);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(r=>{if(r===n)return r;if(!(r.indexOf("-")<0&&n.indexOf("-")<0)&&(r.indexOf("-")>0&&n.indexOf("-")<0&&r.substring(0,r.indexOf("-"))===n||r.indexOf(n)===0&&n.length>1))return r})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),g(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let i=e[t];return i||(i=e[this.getScriptPartFromCode(t)]),i||(i=e[this.formatLanguageCode(t)]),i||(i=e[this.getLanguagePartFromCode(t)]),i||(i=e.default),i||[]}toResolveHierarchy(e,t){const i=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),s=[],n=r=>{!r||(this.isSupportedCode(r)?s.push(r):this.logger.warn(`rejecting language code not found in supportedLngs: ${r}`))};return g(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(e))):g(e)&&n(this.formatLanguageCode(e)),i.forEach(r=>{s.indexOf(r)<0&&n(this.formatLanguageCode(r))}),s}}const pe={zero:0,one:1,two:2,few:3,many:4,other:5},ge={select:o=>o===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Be{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=N.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const i=H(e==="dev"?"en":e),s=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:i,type:s});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let r;try{r=new Intl.PluralRules(i,{type:s})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ge;if(!e.match(/-|_/))return ge;const l=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(l,t)}return this.pluralRulesCache[n]=r,r}needsPlural(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),(i==null?void 0:i.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t,i={}){return this.getSuffixes(e,i).map(s=>`${t}${s}`)}getSuffixes(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),i?i.resolvedOptions().pluralCategories.sort((s,n)=>pe[s]-pe[n]).map(s=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(e,t,i={}){const s=this.getRule(e,i);return s?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${s.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,i))}}const me=(o,e,t,i=".",s=!0)=>{let n=je(o,e,t);return!n&&s&&g(t)&&(n=q(o,t,i),n===void 0&&(n=q(e,t,i))),n},X=o=>o.replace(/\$/g,"$$$$");class He{constructor(e={}){var t;this.logger=N.create("interpolator"),this.options=e,this.format=((t=e==null?void 0:e.interpolation)==null?void 0:t.format)||(i=>i),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:i,useRawValueToEscape:s,prefix:n,prefixEscaped:r,suffix:a,suffixEscaped:l,formatSeparator:u,unescapeSuffix:h,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:d,nestingSuffix:c,nestingSuffixEscaped:x,nestingOptionsSeparator:S,maxReplaces:$,alwaysFormat:v}=e.interpolation;this.escape=t!==void 0?t:Ie,this.escapeValue=i!==void 0?i:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=n?I(n):r||"{{",this.suffix=a?I(a):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=h?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=m?I(m):d||I("$t("),this.nestingSuffix=c?I(c):x||I(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=$||1e3,this.alwaysFormat=v!==void 0?v:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,i)=>(t==null?void 0:t.source)===i?(t.lastIndex=0,t):new RegExp(i,"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,t,i,s){var d;let n,r,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=c=>{if(c.indexOf(this.formatSeparator)<0){const v=me(t,l,c,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(v,void 0,i,O(p(p({},s),t),{interpolationkey:c})):v}const x=c.split(this.formatSeparator),S=x.shift().trim(),$=x.join(this.formatSeparator).trim();return this.format(me(t,l,S,this.options.keySeparator,this.options.ignoreJSONStructure),$,i,O(p(p({},s),t),{interpolationkey:S}))};this.resetRegExp();const h=(s==null?void 0:s.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((d=s==null?void 0:s.interpolation)==null?void 0:d.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:c=>X(c)},{regex:this.regexp,safeValue:c=>this.escapeValue?X(this.escape(c)):X(c)}].forEach(c=>{for(a=0;n=c.regex.exec(e);){const x=n[1].trim();if(r=u(x),r===void 0)if(typeof h=="function"){const $=h(e,n,s);r=g($)?$:""}else if(s&&Object.prototype.hasOwnProperty.call(s,x))r="";else if(f){r=n[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),r="";else!g(r)&&!this.useRawValueToEscape&&(r=ae(r));const S=c.safeValue(r);if(e=e.replace(n[0],S),f?(c.regex.lastIndex+=r.length,c.regex.lastIndex-=n[0].length):c.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),e}nest(e,t,i={}){let s,n,r;const a=(l,u)=>{var x;const h=this.nestingOptionsSeparator;if(l.indexOf(h)<0)return l;const f=l.split(new RegExp(`${h}[ ]*{`));let m=`{${f[1]}`;l=f[0],m=this.interpolate(m,r);const d=m.match(/'/g),c=m.match(/"/g);(((x=d==null?void 0:d.length)!=null?x:0)%2===0&&!c||c.length%2!==0)&&(m=m.replace(/'/g,'"'));try{r=JSON.parse(m),u&&(r=p(p({},u),r))}catch(S){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,S),`${l}${h}${m}`}return r.defaultValue&&r.defaultValue.indexOf(this.prefix)>-1&&delete r.defaultValue,l};for(;s=this.nestingRegexp.exec(e);){let l=[];r=p({},i),r=r.replace&&!g(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.defaultValue;const u=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(u!==-1&&(l=s[1].slice(u).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),s[1]=s[1].slice(0,u)),n=t(a.call(this,s[1].trim(),r),r),n&&s[0]===e&&!g(n))return n;g(n)||(n=ae(n)),n||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((h,f)=>this.format(h,f,i.lng,O(p({},i),{interpolationkey:s[1].trim()})),n.trim())),e=e.replace(s[0],n),this.regexp.lastIndex=0}return e}}const ze=o=>{let e=o.toLowerCase().trim();const t={};if(o.indexOf("(")>-1){const i=o.split("(");e=i[0].toLowerCase().trim();const s=i[1].substring(0,i[1].length-1);e==="currency"&&s.indexOf(":")<0?t.currency||(t.currency=s.trim()):e==="relativetime"&&s.indexOf(":")<0?t.range||(t.range=s.trim()):s.split(";").forEach(r=>{if(r){const[a,...l]=r.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),h=a.trim();t[h]||(t[h]=u),u==="false"&&(t[h]=!1),u==="true"&&(t[h]=!0),isNaN(u)||(t[h]=parseInt(u,10))}})}return{formatName:e,formatOptions:t}},xe=o=>{const e={};return(t,i,s)=>{let n=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(n=O(p({},n),{[s.interpolationkey]:void 0}));const r=i+JSON.stringify(n);let a=e[r];return a||(a=o(H(i),s),e[r]=a),a(t)}},Je=o=>(e,t,i)=>o(H(t),i)(e);class We{constructor(e={}){this.logger=N.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const i=t.cacheInBuiltFormats?xe:Je;this.formats={number:i((s,n)=>{const r=new Intl.NumberFormat(s,p({},n));return a=>r.format(a)}),currency:i((s,n)=>{const r=new Intl.NumberFormat(s,O(p({},n),{style:"currency"}));return a=>r.format(a)}),datetime:i((s,n)=>{const r=new Intl.DateTimeFormat(s,p({},n));return a=>r.format(a)}),relativetime:i((s,n)=>{const r=new Intl.RelativeTimeFormat(s,p({},n));return a=>r.format(a,n.range||"day")}),list:i((s,n)=>{const r=new Intl.ListFormat(s,p({},n));return a=>r.format(a)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=xe(t)}format(e,t,i,s={}){const n=t.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find(a=>a.indexOf(")")>-1)){const a=n.findIndex(l=>l.indexOf(")")>-1);n[0]=[n[0],...n.splice(1,a)].join(this.formatSeparator)}return n.reduce((a,l)=>{var f;const{formatName:u,formatOptions:h}=ze(l);if(this.formats[u]){let m=a;try{const d=((f=s==null?void 0:s.formatParams)==null?void 0:f[s.interpolationkey])||{},c=d.locale||d.lng||s.locale||s.lng||i;m=this.formats[u](a,c,p(p(p({},h),s),d))}catch(d){this.logger.warn(d)}return m}else this.logger.warn(`there was no format function for ${u}`);return a},e)}}const _e=(o,e)=>{o.pending[e]!==void 0&&(delete o.pending[e],o.pendingCount--)};class Ye extends Z{constructor(e,t,i,s={}){var n,r;super(),this.backend=e,this.store=t,this.services=i,this.languageUtils=i.languageUtils,this.options=s,this.logger=N.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],(r=(n=this.backend)==null?void 0:n.init)==null||r.call(n,i,s.backend,s)}queueLoad(e,t,i,s){const n={},r={},a={},l={};return e.forEach(u=>{let h=!0;t.forEach(f=>{const m=`${u}|${f}`;!i.reload&&this.store.hasResourceBundle(u,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?r[m]===void 0&&(r[m]=!0):(this.state[m]=1,h=!1,r[m]===void 0&&(r[m]=!0),n[m]===void 0&&(n[m]=!0),l[f]===void 0&&(l[f]=!0)))}),h||(a[u]=!0)}),(Object.keys(n).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(n),pending:Object.keys(r),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,t,i){const s=e.split("|"),n=s[0],r=s[1];t&&this.emit("failedLoading",n,r,t),!t&&i&&this.store.addResourceBundle(n,r,i,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&i&&(this.state[e]=0);const a={};this.queue.forEach(l=>{Te(l.loaded,[n],r),_e(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{a[u]||(a[u]={});const h=l.loaded[u];h.length&&h.forEach(f=>{a[u][f]===void 0&&(a[u][f]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(l=>!l.done)}read(e,t,i,s=0,n=this.retryTimeout,r){if(!e.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:i,tried:s,wait:n,callback:r});return}this.readingCalls++;const a=(u,h)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&h&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,i,s+1,n*2,r)},n);return}r(u,h)},l=this.backend[i].bind(this.backend);if(l.length===2){try{const u=l(e,t);u&&typeof u.then=="function"?u.then(h=>a(null,h)).catch(a):a(null,u)}catch(u){a(u)}return}return l(e,t,a)}prepareLoading(e,t,i={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();g(e)&&(e=this.languageUtils.toResolveHierarchy(e)),g(t)&&(t=[t]);const n=this.queueLoad(e,t,i,s);if(!n.toLoad.length)return n.pending.length||s(),null;n.toLoad.forEach(r=>{this.loadOne(r)})}load(e,t,i){this.prepareLoading(e,t,{},i)}reload(e,t,i){this.prepareLoading(e,t,{reload:!0},i)}loadOne(e,t=""){const i=e.split("|"),s=i[0],n=i[1];this.read(s,n,"read",void 0,void 0,(r,a)=>{r&&this.logger.warn(`${t}loading namespace ${n} for language ${s} failed`,r),!r&&a&&this.logger.log(`${t}loaded namespace ${n} for language ${s}`,a),this.loaded(e,r,a)})}saveMissing(e,t,i,s,n,r={},a=()=>{}){var l,u,h,f,m;if(((u=(l=this.services)==null?void 0:l.utils)==null?void 0:u.hasLoadedNamespace)&&!((f=(h=this.services)==null?void 0:h.utils)!=null&&f.hasLoadedNamespace(t))){this.logger.warn(`did not save key "${i}" as the namespace "${t}" 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(!(i==null||i==="")){if((m=this.backend)!=null&&m.create){const d=O(p({},r),{isUpdate:n}),c=this.backend.create.bind(this.backend);if(c.length<6)try{let x;c.length===5?x=c(e,t,i,s,d):x=c(e,t,i,s),x&&typeof x.then=="function"?x.then(S=>a(null,S)).catch(a):a(null,x)}catch(x){a(x)}else c(e,t,i,s,a,d)}!e||!e[0]||this.store.addResource(e[0],t,i,s)}}}const ye=()=>({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:o=>{let e={};if(typeof o[1]=="object"&&(e=o[1]),g(o[1])&&(e.defaultValue=o[1]),g(o[2])&&(e.tDescription=o[2]),typeof o[2]=="object"||typeof o[3]=="object"){const t=o[3]||o[2];Object.keys(t).forEach(i=>{e[i]=t[i]})}return e},interpolation:{escapeValue:!0,format:o=>o,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Se=o=>{var e,t;return g(o.ns)&&(o.ns=[o.ns]),g(o.fallbackLng)&&(o.fallbackLng=[o.fallbackLng]),g(o.fallbackNS)&&(o.fallbackNS=[o.fallbackNS]),((t=(e=o.supportedLngs)==null?void 0:e.indexOf)==null?void 0:t.call(e,"cimode"))<0&&(o.supportedLngs=o.supportedLngs.concat(["cimode"])),typeof o.initImmediate=="boolean"&&(o.initAsync=o.initImmediate),o},_=()=>{},Qe=o=>{Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach(t=>{typeof o[t]=="function"&&(o[t]=o[t].bind(o))})};class z extends Z{constructor(e={},t){if(super(),this.options=Se(e),this.services={},this.logger=N,this.modules={external:[]},Qe(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e=="function"&&(t=e,e={}),e.defaultNS==null&&e.ns&&(g(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const i=ye();this.options=p(p(p({},i),this.options),Se(e)),this.options.interpolation=p(p({},i.interpolation),this.options.interpolation),e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const s=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?N.init(s(this.modules.logger),this.options):N.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=We;const h=new de(this.options);this.store=new fe(this.options.resources,this.options);const f=this.services;f.logger=N,f.resourceStore=this.store,f.languageUtils=h,f.pluralResolver=new Be(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==i.interpolation.format&&this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(f.formatter=s(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new He(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Ye(s(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(d,...c)=>{this.emit(d,...c)}),this.modules.languageDetector&&(f.languageDetector=s(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=s(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new G(this.services,this.options),this.translator.on("*",(d,...c)=>{this.emit(d,...c)}),this.modules.external.forEach(d=>{d.init&&d.init(this)})}if(this.format=this.options.interpolation.format,t||(t=_),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=(...h)=>this.store[u](...h)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...h)=>(this.store[u](...h),this)});const a=U(),l=()=>{const u=(h,f)=>{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),a.resolve(f),t(h,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),a}loadResources(e,t=_){var n,r;let i=t;const s=g(e)?e:this.language;if(typeof e=="function"&&(i=e),!this.options.resources||this.options.partialBundledLanguages){if((s==null?void 0:s.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return i();const a=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(f=>{f!=="cimode"&&a.indexOf(f)<0&&a.push(f)})};s?l(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(h=>l(h)),(r=(n=this.options.preload)==null?void 0:n.forEach)==null||r.call(n,u=>l(u)),this.services.backendConnector.load(a,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),i(u)})}else i(null)}reloadResources(e,t,i){const s=U();return typeof e=="function"&&(i=e,e=void 0),typeof t=="function"&&(i=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),i||(i=_),this.services.backendConnector.reload(e,t,n=>{s.resolve(),i(n)}),s}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"&&we.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 t=0;t<this.languages.length;t++){const i=this.languages[t];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const i=U();this.emit("languageChanging",e);const s=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},n=(a,l)=>{l?this.isLanguageChangingTo===e&&(s(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,i.resolve((...u)=>this.t(...u)),t&&t(a,(...u)=>this.t(...u))},r=a=>{var h,f;!e&&!a&&this.services.languageDetector&&(a=[]);const l=g(a)?a:a&&a[0],u=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(g(a)?[a]:a);u&&(this.language||s(u),this.translator.language||this.translator.changeLanguage(u),(f=(h=this.services.languageDetector)==null?void 0:h.cacheUserLanguage)==null||f.call(h,u)),this.loadResources(u,m=>{n(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?r(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(r):this.services.languageDetector.detect(r):r(e),i}getFixedT(e,t,i){const s=(n,r,...a)=>{let l;typeof r!="object"?l=this.options.overloadTranslationOptionHandler([n,r].concat(a)):l=p({},r),l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||i||s.keyPrefix);const u=this.options.keySeparator||".";let h;return l.keyPrefix&&Array.isArray(n)?h=n.map(f=>`${l.keyPrefix}${u}${f}`):h=l.keyPrefix?`${l.keyPrefix}${u}${n}`:n,this.t(h,l)};return g(e)?s.lng=e:s.lngs=e,s.ns=t,s.keyPrefix=i,s}t(...e){var t;return(t=this.translator)==null?void 0:t.translate(...e)}exists(...e){var t;return(t=this.translator)==null?void 0:t.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){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 i=t.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(i.toLowerCase()==="cimode")return!0;const r=(a,l)=>{const u=this.services.backendConnector.state[`${a}|${l}`];return u===-1||u===0||u===2};if(t.precheck){const a=t.precheck(this,r);if(a!==void 0)return a}return!!(this.hasResourceBundle(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||r(i,e)&&(!s||r(n,e)))}loadNamespaces(e,t){const i=U();return this.options.ns?(g(e)&&(e=[e]),e.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{i.resolve(),t&&t(s)}),i):(t&&t(),Promise.resolve())}loadLanguages(e,t){const i=U();g(e)&&(e=[e]);const s=this.options.preload||[],n=e.filter(r=>s.indexOf(r)<0&&this.services.languageUtils.isSupportedCode(r));return n.length?(this.options.preload=s.concat(n),this.loadResources(r=>{i.resolve(),t&&t(r)}),i):(t&&t(),Promise.resolve())}dir(e){var s,n;if(e||(e=this.resolvedLanguage||(((s=this.languages)==null?void 0:s.length)>0?this.languages[0]:this.language)),!e)return"rtl";try{const r=new Intl.Locale(e);if(r&&r.getTextInfo){const a=r.getTextInfo();if(a&&a.direction)return a.direction}}catch(r){}const t=["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"],i=((n=this.services)==null?void 0:n.languageUtils)||new de(ye());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(i.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new z(e,t)}cloneInstance(e={},t=_){const i=e.forkResourceStore;i&&delete e.forkResourceStore;const s=O(p(p({},this.options),e),{isClone:!0}),n=new z(s);if((e.debug!==void 0||e.prefix!==void 0)&&(n.logger=n.logger.clone(e)),["store","services","language"].forEach(a=>{n[a]=this[a]}),n.services=p({},this.services),n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},i){const a=Object.keys(this.store.data).reduce((l,u)=>(l[u]=p({},this.store.data[u]),l[u]=Object.keys(l[u]).reduce((h,f)=>(h[f]=p({},l[u][f]),h),l[u]),l),{});n.store=new fe(a,s),n.services.resourceStore=n.store}return n.translator=new G(n.services,s),n.translator.on("*",(a,...l)=>{n.emit(a,...l)}),n.init(s,t),n.translator.options=s,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const y=z.createInstance();y.createInstance=z.createInstance;y.createInstance;y.dir;y.init;y.loadResources;y.reloadResources;y.use;y.changeLanguage;y.getFixedT;y.t;y.exists;y.setDefaultNamespace;y.hasLoadedNamespace;y.loadNamespaces;y.loadLanguages;const Ge=(o,e)=>{for(const t of e){const i=o.find(t);i&&i.each((s,n)=>{const r=globalThis.$(n);if(r.attr("data-i18n"))return;const a=r.text().trim();a&&(r.attr({"data-i18n":a}),r.text(y.t(a)));const l=r.attr("placeholder");l&&(r.attr({"data-i18n":"[placeholder]"+l}),r.attr({placeholder:y.t(l)}))})}},M=o=>{for(const e of o){const t=globalThis.$(e);t&&t.each((i,s)=>{const n=globalThis.$(s);if(n.attr("data-i18n"))return;const r=n.text().trim();r&&(n.attr({"data-i18n":r}),n.text(y.t(r)));const a=n.attr("placeholder");a&&(n.attr({"data-i18n":"[placeholder]"+a}),n.attr({placeholder:y.t(a)}))})}},Ze=(o,e)=>{Ge(e,[".hiprint-option-item-label","textarea","input","select option",".option","button","label",".hiprint-option-title",".hiprint-option-item-desc"])},Xe=()=>{document.querySelectorAll("[data-i18n]").forEach(o=>{const e=o.getAttribute("data-i18n");if(!e.includes("[")){o.textContent=y.t(e);return}const t=e.match(/\[([^\]]+)\](.+)/);if(t&&t.length===3){const i=t[1],s=t[2];o.setAttribute(i,y.t(s))}})};let be=!1;const Le=o=>{if(be)return;be=!0,globalThis.hiprint.i18next=y,globalThis.hiprint.t=y.t;const e=Object.keys(o.resources||{});globalThis.hiprint.languages=["\u7B80\u4F53\u4E2D\u6587",...e],globalThis.hiprint.changeLanguage=(t,i)=>{y.changeLanguage(t,(s,n)=>{i&&i(s,n),Xe()})}};function qe(o,e){y.init(p({},o),(i,s)=>{e&&e(y,s,i)});let t=[];return{name:"i18n",description:"i18next",hooks:[{hook:"ready",name:"i18n set",description:"\u6DFB\u52A0 i18n \u65B9\u6CD5",priority:1,run:()=>{Le(o)}},{hook:"getOptionItem",name:"i18n options",description:"\u6E32\u67D3\u5143\u7D20\u5C5E\u6027\u65F6\u505A\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:i=>{if(i){t.push(i.name);const s=i.createTarget;return i.createTarget=function(...n){const r=s.call(i,...n);return t.some(a=>a==i.name)&&r.attr("data-name")||(r.attr({"data-name":i.name}),Ze(i,r)),r},i}}},{hook:"onDesigned",name:"i18n other selector",description:"\u5176\u4ED6UI\u9009\u62E9\u5668\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:({hiprint:i,designerUtils:s})=>{var a;Le(o);const n=(a=s.printTemplate)==null?void 0:a.id;n&&(globalThis.hinnn.event.on("PrintElementSelectEventKey_"+n,l=>{setTimeout(()=>{M([".printSetting .prop-tab-items .tab-title"])},0)}),globalThis.$(".hiprint-printPaper.design").on("contextmenu",()=>{M([".hicontextmenu .hicontextmenuitem .title span",".hicontextmenu .hicontextmenuitem .nav"])})),M([".svp-header p",".svp-tools .tool-name",".svp-dragbox .header span",".preview-bar button span",".printer-list-txt"])}},{hook:"onPreview",name:"i18n preview selector",description:"\u7EC4\u4EF6\u5185\u9884\u89C8\u9009\u62E9\u5668\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:i=>{setTimeout(()=>{M([".preview-bar button span",".printer-list-txt"])},0)}}],leastHiprintVersion:"0.1.28"}}exports.default=qe;exports.translateBySelector=M;
1
+ "use strict";var $e=Object.defineProperty,Pe=Object.defineProperties;var Re=Object.getOwnPropertyDescriptors;var ne=Object.getOwnPropertySymbols;var ke=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable;var re=(o,e,t)=>e in o?$e(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,p=(o,e)=>{for(var t in e||(e={}))ke.call(e,t)&&re(o,t,e[t]);if(ne)for(var t of ne(e))Ne.call(e,t)&&re(o,t,e[t]);return o},O=(o,e)=>Pe(o,Re(e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=o=>typeof o=="string",U=()=>{let o,e;const t=new Promise((i,s)=>{o=i,e=s});return t.resolve=o,t.reject=e,t},ae=o=>o==null?"":""+o,Fe=(o,e,t)=>{o.forEach(i=>{e[i]&&(t[i]=e[i])})},Te=/###/g,oe=o=>o&&o.indexOf("###")>-1?o.replace(Te,"."):o,le=o=>!o||g(o),H=(o,e,t)=>{const i=g(e)?e.split("."):e;let s=0;for(;s<i.length-1;){if(le(o))return{};const n=oe(i[s]);!o[n]&&t&&(o[n]=new t),Object.prototype.hasOwnProperty.call(o,n)?o=o[n]:o={},++s}return le(o)?{}:{obj:o,k:oe(i[s])}},ue=(o,e,t)=>{const{obj:i,k:s}=H(o,e,Object);if(i!==void 0||e.length===1){i[s]=t;return}let n=e[e.length-1],r=e.slice(0,e.length-1),a=H(o,r,Object);for(;a.obj===void 0&&r.length;)n=`${r[r.length-1]}.${n}`,r=r.slice(0,r.length-1),a=H(o,r,Object),a!=null&&a.obj&&typeof a.obj[`${a.k}.${n}`]!="undefined"&&(a.obj=void 0);a.obj[`${a.k}.${n}`]=t},je=(o,e,t,i)=>{const{obj:s,k:n}=H(o,e,Object);s[n]=s[n]||[],s[n].push(t)},Y=(o,e)=>{const{obj:t,k:i}=H(o,e);if(t&&Object.prototype.hasOwnProperty.call(t,i))return t[i]},Ee=(o,e,t)=>{const i=Y(o,t);return i!==void 0?i:Y(e,t)},Oe=(o,e,t)=>{for(const i in e)i!=="__proto__"&&i!=="constructor"&&(i in o?g(o[i])||o[i]instanceof String||g(e[i])||e[i]instanceof String?t&&(o[i]=e[i]):Oe(o[i],e[i],t):o[i]=e[i]);return o},D=o=>o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Ie={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const De=o=>g(o)?o.replace(/[&<>"'\/]/g,e=>Ie[e]):o;class Ve{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)return t;const i=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,i),this.regExpQueue.push(e),i}}const Ae=[" ",",","?","!",";"],Ke=new Ve(20),Ue=(o,e,t)=>{e=e||"",t=t||"";const i=Ae.filter(r=>e.indexOf(r)<0&&t.indexOf(r)<0);if(i.length===0)return!0;const s=Ke.getRegExp(`(${i.map(r=>r==="?"?"\\?":r).join("|")})`);let n=!s.test(o);if(!n){const r=o.indexOf(t);r>0&&!s.test(o.substring(0,r))&&(n=!0)}return n},q=(o,e,t=".")=>{if(!o)return;if(o[e])return Object.prototype.hasOwnProperty.call(o,e)?o[e]:void 0;const i=e.split(t);let s=o;for(let n=0;n<i.length;){if(!s||typeof s!="object")return;let r,a="";for(let l=n;l<i.length;++l)if(l!==n&&(a+=t),a+=i[l],r=s[a],r!==void 0){if(["string","number","boolean"].indexOf(typeof r)>-1&&l<i.length-1)continue;n+=l-n+1;break}s=r}return s},B=o=>o==null?void 0:o.replace("_","-"),Me={type:"logger",log(o){this.output("log",o)},warn(o){this.output("warn",o)},error(o){this.output("error",o)},output(o,e){var t,i;(i=(t=console==null?void 0:console[o])==null?void 0:t.apply)==null||i.call(t,console,e)}};class Q{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||Me,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,i,s){return s&&!this.debug?null:(g(e[0])&&(e[0]=`${i}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new Q(this.logger,p({prefix:`${this.prefix}:${e}:`},this.options))}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Q(this.logger,e)}}var N=new Q;class Z{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(i=>{this.observers[i]||(this.observers[i]=new Map);const s=this.observers[i].get(t)||0;this.observers[i].set(t,s+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([s,n])=>{for(let r=0;r<n;r++)s(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,n])=>{for(let r=0;r<n;r++)s.apply(s,[e,...t])})}}class fe extends Z{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,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 t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,i,s={}){var u,h;const n=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,r=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],i&&(Array.isArray(i)?a.push(...i):g(i)&&n?a.push(...i.split(n)):a.push(i)));const l=Y(this.data,a);return!l&&!t&&!i&&e.indexOf(".")>-1&&(e=a[0],t=a[1],i=a.slice(2).join(".")),l||!r||!g(i)?l:q((h=(u=this.data)==null?void 0:u[e])==null?void 0:h[t],i,n)}addResource(e,t,i,s,n={silent:!1}){const r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=[e,t];i&&(a=a.concat(r?i.split(r):i)),e.indexOf(".")>-1&&(a=e.split("."),s=t,t=a[1]),this.addNamespaces(t),ue(this.data,a,s),n.silent||this.emit("added",e,t,i,s)}addResources(e,t,i,s={silent:!1}){for(const n in i)(g(i[n])||Array.isArray(i[n]))&&this.addResource(e,t,n,i[n],{silent:!0});s.silent||this.emit("added",e,t,i)}addResourceBundle(e,t,i,s,n,r={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),s=i,i=t,t=a[1]),this.addNamespaces(t);let l=Y(this.data,a)||{};r.skipCopy||(i=JSON.parse(JSON.stringify(i))),s?Oe(l,i,n):l=p(p({},l),i),ue(this.data,a,l),r.silent||this.emit("added",e,t,i)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(s=>t[s]&&Object.keys(t[s]).length>0)}toJSON(){return this.data}}var we={processors:{},addPostProcessor(o){this.processors[o.name]=o},handle(o,e,t,i,s){return o.forEach(n=>{var r,a;e=(a=(r=this.processors[n])==null?void 0:r.process(e,t,i,s))!=null?a:e}),e}};const he={},ce=o=>!g(o)&&typeof o!="boolean"&&typeof o!="number";class G extends Z{constructor(e,t={}){super(),Fe(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=N.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const i=p({},t);if(e==null)return!1;const s=this.resolve(e,i);return(s==null?void 0:s.res)!==void 0}extractFromKey(e,t){let i=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;i===void 0&&(i=":");const s=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const r=i&&e.indexOf(i)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Ue(e,i,s);if(r&&!a){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:g(n)?[n]:n};const u=e.split(i);(i!==s||i===s&&this.options.ns.indexOf(u[0])>-1)&&(n=u.shift()),e=u.join(s)}return{key:e,namespaces:g(n)?[n]:n}}translate(e,t,i){let s=typeof t=="object"?p({},t):t;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof options=="object"&&(s=p({},s)),s||(s={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const n=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,r=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(e[e.length-1],s),u=l[l.length-1];let h=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const f=s.lng||this.language,m=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((f==null?void 0:f.toLowerCase())==="cimode")return m?n?{res:`${u}${h}${a}`,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(s)}:`${u}${h}${a}`:n?{res:a,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(s)}:a;const d=this.resolve(e,s);let c=d==null?void 0:d.res;const x=(d==null?void 0:d.usedKey)||a,S=(d==null?void 0:d.exactUsedKey)||a,$=["[object Number]","[object Function]","[object RegExp]"],C=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,E=!this.i18nFormat||this.i18nFormat.handleAsObject,L=s.count!==void 0&&!g(s.count),F=G.hasDefaultValue(s),J=L?this.pluralResolver.getSuffix(f,s.count,s):"",T=s.ordinal&&L?this.pluralResolver.getSuffix(f,s.count,{ordinal:!1}):"",V=L&&!s.ordinal&&s.count===0,w=V&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${J}`]||s[`defaultValue${T}`]||s.defaultValue;let b=c;E&&!c&&F&&(b=w);const ve=ce(b),Ce=Object.prototype.toString.apply(b);if(E&&b&&ve&&$.indexOf(Ce)<0&&!(g(C)&&Array.isArray(b))){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,b,O(p({},s),{ns:l})):`key '${a} (${this.language})' returned an object instead of string.`;return n?(d.res=R,d.usedParams=this.getUsedParamsDetails(s),d):R}if(r){const R=Array.isArray(b),P=R?[]:{},ee=R?S:x;for(const k in b)if(Object.prototype.hasOwnProperty.call(b,k)){const j=`${ee}${r}${k}`;F&&!c?P[k]=this.translate(j,O(p({},s),{defaultValue:ce(w)?w[k]:void 0,joinArrays:!1,ns:l})):P[k]=this.translate(j,O(p({},s),{joinArrays:!1,ns:l})),P[k]===j&&(P[k]=b[k])}c=P}}else if(E&&g(C)&&Array.isArray(c))c=c.join(C),c&&(c=this.extendTranslation(c,e,s,i));else{let R=!1,P=!1;!this.isValidLookup(c)&&F&&(R=!0,c=w),this.isValidLookup(c)||(P=!0,c=a);const k=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&P?void 0:c,j=F&&w!==c&&this.options.updateMissing;if(P||R||j){if(this.logger.log(j?"updateKey":"missingKey",f,u,a,j?w:c),r){const v=this.resolve(a,O(p({},s),{keySeparator:!1}));v&&v.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 A=[];const W=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&W&&W[0])for(let v=0;v<W.length;v++)A.push(W[v]);else this.options.saveMissingTo==="all"?A=this.languageUtils.toResolveHierarchy(s.lng||this.language):A.push(s.lng||this.language);const te=(v,I,K)=>{var se;const ie=F&&K!==c?K:k;this.options.missingKeyHandler?this.options.missingKeyHandler(v,u,I,ie,j,s):(se=this.backendConnector)!=null&&se.saveMissing&&this.backendConnector.saveMissing(v,u,I,ie,j,s),this.emit("missingKey",v,u,I,c)};this.options.saveMissing&&(this.options.saveMissingPlurals&&L?A.forEach(v=>{const I=this.pluralResolver.getSuffixes(v,s);V&&s[`defaultValue${this.options.pluralSeparator}zero`]&&I.indexOf(`${this.options.pluralSeparator}zero`)<0&&I.push(`${this.options.pluralSeparator}zero`),I.forEach(K=>{te([v],a+K,s[`defaultValue${K}`]||w)})}):te(A,a,w))}c=this.extendTranslation(c,e,s,d,i),P&&c===a&&this.options.appendNamespaceToMissingKey&&(c=`${u}${h}${a}`),(P||R)&&this.options.parseMissingKeyHandler&&(c=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${h}${a}`:a,R?c:void 0,s))}return n?(d.res=c,d.usedParams=this.getUsedParamsDetails(s),d):c}extendTranslation(e,t,i,s,n){var l,u;if((l=this.i18nFormat)!=null&&l.parse)e=this.i18nFormat.parse(e,p(p({},this.options.interpolation.defaultVariables),i),i.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init(O(p({},i),{interpolation:p(p({},this.options.interpolation),i.interpolation)}));const h=g(e)&&(((u=i==null?void 0:i.interpolation)==null?void 0:u.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(h){const d=e.match(this.interpolator.nestingRegexp);f=d&&d.length}let m=i.replace&&!g(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(m=p(p({},this.options.interpolation.defaultVariables),m)),e=this.interpolator.interpolate(e,m,i.lng||this.language||s.usedLng,i),h){const d=e.match(this.interpolator.nestingRegexp),c=d&&d.length;f<c&&(i.nest=!1)}!i.lng&&s&&s.res&&(i.lng=this.language||s.usedLng),i.nest!==!1&&(e=this.interpolator.nest(e,(...d)=>(n==null?void 0:n[0])===d[0]&&!i.context?(this.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${t[0]}`),null):this.translate(...d,t),i)),i.interpolation&&this.interpolator.reset()}const r=i.postProcess||this.options.postProcess,a=g(r)?[r]:r;return e!=null&&(a!=null&&a.length)&&i.applyPostProcessor!==!1&&(e=we.handle(a,e,t,this.options&&this.options.postProcessPassResolved?p({i18nResolved:O(p({},s),{usedParams:this.getUsedParamsDetails(i)})},i):i,this)),e}resolve(e,t={}){let i,s,n,r,a;return g(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(i))return;const u=this.extractFromKey(l,t),h=u.key;s=h;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const m=t.count!==void 0&&!g(t.count),d=m&&!t.ordinal&&t.count===0,c=t.context!==void 0&&(g(t.context)||typeof t.context=="number")&&t.context!=="",x=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);f.forEach(S=>{var $,C;this.isValidLookup(i)||(a=S,!he[`${x[0]}-${S}`]&&(($=this.utils)!=null&&$.hasLoadedNamespace)&&!((C=this.utils)!=null&&C.hasLoadedNamespace(a))&&(he[`${x[0]}-${S}`]=!0,this.logger.warn(`key "${s}" for languages "${x.join(", ")}" won't get resolved as 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!!!")),x.forEach(E=>{var J;if(this.isValidLookup(i))return;r=E;const L=[h];if((J=this.i18nFormat)!=null&&J.addLookupKeys)this.i18nFormat.addLookupKeys(L,h,E,S,t);else{let T;m&&(T=this.pluralResolver.getSuffix(E,t.count,t));const V=`${this.options.pluralSeparator}zero`,w=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(L.push(h+T),t.ordinal&&T.indexOf(w)===0&&L.push(h+T.replace(w,this.options.pluralSeparator)),d&&L.push(h+V)),c){const b=`${h}${this.options.contextSeparator}${t.context}`;L.push(b),m&&(L.push(b+T),t.ordinal&&T.indexOf(w)===0&&L.push(b+T.replace(w,this.options.pluralSeparator)),d&&L.push(b+V))}}let F;for(;F=L.pop();)this.isValidLookup(i)||(n=F,i=this.getResource(E,S,F,t))}))})}),{res:i,usedKey:s,exactUsedKey:n,usedLng:r,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,i,s={}){var n;return(n=this.i18nFormat)!=null&&n.getResource?this.i18nFormat.getResource(e,t,i,s):this.resourceStore.getResource(e,t,i,s)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=e.replace&&!g(e.replace);let s=i?e.replace:e;if(i&&typeof e.count!="undefined"&&(s.count=e.count),this.options.interpolation.defaultVariables&&(s=p(p({},this.options.interpolation.defaultVariables),s)),!i){s=p({},s);for(const n of t)delete s[n]}return s}static hasDefaultValue(e){const t="defaultValue";for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t===i.substring(0,t.length)&&e[i]!==void 0)return!0;return!1}}class de{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=N.create("languageUtils")}getScriptPartFromCode(e){if(e=B(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=B(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(g(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(i){}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(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 t;return e.forEach(i=>{if(t)return;const s=this.formatLanguageCode(i);(!this.options.supportedLngs||this.isSupportedCode(s))&&(t=s)}),!t&&this.options.supportedLngs&&e.forEach(i=>{if(t)return;const s=this.getScriptPartFromCode(i);if(this.isSupportedCode(s))return t=s;const n=this.getLanguagePartFromCode(i);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(r=>{if(r===n)return r;if(!(r.indexOf("-")<0&&n.indexOf("-")<0)&&(r.indexOf("-")>0&&n.indexOf("-")<0&&r.substring(0,r.indexOf("-"))===n||r.indexOf(n)===0&&n.length>1))return r})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),g(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let i=e[t];return i||(i=e[this.getScriptPartFromCode(t)]),i||(i=e[this.formatLanguageCode(t)]),i||(i=e[this.getLanguagePartFromCode(t)]),i||(i=e.default),i||[]}toResolveHierarchy(e,t){const i=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),s=[],n=r=>{r&&(this.isSupportedCode(r)?s.push(r):this.logger.warn(`rejecting language code not found in supportedLngs: ${r}`))};return g(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(e))):g(e)&&n(this.formatLanguageCode(e)),i.forEach(r=>{s.indexOf(r)<0&&n(this.formatLanguageCode(r))}),s}}const pe={zero:0,one:1,two:2,few:3,many:4,other:5},ge={select:o=>o===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class He{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=N.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const i=B(e==="dev"?"en":e),s=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:i,type:s});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let r;try{r=new Intl.PluralRules(i,{type:s})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ge;if(!e.match(/-|_/))return ge;const l=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(l,t)}return this.pluralRulesCache[n]=r,r}needsPlural(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),(i==null?void 0:i.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t,i={}){return this.getSuffixes(e,i).map(s=>`${t}${s}`)}getSuffixes(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),i?i.resolvedOptions().pluralCategories.sort((s,n)=>pe[s]-pe[n]).map(s=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(e,t,i={}){const s=this.getRule(e,i);return s?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${s.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,i))}}const me=(o,e,t,i=".",s=!0)=>{let n=Ee(o,e,t);return!n&&s&&g(t)&&(n=q(o,t,i),n===void 0&&(n=q(e,t,i))),n},X=o=>o.replace(/\$/g,"$$$$");class Be{constructor(e={}){var t;this.logger=N.create("interpolator"),this.options=e,this.format=((t=e==null?void 0:e.interpolation)==null?void 0:t.format)||(i=>i),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:i,useRawValueToEscape:s,prefix:n,prefixEscaped:r,suffix:a,suffixEscaped:l,formatSeparator:u,unescapeSuffix:h,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:d,nestingSuffix:c,nestingSuffixEscaped:x,nestingOptionsSeparator:S,maxReplaces:$,alwaysFormat:C}=e.interpolation;this.escape=t!==void 0?t:De,this.escapeValue=i!==void 0?i:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=n?D(n):r||"{{",this.suffix=a?D(a):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=h?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=m?D(m):d||D("$t("),this.nestingSuffix=c?D(c):x||D(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=$||1e3,this.alwaysFormat=C!==void 0?C:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,i)=>(t==null?void 0:t.source)===i?(t.lastIndex=0,t):new RegExp(i,"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,t,i,s){var d;let n,r,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=c=>{if(c.indexOf(this.formatSeparator)<0){const C=me(t,l,c,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(C,void 0,i,O(p(p({},s),t),{interpolationkey:c})):C}const x=c.split(this.formatSeparator),S=x.shift().trim(),$=x.join(this.formatSeparator).trim();return this.format(me(t,l,S,this.options.keySeparator,this.options.ignoreJSONStructure),$,i,O(p(p({},s),t),{interpolationkey:S}))};this.resetRegExp();const h=(s==null?void 0:s.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((d=s==null?void 0:s.interpolation)==null?void 0:d.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:c=>X(c)},{regex:this.regexp,safeValue:c=>this.escapeValue?X(this.escape(c)):X(c)}].forEach(c=>{for(a=0;n=c.regex.exec(e);){const x=n[1].trim();if(r=u(x),r===void 0)if(typeof h=="function"){const $=h(e,n,s);r=g($)?$:""}else if(s&&Object.prototype.hasOwnProperty.call(s,x))r="";else if(f){r=n[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),r="";else!g(r)&&!this.useRawValueToEscape&&(r=ae(r));const S=c.safeValue(r);if(e=e.replace(n[0],S),f?(c.regex.lastIndex+=r.length,c.regex.lastIndex-=n[0].length):c.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),e}nest(e,t,i={}){let s,n,r;const a=(l,u)=>{var x;const h=this.nestingOptionsSeparator;if(l.indexOf(h)<0)return l;const f=l.split(new RegExp(`${h}[ ]*{`));let m=`{${f[1]}`;l=f[0],m=this.interpolate(m,r);const d=m.match(/'/g),c=m.match(/"/g);(((x=d==null?void 0:d.length)!=null?x:0)%2===0&&!c||c.length%2!==0)&&(m=m.replace(/'/g,'"'));try{r=JSON.parse(m),u&&(r=p(p({},u),r))}catch(S){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,S),`${l}${h}${m}`}return r.defaultValue&&r.defaultValue.indexOf(this.prefix)>-1&&delete r.defaultValue,l};for(;s=this.nestingRegexp.exec(e);){let l=[];r=p({},i),r=r.replace&&!g(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.defaultValue;const u=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(u!==-1&&(l=s[1].slice(u).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),s[1]=s[1].slice(0,u)),n=t(a.call(this,s[1].trim(),r),r),n&&s[0]===e&&!g(n))return n;g(n)||(n=ae(n)),n||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((h,f)=>this.format(h,f,i.lng,O(p({},i),{interpolationkey:s[1].trim()})),n.trim())),e=e.replace(s[0],n),this.regexp.lastIndex=0}return e}}const ze=o=>{let e=o.toLowerCase().trim();const t={};if(o.indexOf("(")>-1){const i=o.split("(");e=i[0].toLowerCase().trim();const s=i[1].substring(0,i[1].length-1);e==="currency"&&s.indexOf(":")<0?t.currency||(t.currency=s.trim()):e==="relativetime"&&s.indexOf(":")<0?t.range||(t.range=s.trim()):s.split(";").forEach(r=>{if(r){const[a,...l]=r.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),h=a.trim();t[h]||(t[h]=u),u==="false"&&(t[h]=!1),u==="true"&&(t[h]=!0),isNaN(u)||(t[h]=parseInt(u,10))}})}return{formatName:e,formatOptions:t}},xe=o=>{const e={};return(t,i,s)=>{let n=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(n=O(p({},n),{[s.interpolationkey]:void 0}));const r=i+JSON.stringify(n);let a=e[r];return a||(a=o(B(i),s),e[r]=a),a(t)}},Je=o=>(e,t,i)=>o(B(t),i)(e);class We{constructor(e={}){this.logger=N.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const i=t.cacheInBuiltFormats?xe:Je;this.formats={number:i((s,n)=>{const r=new Intl.NumberFormat(s,p({},n));return a=>r.format(a)}),currency:i((s,n)=>{const r=new Intl.NumberFormat(s,O(p({},n),{style:"currency"}));return a=>r.format(a)}),datetime:i((s,n)=>{const r=new Intl.DateTimeFormat(s,p({},n));return a=>r.format(a)}),relativetime:i((s,n)=>{const r=new Intl.RelativeTimeFormat(s,p({},n));return a=>r.format(a,n.range||"day")}),list:i((s,n)=>{const r=new Intl.ListFormat(s,p({},n));return a=>r.format(a)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=xe(t)}format(e,t,i,s={}){const n=t.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find(a=>a.indexOf(")")>-1)){const a=n.findIndex(l=>l.indexOf(")")>-1);n[0]=[n[0],...n.splice(1,a)].join(this.formatSeparator)}return n.reduce((a,l)=>{var f;const{formatName:u,formatOptions:h}=ze(l);if(this.formats[u]){let m=a;try{const d=((f=s==null?void 0:s.formatParams)==null?void 0:f[s.interpolationkey])||{},c=d.locale||d.lng||s.locale||s.lng||i;m=this.formats[u](a,c,p(p(p({},h),s),d))}catch(d){this.logger.warn(d)}return m}else this.logger.warn(`there was no format function for ${u}`);return a},e)}}const _e=(o,e)=>{o.pending[e]!==void 0&&(delete o.pending[e],o.pendingCount--)};class Ye extends Z{constructor(e,t,i,s={}){var n,r;super(),this.backend=e,this.store=t,this.services=i,this.languageUtils=i.languageUtils,this.options=s,this.logger=N.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],(r=(n=this.backend)==null?void 0:n.init)==null||r.call(n,i,s.backend,s)}queueLoad(e,t,i,s){const n={},r={},a={},l={};return e.forEach(u=>{let h=!0;t.forEach(f=>{const m=`${u}|${f}`;!i.reload&&this.store.hasResourceBundle(u,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?r[m]===void 0&&(r[m]=!0):(this.state[m]=1,h=!1,r[m]===void 0&&(r[m]=!0),n[m]===void 0&&(n[m]=!0),l[f]===void 0&&(l[f]=!0)))}),h||(a[u]=!0)}),(Object.keys(n).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(n),pending:Object.keys(r),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,t,i){const s=e.split("|"),n=s[0],r=s[1];t&&this.emit("failedLoading",n,r,t),!t&&i&&this.store.addResourceBundle(n,r,i,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&i&&(this.state[e]=0);const a={};this.queue.forEach(l=>{je(l.loaded,[n],r),_e(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{a[u]||(a[u]={});const h=l.loaded[u];h.length&&h.forEach(f=>{a[u][f]===void 0&&(a[u][f]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(l=>!l.done)}read(e,t,i,s=0,n=this.retryTimeout,r){if(!e.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:i,tried:s,wait:n,callback:r});return}this.readingCalls++;const a=(u,h)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&h&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,i,s+1,n*2,r)},n);return}r(u,h)},l=this.backend[i].bind(this.backend);if(l.length===2){try{const u=l(e,t);u&&typeof u.then=="function"?u.then(h=>a(null,h)).catch(a):a(null,u)}catch(u){a(u)}return}return l(e,t,a)}prepareLoading(e,t,i={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();g(e)&&(e=this.languageUtils.toResolveHierarchy(e)),g(t)&&(t=[t]);const n=this.queueLoad(e,t,i,s);if(!n.toLoad.length)return n.pending.length||s(),null;n.toLoad.forEach(r=>{this.loadOne(r)})}load(e,t,i){this.prepareLoading(e,t,{},i)}reload(e,t,i){this.prepareLoading(e,t,{reload:!0},i)}loadOne(e,t=""){const i=e.split("|"),s=i[0],n=i[1];this.read(s,n,"read",void 0,void 0,(r,a)=>{r&&this.logger.warn(`${t}loading namespace ${n} for language ${s} failed`,r),!r&&a&&this.logger.log(`${t}loaded namespace ${n} for language ${s}`,a),this.loaded(e,r,a)})}saveMissing(e,t,i,s,n,r={},a=()=>{}){var l,u,h,f,m;if((u=(l=this.services)==null?void 0:l.utils)!=null&&u.hasLoadedNamespace&&!((f=(h=this.services)==null?void 0:h.utils)!=null&&f.hasLoadedNamespace(t))){this.logger.warn(`did not save key "${i}" as the namespace "${t}" 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(!(i==null||i==="")){if((m=this.backend)!=null&&m.create){const d=O(p({},r),{isUpdate:n}),c=this.backend.create.bind(this.backend);if(c.length<6)try{let x;c.length===5?x=c(e,t,i,s,d):x=c(e,t,i,s),x&&typeof x.then=="function"?x.then(S=>a(null,S)).catch(a):a(null,x)}catch(x){a(x)}else c(e,t,i,s,a,d)}!e||!e[0]||this.store.addResource(e[0],t,i,s)}}}const ye=()=>({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:o=>{let e={};if(typeof o[1]=="object"&&(e=o[1]),g(o[1])&&(e.defaultValue=o[1]),g(o[2])&&(e.tDescription=o[2]),typeof o[2]=="object"||typeof o[3]=="object"){const t=o[3]||o[2];Object.keys(t).forEach(i=>{e[i]=t[i]})}return e},interpolation:{escapeValue:!0,format:o=>o,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Se=o=>{var e,t;return g(o.ns)&&(o.ns=[o.ns]),g(o.fallbackLng)&&(o.fallbackLng=[o.fallbackLng]),g(o.fallbackNS)&&(o.fallbackNS=[o.fallbackNS]),((t=(e=o.supportedLngs)==null?void 0:e.indexOf)==null?void 0:t.call(e,"cimode"))<0&&(o.supportedLngs=o.supportedLngs.concat(["cimode"])),typeof o.initImmediate=="boolean"&&(o.initAsync=o.initImmediate),o},_=()=>{},Qe=o=>{Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach(t=>{typeof o[t]=="function"&&(o[t]=o[t].bind(o))})};class z extends Z{constructor(e={},t){if(super(),this.options=Se(e),this.services={},this.logger=N,this.modules={external:[]},Qe(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e=="function"&&(t=e,e={}),e.defaultNS==null&&e.ns&&(g(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const i=ye();this.options=p(p(p({},i),this.options),Se(e)),this.options.interpolation=p(p({},i.interpolation),this.options.interpolation),e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const s=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?N.init(s(this.modules.logger),this.options):N.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=We;const h=new de(this.options);this.store=new fe(this.options.resources,this.options);const f=this.services;f.logger=N,f.resourceStore=this.store,f.languageUtils=h,f.pluralResolver=new He(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==i.interpolation.format&&this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(f.formatter=s(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Be(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Ye(s(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(d,...c)=>{this.emit(d,...c)}),this.modules.languageDetector&&(f.languageDetector=s(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=s(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new G(this.services,this.options),this.translator.on("*",(d,...c)=>{this.emit(d,...c)}),this.modules.external.forEach(d=>{d.init&&d.init(this)})}if(this.format=this.options.interpolation.format,t||(t=_),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=(...h)=>this.store[u](...h)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...h)=>(this.store[u](...h),this)});const a=U(),l=()=>{const u=(h,f)=>{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),a.resolve(f),t(h,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),a}loadResources(e,t=_){var n,r;let i=t;const s=g(e)?e:this.language;if(typeof e=="function"&&(i=e),!this.options.resources||this.options.partialBundledLanguages){if((s==null?void 0:s.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return i();const a=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(f=>{f!=="cimode"&&a.indexOf(f)<0&&a.push(f)})};s?l(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(h=>l(h)),(r=(n=this.options.preload)==null?void 0:n.forEach)==null||r.call(n,u=>l(u)),this.services.backendConnector.load(a,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),i(u)})}else i(null)}reloadResources(e,t,i){const s=U();return typeof e=="function"&&(i=e,e=void 0),typeof t=="function"&&(i=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),i||(i=_),this.services.backendConnector.reload(e,t,n=>{s.resolve(),i(n)}),s}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"&&we.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 t=0;t<this.languages.length;t++){const i=this.languages[t];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const i=U();this.emit("languageChanging",e);const s=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},n=(a,l)=>{l?this.isLanguageChangingTo===e&&(s(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,i.resolve((...u)=>this.t(...u)),t&&t(a,(...u)=>this.t(...u))},r=a=>{var h,f;!e&&!a&&this.services.languageDetector&&(a=[]);const l=g(a)?a:a&&a[0],u=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(g(a)?[a]:a);u&&(this.language||s(u),this.translator.language||this.translator.changeLanguage(u),(f=(h=this.services.languageDetector)==null?void 0:h.cacheUserLanguage)==null||f.call(h,u)),this.loadResources(u,m=>{n(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?r(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(r):this.services.languageDetector.detect(r):r(e),i}getFixedT(e,t,i){const s=(n,r,...a)=>{let l;typeof r!="object"?l=this.options.overloadTranslationOptionHandler([n,r].concat(a)):l=p({},r),l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||i||s.keyPrefix);const u=this.options.keySeparator||".";let h;return l.keyPrefix&&Array.isArray(n)?h=n.map(f=>`${l.keyPrefix}${u}${f}`):h=l.keyPrefix?`${l.keyPrefix}${u}${n}`:n,this.t(h,l)};return g(e)?s.lng=e:s.lngs=e,s.ns=t,s.keyPrefix=i,s}t(...e){var t;return(t=this.translator)==null?void 0:t.translate(...e)}exists(...e){var t;return(t=this.translator)==null?void 0:t.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){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 i=t.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(i.toLowerCase()==="cimode")return!0;const r=(a,l)=>{const u=this.services.backendConnector.state[`${a}|${l}`];return u===-1||u===0||u===2};if(t.precheck){const a=t.precheck(this,r);if(a!==void 0)return a}return!!(this.hasResourceBundle(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||r(i,e)&&(!s||r(n,e)))}loadNamespaces(e,t){const i=U();return this.options.ns?(g(e)&&(e=[e]),e.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{i.resolve(),t&&t(s)}),i):(t&&t(),Promise.resolve())}loadLanguages(e,t){const i=U();g(e)&&(e=[e]);const s=this.options.preload||[],n=e.filter(r=>s.indexOf(r)<0&&this.services.languageUtils.isSupportedCode(r));return n.length?(this.options.preload=s.concat(n),this.loadResources(r=>{i.resolve(),t&&t(r)}),i):(t&&t(),Promise.resolve())}dir(e){var s,n;if(e||(e=this.resolvedLanguage||(((s=this.languages)==null?void 0:s.length)>0?this.languages[0]:this.language)),!e)return"rtl";try{const r=new Intl.Locale(e);if(r&&r.getTextInfo){const a=r.getTextInfo();if(a&&a.direction)return a.direction}}catch(r){}const t=["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"],i=((n=this.services)==null?void 0:n.languageUtils)||new de(ye());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(i.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new z(e,t)}cloneInstance(e={},t=_){const i=e.forkResourceStore;i&&delete e.forkResourceStore;const s=O(p(p({},this.options),e),{isClone:!0}),n=new z(s);if((e.debug!==void 0||e.prefix!==void 0)&&(n.logger=n.logger.clone(e)),["store","services","language"].forEach(a=>{n[a]=this[a]}),n.services=p({},this.services),n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},i){const a=Object.keys(this.store.data).reduce((l,u)=>(l[u]=p({},this.store.data[u]),l[u]=Object.keys(l[u]).reduce((h,f)=>(h[f]=p({},l[u][f]),h),l[u]),l),{});n.store=new fe(a,s),n.services.resourceStore=n.store}return n.translator=new G(n.services,s),n.translator.on("*",(a,...l)=>{n.emit(a,...l)}),n.init(s,t),n.translator.options=s,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const y=z.createInstance();y.createInstance=z.createInstance;y.createInstance;y.dir;y.init;y.loadResources;y.reloadResources;y.use;y.changeLanguage;y.getFixedT;y.t;y.exists;y.setDefaultNamespace;y.hasLoadedNamespace;y.loadNamespaces;y.loadLanguages;const Ge=(o,e)=>{for(const t of e){const i=o.find(t);i&&i.each((s,n)=>{const r=globalThis.$(n);if(r.attr("data-i18n"))return;const a=r.text().trim();a&&(r.attr({"data-i18n":a}),r.text(y.t(a)));const l=r.attr("placeholder");l&&(r.attr({"data-i18n":"[placeholder]"+l}),r.attr({placeholder:y.t(l)}))})}},M=o=>{for(const e of o){const t=globalThis.$(e);t&&t.each((i,s)=>{const n=globalThis.$(s);if(n.attr("data-i18n"))return;const r=n.text().trim();r&&(n.attr({"data-i18n":r}),n.text(y.t(r)));const a=n.attr("placeholder");a&&(n.attr({"data-i18n":"[placeholder]"+a}),n.attr({placeholder:y.t(a)}))})}},Ze=(o,e)=>{Ge(e,[".hiprint-option-item-label","textarea","input","select option",".option","button","label",".hiprint-option-title",".hiprint-option-item-desc"])},Xe=()=>{document.querySelectorAll("[data-i18n]").forEach(o=>{const e=o.getAttribute("data-i18n");if(!e.includes("[")){o.textContent=y.t(e);return}const t=e.match(/\[([^\]]+)\](.+)/);if(t&&t.length===3){const i=t[1],s=t[2];o.setAttribute(i,y.t(s))}})};let be=!1;const Le=o=>{if(be)return;be=!0,globalThis.hiprint.i18next=y,globalThis.hiprint.t=y.t;const e=Object.keys(o.resources||{});globalThis.hiprint.languages=["简体中文",...e],globalThis.hiprint.changeLanguage=(t,i)=>{y.changeLanguage(t,(s,n)=>{i&&i(s,n),Xe()})}};function qe(o,e){y.init(p({},o),(i,s)=>{e&&e(y,s,i)});let t=[];return{name:"i18n",description:"i18next",hooks:[{hook:"ready",name:"i18n set",description:"添加 i18n 方法",priority:1,run:()=>{Le(o)}},{hook:"getOptionItem",name:"i18n options",description:"渲染元素属性时做多语言处理",priority:1,run:i=>{if(i){t.push(i.name);const s=i.createTarget;return i.createTarget=function(...n){const r=s.call(i,...n);return t.some(a=>a==i.name)&&r.attr("data-name")||(r.attr({"data-name":i.name}),Ze(i,r)),r},i}}},{hook:"onDesigned",name:"i18n other selector",description:"其他UI选择器多语言处理",priority:1,run:({hiprint:i,designerUtils:s})=>{var a;Le(o);const n=(a=s.printTemplate)==null?void 0:a.id;n&&(globalThis.hinnn.event.on("PrintElementSelectEventKey_"+n,l=>{setTimeout(()=>{M([".printSetting .prop-tab-items .tab-title"])},0)}),globalThis.$(".hiprint-printPaper.design").on("contextmenu",()=>{M([".hicontextmenu .hicontextmenuitem .title span",".hicontextmenu .hicontextmenuitem .nav"])})),M([".svp-header p",".svp-tools .tool-name",".svp-dragbox .header span",".preview-bar button span",".printer-list-txt"])}},{hook:"onPreview",name:"i18n preview selector",description:"组件内预览选择器多语言处理",priority:1,run:i=>{setTimeout(()=>{M([".preview-bar button span",".printer-list-txt"])},0)}}],leastHiprintVersion:"0.1.28"}}exports.default=qe;exports.translateBySelector=M;
package/dist/index.mjs CHANGED
@@ -16,16 +16,15 @@ const g = (o) => typeof o == "string", U = () => {
16
16
  o = i, e = s;
17
17
  });
18
18
  return t.resolve = o, t.reject = e, t;
19
- }, ae = (o) => o == null ? "" : "" + o, Ee = (o, e, t) => {
19
+ }, ae = (o) => o == null ? "" : "" + o, Fe = (o, e, t) => {
20
20
  o.forEach((i) => {
21
21
  e[i] && (t[i] = e[i]);
22
22
  });
23
- }, Fe = /###/g, oe = (o) => o && o.indexOf("###") > -1 ? o.replace(Fe, ".") : o, le = (o) => !o || g(o), M = (o, e, t) => {
23
+ }, Te = /###/g, oe = (o) => o && o.indexOf("###") > -1 ? o.replace(Te, ".") : o, le = (o) => !o || g(o), M = (o, e, t) => {
24
24
  const i = g(e) ? e.split(".") : e;
25
25
  let s = 0;
26
26
  for (; s < i.length - 1; ) {
27
- if (le(o))
28
- return {};
27
+ if (le(o)) return {};
29
28
  const n = oe(i[s]);
30
29
  !o[n] && t && (o[n] = new t()), Object.prototype.hasOwnProperty.call(o, n) ? o = o[n] : o = {}, ++s;
31
30
  }
@@ -44,9 +43,9 @@ const g = (o) => typeof o == "string", U = () => {
44
43
  }
45
44
  let n = e[e.length - 1], r = e.slice(0, e.length - 1), a = M(o, r, Object);
46
45
  for (; a.obj === void 0 && r.length; )
47
- n = `${r[r.length - 1]}.${n}`, r = r.slice(0, r.length - 1), a = M(o, r, Object), (a == null ? void 0 : a.obj) && typeof a.obj[`${a.k}.${n}`] != "undefined" && (a.obj = void 0);
46
+ n = `${r[r.length - 1]}.${n}`, r = r.slice(0, r.length - 1), a = M(o, r, Object), a != null && a.obj && typeof a.obj[`${a.k}.${n}`] != "undefined" && (a.obj = void 0);
48
47
  a.obj[`${a.k}.${n}`] = t;
49
- }, Te = (o, e, t, i) => {
48
+ }, je = (o, e, t, i) => {
50
49
  const {
51
50
  obj: s,
52
51
  k: n
@@ -57,17 +56,17 @@ const g = (o) => typeof o == "string", U = () => {
57
56
  obj: t,
58
57
  k: i
59
58
  } = M(o, e);
60
- if (!!t && !!Object.prototype.hasOwnProperty.call(t, i))
59
+ if (t && Object.prototype.hasOwnProperty.call(t, i))
61
60
  return t[i];
62
- }, je = (o, e, t) => {
61
+ }, Ee = (o, e, t) => {
63
62
  const i = Y(o, t);
64
63
  return i !== void 0 ? i : Y(e, t);
65
64
  }, Oe = (o, e, t) => {
66
65
  for (const i in e)
67
66
  i !== "__proto__" && i !== "constructor" && (i in o ? g(o[i]) || o[i] instanceof String || g(e[i]) || e[i] instanceof String ? t && (o[i] = e[i]) : Oe(o[i], e[i], t) : o[i] = e[i]);
68
67
  return o;
69
- }, I = (o) => o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
70
- var De = {
68
+ }, D = (o) => o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
69
+ var Ie = {
71
70
  "&": "&amp;",
72
71
  "<": "&lt;",
73
72
  ">": "&gt;",
@@ -75,8 +74,8 @@ var De = {
75
74
  "'": "&#39;",
76
75
  "/": "&#x2F;"
77
76
  };
78
- const Ie = (o) => g(o) ? o.replace(/[&<>"'\/]/g, (e) => De[e]) : o;
79
- class Ae {
77
+ const De = (o) => g(o) ? o.replace(/[&<>"'\/]/g, (e) => Ie[e]) : o;
78
+ class Ve {
80
79
  constructor(e) {
81
80
  this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
82
81
  }
@@ -88,11 +87,10 @@ class Ae {
88
87
  return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, i), this.regExpQueue.push(e), i;
89
88
  }
90
89
  }
91
- const Ve = [" ", ",", "?", "!", ";"], Ke = new Ae(20), Ue = (o, e, t) => {
90
+ const Ae = [" ", ",", "?", "!", ";"], Ke = new Ve(20), Ue = (o, e, t) => {
92
91
  e = e || "", t = t || "";
93
- const i = Ve.filter((r) => e.indexOf(r) < 0 && t.indexOf(r) < 0);
94
- if (i.length === 0)
95
- return !0;
92
+ const i = Ae.filter((r) => e.indexOf(r) < 0 && t.indexOf(r) < 0);
93
+ if (i.length === 0) return !0;
96
94
  const s = Ke.getRegExp(`(${i.map((r) => r === "?" ? "\\?" : r).join("|")})`);
97
95
  let n = !s.test(o);
98
96
  if (!n) {
@@ -101,8 +99,7 @@ const Ve = [" ", ",", "?", "!", ";"], Ke = new Ae(20), Ue = (o, e, t) => {
101
99
  }
102
100
  return n;
103
101
  }, q = (o, e, t = ".") => {
104
- if (!o)
105
- return;
102
+ if (!o) return;
106
103
  if (o[e])
107
104
  return Object.prototype.hasOwnProperty.call(o, e) ? o[e] : void 0;
108
105
  const i = e.split(t);
@@ -121,7 +118,7 @@ const Ve = [" ", ",", "?", "!", ";"], Ke = new Ae(20), Ue = (o, e, t) => {
121
118
  s = r;
122
119
  }
123
120
  return s;
124
- }, B = (o) => o == null ? void 0 : o.replace("_", "-"), Me = {
121
+ }, H = (o) => o == null ? void 0 : o.replace("_", "-"), Me = {
125
122
  type: "logger",
126
123
  log(o) {
127
124
  this.output("log", o);
@@ -181,7 +178,7 @@ class Z {
181
178
  }), this;
182
179
  }
183
180
  off(e, t) {
184
- if (!!this.observers[e]) {
181
+ if (this.observers[e]) {
185
182
  if (!t) {
186
183
  delete this.observers[e];
187
184
  return;
@@ -281,7 +278,7 @@ var we = {
281
278
  const he = {}, ce = (o) => !g(o) && typeof o != "boolean" && typeof o != "number";
282
279
  class G extends Z {
283
280
  constructor(e, t = {}) {
284
- super(), Ee(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = N.create("translator");
281
+ super(), Fe(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = N.create("translator");
285
282
  }
286
283
  changeLanguage(e) {
287
284
  e && (this.language = e);
@@ -290,8 +287,7 @@ class G extends Z {
290
287
  interpolation: {}
291
288
  }) {
292
289
  const i = p({}, t);
293
- if (e == null)
294
- return !1;
290
+ if (e == null) return !1;
295
291
  const s = this.resolve(e, i);
296
292
  return (s == null ? void 0 : s.res) !== void 0;
297
293
  }
@@ -318,8 +314,7 @@ class G extends Z {
318
314
  }
319
315
  translate(e, t, i) {
320
316
  let s = typeof t == "object" ? p({}, t) : t;
321
- if (typeof s != "object" && this.options.overloadTranslationOptionHandler && (s = this.options.overloadTranslationOptionHandler(arguments)), typeof options == "object" && (s = p({}, s)), s || (s = {}), e == null)
322
- return "";
317
+ if (typeof s != "object" && this.options.overloadTranslationOptionHandler && (s = this.options.overloadTranslationOptionHandler(arguments)), typeof options == "object" && (s = p({}, s)), s || (s = {}), e == null) return "";
323
318
  Array.isArray(e) || (e = [String(e)]);
324
319
  const n = s.returnDetails !== void 0 ? s.returnDetails : this.options.returnDetails, r = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, {
325
320
  key: a,
@@ -346,13 +341,13 @@ class G extends Z {
346
341
  } : a;
347
342
  const d = this.resolve(e, s);
348
343
  let c = d == null ? void 0 : d.res;
349
- const x = (d == null ? void 0 : d.usedKey) || a, S = (d == null ? void 0 : d.exactUsedKey) || a, $ = ["[object Number]", "[object Function]", "[object RegExp]"], v = s.joinArrays !== void 0 ? s.joinArrays : this.options.joinArrays, j = !this.i18nFormat || this.i18nFormat.handleAsObject, L = s.count !== void 0 && !g(s.count), E = G.hasDefaultValue(s), z = L ? this.pluralResolver.getSuffix(f, s.count, s) : "", F = s.ordinal && L ? this.pluralResolver.getSuffix(f, s.count, {
344
+ const x = (d == null ? void 0 : d.usedKey) || a, S = (d == null ? void 0 : d.exactUsedKey) || a, $ = ["[object Number]", "[object Function]", "[object RegExp]"], C = s.joinArrays !== void 0 ? s.joinArrays : this.options.joinArrays, E = !this.i18nFormat || this.i18nFormat.handleAsObject, L = s.count !== void 0 && !g(s.count), F = G.hasDefaultValue(s), z = L ? this.pluralResolver.getSuffix(f, s.count, s) : "", T = s.ordinal && L ? this.pluralResolver.getSuffix(f, s.count, {
350
345
  ordinal: !1
351
- }) : "", A = L && !s.ordinal && s.count === 0, w = A && s[`defaultValue${this.options.pluralSeparator}zero`] || s[`defaultValue${z}`] || s[`defaultValue${F}`] || s.defaultValue;
346
+ }) : "", V = L && !s.ordinal && s.count === 0, w = V && s[`defaultValue${this.options.pluralSeparator}zero`] || s[`defaultValue${z}`] || s[`defaultValue${T}`] || s.defaultValue;
352
347
  let b = c;
353
- j && !c && E && (b = w);
354
- const Ce = ce(b), ve = Object.prototype.toString.apply(b);
355
- if (j && b && Ce && $.indexOf(ve) < 0 && !(g(v) && Array.isArray(b))) {
348
+ E && !c && F && (b = w);
349
+ const ve = ce(b), Ce = Object.prototype.toString.apply(b);
350
+ if (E && b && ve && $.indexOf(Ce) < 0 && !(g(C) && Array.isArray(b))) {
356
351
  if (!s.returnObjects && !this.options.returnObjects) {
357
352
  this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
358
353
  const P = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(x, b, O(p({}, s), {
@@ -364,49 +359,48 @@ class G extends Z {
364
359
  const P = Array.isArray(b), R = P ? [] : {}, ee = P ? S : x;
365
360
  for (const k in b)
366
361
  if (Object.prototype.hasOwnProperty.call(b, k)) {
367
- const T = `${ee}${r}${k}`;
368
- E && !c ? R[k] = this.translate(T, O(p({}, s), {
362
+ const j = `${ee}${r}${k}`;
363
+ F && !c ? R[k] = this.translate(j, O(p({}, s), {
369
364
  defaultValue: ce(w) ? w[k] : void 0,
370
365
  joinArrays: !1,
371
366
  ns: l
372
- })) : R[k] = this.translate(T, O(p({}, s), {
367
+ })) : R[k] = this.translate(j, O(p({}, s), {
373
368
  joinArrays: !1,
374
369
  ns: l
375
- })), R[k] === T && (R[k] = b[k]);
370
+ })), R[k] === j && (R[k] = b[k]);
376
371
  }
377
372
  c = R;
378
373
  }
379
- } else if (j && g(v) && Array.isArray(c))
380
- c = c.join(v), c && (c = this.extendTranslation(c, e, s, i));
374
+ } else if (E && g(C) && Array.isArray(c))
375
+ c = c.join(C), c && (c = this.extendTranslation(c, e, s, i));
381
376
  else {
382
377
  let P = !1, R = !1;
383
- !this.isValidLookup(c) && E && (P = !0, c = w), this.isValidLookup(c) || (R = !0, c = a);
384
- const k = (s.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && R ? void 0 : c, T = E && w !== c && this.options.updateMissing;
385
- if (R || P || T) {
386
- if (this.logger.log(T ? "updateKey" : "missingKey", f, u, a, T ? w : c), r) {
387
- const C = this.resolve(a, O(p({}, s), {
378
+ !this.isValidLookup(c) && F && (P = !0, c = w), this.isValidLookup(c) || (R = !0, c = a);
379
+ const k = (s.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && R ? void 0 : c, j = F && w !== c && this.options.updateMissing;
380
+ if (R || P || j) {
381
+ if (this.logger.log(j ? "updateKey" : "missingKey", f, u, a, j ? w : c), r) {
382
+ const v = this.resolve(a, O(p({}, s), {
388
383
  keySeparator: !1
389
384
  }));
390
- C && C.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.");
385
+ v && v.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.");
391
386
  }
392
- let V = [];
387
+ let A = [];
393
388
  const J = this.languageUtils.getFallbackCodes(this.options.fallbackLng, s.lng || this.language);
394
389
  if (this.options.saveMissingTo === "fallback" && J && J[0])
395
- for (let C = 0; C < J.length; C++)
396
- V.push(J[C]);
397
- else
398
- this.options.saveMissingTo === "all" ? V = this.languageUtils.toResolveHierarchy(s.lng || this.language) : V.push(s.lng || this.language);
399
- const te = (C, D, K) => {
390
+ for (let v = 0; v < J.length; v++)
391
+ A.push(J[v]);
392
+ else this.options.saveMissingTo === "all" ? A = this.languageUtils.toResolveHierarchy(s.lng || this.language) : A.push(s.lng || this.language);
393
+ const te = (v, I, K) => {
400
394
  var se;
401
- const ie = E && K !== c ? K : k;
402
- this.options.missingKeyHandler ? this.options.missingKeyHandler(C, u, D, ie, T, s) : (se = this.backendConnector) != null && se.saveMissing && this.backendConnector.saveMissing(C, u, D, ie, T, s), this.emit("missingKey", C, u, D, c);
395
+ const ie = F && K !== c ? K : k;
396
+ this.options.missingKeyHandler ? this.options.missingKeyHandler(v, u, I, ie, j, s) : (se = this.backendConnector) != null && se.saveMissing && this.backendConnector.saveMissing(v, u, I, ie, j, s), this.emit("missingKey", v, u, I, c);
403
397
  };
404
- this.options.saveMissing && (this.options.saveMissingPlurals && L ? V.forEach((C) => {
405
- const D = this.pluralResolver.getSuffixes(C, s);
406
- A && s[`defaultValue${this.options.pluralSeparator}zero`] && D.indexOf(`${this.options.pluralSeparator}zero`) < 0 && D.push(`${this.options.pluralSeparator}zero`), D.forEach((K) => {
407
- te([C], a + K, s[`defaultValue${K}`] || w);
398
+ this.options.saveMissing && (this.options.saveMissingPlurals && L ? A.forEach((v) => {
399
+ const I = this.pluralResolver.getSuffixes(v, s);
400
+ V && s[`defaultValue${this.options.pluralSeparator}zero`] && I.indexOf(`${this.options.pluralSeparator}zero`) < 0 && I.push(`${this.options.pluralSeparator}zero`), I.forEach((K) => {
401
+ te([v], a + K, s[`defaultValue${K}`] || w);
408
402
  });
409
- }) : te(V, a, w));
403
+ }) : te(A, a, w));
410
404
  }
411
405
  c = this.extendTranslation(c, e, s, d, i), R && c === a && this.options.appendNamespaceToMissingKey && (c = `${u}${h}${a}`), (R || P) && this.options.parseMissingKeyHandler && (c = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${u}${h}${a}` : a, P ? c : void 0, s));
412
406
  }
@@ -436,7 +430,7 @@ class G extends Z {
436
430
  !i.lng && s && s.res && (i.lng = this.language || s.usedLng), i.nest !== !1 && (e = this.interpolator.nest(e, (...d) => (n == null ? void 0 : n[0]) === d[0] && !i.context ? (this.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${t[0]}`), null) : this.translate(...d, t), i)), i.interpolation && this.interpolator.reset();
437
431
  }
438
432
  const r = i.postProcess || this.options.postProcess, a = g(r) ? [r] : r;
439
- return e != null && (a == null ? void 0 : a.length) && i.applyPostProcessor !== !1 && (e = we.handle(a, e, t, this.options && this.options.postProcessPassResolved ? p({
433
+ return e != null && (a != null && a.length) && i.applyPostProcessor !== !1 && (e = we.handle(a, e, t, this.options && this.options.postProcessPassResolved ? p({
440
434
  i18nResolved: O(p({}, s), {
441
435
  usedParams: this.getUsedParamsDetails(i)
442
436
  })
@@ -445,35 +439,33 @@ class G extends Z {
445
439
  resolve(e, t = {}) {
446
440
  let i, s, n, r, a;
447
441
  return g(e) && (e = [e]), e.forEach((l) => {
448
- if (this.isValidLookup(i))
449
- return;
442
+ if (this.isValidLookup(i)) return;
450
443
  const u = this.extractFromKey(l, t), h = u.key;
451
444
  s = h;
452
445
  let f = u.namespaces;
453
446
  this.options.fallbackNS && (f = f.concat(this.options.fallbackNS));
454
447
  const m = t.count !== void 0 && !g(t.count), d = m && !t.ordinal && t.count === 0, c = t.context !== void 0 && (g(t.context) || typeof t.context == "number") && t.context !== "", x = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
455
448
  f.forEach((S) => {
456
- var $, v;
457
- this.isValidLookup(i) || (a = S, !he[`${x[0]}-${S}`] && (($ = this.utils) == null ? void 0 : $.hasLoadedNamespace) && !((v = this.utils) != null && v.hasLoadedNamespace(a)) && (he[`${x[0]}-${S}`] = !0, this.logger.warn(`key "${s}" for languages "${x.join(", ")}" won't get resolved as 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!!!")), x.forEach((j) => {
449
+ var $, C;
450
+ this.isValidLookup(i) || (a = S, !he[`${x[0]}-${S}`] && (($ = this.utils) != null && $.hasLoadedNamespace) && !((C = this.utils) != null && C.hasLoadedNamespace(a)) && (he[`${x[0]}-${S}`] = !0, this.logger.warn(`key "${s}" for languages "${x.join(", ")}" won't get resolved as 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!!!")), x.forEach((E) => {
458
451
  var z;
459
- if (this.isValidLookup(i))
460
- return;
461
- r = j;
452
+ if (this.isValidLookup(i)) return;
453
+ r = E;
462
454
  const L = [h];
463
455
  if ((z = this.i18nFormat) != null && z.addLookupKeys)
464
- this.i18nFormat.addLookupKeys(L, h, j, S, t);
456
+ this.i18nFormat.addLookupKeys(L, h, E, S, t);
465
457
  else {
466
- let F;
467
- m && (F = this.pluralResolver.getSuffix(j, t.count, t));
468
- const A = `${this.options.pluralSeparator}zero`, w = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
469
- if (m && (L.push(h + F), t.ordinal && F.indexOf(w) === 0 && L.push(h + F.replace(w, this.options.pluralSeparator)), d && L.push(h + A)), c) {
458
+ let T;
459
+ m && (T = this.pluralResolver.getSuffix(E, t.count, t));
460
+ const V = `${this.options.pluralSeparator}zero`, w = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
461
+ if (m && (L.push(h + T), t.ordinal && T.indexOf(w) === 0 && L.push(h + T.replace(w, this.options.pluralSeparator)), d && L.push(h + V)), c) {
470
462
  const b = `${h}${this.options.contextSeparator}${t.context}`;
471
- L.push(b), m && (L.push(b + F), t.ordinal && F.indexOf(w) === 0 && L.push(b + F.replace(w, this.options.pluralSeparator)), d && L.push(b + A));
463
+ L.push(b), m && (L.push(b + T), t.ordinal && T.indexOf(w) === 0 && L.push(b + T.replace(w, this.options.pluralSeparator)), d && L.push(b + V));
472
464
  }
473
465
  }
474
- let E;
475
- for (; E = L.pop(); )
476
- this.isValidLookup(i) || (n = E, i = this.getResource(j, S, E, t));
466
+ let F;
467
+ for (; F = L.pop(); )
468
+ this.isValidLookup(i) || (n = F, i = this.getResource(E, S, F, t));
477
469
  }));
478
470
  });
479
471
  }), {
@@ -514,14 +506,12 @@ class de {
514
506
  this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = N.create("languageUtils");
515
507
  }
516
508
  getScriptPartFromCode(e) {
517
- if (e = B(e), !e || e.indexOf("-") < 0)
518
- return null;
509
+ if (e = H(e), !e || e.indexOf("-") < 0) return null;
519
510
  const t = e.split("-");
520
511
  return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
521
512
  }
522
513
  getLanguagePartFromCode(e) {
523
- if (e = B(e), !e || e.indexOf("-") < 0)
524
- return e;
514
+ if (e = H(e), !e || e.indexOf("-") < 0) return e;
525
515
  const t = e.split("-");
526
516
  return this.formatLanguageCode(t[0]);
527
517
  }
@@ -540,44 +530,35 @@ class de {
540
530
  return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
541
531
  }
542
532
  getBestMatchFromCodes(e) {
543
- if (!e)
544
- return null;
533
+ if (!e) return null;
545
534
  let t;
546
535
  return e.forEach((i) => {
547
- if (t)
548
- return;
536
+ if (t) return;
549
537
  const s = this.formatLanguageCode(i);
550
538
  (!this.options.supportedLngs || this.isSupportedCode(s)) && (t = s);
551
539
  }), !t && this.options.supportedLngs && e.forEach((i) => {
552
- if (t)
553
- return;
540
+ if (t) return;
554
541
  const s = this.getScriptPartFromCode(i);
555
- if (this.isSupportedCode(s))
556
- return t = s;
542
+ if (this.isSupportedCode(s)) return t = s;
557
543
  const n = this.getLanguagePartFromCode(i);
558
- if (this.isSupportedCode(n))
559
- return t = n;
544
+ if (this.isSupportedCode(n)) return t = n;
560
545
  t = this.options.supportedLngs.find((r) => {
561
- if (r === n)
562
- return r;
546
+ if (r === n) return r;
563
547
  if (!(r.indexOf("-") < 0 && n.indexOf("-") < 0) && (r.indexOf("-") > 0 && n.indexOf("-") < 0 && r.substring(0, r.indexOf("-")) === n || r.indexOf(n) === 0 && n.length > 1))
564
548
  return r;
565
549
  });
566
550
  }), t || (t = this.getFallbackCodes(this.options.fallbackLng)[0]), t;
567
551
  }
568
552
  getFallbackCodes(e, t) {
569
- if (!e)
570
- return [];
571
- if (typeof e == "function" && (e = e(t)), g(e) && (e = [e]), Array.isArray(e))
572
- return e;
573
- if (!t)
574
- return e.default || [];
553
+ if (!e) return [];
554
+ if (typeof e == "function" && (e = e(t)), g(e) && (e = [e]), Array.isArray(e)) return e;
555
+ if (!t) return e.default || [];
575
556
  let i = e[t];
576
557
  return i || (i = e[this.getScriptPartFromCode(t)]), i || (i = e[this.formatLanguageCode(t)]), i || (i = e[this.getLanguagePartFromCode(t)]), i || (i = e.default), i || [];
577
558
  }
578
559
  toResolveHierarchy(e, t) {
579
560
  const i = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), s = [], n = (r) => {
580
- !r || (this.isSupportedCode(r) ? s.push(r) : this.logger.warn(`rejecting language code not found in supportedLngs: ${r}`));
561
+ r && (this.isSupportedCode(r) ? s.push(r) : this.logger.warn(`rejecting language code not found in supportedLngs: ${r}`));
581
562
  };
582
563
  return g(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && n(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && n(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && n(this.getLanguagePartFromCode(e))) : g(e) && n(this.formatLanguageCode(e)), i.forEach((r) => {
583
564
  s.indexOf(r) < 0 && n(this.formatLanguageCode(r));
@@ -597,7 +578,7 @@ const pe = {
597
578
  pluralCategories: ["one", "other"]
598
579
  })
599
580
  };
600
- class Be {
581
+ class He {
601
582
  constructor(e, t = {}) {
602
583
  this.languageUtils = e, this.options = t, this.logger = N.create("pluralResolver"), this.pluralRulesCache = {};
603
584
  }
@@ -608,7 +589,7 @@ class Be {
608
589
  this.pluralRulesCache = {};
609
590
  }
610
591
  getRule(e, t = {}) {
611
- const i = B(e === "dev" ? "en" : e), s = t.ordinal ? "ordinal" : "cardinal", n = JSON.stringify({
592
+ const i = H(e === "dev" ? "en" : e), s = t.ordinal ? "ordinal" : "cardinal", n = JSON.stringify({
612
593
  cleanedCode: i,
613
594
  type: s
614
595
  });
@@ -622,8 +603,7 @@ class Be {
622
603
  } catch (a) {
623
604
  if (!Intl)
624
605
  return this.logger.error("No Intl support, please use an Intl polyfill!"), ge;
625
- if (!e.match(/-|_/))
626
- return ge;
606
+ if (!e.match(/-|_/)) return ge;
627
607
  const l = this.languageUtils.getLanguagePartFromCode(e);
628
608
  r = this.getRule(l, t);
629
609
  }
@@ -646,10 +626,10 @@ class Be {
646
626
  }
647
627
  }
648
628
  const me = (o, e, t, i = ".", s = !0) => {
649
- let n = je(o, e, t);
629
+ let n = Ee(o, e, t);
650
630
  return !n && s && g(t) && (n = q(o, t, i), n === void 0 && (n = q(e, t, i))), n;
651
631
  }, X = (o) => o.replace(/\$/g, "$$$$");
652
- class He {
632
+ class Be {
653
633
  constructor(e = {}) {
654
634
  var t;
655
635
  this.logger = N.create("interpolator"), this.options = e, this.format = ((t = e == null ? void 0 : e.interpolation) == null ? void 0 : t.format) || ((i) => i), this.init(e);
@@ -675,9 +655,9 @@ class He {
675
655
  nestingSuffixEscaped: x,
676
656
  nestingOptionsSeparator: S,
677
657
  maxReplaces: $,
678
- alwaysFormat: v
658
+ alwaysFormat: C
679
659
  } = e.interpolation;
680
- this.escape = t !== void 0 ? t : Ie, this.escapeValue = i !== void 0 ? i : !0, this.useRawValueToEscape = s !== void 0 ? s : !1, this.prefix = n ? I(n) : r || "{{", this.suffix = a ? I(a) : l || "}}", this.formatSeparator = u || ",", this.unescapePrefix = h ? "" : f || "-", this.unescapeSuffix = this.unescapePrefix ? "" : h || "", this.nestingPrefix = m ? I(m) : d || I("$t("), this.nestingSuffix = c ? I(c) : x || I(")"), this.nestingOptionsSeparator = S || ",", this.maxReplaces = $ || 1e3, this.alwaysFormat = v !== void 0 ? v : !1, this.resetRegExp();
660
+ this.escape = t !== void 0 ? t : De, this.escapeValue = i !== void 0 ? i : !0, this.useRawValueToEscape = s !== void 0 ? s : !1, this.prefix = n ? D(n) : r || "{{", this.suffix = a ? D(a) : l || "}}", this.formatSeparator = u || ",", this.unescapePrefix = h ? "" : f || "-", this.unescapeSuffix = this.unescapePrefix ? "" : h || "", this.nestingPrefix = m ? D(m) : d || D("$t("), this.nestingSuffix = c ? D(c) : x || D(")"), this.nestingOptionsSeparator = S || ",", this.maxReplaces = $ || 1e3, this.alwaysFormat = C !== void 0 ? C : !1, this.resetRegExp();
681
661
  }
682
662
  reset() {
683
663
  this.options && this.init(this.options);
@@ -691,10 +671,10 @@ class He {
691
671
  let n, r, a;
692
672
  const l = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, u = (c) => {
693
673
  if (c.indexOf(this.formatSeparator) < 0) {
694
- const v = me(t, l, c, this.options.keySeparator, this.options.ignoreJSONStructure);
695
- return this.alwaysFormat ? this.format(v, void 0, i, O(p(p({}, s), t), {
674
+ const C = me(t, l, c, this.options.keySeparator, this.options.ignoreJSONStructure);
675
+ return this.alwaysFormat ? this.format(C, void 0, i, O(p(p({}, s), t), {
696
676
  interpolationkey: c
697
- })) : v;
677
+ })) : C;
698
678
  }
699
679
  const x = c.split(this.formatSeparator), S = x.shift().trim(), $ = x.join(this.formatSeparator).trim();
700
680
  return this.format(me(t, l, S, this.options.keySeparator, this.options.ignoreJSONStructure), $, i, O(p(p({}, s), t), {
@@ -723,8 +703,7 @@ class He {
723
703
  continue;
724
704
  } else
725
705
  this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`), r = "";
726
- else
727
- !g(r) && !this.useRawValueToEscape && (r = ae(r));
706
+ else !g(r) && !this.useRawValueToEscape && (r = ae(r));
728
707
  const S = c.safeValue(r);
729
708
  if (e = e.replace(n[0], S), f ? (c.regex.lastIndex += r.length, c.regex.lastIndex -= n[0].length) : c.regex.lastIndex = 0, a++, a >= this.maxReplaces)
730
709
  break;
@@ -736,8 +715,7 @@ class He {
736
715
  const a = (l, u) => {
737
716
  var x;
738
717
  const h = this.nestingOptionsSeparator;
739
- if (l.indexOf(h) < 0)
740
- return l;
718
+ if (l.indexOf(h) < 0) return l;
741
719
  const f = l.split(new RegExp(`${h}[ ]*{`));
742
720
  let m = `{${f[1]}`;
743
721
  l = f[0], m = this.interpolate(m, r);
@@ -754,8 +732,7 @@ class He {
754
732
  let l = [];
755
733
  r = p({}, i), r = r.replace && !g(r.replace) ? r.replace : r, r.applyPostProcessor = !1, delete r.defaultValue;
756
734
  const u = /{.*}/.test(s[1]) ? s[1].lastIndexOf("}") + 1 : s[1].indexOf(this.formatSeparator);
757
- if (u !== -1 && (l = s[1].slice(u).split(this.formatSeparator).map((h) => h.trim()).filter(Boolean), s[1] = s[1].slice(0, u)), n = t(a.call(this, s[1].trim(), r), r), n && s[0] === e && !g(n))
758
- return n;
735
+ if (u !== -1 && (l = s[1].slice(u).split(this.formatSeparator).map((h) => h.trim()).filter(Boolean), s[1] = s[1].slice(0, u)), n = t(a.call(this, s[1].trim(), r), r), n && s[0] === e && !g(n)) return n;
759
736
  g(n) || (n = ae(n)), n || (this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`), n = ""), l.length && (n = l.reduce((h, f) => this.format(h, f, i.lng, O(p({}, i), {
760
737
  interpolationkey: s[1].trim()
761
738
  })), n.trim())), e = e.replace(s[0], n), this.regexp.lastIndex = 0;
@@ -790,9 +767,9 @@ const ze = (o) => {
790
767
  }));
791
768
  const r = i + JSON.stringify(n);
792
769
  let a = e[r];
793
- return a || (a = o(B(i), s), e[r] = a), a(t);
770
+ return a || (a = o(H(i), s), e[r] = a), a(t);
794
771
  };
795
- }, Je = (o) => (e, t, i) => o(B(t), i)(e);
772
+ }, Je = (o) => (e, t, i) => o(H(t), i)(e);
796
773
  class We {
797
774
  constructor(e = {}) {
798
775
  this.logger = N.create("formatter"), this.options = e, this.init(e);
@@ -896,7 +873,7 @@ class Ye extends Z {
896
873
  }), this.state[e] = t ? -1 : 2, t && i && (this.state[e] = 0);
897
874
  const a = {};
898
875
  this.queue.forEach((l) => {
899
- Te(l.loaded, [n], r), _e(l, e), t && l.errors.push(t), l.pendingCount === 0 && !l.done && (Object.keys(l.loaded).forEach((u) => {
876
+ je(l.loaded, [n], r), _e(l, e), t && l.errors.push(t), l.pendingCount === 0 && !l.done && (Object.keys(l.loaded).forEach((u) => {
900
877
  a[u] || (a[u] = {});
901
878
  const h = l.loaded[u];
902
879
  h.length && h.forEach((f) => {
@@ -906,8 +883,7 @@ class Ye extends Z {
906
883
  }), this.emit("loaded", a), this.queue = this.queue.filter((l) => !l.done);
907
884
  }
908
885
  read(e, t, i, s = 0, n = this.retryTimeout, r) {
909
- if (!e.length)
910
- return r(null, {});
886
+ if (!e.length) return r(null, {});
911
887
  if (this.readingCalls >= this.maxParallelReads) {
912
888
  this.waitingReads.push({
913
889
  lng: e,
@@ -972,7 +948,7 @@ class Ye extends Z {
972
948
  saveMissing(e, t, i, s, n, r = {}, a = () => {
973
949
  }) {
974
950
  var l, u, h, f, m;
975
- if (((u = (l = this.services) == null ? void 0 : l.utils) == null ? void 0 : u.hasLoadedNamespace) && !((f = (h = this.services) == null ? void 0 : h.utils) != null && f.hasLoadedNamespace(t))) {
951
+ if ((u = (l = this.services) == null ? void 0 : l.utils) != null && u.hasLoadedNamespace && !((f = (h = this.services) == null ? void 0 : h.utils) != null && f.hasLoadedNamespace(t))) {
976
952
  this.logger.warn(`did not save key "${i}" as the namespace "${t}" 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!!!");
977
953
  return;
978
954
  }
@@ -1061,7 +1037,7 @@ const ye = () => ({
1061
1037
  typeof o[t] == "function" && (o[t] = o[t].bind(o));
1062
1038
  });
1063
1039
  };
1064
- class H extends Z {
1040
+ class B extends Z {
1065
1041
  constructor(e = {}, t) {
1066
1042
  if (super(), this.options = Se(e), this.services = {}, this.logger = N, this.modules = {
1067
1043
  external: []
@@ -1085,10 +1061,10 @@ class H extends Z {
1085
1061
  const h = new de(this.options);
1086
1062
  this.store = new fe(this.options.resources, this.options);
1087
1063
  const f = this.services;
1088
- f.logger = N, f.resourceStore = this.store, f.languageUtils = h, f.pluralResolver = new Be(h, {
1064
+ f.logger = N, f.resourceStore = this.store, f.languageUtils = h, f.pluralResolver = new He(h, {
1089
1065
  prepend: this.options.pluralSeparator,
1090
1066
  simplifyPluralSuffix: this.options.simplifyPluralSuffix
1091
- }), this.options.interpolation.format && this.options.interpolation.format !== i.interpolation.format && this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"), u && (!this.options.interpolation.format || this.options.interpolation.format === i.interpolation.format) && (f.formatter = s(u), f.formatter.init && f.formatter.init(f, this.options), this.options.interpolation.format = f.formatter.format.bind(f.formatter)), f.interpolator = new He(this.options), f.utils = {
1067
+ }), this.options.interpolation.format && this.options.interpolation.format !== i.interpolation.format && this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"), u && (!this.options.interpolation.format || this.options.interpolation.format === i.interpolation.format) && (f.formatter = s(u), f.formatter.init && f.formatter.init(f, this.options), this.options.interpolation.format = f.formatter.format.bind(f.formatter)), f.interpolator = new Be(this.options), f.utils = {
1092
1068
  hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1093
1069
  }, f.backendConnector = new Ye(s(this.modules.backend), f.resourceStore, f, this.options), f.backendConnector.on("*", (d, ...c) => {
1094
1070
  this.emit(d, ...c);
@@ -1111,8 +1087,7 @@ class H extends Z {
1111
1087
  const u = (h, f) => {
1112
1088
  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), a.resolve(f), t(h, f);
1113
1089
  };
1114
- if (this.languages && !this.isInitialized)
1115
- return u(null, this.t.bind(this));
1090
+ if (this.languages && !this.isInitialized) return u(null, this.t.bind(this));
1116
1091
  this.changeLanguage(this.options.lng, u);
1117
1092
  };
1118
1093
  return this.options.resources || !this.options.initAsync ? l() : setTimeout(l, 0), a;
@@ -1122,11 +1097,9 @@ class H extends Z {
1122
1097
  let i = t;
1123
1098
  const s = g(e) ? e : this.language;
1124
1099
  if (typeof e == "function" && (i = e), !this.options.resources || this.options.partialBundledLanguages) {
1125
- if ((s == null ? void 0 : s.toLowerCase()) === "cimode" && (!this.options.preload || this.options.preload.length === 0))
1126
- return i();
1100
+ if ((s == null ? void 0 : s.toLowerCase()) === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return i();
1127
1101
  const a = [], l = (u) => {
1128
- if (!u || u === "cimode")
1129
- return;
1102
+ if (!u || u === "cimode") return;
1130
1103
  this.services.languageUtils.toResolveHierarchy(u).forEach((f) => {
1131
1104
  f !== "cimode" && a.indexOf(f) < 0 && a.push(f);
1132
1105
  });
@@ -1144,10 +1117,8 @@ class H extends Z {
1144
1117
  }), s;
1145
1118
  }
1146
1119
  use(e) {
1147
- if (!e)
1148
- throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
1149
- if (!e.type)
1150
- throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
1120
+ if (!e) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
1121
+ if (!e.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
1151
1122
  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" && we.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
1152
1123
  }
1153
1124
  setResolvedLanguage(e) {
@@ -1207,16 +1178,14 @@ class H extends Z {
1207
1178
  if (!this.languages || !this.languages.length)
1208
1179
  return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
1209
1180
  const i = t.lng || this.resolvedLanguage || this.languages[0], s = this.options ? this.options.fallbackLng : !1, n = this.languages[this.languages.length - 1];
1210
- if (i.toLowerCase() === "cimode")
1211
- return !0;
1181
+ if (i.toLowerCase() === "cimode") return !0;
1212
1182
  const r = (a, l) => {
1213
1183
  const u = this.services.backendConnector.state[`${a}|${l}`];
1214
1184
  return u === -1 || u === 0 || u === 2;
1215
1185
  };
1216
1186
  if (t.precheck) {
1217
1187
  const a = t.precheck(this, r);
1218
- if (a !== void 0)
1219
- return a;
1188
+ if (a !== void 0) return a;
1220
1189
  }
1221
1190
  return !!(this.hasResourceBundle(i, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || r(i, e) && (!s || r(n, e)));
1222
1191
  }
@@ -1238,14 +1207,12 @@ class H extends Z {
1238
1207
  }
1239
1208
  dir(e) {
1240
1209
  var s, n;
1241
- if (e || (e = this.resolvedLanguage || (((s = this.languages) == null ? void 0 : s.length) > 0 ? this.languages[0] : this.language)), !e)
1242
- return "rtl";
1210
+ if (e || (e = this.resolvedLanguage || (((s = this.languages) == null ? void 0 : s.length) > 0 ? this.languages[0] : this.language)), !e) return "rtl";
1243
1211
  try {
1244
1212
  const r = new Intl.Locale(e);
1245
1213
  if (r && r.getTextInfo) {
1246
1214
  const a = r.getTextInfo();
1247
- if (a && a.direction)
1248
- return a.direction;
1215
+ if (a && a.direction) return a.direction;
1249
1216
  }
1250
1217
  } catch (r) {
1251
1218
  }
@@ -1253,14 +1220,14 @@ class H extends Z {
1253
1220
  return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.indexOf(i.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
1254
1221
  }
1255
1222
  static createInstance(e = {}, t) {
1256
- return new H(e, t);
1223
+ return new B(e, t);
1257
1224
  }
1258
1225
  cloneInstance(e = {}, t = W) {
1259
1226
  const i = e.forkResourceStore;
1260
1227
  i && delete e.forkResourceStore;
1261
1228
  const s = O(p(p({}, this.options), e), {
1262
1229
  isClone: !0
1263
- }), n = new H(s);
1230
+ }), n = new B(s);
1264
1231
  if ((e.debug !== void 0 || e.prefix !== void 0) && (n.logger = n.logger.clone(e)), ["store", "services", "language"].forEach((a) => {
1265
1232
  n[a] = this[a];
1266
1233
  }), n.services = p({}, this.services), n.services.utils = {
@@ -1285,8 +1252,8 @@ class H extends Z {
1285
1252
  };
1286
1253
  }
1287
1254
  }
1288
- const y = H.createInstance();
1289
- y.createInstance = H.createInstance;
1255
+ const y = B.createInstance();
1256
+ y.createInstance = B.createInstance;
1290
1257
  y.createInstance;
1291
1258
  y.dir;
1292
1259
  y.init;
@@ -1371,7 +1338,7 @@ const Le = (o) => {
1371
1338
  return;
1372
1339
  be = !0, globalThis.hiprint.i18next = y, globalThis.hiprint.t = y.t;
1373
1340
  const e = Object.keys(o.resources || {});
1374
- globalThis.hiprint.languages = ["\u7B80\u4F53\u4E2D\u6587", ...e], globalThis.hiprint.changeLanguage = (t, i) => {
1341
+ globalThis.hiprint.languages = ["简体中文", ...e], globalThis.hiprint.changeLanguage = (t, i) => {
1375
1342
  y.changeLanguage(t, (s, n) => {
1376
1343
  i && i(s, n), Xe();
1377
1344
  });
@@ -1389,7 +1356,7 @@ function et(o, e) {
1389
1356
  {
1390
1357
  hook: "ready",
1391
1358
  name: "i18n set",
1392
- description: "\u6DFB\u52A0 i18n \u65B9\u6CD5",
1359
+ description: "添加 i18n 方法",
1393
1360
  priority: 1,
1394
1361
  run: () => {
1395
1362
  Le(o);
@@ -1398,7 +1365,7 @@ function et(o, e) {
1398
1365
  {
1399
1366
  hook: "getOptionItem",
1400
1367
  name: "i18n options",
1401
- description: "\u6E32\u67D3\u5143\u7D20\u5C5E\u6027\u65F6\u505A\u591A\u8BED\u8A00\u5904\u7406",
1368
+ description: "渲染元素属性时做多语言处理",
1402
1369
  priority: 1,
1403
1370
  run: (i) => {
1404
1371
  if (i) {
@@ -1416,7 +1383,7 @@ function et(o, e) {
1416
1383
  {
1417
1384
  hook: "onDesigned",
1418
1385
  name: "i18n other selector",
1419
- description: "\u5176\u4ED6UI\u9009\u62E9\u5668\u591A\u8BED\u8A00\u5904\u7406",
1386
+ description: "其他UI选择器多语言处理",
1420
1387
  priority: 1,
1421
1388
  run: ({ hiprint: i, designerUtils: s }) => {
1422
1389
  var a;
@@ -1443,7 +1410,7 @@ function et(o, e) {
1443
1410
  {
1444
1411
  hook: "onPreview",
1445
1412
  name: "i18n preview selector",
1446
- description: "\u7EC4\u4EF6\u5185\u9884\u89C8\u9009\u62E9\u5668\u591A\u8BED\u8A00\u5904\u7406",
1413
+ description: "组件内预览选择器多语言处理",
1447
1414
  priority: 1,
1448
1415
  run: (i) => {
1449
1416
  setTimeout(() => {
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(b,d){typeof exports=="object"&&typeof module!="undefined"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(b=typeof globalThis!="undefined"?globalThis:b||self,d(b.pluginI18n={}))})(this,function(b){"use strict";var Ge=Object.defineProperty,Ze=Object.defineProperties;var Xe=Object.getOwnPropertyDescriptors;var we=Object.getOwnPropertySymbols;var qe=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable;var Ce=(b,d,L)=>d in b?Ge(b,d,{enumerable:!0,configurable:!0,writable:!0,value:L}):b[d]=L,g=(b,d)=>{for(var L in d||(d={}))qe.call(d,L)&&Ce(b,L,d[L]);if(we)for(var L of we(d))et.call(d,L)&&Ce(b,L,d[L]);return b},C=(b,d)=>Ze(b,Xe(d));const d=o=>typeof o=="string",L=()=>{let o,e;const t=new Promise((i,s)=>{o=i,e=s});return t.resolve=o,t.reject=e,t},te=o=>o==null?"":""+o,ve=(o,e,t)=>{o.forEach(i=>{e[i]&&(t[i]=e[i])})},$e=/###/g,ie=o=>o&&o.indexOf("###")>-1?o.replace($e,"."):o,se=o=>!o||d(o),K=(o,e,t)=>{const i=d(e)?e.split("."):e;let s=0;for(;s<i.length-1;){if(se(o))return{};const n=ie(i[s]);!o[n]&&t&&(o[n]=new t),Object.prototype.hasOwnProperty.call(o,n)?o=o[n]:o={},++s}return se(o)?{}:{obj:o,k:ie(i[s])}},ne=(o,e,t)=>{const{obj:i,k:s}=K(o,e,Object);if(i!==void 0||e.length===1){i[s]=t;return}let n=e[e.length-1],r=e.slice(0,e.length-1),a=K(o,r,Object);for(;a.obj===void 0&&r.length;)n=`${r[r.length-1]}.${n}`,r=r.slice(0,r.length-1),a=K(o,r,Object),(a==null?void 0:a.obj)&&typeof a.obj[`${a.k}.${n}`]!="undefined"&&(a.obj=void 0);a.obj[`${a.k}.${n}`]=t},Pe=(o,e,t,i)=>{const{obj:s,k:n}=K(o,e,Object);s[n]=s[n]||[],s[n].push(t)},W=(o,e)=>{const{obj:t,k:i}=K(o,e);if(!!t&&!!Object.prototype.hasOwnProperty.call(t,i))return t[i]},Re=(o,e,t)=>{const i=W(o,t);return i!==void 0?i:W(e,t)},re=(o,e,t)=>{for(const i in e)i!=="__proto__"&&i!=="constructor"&&(i in o?d(o[i])||o[i]instanceof String||d(e[i])||e[i]instanceof String?t&&(o[i]=e[i]):re(o[i],e[i],t):o[i]=e[i]);return o},V=o=>o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var ke={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Ne=o=>d(o)?o.replace(/[&<>"'\/]/g,e=>ke[e]):o;class Ee{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)return t;const i=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,i),this.regExpQueue.push(e),i}}const Fe=[" ",",","?","!",";"],Te=new Ee(20),je=(o,e,t)=>{e=e||"",t=t||"";const i=Fe.filter(r=>e.indexOf(r)<0&&t.indexOf(r)<0);if(i.length===0)return!0;const s=Te.getRegExp(`(${i.map(r=>r==="?"?"\\?":r).join("|")})`);let n=!s.test(o);if(!n){const r=o.indexOf(t);r>0&&!s.test(o.substring(0,r))&&(n=!0)}return n},q=(o,e,t=".")=>{if(!o)return;if(o[e])return Object.prototype.hasOwnProperty.call(o,e)?o[e]:void 0;const i=e.split(t);let s=o;for(let n=0;n<i.length;){if(!s||typeof s!="object")return;let r,a="";for(let l=n;l<i.length;++l)if(l!==n&&(a+=t),a+=i[l],r=s[a],r!==void 0){if(["string","number","boolean"].indexOf(typeof r)>-1&&l<i.length-1)continue;n+=l-n+1;break}s=r}return s},U=o=>o==null?void 0:o.replace("_","-"),Ie={type:"logger",log(o){this.output("log",o)},warn(o){this.output("warn",o)},error(o){this.output("error",o)},output(o,e){var t,i;(i=(t=console==null?void 0:console[o])==null?void 0:t.apply)==null||i.call(t,console,e)}};class _{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||Ie,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,i,s){return s&&!this.debug?null:(d(e[0])&&(e[0]=`${i}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new _(this.logger,g({prefix:`${this.prefix}:${e}:`},this.options))}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new _(this.logger,e)}}var N=new _;class Y{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(i=>{this.observers[i]||(this.observers[i]=new Map);const s=this.observers[i].get(t)||0;this.observers[i].set(t,s+1)}),this}off(e,t){if(!!this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([s,n])=>{for(let r=0;r<n;r++)s(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,n])=>{for(let r=0;r<n;r++)s.apply(s,[e,...t])})}}class ae extends Y{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,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 t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,i,s={}){var u,h;const n=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,r=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],i&&(Array.isArray(i)?a.push(...i):d(i)&&n?a.push(...i.split(n)):a.push(i)));const l=W(this.data,a);return!l&&!t&&!i&&e.indexOf(".")>-1&&(e=a[0],t=a[1],i=a.slice(2).join(".")),l||!r||!d(i)?l:q((h=(u=this.data)==null?void 0:u[e])==null?void 0:h[t],i,n)}addResource(e,t,i,s,n={silent:!1}){const r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=[e,t];i&&(a=a.concat(r?i.split(r):i)),e.indexOf(".")>-1&&(a=e.split("."),s=t,t=a[1]),this.addNamespaces(t),ne(this.data,a,s),n.silent||this.emit("added",e,t,i,s)}addResources(e,t,i,s={silent:!1}){for(const n in i)(d(i[n])||Array.isArray(i[n]))&&this.addResource(e,t,n,i[n],{silent:!0});s.silent||this.emit("added",e,t,i)}addResourceBundle(e,t,i,s,n,r={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),s=i,i=t,t=a[1]),this.addNamespaces(t);let l=W(this.data,a)||{};r.skipCopy||(i=JSON.parse(JSON.stringify(i))),s?re(l,i,n):l=g(g({},l),i),ne(this.data,a,l),r.silent||this.emit("added",e,t,i)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(s=>t[s]&&Object.keys(t[s]).length>0)}toJSON(){return this.data}}var oe={processors:{},addPostProcessor(o){this.processors[o.name]=o},handle(o,e,t,i,s){return o.forEach(n=>{var r,a;e=(a=(r=this.processors[n])==null?void 0:r.process(e,t,i,s))!=null?a:e}),e}};const le={},ue=o=>!d(o)&&typeof o!="boolean"&&typeof o!="number";class Q extends Y{constructor(e,t={}){super(),ve(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=N.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const i=g({},t);if(e==null)return!1;const s=this.resolve(e,i);return(s==null?void 0:s.res)!==void 0}extractFromKey(e,t){let i=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;i===void 0&&(i=":");const s=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const r=i&&e.indexOf(i)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!je(e,i,s);if(r&&!a){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:d(n)?[n]:n};const u=e.split(i);(i!==s||i===s&&this.options.ns.indexOf(u[0])>-1)&&(n=u.shift()),e=u.join(s)}return{key:e,namespaces:d(n)?[n]:n}}translate(e,t,i){let s=typeof t=="object"?g({},t):t;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof options=="object"&&(s=g({},s)),s||(s={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const n=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,r=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(e[e.length-1],s),u=l[l.length-1];let h=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const f=s.lng||this.language,m=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((f==null?void 0:f.toLowerCase())==="cimode")return m?n?{res:`${u}${h}${a}`,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(s)}:`${u}${h}${a}`:n?{res:a,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(s)}:a;const p=this.resolve(e,s);let c=p==null?void 0:p.res;const x=(p==null?void 0:p.usedKey)||a,S=(p==null?void 0:p.exactUsedKey)||a,R=["[object Number]","[object Function]","[object RegExp]"],P=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,D=!this.i18nFormat||this.i18nFormat.handleAsObject,w=s.count!==void 0&&!d(s.count),T=Q.hasDefaultValue(s),Z=w?this.pluralResolver.getSuffix(f,s.count,s):"",j=s.ordinal&&w?this.pluralResolver.getSuffix(f,s.count,{ordinal:!1}):"",H=w&&!s.ordinal&&s.count===0,v=H&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${Z}`]||s[`defaultValue${j}`]||s.defaultValue;let O=c;D&&!c&&T&&(O=v);const Ye=ue(O),Qe=Object.prototype.toString.apply(O);if(D&&O&&Ye&&R.indexOf(Qe)<0&&!(d(P)&&Array.isArray(O))){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const E=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,O,C(g({},s),{ns:l})):`key '${a} (${this.language})' returned an object instead of string.`;return n?(p.res=E,p.usedParams=this.getUsedParamsDetails(s),p):E}if(r){const E=Array.isArray(O),k=E?[]:{},Se=E?S:x;for(const F in O)if(Object.prototype.hasOwnProperty.call(O,F)){const I=`${Se}${r}${F}`;T&&!c?k[F]=this.translate(I,C(g({},s),{defaultValue:ue(v)?v[F]:void 0,joinArrays:!1,ns:l})):k[F]=this.translate(I,C(g({},s),{joinArrays:!1,ns:l})),k[F]===I&&(k[F]=O[F])}c=k}}else if(D&&d(P)&&Array.isArray(c))c=c.join(P),c&&(c=this.extendTranslation(c,e,s,i));else{let E=!1,k=!1;!this.isValidLookup(c)&&T&&(E=!0,c=v),this.isValidLookup(c)||(k=!0,c=a);const F=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&k?void 0:c,I=T&&v!==c&&this.options.updateMissing;if(k||E||I){if(this.logger.log(I?"updateKey":"missingKey",f,u,a,I?v:c),r){const $=this.resolve(a,C(g({},s),{keySeparator:!1}));$&&$.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 z=[];const X=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&X&&X[0])for(let $=0;$<X.length;$++)z.push(X[$]);else this.options.saveMissingTo==="all"?z=this.languageUtils.toResolveHierarchy(s.lng||this.language):z.push(s.lng||this.language);const be=($,A,J)=>{var Oe;const Le=T&&J!==c?J:F;this.options.missingKeyHandler?this.options.missingKeyHandler($,u,A,Le,I,s):(Oe=this.backendConnector)!=null&&Oe.saveMissing&&this.backendConnector.saveMissing($,u,A,Le,I,s),this.emit("missingKey",$,u,A,c)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?z.forEach($=>{const A=this.pluralResolver.getSuffixes($,s);H&&s[`defaultValue${this.options.pluralSeparator}zero`]&&A.indexOf(`${this.options.pluralSeparator}zero`)<0&&A.push(`${this.options.pluralSeparator}zero`),A.forEach(J=>{be([$],a+J,s[`defaultValue${J}`]||v)})}):be(z,a,v))}c=this.extendTranslation(c,e,s,p,i),k&&c===a&&this.options.appendNamespaceToMissingKey&&(c=`${u}${h}${a}`),(k||E)&&this.options.parseMissingKeyHandler&&(c=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${h}${a}`:a,E?c:void 0,s))}return n?(p.res=c,p.usedParams=this.getUsedParamsDetails(s),p):c}extendTranslation(e,t,i,s,n){var l,u;if((l=this.i18nFormat)!=null&&l.parse)e=this.i18nFormat.parse(e,g(g({},this.options.interpolation.defaultVariables),i),i.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init(C(g({},i),{interpolation:g(g({},this.options.interpolation),i.interpolation)}));const h=d(e)&&(((u=i==null?void 0:i.interpolation)==null?void 0:u.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(h){const p=e.match(this.interpolator.nestingRegexp);f=p&&p.length}let m=i.replace&&!d(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(m=g(g({},this.options.interpolation.defaultVariables),m)),e=this.interpolator.interpolate(e,m,i.lng||this.language||s.usedLng,i),h){const p=e.match(this.interpolator.nestingRegexp),c=p&&p.length;f<c&&(i.nest=!1)}!i.lng&&s&&s.res&&(i.lng=this.language||s.usedLng),i.nest!==!1&&(e=this.interpolator.nest(e,(...p)=>(n==null?void 0:n[0])===p[0]&&!i.context?(this.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${t[0]}`),null):this.translate(...p,t),i)),i.interpolation&&this.interpolator.reset()}const r=i.postProcess||this.options.postProcess,a=d(r)?[r]:r;return e!=null&&(a==null?void 0:a.length)&&i.applyPostProcessor!==!1&&(e=oe.handle(a,e,t,this.options&&this.options.postProcessPassResolved?g({i18nResolved:C(g({},s),{usedParams:this.getUsedParamsDetails(i)})},i):i,this)),e}resolve(e,t={}){let i,s,n,r,a;return d(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(i))return;const u=this.extractFromKey(l,t),h=u.key;s=h;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const m=t.count!==void 0&&!d(t.count),p=m&&!t.ordinal&&t.count===0,c=t.context!==void 0&&(d(t.context)||typeof t.context=="number")&&t.context!=="",x=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);f.forEach(S=>{var R,P;this.isValidLookup(i)||(a=S,!le[`${x[0]}-${S}`]&&((R=this.utils)==null?void 0:R.hasLoadedNamespace)&&!((P=this.utils)!=null&&P.hasLoadedNamespace(a))&&(le[`${x[0]}-${S}`]=!0,this.logger.warn(`key "${s}" for languages "${x.join(", ")}" won't get resolved as 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!!!")),x.forEach(D=>{var Z;if(this.isValidLookup(i))return;r=D;const w=[h];if((Z=this.i18nFormat)!=null&&Z.addLookupKeys)this.i18nFormat.addLookupKeys(w,h,D,S,t);else{let j;m&&(j=this.pluralResolver.getSuffix(D,t.count,t));const H=`${this.options.pluralSeparator}zero`,v=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(w.push(h+j),t.ordinal&&j.indexOf(v)===0&&w.push(h+j.replace(v,this.options.pluralSeparator)),p&&w.push(h+H)),c){const O=`${h}${this.options.contextSeparator}${t.context}`;w.push(O),m&&(w.push(O+j),t.ordinal&&j.indexOf(v)===0&&w.push(O+j.replace(v,this.options.pluralSeparator)),p&&w.push(O+H))}}let T;for(;T=w.pop();)this.isValidLookup(i)||(n=T,i=this.getResource(D,S,T,t))}))})}),{res:i,usedKey:s,exactUsedKey:n,usedLng:r,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,i,s={}){var n;return(n=this.i18nFormat)!=null&&n.getResource?this.i18nFormat.getResource(e,t,i,s):this.resourceStore.getResource(e,t,i,s)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=e.replace&&!d(e.replace);let s=i?e.replace:e;if(i&&typeof e.count!="undefined"&&(s.count=e.count),this.options.interpolation.defaultVariables&&(s=g(g({},this.options.interpolation.defaultVariables),s)),!i){s=g({},s);for(const n of t)delete s[n]}return s}static hasDefaultValue(e){const t="defaultValue";for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t===i.substring(0,t.length)&&e[i]!==void 0)return!0;return!1}}class fe{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=N.create("languageUtils")}getScriptPartFromCode(e){if(e=U(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=U(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(d(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(i){}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(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 t;return e.forEach(i=>{if(t)return;const s=this.formatLanguageCode(i);(!this.options.supportedLngs||this.isSupportedCode(s))&&(t=s)}),!t&&this.options.supportedLngs&&e.forEach(i=>{if(t)return;const s=this.getScriptPartFromCode(i);if(this.isSupportedCode(s))return t=s;const n=this.getLanguagePartFromCode(i);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(r=>{if(r===n)return r;if(!(r.indexOf("-")<0&&n.indexOf("-")<0)&&(r.indexOf("-")>0&&n.indexOf("-")<0&&r.substring(0,r.indexOf("-"))===n||r.indexOf(n)===0&&n.length>1))return r})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),d(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let i=e[t];return i||(i=e[this.getScriptPartFromCode(t)]),i||(i=e[this.formatLanguageCode(t)]),i||(i=e[this.getLanguagePartFromCode(t)]),i||(i=e.default),i||[]}toResolveHierarchy(e,t){const i=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),s=[],n=r=>{!r||(this.isSupportedCode(r)?s.push(r):this.logger.warn(`rejecting language code not found in supportedLngs: ${r}`))};return d(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(e))):d(e)&&n(this.formatLanguageCode(e)),i.forEach(r=>{s.indexOf(r)<0&&n(this.formatLanguageCode(r))}),s}}const he={zero:0,one:1,two:2,few:3,many:4,other:5},ce={select:o=>o===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class De{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=N.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const i=U(e==="dev"?"en":e),s=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:i,type:s});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let r;try{r=new Intl.PluralRules(i,{type:s})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ce;if(!e.match(/-|_/))return ce;const l=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(l,t)}return this.pluralRulesCache[n]=r,r}needsPlural(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),(i==null?void 0:i.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t,i={}){return this.getSuffixes(e,i).map(s=>`${t}${s}`)}getSuffixes(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),i?i.resolvedOptions().pluralCategories.sort((s,n)=>he[s]-he[n]).map(s=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(e,t,i={}){const s=this.getRule(e,i);return s?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${s.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,i))}}const de=(o,e,t,i=".",s=!0)=>{let n=Re(o,e,t);return!n&&s&&d(t)&&(n=q(o,t,i),n===void 0&&(n=q(e,t,i))),n},ee=o=>o.replace(/\$/g,"$$$$");class Ae{constructor(e={}){var t;this.logger=N.create("interpolator"),this.options=e,this.format=((t=e==null?void 0:e.interpolation)==null?void 0:t.format)||(i=>i),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:i,useRawValueToEscape:s,prefix:n,prefixEscaped:r,suffix:a,suffixEscaped:l,formatSeparator:u,unescapeSuffix:h,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:p,nestingSuffix:c,nestingSuffixEscaped:x,nestingOptionsSeparator:S,maxReplaces:R,alwaysFormat:P}=e.interpolation;this.escape=t!==void 0?t:Ne,this.escapeValue=i!==void 0?i:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=n?V(n):r||"{{",this.suffix=a?V(a):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=h?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=m?V(m):p||V("$t("),this.nestingSuffix=c?V(c):x||V(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=R||1e3,this.alwaysFormat=P!==void 0?P:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,i)=>(t==null?void 0:t.source)===i?(t.lastIndex=0,t):new RegExp(i,"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,t,i,s){var p;let n,r,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=c=>{if(c.indexOf(this.formatSeparator)<0){const P=de(t,l,c,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(P,void 0,i,C(g(g({},s),t),{interpolationkey:c})):P}const x=c.split(this.formatSeparator),S=x.shift().trim(),R=x.join(this.formatSeparator).trim();return this.format(de(t,l,S,this.options.keySeparator,this.options.ignoreJSONStructure),R,i,C(g(g({},s),t),{interpolationkey:S}))};this.resetRegExp();const h=(s==null?void 0:s.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((p=s==null?void 0:s.interpolation)==null?void 0:p.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:c=>ee(c)},{regex:this.regexp,safeValue:c=>this.escapeValue?ee(this.escape(c)):ee(c)}].forEach(c=>{for(a=0;n=c.regex.exec(e);){const x=n[1].trim();if(r=u(x),r===void 0)if(typeof h=="function"){const R=h(e,n,s);r=d(R)?R:""}else if(s&&Object.prototype.hasOwnProperty.call(s,x))r="";else if(f){r=n[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),r="";else!d(r)&&!this.useRawValueToEscape&&(r=te(r));const S=c.safeValue(r);if(e=e.replace(n[0],S),f?(c.regex.lastIndex+=r.length,c.regex.lastIndex-=n[0].length):c.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),e}nest(e,t,i={}){let s,n,r;const a=(l,u)=>{var x;const h=this.nestingOptionsSeparator;if(l.indexOf(h)<0)return l;const f=l.split(new RegExp(`${h}[ ]*{`));let m=`{${f[1]}`;l=f[0],m=this.interpolate(m,r);const p=m.match(/'/g),c=m.match(/"/g);(((x=p==null?void 0:p.length)!=null?x:0)%2===0&&!c||c.length%2!==0)&&(m=m.replace(/'/g,'"'));try{r=JSON.parse(m),u&&(r=g(g({},u),r))}catch(S){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,S),`${l}${h}${m}`}return r.defaultValue&&r.defaultValue.indexOf(this.prefix)>-1&&delete r.defaultValue,l};for(;s=this.nestingRegexp.exec(e);){let l=[];r=g({},i),r=r.replace&&!d(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.defaultValue;const u=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(u!==-1&&(l=s[1].slice(u).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),s[1]=s[1].slice(0,u)),n=t(a.call(this,s[1].trim(),r),r),n&&s[0]===e&&!d(n))return n;d(n)||(n=te(n)),n||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((h,f)=>this.format(h,f,i.lng,C(g({},i),{interpolationkey:s[1].trim()})),n.trim())),e=e.replace(s[0],n),this.regexp.lastIndex=0}return e}}const Ve=o=>{let e=o.toLowerCase().trim();const t={};if(o.indexOf("(")>-1){const i=o.split("(");e=i[0].toLowerCase().trim();const s=i[1].substring(0,i[1].length-1);e==="currency"&&s.indexOf(":")<0?t.currency||(t.currency=s.trim()):e==="relativetime"&&s.indexOf(":")<0?t.range||(t.range=s.trim()):s.split(";").forEach(r=>{if(r){const[a,...l]=r.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),h=a.trim();t[h]||(t[h]=u),u==="false"&&(t[h]=!1),u==="true"&&(t[h]=!0),isNaN(u)||(t[h]=parseInt(u,10))}})}return{formatName:e,formatOptions:t}},pe=o=>{const e={};return(t,i,s)=>{let n=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(n=C(g({},n),{[s.interpolationkey]:void 0}));const r=i+JSON.stringify(n);let a=e[r];return a||(a=o(U(i),s),e[r]=a),a(t)}},Ke=o=>(e,t,i)=>o(U(t),i)(e);class Ue{constructor(e={}){this.logger=N.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const i=t.cacheInBuiltFormats?pe:Ke;this.formats={number:i((s,n)=>{const r=new Intl.NumberFormat(s,g({},n));return a=>r.format(a)}),currency:i((s,n)=>{const r=new Intl.NumberFormat(s,C(g({},n),{style:"currency"}));return a=>r.format(a)}),datetime:i((s,n)=>{const r=new Intl.DateTimeFormat(s,g({},n));return a=>r.format(a)}),relativetime:i((s,n)=>{const r=new Intl.RelativeTimeFormat(s,g({},n));return a=>r.format(a,n.range||"day")}),list:i((s,n)=>{const r=new Intl.ListFormat(s,g({},n));return a=>r.format(a)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=pe(t)}format(e,t,i,s={}){const n=t.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find(a=>a.indexOf(")")>-1)){const a=n.findIndex(l=>l.indexOf(")")>-1);n[0]=[n[0],...n.splice(1,a)].join(this.formatSeparator)}return n.reduce((a,l)=>{var f;const{formatName:u,formatOptions:h}=Ve(l);if(this.formats[u]){let m=a;try{const p=((f=s==null?void 0:s.formatParams)==null?void 0:f[s.interpolationkey])||{},c=p.locale||p.lng||s.locale||s.lng||i;m=this.formats[u](a,c,g(g(g({},h),s),p))}catch(p){this.logger.warn(p)}return m}else this.logger.warn(`there was no format function for ${u}`);return a},e)}}const Me=(o,e)=>{o.pending[e]!==void 0&&(delete o.pending[e],o.pendingCount--)};class Be extends Y{constructor(e,t,i,s={}){var n,r;super(),this.backend=e,this.store=t,this.services=i,this.languageUtils=i.languageUtils,this.options=s,this.logger=N.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],(r=(n=this.backend)==null?void 0:n.init)==null||r.call(n,i,s.backend,s)}queueLoad(e,t,i,s){const n={},r={},a={},l={};return e.forEach(u=>{let h=!0;t.forEach(f=>{const m=`${u}|${f}`;!i.reload&&this.store.hasResourceBundle(u,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?r[m]===void 0&&(r[m]=!0):(this.state[m]=1,h=!1,r[m]===void 0&&(r[m]=!0),n[m]===void 0&&(n[m]=!0),l[f]===void 0&&(l[f]=!0)))}),h||(a[u]=!0)}),(Object.keys(n).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(n),pending:Object.keys(r),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,t,i){const s=e.split("|"),n=s[0],r=s[1];t&&this.emit("failedLoading",n,r,t),!t&&i&&this.store.addResourceBundle(n,r,i,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&i&&(this.state[e]=0);const a={};this.queue.forEach(l=>{Pe(l.loaded,[n],r),Me(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{a[u]||(a[u]={});const h=l.loaded[u];h.length&&h.forEach(f=>{a[u][f]===void 0&&(a[u][f]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(l=>!l.done)}read(e,t,i,s=0,n=this.retryTimeout,r){if(!e.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:i,tried:s,wait:n,callback:r});return}this.readingCalls++;const a=(u,h)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&h&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,i,s+1,n*2,r)},n);return}r(u,h)},l=this.backend[i].bind(this.backend);if(l.length===2){try{const u=l(e,t);u&&typeof u.then=="function"?u.then(h=>a(null,h)).catch(a):a(null,u)}catch(u){a(u)}return}return l(e,t,a)}prepareLoading(e,t,i={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();d(e)&&(e=this.languageUtils.toResolveHierarchy(e)),d(t)&&(t=[t]);const n=this.queueLoad(e,t,i,s);if(!n.toLoad.length)return n.pending.length||s(),null;n.toLoad.forEach(r=>{this.loadOne(r)})}load(e,t,i){this.prepareLoading(e,t,{},i)}reload(e,t,i){this.prepareLoading(e,t,{reload:!0},i)}loadOne(e,t=""){const i=e.split("|"),s=i[0],n=i[1];this.read(s,n,"read",void 0,void 0,(r,a)=>{r&&this.logger.warn(`${t}loading namespace ${n} for language ${s} failed`,r),!r&&a&&this.logger.log(`${t}loaded namespace ${n} for language ${s}`,a),this.loaded(e,r,a)})}saveMissing(e,t,i,s,n,r={},a=()=>{}){var l,u,h,f,m;if(((u=(l=this.services)==null?void 0:l.utils)==null?void 0:u.hasLoadedNamespace)&&!((f=(h=this.services)==null?void 0:h.utils)!=null&&f.hasLoadedNamespace(t))){this.logger.warn(`did not save key "${i}" as the namespace "${t}" 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(!(i==null||i==="")){if((m=this.backend)!=null&&m.create){const p=C(g({},r),{isUpdate:n}),c=this.backend.create.bind(this.backend);if(c.length<6)try{let x;c.length===5?x=c(e,t,i,s,p):x=c(e,t,i,s),x&&typeof x.then=="function"?x.then(S=>a(null,S)).catch(a):a(null,x)}catch(x){a(x)}else c(e,t,i,s,a,p)}!e||!e[0]||this.store.addResource(e[0],t,i,s)}}}const ge=()=>({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:o=>{let e={};if(typeof o[1]=="object"&&(e=o[1]),d(o[1])&&(e.defaultValue=o[1]),d(o[2])&&(e.tDescription=o[2]),typeof o[2]=="object"||typeof o[3]=="object"){const t=o[3]||o[2];Object.keys(t).forEach(i=>{e[i]=t[i]})}return e},interpolation:{escapeValue:!0,format:o=>o,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),me=o=>{var e,t;return d(o.ns)&&(o.ns=[o.ns]),d(o.fallbackLng)&&(o.fallbackLng=[o.fallbackLng]),d(o.fallbackNS)&&(o.fallbackNS=[o.fallbackNS]),((t=(e=o.supportedLngs)==null?void 0:e.indexOf)==null?void 0:t.call(e,"cimode"))<0&&(o.supportedLngs=o.supportedLngs.concat(["cimode"])),typeof o.initImmediate=="boolean"&&(o.initAsync=o.initImmediate),o},G=()=>{},He=o=>{Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach(t=>{typeof o[t]=="function"&&(o[t]=o[t].bind(o))})};class M extends Y{constructor(e={},t){if(super(),this.options=me(e),this.services={},this.logger=N,this.modules={external:[]},He(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e=="function"&&(t=e,e={}),e.defaultNS==null&&e.ns&&(d(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const i=ge();this.options=g(g(g({},i),this.options),me(e)),this.options.interpolation=g(g({},i.interpolation),this.options.interpolation),e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const s=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?N.init(s(this.modules.logger),this.options):N.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Ue;const h=new fe(this.options);this.store=new ae(this.options.resources,this.options);const f=this.services;f.logger=N,f.resourceStore=this.store,f.languageUtils=h,f.pluralResolver=new De(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==i.interpolation.format&&this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(f.formatter=s(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Ae(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new Be(s(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...c)=>{this.emit(p,...c)}),this.modules.languageDetector&&(f.languageDetector=s(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=s(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new Q(this.services,this.options),this.translator.on("*",(p,...c)=>{this.emit(p,...c)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,t||(t=G),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=(...h)=>this.store[u](...h)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...h)=>(this.store[u](...h),this)});const a=L(),l=()=>{const u=(h,f)=>{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),a.resolve(f),t(h,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),a}loadResources(e,t=G){var n,r;let i=t;const s=d(e)?e:this.language;if(typeof e=="function"&&(i=e),!this.options.resources||this.options.partialBundledLanguages){if((s==null?void 0:s.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return i();const a=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(f=>{f!=="cimode"&&a.indexOf(f)<0&&a.push(f)})};s?l(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(h=>l(h)),(r=(n=this.options.preload)==null?void 0:n.forEach)==null||r.call(n,u=>l(u)),this.services.backendConnector.load(a,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),i(u)})}else i(null)}reloadResources(e,t,i){const s=L();return typeof e=="function"&&(i=e,e=void 0),typeof t=="function"&&(i=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),i||(i=G),this.services.backendConnector.reload(e,t,n=>{s.resolve(),i(n)}),s}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"&&oe.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 t=0;t<this.languages.length;t++){const i=this.languages[t];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const i=L();this.emit("languageChanging",e);const s=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},n=(a,l)=>{l?this.isLanguageChangingTo===e&&(s(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,i.resolve((...u)=>this.t(...u)),t&&t(a,(...u)=>this.t(...u))},r=a=>{var h,f;!e&&!a&&this.services.languageDetector&&(a=[]);const l=d(a)?a:a&&a[0],u=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(d(a)?[a]:a);u&&(this.language||s(u),this.translator.language||this.translator.changeLanguage(u),(f=(h=this.services.languageDetector)==null?void 0:h.cacheUserLanguage)==null||f.call(h,u)),this.loadResources(u,m=>{n(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?r(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(r):this.services.languageDetector.detect(r):r(e),i}getFixedT(e,t,i){const s=(n,r,...a)=>{let l;typeof r!="object"?l=this.options.overloadTranslationOptionHandler([n,r].concat(a)):l=g({},r),l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||i||s.keyPrefix);const u=this.options.keySeparator||".";let h;return l.keyPrefix&&Array.isArray(n)?h=n.map(f=>`${l.keyPrefix}${u}${f}`):h=l.keyPrefix?`${l.keyPrefix}${u}${n}`:n,this.t(h,l)};return d(e)?s.lng=e:s.lngs=e,s.ns=t,s.keyPrefix=i,s}t(...e){var t;return(t=this.translator)==null?void 0:t.translate(...e)}exists(...e){var t;return(t=this.translator)==null?void 0:t.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){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 i=t.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(i.toLowerCase()==="cimode")return!0;const r=(a,l)=>{const u=this.services.backendConnector.state[`${a}|${l}`];return u===-1||u===0||u===2};if(t.precheck){const a=t.precheck(this,r);if(a!==void 0)return a}return!!(this.hasResourceBundle(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||r(i,e)&&(!s||r(n,e)))}loadNamespaces(e,t){const i=L();return this.options.ns?(d(e)&&(e=[e]),e.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{i.resolve(),t&&t(s)}),i):(t&&t(),Promise.resolve())}loadLanguages(e,t){const i=L();d(e)&&(e=[e]);const s=this.options.preload||[],n=e.filter(r=>s.indexOf(r)<0&&this.services.languageUtils.isSupportedCode(r));return n.length?(this.options.preload=s.concat(n),this.loadResources(r=>{i.resolve(),t&&t(r)}),i):(t&&t(),Promise.resolve())}dir(e){var s,n;if(e||(e=this.resolvedLanguage||(((s=this.languages)==null?void 0:s.length)>0?this.languages[0]:this.language)),!e)return"rtl";try{const r=new Intl.Locale(e);if(r&&r.getTextInfo){const a=r.getTextInfo();if(a&&a.direction)return a.direction}}catch(r){}const t=["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"],i=((n=this.services)==null?void 0:n.languageUtils)||new fe(ge());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(i.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new M(e,t)}cloneInstance(e={},t=G){const i=e.forkResourceStore;i&&delete e.forkResourceStore;const s=C(g(g({},this.options),e),{isClone:!0}),n=new M(s);if((e.debug!==void 0||e.prefix!==void 0)&&(n.logger=n.logger.clone(e)),["store","services","language"].forEach(a=>{n[a]=this[a]}),n.services=g({},this.services),n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},i){const a=Object.keys(this.store.data).reduce((l,u)=>(l[u]=g({},this.store.data[u]),l[u]=Object.keys(l[u]).reduce((h,f)=>(h[f]=g({},l[u][f]),h),l[u]),l),{});n.store=new ae(a,s),n.services.resourceStore=n.store}return n.translator=new Q(n.services,s),n.translator.on("*",(a,...l)=>{n.emit(a,...l)}),n.init(s,t),n.translator.options=s,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const y=M.createInstance();y.createInstance=M.createInstance,y.createInstance,y.dir,y.init,y.loadResources,y.reloadResources,y.use,y.changeLanguage,y.getFixedT,y.t,y.exists,y.setDefaultNamespace,y.hasLoadedNamespace,y.loadNamespaces,y.loadLanguages;const ze=(o,e)=>{for(const t of e){const i=o.find(t);i&&i.each((s,n)=>{const r=globalThis.$(n);if(r.attr("data-i18n"))return;const a=r.text().trim();a&&(r.attr({"data-i18n":a}),r.text(y.t(a)));const l=r.attr("placeholder");l&&(r.attr({"data-i18n":"[placeholder]"+l}),r.attr({placeholder:y.t(l)}))})}},B=o=>{for(const e of o){const t=globalThis.$(e);t&&t.each((i,s)=>{const n=globalThis.$(s);if(n.attr("data-i18n"))return;const r=n.text().trim();r&&(n.attr({"data-i18n":r}),n.text(y.t(r)));const a=n.attr("placeholder");a&&(n.attr({"data-i18n":"[placeholder]"+a}),n.attr({placeholder:y.t(a)}))})}},Je=(o,e)=>{ze(e,[".hiprint-option-item-label","textarea","input","select option",".option","button","label",".hiprint-option-title",".hiprint-option-item-desc"])},We=()=>{document.querySelectorAll("[data-i18n]").forEach(o=>{const e=o.getAttribute("data-i18n");if(!e.includes("[")){o.textContent=y.t(e);return}const t=e.match(/\[([^\]]+)\](.+)/);if(t&&t.length===3){const i=t[1],s=t[2];o.setAttribute(i,y.t(s))}})};let xe=!1;const ye=o=>{if(xe)return;xe=!0,globalThis.hiprint.i18next=y,globalThis.hiprint.t=y.t;const e=Object.keys(o.resources||{});globalThis.hiprint.languages=["\u7B80\u4F53\u4E2D\u6587",...e],globalThis.hiprint.changeLanguage=(t,i)=>{y.changeLanguage(t,(s,n)=>{i&&i(s,n),We()})}};function _e(o,e){y.init(g({},o),(i,s)=>{e&&e(y,s,i)});let t=[];return{name:"i18n",description:"i18next",hooks:[{hook:"ready",name:"i18n set",description:"\u6DFB\u52A0 i18n \u65B9\u6CD5",priority:1,run:()=>{ye(o)}},{hook:"getOptionItem",name:"i18n options",description:"\u6E32\u67D3\u5143\u7D20\u5C5E\u6027\u65F6\u505A\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:i=>{if(i){t.push(i.name);const s=i.createTarget;return i.createTarget=function(...n){const r=s.call(i,...n);return t.some(a=>a==i.name)&&r.attr("data-name")||(r.attr({"data-name":i.name}),Je(i,r)),r},i}}},{hook:"onDesigned",name:"i18n other selector",description:"\u5176\u4ED6UI\u9009\u62E9\u5668\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:({hiprint:i,designerUtils:s})=>{var a;ye(o);const n=(a=s.printTemplate)==null?void 0:a.id;n&&(globalThis.hinnn.event.on("PrintElementSelectEventKey_"+n,l=>{setTimeout(()=>{B([".printSetting .prop-tab-items .tab-title"])},0)}),globalThis.$(".hiprint-printPaper.design").on("contextmenu",()=>{B([".hicontextmenu .hicontextmenuitem .title span",".hicontextmenu .hicontextmenuitem .nav"])})),B([".svp-header p",".svp-tools .tool-name",".svp-dragbox .header span",".preview-bar button span",".printer-list-txt"])}},{hook:"onPreview",name:"i18n preview selector",description:"\u7EC4\u4EF6\u5185\u9884\u89C8\u9009\u62E9\u5668\u591A\u8BED\u8A00\u5904\u7406",priority:1,run:i=>{setTimeout(()=>{B([".preview-bar button span",".printer-list-txt"])},0)}}],leastHiprintVersion:"0.1.28"}}b.default=_e,b.translateBySelector=B,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(b,d){typeof exports=="object"&&typeof module!="undefined"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(b=typeof globalThis!="undefined"?globalThis:b||self,d(b.pluginI18n={}))})(this,function(b){"use strict";var Ge=Object.defineProperty,Ze=Object.defineProperties;var Xe=Object.getOwnPropertyDescriptors;var we=Object.getOwnPropertySymbols;var qe=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable;var ve=(b,d,L)=>d in b?Ge(b,d,{enumerable:!0,configurable:!0,writable:!0,value:L}):b[d]=L,g=(b,d)=>{for(var L in d||(d={}))qe.call(d,L)&&ve(b,L,d[L]);if(we)for(var L of we(d))et.call(d,L)&&ve(b,L,d[L]);return b},v=(b,d)=>Ze(b,Xe(d));const d=o=>typeof o=="string",L=()=>{let o,e;const t=new Promise((i,s)=>{o=i,e=s});return t.resolve=o,t.reject=e,t},te=o=>o==null?"":""+o,Ce=(o,e,t)=>{o.forEach(i=>{e[i]&&(t[i]=e[i])})},$e=/###/g,ie=o=>o&&o.indexOf("###")>-1?o.replace($e,"."):o,se=o=>!o||d(o),K=(o,e,t)=>{const i=d(e)?e.split("."):e;let s=0;for(;s<i.length-1;){if(se(o))return{};const n=ie(i[s]);!o[n]&&t&&(o[n]=new t),Object.prototype.hasOwnProperty.call(o,n)?o=o[n]:o={},++s}return se(o)?{}:{obj:o,k:ie(i[s])}},ne=(o,e,t)=>{const{obj:i,k:s}=K(o,e,Object);if(i!==void 0||e.length===1){i[s]=t;return}let n=e[e.length-1],r=e.slice(0,e.length-1),a=K(o,r,Object);for(;a.obj===void 0&&r.length;)n=`${r[r.length-1]}.${n}`,r=r.slice(0,r.length-1),a=K(o,r,Object),a!=null&&a.obj&&typeof a.obj[`${a.k}.${n}`]!="undefined"&&(a.obj=void 0);a.obj[`${a.k}.${n}`]=t},Pe=(o,e,t,i)=>{const{obj:s,k:n}=K(o,e,Object);s[n]=s[n]||[],s[n].push(t)},W=(o,e)=>{const{obj:t,k:i}=K(o,e);if(t&&Object.prototype.hasOwnProperty.call(t,i))return t[i]},Re=(o,e,t)=>{const i=W(o,t);return i!==void 0?i:W(e,t)},re=(o,e,t)=>{for(const i in e)i!=="__proto__"&&i!=="constructor"&&(i in o?d(o[i])||o[i]instanceof String||d(e[i])||e[i]instanceof String?t&&(o[i]=e[i]):re(o[i],e[i],t):o[i]=e[i]);return o},A=o=>o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var ke={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Ne=o=>d(o)?o.replace(/[&<>"'\/]/g,e=>ke[e]):o;class Te{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)return t;const i=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,i),this.regExpQueue.push(e),i}}const Fe=[" ",",","?","!",";"],je=new Te(20),Ee=(o,e,t)=>{e=e||"",t=t||"";const i=Fe.filter(r=>e.indexOf(r)<0&&t.indexOf(r)<0);if(i.length===0)return!0;const s=je.getRegExp(`(${i.map(r=>r==="?"?"\\?":r).join("|")})`);let n=!s.test(o);if(!n){const r=o.indexOf(t);r>0&&!s.test(o.substring(0,r))&&(n=!0)}return n},q=(o,e,t=".")=>{if(!o)return;if(o[e])return Object.prototype.hasOwnProperty.call(o,e)?o[e]:void 0;const i=e.split(t);let s=o;for(let n=0;n<i.length;){if(!s||typeof s!="object")return;let r,a="";for(let l=n;l<i.length;++l)if(l!==n&&(a+=t),a+=i[l],r=s[a],r!==void 0){if(["string","number","boolean"].indexOf(typeof r)>-1&&l<i.length-1)continue;n+=l-n+1;break}s=r}return s},U=o=>o==null?void 0:o.replace("_","-"),Ie={type:"logger",log(o){this.output("log",o)},warn(o){this.output("warn",o)},error(o){this.output("error",o)},output(o,e){var t,i;(i=(t=console==null?void 0:console[o])==null?void 0:t.apply)==null||i.call(t,console,e)}};class _{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||Ie,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,i,s){return s&&!this.debug?null:(d(e[0])&&(e[0]=`${i}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new _(this.logger,g({prefix:`${this.prefix}:${e}:`},this.options))}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new _(this.logger,e)}}var N=new _;class Y{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(i=>{this.observers[i]||(this.observers[i]=new Map);const s=this.observers[i].get(t)||0;this.observers[i].set(t,s+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([s,n])=>{for(let r=0;r<n;r++)s(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,n])=>{for(let r=0;r<n;r++)s.apply(s,[e,...t])})}}class ae extends Y{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,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 t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,i,s={}){var u,h;const n=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,r=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let a;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],i&&(Array.isArray(i)?a.push(...i):d(i)&&n?a.push(...i.split(n)):a.push(i)));const l=W(this.data,a);return!l&&!t&&!i&&e.indexOf(".")>-1&&(e=a[0],t=a[1],i=a.slice(2).join(".")),l||!r||!d(i)?l:q((h=(u=this.data)==null?void 0:u[e])==null?void 0:h[t],i,n)}addResource(e,t,i,s,n={silent:!1}){const r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=[e,t];i&&(a=a.concat(r?i.split(r):i)),e.indexOf(".")>-1&&(a=e.split("."),s=t,t=a[1]),this.addNamespaces(t),ne(this.data,a,s),n.silent||this.emit("added",e,t,i,s)}addResources(e,t,i,s={silent:!1}){for(const n in i)(d(i[n])||Array.isArray(i[n]))&&this.addResource(e,t,n,i[n],{silent:!0});s.silent||this.emit("added",e,t,i)}addResourceBundle(e,t,i,s,n,r={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),s=i,i=t,t=a[1]),this.addNamespaces(t);let l=W(this.data,a)||{};r.skipCopy||(i=JSON.parse(JSON.stringify(i))),s?re(l,i,n):l=g(g({},l),i),ne(this.data,a,l),r.silent||this.emit("added",e,t,i)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(s=>t[s]&&Object.keys(t[s]).length>0)}toJSON(){return this.data}}var oe={processors:{},addPostProcessor(o){this.processors[o.name]=o},handle(o,e,t,i,s){return o.forEach(n=>{var r,a;e=(a=(r=this.processors[n])==null?void 0:r.process(e,t,i,s))!=null?a:e}),e}};const le={},ue=o=>!d(o)&&typeof o!="boolean"&&typeof o!="number";class Q extends Y{constructor(e,t={}){super(),Ce(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=N.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){const i=g({},t);if(e==null)return!1;const s=this.resolve(e,i);return(s==null?void 0:s.res)!==void 0}extractFromKey(e,t){let i=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;i===void 0&&(i=":");const s=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let n=t.ns||this.options.defaultNS||[];const r=i&&e.indexOf(i)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Ee(e,i,s);if(r&&!a){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:d(n)?[n]:n};const u=e.split(i);(i!==s||i===s&&this.options.ns.indexOf(u[0])>-1)&&(n=u.shift()),e=u.join(s)}return{key:e,namespaces:d(n)?[n]:n}}translate(e,t,i){let s=typeof t=="object"?g({},t):t;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof options=="object"&&(s=g({},s)),s||(s={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const n=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,r=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(e[e.length-1],s),u=l[l.length-1];let h=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;h===void 0&&(h=":");const f=s.lng||this.language,m=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((f==null?void 0:f.toLowerCase())==="cimode")return m?n?{res:`${u}${h}${a}`,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(s)}:`${u}${h}${a}`:n?{res:a,usedKey:a,exactUsedKey:a,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(s)}:a;const p=this.resolve(e,s);let c=p==null?void 0:p.res;const x=(p==null?void 0:p.usedKey)||a,S=(p==null?void 0:p.exactUsedKey)||a,R=["[object Number]","[object Function]","[object RegExp]"],P=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,D=!this.i18nFormat||this.i18nFormat.handleAsObject,w=s.count!==void 0&&!d(s.count),j=Q.hasDefaultValue(s),Z=w?this.pluralResolver.getSuffix(f,s.count,s):"",E=s.ordinal&&w?this.pluralResolver.getSuffix(f,s.count,{ordinal:!1}):"",B=w&&!s.ordinal&&s.count===0,C=B&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${Z}`]||s[`defaultValue${E}`]||s.defaultValue;let O=c;D&&!c&&j&&(O=C);const Ye=ue(O),Qe=Object.prototype.toString.apply(O);if(D&&O&&Ye&&R.indexOf(Qe)<0&&!(d(P)&&Array.isArray(O))){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const T=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,O,v(g({},s),{ns:l})):`key '${a} (${this.language})' returned an object instead of string.`;return n?(p.res=T,p.usedParams=this.getUsedParamsDetails(s),p):T}if(r){const T=Array.isArray(O),k=T?[]:{},Se=T?S:x;for(const F in O)if(Object.prototype.hasOwnProperty.call(O,F)){const I=`${Se}${r}${F}`;j&&!c?k[F]=this.translate(I,v(g({},s),{defaultValue:ue(C)?C[F]:void 0,joinArrays:!1,ns:l})):k[F]=this.translate(I,v(g({},s),{joinArrays:!1,ns:l})),k[F]===I&&(k[F]=O[F])}c=k}}else if(D&&d(P)&&Array.isArray(c))c=c.join(P),c&&(c=this.extendTranslation(c,e,s,i));else{let T=!1,k=!1;!this.isValidLookup(c)&&j&&(T=!0,c=C),this.isValidLookup(c)||(k=!0,c=a);const F=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&k?void 0:c,I=j&&C!==c&&this.options.updateMissing;if(k||T||I){if(this.logger.log(I?"updateKey":"missingKey",f,u,a,I?C:c),r){const $=this.resolve(a,v(g({},s),{keySeparator:!1}));$&&$.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 z=[];const X=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&X&&X[0])for(let $=0;$<X.length;$++)z.push(X[$]);else this.options.saveMissingTo==="all"?z=this.languageUtils.toResolveHierarchy(s.lng||this.language):z.push(s.lng||this.language);const be=($,V,J)=>{var Oe;const Le=j&&J!==c?J:F;this.options.missingKeyHandler?this.options.missingKeyHandler($,u,V,Le,I,s):(Oe=this.backendConnector)!=null&&Oe.saveMissing&&this.backendConnector.saveMissing($,u,V,Le,I,s),this.emit("missingKey",$,u,V,c)};this.options.saveMissing&&(this.options.saveMissingPlurals&&w?z.forEach($=>{const V=this.pluralResolver.getSuffixes($,s);B&&s[`defaultValue${this.options.pluralSeparator}zero`]&&V.indexOf(`${this.options.pluralSeparator}zero`)<0&&V.push(`${this.options.pluralSeparator}zero`),V.forEach(J=>{be([$],a+J,s[`defaultValue${J}`]||C)})}):be(z,a,C))}c=this.extendTranslation(c,e,s,p,i),k&&c===a&&this.options.appendNamespaceToMissingKey&&(c=`${u}${h}${a}`),(k||T)&&this.options.parseMissingKeyHandler&&(c=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${h}${a}`:a,T?c:void 0,s))}return n?(p.res=c,p.usedParams=this.getUsedParamsDetails(s),p):c}extendTranslation(e,t,i,s,n){var l,u;if((l=this.i18nFormat)!=null&&l.parse)e=this.i18nFormat.parse(e,g(g({},this.options.interpolation.defaultVariables),i),i.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init(v(g({},i),{interpolation:g(g({},this.options.interpolation),i.interpolation)}));const h=d(e)&&(((u=i==null?void 0:i.interpolation)==null?void 0:u.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(h){const p=e.match(this.interpolator.nestingRegexp);f=p&&p.length}let m=i.replace&&!d(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(m=g(g({},this.options.interpolation.defaultVariables),m)),e=this.interpolator.interpolate(e,m,i.lng||this.language||s.usedLng,i),h){const p=e.match(this.interpolator.nestingRegexp),c=p&&p.length;f<c&&(i.nest=!1)}!i.lng&&s&&s.res&&(i.lng=this.language||s.usedLng),i.nest!==!1&&(e=this.interpolator.nest(e,(...p)=>(n==null?void 0:n[0])===p[0]&&!i.context?(this.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${t[0]}`),null):this.translate(...p,t),i)),i.interpolation&&this.interpolator.reset()}const r=i.postProcess||this.options.postProcess,a=d(r)?[r]:r;return e!=null&&(a!=null&&a.length)&&i.applyPostProcessor!==!1&&(e=oe.handle(a,e,t,this.options&&this.options.postProcessPassResolved?g({i18nResolved:v(g({},s),{usedParams:this.getUsedParamsDetails(i)})},i):i,this)),e}resolve(e,t={}){let i,s,n,r,a;return d(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(i))return;const u=this.extractFromKey(l,t),h=u.key;s=h;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const m=t.count!==void 0&&!d(t.count),p=m&&!t.ordinal&&t.count===0,c=t.context!==void 0&&(d(t.context)||typeof t.context=="number")&&t.context!=="",x=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);f.forEach(S=>{var R,P;this.isValidLookup(i)||(a=S,!le[`${x[0]}-${S}`]&&((R=this.utils)!=null&&R.hasLoadedNamespace)&&!((P=this.utils)!=null&&P.hasLoadedNamespace(a))&&(le[`${x[0]}-${S}`]=!0,this.logger.warn(`key "${s}" for languages "${x.join(", ")}" won't get resolved as 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!!!")),x.forEach(D=>{var Z;if(this.isValidLookup(i))return;r=D;const w=[h];if((Z=this.i18nFormat)!=null&&Z.addLookupKeys)this.i18nFormat.addLookupKeys(w,h,D,S,t);else{let E;m&&(E=this.pluralResolver.getSuffix(D,t.count,t));const B=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(w.push(h+E),t.ordinal&&E.indexOf(C)===0&&w.push(h+E.replace(C,this.options.pluralSeparator)),p&&w.push(h+B)),c){const O=`${h}${this.options.contextSeparator}${t.context}`;w.push(O),m&&(w.push(O+E),t.ordinal&&E.indexOf(C)===0&&w.push(O+E.replace(C,this.options.pluralSeparator)),p&&w.push(O+B))}}let j;for(;j=w.pop();)this.isValidLookup(i)||(n=j,i=this.getResource(D,S,j,t))}))})}),{res:i,usedKey:s,exactUsedKey:n,usedLng:r,usedNS:a}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,i,s={}){var n;return(n=this.i18nFormat)!=null&&n.getResource?this.i18nFormat.getResource(e,t,i,s):this.resourceStore.getResource(e,t,i,s)}getUsedParamsDetails(e={}){const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=e.replace&&!d(e.replace);let s=i?e.replace:e;if(i&&typeof e.count!="undefined"&&(s.count=e.count),this.options.interpolation.defaultVariables&&(s=g(g({},this.options.interpolation.defaultVariables),s)),!i){s=g({},s);for(const n of t)delete s[n]}return s}static hasDefaultValue(e){const t="defaultValue";for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t===i.substring(0,t.length)&&e[i]!==void 0)return!0;return!1}}class fe{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=N.create("languageUtils")}getScriptPartFromCode(e){if(e=U(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=U(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(d(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(i){}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(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 t;return e.forEach(i=>{if(t)return;const s=this.formatLanguageCode(i);(!this.options.supportedLngs||this.isSupportedCode(s))&&(t=s)}),!t&&this.options.supportedLngs&&e.forEach(i=>{if(t)return;const s=this.getScriptPartFromCode(i);if(this.isSupportedCode(s))return t=s;const n=this.getLanguagePartFromCode(i);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(r=>{if(r===n)return r;if(!(r.indexOf("-")<0&&n.indexOf("-")<0)&&(r.indexOf("-")>0&&n.indexOf("-")<0&&r.substring(0,r.indexOf("-"))===n||r.indexOf(n)===0&&n.length>1))return r})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),d(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let i=e[t];return i||(i=e[this.getScriptPartFromCode(t)]),i||(i=e[this.formatLanguageCode(t)]),i||(i=e[this.getLanguagePartFromCode(t)]),i||(i=e.default),i||[]}toResolveHierarchy(e,t){const i=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),s=[],n=r=>{r&&(this.isSupportedCode(r)?s.push(r):this.logger.warn(`rejecting language code not found in supportedLngs: ${r}`))};return d(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&n(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&n(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&n(this.getLanguagePartFromCode(e))):d(e)&&n(this.formatLanguageCode(e)),i.forEach(r=>{s.indexOf(r)<0&&n(this.formatLanguageCode(r))}),s}}const he={zero:0,one:1,two:2,few:3,many:4,other:5},ce={select:o=>o===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class De{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=N.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){const i=U(e==="dev"?"en":e),s=t.ordinal?"ordinal":"cardinal",n=JSON.stringify({cleanedCode:i,type:s});if(n in this.pluralRulesCache)return this.pluralRulesCache[n];let r;try{r=new Intl.PluralRules(i,{type:s})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ce;if(!e.match(/-|_/))return ce;const l=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(l,t)}return this.pluralRulesCache[n]=r,r}needsPlural(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),(i==null?void 0:i.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t,i={}){return this.getSuffixes(e,i).map(s=>`${t}${s}`)}getSuffixes(e,t={}){let i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),i?i.resolvedOptions().pluralCategories.sort((s,n)=>he[s]-he[n]).map(s=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(e,t,i={}){const s=this.getRule(e,i);return s?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${s.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,i))}}const de=(o,e,t,i=".",s=!0)=>{let n=Re(o,e,t);return!n&&s&&d(t)&&(n=q(o,t,i),n===void 0&&(n=q(e,t,i))),n},ee=o=>o.replace(/\$/g,"$$$$");class Ve{constructor(e={}){var t;this.logger=N.create("interpolator"),this.options=e,this.format=((t=e==null?void 0:e.interpolation)==null?void 0:t.format)||(i=>i),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:i,useRawValueToEscape:s,prefix:n,prefixEscaped:r,suffix:a,suffixEscaped:l,formatSeparator:u,unescapeSuffix:h,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:p,nestingSuffix:c,nestingSuffixEscaped:x,nestingOptionsSeparator:S,maxReplaces:R,alwaysFormat:P}=e.interpolation;this.escape=t!==void 0?t:Ne,this.escapeValue=i!==void 0?i:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=n?A(n):r||"{{",this.suffix=a?A(a):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=h?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":h||"",this.nestingPrefix=m?A(m):p||A("$t("),this.nestingSuffix=c?A(c):x||A(")"),this.nestingOptionsSeparator=S||",",this.maxReplaces=R||1e3,this.alwaysFormat=P!==void 0?P:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,i)=>(t==null?void 0:t.source)===i?(t.lastIndex=0,t):new RegExp(i,"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,t,i,s){var p;let n,r,a;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=c=>{if(c.indexOf(this.formatSeparator)<0){const P=de(t,l,c,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(P,void 0,i,v(g(g({},s),t),{interpolationkey:c})):P}const x=c.split(this.formatSeparator),S=x.shift().trim(),R=x.join(this.formatSeparator).trim();return this.format(de(t,l,S,this.options.keySeparator,this.options.ignoreJSONStructure),R,i,v(g(g({},s),t),{interpolationkey:S}))};this.resetRegExp();const h=(s==null?void 0:s.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((p=s==null?void 0:s.interpolation)==null?void 0:p.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:c=>ee(c)},{regex:this.regexp,safeValue:c=>this.escapeValue?ee(this.escape(c)):ee(c)}].forEach(c=>{for(a=0;n=c.regex.exec(e);){const x=n[1].trim();if(r=u(x),r===void 0)if(typeof h=="function"){const R=h(e,n,s);r=d(R)?R:""}else if(s&&Object.prototype.hasOwnProperty.call(s,x))r="";else if(f){r=n[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),r="";else!d(r)&&!this.useRawValueToEscape&&(r=te(r));const S=c.safeValue(r);if(e=e.replace(n[0],S),f?(c.regex.lastIndex+=r.length,c.regex.lastIndex-=n[0].length):c.regex.lastIndex=0,a++,a>=this.maxReplaces)break}}),e}nest(e,t,i={}){let s,n,r;const a=(l,u)=>{var x;const h=this.nestingOptionsSeparator;if(l.indexOf(h)<0)return l;const f=l.split(new RegExp(`${h}[ ]*{`));let m=`{${f[1]}`;l=f[0],m=this.interpolate(m,r);const p=m.match(/'/g),c=m.match(/"/g);(((x=p==null?void 0:p.length)!=null?x:0)%2===0&&!c||c.length%2!==0)&&(m=m.replace(/'/g,'"'));try{r=JSON.parse(m),u&&(r=g(g({},u),r))}catch(S){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,S),`${l}${h}${m}`}return r.defaultValue&&r.defaultValue.indexOf(this.prefix)>-1&&delete r.defaultValue,l};for(;s=this.nestingRegexp.exec(e);){let l=[];r=g({},i),r=r.replace&&!d(r.replace)?r.replace:r,r.applyPostProcessor=!1,delete r.defaultValue;const u=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(u!==-1&&(l=s[1].slice(u).split(this.formatSeparator).map(h=>h.trim()).filter(Boolean),s[1]=s[1].slice(0,u)),n=t(a.call(this,s[1].trim(),r),r),n&&s[0]===e&&!d(n))return n;d(n)||(n=te(n)),n||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`),n=""),l.length&&(n=l.reduce((h,f)=>this.format(h,f,i.lng,v(g({},i),{interpolationkey:s[1].trim()})),n.trim())),e=e.replace(s[0],n),this.regexp.lastIndex=0}return e}}const Ae=o=>{let e=o.toLowerCase().trim();const t={};if(o.indexOf("(")>-1){const i=o.split("(");e=i[0].toLowerCase().trim();const s=i[1].substring(0,i[1].length-1);e==="currency"&&s.indexOf(":")<0?t.currency||(t.currency=s.trim()):e==="relativetime"&&s.indexOf(":")<0?t.range||(t.range=s.trim()):s.split(";").forEach(r=>{if(r){const[a,...l]=r.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),h=a.trim();t[h]||(t[h]=u),u==="false"&&(t[h]=!1),u==="true"&&(t[h]=!0),isNaN(u)||(t[h]=parseInt(u,10))}})}return{formatName:e,formatOptions:t}},pe=o=>{const e={};return(t,i,s)=>{let n=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(n=v(g({},n),{[s.interpolationkey]:void 0}));const r=i+JSON.stringify(n);let a=e[r];return a||(a=o(U(i),s),e[r]=a),a(t)}},Ke=o=>(e,t,i)=>o(U(t),i)(e);class Ue{constructor(e={}){this.logger=N.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";const i=t.cacheInBuiltFormats?pe:Ke;this.formats={number:i((s,n)=>{const r=new Intl.NumberFormat(s,g({},n));return a=>r.format(a)}),currency:i((s,n)=>{const r=new Intl.NumberFormat(s,v(g({},n),{style:"currency"}));return a=>r.format(a)}),datetime:i((s,n)=>{const r=new Intl.DateTimeFormat(s,g({},n));return a=>r.format(a)}),relativetime:i((s,n)=>{const r=new Intl.RelativeTimeFormat(s,g({},n));return a=>r.format(a,n.range||"day")}),list:i((s,n)=>{const r=new Intl.ListFormat(s,g({},n));return a=>r.format(a)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=pe(t)}format(e,t,i,s={}){const n=t.split(this.formatSeparator);if(n.length>1&&n[0].indexOf("(")>1&&n[0].indexOf(")")<0&&n.find(a=>a.indexOf(")")>-1)){const a=n.findIndex(l=>l.indexOf(")")>-1);n[0]=[n[0],...n.splice(1,a)].join(this.formatSeparator)}return n.reduce((a,l)=>{var f;const{formatName:u,formatOptions:h}=Ae(l);if(this.formats[u]){let m=a;try{const p=((f=s==null?void 0:s.formatParams)==null?void 0:f[s.interpolationkey])||{},c=p.locale||p.lng||s.locale||s.lng||i;m=this.formats[u](a,c,g(g(g({},h),s),p))}catch(p){this.logger.warn(p)}return m}else this.logger.warn(`there was no format function for ${u}`);return a},e)}}const Me=(o,e)=>{o.pending[e]!==void 0&&(delete o.pending[e],o.pendingCount--)};class He extends Y{constructor(e,t,i,s={}){var n,r;super(),this.backend=e,this.store=t,this.services=i,this.languageUtils=i.languageUtils,this.options=s,this.logger=N.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],(r=(n=this.backend)==null?void 0:n.init)==null||r.call(n,i,s.backend,s)}queueLoad(e,t,i,s){const n={},r={},a={},l={};return e.forEach(u=>{let h=!0;t.forEach(f=>{const m=`${u}|${f}`;!i.reload&&this.store.hasResourceBundle(u,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?r[m]===void 0&&(r[m]=!0):(this.state[m]=1,h=!1,r[m]===void 0&&(r[m]=!0),n[m]===void 0&&(n[m]=!0),l[f]===void 0&&(l[f]=!0)))}),h||(a[u]=!0)}),(Object.keys(n).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(n),pending:Object.keys(r),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(l)}}loaded(e,t,i){const s=e.split("|"),n=s[0],r=s[1];t&&this.emit("failedLoading",n,r,t),!t&&i&&this.store.addResourceBundle(n,r,i,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&i&&(this.state[e]=0);const a={};this.queue.forEach(l=>{Pe(l.loaded,[n],r),Me(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{a[u]||(a[u]={});const h=l.loaded[u];h.length&&h.forEach(f=>{a[u][f]===void 0&&(a[u][f]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(l=>!l.done)}read(e,t,i,s=0,n=this.retryTimeout,r){if(!e.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:i,tried:s,wait:n,callback:r});return}this.readingCalls++;const a=(u,h)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&h&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,i,s+1,n*2,r)},n);return}r(u,h)},l=this.backend[i].bind(this.backend);if(l.length===2){try{const u=l(e,t);u&&typeof u.then=="function"?u.then(h=>a(null,h)).catch(a):a(null,u)}catch(u){a(u)}return}return l(e,t,a)}prepareLoading(e,t,i={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();d(e)&&(e=this.languageUtils.toResolveHierarchy(e)),d(t)&&(t=[t]);const n=this.queueLoad(e,t,i,s);if(!n.toLoad.length)return n.pending.length||s(),null;n.toLoad.forEach(r=>{this.loadOne(r)})}load(e,t,i){this.prepareLoading(e,t,{},i)}reload(e,t,i){this.prepareLoading(e,t,{reload:!0},i)}loadOne(e,t=""){const i=e.split("|"),s=i[0],n=i[1];this.read(s,n,"read",void 0,void 0,(r,a)=>{r&&this.logger.warn(`${t}loading namespace ${n} for language ${s} failed`,r),!r&&a&&this.logger.log(`${t}loaded namespace ${n} for language ${s}`,a),this.loaded(e,r,a)})}saveMissing(e,t,i,s,n,r={},a=()=>{}){var l,u,h,f,m;if((u=(l=this.services)==null?void 0:l.utils)!=null&&u.hasLoadedNamespace&&!((f=(h=this.services)==null?void 0:h.utils)!=null&&f.hasLoadedNamespace(t))){this.logger.warn(`did not save key "${i}" as the namespace "${t}" 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(!(i==null||i==="")){if((m=this.backend)!=null&&m.create){const p=v(g({},r),{isUpdate:n}),c=this.backend.create.bind(this.backend);if(c.length<6)try{let x;c.length===5?x=c(e,t,i,s,p):x=c(e,t,i,s),x&&typeof x.then=="function"?x.then(S=>a(null,S)).catch(a):a(null,x)}catch(x){a(x)}else c(e,t,i,s,a,p)}!e||!e[0]||this.store.addResource(e[0],t,i,s)}}}const ge=()=>({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:o=>{let e={};if(typeof o[1]=="object"&&(e=o[1]),d(o[1])&&(e.defaultValue=o[1]),d(o[2])&&(e.tDescription=o[2]),typeof o[2]=="object"||typeof o[3]=="object"){const t=o[3]||o[2];Object.keys(t).forEach(i=>{e[i]=t[i]})}return e},interpolation:{escapeValue:!0,format:o=>o,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),me=o=>{var e,t;return d(o.ns)&&(o.ns=[o.ns]),d(o.fallbackLng)&&(o.fallbackLng=[o.fallbackLng]),d(o.fallbackNS)&&(o.fallbackNS=[o.fallbackNS]),((t=(e=o.supportedLngs)==null?void 0:e.indexOf)==null?void 0:t.call(e,"cimode"))<0&&(o.supportedLngs=o.supportedLngs.concat(["cimode"])),typeof o.initImmediate=="boolean"&&(o.initAsync=o.initImmediate),o},G=()=>{},Be=o=>{Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach(t=>{typeof o[t]=="function"&&(o[t]=o[t].bind(o))})};class M extends Y{constructor(e={},t){if(super(),this.options=me(e),this.services={},this.logger=N,this.modules={external:[]},Be(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e=="function"&&(t=e,e={}),e.defaultNS==null&&e.ns&&(d(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const i=ge();this.options=g(g(g({},i),this.options),me(e)),this.options.interpolation=g(g({},i.interpolation),this.options.interpolation),e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);const s=u=>u?typeof u=="function"?new u:u:null;if(!this.options.isClone){this.modules.logger?N.init(s(this.modules.logger),this.options):N.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=Ue;const h=new fe(this.options);this.store=new ae(this.options.resources,this.options);const f=this.services;f.logger=N,f.resourceStore=this.store,f.languageUtils=h,f.pluralResolver=new De(h,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==i.interpolation.format&&this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(f.formatter=s(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new Ve(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new He(s(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(p,...c)=>{this.emit(p,...c)}),this.modules.languageDetector&&(f.languageDetector=s(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=s(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new Q(this.services,this.options),this.translator.on("*",(p,...c)=>{this.emit(p,...c)}),this.modules.external.forEach(p=>{p.init&&p.init(this)})}if(this.format=this.options.interpolation.format,t||(t=G),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&u[0]!=="dev"&&(this.options.lng=u[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(u=>{this[u]=(...h)=>this.store[u](...h)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(u=>{this[u]=(...h)=>(this.store[u](...h),this)});const a=L(),l=()=>{const u=(h,f)=>{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),a.resolve(f),t(h,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?l():setTimeout(l,0),a}loadResources(e,t=G){var n,r;let i=t;const s=d(e)?e:this.language;if(typeof e=="function"&&(i=e),!this.options.resources||this.options.partialBundledLanguages){if((s==null?void 0:s.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return i();const a=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(f=>{f!=="cimode"&&a.indexOf(f)<0&&a.push(f)})};s?l(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(h=>l(h)),(r=(n=this.options.preload)==null?void 0:n.forEach)==null||r.call(n,u=>l(u)),this.services.backendConnector.load(a,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),i(u)})}else i(null)}reloadResources(e,t,i){const s=L();return typeof e=="function"&&(i=e,e=void 0),typeof t=="function"&&(i=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),i||(i=G),this.services.backendConnector.reload(e,t,n=>{s.resolve(),i(n)}),s}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"&&oe.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 t=0;t<this.languages.length;t++){const i=this.languages[t];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;const i=L();this.emit("languageChanging",e);const s=a=>{this.language=a,this.languages=this.services.languageUtils.toResolveHierarchy(a),this.resolvedLanguage=void 0,this.setResolvedLanguage(a)},n=(a,l)=>{l?this.isLanguageChangingTo===e&&(s(l),this.translator.changeLanguage(l),this.isLanguageChangingTo=void 0,this.emit("languageChanged",l),this.logger.log("languageChanged",l)):this.isLanguageChangingTo=void 0,i.resolve((...u)=>this.t(...u)),t&&t(a,(...u)=>this.t(...u))},r=a=>{var h,f;!e&&!a&&this.services.languageDetector&&(a=[]);const l=d(a)?a:a&&a[0],u=this.store.hasLanguageSomeTranslations(l)?l:this.services.languageUtils.getBestMatchFromCodes(d(a)?[a]:a);u&&(this.language||s(u),this.translator.language||this.translator.changeLanguage(u),(f=(h=this.services.languageDetector)==null?void 0:h.cacheUserLanguage)==null||f.call(h,u)),this.loadResources(u,m=>{n(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?r(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(r):this.services.languageDetector.detect(r):r(e),i}getFixedT(e,t,i){const s=(n,r,...a)=>{let l;typeof r!="object"?l=this.options.overloadTranslationOptionHandler([n,r].concat(a)):l=g({},r),l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||i||s.keyPrefix);const u=this.options.keySeparator||".";let h;return l.keyPrefix&&Array.isArray(n)?h=n.map(f=>`${l.keyPrefix}${u}${f}`):h=l.keyPrefix?`${l.keyPrefix}${u}${n}`:n,this.t(h,l)};return d(e)?s.lng=e:s.lngs=e,s.ns=t,s.keyPrefix=i,s}t(...e){var t;return(t=this.translator)==null?void 0:t.translate(...e)}exists(...e){var t;return(t=this.translator)==null?void 0:t.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){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 i=t.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,n=this.languages[this.languages.length-1];if(i.toLowerCase()==="cimode")return!0;const r=(a,l)=>{const u=this.services.backendConnector.state[`${a}|${l}`];return u===-1||u===0||u===2};if(t.precheck){const a=t.precheck(this,r);if(a!==void 0)return a}return!!(this.hasResourceBundle(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||r(i,e)&&(!s||r(n,e)))}loadNamespaces(e,t){const i=L();return this.options.ns?(d(e)&&(e=[e]),e.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{i.resolve(),t&&t(s)}),i):(t&&t(),Promise.resolve())}loadLanguages(e,t){const i=L();d(e)&&(e=[e]);const s=this.options.preload||[],n=e.filter(r=>s.indexOf(r)<0&&this.services.languageUtils.isSupportedCode(r));return n.length?(this.options.preload=s.concat(n),this.loadResources(r=>{i.resolve(),t&&t(r)}),i):(t&&t(),Promise.resolve())}dir(e){var s,n;if(e||(e=this.resolvedLanguage||(((s=this.languages)==null?void 0:s.length)>0?this.languages[0]:this.language)),!e)return"rtl";try{const r=new Intl.Locale(e);if(r&&r.getTextInfo){const a=r.getTextInfo();if(a&&a.direction)return a.direction}}catch(r){}const t=["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"],i=((n=this.services)==null?void 0:n.languageUtils)||new fe(ge());return e.toLowerCase().indexOf("-latn")>1?"ltr":t.indexOf(i.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new M(e,t)}cloneInstance(e={},t=G){const i=e.forkResourceStore;i&&delete e.forkResourceStore;const s=v(g(g({},this.options),e),{isClone:!0}),n=new M(s);if((e.debug!==void 0||e.prefix!==void 0)&&(n.logger=n.logger.clone(e)),["store","services","language"].forEach(a=>{n[a]=this[a]}),n.services=g({},this.services),n.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},i){const a=Object.keys(this.store.data).reduce((l,u)=>(l[u]=g({},this.store.data[u]),l[u]=Object.keys(l[u]).reduce((h,f)=>(h[f]=g({},l[u][f]),h),l[u]),l),{});n.store=new ae(a,s),n.services.resourceStore=n.store}return n.translator=new Q(n.services,s),n.translator.on("*",(a,...l)=>{n.emit(a,...l)}),n.init(s,t),n.translator.options=s,n.translator.backendConnector.services.utils={hasLoadedNamespace:n.hasLoadedNamespace.bind(n)},n}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const y=M.createInstance();y.createInstance=M.createInstance,y.createInstance,y.dir,y.init,y.loadResources,y.reloadResources,y.use,y.changeLanguage,y.getFixedT,y.t,y.exists,y.setDefaultNamespace,y.hasLoadedNamespace,y.loadNamespaces,y.loadLanguages;const ze=(o,e)=>{for(const t of e){const i=o.find(t);i&&i.each((s,n)=>{const r=globalThis.$(n);if(r.attr("data-i18n"))return;const a=r.text().trim();a&&(r.attr({"data-i18n":a}),r.text(y.t(a)));const l=r.attr("placeholder");l&&(r.attr({"data-i18n":"[placeholder]"+l}),r.attr({placeholder:y.t(l)}))})}},H=o=>{for(const e of o){const t=globalThis.$(e);t&&t.each((i,s)=>{const n=globalThis.$(s);if(n.attr("data-i18n"))return;const r=n.text().trim();r&&(n.attr({"data-i18n":r}),n.text(y.t(r)));const a=n.attr("placeholder");a&&(n.attr({"data-i18n":"[placeholder]"+a}),n.attr({placeholder:y.t(a)}))})}},Je=(o,e)=>{ze(e,[".hiprint-option-item-label","textarea","input","select option",".option","button","label",".hiprint-option-title",".hiprint-option-item-desc"])},We=()=>{document.querySelectorAll("[data-i18n]").forEach(o=>{const e=o.getAttribute("data-i18n");if(!e.includes("[")){o.textContent=y.t(e);return}const t=e.match(/\[([^\]]+)\](.+)/);if(t&&t.length===3){const i=t[1],s=t[2];o.setAttribute(i,y.t(s))}})};let xe=!1;const ye=o=>{if(xe)return;xe=!0,globalThis.hiprint.i18next=y,globalThis.hiprint.t=y.t;const e=Object.keys(o.resources||{});globalThis.hiprint.languages=["简体中文",...e],globalThis.hiprint.changeLanguage=(t,i)=>{y.changeLanguage(t,(s,n)=>{i&&i(s,n),We()})}};function _e(o,e){y.init(g({},o),(i,s)=>{e&&e(y,s,i)});let t=[];return{name:"i18n",description:"i18next",hooks:[{hook:"ready",name:"i18n set",description:"添加 i18n 方法",priority:1,run:()=>{ye(o)}},{hook:"getOptionItem",name:"i18n options",description:"渲染元素属性时做多语言处理",priority:1,run:i=>{if(i){t.push(i.name);const s=i.createTarget;return i.createTarget=function(...n){const r=s.call(i,...n);return t.some(a=>a==i.name)&&r.attr("data-name")||(r.attr({"data-name":i.name}),Je(i,r)),r},i}}},{hook:"onDesigned",name:"i18n other selector",description:"其他UI选择器多语言处理",priority:1,run:({hiprint:i,designerUtils:s})=>{var a;ye(o);const n=(a=s.printTemplate)==null?void 0:a.id;n&&(globalThis.hinnn.event.on("PrintElementSelectEventKey_"+n,l=>{setTimeout(()=>{H([".printSetting .prop-tab-items .tab-title"])},0)}),globalThis.$(".hiprint-printPaper.design").on("contextmenu",()=>{H([".hicontextmenu .hicontextmenuitem .title span",".hicontextmenu .hicontextmenuitem .nav"])})),H([".svp-header p",".svp-tools .tool-name",".svp-dragbox .header span",".preview-bar button span",".printer-list-txt"])}},{hook:"onPreview",name:"i18n preview selector",description:"组件内预览选择器多语言处理",priority:1,run:i=>{setTimeout(()=>{H([".preview-bar button span",".printer-list-txt"])},0)}}],leastHiprintVersion:"0.1.28"}}b.default=_e,b.translateBySelector=H,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -0,0 +1,2 @@
1
+ export declare const translateBySelector: (selectorList: string[]) => void;
2
+ export declare const translateOptions: (item: any, target: any) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sv-print/plugin-i18n",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "sv-print 多语言插件",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "dist"
21
21
  ],
22
22
  "scripts": {
23
- "build": "vite build",
23
+ "build": "vite build && tsc src/index.ts --declaration --emitDeclarationOnly --outDir dist",
24
24
  "build-browserify": "vite build --mode=browserify",
25
25
  "pub": "pnpm build && npm --registry https://registry.npmjs.org/ publish --access public",
26
26
  "pub-beta": "pnpm build && npm --registry https://registry.npmjs.org/ publish --access public --tag beta"
@@ -31,10 +31,14 @@
31
31
  ],
32
32
  "author": "",
33
33
  "license": "MIT",
34
- "devDependencies": {
35
- "sv-print": "^0.1.28"
36
- },
37
34
  "dependencies": {
38
35
  "i18next": "^25.3.2"
36
+ },
37
+ "devDependencies": {
38
+ "sv-print": "^0.2.9",
39
+ "typescript": "^5.9.3"
40
+ },
41
+ "peerDependencies": {
42
+ "sv-print": "^0.2.0"
39
43
  }
40
44
  }