@tolgee/web
Advanced tools
Comparing version 5.28.7 to 5.29.0
@@ -1,2 +0,2 @@ | ||
var e,t=Object.defineProperty,n=Object.defineProperties,a=Object.getOwnPropertyDescriptors,r=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(e,n,a)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a,l=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&s(e,n,t[n]);if(r)for(var n of r(t))i.call(t,n)&&s(e,n,t[n]);return e},c=(e,t)=>n(e,a(t));function u(e,t){for(var n=0;n<t.length;n++){const a=t[n];if("string"!=typeof a&&!Array.isArray(a))for(const t in a)if("default"!==t&&!(t in e)){const n=Object.getOwnPropertyDescriptor(a,t);n&&Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>a[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function g(e){return Boolean(e&&"function"==typeof e.then)}function d(e,t){return g(e)?Promise.resolve(e).then(t):t(e)}function f(e,t,n){function a(n){const a=t(n);throw e.emit(a),console.error(a),a}try{const e=n();return g(e)?e.catch(a):e}catch(e){a(e)}}function p(e){const t=(Array.isArray(e)?e:[e]).map((e=>`'${e}'`)),n=t.slice(-2).join(" or ");return`Tolgee: You need to specify ${[...t.slice(0,-2),n].join(", ")} option`}function h(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function v(e){return h(e)||[]}function m(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?v(t):v(null==t?void 0:t[e]);var n}function y(e){return Array.from(new Set(e))}function b(e){return e?e.replace(/\/+$/,""):e}const E=(e,t)=>fetch(e,t);const w=(e=E)=>(t,n)=>{let a=(r=null==n?void 0:n.headers,Object.fromEntries(new Headers(r).entries()));var r;return a["x-api-key"]&&(a=Object.assign({"x-tolgee-sdk-type":"JS","x-tolgee-sdk-version":"5.28.7"},a)),e(t,Object.assign(Object.assign({},n),{headers:a}))};function O(e){let t=[];return Object.freeze({listen(e){const n=t=>{e(t)};return t.push(n),{unsubscribe(){t=t.filter((e=>n!==e))}}},emit(n){e()&&t.forEach((e=>e({value:n})))}})}function L(e,t,n){const a=new Set,r=new Set;let o=[];function i(){if(0===o.length)return;const e=o;o=[],a.forEach((e=>{e({value:void 0})}));let n=new Set;e.forEach((e=>{void 0===e?n=void 0:void 0!==n&&e.forEach((e=>n.add(e)))}));!function(e){const n=new Set(t());r.forEach((t=>{(void 0===e||-1!==(null==e?void 0:e.findIndex((e=>n.has(e)||t.namespaces.has(e)))))&&t.fn({value:void 0})}))}(n?Array.from(n.keys()):void 0)}return Object.freeze({emit(t,n){e()&&(o.push(t),n?setTimeout(i,0):i())},listen(e){a.add(e);return{unsubscribe:()=>{a.delete(e)}}},listenSome(e){const t={fn:t=>{e(t)},namespaces:new Set};r.add(t);const a={unsubscribe:()=>{r.delete(t)},subscribeNs:e=>(v(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}class A extends Error{constructor(e,t,n=!1){const{language:a,namespace:r}=e;super(`Tolgee: Failed to fetch record for "${a}"${r&&` and "${r}"`}`),this.cause=t,this.isDev=n,this.name="RecordFetchError",this.language=a,this.namespace=r}}class k extends Error{constructor(e,t){super(e),this.cause=t,this.name="LanguageDetectorError"}}class N extends Error{constructor(e,t){super(e),this.cause=t,this.name="LanguageStorageError"}}const j=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):j(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},T=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},x=({language:e,namespace:t})=>t?`${e}:${t}`:e;function R(e,t,n,a,r,o,i){const s=new Map,l=new Map;let c={},u=0;function d(t,n,a){const r=x(t);l.set(r,{data:j(n),version:a}),e.onCacheChange.emit(t)}async function f(a,r){let o;if(r)try{o=await n(a)}catch(t){const n=new A(a,t,!0);e.onError.emit(n),console.warn(n)}return o||(o=await async function(n){let a;const r=c[x(n)];return"function"==typeof r&&(a=r()),a||(a=t(n)),g(a)?null==a?void 0:a.catch((t=>{const a=new A(n,t);throw e.onError.emit(a),console.error(a),a})):a}(a)),o}const p=Object.freeze({addStaticData(e){e&&(c=Object.assign(Object.assign({},c),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=T(e),a=l.get(e);a&&0!==a.version||d(n,t,0)}})))},invalidate(){s.clear(),u+=1},addRecord(e,t){d(e,t,u)},exists(e,t=!1){const n=l.get(x(e));return n&&t?n.version===u:Boolean(n)},getRecord(e){var t;return null===(t=l.get(x(a(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=l.get(x(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const r of e)for(const e of t){const t=null===(a=l.get(x({language:e,namespace:r})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[r]}return y(e)},getTranslationFallback(e,t,n){var a;for(const r of e)for(const e of t){const t=null===(a=l.get(x({language:e,namespace:r})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var r;const o=null===(r=l.get(x(t)))||void 0===r?void 0:r.data;null==o||o.set(n,a),e.onCacheChange.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(r())return!0;if(void 0===e)return s.size>0;const t=v(e);return Boolean(Array.from(s.keys()).find((e=>t.includes(T(e).namespace))))},isLoading(e,t){const n=v(t);return Boolean(r()||Array.from(s.keys()).find((t=>{const a=T(t);return(!n.length||n.includes(a.namespace))&&!p.exists({namespace:a.namespace,language:e})})))},async loadRecords(e,t){const n=e.map((e=>{const n=a(e),r=x(n),o=s.get(r);if(o)return{new:!1,promise:o,keyObject:n,cacheKey:r};const i=f(n,t)||Promise.resolve(void 0);return s.set(r,i),{new:!0,promise:i,keyObject:n,cacheKey:r}}));o.notify(),i.notify();const r=await Promise.all(n.map((e=>e.promise)));return n.forEach(((e,t)=>{const n=s.get(e.cacheKey)!==e.promise;if(e.new&&!n){s.delete(e.cacheKey);const n=r[t];n?p.addRecord(e.keyObject,n):p.getRecord(e.keyObject)||p.addRecord(e.keyObject,{})}})),o.notify(),i.notify(),n.map((e=>p.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(l.entries()).map((([e,t])=>Object.assign(Object.assign({},T(e)),{data:t.data})))});return p}function C(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(e);r<a.length;r++)t.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(n[a[r]]=e[a[r]])}return n}const P="invalid",S={defaultNs:"",observerOptions:{tagAttributes:{textarea:["placeholder"],input:["value","placeholder"],img:["alt"],"*":["aria-label","title"]},restrictedElements:["script","style"],highlightKeys:["Alt"],highlightColor:"rgb(255, 0, 0)",highlightWidth:5,inputPrefix:"%-%tolgee:",inputSuffix:"%-%",passToParent:["option","optgroup"],fullKeyEncode:!1},observerType:"invisible",onFormatError:P,apiUrl:"https://app.tolgee.io",fetch:w(),onTranslationMissing:({key:e})=>e},D=(...e)=>{let t={};return e.forEach((e=>{t=Object.assign(Object.assign(Object.assign({},t),e),{observerOptions:Object.assign(Object.assign({},t.observerOptions),null==e?void 0:e.observerOptions)})})),t};function I(e,t){const n=D(S,null==t?void 0:t.initialOptions,e);return n.apiUrl=b(n.apiUrl),(null==e?void 0:e.fetch)&&(n.fetch=w(e.fetch)),{initialOptions:n,activeNamespaces:(null==t?void 0:t.activeNamespaces)||new Map,language:null==t?void 0:t.language,pendingLanguage:null==t?void 0:t.language,isInitialLoading:!1,isRunning:!1}}function U(e,t,n,a,r,o,i,s){const l={ui:void 0},c={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},u=async({keysAndDefaults:e,target:t})=>{var n;const i=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,fallbackNamespaces:a(t),namespace:r({key:e,ns:t})[0],translation:o({key:e,ns:t})})));null===(n=c.ui)||void 0===n||n.handleElementClick(i,t)},g=(e,t)=>{var n;return(null===(n=c.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function p(e){const t=o({key:e.key,ns:e.ns});return T.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function h(){return{fetch:t().fetch}}function v(e){c.observer=null==e?void 0:e()}function m(){return Boolean(c.observer)}function y(e){e&&c.formatters.push(e)}function b(e){c.finalFormatter=e}function E(e){l.ui=e}function w(){return Boolean(l.ui)}function O(e){c.languageStorage=e}function L(e){c.languageDetector=e}function A(e){e&&c.backends.push(e)}function j(e){c.devBackend=e}const T=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:b,addFormatter:y,setObserver:v,hasObserver:m,setUi:E,hasUi:w,setDevBackend:j,addBackend:A,setLanguageDetector:L,setLanguageStorage:O}))},findPositions:g,run(){var e,n;const{apiKey:a,apiUrl:r,projectId:o,observerOptions:d,tagNewKeys:f}=t();c.ui=null===(e=l.ui)||void 0===e?void 0:e.call(l,{apiKey:a,apiUrl:r,projectId:o,highlight:T.highlight,changeTranslation:i,findPositions:g,onPermanentChange:e=>s.onPermanentChange.emit(e),tagNewKeys:f}),null===(n=c.observer)||void 0===n||n.run({mouseHighlight:!0,options:d,translate:p,onClick:u})},stop(){var e;c.ui=void 0,null===(e=c.observer)||void 0===e||e.stop()},getLanguageStorage:()=>c.languageStorage,getInitialLanguage(){const e=n();return d(f(s.onError,(e=>new N("Tolgee: Failed to load language",e)),(()=>{var e;return null===(e=c.languageStorage)||void 0===e?void 0:e.getLanguage(h())})),(t=>e&&!e.includes(t)||!t?function(){if(!c.languageDetector)return;const e=n();return f(s.onError,(e=>new k("Tolgee: Failed to detect language",e)),(()=>{var t;return null===(t=c.languageDetector)||void 0===t?void 0:t.getLanguage(Object.assign({availableLanguages:e},h()))}))}():t))},setStoredLanguage:e=>f(s.onError,(e=>new N("Tolgee: Failed to store language",e)),(()=>{var t;return null===(t=c.languageStorage)||void 0===t?void 0:t.setLanguage(e,h())})),getDevBackend:()=>c.devBackend,getBackendRecord:async({language:e,namespace:t})=>{for(const n of c.backends){const a=await n.getRecord(Object.assign({language:e,namespace:t},h()));if(void 0!==a)return a}},getBackendDevRecord:async({language:e,namespace:n})=>{var a;const{apiKey:r,apiUrl:o,projectId:i}=t();return null===(a=c.devBackend)||void 0===a?void 0:a.getRecord(Object.assign({apiKey:r,apiUrl:o,projectId:i,language:e,namespace:n},h()))},getLanguageDetector:()=>c.languageDetector,retranslate(){var e;null===(e=c.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,a;return(null===(a=null===(n=c.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return c.observer?null===(t=c.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return c.observer?null===(t=c.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(T.getDevBackend()),formatTranslation(n){var a,{formatEnabled:r}=n,o=C(n,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:u,params:g,ns:d,orEmpty:f}=o,p=null!=s?s:l;let h="";null==s&&(h=t().onTranslationMissing(o));let v=null!=p?p:f?"":h;const m=e(),y=r||!(null===(a=c.observer)||void 0===a?void 0:a.outputNotFormattable),b=e=>c.observer&&!u?c.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:d}):e;v=b(v);try{if(p&&m&&y)for(const e of c.formatters)v=e.format({translation:v,language:m,params:g});c.finalFormatter&&p&&m&&y&&(v=c.finalFormatter.format({translation:v,language:m,params:g}))}catch(e){console.error(e);const n=("string"==typeof(E=e)?E:"string"==typeof(null==E?void 0:E.message)?E.message:void 0)||P,a=t().onFormatError,r=typeof a;v="string"===r?a:"function"===r?a(n,o):P,v=b(v)}var E;return v}});return T}const F=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const _=(e,...t)=>{let n,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof t[0]?(a.defaultValue=t[0],n=t[1]):"object"==typeof t[0]&&(n=t[0])),n&&(a=Object.assign(Object.assign({},function(e){var{ns:t,noWrap:n,orEmpty:a,params:r,language:o}=e,i=C(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:o};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function $({options:e}){const t=function(e,t){let n=!0;function a(){return n}const r=Object.freeze({onPendingLanguageChange:O(a),onLanguageChange:O(a),onLoadingChange:O(a),onFetchingChange:O(a),onInitialLoaded:O(a),onRunningChange:O(a),onCacheChange:O(a),onUpdate:L(a,e,t),onPermanentChange:O(a),onError:O(a),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return r.onPendingLanguageChange.listen(t);case"language":return r.onLanguageChange.listen(t);case"loading":return r.onLoadingChange.listen(t);case"fetching":return r.onFetchingChange.listen(t);case"initialLoad":return r.onInitialLoaded.listen(t);case"running":return r.onRunningChange.listen(t);case"cache":return r.onCacheChange.listen(t);case"update":return r.onUpdate.listen(t);case"permanentChange":return r.onPermanentChange.listen(t);case"error":return r.onError.listen(t)}}});return r.onInitialLoaded.listen((()=>r.onUpdate.emit())),r.onLanguageChange.listen((()=>r.onUpdate.emit())),r.onCacheChange.listen((({value:e})=>r.onUpdate.emit([e.namespace],!0))),r}(l,c),n=F(!1,(()=>i.isFetching()),t.onFetchingChange.emit),a=F(!1,(()=>x.isLoading()),t.onLoadingChange.emit),r=function(e,t,n){let a,r=I();const o=Object.freeze({init(e){r=I(e,r)},isRunning:()=>r.isRunning,setRunning(e){r.isRunning!==e&&(r.isRunning=e,n.emit(e))},isInitialLoading:()=>r.isInitialLoading,setInitialLoading(e){r.isInitialLoading=e},getLanguage:()=>r.language||r.initialOptions.language,setLanguage(t){r.language!==t&&(r.language=t,e.emit(t))},getPendingLanguage:()=>r.pendingLanguage||o.getLanguage(),setPendingLanguage(e){r.pendingLanguage!==e&&(r.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},r.initialOptions),a),addActiveNs(e){v(e).forEach((e=>{const t=r.activeNamespaces.get(e);void 0!==t?r.activeNamespaces.set(e,t+1):r.activeNamespaces.set(e,1)}))},removeActiveNs(e){v(e).forEach((e=>{const t=r.activeNamespaces.get(e);void 0!==t&&t>1?r.activeNamespaces.set(e,t-1):r.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>y([...r.initialOptions.ns||[r.initialOptions.defaultNs],...v(r.initialOptions.fallbackNs),...r.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||o.getLanguage();return t?y([t,...m(t,r.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>v(r.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?r.initialOptions.defaultNs:e,getAvailableLanguages(){if(r.initialOptions.availableLanguages)return r.initialOptions.availableLanguages;if(r.initialOptions.staticData){const e=Object.keys(r.initialOptions.staticData).map((e=>T(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?o.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:b(e.apiUrl)}):void 0}});return o}(t.onLanguageChange,t.onPendingLanguageChange,t.onRunningChange),o=U(r.getLanguage,r.getInitialOptions,r.getAvailableLanguages,u,k,N,h,t),i=R(t,o.getBackendRecord,o.getBackendDevRecord,r.withDefaultNs,r.isInitialLoading,n,a);let s;function l(){return r.getFallbackNs()}function c(e){return r.getDefaultNs(e)}function u(e){return[...v(c(e)),...l()]}function f(e){return[...v(null!=e?e:c()),...r.getRequiredNamespaces()]}function h(e,t,n){const a=r.withDefaultNs(e),o=i.getTranslation(a,t);return i.changeTranslation(a,t,n),{revert(){i.changeTranslation(a,t,o)}}}function E(e){r.init(e),i.addStaticData(r.getInitialOptions().staticData)}function w(e,t){const n=r.getFallbackLangs(e),a=f(t),o=[];return n.forEach((e=>{a.forEach((t=>{i.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}function A(e,t){const n=w(e,t);if(n.length)return d(x.loadRecords(n),(()=>{}))}function k({key:e,ns:t}){const n=r.getFallbackLangs(),a=u(null!=t?t:void 0);return i.getTranslationNs(a,n,e)}function N({key:e,ns:t,language:n}){const a=u(null!=t?t:void 0),o=r.getFallbackLangs(n);return i.getTranslationFallback(a,o,e)}function j(){const e=d(function(){if(r.getLanguage())return;return d(o.getInitialLanguage(),(e=>{const t=e||r.getInitialOptions().defaultLanguage;t&&r.setLanguage(t)}))}(),(()=>A()));if(g(e))return r.setInitialLoading(!0),n.notify(),a.notify(),Promise.resolve(e).then((()=>{r.setInitialLoading(!1),n.notify(),a.notify(),t.onInitialLoaded.emit()}));t.onInitialLoaded.emit()}e&&E(e),t.onUpdate.listen((()=>{r.isRunning()&&o.retranslate()}));const x=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),r),o),i),{init:E,getTranslation:N,changeTranslation:h,getTranslationNs:k,getDefaultAndFallbackNs:u,findPositions:o.findPositions,getRequiredRecords:w,async changeLanguage(e){r.getPendingLanguage()===e&&r.getLanguage()===e||(r.setPendingLanguage(e),r.isRunning()&&await A(e),e===r.getPendingLanguage()&&(r.setLanguage(e),await o.setStoredLanguage(e)))},async addActiveNs(e,t){t||r.addActiveNs(e),r.isRunning()&&await A(void 0,e)},loadRecords:e=>i.loadRecords(e,x.isDev()),loadRecord:async e=>(await x.loadRecords([e]))[0],isLoading:e=>i.isLoading(r.getLanguage(),e),isLoaded(e){const t=r.getLanguage();if(!t)return!1;const n=r.getFallbackLangs(t),a=f(e),o=[];return n.forEach((e=>{a.forEach((t=>{i.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=_(...e),n=N(t);return o.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(r.getInitialOptions().apiKey&&r.getInitialOptions().apiUrl),run:()=>(function(){if((o.getLanguageDetector()||o.getLanguageStorage())&&!r.getAvailableLanguages())throw new Error(p("availableLanguages"));if(!r.getLanguage()&&!r.getInitialOptions().defaultLanguage)throw new Error(p(["defaultLanguage","language"]))}(),r.isRunning()||(r.setRunning(!0),o.run(),s=j()),Promise.resolve(s)),stop(){r.isRunning()&&(o.stop(),r.setRunning(!1))}}));return x}const M=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=D(e.options,n),t),init(t){const n=function(e){const t=$({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),t.isDev()&&t.invalidate(),n&&t.run()}t.isDev()&&t.invalidate();const a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmitterActive:t.setEmitterActive,getLanguage:t.getLanguage,getPendingLanguage:t.getPendingLanguage,changeLanguage:t.changeLanguage,changeTranslation:t.changeTranslation,addActiveNs:t.addActiveNs,removeActiveNs:t.removeActiveNs,loadRecords:t.loadRecords,loadRecord:t.loadRecord,addStaticData:t.addStaticData,getRecord:t.getRecord,getAllRecords:t.getAllRecords,isLoaded:t.isLoaded,getRequiredRecords:t.getRequiredRecords,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,findPositions:t.findPositions,getInitialOptions:t.getInitialOptions,isDev:t.isDev,wrap:t.wrap,unwrap:t.unwrap,overrideCredentials(e){n((()=>t.overrideCredentials(e)))},addPlugin(e){e&&n((()=>t.addPlugin(a,e)))},updateOptions(e){e&&n((()=>t.init(e)))}});return a}(D(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},K=0,B=1,z=2;class V extends Error{constructor(e,t,n){let a;a=e===K?"Empty parameter":e===B?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function W(e){return/\s/.test(e)}const H=0,Y=1,G=2,X=3,q=4,J=new Set([G,Y,H]),Z="'",Q=new Set(["{","}",Z]),ee=e=>/[0-9a-zA-Z_]/.test(e);function te(e,t){const[n,a]=function(e){let t=H,n="",a="",r="";const o=[],i=[];let s=0;function l(t){throw new V(t,s,e)}const c=()=>{o.push(n),n=""},u=()=>{""===a&&l(K),i.push(a),a=""};for(s=0;s<e.length;s++)switch(r=e[s],t){case H:r===Z?(n+=r,t=Y):"{"===r?(c(),t=X):(n+=r,t=H);break;case Y:Q.has(r)?(n=n.slice(0,-1)+r,t=G):(n+=r,t=H);break;case G:r===Z?t=H:(n+=r,t=G);break;case X:"}"===r?(u(),t=H):W(r)?""!==a&&(u(),t=q):(ee(r)||l(B),a+=r,t=X);break;case q:"}"==r?t=H:W(r)?t=q:l(B)}return J.has(t)||l(z),c(),[o,i]}(e),r=[n[0]];for(let o=1;o<n.length;o++){const i=null==t?void 0:t[a[o-1]];if(void 0===i)throw new Error(`Missing parameter "${a[o-1]}" in "${e}"`);r.push(String(i)),r.push(n[o])}return r.join("")}const ne=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>te(e,t)}),e),ae="__tolgee_dev_tools",re="__tolgee_preferredLanguages",oe="data-tolgee-key-only",ie="data-tolgee-restricted",se="_tolgee",le="_tolgee-highlighter";function ce(){var e,t;return void 0===(null==(t=null==(e=globalThis.window)?void 0:e.document)?void 0:t.createElement)}function ue(e){if(ce())throw new Error(`${e}: Can't run on the server`)}function ge(e,t){return{oldTextContent:e,keys:t}}function de(e){return e.textContent}function fe(e,t){e.textContent=t}function pe(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,r=void 0===e.ns||void 0===t.ns||-1!==(null==(n=e.ns)?void 0:n.findIndex((e=>{var n;return null==(n=t.ns)?void 0:n.includes(e)})));return a&&r}const he={position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function ve({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;const r=function(e){for(;e;){if(null!==e.getAttribute("disabled"))return!1;e=e.parentElement}return!0}(n);let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(le),Object.entries(he).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const i=n.getBoundingClientRect();o.style.pointerEvents=r?"none":"auto",o.style.borderWidth=t+"px",o.style.top=i.top-t+"px",o.style.left=i.left-t+"px",o.style.width=i.width+"px",o.style.height=i.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null==(e=t.highlightEl)||e.remove(),t.highlightEl=void 0}}(0,a)}})}const me={capture:!0},ye={capture:!0,passive:!0},be=new Map([["Control","ctrlKey"],["Alt","altKey"],["Meta","metaKey"],["Shift","shiftKey"]]);function Ee({highlightKeys:e,elementStore:t,onClick:n,options:a}){var r,o;const i=new Set;let s,l,c=[];const u=(null==(r=a.targetElement)?void 0:r.getRootNode())||document,g=(null==(o=a.targetElement)?void 0:o.ownerDocument)||document;function d(){var e;const n=t.get(s);n&&(n.preventClean=!1,null==(e=n.unhighlight)||e.call(n),s=void 0)}function f(){const e=l;let n;if(e&&A()){n=function(e){for(const n of e){const e=L(n,(e=>t.get(e)));if(void 0!==e)return e||void 0}}(u.elementsFromPoint(e.x,e.y)||[])}!function(e){var n;if(s!==e){d();const a=t.get(e);a&&(a.preventClean=!0,null==(n=a.highlight)||n.call(a),s=e)}}(n)}function p(e){l=e,f()}function h(e){for(const[t,n]of be.entries())i.has(t)&&!e[n]?i.delete(t):!i.has(t)&&e[n]&&i.add(t)}function v(e){var t;h(e),A()&&(t=e.target,!Boolean(L(t,(e=>e.id===ae))))&&(e.stopPropagation(),e.preventDefault())}function m(e){h(e),p({x:e.clientX,y:e.clientY})}function y(e){h(e),f()}function b(e){h(e),f()}function E(){var e;const n=t.get(s);null==(e=null==n?void 0:n.highlight)||e.call(n)}function w(e){v(e),h(e),p({x:e.clientX,y:e.clientY}),A()&&s&&(n(s),d())}function O(e,t,n){g.addEventListener(e,t,n),c.push([e,t,n])}function L(e,t){return e.id===ae?null:t(e)?e:(null==e?void 0:e.parentElement)?L(e.parentElement,t):void 0}function A(){for(const t of e)if(!i.has(t))return!1;return!0}return Object.freeze({stop(){!function(){for(const e of c)g.removeEventListener(...e);c=[]}()},run(){O("keydown",y,me),O("keyup",b,me),O("mousemove",m,ye),O("scroll",E,ye),O("click",w,me),O("mouseenter",v,me),O("mouseover",v,me),O("mouseout",v,me),O("mouseleave",v,me),O("mousedown",v,me),O("mouseup",v,me)}})}function we(e,t,n){const a=ve({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=Ee({highlightKeys:e.highlightKeys,elementStore:t,onClick(e){const a=t.get(e);n({target:e,keysAndDefaults:s(a)})},options:e});function o(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${ie}]`)}function i(e,n){var a;n.highlightEl&&(null==(a=n.unhighlight)||a.call(n)),e.removeAttribute(se),t.remove(e)}function s(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({isRestricted:o,register(e,n,r){if(o(e))return;const i=e;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(se,"true")),s.nodes.set(n,r),a.initHighlighter(i,s)},forEachElement:t.forEachElement,cleanupLingeringKeyAttributes(){t.forEachElement(((e,t)=>{if(!t.preventClean){for(const[e]of t.nodes)if(e.nodeType===Node.ATTRIBUTE_NODE){const n=e;n.name===oe&&null===n.ownerElement&&t.nodes.delete(n)}0===t.nodes.size&&i(e,t)}}))},cleanupRemovedNodes(e){t.forEachElement(((t,n)=>{n.preventClean||(e.has(t)||function(e,t){for(const[n]of e.nodes)t.has(n)&&e.nodes.delete(n)}(n,e),(e.has(t)||0===n.nodes.size)&&i(t,n))}))},findAll(e,n){const a=[];return t.forEachElement(((t,r)=>{for(const t of r.nodes.values()){if(t.keys.find((t=>pe({key:e,ns:h(n)},{key:t.key,ns:h(t.ns)})))){a.push(r);break}}})),a},run(e){e&&r.run()},stop(){r.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null==(n=t.unhighlight)||n.call(t))}))}})}function Oe(){let e,t=!1;const n=function(){const e=new Map;return Object.freeze({set(t,n){e.set(t,n)},get:t=>t&&e.get(t),remove:t=>e.delete(t),forEachElement(t){e.forEach(((e,n)=>t(n,e)))}})}();function a({mouseHighlight:e,options:a,wrapper:r,onClick:o}){if(ce())return{stop(){t=!1},wrapper:r};const i=function(e){const t=Object.freeze({getSuitableParent(n){const a=function(e){return e.parentElement?e.parentElement:e.ownerElement&&e.ownerElement||void 0}(n);if(void 0===a)throw console.error(n),new Error("No suitable parent found for node above.");if(!e.passToParent)return a;if(Array.isArray(e.passToParent)){const t=e=>a.tagName.toLowerCase()===e.toLowerCase();if(-1===e.passToParent.findIndex(t))return a}return"function"!=typeof e.passToParent||e.passToParent(a)?t.getSuitableParent(a):a}});return t}(a),s=function(e,t){const n=Object.freeze({handleAttributes(n,a=!0){var r,o;const i=[],s=Object.fromEntries(Object.entries(e.tagAttributes).map((([e,t])=>[e.toUpperCase(),t])));if(n.nodeType===Node.ELEMENT_NODE){const e=n;let a=null!=(r=s[e.tagName.toUpperCase()])?r:[];"*"in s&&(a=a.concat(s["*"])),i.push(...a.filter((t=>e.hasAttribute(t))).map((t=>e.getAttributeNode(t))).filter((e=>t.testAttribute(e))))}if(a){const e=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,(e=>{var t,n;return(null==(t=s[e.tagName.toUpperCase()])?void 0:t.some((t=>e.hasAttribute(t))))||(null==(n=s["*"])?void 0:n.some((t=>e.hasAttribute(t))))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}));for(;e.nextNode();){const n=e.currentNode;let a=null!=(o=s[n.tagName.toUpperCase()])?o:[];"*"in s&&(a=a.concat(s["*"])),i.push(...a.filter((e=>n.hasAttribute(e))).map((e=>n.getAttributeNode(e))).filter((e=>t.testAttribute(e))))}}return i},handleChildList(e){const t=[];return t.push(...e.flatMap((e=>n.handleAttributes(e,!0)))),t.push(...e.flatMap((e=>n.handleText(e)))),t},handleText(e){if(e.nodeType===Node.TEXT_NODE)return t.testTextNode(e)?[e]:[];const n=[],a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,(e=>t.testTextNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;a.nextNode();)n.push(a.currentNode);return n}});return n}(a,r),l=we(a,n,o);function c(e){for(const t of e){const e=t.parentElement;if(e&&l.isRestricted(e))continue;const n=de(t),a=n?r.unwrap(n):null;if(a){const{text:e,keys:r}=a;fe(t,e);const o=ge(n,r),s=i.getSuitableParent(t);l.register(s,t,o)}}}function u(e){const t=i.getSuitableParent(e);l.register(t,e,{oldTextContent:"",keys:[{key:de(e)}],keyAttributeOnly:!0})}function g(e,t){if(e.nodeType===Node.ATTRIBUTE_NODE){const t=e;if(t.name===oe)return void u(t)}if(e.nodeType===Node.ELEMENT_NODE){const t=e.getAttributeNode(oe);t&&u(t)}if(!t)return;const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,(e=>e.hasAttribute(oe)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;n.nextNode();){u(n.currentNode.getAttributeNode(oe))}}const d=new MutationObserver((e=>{if(!t)return;const n=e.filter((e=>"childList"===e.type)).flatMap((e=>Array.from(e.removedNodes))),a=new Set(n);for(const e of n){if(e.nodeType===Node.ELEMENT_NODE)for(let t=0;t<e.attributes.length;t++)a.add(e.attributes[t]);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);for(;t.nextNode();){const e=t.currentNode;if(e.nodeType===Node.ELEMENT_NODE){const t=e;for(let e=0;e<t.attributes.length;e++)a.add(t.attributes[e])}a.add(e)}}a.size>0&&l.cleanupRemovedNodes(a),e.some((e=>"attributes"===e.type&&e.attributeName===oe))&&l.cleanupLingeringKeyAttributes();const r=new Set;for(const t of e)switch(t.type){case"characterData":s.handleText(t.target).forEach((e=>r.add(e)));break;case"childList":g(t.target,!0),t.addedNodes.length>0&&s.handleChildList(Array.from(t.addedNodes)).forEach((e=>r.add(e))),t.removedNodes.length>0&&s.handleChildList(Array.from(t.removedNodes)).forEach((e=>r.delete(e)));break;case"attributes":t.attributeName===oe&&g(t.target,!1),s.handleAttributes(t.target,!1).forEach((e=>r.add(e)))}c([...r])})),f=a.targetElement||document;t=!0,l.run(e),g(f,!0),c(s.handleChildList([f]));const p=new Set;return p.add(oe),Object.values(a.tagAttributes).forEach((e=>e.forEach((e=>p.add(e.toLowerCase()))))),d.observe(f,{attributes:!0,attributeFilter:[...p],childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),d.disconnect()},elementRegistry:l,wrapper:r}}return Object.freeze({run(t){e=a(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null==(a=null==(n=null==e?void 0:e.elementRegistry)?void 0:n.forEachElement)||a.call(n,t)},highlight(t,n){var a;const r=(null==(a=null==e?void 0:e.elementRegistry)?void 0:a.findAll(t,n))||[];return r.forEach((e=>{var t;return null==(t=e.highlight)?void 0:t.call(e)})),{unhighlight(){r.forEach((e=>{var t;return null==(t=e.unhighlight)?void 0:t.call(e)}))}}},findPositions(t,n){var a;const r=(null==(a=null==e?void 0:e.elementRegistry)?void 0:a.findAll(t,n))||[],o=[];return r.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),r.forEach((e=>{const a=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{pe({key:t,ns:h(n)},{key:e.key,ns:h(e.ns)})&&o.push({position:{x:a.x,y:a.y,width:a.width,height:a.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),o},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}var Le="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Ae={};!function(e){function t(e){for(var t=0,n=Math.min(65536,e.length+1),a=new Uint16Array(n),r=[],o=0;;){var i=t<e.length;if(!i||o>=n-1){var s=a.subarray(0,o);if(r.push(String.fromCharCode.apply(null,s)),!i)return r.join("");e=e.subarray(t),t=0,o=0}var l=e[t++];if(0==(128&l))a[o++]=l;else if(192==(224&l)){var c=63&e[t++];a[o++]=(31&l)<<6|c}else if(224==(240&l)){c=63&e[t++];var u=63&e[t++];a[o++]=(31&l)<<12|c<<6|u}else if(240==(248&l)){var g=(7&l)<<18|(c=63&e[t++])<<12|(u=63&e[t++])<<6|63&e[t++];g>65535&&(g-=65536,a[o++]=g>>>10&1023|55296,g=56320|1023&g),a[o++]=g}}}var n="Failed to ",a=function(e,t,a){if(e)throw new Error("".concat(n).concat(t,": the '").concat(a,"' option is unsupported."))},r="function"==typeof Buffer&&Buffer.from,o=r?function(e){return Buffer.from(e)}:function(e){for(var t=0,n=e.length,a=0,r=Math.max(32,n+(n>>>1)+7),o=new Uint8Array(r>>>3<<3);t<n;){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319){if(t<n){var s=e.charCodeAt(t);56320==(64512&s)&&(++t,i=((1023&i)<<10)+(1023&s)+65536)}if(i>=55296&&i<=56319)continue}if(a+4>o.length){r+=8,r=(r*=1+t/e.length*2)>>>3<<3;var l=new Uint8Array(r);l.set(o),o=l}if(0!=(4294967168&i)){if(0==(4294965248&i))o[a++]=i>>>6&31|192;else if(0==(4294901760&i))o[a++]=i>>>12&15|224,o[a++]=i>>>6&63|128;else{if(0!=(4292870144&i))continue;o[a++]=i>>>18&7|240,o[a++]=i>>>12&63|128,o[a++]=i>>>6&63|128}o[a++]=63&i|128}else o[a++]=i}return o.slice?o.slice(0,a):o.subarray(0,a)};function i(){this.encoding="utf-8"}i.prototype.encode=function(e,t){return a(t&&t.stream,"encode","stream"),o(e)};var s=!r&&"function"==typeof Blob&&"function"==typeof URL&&"function"==typeof URL.createObjectURL,l=["utf-8","utf8","unicode-1-1-utf-8"],c=t;r?c=function(e,t){return(e instanceof Buffer?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)).toString(t)}:s&&(c=function(e){try{return function(e){var t;try{var n=new Blob([e],{type:"text/plain;charset=UTF-8"});t=URL.createObjectURL(n);var a=new XMLHttpRequest;return a.open("GET",t,!1),a.send(),a.responseText}finally{t&&URL.revokeObjectURL(t)}}(e)}catch(n){return t(e)}});var u="construct 'TextDecoder'",g="".concat(n," ").concat(u,": the ");function d(e,t){if(a(t&&t.fatal,u,"fatal"),e=e||"utf-8",!(r?Buffer.isEncoding(e):-1!==l.indexOf(e.toLowerCase())))throw new RangeError("".concat(g," encoding label provided ('").concat(e,"') is invalid."));this.encoding=e,this.fatal=!1,this.ignoreBOM=!1}d.prototype.decode=function(e,t){var n;return a(t&&t.stream,"decode","stream"),n=e instanceof Uint8Array?e:e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer):new Uint8Array(e),c(n,this.encoding)},e.TextEncoder=e.TextEncoder||i,e.TextDecoder=e.TextDecoder||d}("undefined"!=typeof window?window:Le);const ke=u({__proto__:null,default:Ae},[Ae]);null==(e=console.assert)||e.call(console,ke);const Ne=["",""],je=RegExp(`([${Ne.join("")}]{9})+`,"gu");function Te(e){const t=function(e){return Array.from((new TextEncoder).encode(e))}(e).map(Number),n=t.map((e=>function(e){const t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0")).join("");return Array.from(n).map((e=>Ne[Number(e)])).join("")}function xe(e){const t=Array.from(e).map((e=>Ne.indexOf(e))).map(String).join("").match(/(.{9})/g),n=Uint8Array.from((null==t?void 0:t.map((e=>parseInt(e.slice(0,8),2))))||[]);return a=n,(new TextDecoder).decode(new Uint8Array(a));var a}function Re({fullKeyEncode:e}){const t=function(){const e=[];return Object.freeze({valueToNumber(t){let n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:t=>e[t]})}();function n(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}return Object.freeze({unwrap(e){const n=[],a=function(e){var t;const n=null==(t=e.match(je))?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(xe))||[]}(e);a.forEach((e=>{const a=function(e){if(e.length<=4){const[n]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(e);return t.numberToValue(n)}return e}(e),r=function(e){try{return JSON.parse(e||"{}")}catch(e){return void console.error(e)}}(a);if(r){const{k:e,d:t,n:a}=r;n.push({key:e,defaultValue:t,ns:a})}}));const r=function(e){return e.replace(je,"")}(e);return{text:r,keys:n}},wrap({key:a,defaultValue:r,translation:o,ns:i}){let s;if(e){s=Te(n({key:a,ns:i}))}else{const e=n({key:a,ns:i,defaultValue:r}),o=t.valueToNumber(e);s=Te(String.fromCodePoint(o))}const l=o||"";return"string"==typeof l?l+s:l},testTextNode(e){var t,n,a;return null!=(a=(null==(t=e.textContent)?void 0:t.includes(`${Ne[0]}${Ne[0]}`))||(null==(n=e.textContent)?void 0:n.includes(`${Ne[1]}${Ne[0]}`)))&&a},testAttribute:e=>e.value.includes(`${Ne[0]}${Ne[0]}`)||e.value.includes(`${Ne[1]}${Ne[0]}`)})}function Ce(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function Pe({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:r,ns:o}=function(e){let t=!1,n="",a="",r="KEY";const o={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{o.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==r||","!==s?"KEY"!==r||"|"!==s?"NAMESPACE"!==r||","!==s?"KEY"!==r||":"!==s?"DEFAULT_VALUE"!==r||":"!==s?"PARAM_NAME"!==r||":"!==s?"PARAM_VALUE"!==r||","!==s?n+=s:(r="PARAM_NAME",o.params[a]=n,n=""):(r="PARAM_VALUE",a=n,n=""):(r="PARAM_NAME",o.defaultValue=n,n=""):(r="PARAM_NAME",o.key=n,n=""):(r="DEFAULT_VALUE",i(n),n=""):(r="NAMESPACE",o.key=n,n=""):(r="DEFAULT_VALUE",o.key=n,n=""):t=!0;return"KEY"===r&&(o.key=n),"DEFAULT_VALUE"===r&&(o.defaultValue=n),"PARAM_VALUE"===r&&(o.params[a]=n),"NAMESPACE"===r&&i(n),o}(e);return{translated:n({key:t,params:a,defaultValue:r,ns:o,noWrap:!0}),key:t,params:a,defaultValue:r,ns:o}}function r(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function o(e){return"string"==typeof e?e.replace(new RegExp("[,:|\\\\]","gs"),"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(`Parameters of type "${typeof e}" are not supported in "text" wrapper mode.`),e)}return Object.freeze({wrap({key:n,params:a,defaultValue:r,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${o(e)}:${o(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==r?`,${o(r)}`:"",c="string"==typeof i?[i]:i,u=(null==c?void 0:c.length)?`|${c.map((e=>o(e))).join("|")}`:"";return`${e}${o(n)}${u}${l}${s}${t}`},unwrap(n){const o=new RegExp(`(\\\\?)(${r(e)}(.*?)${r(t)})`,"gs"),i=[];let s,l=!1,c=0,u="";for(;null!==(s=o.exec(n));){let e=s[1];const[t,r,o,g]=s,{index:d,input:f}=s;if(u+=f.substr(c,d-c),c=d+t.length,"\\"===e){if(!Ce(d,n)){u+=o;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,u+=e+p.translated}return u+=n.substring(c),l?{text:u,keys:i}:{text:n,keys:[]}},testTextNode(n){var a,r,o;return null!=(o=(null==(a=n.textContent)?void 0:a.includes(e))&&(null==(r=n.textContent)?void 0:r.includes(t)))&&o},testAttribute:n=>n.value.includes(e)&&n.value.includes(t)})}const Se=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=Oe();return Object.freeze(c(l({},e),{run(t){const n=Pe({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(c(l({},t),{wrapper:n}))},retranslate(){e.forEachElement(((t,n)=>{for(const[t,a]of n.nodes.entries()){if(a.keyAttributeOnly)return;const n=e.unwrap(a.oldTextContent);n&&fe(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=Oe();return Object.freeze(c(l({},e),{run(t){const n=Re({fullKeyEncode:t.options.fullKeyEncode});e.run(c(l({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),De="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Ie(e){const t=De.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function Ue(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,r=0;const o=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|Ie(e[i]),n+=5,n>=8&&(o[r++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",r=Math.pow(2,16)-1;for(let e=0;e<n;e+=r)e+r>n&&(r=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+r));return a}(o.buffer)}function Fe(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=Ue(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}const _e=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:r,fetch:o}){var i;const s=null!=(i=Fe(t))?i:r;let l=void 0!==s?`${e}/v2/projects/${s}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(l+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===r)throw new Error("You need to specify 'projectId' when using PAT key");return o(l,{headers:{"X-API-Key":t||"","Content-Type":"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>e[n]));throw new Error(e.statusText)}))}}),e);function $e({message:e,recievingMessage:t,data:n,attempts:a=1,timeout:r=300}){let o=!1;const i=()=>new Promise(((a,o)=>{const i=function(e,t){const n=n=>{var a,r;e.includes(null==(a=n.data)?void 0:a.type)&&t(null==(r=n.data)?void 0:r.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(s),l(),a(e)}));window.postMessage({type:e,data:n},window.origin);const s=setTimeout((function(){l(),o()}),r);function l(){i.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<a;e++){if(o)return new Promise((()=>{}));try{return await i()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}let Me=null;function Ke(e){var t;return Me||(Me=(t=`https://cdn.jsdelivr.net/npm/@tolgee/web@${e}/dist/tolgee-in-context-tools.umd.min.js`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.head.appendChild(a)}))).then((()=>window["@tolgee/in-context-tools"].InContextTools))),Me}const Be="__tolgee_apiKey",ze="__tolgee_apiUrl";function Ve(){const e=sessionStorage.getItem(Be)||void 0,t=sessionStorage.getItem(ze)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function We(){sessionStorage.removeItem(Be),sessionStorage.removeItem(ze)}let He=()=>e=>e;(()=>{if("undefined"==typeof window)return!1;try{return"undefined"!=typeof sessionStorage&&sessionStorage}catch(e){return console.error("sessionStorage not available",e),!1}})()&&(He=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=$e({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:t,attempts:4});return e=n,a}}}();e.on("running",(({value:n})=>{var a;n&&(a=()=>{t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(We)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Ve()&&(async()=>{const e=await Ke("5.28.7");return t=>{const n=Ve();return t.addPlugin(e({credentials:n})),t}})().then((t=>{e.addPlugin(t)})).catch((e=>{console.error("Tolgee: Failed to load in-context tools"),console.error(e)})),e});const Ye="__tolgee_currentLanguage";const Ge=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(ue("LanguageStorage"),localStorage.getItem(Ye)||void 0),setLanguage(e){ue("LanguageStorage"),localStorage.setItem(Ye,e)}}),e);const Xe=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){ue("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),r=a(window.navigator.language);return e.find((e=>a(e)===r))||void 0}}),e);function qe(e){return e.endsWith("/")?e.slice(0,-1):e}const Je={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${qe(n)}/${e}/${t}.json`:`${qe(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Ze(e){const t=c(l(l({},Je),e),{headers:l(l({},Je.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:a,getData:s,headers:u}=t,g=((e,t)=>{var n={};for(var a in e)o.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&r)for(var a of r(e))t.indexOf(a)<0&&i.call(e,a)&&(n[a]=e[a]);return n})(t,["prefix","getPath","getData","headers"]);return{getRecord:({namespace:e,language:t,fetch:r})=>r(a({namespace:e,language:t,prefix:n}),l({headers:u},g)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return s(e)}))}}const Qe=e=>(t,n)=>(n.addBackend(Ze(e)),t);function et(){return M().use(He())}const tt=()=>e=>e;export{Qe as BackendFetch,He as BrowserExtensionPlugin,ae as DEVTOOLS_ID,_e as DevBackend,tt as DevTools,ne as FormatSimple,Xe as LanguageDetector,k as LanguageDetectorError,Ge as LanguageStorage,N as LanguageStorageError,Se as ObserverPlugin,re as PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY,A as RecordFetchError,se as TOLGEE_ATTRIBUTE_NAME,ie as TOLGEE_RESTRICT_ATTRIBUTE,oe as TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE,et as Tolgee,M as TolgeeCore,w as createFetchFunction,h as getFallback,v as getFallbackArray,Fe as getProjectIdFromApiKey,_ as getTranslateProps}; | ||
var e,t=Object.defineProperty,n=Object.defineProperties,a=Object.getOwnPropertyDescriptors,r=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(e,n,a)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a,l=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&s(e,n,t[n]);if(r)for(var n of r(t))i.call(t,n)&&s(e,n,t[n]);return e},c=(e,t)=>n(e,a(t));function u(e,t){for(var n=0;n<t.length;n++){const a=t[n];if("string"!=typeof a&&!Array.isArray(a))for(const t in a)if("default"!==t&&!(t in e)){const n=Object.getOwnPropertyDescriptor(a,t);n&&Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>a[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function g(e){return Boolean(e&&"function"==typeof e.then)}function d(e,t){return g(e)?Promise.resolve(e).then(t):t(e)}function f(e,t,n){function a(n){const a=t(n);throw e.emit(a),console.error(a),a}try{const e=n();return g(e)?e.catch(a):e}catch(e){a(e)}}function p(e){const t=(Array.isArray(e)?e:[e]).map((e=>`'${e}'`)),n=t.slice(-2).join(" or ");return`Tolgee: You need to specify ${[...t.slice(0,-2),n].join(", ")} option`}function h(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function v(e){return h(e)||[]}function m(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?v(t):v(null==t?void 0:t[e]);var n}function y(e){return Array.from(new Set(e))}function b(e){return e?e.replace(/\/+$/,""):e}const E=(e,t)=>fetch(e,t);const w=(e=E)=>(t,n)=>{let a=(r=null==n?void 0:n.headers,Object.fromEntries(new Headers(r).entries()));var r;return a["x-api-key"]&&(a=Object.assign({"x-tolgee-sdk-type":"JS","x-tolgee-sdk-version":"5.29.0"},a)),e(t,Object.assign(Object.assign({},n),{headers:a}))};function O(e){let t=[];return Object.freeze({listen(e){const n=t=>{e(t)};return t.push(n),{unsubscribe(){t=t.filter((e=>n!==e))}}},emit(n){e()&&t.forEach((e=>e({value:n})))}})}function L(e,t,n){const a=new Set,r=new Set;let o=[];function i(){if(0===o.length)return;const e=o;o=[],a.forEach((e=>{e({value:void 0})}));let n=new Set;e.forEach((e=>{void 0===e?n=void 0:void 0!==n&&e.forEach((e=>n.add(e)))}));!function(e){const n=new Set(t());r.forEach((t=>{(void 0===e||-1!==(null==e?void 0:e.findIndex((e=>n.has(e)||t.namespaces.has(e)))))&&t.fn({value:void 0})}))}(n?Array.from(n.keys()):void 0)}return Object.freeze({emit(t,n){e()&&(o.push(t),n?setTimeout(i,0):i())},listen(e){a.add(e);return{unsubscribe:()=>{a.delete(e)}}},listenSome(e){const t={fn:t=>{e(t)},namespaces:new Set};r.add(t);const a={unsubscribe:()=>{r.delete(t)},subscribeNs:e=>(v(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}class A extends Error{constructor(e,t,n=!1){const{language:a,namespace:r}=e;super(`Tolgee: Failed to fetch record for "${a}"${r&&` and "${r}"`}`),this.cause=t,this.isDev=n,this.name="RecordFetchError",this.language=a,this.namespace=r}}class k extends Error{constructor(e,t){super(e),this.cause=t,this.name="LanguageDetectorError"}}class N extends Error{constructor(e,t){super(e),this.cause=t,this.name="LanguageStorageError"}}const j=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):j(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},T=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},x=({language:e,namespace:t})=>t?`${e}:${t}`:e;function R(e,t,n,a,r,o,i){const s=new Map,l=new Map;let c={},u=0;function d(t,n,a){const r=x(t);l.set(r,{data:j(n),version:a}),e.onCacheChange.emit(t)}async function f(a,r){let o;if(r)try{o=await n(a)}catch(t){const n=new A(a,t,!0);e.onError.emit(n),console.warn(n)}return o||(o=await async function(n){let a;const r=c[x(n)];return"function"==typeof r&&(a=r()),a||(a=t(n)),g(a)?null==a?void 0:a.catch((t=>{const a=new A(n,t);throw e.onError.emit(a),console.error(a),a})):a}(a)),o}const p=Object.freeze({addStaticData(e){e&&(c=Object.assign(Object.assign({},c),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=T(e),a=l.get(e);a&&0!==a.version||d(n,t,0)}})))},invalidate(){s.clear(),u+=1},addRecord(e,t){d(e,t,u)},exists(e,t=!1){const n=l.get(x(e));return n&&t?n.version===u:Boolean(n)},getRecord(e){var t;return null===(t=l.get(x(a(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=l.get(x(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const r of e)for(const e of t){const t=null===(a=l.get(x({language:e,namespace:r})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[r]}return y(e)},getTranslationFallback(e,t,n){var a;for(const r of e)for(const e of t){const t=null===(a=l.get(x({language:e,namespace:r})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var r;const o=null===(r=l.get(x(t)))||void 0===r?void 0:r.data;null==o||o.set(n,a),e.onCacheChange.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(r())return!0;if(void 0===e)return s.size>0;const t=v(e);return Boolean(Array.from(s.keys()).find((e=>t.includes(T(e).namespace))))},isLoading(e,t){const n=v(t);return Boolean(r()||Array.from(s.keys()).find((t=>{const a=T(t);return(!n.length||n.includes(a.namespace))&&!p.exists({namespace:a.namespace,language:e})})))},async loadRecords(e,t){const n=e.map((e=>{const n=a(e),r=x(n),o=s.get(r);if(o)return{new:!1,promise:o,keyObject:n,cacheKey:r};const i=f(n,t)||Promise.resolve(void 0);return s.set(r,i),{new:!0,promise:i,keyObject:n,cacheKey:r}}));o.notify(),i.notify();const r=await Promise.all(n.map((e=>e.promise)));return n.forEach(((e,t)=>{const n=s.get(e.cacheKey)!==e.promise;if(e.new&&!n){s.delete(e.cacheKey);const n=r[t];n?p.addRecord(e.keyObject,n):p.getRecord(e.keyObject)||p.addRecord(e.keyObject,{})}})),o.notify(),i.notify(),n.map((e=>p.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(l.entries()).map((([e,t])=>Object.assign(Object.assign({},T(e)),{data:t.data})))});return p}function C(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(e);r<a.length;r++)t.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(n[a[r]]=e[a[r]])}return n}const P="invalid",S={defaultNs:"",observerOptions:{tagAttributes:{textarea:["placeholder"],input:["value","placeholder"],img:["alt"],"*":["aria-label","title"]},restrictedElements:["script","style"],highlightKeys:["Alt"],highlightColor:"rgb(255, 0, 0)",highlightWidth:5,inputPrefix:"%-%tolgee:",inputSuffix:"%-%",passToParent:["option","optgroup"],fullKeyEncode:!1},observerType:"invisible",onFormatError:P,apiUrl:"https://app.tolgee.io",fetch:w(),onTranslationMissing:({key:e})=>e},D=(...e)=>{let t={};return e.forEach((e=>{t=Object.assign(Object.assign(Object.assign({},t),e),{observerOptions:Object.assign(Object.assign({},t.observerOptions),null==e?void 0:e.observerOptions)})})),t};function I(e,t){const n=D(S,null==t?void 0:t.initialOptions,e);return n.apiUrl=b(n.apiUrl),(null==e?void 0:e.fetch)&&(n.fetch=w(e.fetch)),{initialOptions:n,activeNamespaces:(null==t?void 0:t.activeNamespaces)||new Map,language:null==t?void 0:t.language,pendingLanguage:null==t?void 0:t.language,isInitialLoading:!1,isRunning:!1}}function U(e,t,n,a,r,o,i,s){const l={ui:void 0},c={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},u=async({keysAndDefaults:e,target:t})=>{var n;const i=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,fallbackNamespaces:a(t),namespace:r({key:e,ns:t})[0],translation:o({key:e,ns:t})})));null===(n=c.ui)||void 0===n||n.handleElementClick(i,t)},g=(e,t)=>{var n;return(null===(n=c.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function p(e){const t=o({key:e.key,ns:e.ns});return T.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function h(){return{fetch:t().fetch}}function v(e){c.observer=null==e?void 0:e()}function m(){return Boolean(c.observer)}function y(e){e&&c.formatters.push(e)}function b(e){c.finalFormatter=e}function E(e){l.ui=e}function w(){return Boolean(l.ui)}function O(e){c.languageStorage=e}function L(e){c.languageDetector=e}function A(e){e&&c.backends.push(e)}function j(e){c.devBackend=e}const T=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:b,addFormatter:y,setObserver:v,hasObserver:m,setUi:E,hasUi:w,setDevBackend:j,addBackend:A,setLanguageDetector:L,setLanguageStorage:O}))},findPositions:g,run(){var e,n;const{apiKey:a,apiUrl:r,projectId:o,observerOptions:d,tagNewKeys:f}=t();c.ui=null===(e=l.ui)||void 0===e?void 0:e.call(l,{apiKey:a,apiUrl:r,projectId:o,highlight:T.highlight,changeTranslation:i,findPositions:g,onPermanentChange:e=>s.onPermanentChange.emit(e),tagNewKeys:f}),null===(n=c.observer)||void 0===n||n.run({mouseHighlight:!0,options:d,translate:p,onClick:u})},stop(){var e;c.ui=void 0,null===(e=c.observer)||void 0===e||e.stop()},getLanguageStorage:()=>c.languageStorage,getInitialLanguage(){const e=n();return d(f(s.onError,(e=>new N("Tolgee: Failed to load language",e)),(()=>{var e;return null===(e=c.languageStorage)||void 0===e?void 0:e.getLanguage(h())})),(t=>e&&!e.includes(t)||!t?function(){if(!c.languageDetector)return;const e=n();return f(s.onError,(e=>new k("Tolgee: Failed to detect language",e)),(()=>{var t;return null===(t=c.languageDetector)||void 0===t?void 0:t.getLanguage(Object.assign({availableLanguages:e},h()))}))}():t))},setStoredLanguage:e=>f(s.onError,(e=>new N("Tolgee: Failed to store language",e)),(()=>{var t;return null===(t=c.languageStorage)||void 0===t?void 0:t.setLanguage(e,h())})),getDevBackend:()=>c.devBackend,getBackendRecord:async({language:e,namespace:t})=>{for(const n of c.backends){const a=await n.getRecord(Object.assign({language:e,namespace:t},h()));if(void 0!==a)return a}},getBackendDevRecord:async({language:e,namespace:n})=>{var a;const{apiKey:r,apiUrl:o,projectId:i}=t();return null===(a=c.devBackend)||void 0===a?void 0:a.getRecord(Object.assign({apiKey:r,apiUrl:o,projectId:i,language:e,namespace:n},h()))},getLanguageDetector:()=>c.languageDetector,retranslate(){var e;null===(e=c.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,a;return(null===(a=null===(n=c.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return c.observer?null===(t=c.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return c.observer?null===(t=c.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(T.getDevBackend()),formatTranslation(n){var a,{formatEnabled:r}=n,o=C(n,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:u,params:g,ns:d,orEmpty:f}=o,p=null!=s?s:l;let h="";null==s&&(h=t().onTranslationMissing(o));let v=null!=p?p:f?"":h;const m=e(),y=r||!(null===(a=c.observer)||void 0===a?void 0:a.outputNotFormattable),b=e=>c.observer&&!u?c.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:d}):e;v=b(v);try{if(p&&m&&y)for(const e of c.formatters)v=e.format({translation:v,language:m,params:g});c.finalFormatter&&p&&m&&y&&(v=c.finalFormatter.format({translation:v,language:m,params:g}))}catch(e){console.error(e);const n=("string"==typeof(E=e)?E:"string"==typeof(null==E?void 0:E.message)?E.message:void 0)||P,a=t().onFormatError,r=typeof a;v="string"===r?a:"function"===r?a(n,o):P,v=b(v)}var E;return v}});return T}const F=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const _=(e,...t)=>{let n,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof t[0]?(a.defaultValue=t[0],n=t[1]):"object"==typeof t[0]&&(n=t[0])),n&&(a=Object.assign(Object.assign({},function(e){var{ns:t,noWrap:n,orEmpty:a,params:r,language:o}=e,i=C(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:o};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function $({options:e}){const t=function(e,t){let n=!0;function a(){return n}const r=Object.freeze({onPendingLanguageChange:O(a),onLanguageChange:O(a),onLoadingChange:O(a),onFetchingChange:O(a),onInitialLoaded:O(a),onRunningChange:O(a),onCacheChange:O(a),onUpdate:L(a,e,t),onPermanentChange:O(a),onError:O(a),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return r.onPendingLanguageChange.listen(t);case"language":return r.onLanguageChange.listen(t);case"loading":return r.onLoadingChange.listen(t);case"fetching":return r.onFetchingChange.listen(t);case"initialLoad":return r.onInitialLoaded.listen(t);case"running":return r.onRunningChange.listen(t);case"cache":return r.onCacheChange.listen(t);case"update":return r.onUpdate.listen(t);case"permanentChange":return r.onPermanentChange.listen(t);case"error":return r.onError.listen(t)}}});return r.onInitialLoaded.listen((()=>r.onUpdate.emit())),r.onLanguageChange.listen((()=>r.onUpdate.emit())),r.onCacheChange.listen((({value:e})=>r.onUpdate.emit([e.namespace],!0))),r}(l,c),n=F(!1,(()=>i.isFetching()),t.onFetchingChange.emit),a=F(!1,(()=>x.isLoading()),t.onLoadingChange.emit),r=function(e,t,n){let a,r=I();const o=Object.freeze({init(e){r=I(e,r)},isRunning:()=>r.isRunning,setRunning(e){r.isRunning!==e&&(r.isRunning=e,n.emit(e))},isInitialLoading:()=>r.isInitialLoading,setInitialLoading(e){r.isInitialLoading=e},getLanguage:()=>r.language||r.initialOptions.language,setLanguage(t){r.language!==t&&(r.language=t,e.emit(t))},getPendingLanguage:()=>r.pendingLanguage||o.getLanguage(),setPendingLanguage(e){r.pendingLanguage!==e&&(r.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},r.initialOptions),a),addActiveNs(e){v(e).forEach((e=>{const t=r.activeNamespaces.get(e);void 0!==t?r.activeNamespaces.set(e,t+1):r.activeNamespaces.set(e,1)}))},removeActiveNs(e){v(e).forEach((e=>{const t=r.activeNamespaces.get(e);void 0!==t&&t>1?r.activeNamespaces.set(e,t-1):r.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>y([...r.initialOptions.ns||[r.initialOptions.defaultNs],...v(r.initialOptions.fallbackNs),...r.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||o.getLanguage();return t?y([t,...m(t,r.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>v(r.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?r.initialOptions.defaultNs:e,getAvailableLanguages(){if(r.initialOptions.availableLanguages)return r.initialOptions.availableLanguages;if(r.initialOptions.staticData){const e=Object.keys(r.initialOptions.staticData).map((e=>T(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?o.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:b(e.apiUrl)}):void 0}});return o}(t.onLanguageChange,t.onPendingLanguageChange,t.onRunningChange),o=U(r.getLanguage,r.getInitialOptions,r.getAvailableLanguages,u,k,N,h,t),i=R(t,o.getBackendRecord,o.getBackendDevRecord,r.withDefaultNs,r.isInitialLoading,n,a);let s;function l(){return r.getFallbackNs()}function c(e){return r.getDefaultNs(e)}function u(e){return[...v(c(e)),...l()]}function f(e){return[...v(null!=e?e:c()),...r.getRequiredNamespaces()]}function h(e,t,n){const a=r.withDefaultNs(e),o=i.getTranslation(a,t);return i.changeTranslation(a,t,n),{revert(){i.changeTranslation(a,t,o)}}}function E(e){r.init(e),i.addStaticData(r.getInitialOptions().staticData)}function w(e,t){const n=r.getFallbackLangs(e),a=f(t),o=[];return n.forEach((e=>{a.forEach((t=>{i.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}function A(e,t){const n=w(e,t);if(n.length)return d(x.loadRecords(n),(()=>{}))}function k({key:e,ns:t}){const n=r.getFallbackLangs(),a=u(null!=t?t:void 0);return i.getTranslationNs(a,n,e)}function N({key:e,ns:t,language:n}){const a=u(null!=t?t:void 0),o=r.getFallbackLangs(n);return i.getTranslationFallback(a,o,e)}function j(){const e=d(function(){if(r.getLanguage())return;return d(o.getInitialLanguage(),(e=>{const t=e||r.getInitialOptions().defaultLanguage;t&&r.setLanguage(t)}))}(),(()=>A()));if(g(e))return r.setInitialLoading(!0),n.notify(),a.notify(),Promise.resolve(e).then((()=>{r.setInitialLoading(!1),n.notify(),a.notify(),t.onInitialLoaded.emit()}));t.onInitialLoaded.emit()}e&&E(e),t.onUpdate.listen((()=>{r.isRunning()&&o.retranslate()}));const x=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),r),o),i),{init:E,getTranslation:N,changeTranslation:h,getTranslationNs:k,getDefaultAndFallbackNs:u,findPositions:o.findPositions,getRequiredRecords:w,async changeLanguage(e){r.getPendingLanguage()===e&&r.getLanguage()===e||(r.setPendingLanguage(e),r.isRunning()&&await A(e),e===r.getPendingLanguage()&&(r.setLanguage(e),await o.setStoredLanguage(e)))},async addActiveNs(e,t){t||r.addActiveNs(e),r.isRunning()&&await A(void 0,e)},loadRecords:e=>i.loadRecords(e,x.isDev()),loadRecord:async e=>(await x.loadRecords([e]))[0],isLoading:e=>i.isLoading(r.getLanguage(),e),isLoaded(e){const t=r.getLanguage();if(!t)return!1;const n=r.getFallbackLangs(t),a=f(e),o=[];return n.forEach((e=>{a.forEach((t=>{i.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=_(...e),n=N(t);return o.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(r.getInitialOptions().apiKey&&r.getInitialOptions().apiUrl),run:()=>(function(){if((o.getLanguageDetector()||o.getLanguageStorage())&&!r.getAvailableLanguages())throw new Error(p("availableLanguages"));if(!r.getLanguage()&&!r.getInitialOptions().defaultLanguage)throw new Error(p(["defaultLanguage","language"]))}(),r.isRunning()||(r.setRunning(!0),o.run(),s=j()),Promise.resolve(s)),stop(){r.isRunning()&&(o.stop(),r.setRunning(!1))}}));return x}const M=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=D(e.options,n),t),init(t){const n=function(e){const t=$({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),t.isDev()&&t.invalidate(),n&&t.run()}t.isDev()&&t.invalidate();const a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmitterActive:t.setEmitterActive,getLanguage:t.getLanguage,getPendingLanguage:t.getPendingLanguage,changeLanguage:t.changeLanguage,changeTranslation:t.changeTranslation,addActiveNs:t.addActiveNs,removeActiveNs:t.removeActiveNs,loadRecords:t.loadRecords,loadRecord:t.loadRecord,addStaticData:t.addStaticData,getRecord:t.getRecord,getAllRecords:t.getAllRecords,isLoaded:t.isLoaded,getRequiredRecords:t.getRequiredRecords,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,findPositions:t.findPositions,getInitialOptions:t.getInitialOptions,isDev:t.isDev,wrap:t.wrap,unwrap:t.unwrap,overrideCredentials(e){n((()=>t.overrideCredentials(e)))},addPlugin(e){e&&n((()=>t.addPlugin(a,e)))},updateOptions(e){e&&n((()=>t.init(e)))}});return a}(D(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},K=0,B=1,z=2;class V extends Error{constructor(e,t,n){let a;a=e===K?"Empty parameter":e===B?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function W(e){return/\s/.test(e)}const H=0,Y=1,G=2,X=3,q=4,J=new Set([G,Y,H]),Z="'",Q=new Set(["{","}",Z]),ee=e=>/[0-9a-zA-Z_]/.test(e);function te(e,t){const[n,a]=function(e){let t=H,n="",a="",r="";const o=[],i=[];let s=0;function l(t){throw new V(t,s,e)}const c=()=>{o.push(n),n=""},u=()=>{""===a&&l(K),i.push(a),a=""};for(s=0;s<e.length;s++)switch(r=e[s],t){case H:r===Z?(n+=r,t=Y):"{"===r?(c(),t=X):(n+=r,t=H);break;case Y:Q.has(r)?(n=n.slice(0,-1)+r,t=G):(n+=r,t=H);break;case G:r===Z?t=H:(n+=r,t=G);break;case X:"}"===r?(u(),t=H):W(r)?""!==a&&(u(),t=q):(ee(r)||l(B),a+=r,t=X);break;case q:"}"==r?t=H:W(r)?t=q:l(B)}return J.has(t)||l(z),c(),[o,i]}(e),r=[n[0]];for(let o=1;o<n.length;o++){const i=null==t?void 0:t[a[o-1]];if(void 0===i)throw new Error(`Missing parameter "${a[o-1]}" in "${e}"`);r.push(String(i)),r.push(n[o])}return r.join("")}const ne=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>te(e,t)}),e),ae="__tolgee_dev_tools",re="__tolgee_preferredLanguages",oe="data-tolgee-key-only",ie="data-tolgee-restricted",se="_tolgee",le="_tolgee-highlighter";function ce(){var e,t;return void 0===(null==(t=null==(e=globalThis.window)?void 0:e.document)?void 0:t.createElement)}function ue(e){if(ce())throw new Error(`${e}: Can't run on the server`)}function ge(e,t){return{oldTextContent:e,keys:t}}function de(e){return e.textContent}function fe(e,t){e.textContent=t}function pe(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,r=void 0===e.ns||void 0===t.ns||-1!==(null==(n=e.ns)?void 0:n.findIndex((e=>{var n;return null==(n=t.ns)?void 0:n.includes(e)})));return a&&r}const he={position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function ve({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;const r=function(e){for(;e;){if(null!==e.getAttribute("disabled"))return!1;e=e.parentElement}return!0}(n);let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(le),Object.entries(he).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const i=n.getBoundingClientRect();o.style.pointerEvents=r?"none":"auto",o.style.borderWidth=t+"px",o.style.top=i.top-t+"px",o.style.left=i.left-t+"px",o.style.width=i.width+"px",o.style.height=i.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null==(e=t.highlightEl)||e.remove(),t.highlightEl=void 0}}(0,a)}})}const me={capture:!0},ye={capture:!0,passive:!0},be=new Map([["Control","ctrlKey"],["Alt","altKey"],["Meta","metaKey"],["Shift","shiftKey"]]);function Ee({highlightKeys:e,elementStore:t,onClick:n,options:a}){var r,o;const i=new Set;let s,l,c=[];const u=(null==(r=a.targetElement)?void 0:r.getRootNode())||document,g=(null==(o=a.targetElement)?void 0:o.ownerDocument)||document;function d(){var e;const n=t.get(s);n&&(n.preventClean=!1,null==(e=n.unhighlight)||e.call(n),s=void 0)}function f(){const e=l;let n;if(e&&A()){n=function(e){for(const n of e){const e=L(n,(e=>t.get(e)));if(void 0!==e)return e||void 0}}(u.elementsFromPoint(e.x,e.y)||[])}!function(e){var n;if(s!==e){d();const a=t.get(e);a&&(a.preventClean=!0,null==(n=a.highlight)||n.call(a),s=e)}}(n)}function p(e){l=e,f()}function h(e){for(const[t,n]of be.entries())i.has(t)&&!e[n]?i.delete(t):!i.has(t)&&e[n]&&i.add(t)}function v(e){var t;h(e),A()&&(t=e.target,!Boolean(L(t,(e=>e.id===ae))))&&(e.stopPropagation(),e.preventDefault())}function m(e){h(e),p({x:e.clientX,y:e.clientY})}function y(e){h(e),f()}function b(e){h(e),f()}function E(){var e;const n=t.get(s);null==(e=null==n?void 0:n.highlight)||e.call(n)}function w(e){v(e),h(e),p({x:e.clientX,y:e.clientY}),A()&&s&&(n(s),d())}function O(e,t,n){g.addEventListener(e,t,n),c.push([e,t,n])}function L(e,t){return e.id===ae?null:t(e)?e:(null==e?void 0:e.parentElement)?L(e.parentElement,t):void 0}function A(){for(const t of e)if(!i.has(t))return!1;return!0}return Object.freeze({stop(){!function(){for(const e of c)g.removeEventListener(...e);c=[]}()},run(){O("keydown",y,me),O("keyup",b,me),O("mousemove",m,ye),O("scroll",E,ye),O("click",w,me),O("mouseenter",v,me),O("mouseover",v,me),O("mouseout",v,me),O("mouseleave",v,me),O("mousedown",v,me),O("mouseup",v,me)}})}function we(e,t,n){const a=ve({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=Ee({highlightKeys:e.highlightKeys,elementStore:t,onClick(e){const a=t.get(e);n({target:e,keysAndDefaults:s(a)})},options:e});function o(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${ie}]`)}function i(e,n){var a;n.highlightEl&&(null==(a=n.unhighlight)||a.call(n)),e.removeAttribute(se),t.remove(e)}function s(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({isRestricted:o,register(e,n,r){if(o(e))return;const i=e;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(se,"true")),s.nodes.set(n,r),a.initHighlighter(i,s)},forEachElement:t.forEachElement,cleanupLingeringKeyAttributes(){t.forEachElement(((e,t)=>{if(!t.preventClean){for(const[e]of t.nodes)if(e.nodeType===Node.ATTRIBUTE_NODE){const n=e;n.name===oe&&null===n.ownerElement&&t.nodes.delete(n)}0===t.nodes.size&&i(e,t)}}))},cleanupRemovedNodes(e){t.forEachElement(((t,n)=>{n.preventClean||(e.has(t)||function(e,t){for(const[n]of e.nodes)t.has(n)&&e.nodes.delete(n)}(n,e),(e.has(t)||0===n.nodes.size)&&i(t,n))}))},findAll(e,n){const a=[];return t.forEachElement(((t,r)=>{for(const t of r.nodes.values()){if(t.keys.find((t=>pe({key:e,ns:h(n)},{key:t.key,ns:h(t.ns)})))){a.push(r);break}}})),a},run(e){e&&r.run()},stop(){r.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null==(n=t.unhighlight)||n.call(t))}))}})}function Oe(){let e,t=!1;const n=function(){const e=new Map;return Object.freeze({set(t,n){e.set(t,n)},get:t=>t&&e.get(t),remove:t=>e.delete(t),forEachElement(t){e.forEach(((e,n)=>t(n,e)))}})}();function a({mouseHighlight:e,options:a,wrapper:r,onClick:o}){if(ce())return{stop(){t=!1},wrapper:r};const i=function(e){const t=Object.freeze({getSuitableParent(n){const a=function(e){return e.parentElement?e.parentElement:e.ownerElement&&e.ownerElement||void 0}(n);if(void 0===a)throw console.error(n),new Error("No suitable parent found for node above.");if(!e.passToParent)return a;if(Array.isArray(e.passToParent)){const t=e=>a.tagName.toLowerCase()===e.toLowerCase();if(-1===e.passToParent.findIndex(t))return a}return"function"!=typeof e.passToParent||e.passToParent(a)?t.getSuitableParent(a):a}});return t}(a),s=function(e,t){const n=Object.freeze({handleAttributes(n,a=!0){var r,o;const i=[],s=Object.fromEntries(Object.entries(e.tagAttributes).map((([e,t])=>[e.toUpperCase(),t])));if(n.nodeType===Node.ELEMENT_NODE){const e=n;let a=null!=(r=s[e.tagName.toUpperCase()])?r:[];"*"in s&&(a=a.concat(s["*"])),i.push(...a.filter((t=>e.hasAttribute(t))).map((t=>e.getAttributeNode(t))).filter((e=>t.testAttribute(e))))}if(a){const e=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,(e=>{var t,n;return(null==(t=s[e.tagName.toUpperCase()])?void 0:t.some((t=>e.hasAttribute(t))))||(null==(n=s["*"])?void 0:n.some((t=>e.hasAttribute(t))))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}));for(;e.nextNode();){const n=e.currentNode;let a=null!=(o=s[n.tagName.toUpperCase()])?o:[];"*"in s&&(a=a.concat(s["*"])),i.push(...a.filter((e=>n.hasAttribute(e))).map((e=>n.getAttributeNode(e))).filter((e=>t.testAttribute(e))))}}return i},handleChildList(e){const t=[];return t.push(...e.flatMap((e=>n.handleAttributes(e,!0)))),t.push(...e.flatMap((e=>n.handleText(e)))),t},handleText(e){if(e.nodeType===Node.TEXT_NODE)return t.testTextNode(e)?[e]:[];const n=[],a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,(e=>t.testTextNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;a.nextNode();)n.push(a.currentNode);return n}});return n}(a,r),l=we(a,n,o);function c(e){for(const t of e){const e=t.parentElement;if(e&&l.isRestricted(e))continue;const n=de(t),a=n?r.unwrap(n):null;if(a){const{text:e,keys:r}=a;fe(t,e);const o=ge(n,r),s=i.getSuitableParent(t);l.register(s,t,o)}}}function u(e){const t=i.getSuitableParent(e);l.register(t,e,{oldTextContent:"",keys:[{key:de(e)}],keyAttributeOnly:!0})}function g(e,t){if(e.nodeType===Node.ATTRIBUTE_NODE){const t=e;if(t.name===oe)return void u(t)}if(e.nodeType===Node.ELEMENT_NODE){const t=e.getAttributeNode(oe);t&&u(t)}if(!t)return;const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,(e=>e.hasAttribute(oe)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;n.nextNode();){u(n.currentNode.getAttributeNode(oe))}}const d=new MutationObserver((e=>{if(!t)return;const n=e.filter((e=>"childList"===e.type)).flatMap((e=>Array.from(e.removedNodes))),a=new Set(n);for(const e of n){if(e.nodeType===Node.ELEMENT_NODE)for(let t=0;t<e.attributes.length;t++)a.add(e.attributes[t]);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);for(;t.nextNode();){const e=t.currentNode;if(e.nodeType===Node.ELEMENT_NODE){const t=e;for(let e=0;e<t.attributes.length;e++)a.add(t.attributes[e])}a.add(e)}}a.size>0&&l.cleanupRemovedNodes(a),e.some((e=>"attributes"===e.type&&e.attributeName===oe))&&l.cleanupLingeringKeyAttributes();const r=new Set;for(const t of e)switch(t.type){case"characterData":s.handleText(t.target).forEach((e=>r.add(e)));break;case"childList":g(t.target,!0),t.addedNodes.length>0&&s.handleChildList(Array.from(t.addedNodes)).forEach((e=>r.add(e))),t.removedNodes.length>0&&s.handleChildList(Array.from(t.removedNodes)).forEach((e=>r.delete(e)));break;case"attributes":t.attributeName===oe&&g(t.target,!1),s.handleAttributes(t.target,!1).forEach((e=>r.add(e)))}c([...r])})),f=a.targetElement||document;t=!0,l.run(e),g(f,!0),c(s.handleChildList([f]));const p=new Set;return p.add(oe),Object.values(a.tagAttributes).forEach((e=>e.forEach((e=>p.add(e.toLowerCase()))))),d.observe(f,{attributes:!0,attributeFilter:[...p],childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),d.disconnect()},elementRegistry:l,wrapper:r}}return Object.freeze({run(t){e=a(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null==(a=null==(n=null==e?void 0:e.elementRegistry)?void 0:n.forEachElement)||a.call(n,t)},highlight(t,n){var a;const r=(null==(a=null==e?void 0:e.elementRegistry)?void 0:a.findAll(t,n))||[];return r.forEach((e=>{var t;return null==(t=e.highlight)?void 0:t.call(e)})),{unhighlight(){r.forEach((e=>{var t;return null==(t=e.unhighlight)?void 0:t.call(e)}))}}},findPositions(t,n){var a;const r=(null==(a=null==e?void 0:e.elementRegistry)?void 0:a.findAll(t,n))||[],o=[];return r.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),r.forEach((e=>{const a=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{pe({key:t,ns:h(n)},{key:e.key,ns:h(e.ns)})&&o.push({position:{x:a.x,y:a.y,width:a.width,height:a.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),o},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}var Le="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Ae={};!function(e){function t(e){for(var t=0,n=Math.min(65536,e.length+1),a=new Uint16Array(n),r=[],o=0;;){var i=t<e.length;if(!i||o>=n-1){var s=a.subarray(0,o);if(r.push(String.fromCharCode.apply(null,s)),!i)return r.join("");e=e.subarray(t),t=0,o=0}var l=e[t++];if(0==(128&l))a[o++]=l;else if(192==(224&l)){var c=63&e[t++];a[o++]=(31&l)<<6|c}else if(224==(240&l)){c=63&e[t++];var u=63&e[t++];a[o++]=(31&l)<<12|c<<6|u}else if(240==(248&l)){var g=(7&l)<<18|(c=63&e[t++])<<12|(u=63&e[t++])<<6|63&e[t++];g>65535&&(g-=65536,a[o++]=g>>>10&1023|55296,g=56320|1023&g),a[o++]=g}}}var n="Failed to ",a=function(e,t,a){if(e)throw new Error("".concat(n).concat(t,": the '").concat(a,"' option is unsupported."))},r="function"==typeof Buffer&&Buffer.from,o=r?function(e){return Buffer.from(e)}:function(e){for(var t=0,n=e.length,a=0,r=Math.max(32,n+(n>>>1)+7),o=new Uint8Array(r>>>3<<3);t<n;){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319){if(t<n){var s=e.charCodeAt(t);56320==(64512&s)&&(++t,i=((1023&i)<<10)+(1023&s)+65536)}if(i>=55296&&i<=56319)continue}if(a+4>o.length){r+=8,r=(r*=1+t/e.length*2)>>>3<<3;var l=new Uint8Array(r);l.set(o),o=l}if(0!=(4294967168&i)){if(0==(4294965248&i))o[a++]=i>>>6&31|192;else if(0==(4294901760&i))o[a++]=i>>>12&15|224,o[a++]=i>>>6&63|128;else{if(0!=(4292870144&i))continue;o[a++]=i>>>18&7|240,o[a++]=i>>>12&63|128,o[a++]=i>>>6&63|128}o[a++]=63&i|128}else o[a++]=i}return o.slice?o.slice(0,a):o.subarray(0,a)};function i(){this.encoding="utf-8"}i.prototype.encode=function(e,t){return a(t&&t.stream,"encode","stream"),o(e)};var s=!r&&"function"==typeof Blob&&"function"==typeof URL&&"function"==typeof URL.createObjectURL,l=["utf-8","utf8","unicode-1-1-utf-8"],c=t;r?c=function(e,t){return(e instanceof Buffer?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)).toString(t)}:s&&(c=function(e){try{return function(e){var t;try{var n=new Blob([e],{type:"text/plain;charset=UTF-8"});t=URL.createObjectURL(n);var a=new XMLHttpRequest;return a.open("GET",t,!1),a.send(),a.responseText}finally{t&&URL.revokeObjectURL(t)}}(e)}catch(n){return t(e)}});var u="construct 'TextDecoder'",g="".concat(n," ").concat(u,": the ");function d(e,t){if(a(t&&t.fatal,u,"fatal"),e=e||"utf-8",!(r?Buffer.isEncoding(e):-1!==l.indexOf(e.toLowerCase())))throw new RangeError("".concat(g," encoding label provided ('").concat(e,"') is invalid."));this.encoding=e,this.fatal=!1,this.ignoreBOM=!1}d.prototype.decode=function(e,t){var n;return a(t&&t.stream,"decode","stream"),n=e instanceof Uint8Array?e:e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer):new Uint8Array(e),c(n,this.encoding)},e.TextEncoder=e.TextEncoder||i,e.TextDecoder=e.TextDecoder||d}("undefined"!=typeof window?window:Le);const ke=u({__proto__:null,default:Ae},[Ae]);null==(e=console.assert)||e.call(console,ke);const Ne=["",""],je=RegExp(`([${Ne.join("")}]{9})+`,"gu");function Te(e){const t=function(e){return Array.from((new TextEncoder).encode(e))}(e).map(Number),n=t.map((e=>function(e){const t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0")).join("");return Array.from(n).map((e=>Ne[Number(e)])).join("")}function xe(e){const t=Array.from(e).map((e=>Ne.indexOf(e))).map(String).join("").match(/(.{9})/g),n=Uint8Array.from((null==t?void 0:t.map((e=>parseInt(e.slice(0,8),2))))||[]);return a=n,(new TextDecoder).decode(new Uint8Array(a));var a}function Re({fullKeyEncode:e}){const t=function(){const e=[];return Object.freeze({valueToNumber(t){let n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:t=>e[t]})}();function n(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}return Object.freeze({unwrap(e){const n=[],a=function(e){var t;const n=null==(t=e.match(je))?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(xe))||[]}(e);a.forEach((e=>{const a=function(e){if(e.length<=4){const[n]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(e);return t.numberToValue(n)}return e}(e),r=function(e){try{return JSON.parse(e||"{}")}catch(e){return void console.error(e)}}(a);if(r){const{k:e,d:t,n:a}=r;n.push({key:e,defaultValue:t,ns:a})}}));const r=function(e){return e.replace(je,"")}(e);return{text:r,keys:n}},wrap({key:a,defaultValue:r,translation:o,ns:i}){let s;if(e){s=Te(n({key:a,ns:i}))}else{const e=n({key:a,ns:i,defaultValue:r}),o=t.valueToNumber(e);s=Te(String.fromCodePoint(o))}const l=o||"";return"string"==typeof l?l+s:l},testTextNode(e){var t,n,a;return null!=(a=(null==(t=e.textContent)?void 0:t.includes(`${Ne[0]}${Ne[0]}`))||(null==(n=e.textContent)?void 0:n.includes(`${Ne[1]}${Ne[0]}`)))&&a},testAttribute:e=>e.value.includes(`${Ne[0]}${Ne[0]}`)||e.value.includes(`${Ne[1]}${Ne[0]}`)})}function Ce(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function Pe({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:r,ns:o}=function(e){let t=!1,n="",a="",r="KEY";const o={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{o.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==r||","!==s?"KEY"!==r||"|"!==s?"NAMESPACE"!==r||","!==s?"KEY"!==r||":"!==s?"DEFAULT_VALUE"!==r||":"!==s?"PARAM_NAME"!==r||":"!==s?"PARAM_VALUE"!==r||","!==s?n+=s:(r="PARAM_NAME",o.params[a]=n,n=""):(r="PARAM_VALUE",a=n,n=""):(r="PARAM_NAME",o.defaultValue=n,n=""):(r="PARAM_NAME",o.key=n,n=""):(r="DEFAULT_VALUE",i(n),n=""):(r="NAMESPACE",o.key=n,n=""):(r="DEFAULT_VALUE",o.key=n,n=""):t=!0;return"KEY"===r&&(o.key=n),"DEFAULT_VALUE"===r&&(o.defaultValue=n),"PARAM_VALUE"===r&&(o.params[a]=n),"NAMESPACE"===r&&i(n),o}(e);return{translated:n({key:t,params:a,defaultValue:r,ns:o,noWrap:!0}),key:t,params:a,defaultValue:r,ns:o}}function r(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function o(e){return"string"==typeof e?e.replace(new RegExp("[,:|\\\\]","gs"),"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(`Parameters of type "${typeof e}" are not supported in "text" wrapper mode.`),e)}return Object.freeze({wrap({key:n,params:a,defaultValue:r,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${o(e)}:${o(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==r?`,${o(r)}`:"",c="string"==typeof i?[i]:i,u=(null==c?void 0:c.length)?`|${c.map((e=>o(e))).join("|")}`:"";return`${e}${o(n)}${u}${l}${s}${t}`},unwrap(n){const o=new RegExp(`(\\\\?)(${r(e)}(.*?)${r(t)})`,"gs"),i=[];let s,l=!1,c=0,u="";for(;null!==(s=o.exec(n));){let e=s[1];const[t,r,o,g]=s,{index:d,input:f}=s;if(u+=f.substr(c,d-c),c=d+t.length,"\\"===e){if(!Ce(d,n)){u+=o;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,u+=e+p.translated}return u+=n.substring(c),l?{text:u,keys:i}:{text:n,keys:[]}},testTextNode(n){var a,r,o;return null!=(o=(null==(a=n.textContent)?void 0:a.includes(e))&&(null==(r=n.textContent)?void 0:r.includes(t)))&&o},testAttribute:n=>n.value.includes(e)&&n.value.includes(t)})}const Se=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=Oe();return Object.freeze(c(l({},e),{run(t){const n=Pe({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(c(l({},t),{wrapper:n}))},retranslate(){e.forEachElement(((t,n)=>{for(const[t,a]of n.nodes.entries()){if(a.keyAttributeOnly)return;const n=e.unwrap(a.oldTextContent);n&&fe(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=Oe();return Object.freeze(c(l({},e),{run(t){const n=Re({fullKeyEncode:t.options.fullKeyEncode});e.run(c(l({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),De="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Ie(e){const t=De.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function Ue(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,r=0;const o=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|Ie(e[i]),n+=5,n>=8&&(o[r++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",r=Math.pow(2,16)-1;for(let e=0;e<n;e+=r)e+r>n&&(r=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+r));return a}(o.buffer)}function Fe(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=Ue(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}const _e=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:r,fetch:o}){var i;const s=null!=(i=Fe(t))?i:r;let l=void 0!==s?`${e}/v2/projects/${s}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(l+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===r)throw new Error("You need to specify 'projectId' when using PAT key");return o(l,{headers:{"X-API-Key":t||"","Content-Type":"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>e[n]));throw new Error(e.statusText)}))}}),e);function $e({message:e,recievingMessage:t,data:n,attempts:a=1,timeout:r=300}){let o=!1;const i=()=>new Promise(((a,o)=>{const i=function(e,t){const n=n=>{var a,r;e.includes(null==(a=n.data)?void 0:a.type)&&t(null==(r=n.data)?void 0:r.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(s),l(),a(e)}));window.postMessage({type:e,data:n},window.origin);const s=setTimeout((function(){l(),o()}),r);function l(){i.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<a;e++){if(o)return new Promise((()=>{}));try{return await i()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}let Me=null;function Ke(e){var t;return Me||(Me=(t=`https://cdn.jsdelivr.net/npm/@tolgee/web@${e}/dist/tolgee-in-context-tools.umd.min.js`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.head.appendChild(a)}))).then((()=>window["@tolgee/in-context-tools"].InContextTools))),Me}const Be="__tolgee_apiKey",ze="__tolgee_apiUrl";function Ve(){const e=sessionStorage.getItem(Be)||void 0,t=sessionStorage.getItem(ze)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function We(){sessionStorage.removeItem(Be),sessionStorage.removeItem(ze)}let He=()=>e=>e;(()=>{if("undefined"==typeof window)return!1;try{return"undefined"!=typeof sessionStorage&&sessionStorage}catch(e){return console.error("sessionStorage not available",e),!1}})()&&(He=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=$e({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:t,attempts:4});return e=n,a}}}();e.on("running",(({value:n})=>{var a;n&&(a=()=>{t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(We)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Ve()&&(async()=>{const e=await Ke("5.29.0");return t=>{const n=Ve();return t.addPlugin(e({credentials:n})),t}})().then((t=>{e.addPlugin(t)})).catch((e=>{console.error("Tolgee: Failed to load in-context tools"),console.error(e)})),e});const Ye="__tolgee_currentLanguage";const Ge=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(ue("LanguageStorage"),localStorage.getItem(Ye)||void 0),setLanguage(e){ue("LanguageStorage"),localStorage.setItem(Ye,e)}}),e);const Xe=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){ue("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),r=a(window.navigator.language);return e.find((e=>a(e)===r))||void 0}}),e);function qe(e){return e.endsWith("/")?e.slice(0,-1):e}const Je={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${qe(n)}/${e}/${t}.json`:`${qe(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Ze(e){const t=c(l(l({},Je),e),{headers:l(l({},Je.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:a,getData:s,headers:u}=t,g=((e,t)=>{var n={};for(var a in e)o.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&r)for(var a of r(e))t.indexOf(a)<0&&i.call(e,a)&&(n[a]=e[a]);return n})(t,["prefix","getPath","getData","headers"]);return{getRecord:({namespace:e,language:t,fetch:r})=>r(a({namespace:e,language:t,prefix:n}),l({headers:u},g)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return s(e)}))}}const Qe=e=>(t,n)=>(n.addBackend(Ze(e)),t);function et(){return M().use(He())}const tt=()=>e=>e;export{Qe as BackendFetch,He as BrowserExtensionPlugin,ae as DEVTOOLS_ID,_e as DevBackend,tt as DevTools,ne as FormatSimple,Xe as LanguageDetector,k as LanguageDetectorError,Ge as LanguageStorage,N as LanguageStorageError,Se as ObserverPlugin,re as PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY,A as RecordFetchError,se as TOLGEE_ATTRIBUTE_NAME,ie as TOLGEE_RESTRICT_ATTRIBUTE,oe as TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE,et as Tolgee,M as TolgeeCore,w as createFetchFunction,h as getFallback,v as getFallbackArray,Fe as getProjectIdFromApiKey,_ as getTranslateProps}; | ||
//# sourceMappingURL=tolgee-web.production.esm.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@tolgee/web"]={})}(this,(function(e){"use strict";var t,n=Object.defineProperty,r=Object.defineProperties,a=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,l=(e,t,r)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,c=(e,t)=>{for(var n in t||(t={}))i.call(t,n)&&l(e,n,t[n]);if(o)for(var n of o(t))s.call(t,n)&&l(e,n,t[n]);return e},u=(e,t)=>r(e,a(t));function g(e,t){for(var n=0;n<t.length;n++){const r=t[n];if("string"!=typeof r&&!Array.isArray(r))for(const t in r)if("default"!==t&&!(t in e)){const n=Object.getOwnPropertyDescriptor(r,t);n&&Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function d(e){return Boolean(e&&"function"==typeof e.then)}function f(e,t){return d(e)?Promise.resolve(e).then(t):t(e)}function p(e,t,n){function r(n){const r=t(n);throw e.emit(r),console.error(r),r}try{const e=n();return d(e)?e.catch(r):e}catch(e){r(e)}}function h(e){const t=(Array.isArray(e)?e:[e]).map((e=>`'${e}'`)),n=t.slice(-2).join(" or ");return`Tolgee: You need to specify ${[...t.slice(0,-2),n].join(", ")} option`}function v(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function m(e){return v(e)||[]}function y(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?m(t):m(null==t?void 0:t[e]);var n}function b(e){return Array.from(new Set(e))}function E(e){return e?e.replace(/\/+$/,""):e}const L=(e,t)=>fetch(e,t);const O=(e=L)=>(t,n)=>{let r=(a=null==n?void 0:n.headers,Object.fromEntries(new Headers(a).entries()));var a;return r["x-api-key"]&&(r=Object.assign({"x-tolgee-sdk-type":"JS","x-tolgee-sdk-version":"5.28.7"},r)),e(t,Object.assign(Object.assign({},n),{headers:r}))};function w(e){let t=[];return Object.freeze({listen(e){const n=t=>{e(t)};return t.push(n),{unsubscribe(){t=t.filter((e=>n!==e))}}},emit(n){e()&&t.forEach((e=>e({value:n})))}})}function A(e,t,n){const r=new Set,a=new Set;let o=[];function i(){if(0===o.length)return;const e=o;o=[],r.forEach((e=>{e({value:void 0})}));let n=new Set;e.forEach((e=>{void 0===e?n=void 0:void 0!==n&&e.forEach((e=>n.add(e)))}));!function(e){const n=new Set(t());a.forEach((t=>{(void 0===e||-1!==(null==e?void 0:e.findIndex((e=>n.has(e)||t.namespaces.has(e)))))&&t.fn({value:void 0})}))}(n?Array.from(n.keys()):void 0)}return Object.freeze({emit(t,n){e()&&(o.push(t),n?setTimeout(i,0):i())},listen(e){r.add(e);return{unsubscribe:()=>{r.delete(e)}}},listenSome(e){const t={fn:t=>{e(t)},namespaces:new Set};a.add(t);const r={unsubscribe:()=>{a.delete(t)},subscribeNs:e=>(m(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),r)};return r}})}class T extends Error{constructor(e,t,n=!1){const{language:r,namespace:a}=e;super(`Tolgee: Failed to fetch record for "${r}"${a&&` and "${a}"`}`),this.cause=t,this.isDev=n,this.name="RecordFetchError",this.language=r,this.namespace=a}}class k extends Error{constructor(e,t){super(e),this.cause=t,this.name="LanguageDetectorError"}}class N extends Error{constructor(e,t){super(e),this.cause=t,this.name="LanguageStorageError"}}const j=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):j(n).forEach(((n,r)=>{t.set(e+"."+r,n)})))})),t},R=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},x=({language:e,namespace:t})=>t?`${e}:${t}`:e;function P(e,t,n,r,a,o,i){const s=new Map,l=new Map;let c={},u=0;function g(t,n,r){const a=x(t);l.set(a,{data:j(n),version:r}),e.onCacheChange.emit(t)}async function f(r,a){let o;if(a)try{o=await n(r)}catch(t){const n=new T(r,t,!0);e.onError.emit(n),console.warn(n)}return o||(o=await async function(n){let r;const a=c[x(n)];return"function"==typeof a&&(r=a()),r||(r=t(n)),d(r)?null==r?void 0:r.catch((t=>{const r=new T(n,t);throw e.onError.emit(r),console.error(r),r})):r}(r)),o}const p=Object.freeze({addStaticData(e){e&&(c=Object.assign(Object.assign({},c),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=R(e),r=l.get(e);r&&0!==r.version||g(n,t,0)}})))},invalidate(){s.clear(),u+=1},addRecord(e,t){g(e,t,u)},exists(e,t=!1){const n=l.get(x(e));return n&&t?n.version===u:Boolean(n)},getRecord(e){var t;return null===(t=l.get(x(r(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=l.get(x(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var r;for(const a of e)for(const e of t){const t=null===(r=l.get(x({language:e,namespace:a})))||void 0===r?void 0:r.data.get(n);if(null!=t)return[a]}return b(e)},getTranslationFallback(e,t,n){var r;for(const a of e)for(const e of t){const t=null===(r=l.get(x({language:e,namespace:a})))||void 0===r?void 0:r.data.get(n);if(null!=t)return t}},changeTranslation(t,n,r){var a;const o=null===(a=l.get(x(t)))||void 0===a?void 0:a.data;null==o||o.set(n,r),e.onCacheChange.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(a())return!0;if(void 0===e)return s.size>0;const t=m(e);return Boolean(Array.from(s.keys()).find((e=>t.includes(R(e).namespace))))},isLoading(e,t){const n=m(t);return Boolean(a()||Array.from(s.keys()).find((t=>{const r=R(t);return(!n.length||n.includes(r.namespace))&&!p.exists({namespace:r.namespace,language:e})})))},async loadRecords(e,t){const n=e.map((e=>{const n=r(e),a=x(n),o=s.get(a);if(o)return{new:!1,promise:o,keyObject:n,cacheKey:a};const i=f(n,t)||Promise.resolve(void 0);return s.set(a,i),{new:!0,promise:i,keyObject:n,cacheKey:a}}));o.notify(),i.notify();const a=await Promise.all(n.map((e=>e.promise)));return n.forEach(((e,t)=>{const n=s.get(e.cacheKey)!==e.promise;if(e.new&&!n){s.delete(e.cacheKey);const n=a[t];n?p.addRecord(e.keyObject,n):p.getRecord(e.keyObject)||p.addRecord(e.keyObject,{})}})),o.notify(),i.notify(),n.map((e=>p.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(l.entries()).map((([e,t])=>Object.assign(Object.assign({},R(e)),{data:t.data})))});return p}function C(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]])}return n}const S="invalid",D={defaultNs:"",observerOptions:{tagAttributes:{textarea:["placeholder"],input:["value","placeholder"],img:["alt"],"*":["aria-label","title"]},restrictedElements:["script","style"],highlightKeys:["Alt"],highlightColor:"rgb(255, 0, 0)",highlightWidth:5,inputPrefix:"%-%tolgee:",inputSuffix:"%-%",passToParent:["option","optgroup"],fullKeyEncode:!1},observerType:"invisible",onFormatError:S,apiUrl:"https://app.tolgee.io",fetch:O(),onTranslationMissing:({key:e})=>e},_=(...e)=>{let t={};return e.forEach((e=>{t=Object.assign(Object.assign(Object.assign({},t),e),{observerOptions:Object.assign(Object.assign({},t.observerOptions),null==e?void 0:e.observerOptions)})})),t};function I(e,t){const n=_(D,null==t?void 0:t.initialOptions,e);return n.apiUrl=E(n.apiUrl),(null==e?void 0:e.fetch)&&(n.fetch=O(e.fetch)),{initialOptions:n,activeNamespaces:(null==t?void 0:t.activeNamespaces)||new Map,language:null==t?void 0:t.language,pendingLanguage:null==t?void 0:t.language,isInitialLoading:!1,isRunning:!1}}function F(e,t,n,r,a,o,i,s){const l={ui:void 0},c={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},u=async({keysAndDefaults:e,target:t})=>{var n;const i=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,fallbackNamespaces:r(t),namespace:a({key:e,ns:t})[0],translation:o({key:e,ns:t})})));null===(n=c.ui)||void 0===n||n.handleElementClick(i,t)},g=(e,t)=>{var n;return(null===(n=c.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function d(e){const t=o({key:e.key,ns:e.ns});return j.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function h(){return{fetch:t().fetch}}function v(e){c.observer=null==e?void 0:e()}function m(){return Boolean(c.observer)}function y(e){e&&c.formatters.push(e)}function b(e){c.finalFormatter=e}function E(e){l.ui=e}function L(){return Boolean(l.ui)}function O(e){c.languageStorage=e}function w(e){c.languageDetector=e}function A(e){e&&c.backends.push(e)}function T(e){c.devBackend=e}const j=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:b,addFormatter:y,setObserver:v,hasObserver:m,setUi:E,hasUi:L,setDevBackend:T,addBackend:A,setLanguageDetector:w,setLanguageStorage:O}))},findPositions:g,run(){var e,n;const{apiKey:r,apiUrl:a,projectId:o,observerOptions:f,tagNewKeys:p}=t();c.ui=null===(e=l.ui)||void 0===e?void 0:e.call(l,{apiKey:r,apiUrl:a,projectId:o,highlight:j.highlight,changeTranslation:i,findPositions:g,onPermanentChange:e=>s.onPermanentChange.emit(e),tagNewKeys:p}),null===(n=c.observer)||void 0===n||n.run({mouseHighlight:!0,options:f,translate:d,onClick:u})},stop(){var e;c.ui=void 0,null===(e=c.observer)||void 0===e||e.stop()},getLanguageStorage:()=>c.languageStorage,getInitialLanguage(){const e=n();return f(p(s.onError,(e=>new N("Tolgee: Failed to load language",e)),(()=>{var e;return null===(e=c.languageStorage)||void 0===e?void 0:e.getLanguage(h())})),(t=>e&&!e.includes(t)||!t?function(){if(!c.languageDetector)return;const e=n();return p(s.onError,(e=>new k("Tolgee: Failed to detect language",e)),(()=>{var t;return null===(t=c.languageDetector)||void 0===t?void 0:t.getLanguage(Object.assign({availableLanguages:e},h()))}))}():t))},setStoredLanguage:e=>p(s.onError,(e=>new N("Tolgee: Failed to store language",e)),(()=>{var t;return null===(t=c.languageStorage)||void 0===t?void 0:t.setLanguage(e,h())})),getDevBackend:()=>c.devBackend,getBackendRecord:async({language:e,namespace:t})=>{for(const n of c.backends){const r=await n.getRecord(Object.assign({language:e,namespace:t},h()));if(void 0!==r)return r}},getBackendDevRecord:async({language:e,namespace:n})=>{var r;const{apiKey:a,apiUrl:o,projectId:i}=t();return null===(r=c.devBackend)||void 0===r?void 0:r.getRecord(Object.assign({apiKey:a,apiUrl:o,projectId:i,language:e,namespace:n},h()))},getLanguageDetector:()=>c.languageDetector,retranslate(){var e;null===(e=c.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,r;return(null===(r=null===(n=c.observer)||void 0===n?void 0:n.highlight)||void 0===r?void 0:r.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return c.observer?null===(t=c.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return c.observer?null===(t=c.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(j.getDevBackend()),formatTranslation(n){var r,{formatEnabled:a}=n,o=C(n,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:u,params:g,ns:d,orEmpty:f}=o,p=null!=s?s:l;let h="";null==s&&(h=t().onTranslationMissing(o));let v=null!=p?p:f?"":h;const m=e(),y=a||!(null===(r=c.observer)||void 0===r?void 0:r.outputNotFormattable),b=e=>c.observer&&!u?c.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:d}):e;v=b(v);try{if(p&&m&&y)for(const e of c.formatters)v=e.format({translation:v,language:m,params:g});c.finalFormatter&&p&&m&&y&&(v=c.finalFormatter.format({translation:v,language:m,params:g}))}catch(e){console.error(e);const n=("string"==typeof(E=e)?E:"string"==typeof(null==E?void 0:E.message)?E.message:void 0)||S,r=t().onFormatError,a=typeof r;v="string"===a?r:"function"===a?r(n,o):S,v=b(v)}var E;return v}});return j}const U=(e,t,n)=>{let r=e;return Object.freeze({init(e){r=e},notify(){const e=t();r!==e&&n(e),r=e}})};const $=(e,...t)=>{let n,r={};return"object"==typeof e?r=e:(r.key=e,"string"==typeof t[0]?(r.defaultValue=t[0],n=t[1]):"object"==typeof t[0]&&(n=t[0])),n&&(r=Object.assign(Object.assign({},function(e){var{ns:t,noWrap:n,orEmpty:r,params:a,language:o}=e,i=C(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:r,language:o};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),r)),r};function M({options:e}){const t=function(e,t){let n=!0;function r(){return n}const a=Object.freeze({onPendingLanguageChange:w(r),onLanguageChange:w(r),onLoadingChange:w(r),onFetchingChange:w(r),onInitialLoaded:w(r),onRunningChange:w(r),onCacheChange:w(r),onUpdate:A(r,e,t),onPermanentChange:w(r),onError:w(r),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return a.onPendingLanguageChange.listen(t);case"language":return a.onLanguageChange.listen(t);case"loading":return a.onLoadingChange.listen(t);case"fetching":return a.onFetchingChange.listen(t);case"initialLoad":return a.onInitialLoaded.listen(t);case"running":return a.onRunningChange.listen(t);case"cache":return a.onCacheChange.listen(t);case"update":return a.onUpdate.listen(t);case"permanentChange":return a.onPermanentChange.listen(t);case"error":return a.onError.listen(t)}}});return a.onInitialLoaded.listen((()=>a.onUpdate.emit())),a.onLanguageChange.listen((()=>a.onUpdate.emit())),a.onCacheChange.listen((({value:e})=>a.onUpdate.emit([e.namespace],!0))),a}(l,c),n=U(!1,(()=>i.isFetching()),t.onFetchingChange.emit),r=U(!1,(()=>j.isLoading()),t.onLoadingChange.emit),a=function(e,t,n){let r,a=I();const o=Object.freeze({init(e){a=I(e,a)},isRunning:()=>a.isRunning,setRunning(e){a.isRunning!==e&&(a.isRunning=e,n.emit(e))},isInitialLoading:()=>a.isInitialLoading,setInitialLoading(e){a.isInitialLoading=e},getLanguage:()=>a.language||a.initialOptions.language,setLanguage(t){a.language!==t&&(a.language=t,e.emit(t))},getPendingLanguage:()=>a.pendingLanguage||o.getLanguage(),setPendingLanguage(e){a.pendingLanguage!==e&&(a.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},a.initialOptions),r),addActiveNs(e){m(e).forEach((e=>{const t=a.activeNamespaces.get(e);void 0!==t?a.activeNamespaces.set(e,t+1):a.activeNamespaces.set(e,1)}))},removeActiveNs(e){m(e).forEach((e=>{const t=a.activeNamespaces.get(e);void 0!==t&&t>1?a.activeNamespaces.set(e,t-1):a.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>b([...a.initialOptions.ns||[a.initialOptions.defaultNs],...m(a.initialOptions.fallbackNs),...a.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||o.getLanguage();return t?b([t,...y(t,a.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>m(a.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?a.initialOptions.defaultNs:e,getAvailableLanguages(){if(a.initialOptions.availableLanguages)return a.initialOptions.availableLanguages;if(a.initialOptions.staticData){const e=Object.keys(a.initialOptions.staticData).map((e=>R(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?o.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){r=e?Object.assign(Object.assign({},e),{apiUrl:E(e.apiUrl)}):void 0}});return o}(t.onLanguageChange,t.onPendingLanguageChange,t.onRunningChange),o=F(a.getLanguage,a.getInitialOptions,a.getAvailableLanguages,u,T,k,p,t),i=P(t,o.getBackendRecord,o.getBackendDevRecord,a.withDefaultNs,a.isInitialLoading,n,r);let s;function l(){return a.getFallbackNs()}function c(e){return a.getDefaultNs(e)}function u(e){return[...m(c(e)),...l()]}function g(e){return[...m(null!=e?e:c()),...a.getRequiredNamespaces()]}function p(e,t,n){const r=a.withDefaultNs(e),o=i.getTranslation(r,t);return i.changeTranslation(r,t,n),{revert(){i.changeTranslation(r,t,o)}}}function v(e){a.init(e),i.addStaticData(a.getInitialOptions().staticData)}function L(e,t){const n=a.getFallbackLangs(e),r=g(t),o=[];return n.forEach((e=>{r.forEach((t=>{i.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}function O(e,t){const n=L(e,t);if(n.length)return f(j.loadRecords(n),(()=>{}))}function T({key:e,ns:t}){const n=a.getFallbackLangs(),r=u(null!=t?t:void 0);return i.getTranslationNs(r,n,e)}function k({key:e,ns:t,language:n}){const r=u(null!=t?t:void 0),o=a.getFallbackLangs(n);return i.getTranslationFallback(r,o,e)}function N(){const e=f(function(){if(a.getLanguage())return;return f(o.getInitialLanguage(),(e=>{const t=e||a.getInitialOptions().defaultLanguage;t&&a.setLanguage(t)}))}(),(()=>O()));if(d(e))return a.setInitialLoading(!0),n.notify(),r.notify(),Promise.resolve(e).then((()=>{a.setInitialLoading(!1),n.notify(),r.notify(),t.onInitialLoaded.emit()}));t.onInitialLoaded.emit()}e&&v(e),t.onUpdate.listen((()=>{a.isRunning()&&o.retranslate()}));const j=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),a),o),i),{init:v,getTranslation:k,changeTranslation:p,getTranslationNs:T,getDefaultAndFallbackNs:u,findPositions:o.findPositions,getRequiredRecords:L,async changeLanguage(e){a.getPendingLanguage()===e&&a.getLanguage()===e||(a.setPendingLanguage(e),a.isRunning()&&await O(e),e===a.getPendingLanguage()&&(a.setLanguage(e),await o.setStoredLanguage(e)))},async addActiveNs(e,t){t||a.addActiveNs(e),a.isRunning()&&await O(void 0,e)},loadRecords:e=>i.loadRecords(e,j.isDev()),loadRecord:async e=>(await j.loadRecords([e]))[0],isLoading:e=>i.isLoading(a.getLanguage(),e),isLoaded(e){const t=a.getLanguage();if(!t)return!1;const n=a.getFallbackLangs(t),r=g(e),o=[];return n.forEach((e=>{r.forEach((t=>{i.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=$(...e),n=k(t);return o.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(a.getInitialOptions().apiKey&&a.getInitialOptions().apiUrl),run:()=>(function(){if((o.getLanguageDetector()||o.getLanguageStorage())&&!a.getAvailableLanguages())throw new Error(h("availableLanguages"));if(!a.getLanguage()&&!a.getInitialOptions().defaultLanguage)throw new Error(h(["defaultLanguage","language"]))}(),a.isRunning()||(a.setRunning(!0),o.run(),s=N()),Promise.resolve(s)),stop(){a.isRunning()&&(o.stop(),a.setRunning(!1))}}));return j}const B=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=_(e.options,n),t),init(t){const n=function(e){const t=M({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),t.isDev()&&t.invalidate(),n&&t.run()}t.isDev()&&t.invalidate();const r=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmitterActive:t.setEmitterActive,getLanguage:t.getLanguage,getPendingLanguage:t.getPendingLanguage,changeLanguage:t.changeLanguage,changeTranslation:t.changeTranslation,addActiveNs:t.addActiveNs,removeActiveNs:t.removeActiveNs,loadRecords:t.loadRecords,loadRecord:t.loadRecord,addStaticData:t.addStaticData,getRecord:t.getRecord,getAllRecords:t.getAllRecords,isLoaded:t.isLoaded,getRequiredRecords:t.getRequiredRecords,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,findPositions:t.findPositions,getInitialOptions:t.getInitialOptions,isDev:t.isDev,wrap:t.wrap,unwrap:t.unwrap,overrideCredentials(e){n((()=>t.overrideCredentials(e)))},addPlugin(e){e&&n((()=>t.addPlugin(r,e)))},updateOptions(e){e&&n((()=>t.init(e)))}});return r}(_(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},K=0,V=1,z=2;class W extends Error{constructor(e,t,n){let r;r=e===K?"Empty parameter":e===V?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${r} at ${t} in "${n}"`),this.code=e,this.index=t}}function G(e){return/\s/.test(e)}const Y=0,H=1,X=2,q=3,J=4,Z=new Set([X,H,Y]),Q="'",ee=new Set(["{","}",Q]),te=e=>/[0-9a-zA-Z_]/.test(e);function ne(e,t){const[n,r]=function(e){let t=Y,n="",r="",a="";const o=[],i=[];let s=0;function l(t){throw new W(t,s,e)}const c=()=>{o.push(n),n=""},u=()=>{""===r&&l(K),i.push(r),r=""};for(s=0;s<e.length;s++)switch(a=e[s],t){case Y:a===Q?(n+=a,t=H):"{"===a?(c(),t=q):(n+=a,t=Y);break;case H:ee.has(a)?(n=n.slice(0,-1)+a,t=X):(n+=a,t=Y);break;case X:a===Q?t=Y:(n+=a,t=X);break;case q:"}"===a?(u(),t=Y):G(a)?""!==r&&(u(),t=J):(te(a)||l(V),r+=a,t=q);break;case J:"}"==a?t=Y:G(a)?t=J:l(V)}return Z.has(t)||l(z),c(),[o,i]}(e),a=[n[0]];for(let o=1;o<n.length;o++){const i=null==t?void 0:t[r[o-1]];if(void 0===i)throw new Error(`Missing parameter "${r[o-1]}" in "${e}"`);a.push(String(i)),a.push(n[o])}return a.join("")}const re="__tolgee_dev_tools",ae="data-tolgee-key-only",oe="data-tolgee-restricted",ie="_tolgee",se="_tolgee-highlighter";function le(){var e,t;return void 0===(null==(t=null==(e=globalThis.window)?void 0:e.document)?void 0:t.createElement)}function ce(e){if(le())throw new Error(`${e}: Can't run on the server`)}function ue(e,t){return{oldTextContent:e,keys:t}}function ge(e){return e.textContent}function de(e,t){e.textContent=t}function fe(e,t){var n;const r=void 0===e.key||void 0===t.key||t.key===e.key,a=void 0===e.ns||void 0===t.ns||-1!==(null==(n=e.ns)?void 0:n.findIndex((e=>{var n;return null==(n=t.ns)?void 0:n.includes(e)})));return r&&a}const pe={position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function he({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,r){!function(n,r){r.highlight=()=>{if(!n.isConnected)return;const a=function(e){for(;e;){if(null!==e.getAttribute("disabled"))return!1;e=e.parentElement}return!0}(n);let o=r.highlightEl;o||(o=document.createElement("div"),o.classList.add(se),Object.entries(pe).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,r.highlightEl=o,document.body.appendChild(o));const i=n.getBoundingClientRect();o.style.pointerEvents=a?"none":"auto",o.style.borderWidth=t+"px",o.style.top=i.top-t+"px",o.style.left=i.left-t+"px",o.style.width=i.width+"px",o.style.height=i.height+"px"}}(n,r),function(e,t){t.unhighlight=()=>{var e;null==(e=t.highlightEl)||e.remove(),t.highlightEl=void 0}}(0,r)}})}const ve={capture:!0},me={capture:!0,passive:!0},ye=new Map([["Control","ctrlKey"],["Alt","altKey"],["Meta","metaKey"],["Shift","shiftKey"]]);function be({highlightKeys:e,elementStore:t,onClick:n,options:r}){var a,o;const i=new Set;let s,l,c=[];const u=(null==(a=r.targetElement)?void 0:a.getRootNode())||document,g=(null==(o=r.targetElement)?void 0:o.ownerDocument)||document;function d(){var e;const n=t.get(s);n&&(n.preventClean=!1,null==(e=n.unhighlight)||e.call(n),s=void 0)}function f(){const e=l;let n;if(e&&A()){n=function(e){for(const n of e){const e=w(n,(e=>t.get(e)));if(void 0!==e)return e||void 0}}(u.elementsFromPoint(e.x,e.y)||[])}!function(e){var n;if(s!==e){d();const r=t.get(e);r&&(r.preventClean=!0,null==(n=r.highlight)||n.call(r),s=e)}}(n)}function p(e){l=e,f()}function h(e){for(const[t,n]of ye.entries())i.has(t)&&!e[n]?i.delete(t):!i.has(t)&&e[n]&&i.add(t)}function v(e){var t;h(e),A()&&(t=e.target,!Boolean(w(t,(e=>e.id===re))))&&(e.stopPropagation(),e.preventDefault())}function m(e){h(e),p({x:e.clientX,y:e.clientY})}function y(e){h(e),f()}function b(e){h(e),f()}function E(){var e;const n=t.get(s);null==(e=null==n?void 0:n.highlight)||e.call(n)}function L(e){v(e),h(e),p({x:e.clientX,y:e.clientY}),A()&&s&&(n(s),d())}function O(e,t,n){g.addEventListener(e,t,n),c.push([e,t,n])}function w(e,t){return e.id===re?null:t(e)?e:(null==e?void 0:e.parentElement)?w(e.parentElement,t):void 0}function A(){for(const t of e)if(!i.has(t))return!1;return!0}return Object.freeze({stop(){!function(){for(const e of c)g.removeEventListener(...e);c=[]}()},run(){O("keydown",y,ve),O("keyup",b,ve),O("mousemove",m,me),O("scroll",E,me),O("click",L,ve),O("mouseenter",v,ve),O("mouseover",v,ve),O("mouseout",v,ve),O("mouseleave",v,ve),O("mousedown",v,ve),O("mouseup",v,ve)}})}function Ee(e,t,n){const r=he({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),a=be({highlightKeys:e.highlightKeys,elementStore:t,onClick(e){const r=t.get(e);n({target:e,keysAndDefaults:s(r)})},options:e});function o(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${oe}]`)}function i(e,n){var r;n.highlightEl&&(null==(r=n.unhighlight)||r.call(n)),e.removeAttribute(ie),t.remove(e)}function s(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({isRestricted:o,register(e,n,a){if(o(e))return;const i=e;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(ie,"true")),s.nodes.set(n,a),r.initHighlighter(i,s)},forEachElement:t.forEachElement,cleanupLingeringKeyAttributes(){t.forEachElement(((e,t)=>{if(!t.preventClean){for(const[e]of t.nodes)if(e.nodeType===Node.ATTRIBUTE_NODE){const n=e;n.name===ae&&null===n.ownerElement&&t.nodes.delete(n)}0===t.nodes.size&&i(e,t)}}))},cleanupRemovedNodes(e){t.forEachElement(((t,n)=>{n.preventClean||(e.has(t)||function(e,t){for(const[n]of e.nodes)t.has(n)&&e.nodes.delete(n)}(n,e),(e.has(t)||0===n.nodes.size)&&i(t,n))}))},findAll(e,n){const r=[];return t.forEachElement(((t,a)=>{for(const t of a.nodes.values()){if(t.keys.find((t=>fe({key:e,ns:v(n)},{key:t.key,ns:v(t.ns)})))){r.push(a);break}}})),r},run(e){e&&a.run()},stop(){a.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null==(n=t.unhighlight)||n.call(t))}))}})}function Le(){let e,t=!1;const n=function(){const e=new Map;return Object.freeze({set(t,n){e.set(t,n)},get:t=>t&&e.get(t),remove:t=>e.delete(t),forEachElement(t){e.forEach(((e,n)=>t(n,e)))}})}();function r({mouseHighlight:e,options:r,wrapper:a,onClick:o}){if(le())return{stop(){t=!1},wrapper:a};const i=function(e){const t=Object.freeze({getSuitableParent(n){const r=function(e){return e.parentElement?e.parentElement:e.ownerElement&&e.ownerElement||void 0}(n);if(void 0===r)throw console.error(n),new Error("No suitable parent found for node above.");if(!e.passToParent)return r;if(Array.isArray(e.passToParent)){const t=e=>r.tagName.toLowerCase()===e.toLowerCase();if(-1===e.passToParent.findIndex(t))return r}return"function"!=typeof e.passToParent||e.passToParent(r)?t.getSuitableParent(r):r}});return t}(r),s=function(e,t){const n=Object.freeze({handleAttributes(n,r=!0){var a,o;const i=[],s=Object.fromEntries(Object.entries(e.tagAttributes).map((([e,t])=>[e.toUpperCase(),t])));if(n.nodeType===Node.ELEMENT_NODE){const e=n;let r=null!=(a=s[e.tagName.toUpperCase()])?a:[];"*"in s&&(r=r.concat(s["*"])),i.push(...r.filter((t=>e.hasAttribute(t))).map((t=>e.getAttributeNode(t))).filter((e=>t.testAttribute(e))))}if(r){const e=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,(e=>{var t,n;return(null==(t=s[e.tagName.toUpperCase()])?void 0:t.some((t=>e.hasAttribute(t))))||(null==(n=s["*"])?void 0:n.some((t=>e.hasAttribute(t))))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}));for(;e.nextNode();){const n=e.currentNode;let r=null!=(o=s[n.tagName.toUpperCase()])?o:[];"*"in s&&(r=r.concat(s["*"])),i.push(...r.filter((e=>n.hasAttribute(e))).map((e=>n.getAttributeNode(e))).filter((e=>t.testAttribute(e))))}}return i},handleChildList(e){const t=[];return t.push(...e.flatMap((e=>n.handleAttributes(e,!0)))),t.push(...e.flatMap((e=>n.handleText(e)))),t},handleText(e){if(e.nodeType===Node.TEXT_NODE)return t.testTextNode(e)?[e]:[];const n=[],r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,(e=>t.testTextNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;r.nextNode();)n.push(r.currentNode);return n}});return n}(r,a),l=Ee(r,n,o);function c(e){for(const t of e){const e=t.parentElement;if(e&&l.isRestricted(e))continue;const n=ge(t),r=n?a.unwrap(n):null;if(r){const{text:e,keys:a}=r;de(t,e);const o=ue(n,a),s=i.getSuitableParent(t);l.register(s,t,o)}}}function u(e){const t=i.getSuitableParent(e);l.register(t,e,{oldTextContent:"",keys:[{key:ge(e)}],keyAttributeOnly:!0})}function g(e,t){if(e.nodeType===Node.ATTRIBUTE_NODE){const t=e;if(t.name===ae)return void u(t)}if(e.nodeType===Node.ELEMENT_NODE){const t=e.getAttributeNode(ae);t&&u(t)}if(!t)return;const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,(e=>e.hasAttribute(ae)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;n.nextNode();){u(n.currentNode.getAttributeNode(ae))}}const d=new MutationObserver((e=>{if(!t)return;const n=e.filter((e=>"childList"===e.type)).flatMap((e=>Array.from(e.removedNodes))),r=new Set(n);for(const e of n){if(e.nodeType===Node.ELEMENT_NODE)for(let t=0;t<e.attributes.length;t++)r.add(e.attributes[t]);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);for(;t.nextNode();){const e=t.currentNode;if(e.nodeType===Node.ELEMENT_NODE){const t=e;for(let e=0;e<t.attributes.length;e++)r.add(t.attributes[e])}r.add(e)}}r.size>0&&l.cleanupRemovedNodes(r),e.some((e=>"attributes"===e.type&&e.attributeName===ae))&&l.cleanupLingeringKeyAttributes();const a=new Set;for(const t of e)switch(t.type){case"characterData":s.handleText(t.target).forEach((e=>a.add(e)));break;case"childList":g(t.target,!0),t.addedNodes.length>0&&s.handleChildList(Array.from(t.addedNodes)).forEach((e=>a.add(e))),t.removedNodes.length>0&&s.handleChildList(Array.from(t.removedNodes)).forEach((e=>a.delete(e)));break;case"attributes":t.attributeName===ae&&g(t.target,!1),s.handleAttributes(t.target,!1).forEach((e=>a.add(e)))}c([...a])})),f=r.targetElement||document;t=!0,l.run(e),g(f,!0),c(s.handleChildList([f]));const p=new Set;return p.add(ae),Object.values(r.tagAttributes).forEach((e=>e.forEach((e=>p.add(e.toLowerCase()))))),d.observe(f,{attributes:!0,attributeFilter:[...p],childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),d.disconnect()},elementRegistry:l,wrapper:a}}return Object.freeze({run(t){e=r(t)},stop(){null==e||e.stop()},forEachElement(t){var n,r;null==(r=null==(n=null==e?void 0:e.elementRegistry)?void 0:n.forEachElement)||r.call(n,t)},highlight(t,n){var r;const a=(null==(r=null==e?void 0:e.elementRegistry)?void 0:r.findAll(t,n))||[];return a.forEach((e=>{var t;return null==(t=e.highlight)?void 0:t.call(e)})),{unhighlight(){a.forEach((e=>{var t;return null==(t=e.unhighlight)?void 0:t.call(e)}))}}},findPositions(t,n){var r;const a=(null==(r=null==e?void 0:e.elementRegistry)?void 0:r.findAll(t,n))||[],o=[];return a.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),a.forEach((e=>{const r=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{fe({key:t,ns:v(n)},{key:e.key,ns:v(e.ns)})&&o.push({position:{x:r.x,y:r.y,width:r.width,height:r.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),o},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}var Oe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},we={};!function(e){function t(e){for(var t=0,n=Math.min(65536,e.length+1),r=new Uint16Array(n),a=[],o=0;;){var i=t<e.length;if(!i||o>=n-1){var s=r.subarray(0,o);if(a.push(String.fromCharCode.apply(null,s)),!i)return a.join("");e=e.subarray(t),t=0,o=0}var l=e[t++];if(0==(128&l))r[o++]=l;else if(192==(224&l)){var c=63&e[t++];r[o++]=(31&l)<<6|c}else if(224==(240&l)){c=63&e[t++];var u=63&e[t++];r[o++]=(31&l)<<12|c<<6|u}else if(240==(248&l)){var g=(7&l)<<18|(c=63&e[t++])<<12|(u=63&e[t++])<<6|63&e[t++];g>65535&&(g-=65536,r[o++]=g>>>10&1023|55296,g=56320|1023&g),r[o++]=g}}}var n="Failed to ",r=function(e,t,r){if(e)throw new Error("".concat(n).concat(t,": the '").concat(r,"' option is unsupported."))},a="function"==typeof Buffer&&Buffer.from,o=a?function(e){return Buffer.from(e)}:function(e){for(var t=0,n=e.length,r=0,a=Math.max(32,n+(n>>>1)+7),o=new Uint8Array(a>>>3<<3);t<n;){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319){if(t<n){var s=e.charCodeAt(t);56320==(64512&s)&&(++t,i=((1023&i)<<10)+(1023&s)+65536)}if(i>=55296&&i<=56319)continue}if(r+4>o.length){a+=8,a=(a*=1+t/e.length*2)>>>3<<3;var l=new Uint8Array(a);l.set(o),o=l}if(0!=(4294967168&i)){if(0==(4294965248&i))o[r++]=i>>>6&31|192;else if(0==(4294901760&i))o[r++]=i>>>12&15|224,o[r++]=i>>>6&63|128;else{if(0!=(4292870144&i))continue;o[r++]=i>>>18&7|240,o[r++]=i>>>12&63|128,o[r++]=i>>>6&63|128}o[r++]=63&i|128}else o[r++]=i}return o.slice?o.slice(0,r):o.subarray(0,r)};function i(){this.encoding="utf-8"}i.prototype.encode=function(e,t){return r(t&&t.stream,"encode","stream"),o(e)};var s=!a&&"function"==typeof Blob&&"function"==typeof URL&&"function"==typeof URL.createObjectURL,l=["utf-8","utf8","unicode-1-1-utf-8"],c=t;a?c=function(e,t){return(e instanceof Buffer?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)).toString(t)}:s&&(c=function(e){try{return function(e){var t;try{var n=new Blob([e],{type:"text/plain;charset=UTF-8"});t=URL.createObjectURL(n);var r=new XMLHttpRequest;return r.open("GET",t,!1),r.send(),r.responseText}finally{t&&URL.revokeObjectURL(t)}}(e)}catch(n){return t(e)}});var u="construct 'TextDecoder'",g="".concat(n," ").concat(u,": the ");function d(e,t){if(r(t&&t.fatal,u,"fatal"),e=e||"utf-8",!(a?Buffer.isEncoding(e):-1!==l.indexOf(e.toLowerCase())))throw new RangeError("".concat(g," encoding label provided ('").concat(e,"') is invalid."));this.encoding=e,this.fatal=!1,this.ignoreBOM=!1}d.prototype.decode=function(e,t){var n;return r(t&&t.stream,"decode","stream"),n=e instanceof Uint8Array?e:e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer):new Uint8Array(e),c(n,this.encoding)},e.TextEncoder=e.TextEncoder||i,e.TextDecoder=e.TextDecoder||d}("undefined"!=typeof window?window:Oe);const Ae=g({__proto__:null,default:we},[we]);null==(t=console.assert)||t.call(console,Ae);const Te=["",""],ke=RegExp(`([${Te.join("")}]{9})+`,"gu");function Ne(e){const t=function(e){return Array.from((new TextEncoder).encode(e))}(e).map(Number),n=t.map((e=>function(e){const t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0")).join("");return Array.from(n).map((e=>Te[Number(e)])).join("")}function je(e){const t=Array.from(e).map((e=>Te.indexOf(e))).map(String).join("").match(/(.{9})/g),n=Uint8Array.from((null==t?void 0:t.map((e=>parseInt(e.slice(0,8),2))))||[]);return r=n,(new TextDecoder).decode(new Uint8Array(r));var r}function Re({fullKeyEncode:e}){const t=function(){const e=[];return Object.freeze({valueToNumber(t){let n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:t=>e[t]})}();function n(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}return Object.freeze({unwrap(e){const n=[],r=function(e){var t;const n=null==(t=e.match(ke))?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(je))||[]}(e);r.forEach((e=>{const r=function(e){if(e.length<=4){const[n]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(e);return t.numberToValue(n)}return e}(e),a=function(e){try{return JSON.parse(e||"{}")}catch(e){return void console.error(e)}}(r);if(a){const{k:e,d:t,n:r}=a;n.push({key:e,defaultValue:t,ns:r})}}));const a=function(e){return e.replace(ke,"")}(e);return{text:a,keys:n}},wrap({key:r,defaultValue:a,translation:o,ns:i}){let s;if(e){s=Ne(n({key:r,ns:i}))}else{const e=n({key:r,ns:i,defaultValue:a}),o=t.valueToNumber(e);s=Ne(String.fromCodePoint(o))}const l=o||"";return"string"==typeof l?l+s:l},testTextNode(e){var t,n,r;return null!=(r=(null==(t=e.textContent)?void 0:t.includes(`${Te[0]}${Te[0]}`))||(null==(n=e.textContent)?void 0:n.includes(`${Te[1]}${Te[0]}`)))&&r},testAttribute:e=>e.value.includes(`${Te[0]}${Te[0]}`)||e.value.includes(`${Te[1]}${Te[0]}`)})}function xe(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function Pe({inputPrefix:e,inputSuffix:t,translate:n}){function r(e){const{key:t,params:r,defaultValue:a,ns:o}=function(e){let t=!1,n="",r="",a="KEY";const o={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{o.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==a||","!==s?"KEY"!==a||"|"!==s?"NAMESPACE"!==a||","!==s?"KEY"!==a||":"!==s?"DEFAULT_VALUE"!==a||":"!==s?"PARAM_NAME"!==a||":"!==s?"PARAM_VALUE"!==a||","!==s?n+=s:(a="PARAM_NAME",o.params[r]=n,n=""):(a="PARAM_VALUE",r=n,n=""):(a="PARAM_NAME",o.defaultValue=n,n=""):(a="PARAM_NAME",o.key=n,n=""):(a="DEFAULT_VALUE",i(n),n=""):(a="NAMESPACE",o.key=n,n=""):(a="DEFAULT_VALUE",o.key=n,n=""):t=!0;return"KEY"===a&&(o.key=n),"DEFAULT_VALUE"===a&&(o.defaultValue=n),"PARAM_VALUE"===a&&(o.params[r]=n),"NAMESPACE"===a&&i(n),o}(e);return{translated:n({key:t,params:r,defaultValue:a,ns:o,noWrap:!0}),key:t,params:r,defaultValue:a,ns:o}}function a(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function o(e){return"string"==typeof e?e.replace(new RegExp("[,:|\\\\]","gs"),"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(`Parameters of type "${typeof e}" are not supported in "text" wrapper mode.`),e)}return Object.freeze({wrap({key:n,params:r,defaultValue:a,ns:i}){let s=Object.entries(r||{}).map((([e,t])=>`${o(e)}:${o(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==a?`,${o(a)}`:"",c="string"==typeof i?[i]:i,u=(null==c?void 0:c.length)?`|${c.map((e=>o(e))).join("|")}`:"";return`${e}${o(n)}${u}${l}${s}${t}`},unwrap(n){const o=new RegExp(`(\\\\?)(${a(e)}(.*?)${a(t)})`,"gs"),i=[];let s,l=!1,c=0,u="";for(;null!==(s=o.exec(n));){let e=s[1];const[t,a,o,g]=s,{index:d,input:f}=s;if(u+=f.substr(c,d-c),c=d+t.length,"\\"===e){if(!xe(d,n)){u+=o;continue}e=""}const p=r(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,u+=e+p.translated}return u+=n.substring(c),l?{text:u,keys:i}:{text:n,keys:[]}},testTextNode(n){var r,a,o;return null!=(o=(null==(r=n.textContent)?void 0:r.includes(e))&&(null==(a=n.textContent)?void 0:a.includes(t)))&&o},testAttribute:n=>n.value.includes(e)&&n.value.includes(t)})}const Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Se(e){const t=Ce.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function De(e){const t=(e=e.toUpperCase()).length;let n=0,r=0,a=0;const o=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)r=r<<5|Se(e[i]),n+=5,n>=8&&(o[a++]=r>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let r="",a=Math.pow(2,16)-1;for(let e=0;e<n;e+=a)e+a>n&&(a=n-e),r+=String.fromCharCode.apply(null,t.subarray(e,e+a));return r}(o.buffer)}function _e(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=De(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}function Ie({message:e,recievingMessage:t,data:n,attempts:r=1,timeout:a=300}){let o=!1;const i=()=>new Promise(((r,o)=>{const i=function(e,t){const n=n=>{var r,a;e.includes(null==(r=n.data)?void 0:r.type)&&t(null==(a=n.data)?void 0:a.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(s),l(),r(e)}));window.postMessage({type:e,data:n},window.origin);const s=setTimeout((function(){l(),o()}),a);function l(){i.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<r;e++){if(o)return new Promise((()=>{}));try{return await i()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}let Fe=null;function Ue(e){var t;return Fe||(Fe=(t=`https://cdn.jsdelivr.net/npm/@tolgee/web@${e}/dist/tolgee-in-context-tools.umd.min.js`,new Promise(((e,n)=>{const r=document.createElement("script");r.src=t,r.addEventListener("load",(()=>e())),r.addEventListener("error",(e=>n(e.error))),document.head.appendChild(r)}))).then((()=>window["@tolgee/in-context-tools"].InContextTools))),Fe}const $e="__tolgee_apiKey",Me="__tolgee_apiUrl";function Be(){const e=sessionStorage.getItem($e)||void 0,t=sessionStorage.getItem(Me)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Ke(){sessionStorage.removeItem($e),sessionStorage.removeItem(Me)}e.BrowserExtensionPlugin=()=>e=>e;(()=>{if("undefined"==typeof window)return!1;try{return"undefined"!=typeof sessionStorage&&sessionStorage}catch(e){return console.error("sessionStorage not available",e),!1}})()&&(e.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:r}=Ie({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:t,attempts:4});return e=n,r}}}();e.on("running",(({value:n})=>{var r;n&&(r=()=>{t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(Ke)},"loading"!==document.readyState?Promise.resolve().then((()=>{r()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",r))}));return Be()&&(async()=>{const e=await Ue("5.28.7");return t=>{const n=Be();return t.addPlugin(e({credentials:n})),t}})().then((t=>{e.addPlugin(t)})).catch((e=>{console.error("Tolgee: Failed to load in-context tools"),console.error(e)})),e});const Ve="__tolgee_currentLanguage";function ze(e){return e.endsWith("/")?e.slice(0,-1):e}const We={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${ze(n)}/${e}/${t}.json`:`${ze(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Ge(e){const t=u(c(c({},We),e),{headers:c(c({},We.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:r,getData:a,headers:l}=t,g=((e,t)=>{var n={};for(var r in e)i.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&o)for(var r of o(e))t.indexOf(r)<0&&s.call(e,r)&&(n[r]=e[r]);return n})(t,["prefix","getPath","getData","headers"]);return{getRecord:({namespace:e,language:t,fetch:o})=>o(r({namespace:e,language:t,prefix:n}),c({headers:l},g)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return a(e)}))}}e.BackendFetch=e=>(t,n)=>(n.addBackend(Ge(e)),t),e.DEVTOOLS_ID=re,e.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:r,projectId:a,fetch:o}){var i;const s=null!=(i=_e(t))?i:a;let l=void 0!==s?`${e}/v2/projects/${s}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(r&&(l+=`?ns=${r}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===a)throw new Error("You need to specify 'projectId' when using PAT key");return o(l,{headers:{"X-API-Key":t||"","Content-Type":"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>e[n]));throw new Error(e.statusText)}))}}),e),e.DevTools=()=>e=>e,e.FormatSimple=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>ne(e,t)}),e),e.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){ce("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const r=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),a=r(window.navigator.language);return e.find((e=>r(e)===a))||void 0}}),e),e.LanguageDetectorError=k,e.LanguageStorage=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(ce("LanguageStorage"),localStorage.getItem(Ve)||void 0),setLanguage(e){ce("LanguageStorage"),localStorage.setItem(Ve,e)}}),e),e.LanguageStorageError=N,e.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=Le();return Object.freeze(u(c({},e),{run(t){const n=Pe({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(u(c({},t),{wrapper:n}))},retranslate(){e.forEachElement(((t,n)=>{for(const[t,r]of n.nodes.entries()){if(r.keyAttributeOnly)return;const n=e.unwrap(r.oldTextContent);n&&de(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=Le();return Object.freeze(u(c({},e),{run(t){const n=Re({fullKeyEncode:t.options.fullKeyEncode});e.run(u(c({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),e.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",e.RecordFetchError=T,e.TOLGEE_ATTRIBUTE_NAME=ie,e.TOLGEE_RESTRICT_ATTRIBUTE=oe,e.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=ae,e.Tolgee=function(){return B().use(e.BrowserExtensionPlugin())},e.TolgeeCore=B,e.createFetchFunction=O,e.getFallback=v,e.getFallbackArray=m,e.getProjectIdFromApiKey=_e,e.getTranslateProps=$,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@tolgee/web"]={})}(this,(function(e){"use strict";var t,n=Object.defineProperty,r=Object.defineProperties,a=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,l=(e,t,r)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,c=(e,t)=>{for(var n in t||(t={}))i.call(t,n)&&l(e,n,t[n]);if(o)for(var n of o(t))s.call(t,n)&&l(e,n,t[n]);return e},u=(e,t)=>r(e,a(t));function g(e,t){for(var n=0;n<t.length;n++){const r=t[n];if("string"!=typeof r&&!Array.isArray(r))for(const t in r)if("default"!==t&&!(t in e)){const n=Object.getOwnPropertyDescriptor(r,t);n&&Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function d(e){return Boolean(e&&"function"==typeof e.then)}function f(e,t){return d(e)?Promise.resolve(e).then(t):t(e)}function p(e,t,n){function r(n){const r=t(n);throw e.emit(r),console.error(r),r}try{const e=n();return d(e)?e.catch(r):e}catch(e){r(e)}}function h(e){const t=(Array.isArray(e)?e:[e]).map((e=>`'${e}'`)),n=t.slice(-2).join(" or ");return`Tolgee: You need to specify ${[...t.slice(0,-2),n].join(", ")} option`}function v(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function m(e){return v(e)||[]}function y(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?m(t):m(null==t?void 0:t[e]);var n}function b(e){return Array.from(new Set(e))}function E(e){return e?e.replace(/\/+$/,""):e}const L=(e,t)=>fetch(e,t);const O=(e=L)=>(t,n)=>{let r=(a=null==n?void 0:n.headers,Object.fromEntries(new Headers(a).entries()));var a;return r["x-api-key"]&&(r=Object.assign({"x-tolgee-sdk-type":"JS","x-tolgee-sdk-version":"5.29.0"},r)),e(t,Object.assign(Object.assign({},n),{headers:r}))};function w(e){let t=[];return Object.freeze({listen(e){const n=t=>{e(t)};return t.push(n),{unsubscribe(){t=t.filter((e=>n!==e))}}},emit(n){e()&&t.forEach((e=>e({value:n})))}})}function A(e,t,n){const r=new Set,a=new Set;let o=[];function i(){if(0===o.length)return;const e=o;o=[],r.forEach((e=>{e({value:void 0})}));let n=new Set;e.forEach((e=>{void 0===e?n=void 0:void 0!==n&&e.forEach((e=>n.add(e)))}));!function(e){const n=new Set(t());a.forEach((t=>{(void 0===e||-1!==(null==e?void 0:e.findIndex((e=>n.has(e)||t.namespaces.has(e)))))&&t.fn({value:void 0})}))}(n?Array.from(n.keys()):void 0)}return Object.freeze({emit(t,n){e()&&(o.push(t),n?setTimeout(i,0):i())},listen(e){r.add(e);return{unsubscribe:()=>{r.delete(e)}}},listenSome(e){const t={fn:t=>{e(t)},namespaces:new Set};a.add(t);const r={unsubscribe:()=>{a.delete(t)},subscribeNs:e=>(m(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),r)};return r}})}class T extends Error{constructor(e,t,n=!1){const{language:r,namespace:a}=e;super(`Tolgee: Failed to fetch record for "${r}"${a&&` and "${a}"`}`),this.cause=t,this.isDev=n,this.name="RecordFetchError",this.language=r,this.namespace=a}}class k extends Error{constructor(e,t){super(e),this.cause=t,this.name="LanguageDetectorError"}}class N extends Error{constructor(e,t){super(e),this.cause=t,this.name="LanguageStorageError"}}const j=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):j(n).forEach(((n,r)=>{t.set(e+"."+r,n)})))})),t},R=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},x=({language:e,namespace:t})=>t?`${e}:${t}`:e;function P(e,t,n,r,a,o,i){const s=new Map,l=new Map;let c={},u=0;function g(t,n,r){const a=x(t);l.set(a,{data:j(n),version:r}),e.onCacheChange.emit(t)}async function f(r,a){let o;if(a)try{o=await n(r)}catch(t){const n=new T(r,t,!0);e.onError.emit(n),console.warn(n)}return o||(o=await async function(n){let r;const a=c[x(n)];return"function"==typeof a&&(r=a()),r||(r=t(n)),d(r)?null==r?void 0:r.catch((t=>{const r=new T(n,t);throw e.onError.emit(r),console.error(r),r})):r}(r)),o}const p=Object.freeze({addStaticData(e){e&&(c=Object.assign(Object.assign({},c),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=R(e),r=l.get(e);r&&0!==r.version||g(n,t,0)}})))},invalidate(){s.clear(),u+=1},addRecord(e,t){g(e,t,u)},exists(e,t=!1){const n=l.get(x(e));return n&&t?n.version===u:Boolean(n)},getRecord(e){var t;return null===(t=l.get(x(r(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=l.get(x(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var r;for(const a of e)for(const e of t){const t=null===(r=l.get(x({language:e,namespace:a})))||void 0===r?void 0:r.data.get(n);if(null!=t)return[a]}return b(e)},getTranslationFallback(e,t,n){var r;for(const a of e)for(const e of t){const t=null===(r=l.get(x({language:e,namespace:a})))||void 0===r?void 0:r.data.get(n);if(null!=t)return t}},changeTranslation(t,n,r){var a;const o=null===(a=l.get(x(t)))||void 0===a?void 0:a.data;null==o||o.set(n,r),e.onCacheChange.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(a())return!0;if(void 0===e)return s.size>0;const t=m(e);return Boolean(Array.from(s.keys()).find((e=>t.includes(R(e).namespace))))},isLoading(e,t){const n=m(t);return Boolean(a()||Array.from(s.keys()).find((t=>{const r=R(t);return(!n.length||n.includes(r.namespace))&&!p.exists({namespace:r.namespace,language:e})})))},async loadRecords(e,t){const n=e.map((e=>{const n=r(e),a=x(n),o=s.get(a);if(o)return{new:!1,promise:o,keyObject:n,cacheKey:a};const i=f(n,t)||Promise.resolve(void 0);return s.set(a,i),{new:!0,promise:i,keyObject:n,cacheKey:a}}));o.notify(),i.notify();const a=await Promise.all(n.map((e=>e.promise)));return n.forEach(((e,t)=>{const n=s.get(e.cacheKey)!==e.promise;if(e.new&&!n){s.delete(e.cacheKey);const n=a[t];n?p.addRecord(e.keyObject,n):p.getRecord(e.keyObject)||p.addRecord(e.keyObject,{})}})),o.notify(),i.notify(),n.map((e=>p.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(l.entries()).map((([e,t])=>Object.assign(Object.assign({},R(e)),{data:t.data})))});return p}function C(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]])}return n}const S="invalid",D={defaultNs:"",observerOptions:{tagAttributes:{textarea:["placeholder"],input:["value","placeholder"],img:["alt"],"*":["aria-label","title"]},restrictedElements:["script","style"],highlightKeys:["Alt"],highlightColor:"rgb(255, 0, 0)",highlightWidth:5,inputPrefix:"%-%tolgee:",inputSuffix:"%-%",passToParent:["option","optgroup"],fullKeyEncode:!1},observerType:"invisible",onFormatError:S,apiUrl:"https://app.tolgee.io",fetch:O(),onTranslationMissing:({key:e})=>e},_=(...e)=>{let t={};return e.forEach((e=>{t=Object.assign(Object.assign(Object.assign({},t),e),{observerOptions:Object.assign(Object.assign({},t.observerOptions),null==e?void 0:e.observerOptions)})})),t};function I(e,t){const n=_(D,null==t?void 0:t.initialOptions,e);return n.apiUrl=E(n.apiUrl),(null==e?void 0:e.fetch)&&(n.fetch=O(e.fetch)),{initialOptions:n,activeNamespaces:(null==t?void 0:t.activeNamespaces)||new Map,language:null==t?void 0:t.language,pendingLanguage:null==t?void 0:t.language,isInitialLoading:!1,isRunning:!1}}function F(e,t,n,r,a,o,i,s){const l={ui:void 0},c={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},u=async({keysAndDefaults:e,target:t})=>{var n;const i=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,fallbackNamespaces:r(t),namespace:a({key:e,ns:t})[0],translation:o({key:e,ns:t})})));null===(n=c.ui)||void 0===n||n.handleElementClick(i,t)},g=(e,t)=>{var n;return(null===(n=c.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function d(e){const t=o({key:e.key,ns:e.ns});return j.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function h(){return{fetch:t().fetch}}function v(e){c.observer=null==e?void 0:e()}function m(){return Boolean(c.observer)}function y(e){e&&c.formatters.push(e)}function b(e){c.finalFormatter=e}function E(e){l.ui=e}function L(){return Boolean(l.ui)}function O(e){c.languageStorage=e}function w(e){c.languageDetector=e}function A(e){e&&c.backends.push(e)}function T(e){c.devBackend=e}const j=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:b,addFormatter:y,setObserver:v,hasObserver:m,setUi:E,hasUi:L,setDevBackend:T,addBackend:A,setLanguageDetector:w,setLanguageStorage:O}))},findPositions:g,run(){var e,n;const{apiKey:r,apiUrl:a,projectId:o,observerOptions:f,tagNewKeys:p}=t();c.ui=null===(e=l.ui)||void 0===e?void 0:e.call(l,{apiKey:r,apiUrl:a,projectId:o,highlight:j.highlight,changeTranslation:i,findPositions:g,onPermanentChange:e=>s.onPermanentChange.emit(e),tagNewKeys:p}),null===(n=c.observer)||void 0===n||n.run({mouseHighlight:!0,options:f,translate:d,onClick:u})},stop(){var e;c.ui=void 0,null===(e=c.observer)||void 0===e||e.stop()},getLanguageStorage:()=>c.languageStorage,getInitialLanguage(){const e=n();return f(p(s.onError,(e=>new N("Tolgee: Failed to load language",e)),(()=>{var e;return null===(e=c.languageStorage)||void 0===e?void 0:e.getLanguage(h())})),(t=>e&&!e.includes(t)||!t?function(){if(!c.languageDetector)return;const e=n();return p(s.onError,(e=>new k("Tolgee: Failed to detect language",e)),(()=>{var t;return null===(t=c.languageDetector)||void 0===t?void 0:t.getLanguage(Object.assign({availableLanguages:e},h()))}))}():t))},setStoredLanguage:e=>p(s.onError,(e=>new N("Tolgee: Failed to store language",e)),(()=>{var t;return null===(t=c.languageStorage)||void 0===t?void 0:t.setLanguage(e,h())})),getDevBackend:()=>c.devBackend,getBackendRecord:async({language:e,namespace:t})=>{for(const n of c.backends){const r=await n.getRecord(Object.assign({language:e,namespace:t},h()));if(void 0!==r)return r}},getBackendDevRecord:async({language:e,namespace:n})=>{var r;const{apiKey:a,apiUrl:o,projectId:i}=t();return null===(r=c.devBackend)||void 0===r?void 0:r.getRecord(Object.assign({apiKey:a,apiUrl:o,projectId:i,language:e,namespace:n},h()))},getLanguageDetector:()=>c.languageDetector,retranslate(){var e;null===(e=c.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,r;return(null===(r=null===(n=c.observer)||void 0===n?void 0:n.highlight)||void 0===r?void 0:r.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return c.observer?null===(t=c.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return c.observer?null===(t=c.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(j.getDevBackend()),formatTranslation(n){var r,{formatEnabled:a}=n,o=C(n,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:u,params:g,ns:d,orEmpty:f}=o,p=null!=s?s:l;let h="";null==s&&(h=t().onTranslationMissing(o));let v=null!=p?p:f?"":h;const m=e(),y=a||!(null===(r=c.observer)||void 0===r?void 0:r.outputNotFormattable),b=e=>c.observer&&!u?c.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:d}):e;v=b(v);try{if(p&&m&&y)for(const e of c.formatters)v=e.format({translation:v,language:m,params:g});c.finalFormatter&&p&&m&&y&&(v=c.finalFormatter.format({translation:v,language:m,params:g}))}catch(e){console.error(e);const n=("string"==typeof(E=e)?E:"string"==typeof(null==E?void 0:E.message)?E.message:void 0)||S,r=t().onFormatError,a=typeof r;v="string"===a?r:"function"===a?r(n,o):S,v=b(v)}var E;return v}});return j}const U=(e,t,n)=>{let r=e;return Object.freeze({init(e){r=e},notify(){const e=t();r!==e&&n(e),r=e}})};const $=(e,...t)=>{let n,r={};return"object"==typeof e?r=e:(r.key=e,"string"==typeof t[0]?(r.defaultValue=t[0],n=t[1]):"object"==typeof t[0]&&(n=t[0])),n&&(r=Object.assign(Object.assign({},function(e){var{ns:t,noWrap:n,orEmpty:r,params:a,language:o}=e,i=C(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:r,language:o};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),r)),r};function M({options:e}){const t=function(e,t){let n=!0;function r(){return n}const a=Object.freeze({onPendingLanguageChange:w(r),onLanguageChange:w(r),onLoadingChange:w(r),onFetchingChange:w(r),onInitialLoaded:w(r),onRunningChange:w(r),onCacheChange:w(r),onUpdate:A(r,e,t),onPermanentChange:w(r),onError:w(r),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return a.onPendingLanguageChange.listen(t);case"language":return a.onLanguageChange.listen(t);case"loading":return a.onLoadingChange.listen(t);case"fetching":return a.onFetchingChange.listen(t);case"initialLoad":return a.onInitialLoaded.listen(t);case"running":return a.onRunningChange.listen(t);case"cache":return a.onCacheChange.listen(t);case"update":return a.onUpdate.listen(t);case"permanentChange":return a.onPermanentChange.listen(t);case"error":return a.onError.listen(t)}}});return a.onInitialLoaded.listen((()=>a.onUpdate.emit())),a.onLanguageChange.listen((()=>a.onUpdate.emit())),a.onCacheChange.listen((({value:e})=>a.onUpdate.emit([e.namespace],!0))),a}(l,c),n=U(!1,(()=>i.isFetching()),t.onFetchingChange.emit),r=U(!1,(()=>j.isLoading()),t.onLoadingChange.emit),a=function(e,t,n){let r,a=I();const o=Object.freeze({init(e){a=I(e,a)},isRunning:()=>a.isRunning,setRunning(e){a.isRunning!==e&&(a.isRunning=e,n.emit(e))},isInitialLoading:()=>a.isInitialLoading,setInitialLoading(e){a.isInitialLoading=e},getLanguage:()=>a.language||a.initialOptions.language,setLanguage(t){a.language!==t&&(a.language=t,e.emit(t))},getPendingLanguage:()=>a.pendingLanguage||o.getLanguage(),setPendingLanguage(e){a.pendingLanguage!==e&&(a.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},a.initialOptions),r),addActiveNs(e){m(e).forEach((e=>{const t=a.activeNamespaces.get(e);void 0!==t?a.activeNamespaces.set(e,t+1):a.activeNamespaces.set(e,1)}))},removeActiveNs(e){m(e).forEach((e=>{const t=a.activeNamespaces.get(e);void 0!==t&&t>1?a.activeNamespaces.set(e,t-1):a.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>b([...a.initialOptions.ns||[a.initialOptions.defaultNs],...m(a.initialOptions.fallbackNs),...a.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||o.getLanguage();return t?b([t,...y(t,a.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>m(a.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?a.initialOptions.defaultNs:e,getAvailableLanguages(){if(a.initialOptions.availableLanguages)return a.initialOptions.availableLanguages;if(a.initialOptions.staticData){const e=Object.keys(a.initialOptions.staticData).map((e=>R(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?o.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){r=e?Object.assign(Object.assign({},e),{apiUrl:E(e.apiUrl)}):void 0}});return o}(t.onLanguageChange,t.onPendingLanguageChange,t.onRunningChange),o=F(a.getLanguage,a.getInitialOptions,a.getAvailableLanguages,u,T,k,p,t),i=P(t,o.getBackendRecord,o.getBackendDevRecord,a.withDefaultNs,a.isInitialLoading,n,r);let s;function l(){return a.getFallbackNs()}function c(e){return a.getDefaultNs(e)}function u(e){return[...m(c(e)),...l()]}function g(e){return[...m(null!=e?e:c()),...a.getRequiredNamespaces()]}function p(e,t,n){const r=a.withDefaultNs(e),o=i.getTranslation(r,t);return i.changeTranslation(r,t,n),{revert(){i.changeTranslation(r,t,o)}}}function v(e){a.init(e),i.addStaticData(a.getInitialOptions().staticData)}function L(e,t){const n=a.getFallbackLangs(e),r=g(t),o=[];return n.forEach((e=>{r.forEach((t=>{i.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}function O(e,t){const n=L(e,t);if(n.length)return f(j.loadRecords(n),(()=>{}))}function T({key:e,ns:t}){const n=a.getFallbackLangs(),r=u(null!=t?t:void 0);return i.getTranslationNs(r,n,e)}function k({key:e,ns:t,language:n}){const r=u(null!=t?t:void 0),o=a.getFallbackLangs(n);return i.getTranslationFallback(r,o,e)}function N(){const e=f(function(){if(a.getLanguage())return;return f(o.getInitialLanguage(),(e=>{const t=e||a.getInitialOptions().defaultLanguage;t&&a.setLanguage(t)}))}(),(()=>O()));if(d(e))return a.setInitialLoading(!0),n.notify(),r.notify(),Promise.resolve(e).then((()=>{a.setInitialLoading(!1),n.notify(),r.notify(),t.onInitialLoaded.emit()}));t.onInitialLoaded.emit()}e&&v(e),t.onUpdate.listen((()=>{a.isRunning()&&o.retranslate()}));const j=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),a),o),i),{init:v,getTranslation:k,changeTranslation:p,getTranslationNs:T,getDefaultAndFallbackNs:u,findPositions:o.findPositions,getRequiredRecords:L,async changeLanguage(e){a.getPendingLanguage()===e&&a.getLanguage()===e||(a.setPendingLanguage(e),a.isRunning()&&await O(e),e===a.getPendingLanguage()&&(a.setLanguage(e),await o.setStoredLanguage(e)))},async addActiveNs(e,t){t||a.addActiveNs(e),a.isRunning()&&await O(void 0,e)},loadRecords:e=>i.loadRecords(e,j.isDev()),loadRecord:async e=>(await j.loadRecords([e]))[0],isLoading:e=>i.isLoading(a.getLanguage(),e),isLoaded(e){const t=a.getLanguage();if(!t)return!1;const n=a.getFallbackLangs(t),r=g(e),o=[];return n.forEach((e=>{r.forEach((t=>{i.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=$(...e),n=k(t);return o.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(a.getInitialOptions().apiKey&&a.getInitialOptions().apiUrl),run:()=>(function(){if((o.getLanguageDetector()||o.getLanguageStorage())&&!a.getAvailableLanguages())throw new Error(h("availableLanguages"));if(!a.getLanguage()&&!a.getInitialOptions().defaultLanguage)throw new Error(h(["defaultLanguage","language"]))}(),a.isRunning()||(a.setRunning(!0),o.run(),s=N()),Promise.resolve(s)),stop(){a.isRunning()&&(o.stop(),a.setRunning(!1))}}));return j}const B=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=_(e.options,n),t),init(t){const n=function(e){const t=M({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),t.isDev()&&t.invalidate(),n&&t.run()}t.isDev()&&t.invalidate();const r=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmitterActive:t.setEmitterActive,getLanguage:t.getLanguage,getPendingLanguage:t.getPendingLanguage,changeLanguage:t.changeLanguage,changeTranslation:t.changeTranslation,addActiveNs:t.addActiveNs,removeActiveNs:t.removeActiveNs,loadRecords:t.loadRecords,loadRecord:t.loadRecord,addStaticData:t.addStaticData,getRecord:t.getRecord,getAllRecords:t.getAllRecords,isLoaded:t.isLoaded,getRequiredRecords:t.getRequiredRecords,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,findPositions:t.findPositions,getInitialOptions:t.getInitialOptions,isDev:t.isDev,wrap:t.wrap,unwrap:t.unwrap,overrideCredentials(e){n((()=>t.overrideCredentials(e)))},addPlugin(e){e&&n((()=>t.addPlugin(r,e)))},updateOptions(e){e&&n((()=>t.init(e)))}});return r}(_(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},K=0,V=1,z=2;class W extends Error{constructor(e,t,n){let r;r=e===K?"Empty parameter":e===V?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${r} at ${t} in "${n}"`),this.code=e,this.index=t}}function G(e){return/\s/.test(e)}const Y=0,H=1,X=2,q=3,J=4,Z=new Set([X,H,Y]),Q="'",ee=new Set(["{","}",Q]),te=e=>/[0-9a-zA-Z_]/.test(e);function ne(e,t){const[n,r]=function(e){let t=Y,n="",r="",a="";const o=[],i=[];let s=0;function l(t){throw new W(t,s,e)}const c=()=>{o.push(n),n=""},u=()=>{""===r&&l(K),i.push(r),r=""};for(s=0;s<e.length;s++)switch(a=e[s],t){case Y:a===Q?(n+=a,t=H):"{"===a?(c(),t=q):(n+=a,t=Y);break;case H:ee.has(a)?(n=n.slice(0,-1)+a,t=X):(n+=a,t=Y);break;case X:a===Q?t=Y:(n+=a,t=X);break;case q:"}"===a?(u(),t=Y):G(a)?""!==r&&(u(),t=J):(te(a)||l(V),r+=a,t=q);break;case J:"}"==a?t=Y:G(a)?t=J:l(V)}return Z.has(t)||l(z),c(),[o,i]}(e),a=[n[0]];for(let o=1;o<n.length;o++){const i=null==t?void 0:t[r[o-1]];if(void 0===i)throw new Error(`Missing parameter "${r[o-1]}" in "${e}"`);a.push(String(i)),a.push(n[o])}return a.join("")}const re="__tolgee_dev_tools",ae="data-tolgee-key-only",oe="data-tolgee-restricted",ie="_tolgee",se="_tolgee-highlighter";function le(){var e,t;return void 0===(null==(t=null==(e=globalThis.window)?void 0:e.document)?void 0:t.createElement)}function ce(e){if(le())throw new Error(`${e}: Can't run on the server`)}function ue(e,t){return{oldTextContent:e,keys:t}}function ge(e){return e.textContent}function de(e,t){e.textContent=t}function fe(e,t){var n;const r=void 0===e.key||void 0===t.key||t.key===e.key,a=void 0===e.ns||void 0===t.ns||-1!==(null==(n=e.ns)?void 0:n.findIndex((e=>{var n;return null==(n=t.ns)?void 0:n.includes(e)})));return r&&a}const pe={position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function he({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,r){!function(n,r){r.highlight=()=>{if(!n.isConnected)return;const a=function(e){for(;e;){if(null!==e.getAttribute("disabled"))return!1;e=e.parentElement}return!0}(n);let o=r.highlightEl;o||(o=document.createElement("div"),o.classList.add(se),Object.entries(pe).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,r.highlightEl=o,document.body.appendChild(o));const i=n.getBoundingClientRect();o.style.pointerEvents=a?"none":"auto",o.style.borderWidth=t+"px",o.style.top=i.top-t+"px",o.style.left=i.left-t+"px",o.style.width=i.width+"px",o.style.height=i.height+"px"}}(n,r),function(e,t){t.unhighlight=()=>{var e;null==(e=t.highlightEl)||e.remove(),t.highlightEl=void 0}}(0,r)}})}const ve={capture:!0},me={capture:!0,passive:!0},ye=new Map([["Control","ctrlKey"],["Alt","altKey"],["Meta","metaKey"],["Shift","shiftKey"]]);function be({highlightKeys:e,elementStore:t,onClick:n,options:r}){var a,o;const i=new Set;let s,l,c=[];const u=(null==(a=r.targetElement)?void 0:a.getRootNode())||document,g=(null==(o=r.targetElement)?void 0:o.ownerDocument)||document;function d(){var e;const n=t.get(s);n&&(n.preventClean=!1,null==(e=n.unhighlight)||e.call(n),s=void 0)}function f(){const e=l;let n;if(e&&A()){n=function(e){for(const n of e){const e=w(n,(e=>t.get(e)));if(void 0!==e)return e||void 0}}(u.elementsFromPoint(e.x,e.y)||[])}!function(e){var n;if(s!==e){d();const r=t.get(e);r&&(r.preventClean=!0,null==(n=r.highlight)||n.call(r),s=e)}}(n)}function p(e){l=e,f()}function h(e){for(const[t,n]of ye.entries())i.has(t)&&!e[n]?i.delete(t):!i.has(t)&&e[n]&&i.add(t)}function v(e){var t;h(e),A()&&(t=e.target,!Boolean(w(t,(e=>e.id===re))))&&(e.stopPropagation(),e.preventDefault())}function m(e){h(e),p({x:e.clientX,y:e.clientY})}function y(e){h(e),f()}function b(e){h(e),f()}function E(){var e;const n=t.get(s);null==(e=null==n?void 0:n.highlight)||e.call(n)}function L(e){v(e),h(e),p({x:e.clientX,y:e.clientY}),A()&&s&&(n(s),d())}function O(e,t,n){g.addEventListener(e,t,n),c.push([e,t,n])}function w(e,t){return e.id===re?null:t(e)?e:(null==e?void 0:e.parentElement)?w(e.parentElement,t):void 0}function A(){for(const t of e)if(!i.has(t))return!1;return!0}return Object.freeze({stop(){!function(){for(const e of c)g.removeEventListener(...e);c=[]}()},run(){O("keydown",y,ve),O("keyup",b,ve),O("mousemove",m,me),O("scroll",E,me),O("click",L,ve),O("mouseenter",v,ve),O("mouseover",v,ve),O("mouseout",v,ve),O("mouseleave",v,ve),O("mousedown",v,ve),O("mouseup",v,ve)}})}function Ee(e,t,n){const r=he({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),a=be({highlightKeys:e.highlightKeys,elementStore:t,onClick(e){const r=t.get(e);n({target:e,keysAndDefaults:s(r)})},options:e});function o(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${oe}]`)}function i(e,n){var r;n.highlightEl&&(null==(r=n.unhighlight)||r.call(n)),e.removeAttribute(ie),t.remove(e)}function s(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({isRestricted:o,register(e,n,a){if(o(e))return;const i=e;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(ie,"true")),s.nodes.set(n,a),r.initHighlighter(i,s)},forEachElement:t.forEachElement,cleanupLingeringKeyAttributes(){t.forEachElement(((e,t)=>{if(!t.preventClean){for(const[e]of t.nodes)if(e.nodeType===Node.ATTRIBUTE_NODE){const n=e;n.name===ae&&null===n.ownerElement&&t.nodes.delete(n)}0===t.nodes.size&&i(e,t)}}))},cleanupRemovedNodes(e){t.forEachElement(((t,n)=>{n.preventClean||(e.has(t)||function(e,t){for(const[n]of e.nodes)t.has(n)&&e.nodes.delete(n)}(n,e),(e.has(t)||0===n.nodes.size)&&i(t,n))}))},findAll(e,n){const r=[];return t.forEachElement(((t,a)=>{for(const t of a.nodes.values()){if(t.keys.find((t=>fe({key:e,ns:v(n)},{key:t.key,ns:v(t.ns)})))){r.push(a);break}}})),r},run(e){e&&a.run()},stop(){a.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null==(n=t.unhighlight)||n.call(t))}))}})}function Le(){let e,t=!1;const n=function(){const e=new Map;return Object.freeze({set(t,n){e.set(t,n)},get:t=>t&&e.get(t),remove:t=>e.delete(t),forEachElement(t){e.forEach(((e,n)=>t(n,e)))}})}();function r({mouseHighlight:e,options:r,wrapper:a,onClick:o}){if(le())return{stop(){t=!1},wrapper:a};const i=function(e){const t=Object.freeze({getSuitableParent(n){const r=function(e){return e.parentElement?e.parentElement:e.ownerElement&&e.ownerElement||void 0}(n);if(void 0===r)throw console.error(n),new Error("No suitable parent found for node above.");if(!e.passToParent)return r;if(Array.isArray(e.passToParent)){const t=e=>r.tagName.toLowerCase()===e.toLowerCase();if(-1===e.passToParent.findIndex(t))return r}return"function"!=typeof e.passToParent||e.passToParent(r)?t.getSuitableParent(r):r}});return t}(r),s=function(e,t){const n=Object.freeze({handleAttributes(n,r=!0){var a,o;const i=[],s=Object.fromEntries(Object.entries(e.tagAttributes).map((([e,t])=>[e.toUpperCase(),t])));if(n.nodeType===Node.ELEMENT_NODE){const e=n;let r=null!=(a=s[e.tagName.toUpperCase()])?a:[];"*"in s&&(r=r.concat(s["*"])),i.push(...r.filter((t=>e.hasAttribute(t))).map((t=>e.getAttributeNode(t))).filter((e=>t.testAttribute(e))))}if(r){const e=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,(e=>{var t,n;return(null==(t=s[e.tagName.toUpperCase()])?void 0:t.some((t=>e.hasAttribute(t))))||(null==(n=s["*"])?void 0:n.some((t=>e.hasAttribute(t))))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}));for(;e.nextNode();){const n=e.currentNode;let r=null!=(o=s[n.tagName.toUpperCase()])?o:[];"*"in s&&(r=r.concat(s["*"])),i.push(...r.filter((e=>n.hasAttribute(e))).map((e=>n.getAttributeNode(e))).filter((e=>t.testAttribute(e))))}}return i},handleChildList(e){const t=[];return t.push(...e.flatMap((e=>n.handleAttributes(e,!0)))),t.push(...e.flatMap((e=>n.handleText(e)))),t},handleText(e){if(e.nodeType===Node.TEXT_NODE)return t.testTextNode(e)?[e]:[];const n=[],r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,(e=>t.testTextNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;r.nextNode();)n.push(r.currentNode);return n}});return n}(r,a),l=Ee(r,n,o);function c(e){for(const t of e){const e=t.parentElement;if(e&&l.isRestricted(e))continue;const n=ge(t),r=n?a.unwrap(n):null;if(r){const{text:e,keys:a}=r;de(t,e);const o=ue(n,a),s=i.getSuitableParent(t);l.register(s,t,o)}}}function u(e){const t=i.getSuitableParent(e);l.register(t,e,{oldTextContent:"",keys:[{key:ge(e)}],keyAttributeOnly:!0})}function g(e,t){if(e.nodeType===Node.ATTRIBUTE_NODE){const t=e;if(t.name===ae)return void u(t)}if(e.nodeType===Node.ELEMENT_NODE){const t=e.getAttributeNode(ae);t&&u(t)}if(!t)return;const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,(e=>e.hasAttribute(ae)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;n.nextNode();){u(n.currentNode.getAttributeNode(ae))}}const d=new MutationObserver((e=>{if(!t)return;const n=e.filter((e=>"childList"===e.type)).flatMap((e=>Array.from(e.removedNodes))),r=new Set(n);for(const e of n){if(e.nodeType===Node.ELEMENT_NODE)for(let t=0;t<e.attributes.length;t++)r.add(e.attributes[t]);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);for(;t.nextNode();){const e=t.currentNode;if(e.nodeType===Node.ELEMENT_NODE){const t=e;for(let e=0;e<t.attributes.length;e++)r.add(t.attributes[e])}r.add(e)}}r.size>0&&l.cleanupRemovedNodes(r),e.some((e=>"attributes"===e.type&&e.attributeName===ae))&&l.cleanupLingeringKeyAttributes();const a=new Set;for(const t of e)switch(t.type){case"characterData":s.handleText(t.target).forEach((e=>a.add(e)));break;case"childList":g(t.target,!0),t.addedNodes.length>0&&s.handleChildList(Array.from(t.addedNodes)).forEach((e=>a.add(e))),t.removedNodes.length>0&&s.handleChildList(Array.from(t.removedNodes)).forEach((e=>a.delete(e)));break;case"attributes":t.attributeName===ae&&g(t.target,!1),s.handleAttributes(t.target,!1).forEach((e=>a.add(e)))}c([...a])})),f=r.targetElement||document;t=!0,l.run(e),g(f,!0),c(s.handleChildList([f]));const p=new Set;return p.add(ae),Object.values(r.tagAttributes).forEach((e=>e.forEach((e=>p.add(e.toLowerCase()))))),d.observe(f,{attributes:!0,attributeFilter:[...p],childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),d.disconnect()},elementRegistry:l,wrapper:a}}return Object.freeze({run(t){e=r(t)},stop(){null==e||e.stop()},forEachElement(t){var n,r;null==(r=null==(n=null==e?void 0:e.elementRegistry)?void 0:n.forEachElement)||r.call(n,t)},highlight(t,n){var r;const a=(null==(r=null==e?void 0:e.elementRegistry)?void 0:r.findAll(t,n))||[];return a.forEach((e=>{var t;return null==(t=e.highlight)?void 0:t.call(e)})),{unhighlight(){a.forEach((e=>{var t;return null==(t=e.unhighlight)?void 0:t.call(e)}))}}},findPositions(t,n){var r;const a=(null==(r=null==e?void 0:e.elementRegistry)?void 0:r.findAll(t,n))||[],o=[];return a.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),a.forEach((e=>{const r=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{fe({key:t,ns:v(n)},{key:e.key,ns:v(e.ns)})&&o.push({position:{x:r.x,y:r.y,width:r.width,height:r.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),o},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}var Oe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},we={};!function(e){function t(e){for(var t=0,n=Math.min(65536,e.length+1),r=new Uint16Array(n),a=[],o=0;;){var i=t<e.length;if(!i||o>=n-1){var s=r.subarray(0,o);if(a.push(String.fromCharCode.apply(null,s)),!i)return a.join("");e=e.subarray(t),t=0,o=0}var l=e[t++];if(0==(128&l))r[o++]=l;else if(192==(224&l)){var c=63&e[t++];r[o++]=(31&l)<<6|c}else if(224==(240&l)){c=63&e[t++];var u=63&e[t++];r[o++]=(31&l)<<12|c<<6|u}else if(240==(248&l)){var g=(7&l)<<18|(c=63&e[t++])<<12|(u=63&e[t++])<<6|63&e[t++];g>65535&&(g-=65536,r[o++]=g>>>10&1023|55296,g=56320|1023&g),r[o++]=g}}}var n="Failed to ",r=function(e,t,r){if(e)throw new Error("".concat(n).concat(t,": the '").concat(r,"' option is unsupported."))},a="function"==typeof Buffer&&Buffer.from,o=a?function(e){return Buffer.from(e)}:function(e){for(var t=0,n=e.length,r=0,a=Math.max(32,n+(n>>>1)+7),o=new Uint8Array(a>>>3<<3);t<n;){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319){if(t<n){var s=e.charCodeAt(t);56320==(64512&s)&&(++t,i=((1023&i)<<10)+(1023&s)+65536)}if(i>=55296&&i<=56319)continue}if(r+4>o.length){a+=8,a=(a*=1+t/e.length*2)>>>3<<3;var l=new Uint8Array(a);l.set(o),o=l}if(0!=(4294967168&i)){if(0==(4294965248&i))o[r++]=i>>>6&31|192;else if(0==(4294901760&i))o[r++]=i>>>12&15|224,o[r++]=i>>>6&63|128;else{if(0!=(4292870144&i))continue;o[r++]=i>>>18&7|240,o[r++]=i>>>12&63|128,o[r++]=i>>>6&63|128}o[r++]=63&i|128}else o[r++]=i}return o.slice?o.slice(0,r):o.subarray(0,r)};function i(){this.encoding="utf-8"}i.prototype.encode=function(e,t){return r(t&&t.stream,"encode","stream"),o(e)};var s=!a&&"function"==typeof Blob&&"function"==typeof URL&&"function"==typeof URL.createObjectURL,l=["utf-8","utf8","unicode-1-1-utf-8"],c=t;a?c=function(e,t){return(e instanceof Buffer?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)).toString(t)}:s&&(c=function(e){try{return function(e){var t;try{var n=new Blob([e],{type:"text/plain;charset=UTF-8"});t=URL.createObjectURL(n);var r=new XMLHttpRequest;return r.open("GET",t,!1),r.send(),r.responseText}finally{t&&URL.revokeObjectURL(t)}}(e)}catch(n){return t(e)}});var u="construct 'TextDecoder'",g="".concat(n," ").concat(u,": the ");function d(e,t){if(r(t&&t.fatal,u,"fatal"),e=e||"utf-8",!(a?Buffer.isEncoding(e):-1!==l.indexOf(e.toLowerCase())))throw new RangeError("".concat(g," encoding label provided ('").concat(e,"') is invalid."));this.encoding=e,this.fatal=!1,this.ignoreBOM=!1}d.prototype.decode=function(e,t){var n;return r(t&&t.stream,"decode","stream"),n=e instanceof Uint8Array?e:e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer):new Uint8Array(e),c(n,this.encoding)},e.TextEncoder=e.TextEncoder||i,e.TextDecoder=e.TextDecoder||d}("undefined"!=typeof window?window:Oe);const Ae=g({__proto__:null,default:we},[we]);null==(t=console.assert)||t.call(console,Ae);const Te=["",""],ke=RegExp(`([${Te.join("")}]{9})+`,"gu");function Ne(e){const t=function(e){return Array.from((new TextEncoder).encode(e))}(e).map(Number),n=t.map((e=>function(e){const t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0")).join("");return Array.from(n).map((e=>Te[Number(e)])).join("")}function je(e){const t=Array.from(e).map((e=>Te.indexOf(e))).map(String).join("").match(/(.{9})/g),n=Uint8Array.from((null==t?void 0:t.map((e=>parseInt(e.slice(0,8),2))))||[]);return r=n,(new TextDecoder).decode(new Uint8Array(r));var r}function Re({fullKeyEncode:e}){const t=function(){const e=[];return Object.freeze({valueToNumber(t){let n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:t=>e[t]})}();function n(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}return Object.freeze({unwrap(e){const n=[],r=function(e){var t;const n=null==(t=e.match(ke))?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(je))||[]}(e);r.forEach((e=>{const r=function(e){if(e.length<=4){const[n]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(e);return t.numberToValue(n)}return e}(e),a=function(e){try{return JSON.parse(e||"{}")}catch(e){return void console.error(e)}}(r);if(a){const{k:e,d:t,n:r}=a;n.push({key:e,defaultValue:t,ns:r})}}));const a=function(e){return e.replace(ke,"")}(e);return{text:a,keys:n}},wrap({key:r,defaultValue:a,translation:o,ns:i}){let s;if(e){s=Ne(n({key:r,ns:i}))}else{const e=n({key:r,ns:i,defaultValue:a}),o=t.valueToNumber(e);s=Ne(String.fromCodePoint(o))}const l=o||"";return"string"==typeof l?l+s:l},testTextNode(e){var t,n,r;return null!=(r=(null==(t=e.textContent)?void 0:t.includes(`${Te[0]}${Te[0]}`))||(null==(n=e.textContent)?void 0:n.includes(`${Te[1]}${Te[0]}`)))&&r},testAttribute:e=>e.value.includes(`${Te[0]}${Te[0]}`)||e.value.includes(`${Te[1]}${Te[0]}`)})}function xe(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function Pe({inputPrefix:e,inputSuffix:t,translate:n}){function r(e){const{key:t,params:r,defaultValue:a,ns:o}=function(e){let t=!1,n="",r="",a="KEY";const o={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{o.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==a||","!==s?"KEY"!==a||"|"!==s?"NAMESPACE"!==a||","!==s?"KEY"!==a||":"!==s?"DEFAULT_VALUE"!==a||":"!==s?"PARAM_NAME"!==a||":"!==s?"PARAM_VALUE"!==a||","!==s?n+=s:(a="PARAM_NAME",o.params[r]=n,n=""):(a="PARAM_VALUE",r=n,n=""):(a="PARAM_NAME",o.defaultValue=n,n=""):(a="PARAM_NAME",o.key=n,n=""):(a="DEFAULT_VALUE",i(n),n=""):(a="NAMESPACE",o.key=n,n=""):(a="DEFAULT_VALUE",o.key=n,n=""):t=!0;return"KEY"===a&&(o.key=n),"DEFAULT_VALUE"===a&&(o.defaultValue=n),"PARAM_VALUE"===a&&(o.params[r]=n),"NAMESPACE"===a&&i(n),o}(e);return{translated:n({key:t,params:r,defaultValue:a,ns:o,noWrap:!0}),key:t,params:r,defaultValue:a,ns:o}}function a(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function o(e){return"string"==typeof e?e.replace(new RegExp("[,:|\\\\]","gs"),"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(`Parameters of type "${typeof e}" are not supported in "text" wrapper mode.`),e)}return Object.freeze({wrap({key:n,params:r,defaultValue:a,ns:i}){let s=Object.entries(r||{}).map((([e,t])=>`${o(e)}:${o(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==a?`,${o(a)}`:"",c="string"==typeof i?[i]:i,u=(null==c?void 0:c.length)?`|${c.map((e=>o(e))).join("|")}`:"";return`${e}${o(n)}${u}${l}${s}${t}`},unwrap(n){const o=new RegExp(`(\\\\?)(${a(e)}(.*?)${a(t)})`,"gs"),i=[];let s,l=!1,c=0,u="";for(;null!==(s=o.exec(n));){let e=s[1];const[t,a,o,g]=s,{index:d,input:f}=s;if(u+=f.substr(c,d-c),c=d+t.length,"\\"===e){if(!xe(d,n)){u+=o;continue}e=""}const p=r(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,u+=e+p.translated}return u+=n.substring(c),l?{text:u,keys:i}:{text:n,keys:[]}},testTextNode(n){var r,a,o;return null!=(o=(null==(r=n.textContent)?void 0:r.includes(e))&&(null==(a=n.textContent)?void 0:a.includes(t)))&&o},testAttribute:n=>n.value.includes(e)&&n.value.includes(t)})}const Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Se(e){const t=Ce.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function De(e){const t=(e=e.toUpperCase()).length;let n=0,r=0,a=0;const o=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)r=r<<5|Se(e[i]),n+=5,n>=8&&(o[a++]=r>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let r="",a=Math.pow(2,16)-1;for(let e=0;e<n;e+=a)e+a>n&&(a=n-e),r+=String.fromCharCode.apply(null,t.subarray(e,e+a));return r}(o.buffer)}function _e(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=De(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}function Ie({message:e,recievingMessage:t,data:n,attempts:r=1,timeout:a=300}){let o=!1;const i=()=>new Promise(((r,o)=>{const i=function(e,t){const n=n=>{var r,a;e.includes(null==(r=n.data)?void 0:r.type)&&t(null==(a=n.data)?void 0:a.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(s),l(),r(e)}));window.postMessage({type:e,data:n},window.origin);const s=setTimeout((function(){l(),o()}),a);function l(){i.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<r;e++){if(o)return new Promise((()=>{}));try{return await i()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}let Fe=null;function Ue(e){var t;return Fe||(Fe=(t=`https://cdn.jsdelivr.net/npm/@tolgee/web@${e}/dist/tolgee-in-context-tools.umd.min.js`,new Promise(((e,n)=>{const r=document.createElement("script");r.src=t,r.addEventListener("load",(()=>e())),r.addEventListener("error",(e=>n(e.error))),document.head.appendChild(r)}))).then((()=>window["@tolgee/in-context-tools"].InContextTools))),Fe}const $e="__tolgee_apiKey",Me="__tolgee_apiUrl";function Be(){const e=sessionStorage.getItem($e)||void 0,t=sessionStorage.getItem(Me)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Ke(){sessionStorage.removeItem($e),sessionStorage.removeItem(Me)}e.BrowserExtensionPlugin=()=>e=>e;(()=>{if("undefined"==typeof window)return!1;try{return"undefined"!=typeof sessionStorage&&sessionStorage}catch(e){return console.error("sessionStorage not available",e),!1}})()&&(e.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:r}=Ie({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:t,attempts:4});return e=n,r}}}();e.on("running",(({value:n})=>{var r;n&&(r=()=>{t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(Ke)},"loading"!==document.readyState?Promise.resolve().then((()=>{r()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",r))}));return Be()&&(async()=>{const e=await Ue("5.29.0");return t=>{const n=Be();return t.addPlugin(e({credentials:n})),t}})().then((t=>{e.addPlugin(t)})).catch((e=>{console.error("Tolgee: Failed to load in-context tools"),console.error(e)})),e});const Ve="__tolgee_currentLanguage";function ze(e){return e.endsWith("/")?e.slice(0,-1):e}const We={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${ze(n)}/${e}/${t}.json`:`${ze(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Ge(e){const t=u(c(c({},We),e),{headers:c(c({},We.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:r,getData:a,headers:l}=t,g=((e,t)=>{var n={};for(var r in e)i.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&o)for(var r of o(e))t.indexOf(r)<0&&s.call(e,r)&&(n[r]=e[r]);return n})(t,["prefix","getPath","getData","headers"]);return{getRecord:({namespace:e,language:t,fetch:o})=>o(r({namespace:e,language:t,prefix:n}),c({headers:l},g)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return a(e)}))}}e.BackendFetch=e=>(t,n)=>(n.addBackend(Ge(e)),t),e.DEVTOOLS_ID=re,e.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:r,projectId:a,fetch:o}){var i;const s=null!=(i=_e(t))?i:a;let l=void 0!==s?`${e}/v2/projects/${s}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(r&&(l+=`?ns=${r}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===a)throw new Error("You need to specify 'projectId' when using PAT key");return o(l,{headers:{"X-API-Key":t||"","Content-Type":"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>e[n]));throw new Error(e.statusText)}))}}),e),e.DevTools=()=>e=>e,e.FormatSimple=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>ne(e,t)}),e),e.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){ce("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const r=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),a=r(window.navigator.language);return e.find((e=>r(e)===a))||void 0}}),e),e.LanguageDetectorError=k,e.LanguageStorage=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(ce("LanguageStorage"),localStorage.getItem(Ve)||void 0),setLanguage(e){ce("LanguageStorage"),localStorage.setItem(Ve,e)}}),e),e.LanguageStorageError=N,e.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=Le();return Object.freeze(u(c({},e),{run(t){const n=Pe({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(u(c({},t),{wrapper:n}))},retranslate(){e.forEachElement(((t,n)=>{for(const[t,r]of n.nodes.entries()){if(r.keyAttributeOnly)return;const n=e.unwrap(r.oldTextContent);n&&de(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=Le();return Object.freeze(u(c({},e),{run(t){const n=Re({fullKeyEncode:t.options.fullKeyEncode});e.run(u(c({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),e.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",e.RecordFetchError=T,e.TOLGEE_ATTRIBUTE_NAME=ie,e.TOLGEE_RESTRICT_ATTRIBUTE=oe,e.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=ae,e.Tolgee=function(){return B().use(e.BrowserExtensionPlugin())},e.TolgeeCore=B,e.createFetchFunction=O,e.getFallback=v,e.getFallbackArray=m,e.getProjectIdFromApiKey=_e,e.getTranslateProps=$,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})})); | ||
//# sourceMappingURL=tolgee-web.production.umd.min.js.map |
{ | ||
"name": "@tolgee/web", | ||
"version": "5.28.7", | ||
"version": "5.29.0", | ||
"description": "Tolgee for web", | ||
@@ -48,3 +48,3 @@ "declaration": true, | ||
"dependencies": { | ||
"@tolgee/core": "5.28.7" | ||
"@tolgee/core": "5.29.0" | ||
}, | ||
@@ -100,3 +100,3 @@ "devDependencies": { | ||
"homepage": "https://github.com/tolgee/tolgee-js#readme", | ||
"gitHead": "674c9b4cdd5185757996da090feed5449a7a0c90", | ||
"gitHead": "a4d8a8874e9c7ce969f1339b5951a767eac945c3", | ||
"publishConfig": { | ||
@@ -103,0 +103,0 @@ "access": "public" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
+ Added@tolgee/core@5.29.0(transitive)
- Removed@tolgee/core@5.28.7(transitive)
Updated@tolgee/core@5.29.0