@tolgee/web
Advanced tools
Comparing version 5.9.2-prerelease.41828ff8.0 to 5.9.2-prerelease.ce0c7097.0
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return Boolean(e&&"function"==typeof e.then)}function t(t,n){return e(t)?Promise.resolve(t).then(n):n(t)}function n(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 a(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function o(e){return a(e)||[]}function r(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?o(t):o(null==t?void 0:t[e]);var n}function i(e){return Array.from(new Set(e))}function s(e){return e?e.replace(/\/+$/,""):e}function l(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 u(e,t,n){const a=new Set,r=new Set;let i=[];function s(){if(0===i.length)return;const e=i;i=[],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()&&(i.push(t),n?setTimeout(s,0):s())},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=>(o(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}Object.defineProperty(exports,"__esModule",{value:!0});const c=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):c(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},g=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},d=({language:e,namespace:t})=>t?`${e}:${t}`:e;function f(e,t,n,a,r,s,l){const u=new Map,f=new Map;let p={},v=0;function h(t,n,a){const o=d(t);f.set(o,{data:c(n),version:a}),e.emit(t)}function m(e){let n;if(!n){const t=p[d(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}const b=Object.freeze({addStaticData(e){e&&(p=Object.assign(Object.assign({},p),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=g(e),a=f.get(e);a&&0!==a.version||h(n,t,0)}})))},invalidate(){u.clear(),v+=1},addRecord(e,t){h(e,t,v)},exists(e,t=!1){const n=f.get(d(e));return n&&t?n.version===v:Boolean(n)},getRecord(e){var t;return null===(t=f.get(d(a(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=f.get(d(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=f.get(d({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return i(e)},getTranslationFallback(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=f.get(d({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var o;const r=null===(o=f.get(d(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(r())return!0;if(void 0===e)return u.size>0;const t=o(e);return Boolean(Array.from(u.keys()).find((e=>t.includes(g(e).namespace))))},isLoading(e,t){const n=o(t);return Boolean(r()||Array.from(u.keys()).find((t=>{const a=g(t);return(!n.length||n.includes(a.namespace))&&!b.exists({namespace:a.namespace,language:e})})))},async loadRecords(e,t){const o=e.map((e=>{const o=a(e),r=d(o),i=u.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const s=function(e,t){var a;let o;return t&&(o=null===(a=n(e))||void 0===a?void 0:a.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),m(e))))),o||(o=m(e)),o}(o,t)||Promise.resolve(void 0);return u.set(r,s),{new:!0,promise:s,keyObject:o,cacheKey:r}}));s.notify(),l.notify();const r=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=u.get(e.cacheKey)!==e.promise;if(e.new&&!n){u.delete(e.cacheKey);const n=r[t];n?b.addRecord(e.keyObject,n):b.getRecord(e.keyObject)||b.addRecord(e.keyObject,{})}})),s.notify(),l.notify(),o.map((e=>b.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(f.entries()).map((([e,t])=>Object.assign(Object.assign({},g(e)),{data:t.data})))});return b}function p(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 o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}const v="invalid",h={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"]},observerType:"invisible",onFormatError:v,apiUrl:"https://app.tolgee.io"},m=(...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 b(e,t){const n=m(h,null==t?void 0:t.initialOptions,e);return n.apiUrl=s(n.apiUrl),{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 y(n,a,o,r,i,s){const l={ui:void 0},u={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},c=async({keysAndDefaults:e,event:t})=>{var n;const a=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,ns:r({key:e,ns:t}),translation:i({key:e,ns:t})})));null===(n=u.ui)||void 0===n||n.handleElementClick(a,t)},g=(e,t)=>{var n;return(null===(n=u.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function d(e){const t=i({key:e.key,ns:e.ns});return A.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function f(e){u.observer=null==e?void 0:e()}function h(){return Boolean(u.observer)}function m(e){e&&u.formatters.push(e)}function b(e){u.finalFormatter=e}function y(e){l.ui=e}function E(){return Boolean(l.ui)}function L(e){u.languageStorage=e}function O(e){u.languageDetector=e}function w(e){e&&u.backends.push(e)}function k(e){u.devBackend=e}const A=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:b,addFormatter:m,setObserver:f,hasObserver:h,setUi:y,hasUi:E,setDevBackend:k,addBackend:w,setLanguageDetector:O,setLanguageStorage:L}))},run(){var e,t;const{apiKey:n,apiUrl:o,projectId:r,observerOptions:i}=a();u.ui=null===(e=l.ui)||void 0===e?void 0:e.call(l,{apiKey:n,apiUrl:o,projectId:r,highlight:A.highlight,changeTranslation:s,findPositions:g}),null===(t=u.observer)||void 0===t||t.run({mouseHighlight:!0,options:i,translate:d,onClick:c})},stop(){var e;u.ui=void 0,null===(e=u.observer)||void 0===e||e.stop()},getLanguageStorage:()=>u.languageStorage,getInitialLanguage(){var e;const n=o();return t(null===(e=u.languageStorage)||void 0===e?void 0:e.getLanguage(),(e=>n&&!n.includes(e)||!e?function(){if(!u.languageDetector)return;const e=o();return u.languageDetector.getLanguage({availableLanguages:e})}():e))},setStoredLanguage(e){var t;null===(t=u.languageStorage)||void 0===t||t.setLanguage(e)},getDevBackend:()=>u.devBackend,getBackendRecord:({language:t,namespace:n})=>{for(const a of u.backends){const o=a.getRecord({language:t,namespace:n});if(e(o))return null==o?void 0:o.catch((e=>(console.error(e),{})));if(void 0!==o)return o}},getBackendDevRecord:({language:e,namespace:t})=>{var n;const{apiKey:o,apiUrl:r,projectId:i}=a();return null===(n=u.devBackend)||void 0===n?void 0:n.getRecord({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:t})},getLanguageDetector:()=>u.languageDetector,retranslate(){var e;null===(e=u.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,a;return(null===(a=null===(n=u.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return u.observer?null===(t=u.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return u.observer?null===(t=u.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(A.getDevBackend()),formatTranslation(e){var t,{formatEnabled:o}=e,r=p(e,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:c,params:g,orEmpty:d,ns:f}=r,h=s||l;let m=h||(d?"":i);const b=n(),y=o||!(null===(t=u.observer)||void 0===t?void 0:t.outputNotFormattable),E=e=>u.observer&&!c?u.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:f}):e;m=E(m);try{if(h&&b&&y)for(const e of u.formatters)m=e.format({translation:m,language:b,params:g});u.finalFormatter&&h&&b&&y&&(m=u.finalFormatter.format({translation:m,language:b,params:g}))}catch(e){console.error(e);const t=("string"==typeof(L=e)?L:"string"==typeof(null==L?void 0:L.message)?L.message:void 0)||v,n=a().onFormatError,o=typeof n;m="string"===o?n:"function"===o?n(t,r):v,m=E(m)}var L;return m}});return A}const E=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const L=(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:o,language:r}=e,i=p(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:r};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function O({options:a}){const c=function(e,t){let n=!0;function a(){return n}const o=Object.freeze({onPendingLanguageChange:l(a),onLanguageChange:l(a),onLoadingChange:l(a),onFetchingChange:l(a),onInitialLoaded:l(a),onRunningChange:l(a),onCacheChange:l(a),onUpdate:u(a,e,t),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.onPendingLanguageChange.listen(t);case"language":return o.onLanguageChange.listen(t);case"loading":return o.onLoadingChange.listen(t);case"fetching":return o.onFetchingChange.listen(t);case"initialLoad":return o.onInitialLoaded.listen(t);case"running":return o.onRunningChange.listen(t);case"cache":return o.onCacheChange.listen(t);case"update":return o.onUpdate.listen(t)}}});return o.onInitialLoaded.listen((()=>o.onUpdate.emit())),o.onLanguageChange.listen((()=>o.onUpdate.emit())),o.onCacheChange.listen((({value:e})=>o.onUpdate.emit([e.namespace],!0))),o}(O,w),d=E(!1,(()=>m.isFetching()),c.onFetchingChange.emit),p=E(!1,(()=>R.isLoading()),c.onLoadingChange.emit),v=function(e,t,n){let a,l=b();const u=Object.freeze({init(e){l=b(e,l)},isRunning:()=>l.isRunning,setRunning(e){l.isRunning!==e&&(l.isRunning=e,n.emit(e))},isInitialLoading:()=>l.isInitialLoading,setInitialLoading(e){l.isInitialLoading=e},getLanguage:()=>l.language||l.initialOptions.language,setLanguage(t){l.language!==t&&(l.language=t,e.emit(t))},getPendingLanguage:()=>l.pendingLanguage||u.getLanguage(),setPendingLanguage(e){l.pendingLanguage!==e&&(l.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},l.initialOptions),a),addActiveNs(e){o(e).forEach((e=>{const t=l.activeNamespaces.get(e);void 0!==t?l.activeNamespaces.set(e,t+1):l.activeNamespaces.set(e,1)}))},removeActiveNs(e){o(e).forEach((e=>{const t=l.activeNamespaces.get(e);void 0!==t&&t>1?l.activeNamespaces.set(e,t-1):l.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>i([...l.initialOptions.ns||[l.initialOptions.defaultNs],...o(l.initialOptions.fallbackNs),...l.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||u.getLanguage();return t?i([t,...r(t,l.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>o(l.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?l.initialOptions.defaultNs:e,getAvailableLanguages(){if(l.initialOptions.availableLanguages)return l.initialOptions.availableLanguages;if(l.initialOptions.staticData){const e=Object.keys(l.initialOptions.staticData).map((e=>g(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?u.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:s(e.apiUrl)}):void 0}});return u}(c.onLanguageChange,c.onPendingLanguageChange,c.onRunningChange),h=y(v.getLanguage,v.getInitialOptions,v.getAvailableLanguages,(function({key:e,ns:t}){const n=v.getFallbackLangs(),a=k(t||void 0);return m.getTranslationNs(a,n,e)}),P,j),m=f(c.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,v.withDefaultNs,v.isInitialLoading,d,p);function O(){return v.getFallbackNs()}function w(e){return v.getDefaultNs(e)}function k(e){return[...o(w(e)),...O()]}function A(e){return[...o(e||w()),...v.getRequiredNamespaces()]}function j(e,t,n){const a=v.withDefaultNs(e),o=m.getTranslation(a,t);return m.changeTranslation(a,t,n),{revert(){m.changeTranslation(a,t,o)}}}function x(e){v.init(e),m.addStaticData(v.getInitialOptions().staticData)}function T(e,n){const a=function(e,t){const n=v.getFallbackLangs(e),a=A(t),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}(e,n);if(a.length)return t(R.loadRecords(a),(()=>{}))}function P({key:e,ns:t,language:n}){const a=k(t||void 0),o=v.getFallbackLangs(n);return m.getTranslationFallback(a,o,e)}function N(){const n=t(function(){if(v.getLanguage())return;return t(h.getInitialLanguage(),(e=>{const t=e||v.getInitialOptions().defaultLanguage;t&&v.setLanguage(t)}))}(),(()=>T()));if(e(n))return v.setInitialLoading(!0),d.notify(),p.notify(),Promise.resolve(n).then((()=>{v.setInitialLoading(!1),d.notify(),p.notify(),c.onInitialLoaded.emit()}));c.onInitialLoaded.emit()}a&&x(a),c.onUpdate.listen((()=>{v.isRunning()&&h.retranslate()}));const R=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},c),v),h),m),{init:x,getTranslation:P,changeTranslation:j,async changeLanguage(e){v.getPendingLanguage()===e&&v.getLanguage()===e||(v.setPendingLanguage(e),v.isRunning()&&await T(e),e===v.getPendingLanguage()&&(v.setLanguage(e),h.setStoredLanguage(e)))},async addActiveNs(e,t){t||v.addActiveNs(e),v.isRunning()&&await T(void 0,e)},loadRecords:e=>m.loadRecords(e,R.isDev()),loadRecord:async e=>(await R.loadRecords([e]))[0],isLoading:e=>m.isLoading(v.getLanguage(),e),isLoaded(e){const t=v.getLanguage();if(!t)return!1;const n=v.getFallbackLangs(t),a=A(e),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=L(...e),n=P(t);return h.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(v.getInitialOptions().apiKey&&v.getInitialOptions().apiUrl),run(){let e;return function(){if((h.getLanguageDetector()||h.getLanguageStorage())&&!v.getAvailableLanguages())throw new Error(n("availableLanguages"));if(!v.getLanguage()&&!v.getInitialOptions().defaultLanguage)throw new Error(n(["defaultLanguage","language"]))}(),v.isRunning()||(R.isDev()&&m.invalidate(),v.setRunning(!0),h.run(),e=N()),Promise.resolve(e)},stop(){v.isRunning()&&(h.stop(),v.setRunning(!1))}}));return R}const w=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=m(e.options,n),t),init(t){const n=function(e){const t=O({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),n&&t.run()}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,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,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}(m(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},k=0,A=1,j=2;class x extends Error{constructor(e,t,n){let a;a=e===k?"Empty parameter":e===A?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function T(e){return/\s/.test(e)}const P=0,N=1,R=2,S=3,C=4,D=new Set([R,N,P]),I="'",$=new Set(["{","}",I]),_=e=>/[0-9a-zA-Z_]/.test(e);function U(e,t){const[n,a]=function(e){let t=P,n="",a="",o="";const r=[],i=[];let s=0;function l(t){throw new x(t,s,e)}const u=()=>{r.push(n),n=""},c=()=>{""===a&&l(k),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case P:o===I?(n+=o,t=N):"{"===o?(u(),t=S):(n+=o,t=P);break;case N:$.has(o)?(n=n.slice(0,-1)+o,t=R):(n+=o,t=P);break;case R:o===I?t=P:(n+=o,t=R);break;case S:"}"===o?(c(),t=P):T(o)?""!==a&&(c(),t=C):(_(o)||l(A),a+=o,t=S);break;case C:"}"==o?t=P:T(o)?t=C:l(A)}return D.has(t)||l(j),u(),[r,i]}(e),o=[n[0]];for(let r=1;r<n.length;r++){const i=null==t?void 0:t[a[r-1]];if(void 0===i)throw new Error(`Missing parameter "${a[r-1]}" in "${e}"`);o.push(String(i)),o.push(n[r])}return o.join("")}const F="__tolgee_dev_tools",B="data-tolgee-key-only",M="data-tolgee-restricted",V="_tolgee",z="_tolgee-highlighter";function K(){var e,t;return void 0===(null===(t=null===(e=globalThis.window)||void 0===e?void 0:e.document)||void 0===t?void 0:t.createElement)}function Y(e){if(K())throw new Error(`${e}: Can't run on the server`)}function G(e,t){return{oldTextContent:e,keys:t}}const W={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function X({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(z),Object.entries(W).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const r=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=r.top-t+"px",o.style.left=r.left-t+"px",o.style.width=r.width+"px",o.style.height=r.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,a)}})}function H(e,t){var n;const a=function(e){switch(e.nodeType){case Node.ATTRIBUTE_NODE:return e.ownerElement||void 0;case Node.TEXT_NODE:return e.parentElement||void 0;case Node.DOCUMENT_NODE:case Node.ELEMENT_NODE:return e;default:return}}(t),o=[];if(!a)return o;const r=null===document||void 0===document?void 0:document.evaluate(e,a,void 0,XPathResult.ANY_TYPE);let i;for(;i=null===(n=null==r?void 0:r.iterateNext)||void 0===n?void 0:n.call(r);)o.push(i);return o}function J(e){return e.textContent}function q(e,t){e.textContent=t}function Z(e,t){if(e.contains(t))return!0;if(t instanceof Attr){const n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}function Q(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null===(n=e.ns)||void 0===n?void 0:n.findIndex((e=>{var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return a&&o}const ee={capture:!0},te={capture:!0,passive:!0};function ne({highlightKeys:e,elementStore:t,onClick:n,options:a}){var o,r;let i,s,l=new Set;const u=(null===(o=a.targetElement)||void 0===o?void 0:o.getRootNode())||document,c=(null===(r=a.targetElement)||void 0===r?void 0:r.ownerDocument)||document;function g(){var e;const n=t.get(i);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),i=void 0)}function d(){const e=s;let n;if(e&&L()){const a=u.elementFromPoint(e.x,e.y);a&&(n=function(e){return E(e,(e=>t.get(e)))}(a))}!function(e){var n;if(i!==e){g();const a=t.get(e);a&&(a.preventClean=!0,null===(n=a.highlight)||void 0===n||n.call(a),i=e)}}(n)}function f(e){var t;L()&&(t=e.target,!Boolean(E(t,(e=>e.id===F))))&&(e.stopPropagation(),e.preventDefault())}function p(e){var t;t={x:e.clientX,y:e.clientY},s=t,d()}function v(){l=new Set,d()}function h(e){const t=e.key;void 0!==t&&l.add(t),d()}function m(e){l.delete(e.key),d()}function b(){var e;const n=t.get(i);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)}function y(e){f(e),L()&&i&&(n(e,i),g())}function E(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?E(e.parentElement,t):void 0}function L(){for(const t of e)if(!l.has(t))return!1;return!0}return Object.freeze({stop(){c.removeEventListener("blur",v,ee),c.removeEventListener("keydown",h,ee),c.removeEventListener("keyup",m,ee),c.removeEventListener("mousemove",p,te),c.removeEventListener("scroll",b,te),c.removeEventListener("click",y,ee),c.removeEventListener("mouseenter",f,ee),c.removeEventListener("mouseover",f,ee),c.removeEventListener("mouseout",f,ee),c.removeEventListener("mouseleave",f,ee),c.removeEventListener("mousedown",f,ee),c.removeEventListener("mouseup",f,ee)},run(){c.addEventListener("blur",v,ee),c.addEventListener("keydown",h,ee),c.addEventListener("keyup",m,ee),c.addEventListener("mousemove",p,te),c.addEventListener("scroll",b,te),c.addEventListener("click",y,ee),c.addEventListener("mouseenter",f,ee),c.addEventListener("mouseover",f,ee),c.addEventListener("mouseout",f,ee),c.addEventListener("mouseleave",f,ee),c.addEventListener("mousedown",f,ee),c.addEventListener("mouseup",f,ee)}})}function ae(e,t,n){const o=X({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=ne({highlightKeys:e.highlightKeys,elementStore:t,onClick(e,a){const o=t.get(a);n({event:e,keysAndDefaults:l(o)})},options:e});function i(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())Z(s(),t)&&(yield[t,n])}(e))}function s(){return e.targetElement||document.body}function l(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({register(n,a,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${M}]`)}(n))return;const i=n;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(V,"true")),s.nodes.set(a,r),o.initHighlighter(i,s)},forEachElement:t.forEachElement,refreshAll(){t.forEachElement(((e,n)=>{n.preventClean||(i(n),0===n.nodes.size&&function(e,n){var a;n.highlightEl&&(null===(a=n.unhighlight)||void 0===a||a.call(n)),e.removeAttribute(V),t.remove(e)}(e,n))}))},findAll(e,n){const o=[];return t.forEachElement(((t,r)=>{for(const t of r.nodes.values()){if(t.keys.find((t=>Q({key:e,ns:a(n)},{key:t.key,ns:a(t.ns)})))){o.push(r);break}}})),o},run(e){e&&r.run()},stop(){r.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||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 o({mouseHighlight:e,options:a,wrapper:o,onClick:r}){if(K())return;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){let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=H(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a},handleChildList(e){let t=[];return t=t.concat(n.handleAttributes(e)),t=t.concat(n.handleText(e)),t},handleText:e=>H(t.getTextXPath(),e)});return n}(a,o),l=ae(a,n,r);function u(e){for(const t of e){const e=J(t),n=e?o.unwrap(e):null;if(n){const{text:a,keys:o}=n;q(t,a);const r=G(e,o),s=i.getSuitableParent(t);l.register(s,t,r)}}}function c(e){H(`./descendant-or-self::*[@${B}]`,e).forEach((e=>{const t=e.getAttributeNode(B),n=i.getSuitableParent(t);l.register(n,t,{oldTextContent:"",keys:[{key:J(t)}],keyAttributeOnly:!0})}))}const g=new MutationObserver((e=>{if(t){for(const t of e){let e=[];switch(t.type){case"characterData":e=s.handleText(t.target);break;case"childList":c(t.target),e=s.handleChildList(t.target);break;case"attributes":c(t.target),e=s.handleAttributes(t.target)}u(e)}l.refreshAll()}})),d=a.targetElement||document.body;return t=!0,l.run(e),c(d),u(s.handleChildList(d)),g.observe(d,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),g.disconnect()},elementRegistry:l,wrapper:o}}return Object.freeze({run(t){e=o(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null===(a=null==e?void 0:(n=e.elementRegistry).forEachElement)||void 0===a||a.call(n,t)},highlight(t,n){const a=(null==e?void 0:e.elementRegistry.findAll(t,n))||[];return a.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){a.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}},findPositions(t,n){const o=(null==e?void 0:e.elementRegistry.findAll(t,n))||[],r=[];return o.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),o.forEach((e=>{const o=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{Q({key:t,ns:a(n)},{key:e.key,ns:a(e.ns)})&&r.push({position:{x:o.x,y:o.y,width:o.width,height:o.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),r},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}const re=["",""],ie=RegExp(`([${re.join("")}]{9})+`,"gu");function se(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=>re[Number(e)])).join("")}function le(e){const t=Array.from(e).map((e=>re.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 ue(){const e=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]})}();return Object.freeze({unwrap(t){const n=[],a=function(e){var t;const n=null===(t=e.match(ie))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(le))||[]}(t);a.forEach((t=>{const[a]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(t),o=e.numberToValue(a),{k:r,d:i,n:s}=(l=o,JSON.parse(l||"{}"));var l;n.push({key:r,defaultValue:i,ns:s})}));const o=function(e){return e.replace(ie,"")}(t);return{text:o,keys:n}},wrap({key:t,defaultValue:n,translation:a,ns:o}){const r=function(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}({key:t,ns:o,defaultValue:n}),i=e.valueToNumber(r),s=a||"",l=se(String.fromCodePoint(i));return"string"==typeof s?s+l:s},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${re[0]}${re[0]}') or contains(., '${re[1]}${re[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${re[0]}${re[0]}') or contains(., '${re[1]}${re[0]}')]`})}function ce(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function ge({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:o,ns:r}=function(e){let t=!1,n="",a="",o="KEY";const r={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{r.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",r.params[a]=n,n=""):(o="PARAM_VALUE",a=n,n=""):(o="PARAM_NAME",r.defaultValue=n,n=""):(o="PARAM_NAME",r.key=n,n=""):(o="DEFAULT_VALUE",i(n),n=""):(o="NAMESPACE",r.key=n,n=""):(o="DEFAULT_VALUE",r.key=n,n=""):t=!0;return"KEY"===o&&(r.key=n),"DEFAULT_VALUE"===o&&(r.defaultValue=n),"PARAM_VALUE"===o&&(r.params[a]=n),"NAMESPACE"===o&&i(n),r}(e);return{translated:n({key:t,params:a,defaultValue:o,ns:r,noWrap:!0}),key:t,params:a,defaultValue:o,ns:r}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e){return"string"==typeof e?e.replace(/[,:|\\]/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:o,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${r(e)}:${r(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==o?`,${r(o)}`:"",u="string"==typeof i?[i]:i,c=(null==u?void 0:u.length)?`|${u.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${c}${l}${s}${t}`},unwrap(n){const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,l=!1,u=0,c="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(c+=f.substr(u,d-u),u=d+t.length,"\\"===e){if(!ce(d,n)){c+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,c+=e+p.translated}return c+=n.substring(u),l?{text:c,keys:i}:{text:n,keys:[]}},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${e}') and contains(., '${t}')]`,getAttributeXPath:({tag:n,attribute:a})=>`descendant-or-self::${n}/@${a}[contains(., '${e}') and contains(., '${t}')]`})}const de="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function fe(e){const t=de.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function pe(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|fe(e[i]),n+=5,n>=8&&(r[o++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+o));return a}(r.buffer)}function ve(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=pe(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}function he({message:e,recievingMessage:t,data:n,attempts:a=1}){let o=!1;const r=()=>new Promise(((a,o)=>{const r=function(e,t){const n=n=>{var a,o;e.includes(null===(a=n.data)||void 0===a?void 0:a.type)&&t(null===(o=n.data)||void 0===o?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(i),s(),a(e)}));window.postMessage({type:e,data:n},window.origin);const i=setTimeout((function(){s(),o()}),300);function s(){r.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<a;e++){if(o)return new Promise((()=>{}));try{return await r()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}const me="tolgee-in-context-tools.umd.min.js",be="@tolgee/in-context-tools",ye="InContextTools",Ee="https://cdn.jsdelivr.net/npm";let Le=null;function Oe(e){var t;return Le||(Le=(t=`${Ee}/@tolgee/web@${e}/dist/${me}`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window[be][ye]))),Le}const we="__tolgee_apiKey",ke="__tolgee_apiUrl";function Ae(){const e=sessionStorage.getItem(we)||void 0,t=sessionStorage.getItem(ke)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function je(){sessionStorage.removeItem(we),sessionStorage.removeItem(ke)}exports.BrowserExtensionPlugin=()=>e=>e,"undefined"!=typeof window&&"undefined"!=typeof sessionStorage&&(exports.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=he({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(je)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Ae()&&(async()=>{const e=await Oe("5.9.2-prerelease.41828ff8.0");return t=>{const n=Ae();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 xe="__tolgee_currentLanguage";function Te(e){return e.endsWith("/")?e.slice(0,-1):e}const Pe={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${Te(n)}/${e}/${t}.json`:`${Te(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Ne(e){const t=Object.assign(Object.assign(Object.assign({},Pe),e),{headers:Object.assign(Object.assign({},Pe.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:a,getData:o,headers:r}=t,i=function(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 o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}(t,["prefix","getPath","getData","headers"]);return{getRecord({namespace:e,language:t}){const s=a({namespace:e,language:t,prefix:n});return fetch(s,Object.assign({headers:r},i)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return o(e)}))}}}exports.BackendFetch=e=>(t,n)=>(n.addBackend(Ne(e)),t),exports.DEVTOOLS_ID=F,exports.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o}){var r;const i=null!==(r=ve(t))&&void 0!==r?r:o;let s=void 0!==i?`${e}/v2/projects/${i}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(s+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return fetch(s,{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),exports.DevTools=()=>e=>e,exports.FormatSimple=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>U(e,t)}),e),exports.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){Y("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=a(window.navigator.language);return e.find((e=>a(e)===o))||void 0}}),e),exports.LanguageStorage=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(Y("LanguageStorage"),localStorage.getItem(xe)||void 0),setLanguage(e){Y("LanguageStorage"),localStorage.setItem(xe,e)}}),e),exports.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=oe();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=ge({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(Object.assign(Object.assign({},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&&q(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=oe();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=ue();e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),exports.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",exports.TOLGEE_ATTRIBUTE_NAME=V,exports.TOLGEE_RESTRICT_ATTRIBUTE=M,exports.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=B,exports.Tolgee=function(){return w().use(exports.BrowserExtensionPlugin())},exports.TolgeeCore=w,exports.getFallback=a,exports.getFallbackArray=o,exports.getProjectIdFromApiKey=ve,exports.getTranslateProps=L; | ||
"use strict";function e(e){return Boolean(e&&"function"==typeof e.then)}function t(t,n){return e(t)?Promise.resolve(t).then(n):n(t)}function n(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 a(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function o(e){return a(e)||[]}function r(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?o(t):o(null==t?void 0:t[e]);var n}function i(e){return Array.from(new Set(e))}function s(e){return e?e.replace(/\/+$/,""):e}function l(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 u(e,t,n){const a=new Set,r=new Set;let i=[];function s(){if(0===i.length)return;const e=i;i=[],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()&&(i.push(t),n?setTimeout(s,0):s())},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=>(o(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}Object.defineProperty(exports,"__esModule",{value:!0});const c=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):c(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},g=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},d=({language:e,namespace:t})=>t?`${e}:${t}`:e;function f(e,t,n,a,r,s,l){const u=new Map,f=new Map;let p={},v=0;function h(t,n,a){const o=d(t);f.set(o,{data:c(n),version:a}),e.emit(t)}function m(e){let n;if(!n){const t=p[d(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}const b=Object.freeze({addStaticData(e){e&&(p=Object.assign(Object.assign({},p),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=g(e),a=f.get(e);a&&0!==a.version||h(n,t,0)}})))},invalidate(){u.clear(),v+=1},addRecord(e,t){h(e,t,v)},exists(e,t=!1){const n=f.get(d(e));return n&&t?n.version===v:Boolean(n)},getRecord(e){var t;return null===(t=f.get(d(a(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=f.get(d(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=f.get(d({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return i(e)},getTranslationFallback(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=f.get(d({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var o;const r=null===(o=f.get(d(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(r())return!0;if(void 0===e)return u.size>0;const t=o(e);return Boolean(Array.from(u.keys()).find((e=>t.includes(g(e).namespace))))},isLoading(e,t){const n=o(t);return Boolean(r()||Array.from(u.keys()).find((t=>{const a=g(t);return(!n.length||n.includes(a.namespace))&&!b.exists({namespace:a.namespace,language:e})})))},async loadRecords(e,t){const o=e.map((e=>{const o=a(e),r=d(o),i=u.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const s=function(e,t){var a;let o;return t&&(o=null===(a=n(e))||void 0===a?void 0:a.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),m(e))))),o||(o=m(e)),o}(o,t)||Promise.resolve(void 0);return u.set(r,s),{new:!0,promise:s,keyObject:o,cacheKey:r}}));s.notify(),l.notify();const r=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=u.get(e.cacheKey)!==e.promise;if(e.new&&!n){u.delete(e.cacheKey);const n=r[t];n?b.addRecord(e.keyObject,n):b.getRecord(e.keyObject)||b.addRecord(e.keyObject,{})}})),s.notify(),l.notify(),o.map((e=>b.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(f.entries()).map((([e,t])=>Object.assign(Object.assign({},g(e)),{data:t.data})))});return b}function p(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 o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}const v="invalid",h={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"]},observerType:"invisible",onFormatError:v,apiUrl:"https://app.tolgee.io"},m=(...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 b(e,t){const n=m(h,null==t?void 0:t.initialOptions,e);return n.apiUrl=s(n.apiUrl),{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 y(n,a,o,r,i,s){const l={ui:void 0},u={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},c=async({keysAndDefaults:e,event:t})=>{var n;const a=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,ns:r({key:e,ns:t}),translation:i({key:e,ns:t})})));null===(n=u.ui)||void 0===n||n.handleElementClick(a,t)},g=(e,t)=>{var n;return(null===(n=u.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function d(e){const t=i({key:e.key,ns:e.ns});return A.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function f(e){u.observer=null==e?void 0:e()}function h(){return Boolean(u.observer)}function m(e){e&&u.formatters.push(e)}function b(e){u.finalFormatter=e}function y(e){l.ui=e}function E(){return Boolean(l.ui)}function L(e){u.languageStorage=e}function O(e){u.languageDetector=e}function w(e){e&&u.backends.push(e)}function k(e){u.devBackend=e}const A=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:b,addFormatter:m,setObserver:f,hasObserver:h,setUi:y,hasUi:E,setDevBackend:k,addBackend:w,setLanguageDetector:O,setLanguageStorage:L}))},run(){var e,t;const{apiKey:n,apiUrl:o,projectId:r,observerOptions:i}=a();u.ui=null===(e=l.ui)||void 0===e?void 0:e.call(l,{apiKey:n,apiUrl:o,projectId:r,highlight:A.highlight,changeTranslation:s,findPositions:g}),null===(t=u.observer)||void 0===t||t.run({mouseHighlight:!0,options:i,translate:d,onClick:c})},stop(){var e;u.ui=void 0,null===(e=u.observer)||void 0===e||e.stop()},getLanguageStorage:()=>u.languageStorage,getInitialLanguage(){var e;const n=o();return t(null===(e=u.languageStorage)||void 0===e?void 0:e.getLanguage(),(e=>n&&!n.includes(e)||!e?function(){if(!u.languageDetector)return;const e=o();return u.languageDetector.getLanguage({availableLanguages:e})}():e))},setStoredLanguage(e){var t;null===(t=u.languageStorage)||void 0===t||t.setLanguage(e)},getDevBackend:()=>u.devBackend,getBackendRecord:({language:t,namespace:n})=>{for(const a of u.backends){const o=a.getRecord({language:t,namespace:n});if(e(o))return null==o?void 0:o.catch((e=>(console.error(e),{})));if(void 0!==o)return o}},getBackendDevRecord:({language:e,namespace:t})=>{var n;const{apiKey:o,apiUrl:r,projectId:i}=a();return null===(n=u.devBackend)||void 0===n?void 0:n.getRecord({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:t})},getLanguageDetector:()=>u.languageDetector,retranslate(){var e;null===(e=u.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,a;return(null===(a=null===(n=u.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return u.observer?null===(t=u.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return u.observer?null===(t=u.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(A.getDevBackend()),formatTranslation(e){var t,{formatEnabled:o}=e,r=p(e,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:c,params:g,orEmpty:d,ns:f}=r,h=s||l;let m=h||(d?"":i);const b=n(),y=o||!(null===(t=u.observer)||void 0===t?void 0:t.outputNotFormattable),E=e=>u.observer&&!c?u.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:f}):e;m=E(m);try{if(h&&b&&y)for(const e of u.formatters)m=e.format({translation:m,language:b,params:g});u.finalFormatter&&h&&b&&y&&(m=u.finalFormatter.format({translation:m,language:b,params:g}))}catch(e){console.error(e);const t=("string"==typeof(L=e)?L:"string"==typeof(null==L?void 0:L.message)?L.message:void 0)||v,n=a().onFormatError,o=typeof n;m="string"===o?n:"function"===o?n(t,r):v,m=E(m)}var L;return m}});return A}const E=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const L=(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:o,language:r}=e,i=p(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:r};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function O({options:a}){const c=function(e,t){let n=!0;function a(){return n}const o=Object.freeze({onPendingLanguageChange:l(a),onLanguageChange:l(a),onLoadingChange:l(a),onFetchingChange:l(a),onInitialLoaded:l(a),onRunningChange:l(a),onCacheChange:l(a),onUpdate:u(a,e,t),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.onPendingLanguageChange.listen(t);case"language":return o.onLanguageChange.listen(t);case"loading":return o.onLoadingChange.listen(t);case"fetching":return o.onFetchingChange.listen(t);case"initialLoad":return o.onInitialLoaded.listen(t);case"running":return o.onRunningChange.listen(t);case"cache":return o.onCacheChange.listen(t);case"update":return o.onUpdate.listen(t)}}});return o.onInitialLoaded.listen((()=>o.onUpdate.emit())),o.onLanguageChange.listen((()=>o.onUpdate.emit())),o.onCacheChange.listen((({value:e})=>o.onUpdate.emit([e.namespace],!0))),o}(O,w),d=E(!1,(()=>m.isFetching()),c.onFetchingChange.emit),p=E(!1,(()=>R.isLoading()),c.onLoadingChange.emit),v=function(e,t,n){let a,l=b();const u=Object.freeze({init(e){l=b(e,l)},isRunning:()=>l.isRunning,setRunning(e){l.isRunning!==e&&(l.isRunning=e,n.emit(e))},isInitialLoading:()=>l.isInitialLoading,setInitialLoading(e){l.isInitialLoading=e},getLanguage:()=>l.language||l.initialOptions.language,setLanguage(t){l.language!==t&&(l.language=t,e.emit(t))},getPendingLanguage:()=>l.pendingLanguage||u.getLanguage(),setPendingLanguage(e){l.pendingLanguage!==e&&(l.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},l.initialOptions),a),addActiveNs(e){o(e).forEach((e=>{const t=l.activeNamespaces.get(e);void 0!==t?l.activeNamespaces.set(e,t+1):l.activeNamespaces.set(e,1)}))},removeActiveNs(e){o(e).forEach((e=>{const t=l.activeNamespaces.get(e);void 0!==t&&t>1?l.activeNamespaces.set(e,t-1):l.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>i([...l.initialOptions.ns||[l.initialOptions.defaultNs],...o(l.initialOptions.fallbackNs),...l.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||u.getLanguage();return t?i([t,...r(t,l.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>o(l.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?l.initialOptions.defaultNs:e,getAvailableLanguages(){if(l.initialOptions.availableLanguages)return l.initialOptions.availableLanguages;if(l.initialOptions.staticData){const e=Object.keys(l.initialOptions.staticData).map((e=>g(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?u.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:s(e.apiUrl)}):void 0}});return u}(c.onLanguageChange,c.onPendingLanguageChange,c.onRunningChange),h=y(v.getLanguage,v.getInitialOptions,v.getAvailableLanguages,(function({key:e,ns:t}){const n=v.getFallbackLangs(),a=k(t||void 0);return m.getTranslationNs(a,n,e)}),P,j),m=f(c.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,v.withDefaultNs,v.isInitialLoading,d,p);function O(){return v.getFallbackNs()}function w(e){return v.getDefaultNs(e)}function k(e){return[...o(w(e)),...O()]}function A(e){return[...o(e||w()),...v.getRequiredNamespaces()]}function j(e,t,n){const a=v.withDefaultNs(e),o=m.getTranslation(a,t);return m.changeTranslation(a,t,n),{revert(){m.changeTranslation(a,t,o)}}}function x(e){v.init(e),m.addStaticData(v.getInitialOptions().staticData)}function T(e,n){const a=function(e,t){const n=v.getFallbackLangs(e),a=A(t),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}(e,n);if(a.length)return t(R.loadRecords(a),(()=>{}))}function P({key:e,ns:t,language:n}){const a=k(t||void 0),o=v.getFallbackLangs(n);return m.getTranslationFallback(a,o,e)}function N(){const n=t(function(){if(v.getLanguage())return;return t(h.getInitialLanguage(),(e=>{const t=e||v.getInitialOptions().defaultLanguage;t&&v.setLanguage(t)}))}(),(()=>T()));if(e(n))return v.setInitialLoading(!0),d.notify(),p.notify(),Promise.resolve(n).then((()=>{v.setInitialLoading(!1),d.notify(),p.notify(),c.onInitialLoaded.emit()}));c.onInitialLoaded.emit()}a&&x(a),c.onUpdate.listen((()=>{v.isRunning()&&h.retranslate()}));const R=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},c),v),h),m),{init:x,getTranslation:P,changeTranslation:j,async changeLanguage(e){v.getPendingLanguage()===e&&v.getLanguage()===e||(v.setPendingLanguage(e),v.isRunning()&&await T(e),e===v.getPendingLanguage()&&(v.setLanguage(e),h.setStoredLanguage(e)))},async addActiveNs(e,t){t||v.addActiveNs(e),v.isRunning()&&await T(void 0,e)},loadRecords:e=>m.loadRecords(e,R.isDev()),loadRecord:async e=>(await R.loadRecords([e]))[0],isLoading:e=>m.isLoading(v.getLanguage(),e),isLoaded(e){const t=v.getLanguage();if(!t)return!1;const n=v.getFallbackLangs(t),a=A(e),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=L(...e),n=P(t);return h.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(v.getInitialOptions().apiKey&&v.getInitialOptions().apiUrl),run(){let e;return function(){if((h.getLanguageDetector()||h.getLanguageStorage())&&!v.getAvailableLanguages())throw new Error(n("availableLanguages"));if(!v.getLanguage()&&!v.getInitialOptions().defaultLanguage)throw new Error(n(["defaultLanguage","language"]))}(),v.isRunning()||(R.isDev()&&m.invalidate(),v.setRunning(!0),h.run(),e=N()),Promise.resolve(e)},stop(){v.isRunning()&&(h.stop(),v.setRunning(!1))}}));return R}const w=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=m(e.options,n),t),init(t){const n=function(e){const t=O({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),n&&t.run()}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,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,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}(m(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},k=0,A=1,j=2;class x extends Error{constructor(e,t,n){let a;a=e===k?"Empty parameter":e===A?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function T(e){return/\s/.test(e)}const P=0,N=1,R=2,S=3,C=4,D=new Set([R,N,P]),I="'",$=new Set(["{","}",I]),_=e=>/[0-9a-zA-Z_]/.test(e);function U(e,t){const[n,a]=function(e){let t=P,n="",a="",o="";const r=[],i=[];let s=0;function l(t){throw new x(t,s,e)}const u=()=>{r.push(n),n=""},c=()=>{""===a&&l(k),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case P:o===I?(n+=o,t=N):"{"===o?(u(),t=S):(n+=o,t=P);break;case N:$.has(o)?(n=n.slice(0,-1)+o,t=R):(n+=o,t=P);break;case R:o===I?t=P:(n+=o,t=R);break;case S:"}"===o?(c(),t=P):T(o)?""!==a&&(c(),t=C):(_(o)||l(A),a+=o,t=S);break;case C:"}"==o?t=P:T(o)?t=C:l(A)}return D.has(t)||l(j),u(),[r,i]}(e),o=[n[0]];for(let r=1;r<n.length;r++){const i=null==t?void 0:t[a[r-1]];if(void 0===i)throw new Error(`Missing parameter "${a[r-1]}" in "${e}"`);o.push(String(i)),o.push(n[r])}return o.join("")}const F="__tolgee_dev_tools",B="data-tolgee-key-only",M="data-tolgee-restricted",V="_tolgee",z="_tolgee-highlighter";function K(){var e,t;return void 0===(null===(t=null===(e=globalThis.window)||void 0===e?void 0:e.document)||void 0===t?void 0:t.createElement)}function Y(e){if(K())throw new Error(`${e}: Can't run on the server`)}function G(e,t){return{oldTextContent:e,keys:t}}const W={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function X({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(z),Object.entries(W).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const r=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=r.top-t+"px",o.style.left=r.left-t+"px",o.style.width=r.width+"px",o.style.height=r.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,a)}})}function H(e,t){var n;const a=function(e){switch(e.nodeType){case Node.ATTRIBUTE_NODE:return e.ownerElement||void 0;case Node.TEXT_NODE:return e.parentElement||void 0;case Node.DOCUMENT_NODE:case Node.ELEMENT_NODE:return e;default:return}}(t),o=[];if(!a)return o;const r=null===document||void 0===document?void 0:document.evaluate(e,a,void 0,XPathResult.ANY_TYPE);let i;for(;i=null===(n=null==r?void 0:r.iterateNext)||void 0===n?void 0:n.call(r);)o.push(i);return o}function J(e){return e.textContent}function q(e,t){e.textContent=t}function Z(e,t){if(e.contains(t))return!0;if(t instanceof Attr){const n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}function Q(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null===(n=e.ns)||void 0===n?void 0:n.findIndex((e=>{var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return a&&o}const ee={capture:!0},te={capture:!0,passive:!0};function ne({highlightKeys:e,elementStore:t,onClick:n,options:a}){var o,r;let i,s,l=new Set;const u=(null===(o=a.targetElement)||void 0===o?void 0:o.getRootNode())||document,c=(null===(r=a.targetElement)||void 0===r?void 0:r.ownerDocument)||document;function g(){var e;const n=t.get(i);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),i=void 0)}function d(){const e=s;let n;if(e&&L()){const a=u.elementFromPoint(e.x,e.y);a&&(n=function(e){return E(e,(e=>t.get(e)))}(a))}!function(e){var n;if(i!==e){g();const a=t.get(e);a&&(a.preventClean=!0,null===(n=a.highlight)||void 0===n||n.call(a),i=e)}}(n)}function f(e){var t;L()&&(t=e.target,!Boolean(E(t,(e=>e.id===F))))&&(e.stopPropagation(),e.preventDefault())}function p(e){var t;t={x:e.clientX,y:e.clientY},s=t,d()}function v(){l=new Set,d()}function h(e){const t=e.key;void 0!==t&&l.add(t),d()}function m(e){l.delete(e.key),d()}function b(){var e;const n=t.get(i);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)}function y(e){f(e),L()&&i&&(n(e,i),g())}function E(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?E(e.parentElement,t):void 0}function L(){for(const t of e)if(!l.has(t))return!1;return!0}return Object.freeze({stop(){c.removeEventListener("blur",v,ee),c.removeEventListener("keydown",h,ee),c.removeEventListener("keyup",m,ee),c.removeEventListener("mousemove",p,te),c.removeEventListener("scroll",b,te),c.removeEventListener("click",y,ee),c.removeEventListener("mouseenter",f,ee),c.removeEventListener("mouseover",f,ee),c.removeEventListener("mouseout",f,ee),c.removeEventListener("mouseleave",f,ee),c.removeEventListener("mousedown",f,ee),c.removeEventListener("mouseup",f,ee)},run(){c.addEventListener("blur",v,ee),c.addEventListener("keydown",h,ee),c.addEventListener("keyup",m,ee),c.addEventListener("mousemove",p,te),c.addEventListener("scroll",b,te),c.addEventListener("click",y,ee),c.addEventListener("mouseenter",f,ee),c.addEventListener("mouseover",f,ee),c.addEventListener("mouseout",f,ee),c.addEventListener("mouseleave",f,ee),c.addEventListener("mousedown",f,ee),c.addEventListener("mouseup",f,ee)}})}function ae(e,t,n){const o=X({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=ne({highlightKeys:e.highlightKeys,elementStore:t,onClick(e,a){const o=t.get(a);n({event:e,keysAndDefaults:l(o)})},options:e});function i(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())Z(s(),t)&&(yield[t,n])}(e))}function s(){return e.targetElement||document.body}function l(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({register(n,a,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${M}]`)}(n))return;const i=n;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(V,"true")),s.nodes.set(a,r),o.initHighlighter(i,s)},forEachElement:t.forEachElement,refreshAll(){t.forEachElement(((e,n)=>{n.preventClean||(i(n),0===n.nodes.size&&function(e,n){var a;n.highlightEl&&(null===(a=n.unhighlight)||void 0===a||a.call(n)),e.removeAttribute(V),t.remove(e)}(e,n))}))},findAll(e,n){const o=[];return t.forEachElement(((t,r)=>{for(const t of r.nodes.values()){if(t.keys.find((t=>Q({key:e,ns:a(n)},{key:t.key,ns:a(t.ns)})))){o.push(r);break}}})),o},run(e){e&&r.run()},stop(){r.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||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 o({mouseHighlight:e,options:a,wrapper:o,onClick:r}){if(K())return;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){let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=H(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a},handleChildList(e){let t=[];return t=t.concat(n.handleAttributes(e)),t=t.concat(n.handleText(e)),t},handleText:e=>H(t.getTextXPath(),e)});return n}(a,o),l=ae(a,n,r);function u(e){for(const t of e){const e=J(t),n=e?o.unwrap(e):null;if(n){const{text:a,keys:o}=n;q(t,a);const r=G(e,o),s=i.getSuitableParent(t);l.register(s,t,r)}}}function c(e){H(`./descendant-or-self::*[@${B}]`,e).forEach((e=>{const t=e.getAttributeNode(B),n=i.getSuitableParent(t);l.register(n,t,{oldTextContent:"",keys:[{key:J(t)}],keyAttributeOnly:!0})}))}const g=new MutationObserver((e=>{if(t){for(const t of e){let e=[];switch(t.type){case"characterData":e=s.handleText(t.target);break;case"childList":c(t.target),e=s.handleChildList(t.target);break;case"attributes":c(t.target),e=s.handleAttributes(t.target)}u(e)}l.refreshAll()}})),d=a.targetElement||document.body;return t=!0,l.run(e),c(d),u(s.handleChildList(d)),g.observe(d,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),g.disconnect()},elementRegistry:l,wrapper:o}}return Object.freeze({run(t){e=o(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null===(a=null==e?void 0:(n=e.elementRegistry).forEachElement)||void 0===a||a.call(n,t)},highlight(t,n){const a=(null==e?void 0:e.elementRegistry.findAll(t,n))||[];return a.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){a.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}},findPositions(t,n){const o=(null==e?void 0:e.elementRegistry.findAll(t,n))||[],r=[];return o.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),o.forEach((e=>{const o=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{Q({key:t,ns:a(n)},{key:e.key,ns:a(e.ns)})&&r.push({position:{x:o.x,y:o.y,width:o.width,height:o.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),r},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}const re=["",""],ie=RegExp(`([${re.join("")}]{9})+`,"gu");function se(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=>re[Number(e)])).join("")}function le(e){const t=Array.from(e).map((e=>re.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 ue(){const e=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]})}();return Object.freeze({unwrap(t){const n=[],a=function(e){var t;const n=null===(t=e.match(ie))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(le))||[]}(t);a.forEach((t=>{const[a]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(t),o=e.numberToValue(a),{k:r,d:i,n:s}=(l=o,JSON.parse(l||"{}"));var l;n.push({key:r,defaultValue:i,ns:s})}));const o=function(e){return e.replace(ie,"")}(t);return{text:o,keys:n}},wrap({key:t,defaultValue:n,translation:a,ns:o}){const r=function(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}({key:t,ns:o,defaultValue:n}),i=e.valueToNumber(r),s=a||"",l=se(String.fromCodePoint(i));return"string"==typeof s?s+l:s},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${re[0]}${re[0]}') or contains(., '${re[1]}${re[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${re[0]}${re[0]}') or contains(., '${re[1]}${re[0]}')]`})}function ce(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function ge({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:o,ns:r}=function(e){let t=!1,n="",a="",o="KEY";const r={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{r.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",r.params[a]=n,n=""):(o="PARAM_VALUE",a=n,n=""):(o="PARAM_NAME",r.defaultValue=n,n=""):(o="PARAM_NAME",r.key=n,n=""):(o="DEFAULT_VALUE",i(n),n=""):(o="NAMESPACE",r.key=n,n=""):(o="DEFAULT_VALUE",r.key=n,n=""):t=!0;return"KEY"===o&&(r.key=n),"DEFAULT_VALUE"===o&&(r.defaultValue=n),"PARAM_VALUE"===o&&(r.params[a]=n),"NAMESPACE"===o&&i(n),r}(e);return{translated:n({key:t,params:a,defaultValue:o,ns:r,noWrap:!0}),key:t,params:a,defaultValue:o,ns:r}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e){return"string"==typeof e?e.replace(/[,:|\\]/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:o,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${r(e)}:${r(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==o?`,${r(o)}`:"",u="string"==typeof i?[i]:i,c=(null==u?void 0:u.length)?`|${u.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${c}${l}${s}${t}`},unwrap(n){const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,l=!1,u=0,c="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(c+=f.substr(u,d-u),u=d+t.length,"\\"===e){if(!ce(d,n)){c+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,c+=e+p.translated}return c+=n.substring(u),l?{text:c,keys:i}:{text:n,keys:[]}},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${e}') and contains(., '${t}')]`,getAttributeXPath:({tag:n,attribute:a})=>`descendant-or-self::${n}/@${a}[contains(., '${e}') and contains(., '${t}')]`})}const de="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function fe(e){const t=de.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function pe(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|fe(e[i]),n+=5,n>=8&&(r[o++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+o));return a}(r.buffer)}function ve(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=pe(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}function he({message:e,recievingMessage:t,data:n,attempts:a=1}){let o=!1;const r=()=>new Promise(((a,o)=>{const r=function(e,t){const n=n=>{var a,o;e.includes(null===(a=n.data)||void 0===a?void 0:a.type)&&t(null===(o=n.data)||void 0===o?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(i),s(),a(e)}));window.postMessage({type:e,data:n},window.origin);const i=setTimeout((function(){s(),o()}),300);function s(){r.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<a;e++){if(o)return new Promise((()=>{}));try{return await r()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}const me="tolgee-in-context-tools.umd.min.js",be="@tolgee/in-context-tools",ye="InContextTools",Ee="https://cdn.jsdelivr.net/npm";let Le=null;function Oe(e){var t;return Le||(Le=(t=`${Ee}/@tolgee/web@${e}/dist/${me}`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window[be][ye]))),Le}const we="__tolgee_apiKey",ke="__tolgee_apiUrl";function Ae(){const e=sessionStorage.getItem(we)||void 0,t=sessionStorage.getItem(ke)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function je(){sessionStorage.removeItem(we),sessionStorage.removeItem(ke)}exports.BrowserExtensionPlugin=()=>e=>e,"undefined"!=typeof window&&"undefined"!=typeof sessionStorage&&(exports.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=he({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(je)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Ae()&&(async()=>{const e=await Oe("5.9.2-prerelease.ce0c7097.0");return t=>{const n=Ae();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 xe="__tolgee_currentLanguage";function Te(e){return e.endsWith("/")?e.slice(0,-1):e}const Pe={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${Te(n)}/${e}/${t}.json`:`${Te(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Ne(e){const t=Object.assign(Object.assign(Object.assign({},Pe),e),{headers:Object.assign(Object.assign({},Pe.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:a,getData:o,headers:r}=t,i=function(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 o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}(t,["prefix","getPath","getData","headers"]);return{getRecord({namespace:e,language:t}){const s=a({namespace:e,language:t,prefix:n});return fetch(s,Object.assign({headers:r},i)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return o(e)}))}}}exports.BackendFetch=e=>(t,n)=>(n.addBackend(Ne(e)),t),exports.DEVTOOLS_ID=F,exports.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o}){var r;const i=null!==(r=ve(t))&&void 0!==r?r:o;let s=void 0!==i?`${e}/v2/projects/${i}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(s+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return fetch(s,{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),exports.DevTools=()=>e=>e,exports.FormatSimple=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>U(e,t)}),e),exports.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){Y("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=a(window.navigator.language);return e.find((e=>a(e)===o))||void 0}}),e),exports.LanguageStorage=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(Y("LanguageStorage"),localStorage.getItem(xe)||void 0),setLanguage(e){Y("LanguageStorage"),localStorage.setItem(xe,e)}}),e),exports.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=oe();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=ge({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(Object.assign(Object.assign({},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&&q(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=oe();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=ue();e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),exports.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",exports.TOLGEE_ATTRIBUTE_NAME=V,exports.TOLGEE_RESTRICT_ATTRIBUTE=M,exports.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=B,exports.Tolgee=function(){return w().use(exports.BrowserExtensionPlugin())},exports.TolgeeCore=w,exports.getFallback=a,exports.getFallbackArray=o,exports.getProjectIdFromApiKey=ve,exports.getTranslateProps=L; | ||
//# sourceMappingURL=tolgee-web.production.cjs.min.js.map |
@@ -1,2 +0,2 @@ | ||
function e(e){return Boolean(e&&"function"==typeof e.then)}function t(t,n){return e(t)?Promise.resolve(t).then(n):n(t)}function n(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 a(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function o(e){return a(e)||[]}function r(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?o(t):o(null==t?void 0:t[e]);var n}function i(e){return Array.from(new Set(e))}function s(e){return e?e.replace(/\/+$/,""):e}function l(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 c(e,t,n){const a=new Set,r=new Set;let i=[];function s(){if(0===i.length)return;const e=i;i=[],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()&&(i.push(t),n?setTimeout(s,0):s())},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=>(o(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}const u=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):u(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},g=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},d=({language:e,namespace:t})=>t?`${e}:${t}`:e;function f(e,t,n,a,r,s,l){const c=new Map,f=new Map;let p={},v=0;function h(t,n,a){const o=d(t);f.set(o,{data:u(n),version:a}),e.emit(t)}function m(e){let n;if(!n){const t=p[d(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}const b=Object.freeze({addStaticData(e){e&&(p=Object.assign(Object.assign({},p),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=g(e),a=f.get(e);a&&0!==a.version||h(n,t,0)}})))},invalidate(){c.clear(),v+=1},addRecord(e,t){h(e,t,v)},exists(e,t=!1){const n=f.get(d(e));return n&&t?n.version===v:Boolean(n)},getRecord(e){var t;return null===(t=f.get(d(a(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=f.get(d(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=f.get(d({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return i(e)},getTranslationFallback(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=f.get(d({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var o;const r=null===(o=f.get(d(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(r())return!0;if(void 0===e)return c.size>0;const t=o(e);return Boolean(Array.from(c.keys()).find((e=>t.includes(g(e).namespace))))},isLoading(e,t){const n=o(t);return Boolean(r()||Array.from(c.keys()).find((t=>{const a=g(t);return(!n.length||n.includes(a.namespace))&&!b.exists({namespace:a.namespace,language:e})})))},async loadRecords(e,t){const o=e.map((e=>{const o=a(e),r=d(o),i=c.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const s=function(e,t){var a;let o;return t&&(o=null===(a=n(e))||void 0===a?void 0:a.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),m(e))))),o||(o=m(e)),o}(o,t)||Promise.resolve(void 0);return c.set(r,s),{new:!0,promise:s,keyObject:o,cacheKey:r}}));s.notify(),l.notify();const r=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=c.get(e.cacheKey)!==e.promise;if(e.new&&!n){c.delete(e.cacheKey);const n=r[t];n?b.addRecord(e.keyObject,n):b.getRecord(e.keyObject)||b.addRecord(e.keyObject,{})}})),s.notify(),l.notify(),o.map((e=>b.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(f.entries()).map((([e,t])=>Object.assign(Object.assign({},g(e)),{data:t.data})))});return b}function p(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 o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}const v="invalid",h={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"]},observerType:"invisible",onFormatError:v,apiUrl:"https://app.tolgee.io"},m=(...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 b(e,t){const n=m(h,null==t?void 0:t.initialOptions,e);return n.apiUrl=s(n.apiUrl),{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 y(n,a,o,r,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,event:t})=>{var n;const a=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,ns:r({key:e,ns:t}),translation:i({key:e,ns:t})})));null===(n=c.ui)||void 0===n||n.handleElementClick(a,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=i({key:e.key,ns:e.ns});return j.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function f(e){c.observer=null==e?void 0:e()}function h(){return Boolean(c.observer)}function m(e){e&&c.formatters.push(e)}function b(e){c.finalFormatter=e}function y(e){l.ui=e}function E(){return Boolean(l.ui)}function L(e){c.languageStorage=e}function O(e){c.languageDetector=e}function w(e){e&&c.backends.push(e)}function k(e){c.devBackend=e}const j=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:b,addFormatter:m,setObserver:f,hasObserver:h,setUi:y,hasUi:E,setDevBackend:k,addBackend:w,setLanguageDetector:O,setLanguageStorage:L}))},run(){var e,t;const{apiKey:n,apiUrl:o,projectId:r,observerOptions:i}=a();c.ui=null===(e=l.ui)||void 0===e?void 0:e.call(l,{apiKey:n,apiUrl:o,projectId:r,highlight:j.highlight,changeTranslation:s,findPositions:g}),null===(t=c.observer)||void 0===t||t.run({mouseHighlight:!0,options:i,translate:d,onClick:u})},stop(){var e;c.ui=void 0,null===(e=c.observer)||void 0===e||e.stop()},getLanguageStorage:()=>c.languageStorage,getInitialLanguage(){var e;const n=o();return t(null===(e=c.languageStorage)||void 0===e?void 0:e.getLanguage(),(e=>n&&!n.includes(e)||!e?function(){if(!c.languageDetector)return;const e=o();return c.languageDetector.getLanguage({availableLanguages:e})}():e))},setStoredLanguage(e){var t;null===(t=c.languageStorage)||void 0===t||t.setLanguage(e)},getDevBackend:()=>c.devBackend,getBackendRecord:({language:t,namespace:n})=>{for(const a of c.backends){const o=a.getRecord({language:t,namespace:n});if(e(o))return null==o?void 0:o.catch((e=>(console.error(e),{})));if(void 0!==o)return o}},getBackendDevRecord:({language:e,namespace:t})=>{var n;const{apiKey:o,apiUrl:r,projectId:i}=a();return null===(n=c.devBackend)||void 0===n?void 0:n.getRecord({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:t})},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(j.getDevBackend()),formatTranslation(e){var t,{formatEnabled:o}=e,r=p(e,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:u,params:g,orEmpty:d,ns:f}=r,h=s||l;let m=h||(d?"":i);const b=n(),y=o||!(null===(t=c.observer)||void 0===t?void 0:t.outputNotFormattable),E=e=>c.observer&&!u?c.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:f}):e;m=E(m);try{if(h&&b&&y)for(const e of c.formatters)m=e.format({translation:m,language:b,params:g});c.finalFormatter&&h&&b&&y&&(m=c.finalFormatter.format({translation:m,language:b,params:g}))}catch(e){console.error(e);const t=("string"==typeof(L=e)?L:"string"==typeof(null==L?void 0:L.message)?L.message:void 0)||v,n=a().onFormatError,o=typeof n;m="string"===o?n:"function"===o?n(t,r):v,m=E(m)}var L;return m}});return j}const E=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const L=(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:o,language:r}=e,i=p(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:r};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function O({options:a}){const u=function(e,t){let n=!0;function a(){return n}const o=Object.freeze({onPendingLanguageChange:l(a),onLanguageChange:l(a),onLoadingChange:l(a),onFetchingChange:l(a),onInitialLoaded:l(a),onRunningChange:l(a),onCacheChange:l(a),onUpdate:c(a,e,t),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.onPendingLanguageChange.listen(t);case"language":return o.onLanguageChange.listen(t);case"loading":return o.onLoadingChange.listen(t);case"fetching":return o.onFetchingChange.listen(t);case"initialLoad":return o.onInitialLoaded.listen(t);case"running":return o.onRunningChange.listen(t);case"cache":return o.onCacheChange.listen(t);case"update":return o.onUpdate.listen(t)}}});return o.onInitialLoaded.listen((()=>o.onUpdate.emit())),o.onLanguageChange.listen((()=>o.onUpdate.emit())),o.onCacheChange.listen((({value:e})=>o.onUpdate.emit([e.namespace],!0))),o}(O,w),d=E(!1,(()=>m.isFetching()),u.onFetchingChange.emit),p=E(!1,(()=>R.isLoading()),u.onLoadingChange.emit),v=function(e,t,n){let a,l=b();const c=Object.freeze({init(e){l=b(e,l)},isRunning:()=>l.isRunning,setRunning(e){l.isRunning!==e&&(l.isRunning=e,n.emit(e))},isInitialLoading:()=>l.isInitialLoading,setInitialLoading(e){l.isInitialLoading=e},getLanguage:()=>l.language||l.initialOptions.language,setLanguage(t){l.language!==t&&(l.language=t,e.emit(t))},getPendingLanguage:()=>l.pendingLanguage||c.getLanguage(),setPendingLanguage(e){l.pendingLanguage!==e&&(l.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},l.initialOptions),a),addActiveNs(e){o(e).forEach((e=>{const t=l.activeNamespaces.get(e);void 0!==t?l.activeNamespaces.set(e,t+1):l.activeNamespaces.set(e,1)}))},removeActiveNs(e){o(e).forEach((e=>{const t=l.activeNamespaces.get(e);void 0!==t&&t>1?l.activeNamespaces.set(e,t-1):l.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>i([...l.initialOptions.ns||[l.initialOptions.defaultNs],...o(l.initialOptions.fallbackNs),...l.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||c.getLanguage();return t?i([t,...r(t,l.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>o(l.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?l.initialOptions.defaultNs:e,getAvailableLanguages(){if(l.initialOptions.availableLanguages)return l.initialOptions.availableLanguages;if(l.initialOptions.staticData){const e=Object.keys(l.initialOptions.staticData).map((e=>g(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?c.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:s(e.apiUrl)}):void 0}});return c}(u.onLanguageChange,u.onPendingLanguageChange,u.onRunningChange),h=y(v.getLanguage,v.getInitialOptions,v.getAvailableLanguages,(function({key:e,ns:t}){const n=v.getFallbackLangs(),a=k(t||void 0);return m.getTranslationNs(a,n,e)}),N,A),m=f(u.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,v.withDefaultNs,v.isInitialLoading,d,p);function O(){return v.getFallbackNs()}function w(e){return v.getDefaultNs(e)}function k(e){return[...o(w(e)),...O()]}function j(e){return[...o(e||w()),...v.getRequiredNamespaces()]}function A(e,t,n){const a=v.withDefaultNs(e),o=m.getTranslation(a,t);return m.changeTranslation(a,t,n),{revert(){m.changeTranslation(a,t,o)}}}function P(e){v.init(e),m.addStaticData(v.getInitialOptions().staticData)}function x(e,n){const a=function(e,t){const n=v.getFallbackLangs(e),a=j(t),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}(e,n);if(a.length)return t(R.loadRecords(a),(()=>{}))}function N({key:e,ns:t,language:n}){const a=k(t||void 0),o=v.getFallbackLangs(n);return m.getTranslationFallback(a,o,e)}function T(){const n=t(function(){if(v.getLanguage())return;return t(h.getInitialLanguage(),(e=>{const t=e||v.getInitialOptions().defaultLanguage;t&&v.setLanguage(t)}))}(),(()=>x()));if(e(n))return v.setInitialLoading(!0),d.notify(),p.notify(),Promise.resolve(n).then((()=>{v.setInitialLoading(!1),d.notify(),p.notify(),u.onInitialLoaded.emit()}));u.onInitialLoaded.emit()}a&&P(a),u.onUpdate.listen((()=>{v.isRunning()&&h.retranslate()}));const R=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},u),v),h),m),{init:P,getTranslation:N,changeTranslation:A,async changeLanguage(e){v.getPendingLanguage()===e&&v.getLanguage()===e||(v.setPendingLanguage(e),v.isRunning()&&await x(e),e===v.getPendingLanguage()&&(v.setLanguage(e),h.setStoredLanguage(e)))},async addActiveNs(e,t){t||v.addActiveNs(e),v.isRunning()&&await x(void 0,e)},loadRecords:e=>m.loadRecords(e,R.isDev()),loadRecord:async e=>(await R.loadRecords([e]))[0],isLoading:e=>m.isLoading(v.getLanguage(),e),isLoaded(e){const t=v.getLanguage();if(!t)return!1;const n=v.getFallbackLangs(t),a=j(e),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=L(...e),n=N(t);return h.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(v.getInitialOptions().apiKey&&v.getInitialOptions().apiUrl),run(){let e;return function(){if((h.getLanguageDetector()||h.getLanguageStorage())&&!v.getAvailableLanguages())throw new Error(n("availableLanguages"));if(!v.getLanguage()&&!v.getInitialOptions().defaultLanguage)throw new Error(n(["defaultLanguage","language"]))}(),v.isRunning()||(R.isDev()&&m.invalidate(),v.setRunning(!0),h.run(),e=T()),Promise.resolve(e)},stop(){v.isRunning()&&(h.stop(),v.setRunning(!1))}}));return R}const w=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=m(e.options,n),t),init(t){const n=function(e){const t=O({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),n&&t.run()}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,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,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}(m(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},k=0,j=1,A=2;class P extends Error{constructor(e,t,n){let a;a=e===k?"Empty parameter":e===j?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function x(e){return/\s/.test(e)}const N=0,T=1,R=2,C=3,S=4,$=new Set([R,T,N]),D="'",I=new Set(["{","}",D]),U=e=>/[0-9a-zA-Z_]/.test(e);function _(e,t){const[n,a]=function(e){let t=N,n="",a="",o="";const r=[],i=[];let s=0;function l(t){throw new P(t,s,e)}const c=()=>{r.push(n),n=""},u=()=>{""===a&&l(k),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case N:o===D?(n+=o,t=T):"{"===o?(c(),t=C):(n+=o,t=N);break;case T:I.has(o)?(n=n.slice(0,-1)+o,t=R):(n+=o,t=N);break;case R:o===D?t=N:(n+=o,t=R);break;case C:"}"===o?(u(),t=N):x(o)?""!==a&&(u(),t=S):(U(o)||l(j),a+=o,t=C);break;case S:"}"==o?t=N:x(o)?t=S:l(j)}return $.has(t)||l(A),c(),[r,i]}(e),o=[n[0]];for(let r=1;r<n.length;r++){const i=null==t?void 0:t[a[r-1]];if(void 0===i)throw new Error(`Missing parameter "${a[r-1]}" in "${e}"`);o.push(String(i)),o.push(n[r])}return o.join("")}const F=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>_(e,t)}),e),M="__tolgee_dev_tools",V="__tolgee_preferredLanguages",z="data-tolgee-key-only",B="data-tolgee-restricted",K="_tolgee",W="_tolgee-highlighter";function Y(){var e,t;return void 0===(null===(t=null===(e=globalThis.window)||void 0===e?void 0:e.document)||void 0===t?void 0:t.createElement)}function X(e){if(Y())throw new Error(`${e}: Can't run on the server`)}function G(e,t){return{oldTextContent:e,keys:t}}const H={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function J({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(W),Object.entries(H).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const r=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=r.top-t+"px",o.style.left=r.left-t+"px",o.style.width=r.width+"px",o.style.height=r.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,a)}})}function q(e,t){var n;const a=function(e){switch(e.nodeType){case Node.ATTRIBUTE_NODE:return e.ownerElement||void 0;case Node.TEXT_NODE:return e.parentElement||void 0;case Node.DOCUMENT_NODE:case Node.ELEMENT_NODE:return e;default:return}}(t),o=[];if(!a)return o;const r=null===document||void 0===document?void 0:document.evaluate(e,a,void 0,XPathResult.ANY_TYPE);let i;for(;i=null===(n=null==r?void 0:r.iterateNext)||void 0===n?void 0:n.call(r);)o.push(i);return o}function Z(e){return e.textContent}function Q(e,t){e.textContent=t}function ee(e,t){if(e.contains(t))return!0;if(t instanceof Attr){const n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}function te(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null===(n=e.ns)||void 0===n?void 0:n.findIndex((e=>{var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return a&&o}const ne={capture:!0},ae={capture:!0,passive:!0};function oe({highlightKeys:e,elementStore:t,onClick:n,options:a}){var o,r;let i,s,l=new Set;const c=(null===(o=a.targetElement)||void 0===o?void 0:o.getRootNode())||document,u=(null===(r=a.targetElement)||void 0===r?void 0:r.ownerDocument)||document;function g(){var e;const n=t.get(i);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),i=void 0)}function d(){const e=s;let n;if(e&&L()){const a=c.elementFromPoint(e.x,e.y);a&&(n=function(e){return E(e,(e=>t.get(e)))}(a))}!function(e){var n;if(i!==e){g();const a=t.get(e);a&&(a.preventClean=!0,null===(n=a.highlight)||void 0===n||n.call(a),i=e)}}(n)}function f(e){var t;L()&&(t=e.target,!Boolean(E(t,(e=>e.id===M))))&&(e.stopPropagation(),e.preventDefault())}function p(e){var t;t={x:e.clientX,y:e.clientY},s=t,d()}function v(){l=new Set,d()}function h(e){const t=e.key;void 0!==t&&l.add(t),d()}function m(e){l.delete(e.key),d()}function b(){var e;const n=t.get(i);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)}function y(e){f(e),L()&&i&&(n(e,i),g())}function E(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?E(e.parentElement,t):void 0}function L(){for(const t of e)if(!l.has(t))return!1;return!0}return Object.freeze({stop(){u.removeEventListener("blur",v,ne),u.removeEventListener("keydown",h,ne),u.removeEventListener("keyup",m,ne),u.removeEventListener("mousemove",p,ae),u.removeEventListener("scroll",b,ae),u.removeEventListener("click",y,ne),u.removeEventListener("mouseenter",f,ne),u.removeEventListener("mouseover",f,ne),u.removeEventListener("mouseout",f,ne),u.removeEventListener("mouseleave",f,ne),u.removeEventListener("mousedown",f,ne),u.removeEventListener("mouseup",f,ne)},run(){u.addEventListener("blur",v,ne),u.addEventListener("keydown",h,ne),u.addEventListener("keyup",m,ne),u.addEventListener("mousemove",p,ae),u.addEventListener("scroll",b,ae),u.addEventListener("click",y,ne),u.addEventListener("mouseenter",f,ne),u.addEventListener("mouseover",f,ne),u.addEventListener("mouseout",f,ne),u.addEventListener("mouseleave",f,ne),u.addEventListener("mousedown",f,ne),u.addEventListener("mouseup",f,ne)}})}function re(e,t,n){const o=J({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=oe({highlightKeys:e.highlightKeys,elementStore:t,onClick(e,a){const o=t.get(a);n({event:e,keysAndDefaults:l(o)})},options:e});function i(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())ee(s(),t)&&(yield[t,n])}(e))}function s(){return e.targetElement||document.body}function l(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({register(n,a,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${B}]`)}(n))return;const i=n;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(K,"true")),s.nodes.set(a,r),o.initHighlighter(i,s)},forEachElement:t.forEachElement,refreshAll(){t.forEachElement(((e,n)=>{n.preventClean||(i(n),0===n.nodes.size&&function(e,n){var a;n.highlightEl&&(null===(a=n.unhighlight)||void 0===a||a.call(n)),e.removeAttribute(K),t.remove(e)}(e,n))}))},findAll(e,n){const o=[];return t.forEachElement(((t,r)=>{for(const t of r.nodes.values()){if(t.keys.find((t=>te({key:e,ns:a(n)},{key:t.key,ns:a(t.ns)})))){o.push(r);break}}})),o},run(e){e&&r.run()},stop(){r.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||n.call(t))}))}})}function ie(){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 o({mouseHighlight:e,options:a,wrapper:o,onClick:r}){if(Y())return;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){let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=q(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a},handleChildList(e){let t=[];return t=t.concat(n.handleAttributes(e)),t=t.concat(n.handleText(e)),t},handleText:e=>q(t.getTextXPath(),e)});return n}(a,o),l=re(a,n,r);function c(e){for(const t of e){const e=Z(t),n=e?o.unwrap(e):null;if(n){const{text:a,keys:o}=n;Q(t,a);const r=G(e,o),s=i.getSuitableParent(t);l.register(s,t,r)}}}function u(e){q(`./descendant-or-self::*[@${z}]`,e).forEach((e=>{const t=e.getAttributeNode(z),n=i.getSuitableParent(t);l.register(n,t,{oldTextContent:"",keys:[{key:Z(t)}],keyAttributeOnly:!0})}))}const g=new MutationObserver((e=>{if(t){for(const t of e){let e=[];switch(t.type){case"characterData":e=s.handleText(t.target);break;case"childList":u(t.target),e=s.handleChildList(t.target);break;case"attributes":u(t.target),e=s.handleAttributes(t.target)}c(e)}l.refreshAll()}})),d=a.targetElement||document.body;return t=!0,l.run(e),u(d),c(s.handleChildList(d)),g.observe(d,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),g.disconnect()},elementRegistry:l,wrapper:o}}return Object.freeze({run(t){e=o(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null===(a=null==e?void 0:(n=e.elementRegistry).forEachElement)||void 0===a||a.call(n,t)},highlight(t,n){const a=(null==e?void 0:e.elementRegistry.findAll(t,n))||[];return a.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){a.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}},findPositions(t,n){const o=(null==e?void 0:e.elementRegistry.findAll(t,n))||[],r=[];return o.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),o.forEach((e=>{const o=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{te({key:t,ns:a(n)},{key:e.key,ns:a(e.ns)})&&r.push({position:{x:o.x,y:o.y,width:o.width,height:o.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),r},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}const se=["",""],le=RegExp(`([${se.join("")}]{9})+`,"gu");function ce(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=>se[Number(e)])).join("")}function ue(e){const t=Array.from(e).map((e=>se.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 ge(){const e=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]})}();return Object.freeze({unwrap(t){const n=[],a=function(e){var t;const n=null===(t=e.match(le))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(ue))||[]}(t);a.forEach((t=>{const[a]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(t),o=e.numberToValue(a),{k:r,d:i,n:s}=(l=o,JSON.parse(l||"{}"));var l;n.push({key:r,defaultValue:i,ns:s})}));const o=function(e){return e.replace(le,"")}(t);return{text:o,keys:n}},wrap({key:t,defaultValue:n,translation:a,ns:o}){const r=function(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}({key:t,ns:o,defaultValue:n}),i=e.valueToNumber(r),s=a||"",l=ce(String.fromCodePoint(i));return"string"==typeof s?s+l:s},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${se[0]}${se[0]}') or contains(., '${se[1]}${se[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${se[0]}${se[0]}') or contains(., '${se[1]}${se[0]}')]`})}function de(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function fe({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:o,ns:r}=function(e){let t=!1,n="",a="",o="KEY";const r={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{r.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",r.params[a]=n,n=""):(o="PARAM_VALUE",a=n,n=""):(o="PARAM_NAME",r.defaultValue=n,n=""):(o="PARAM_NAME",r.key=n,n=""):(o="DEFAULT_VALUE",i(n),n=""):(o="NAMESPACE",r.key=n,n=""):(o="DEFAULT_VALUE",r.key=n,n=""):t=!0;return"KEY"===o&&(r.key=n),"DEFAULT_VALUE"===o&&(r.defaultValue=n),"PARAM_VALUE"===o&&(r.params[a]=n),"NAMESPACE"===o&&i(n),r}(e);return{translated:n({key:t,params:a,defaultValue:o,ns:r,noWrap:!0}),key:t,params:a,defaultValue:o,ns:r}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e){return"string"==typeof e?e.replace(/[,:|\\]/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:o,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${r(e)}:${r(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==o?`,${r(o)}`:"",c="string"==typeof i?[i]:i,u=(null==c?void 0:c.length)?`|${c.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${u}${l}${s}${t}`},unwrap(n){const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,l=!1,c=0,u="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(u+=f.substr(c,d-c),c=d+t.length,"\\"===e){if(!de(d,n)){u+=r;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:[]}},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${e}') and contains(., '${t}')]`,getAttributeXPath:({tag:n,attribute:a})=>`descendant-or-self::${n}/@${a}[contains(., '${e}') and contains(., '${t}')]`})}const pe=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=ie();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=fe({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(Object.assign(Object.assign({},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&&Q(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=ie();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=ge();e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),ve="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function he(e){const t=ve.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function me(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|he(e[i]),n+=5,n>=8&&(r[o++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+o));return a}(r.buffer)}function be(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=me(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}const ye=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o}){var r;const i=null!==(r=be(t))&&void 0!==r?r:o;let s=void 0!==i?`${e}/v2/projects/${i}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(s+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return fetch(s,{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 Ee({message:e,recievingMessage:t,data:n,attempts:a=1}){let o=!1;const r=()=>new Promise(((a,o)=>{const r=function(e,t){const n=n=>{var a,o;e.includes(null===(a=n.data)||void 0===a?void 0:a.type)&&t(null===(o=n.data)||void 0===o?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(i),s(),a(e)}));window.postMessage({type:e,data:n},window.origin);const i=setTimeout((function(){s(),o()}),300);function s(){r.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<a;e++){if(o)return new Promise((()=>{}));try{return await r()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}const Le="tolgee-in-context-tools.umd.min.js",Oe="@tolgee/in-context-tools",we="InContextTools",ke="https://cdn.jsdelivr.net/npm";let je=null;function Ae(e){var t;return je||(je=(t=`${ke}/@tolgee/web@${e}/dist/${Le}`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window[Oe][we]))),je}const Pe="__tolgee_apiKey",xe="__tolgee_apiUrl";function Ne(){const e=sessionStorage.getItem(Pe)||void 0,t=sessionStorage.getItem(xe)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Te(){sessionStorage.removeItem(Pe),sessionStorage.removeItem(xe)}let Re=()=>e=>e;"undefined"!=typeof window&&"undefined"!=typeof sessionStorage&&(Re=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=Ee({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(Te)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Ne()&&(async()=>{const e=await Ae("5.9.2-prerelease.41828ff8.0");return t=>{const n=Ne();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 Ce="__tolgee_currentLanguage";const Se=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(X("LanguageStorage"),localStorage.getItem(Ce)||void 0),setLanguage(e){X("LanguageStorage"),localStorage.setItem(Ce,e)}}),e);const $e=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){X("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=a(window.navigator.language);return e.find((e=>a(e)===o))||void 0}}),e);function De(e){return e.endsWith("/")?e.slice(0,-1):e}const Ie={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${De(n)}/${e}/${t}.json`:`${De(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Ue(e){const t=Object.assign(Object.assign(Object.assign({},Ie),e),{headers:Object.assign(Object.assign({},Ie.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:a,getData:o,headers:r}=t,i=function(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 o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}(t,["prefix","getPath","getData","headers"]);return{getRecord({namespace:e,language:t}){const s=a({namespace:e,language:t,prefix:n});return fetch(s,Object.assign({headers:r},i)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return o(e)}))}}}const _e=e=>(t,n)=>(n.addBackend(Ue(e)),t);function Fe(){return w().use(Re())}const Me=()=>e=>e;export{_e as BackendFetch,Re as BrowserExtensionPlugin,M as DEVTOOLS_ID,ye as DevBackend,Me as DevTools,F as FormatSimple,$e as LanguageDetector,Se as LanguageStorage,pe as ObserverPlugin,V as PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY,K as TOLGEE_ATTRIBUTE_NAME,B as TOLGEE_RESTRICT_ATTRIBUTE,z as TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE,Fe as Tolgee,w as TolgeeCore,a as getFallback,o as getFallbackArray,be as getProjectIdFromApiKey,L as getTranslateProps}; | ||
function e(e){return Boolean(e&&"function"==typeof e.then)}function t(t,n){return e(t)?Promise.resolve(t).then(n):n(t)}function n(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 a(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function o(e){return a(e)||[]}function r(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?o(t):o(null==t?void 0:t[e]);var n}function i(e){return Array.from(new Set(e))}function s(e){return e?e.replace(/\/+$/,""):e}function l(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 c(e,t,n){const a=new Set,r=new Set;let i=[];function s(){if(0===i.length)return;const e=i;i=[],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()&&(i.push(t),n?setTimeout(s,0):s())},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=>(o(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}const u=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):u(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},g=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},d=({language:e,namespace:t})=>t?`${e}:${t}`:e;function f(e,t,n,a,r,s,l){const c=new Map,f=new Map;let p={},v=0;function h(t,n,a){const o=d(t);f.set(o,{data:u(n),version:a}),e.emit(t)}function m(e){let n;if(!n){const t=p[d(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}const b=Object.freeze({addStaticData(e){e&&(p=Object.assign(Object.assign({},p),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=g(e),a=f.get(e);a&&0!==a.version||h(n,t,0)}})))},invalidate(){c.clear(),v+=1},addRecord(e,t){h(e,t,v)},exists(e,t=!1){const n=f.get(d(e));return n&&t?n.version===v:Boolean(n)},getRecord(e){var t;return null===(t=f.get(d(a(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=f.get(d(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=f.get(d({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return i(e)},getTranslationFallback(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=f.get(d({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var o;const r=null===(o=f.get(d(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(r())return!0;if(void 0===e)return c.size>0;const t=o(e);return Boolean(Array.from(c.keys()).find((e=>t.includes(g(e).namespace))))},isLoading(e,t){const n=o(t);return Boolean(r()||Array.from(c.keys()).find((t=>{const a=g(t);return(!n.length||n.includes(a.namespace))&&!b.exists({namespace:a.namespace,language:e})})))},async loadRecords(e,t){const o=e.map((e=>{const o=a(e),r=d(o),i=c.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const s=function(e,t){var a;let o;return t&&(o=null===(a=n(e))||void 0===a?void 0:a.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),m(e))))),o||(o=m(e)),o}(o,t)||Promise.resolve(void 0);return c.set(r,s),{new:!0,promise:s,keyObject:o,cacheKey:r}}));s.notify(),l.notify();const r=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=c.get(e.cacheKey)!==e.promise;if(e.new&&!n){c.delete(e.cacheKey);const n=r[t];n?b.addRecord(e.keyObject,n):b.getRecord(e.keyObject)||b.addRecord(e.keyObject,{})}})),s.notify(),l.notify(),o.map((e=>b.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(f.entries()).map((([e,t])=>Object.assign(Object.assign({},g(e)),{data:t.data})))});return b}function p(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 o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}const v="invalid",h={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"]},observerType:"invisible",onFormatError:v,apiUrl:"https://app.tolgee.io"},m=(...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 b(e,t){const n=m(h,null==t?void 0:t.initialOptions,e);return n.apiUrl=s(n.apiUrl),{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 y(n,a,o,r,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,event:t})=>{var n;const a=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,ns:r({key:e,ns:t}),translation:i({key:e,ns:t})})));null===(n=c.ui)||void 0===n||n.handleElementClick(a,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=i({key:e.key,ns:e.ns});return j.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function f(e){c.observer=null==e?void 0:e()}function h(){return Boolean(c.observer)}function m(e){e&&c.formatters.push(e)}function b(e){c.finalFormatter=e}function y(e){l.ui=e}function E(){return Boolean(l.ui)}function L(e){c.languageStorage=e}function O(e){c.languageDetector=e}function w(e){e&&c.backends.push(e)}function k(e){c.devBackend=e}const j=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:b,addFormatter:m,setObserver:f,hasObserver:h,setUi:y,hasUi:E,setDevBackend:k,addBackend:w,setLanguageDetector:O,setLanguageStorage:L}))},run(){var e,t;const{apiKey:n,apiUrl:o,projectId:r,observerOptions:i}=a();c.ui=null===(e=l.ui)||void 0===e?void 0:e.call(l,{apiKey:n,apiUrl:o,projectId:r,highlight:j.highlight,changeTranslation:s,findPositions:g}),null===(t=c.observer)||void 0===t||t.run({mouseHighlight:!0,options:i,translate:d,onClick:u})},stop(){var e;c.ui=void 0,null===(e=c.observer)||void 0===e||e.stop()},getLanguageStorage:()=>c.languageStorage,getInitialLanguage(){var e;const n=o();return t(null===(e=c.languageStorage)||void 0===e?void 0:e.getLanguage(),(e=>n&&!n.includes(e)||!e?function(){if(!c.languageDetector)return;const e=o();return c.languageDetector.getLanguage({availableLanguages:e})}():e))},setStoredLanguage(e){var t;null===(t=c.languageStorage)||void 0===t||t.setLanguage(e)},getDevBackend:()=>c.devBackend,getBackendRecord:({language:t,namespace:n})=>{for(const a of c.backends){const o=a.getRecord({language:t,namespace:n});if(e(o))return null==o?void 0:o.catch((e=>(console.error(e),{})));if(void 0!==o)return o}},getBackendDevRecord:({language:e,namespace:t})=>{var n;const{apiKey:o,apiUrl:r,projectId:i}=a();return null===(n=c.devBackend)||void 0===n?void 0:n.getRecord({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:t})},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(j.getDevBackend()),formatTranslation(e){var t,{formatEnabled:o}=e,r=p(e,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:u,params:g,orEmpty:d,ns:f}=r,h=s||l;let m=h||(d?"":i);const b=n(),y=o||!(null===(t=c.observer)||void 0===t?void 0:t.outputNotFormattable),E=e=>c.observer&&!u?c.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:f}):e;m=E(m);try{if(h&&b&&y)for(const e of c.formatters)m=e.format({translation:m,language:b,params:g});c.finalFormatter&&h&&b&&y&&(m=c.finalFormatter.format({translation:m,language:b,params:g}))}catch(e){console.error(e);const t=("string"==typeof(L=e)?L:"string"==typeof(null==L?void 0:L.message)?L.message:void 0)||v,n=a().onFormatError,o=typeof n;m="string"===o?n:"function"===o?n(t,r):v,m=E(m)}var L;return m}});return j}const E=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const L=(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:o,language:r}=e,i=p(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:r};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function O({options:a}){const u=function(e,t){let n=!0;function a(){return n}const o=Object.freeze({onPendingLanguageChange:l(a),onLanguageChange:l(a),onLoadingChange:l(a),onFetchingChange:l(a),onInitialLoaded:l(a),onRunningChange:l(a),onCacheChange:l(a),onUpdate:c(a,e,t),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.onPendingLanguageChange.listen(t);case"language":return o.onLanguageChange.listen(t);case"loading":return o.onLoadingChange.listen(t);case"fetching":return o.onFetchingChange.listen(t);case"initialLoad":return o.onInitialLoaded.listen(t);case"running":return o.onRunningChange.listen(t);case"cache":return o.onCacheChange.listen(t);case"update":return o.onUpdate.listen(t)}}});return o.onInitialLoaded.listen((()=>o.onUpdate.emit())),o.onLanguageChange.listen((()=>o.onUpdate.emit())),o.onCacheChange.listen((({value:e})=>o.onUpdate.emit([e.namespace],!0))),o}(O,w),d=E(!1,(()=>m.isFetching()),u.onFetchingChange.emit),p=E(!1,(()=>R.isLoading()),u.onLoadingChange.emit),v=function(e,t,n){let a,l=b();const c=Object.freeze({init(e){l=b(e,l)},isRunning:()=>l.isRunning,setRunning(e){l.isRunning!==e&&(l.isRunning=e,n.emit(e))},isInitialLoading:()=>l.isInitialLoading,setInitialLoading(e){l.isInitialLoading=e},getLanguage:()=>l.language||l.initialOptions.language,setLanguage(t){l.language!==t&&(l.language=t,e.emit(t))},getPendingLanguage:()=>l.pendingLanguage||c.getLanguage(),setPendingLanguage(e){l.pendingLanguage!==e&&(l.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},l.initialOptions),a),addActiveNs(e){o(e).forEach((e=>{const t=l.activeNamespaces.get(e);void 0!==t?l.activeNamespaces.set(e,t+1):l.activeNamespaces.set(e,1)}))},removeActiveNs(e){o(e).forEach((e=>{const t=l.activeNamespaces.get(e);void 0!==t&&t>1?l.activeNamespaces.set(e,t-1):l.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>i([...l.initialOptions.ns||[l.initialOptions.defaultNs],...o(l.initialOptions.fallbackNs),...l.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||c.getLanguage();return t?i([t,...r(t,l.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>o(l.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?l.initialOptions.defaultNs:e,getAvailableLanguages(){if(l.initialOptions.availableLanguages)return l.initialOptions.availableLanguages;if(l.initialOptions.staticData){const e=Object.keys(l.initialOptions.staticData).map((e=>g(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?c.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:s(e.apiUrl)}):void 0}});return c}(u.onLanguageChange,u.onPendingLanguageChange,u.onRunningChange),h=y(v.getLanguage,v.getInitialOptions,v.getAvailableLanguages,(function({key:e,ns:t}){const n=v.getFallbackLangs(),a=k(t||void 0);return m.getTranslationNs(a,n,e)}),N,A),m=f(u.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,v.withDefaultNs,v.isInitialLoading,d,p);function O(){return v.getFallbackNs()}function w(e){return v.getDefaultNs(e)}function k(e){return[...o(w(e)),...O()]}function j(e){return[...o(e||w()),...v.getRequiredNamespaces()]}function A(e,t,n){const a=v.withDefaultNs(e),o=m.getTranslation(a,t);return m.changeTranslation(a,t,n),{revert(){m.changeTranslation(a,t,o)}}}function P(e){v.init(e),m.addStaticData(v.getInitialOptions().staticData)}function x(e,n){const a=function(e,t){const n=v.getFallbackLangs(e),a=j(t),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}(e,n);if(a.length)return t(R.loadRecords(a),(()=>{}))}function N({key:e,ns:t,language:n}){const a=k(t||void 0),o=v.getFallbackLangs(n);return m.getTranslationFallback(a,o,e)}function T(){const n=t(function(){if(v.getLanguage())return;return t(h.getInitialLanguage(),(e=>{const t=e||v.getInitialOptions().defaultLanguage;t&&v.setLanguage(t)}))}(),(()=>x()));if(e(n))return v.setInitialLoading(!0),d.notify(),p.notify(),Promise.resolve(n).then((()=>{v.setInitialLoading(!1),d.notify(),p.notify(),u.onInitialLoaded.emit()}));u.onInitialLoaded.emit()}a&&P(a),u.onUpdate.listen((()=>{v.isRunning()&&h.retranslate()}));const R=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},u),v),h),m),{init:P,getTranslation:N,changeTranslation:A,async changeLanguage(e){v.getPendingLanguage()===e&&v.getLanguage()===e||(v.setPendingLanguage(e),v.isRunning()&&await x(e),e===v.getPendingLanguage()&&(v.setLanguage(e),h.setStoredLanguage(e)))},async addActiveNs(e,t){t||v.addActiveNs(e),v.isRunning()&&await x(void 0,e)},loadRecords:e=>m.loadRecords(e,R.isDev()),loadRecord:async e=>(await R.loadRecords([e]))[0],isLoading:e=>m.isLoading(v.getLanguage(),e),isLoaded(e){const t=v.getLanguage();if(!t)return!1;const n=v.getFallbackLangs(t),a=j(e),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=L(...e),n=N(t);return h.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(v.getInitialOptions().apiKey&&v.getInitialOptions().apiUrl),run(){let e;return function(){if((h.getLanguageDetector()||h.getLanguageStorage())&&!v.getAvailableLanguages())throw new Error(n("availableLanguages"));if(!v.getLanguage()&&!v.getInitialOptions().defaultLanguage)throw new Error(n(["defaultLanguage","language"]))}(),v.isRunning()||(R.isDev()&&m.invalidate(),v.setRunning(!0),h.run(),e=T()),Promise.resolve(e)},stop(){v.isRunning()&&(h.stop(),v.setRunning(!1))}}));return R}const w=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=m(e.options,n),t),init(t){const n=function(e){const t=O({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),n&&t.run()}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,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,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}(m(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},k=0,j=1,A=2;class P extends Error{constructor(e,t,n){let a;a=e===k?"Empty parameter":e===j?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function x(e){return/\s/.test(e)}const N=0,T=1,R=2,C=3,S=4,$=new Set([R,T,N]),D="'",I=new Set(["{","}",D]),U=e=>/[0-9a-zA-Z_]/.test(e);function _(e,t){const[n,a]=function(e){let t=N,n="",a="",o="";const r=[],i=[];let s=0;function l(t){throw new P(t,s,e)}const c=()=>{r.push(n),n=""},u=()=>{""===a&&l(k),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case N:o===D?(n+=o,t=T):"{"===o?(c(),t=C):(n+=o,t=N);break;case T:I.has(o)?(n=n.slice(0,-1)+o,t=R):(n+=o,t=N);break;case R:o===D?t=N:(n+=o,t=R);break;case C:"}"===o?(u(),t=N):x(o)?""!==a&&(u(),t=S):(U(o)||l(j),a+=o,t=C);break;case S:"}"==o?t=N:x(o)?t=S:l(j)}return $.has(t)||l(A),c(),[r,i]}(e),o=[n[0]];for(let r=1;r<n.length;r++){const i=null==t?void 0:t[a[r-1]];if(void 0===i)throw new Error(`Missing parameter "${a[r-1]}" in "${e}"`);o.push(String(i)),o.push(n[r])}return o.join("")}const F=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>_(e,t)}),e),M="__tolgee_dev_tools",V="__tolgee_preferredLanguages",z="data-tolgee-key-only",B="data-tolgee-restricted",K="_tolgee",W="_tolgee-highlighter";function Y(){var e,t;return void 0===(null===(t=null===(e=globalThis.window)||void 0===e?void 0:e.document)||void 0===t?void 0:t.createElement)}function X(e){if(Y())throw new Error(`${e}: Can't run on the server`)}function G(e,t){return{oldTextContent:e,keys:t}}const H={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function J({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(W),Object.entries(H).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const r=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=r.top-t+"px",o.style.left=r.left-t+"px",o.style.width=r.width+"px",o.style.height=r.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,a)}})}function q(e,t){var n;const a=function(e){switch(e.nodeType){case Node.ATTRIBUTE_NODE:return e.ownerElement||void 0;case Node.TEXT_NODE:return e.parentElement||void 0;case Node.DOCUMENT_NODE:case Node.ELEMENT_NODE:return e;default:return}}(t),o=[];if(!a)return o;const r=null===document||void 0===document?void 0:document.evaluate(e,a,void 0,XPathResult.ANY_TYPE);let i;for(;i=null===(n=null==r?void 0:r.iterateNext)||void 0===n?void 0:n.call(r);)o.push(i);return o}function Z(e){return e.textContent}function Q(e,t){e.textContent=t}function ee(e,t){if(e.contains(t))return!0;if(t instanceof Attr){const n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}function te(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null===(n=e.ns)||void 0===n?void 0:n.findIndex((e=>{var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return a&&o}const ne={capture:!0},ae={capture:!0,passive:!0};function oe({highlightKeys:e,elementStore:t,onClick:n,options:a}){var o,r;let i,s,l=new Set;const c=(null===(o=a.targetElement)||void 0===o?void 0:o.getRootNode())||document,u=(null===(r=a.targetElement)||void 0===r?void 0:r.ownerDocument)||document;function g(){var e;const n=t.get(i);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),i=void 0)}function d(){const e=s;let n;if(e&&L()){const a=c.elementFromPoint(e.x,e.y);a&&(n=function(e){return E(e,(e=>t.get(e)))}(a))}!function(e){var n;if(i!==e){g();const a=t.get(e);a&&(a.preventClean=!0,null===(n=a.highlight)||void 0===n||n.call(a),i=e)}}(n)}function f(e){var t;L()&&(t=e.target,!Boolean(E(t,(e=>e.id===M))))&&(e.stopPropagation(),e.preventDefault())}function p(e){var t;t={x:e.clientX,y:e.clientY},s=t,d()}function v(){l=new Set,d()}function h(e){const t=e.key;void 0!==t&&l.add(t),d()}function m(e){l.delete(e.key),d()}function b(){var e;const n=t.get(i);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)}function y(e){f(e),L()&&i&&(n(e,i),g())}function E(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?E(e.parentElement,t):void 0}function L(){for(const t of e)if(!l.has(t))return!1;return!0}return Object.freeze({stop(){u.removeEventListener("blur",v,ne),u.removeEventListener("keydown",h,ne),u.removeEventListener("keyup",m,ne),u.removeEventListener("mousemove",p,ae),u.removeEventListener("scroll",b,ae),u.removeEventListener("click",y,ne),u.removeEventListener("mouseenter",f,ne),u.removeEventListener("mouseover",f,ne),u.removeEventListener("mouseout",f,ne),u.removeEventListener("mouseleave",f,ne),u.removeEventListener("mousedown",f,ne),u.removeEventListener("mouseup",f,ne)},run(){u.addEventListener("blur",v,ne),u.addEventListener("keydown",h,ne),u.addEventListener("keyup",m,ne),u.addEventListener("mousemove",p,ae),u.addEventListener("scroll",b,ae),u.addEventListener("click",y,ne),u.addEventListener("mouseenter",f,ne),u.addEventListener("mouseover",f,ne),u.addEventListener("mouseout",f,ne),u.addEventListener("mouseleave",f,ne),u.addEventListener("mousedown",f,ne),u.addEventListener("mouseup",f,ne)}})}function re(e,t,n){const o=J({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=oe({highlightKeys:e.highlightKeys,elementStore:t,onClick(e,a){const o=t.get(a);n({event:e,keysAndDefaults:l(o)})},options:e});function i(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())ee(s(),t)&&(yield[t,n])}(e))}function s(){return e.targetElement||document.body}function l(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({register(n,a,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${B}]`)}(n))return;const i=n;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(K,"true")),s.nodes.set(a,r),o.initHighlighter(i,s)},forEachElement:t.forEachElement,refreshAll(){t.forEachElement(((e,n)=>{n.preventClean||(i(n),0===n.nodes.size&&function(e,n){var a;n.highlightEl&&(null===(a=n.unhighlight)||void 0===a||a.call(n)),e.removeAttribute(K),t.remove(e)}(e,n))}))},findAll(e,n){const o=[];return t.forEachElement(((t,r)=>{for(const t of r.nodes.values()){if(t.keys.find((t=>te({key:e,ns:a(n)},{key:t.key,ns:a(t.ns)})))){o.push(r);break}}})),o},run(e){e&&r.run()},stop(){r.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||n.call(t))}))}})}function ie(){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 o({mouseHighlight:e,options:a,wrapper:o,onClick:r}){if(Y())return;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){let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=q(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a},handleChildList(e){let t=[];return t=t.concat(n.handleAttributes(e)),t=t.concat(n.handleText(e)),t},handleText:e=>q(t.getTextXPath(),e)});return n}(a,o),l=re(a,n,r);function c(e){for(const t of e){const e=Z(t),n=e?o.unwrap(e):null;if(n){const{text:a,keys:o}=n;Q(t,a);const r=G(e,o),s=i.getSuitableParent(t);l.register(s,t,r)}}}function u(e){q(`./descendant-or-self::*[@${z}]`,e).forEach((e=>{const t=e.getAttributeNode(z),n=i.getSuitableParent(t);l.register(n,t,{oldTextContent:"",keys:[{key:Z(t)}],keyAttributeOnly:!0})}))}const g=new MutationObserver((e=>{if(t){for(const t of e){let e=[];switch(t.type){case"characterData":e=s.handleText(t.target);break;case"childList":u(t.target),e=s.handleChildList(t.target);break;case"attributes":u(t.target),e=s.handleAttributes(t.target)}c(e)}l.refreshAll()}})),d=a.targetElement||document.body;return t=!0,l.run(e),u(d),c(s.handleChildList(d)),g.observe(d,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),g.disconnect()},elementRegistry:l,wrapper:o}}return Object.freeze({run(t){e=o(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null===(a=null==e?void 0:(n=e.elementRegistry).forEachElement)||void 0===a||a.call(n,t)},highlight(t,n){const a=(null==e?void 0:e.elementRegistry.findAll(t,n))||[];return a.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){a.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}},findPositions(t,n){const o=(null==e?void 0:e.elementRegistry.findAll(t,n))||[],r=[];return o.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),o.forEach((e=>{const o=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{te({key:t,ns:a(n)},{key:e.key,ns:a(e.ns)})&&r.push({position:{x:o.x,y:o.y,width:o.width,height:o.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),r},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}const se=["",""],le=RegExp(`([${se.join("")}]{9})+`,"gu");function ce(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=>se[Number(e)])).join("")}function ue(e){const t=Array.from(e).map((e=>se.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 ge(){const e=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]})}();return Object.freeze({unwrap(t){const n=[],a=function(e){var t;const n=null===(t=e.match(le))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(ue))||[]}(t);a.forEach((t=>{const[a]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(t),o=e.numberToValue(a),{k:r,d:i,n:s}=(l=o,JSON.parse(l||"{}"));var l;n.push({key:r,defaultValue:i,ns:s})}));const o=function(e){return e.replace(le,"")}(t);return{text:o,keys:n}},wrap({key:t,defaultValue:n,translation:a,ns:o}){const r=function(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}({key:t,ns:o,defaultValue:n}),i=e.valueToNumber(r),s=a||"",l=ce(String.fromCodePoint(i));return"string"==typeof s?s+l:s},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${se[0]}${se[0]}') or contains(., '${se[1]}${se[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${se[0]}${se[0]}') or contains(., '${se[1]}${se[0]}')]`})}function de(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function fe({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:o,ns:r}=function(e){let t=!1,n="",a="",o="KEY";const r={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{r.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",r.params[a]=n,n=""):(o="PARAM_VALUE",a=n,n=""):(o="PARAM_NAME",r.defaultValue=n,n=""):(o="PARAM_NAME",r.key=n,n=""):(o="DEFAULT_VALUE",i(n),n=""):(o="NAMESPACE",r.key=n,n=""):(o="DEFAULT_VALUE",r.key=n,n=""):t=!0;return"KEY"===o&&(r.key=n),"DEFAULT_VALUE"===o&&(r.defaultValue=n),"PARAM_VALUE"===o&&(r.params[a]=n),"NAMESPACE"===o&&i(n),r}(e);return{translated:n({key:t,params:a,defaultValue:o,ns:r,noWrap:!0}),key:t,params:a,defaultValue:o,ns:r}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e){return"string"==typeof e?e.replace(/[,:|\\]/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:o,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${r(e)}:${r(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==o?`,${r(o)}`:"",c="string"==typeof i?[i]:i,u=(null==c?void 0:c.length)?`|${c.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${u}${l}${s}${t}`},unwrap(n){const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,l=!1,c=0,u="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(u+=f.substr(c,d-c),c=d+t.length,"\\"===e){if(!de(d,n)){u+=r;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:[]}},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${e}') and contains(., '${t}')]`,getAttributeXPath:({tag:n,attribute:a})=>`descendant-or-self::${n}/@${a}[contains(., '${e}') and contains(., '${t}')]`})}const pe=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=ie();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=fe({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(Object.assign(Object.assign({},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&&Q(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=ie();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=ge();e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),ve="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function he(e){const t=ve.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function me(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|he(e[i]),n+=5,n>=8&&(r[o++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+o));return a}(r.buffer)}function be(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=me(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}const ye=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o}){var r;const i=null!==(r=be(t))&&void 0!==r?r:o;let s=void 0!==i?`${e}/v2/projects/${i}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(s+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return fetch(s,{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 Ee({message:e,recievingMessage:t,data:n,attempts:a=1}){let o=!1;const r=()=>new Promise(((a,o)=>{const r=function(e,t){const n=n=>{var a,o;e.includes(null===(a=n.data)||void 0===a?void 0:a.type)&&t(null===(o=n.data)||void 0===o?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(i),s(),a(e)}));window.postMessage({type:e,data:n},window.origin);const i=setTimeout((function(){s(),o()}),300);function s(){r.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<a;e++){if(o)return new Promise((()=>{}));try{return await r()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}const Le="tolgee-in-context-tools.umd.min.js",Oe="@tolgee/in-context-tools",we="InContextTools",ke="https://cdn.jsdelivr.net/npm";let je=null;function Ae(e){var t;return je||(je=(t=`${ke}/@tolgee/web@${e}/dist/${Le}`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window[Oe][we]))),je}const Pe="__tolgee_apiKey",xe="__tolgee_apiUrl";function Ne(){const e=sessionStorage.getItem(Pe)||void 0,t=sessionStorage.getItem(xe)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Te(){sessionStorage.removeItem(Pe),sessionStorage.removeItem(xe)}let Re=()=>e=>e;"undefined"!=typeof window&&"undefined"!=typeof sessionStorage&&(Re=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=Ee({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(Te)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Ne()&&(async()=>{const e=await Ae("5.9.2-prerelease.ce0c7097.0");return t=>{const n=Ne();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 Ce="__tolgee_currentLanguage";const Se=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(X("LanguageStorage"),localStorage.getItem(Ce)||void 0),setLanguage(e){X("LanguageStorage"),localStorage.setItem(Ce,e)}}),e);const $e=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){X("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=a(window.navigator.language);return e.find((e=>a(e)===o))||void 0}}),e);function De(e){return e.endsWith("/")?e.slice(0,-1):e}const Ie={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${De(n)}/${e}/${t}.json`:`${De(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Ue(e){const t=Object.assign(Object.assign(Object.assign({},Ie),e),{headers:Object.assign(Object.assign({},Ie.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:a,getData:o,headers:r}=t,i=function(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 o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}(t,["prefix","getPath","getData","headers"]);return{getRecord({namespace:e,language:t}){const s=a({namespace:e,language:t,prefix:n});return fetch(s,Object.assign({headers:r},i)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return o(e)}))}}}const _e=e=>(t,n)=>(n.addBackend(Ue(e)),t);function Fe(){return w().use(Re())}const Me=()=>e=>e;export{_e as BackendFetch,Re as BrowserExtensionPlugin,M as DEVTOOLS_ID,ye as DevBackend,Me as DevTools,F as FormatSimple,$e as LanguageDetector,Se as LanguageStorage,pe as ObserverPlugin,V as PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY,K as TOLGEE_ATTRIBUTE_NAME,B as TOLGEE_RESTRICT_ATTRIBUTE,z as TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE,Fe as Tolgee,w as TolgeeCore,a as getFallback,o as getFallbackArray,be as getProjectIdFromApiKey,L 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"]=e["@tolgee/web"]||{},e["@tolgee/web"].production={}))}(this,(function(e){"use strict";function t(e){return Boolean(e&&"function"==typeof e.then)}function n(e,n){return t(e)?Promise.resolve(e).then(n):n(e)}function a(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 o(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function r(e){return o(e)||[]}function i(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?r(t):r(null==t?void 0:t[e]);var n}function s(e){return Array.from(new Set(e))}function l(e){return e?e.replace(/\/+$/,""):e}function u(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 c(e,t,n){const a=new Set,o=new Set;let i=[];function s(){if(0===i.length)return;const e=i;i=[],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());o.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()&&(i.push(t),n?setTimeout(s,0):s())},listen(e){a.add(e);return{unsubscribe:()=>{a.delete(e)}}},listenSome(e){const t={fn:t=>{e(t)},namespaces:new Set};o.add(t);const a={unsubscribe:()=>{o.delete(t)},subscribeNs:e=>(r(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}const g=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):g(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},d=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},f=({language:e,namespace:t})=>t?`${e}:${t}`:e;function p(e,t,n,a,o,i,l){const u=new Map,c=new Map;let p={},v=0;function h(t,n,a){const o=f(t);c.set(o,{data:g(n),version:a}),e.emit(t)}function m(e){let n;if(!n){const t=p[f(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}const b=Object.freeze({addStaticData(e){e&&(p=Object.assign(Object.assign({},p),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=d(e),a=c.get(e);a&&0!==a.version||h(n,t,0)}})))},invalidate(){u.clear(),v+=1},addRecord(e,t){h(e,t,v)},exists(e,t=!1){const n=c.get(f(e));return n&&t?n.version===v:Boolean(n)},getRecord(e){var t;return null===(t=c.get(f(a(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=c.get(f(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=c.get(f({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return s(e)},getTranslationFallback(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=c.get(f({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var o;const r=null===(o=c.get(f(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(o())return!0;if(void 0===e)return u.size>0;const t=r(e);return Boolean(Array.from(u.keys()).find((e=>t.includes(d(e).namespace))))},isLoading(e,t){const n=r(t);return Boolean(o()||Array.from(u.keys()).find((t=>{const a=d(t);return(!n.length||n.includes(a.namespace))&&!b.exists({namespace:a.namespace,language:e})})))},async loadRecords(e,t){const o=e.map((e=>{const o=a(e),r=f(o),i=u.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const s=function(e,t){var a;let o;return t&&(o=null===(a=n(e))||void 0===a?void 0:a.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),m(e))))),o||(o=m(e)),o}(o,t)||Promise.resolve(void 0);return u.set(r,s),{new:!0,promise:s,keyObject:o,cacheKey:r}}));i.notify(),l.notify();const r=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=u.get(e.cacheKey)!==e.promise;if(e.new&&!n){u.delete(e.cacheKey);const n=r[t];n?b.addRecord(e.keyObject,n):b.getRecord(e.keyObject)||b.addRecord(e.keyObject,{})}})),i.notify(),l.notify(),o.map((e=>b.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(c.entries()).map((([e,t])=>Object.assign(Object.assign({},d(e)),{data:t.data})))});return b}function v(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 o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}const h="invalid",m={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"]},observerType:"invisible",onFormatError:h,apiUrl:"https://app.tolgee.io"},b=(...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 y(e,t){const n=b(m,null==t?void 0:t.initialOptions,e);return n.apiUrl=l(n.apiUrl),{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 E(e,a,o,r,i,s){const l={ui:void 0},u={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},c=async({keysAndDefaults:e,event:t})=>{var n;const a=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,ns:r({key:e,ns:t}),translation:i({key:e,ns:t})})));null===(n=u.ui)||void 0===n||n.handleElementClick(a,t)},g=(e,t)=>{var n;return(null===(n=u.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function d(e){const t=i({key:e.key,ns:e.ns});return A.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function f(e){u.observer=null==e?void 0:e()}function p(){return Boolean(u.observer)}function m(e){e&&u.formatters.push(e)}function b(e){u.finalFormatter=e}function y(e){l.ui=e}function E(){return Boolean(l.ui)}function L(e){u.languageStorage=e}function O(e){u.languageDetector=e}function w(e){e&&u.backends.push(e)}function k(e){u.devBackend=e}const A=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:b,addFormatter:m,setObserver:f,hasObserver:p,setUi:y,hasUi:E,setDevBackend:k,addBackend:w,setLanguageDetector:O,setLanguageStorage:L}))},run(){var e,t;const{apiKey:n,apiUrl:o,projectId:r,observerOptions:i}=a();u.ui=null===(e=l.ui)||void 0===e?void 0:e.call(l,{apiKey:n,apiUrl:o,projectId:r,highlight:A.highlight,changeTranslation:s,findPositions:g}),null===(t=u.observer)||void 0===t||t.run({mouseHighlight:!0,options:i,translate:d,onClick:c})},stop(){var e;u.ui=void 0,null===(e=u.observer)||void 0===e||e.stop()},getLanguageStorage:()=>u.languageStorage,getInitialLanguage(){var e;const t=o();return n(null===(e=u.languageStorage)||void 0===e?void 0:e.getLanguage(),(e=>t&&!t.includes(e)||!e?function(){if(!u.languageDetector)return;const e=o();return u.languageDetector.getLanguage({availableLanguages:e})}():e))},setStoredLanguage(e){var t;null===(t=u.languageStorage)||void 0===t||t.setLanguage(e)},getDevBackend:()=>u.devBackend,getBackendRecord:({language:e,namespace:n})=>{for(const a of u.backends){const o=a.getRecord({language:e,namespace:n});if(t(o))return null==o?void 0:o.catch((e=>(console.error(e),{})));if(void 0!==o)return o}},getBackendDevRecord:({language:e,namespace:t})=>{var n;const{apiKey:o,apiUrl:r,projectId:i}=a();return null===(n=u.devBackend)||void 0===n?void 0:n.getRecord({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:t})},getLanguageDetector:()=>u.languageDetector,retranslate(){var e;null===(e=u.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,a;return(null===(a=null===(n=u.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return u.observer?null===(t=u.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return u.observer?null===(t=u.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(A.getDevBackend()),formatTranslation(t){var n,{formatEnabled:o}=t,r=v(t,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:c,params:g,orEmpty:d,ns:f}=r,p=s||l;let m=p||(d?"":i);const b=e(),y=o||!(null===(n=u.observer)||void 0===n?void 0:n.outputNotFormattable),E=e=>u.observer&&!c?u.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:f}):e;m=E(m);try{if(p&&b&&y)for(const e of u.formatters)m=e.format({translation:m,language:b,params:g});u.finalFormatter&&p&&b&&y&&(m=u.finalFormatter.format({translation:m,language:b,params:g}))}catch(e){console.error(e);const t=("string"==typeof(L=e)?L:"string"==typeof(null==L?void 0:L.message)?L.message:void 0)||h,n=a().onFormatError,o=typeof n;m="string"===o?n:"function"===o?n(t,r):h,m=E(m)}var L;return m}});return A}const L=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const O=(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:o,language:r}=e,i=v(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:r};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function w({options:e}){const o=function(e,t){let n=!0;function a(){return n}const o=Object.freeze({onPendingLanguageChange:u(a),onLanguageChange:u(a),onLoadingChange:u(a),onFetchingChange:u(a),onInitialLoaded:u(a),onRunningChange:u(a),onCacheChange:u(a),onUpdate:c(a,e,t),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.onPendingLanguageChange.listen(t);case"language":return o.onLanguageChange.listen(t);case"loading":return o.onLoadingChange.listen(t);case"fetching":return o.onFetchingChange.listen(t);case"initialLoad":return o.onInitialLoaded.listen(t);case"running":return o.onRunningChange.listen(t);case"cache":return o.onCacheChange.listen(t);case"update":return o.onUpdate.listen(t)}}});return o.onInitialLoaded.listen((()=>o.onUpdate.emit())),o.onLanguageChange.listen((()=>o.onUpdate.emit())),o.onCacheChange.listen((({value:e})=>o.onUpdate.emit([e.namespace],!0))),o}(b,w),g=L(!1,(()=>m.isFetching()),o.onFetchingChange.emit),f=L(!1,(()=>R.isLoading()),o.onLoadingChange.emit),v=function(e,t,n){let a,o=y();const u=Object.freeze({init(e){o=y(e,o)},isRunning:()=>o.isRunning,setRunning(e){o.isRunning!==e&&(o.isRunning=e,n.emit(e))},isInitialLoading:()=>o.isInitialLoading,setInitialLoading(e){o.isInitialLoading=e},getLanguage:()=>o.language||o.initialOptions.language,setLanguage(t){o.language!==t&&(o.language=t,e.emit(t))},getPendingLanguage:()=>o.pendingLanguage||u.getLanguage(),setPendingLanguage(e){o.pendingLanguage!==e&&(o.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},o.initialOptions),a),addActiveNs(e){r(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t?o.activeNamespaces.set(e,t+1):o.activeNamespaces.set(e,1)}))},removeActiveNs(e){r(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t&&t>1?o.activeNamespaces.set(e,t-1):o.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>s([...o.initialOptions.ns||[o.initialOptions.defaultNs],...r(o.initialOptions.fallbackNs),...o.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||u.getLanguage();return t?s([t,...i(t,o.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>r(o.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?o.initialOptions.defaultNs:e,getAvailableLanguages(){if(o.initialOptions.availableLanguages)return o.initialOptions.availableLanguages;if(o.initialOptions.staticData){const e=Object.keys(o.initialOptions.staticData).map((e=>d(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?u.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:l(e.apiUrl)}):void 0}});return u}(o.onLanguageChange,o.onPendingLanguageChange,o.onRunningChange),h=E(v.getLanguage,v.getInitialOptions,v.getAvailableLanguages,(function({key:e,ns:t}){const n=v.getFallbackLangs(),a=k(t||void 0);return m.getTranslationNs(a,n,e)}),x,j),m=p(o.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,v.withDefaultNs,v.isInitialLoading,g,f);function b(){return v.getFallbackNs()}function w(e){return v.getDefaultNs(e)}function k(e){return[...r(w(e)),...b()]}function A(e){return[...r(e||w()),...v.getRequiredNamespaces()]}function j(e,t,n){const a=v.withDefaultNs(e),o=m.getTranslation(a,t);return m.changeTranslation(a,t,n),{revert(){m.changeTranslation(a,t,o)}}}function T(e){v.init(e),m.addStaticData(v.getInitialOptions().staticData)}function P(e,t){const a=function(e,t){const n=v.getFallbackLangs(e),a=A(t),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}(e,t);if(a.length)return n(R.loadRecords(a),(()=>{}))}function x({key:e,ns:t,language:n}){const a=k(t||void 0),o=v.getFallbackLangs(n);return m.getTranslationFallback(a,o,e)}function N(){const e=n(function(){if(v.getLanguage())return;return n(h.getInitialLanguage(),(e=>{const t=e||v.getInitialOptions().defaultLanguage;t&&v.setLanguage(t)}))}(),(()=>P()));if(t(e))return v.setInitialLoading(!0),g.notify(),f.notify(),Promise.resolve(e).then((()=>{v.setInitialLoading(!1),g.notify(),f.notify(),o.onInitialLoaded.emit()}));o.onInitialLoaded.emit()}e&&T(e),o.onUpdate.listen((()=>{v.isRunning()&&h.retranslate()}));const R=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},o),v),h),m),{init:T,getTranslation:x,changeTranslation:j,async changeLanguage(e){v.getPendingLanguage()===e&&v.getLanguage()===e||(v.setPendingLanguage(e),v.isRunning()&&await P(e),e===v.getPendingLanguage()&&(v.setLanguage(e),h.setStoredLanguage(e)))},async addActiveNs(e,t){t||v.addActiveNs(e),v.isRunning()&&await P(void 0,e)},loadRecords:e=>m.loadRecords(e,R.isDev()),loadRecord:async e=>(await R.loadRecords([e]))[0],isLoading:e=>m.isLoading(v.getLanguage(),e),isLoaded(e){const t=v.getLanguage();if(!t)return!1;const n=v.getFallbackLangs(t),a=A(e),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=O(...e),n=x(t);return h.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(v.getInitialOptions().apiKey&&v.getInitialOptions().apiUrl),run(){let e;return function(){if((h.getLanguageDetector()||h.getLanguageStorage())&&!v.getAvailableLanguages())throw new Error(a("availableLanguages"));if(!v.getLanguage()&&!v.getInitialOptions().defaultLanguage)throw new Error(a(["defaultLanguage","language"]))}(),v.isRunning()||(R.isDev()&&m.invalidate(),v.setRunning(!0),h.run(),e=N()),Promise.resolve(e)},stop(){v.isRunning()&&(h.stop(),v.setRunning(!1))}}));return R}const k=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=b(e.options,n),t),init(t){const n=function(e){const t=w({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),n&&t.run()}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,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,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}(b(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},A=0,j=1,T=2;class P extends Error{constructor(e,t,n){let a;a=e===A?"Empty parameter":e===j?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function x(e){return/\s/.test(e)}const N=0,R=1,S=2,C=3,D=4,I=new Set([S,R,N]),$="'",_=new Set(["{","}",$]),U=e=>/[0-9a-zA-Z_]/.test(e);function F(e,t){const[n,a]=function(e){let t=N,n="",a="",o="";const r=[],i=[];let s=0;function l(t){throw new P(t,s,e)}const u=()=>{r.push(n),n=""},c=()=>{""===a&&l(A),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case N:o===$?(n+=o,t=R):"{"===o?(u(),t=C):(n+=o,t=N);break;case R:_.has(o)?(n=n.slice(0,-1)+o,t=S):(n+=o,t=N);break;case S:o===$?t=N:(n+=o,t=S);break;case C:"}"===o?(c(),t=N):x(o)?""!==a&&(c(),t=D):(U(o)||l(j),a+=o,t=C);break;case D:"}"==o?t=N:x(o)?t=D:l(j)}return I.has(t)||l(T),u(),[r,i]}(e),o=[n[0]];for(let r=1;r<n.length;r++){const i=null==t?void 0:t[a[r-1]];if(void 0===i)throw new Error(`Missing parameter "${a[r-1]}" in "${e}"`);o.push(String(i)),o.push(n[r])}return o.join("")}const B="__tolgee_dev_tools",M="data-tolgee-key-only",V="data-tolgee-restricted",z="_tolgee",K="_tolgee-highlighter";function Y(){var e,t;return void 0===(null===(t=null===(e=globalThis.window)||void 0===e?void 0:e.document)||void 0===t?void 0:t.createElement)}function G(e){if(Y())throw new Error(`${e}: Can't run on the server`)}function W(e,t){return{oldTextContent:e,keys:t}}const X={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function H({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(K),Object.entries(X).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const r=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=r.top-t+"px",o.style.left=r.left-t+"px",o.style.width=r.width+"px",o.style.height=r.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,a)}})}function J(e,t){var n;const a=function(e){switch(e.nodeType){case Node.ATTRIBUTE_NODE:return e.ownerElement||void 0;case Node.TEXT_NODE:return e.parentElement||void 0;case Node.DOCUMENT_NODE:case Node.ELEMENT_NODE:return e;default:return}}(t),o=[];if(!a)return o;const r=null===document||void 0===document?void 0:document.evaluate(e,a,void 0,XPathResult.ANY_TYPE);let i;for(;i=null===(n=null==r?void 0:r.iterateNext)||void 0===n?void 0:n.call(r);)o.push(i);return o}function q(e){return e.textContent}function Z(e,t){e.textContent=t}function Q(e,t){if(e.contains(t))return!0;if(t instanceof Attr){const n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}function ee(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null===(n=e.ns)||void 0===n?void 0:n.findIndex((e=>{var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return a&&o}const te={capture:!0},ne={capture:!0,passive:!0};function ae({highlightKeys:e,elementStore:t,onClick:n,options:a}){var o,r;let i,s,l=new Set;const u=(null===(o=a.targetElement)||void 0===o?void 0:o.getRootNode())||document,c=(null===(r=a.targetElement)||void 0===r?void 0:r.ownerDocument)||document;function g(){var e;const n=t.get(i);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),i=void 0)}function d(){const e=s;let n;if(e&&L()){const a=u.elementFromPoint(e.x,e.y);a&&(n=function(e){return E(e,(e=>t.get(e)))}(a))}!function(e){var n;if(i!==e){g();const a=t.get(e);a&&(a.preventClean=!0,null===(n=a.highlight)||void 0===n||n.call(a),i=e)}}(n)}function f(e){var t;L()&&(t=e.target,!Boolean(E(t,(e=>e.id===B))))&&(e.stopPropagation(),e.preventDefault())}function p(e){var t;t={x:e.clientX,y:e.clientY},s=t,d()}function v(){l=new Set,d()}function h(e){const t=e.key;void 0!==t&&l.add(t),d()}function m(e){l.delete(e.key),d()}function b(){var e;const n=t.get(i);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)}function y(e){f(e),L()&&i&&(n(e,i),g())}function E(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?E(e.parentElement,t):void 0}function L(){for(const t of e)if(!l.has(t))return!1;return!0}return Object.freeze({stop(){c.removeEventListener("blur",v,te),c.removeEventListener("keydown",h,te),c.removeEventListener("keyup",m,te),c.removeEventListener("mousemove",p,ne),c.removeEventListener("scroll",b,ne),c.removeEventListener("click",y,te),c.removeEventListener("mouseenter",f,te),c.removeEventListener("mouseover",f,te),c.removeEventListener("mouseout",f,te),c.removeEventListener("mouseleave",f,te),c.removeEventListener("mousedown",f,te),c.removeEventListener("mouseup",f,te)},run(){c.addEventListener("blur",v,te),c.addEventListener("keydown",h,te),c.addEventListener("keyup",m,te),c.addEventListener("mousemove",p,ne),c.addEventListener("scroll",b,ne),c.addEventListener("click",y,te),c.addEventListener("mouseenter",f,te),c.addEventListener("mouseover",f,te),c.addEventListener("mouseout",f,te),c.addEventListener("mouseleave",f,te),c.addEventListener("mousedown",f,te),c.addEventListener("mouseup",f,te)}})}function oe(e,t,n){const a=H({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=ae({highlightKeys:e.highlightKeys,elementStore:t,onClick(e,a){const o=t.get(a);n({event:e,keysAndDefaults:l(o)})},options:e});function i(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())Q(s(),t)&&(yield[t,n])}(e))}function s(){return e.targetElement||document.body}function l(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({register(n,o,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${V}]`)}(n))return;const i=n;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(z,"true")),s.nodes.set(o,r),a.initHighlighter(i,s)},forEachElement:t.forEachElement,refreshAll(){t.forEachElement(((e,n)=>{n.preventClean||(i(n),0===n.nodes.size&&function(e,n){var a;n.highlightEl&&(null===(a=n.unhighlight)||void 0===a||a.call(n)),e.removeAttribute(z),t.remove(e)}(e,n))}))},findAll(e,n){const a=[];return t.forEachElement(((t,r)=>{for(const t of r.nodes.values()){if(t.keys.find((t=>ee({key:e,ns:o(n)},{key:t.key,ns:o(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)||void 0===n||n.call(t))}))}})}function re(){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:o,onClick:r}){if(Y())return;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){let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=J(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a},handleChildList(e){let t=[];return t=t.concat(n.handleAttributes(e)),t=t.concat(n.handleText(e)),t},handleText:e=>J(t.getTextXPath(),e)});return n}(a,o),l=oe(a,n,r);function u(e){for(const t of e){const e=q(t),n=e?o.unwrap(e):null;if(n){const{text:a,keys:o}=n;Z(t,a);const r=W(e,o),s=i.getSuitableParent(t);l.register(s,t,r)}}}function c(e){J(`./descendant-or-self::*[@${M}]`,e).forEach((e=>{const t=e.getAttributeNode(M),n=i.getSuitableParent(t);l.register(n,t,{oldTextContent:"",keys:[{key:q(t)}],keyAttributeOnly:!0})}))}const g=new MutationObserver((e=>{if(t){for(const t of e){let e=[];switch(t.type){case"characterData":e=s.handleText(t.target);break;case"childList":c(t.target),e=s.handleChildList(t.target);break;case"attributes":c(t.target),e=s.handleAttributes(t.target)}u(e)}l.refreshAll()}})),d=a.targetElement||document.body;return t=!0,l.run(e),c(d),u(s.handleChildList(d)),g.observe(d,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),g.disconnect()},elementRegistry:l,wrapper:o}}return Object.freeze({run(t){e=a(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null===(a=null==e?void 0:(n=e.elementRegistry).forEachElement)||void 0===a||a.call(n,t)},highlight(t,n){const a=(null==e?void 0:e.elementRegistry.findAll(t,n))||[];return a.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){a.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}},findPositions(t,n){const a=(null==e?void 0:e.elementRegistry.findAll(t,n))||[],r=[];return a.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),a.forEach((e=>{const a=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{ee({key:t,ns:o(n)},{key:e.key,ns:o(e.ns)})&&r.push({position:{x:a.x,y:a.y,width:a.width,height:a.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),r},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}const ie=["",""],se=RegExp(`([${ie.join("")}]{9})+`,"gu");function le(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=>ie[Number(e)])).join("")}function ue(e){const t=Array.from(e).map((e=>ie.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 ce(){const e=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]})}();return Object.freeze({unwrap(t){const n=[],a=function(e){var t;const n=null===(t=e.match(se))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(ue))||[]}(t);a.forEach((t=>{const[a]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(t),o=e.numberToValue(a),{k:r,d:i,n:s}=(l=o,JSON.parse(l||"{}"));var l;n.push({key:r,defaultValue:i,ns:s})}));const o=function(e){return e.replace(se,"")}(t);return{text:o,keys:n}},wrap({key:t,defaultValue:n,translation:a,ns:o}){const r=function(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}({key:t,ns:o,defaultValue:n}),i=e.valueToNumber(r),s=a||"",l=le(String.fromCodePoint(i));return"string"==typeof s?s+l:s},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${ie[0]}${ie[0]}') or contains(., '${ie[1]}${ie[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${ie[0]}${ie[0]}') or contains(., '${ie[1]}${ie[0]}')]`})}function ge(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function de({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:o,ns:r}=function(e){let t=!1,n="",a="",o="KEY";const r={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{r.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",r.params[a]=n,n=""):(o="PARAM_VALUE",a=n,n=""):(o="PARAM_NAME",r.defaultValue=n,n=""):(o="PARAM_NAME",r.key=n,n=""):(o="DEFAULT_VALUE",i(n),n=""):(o="NAMESPACE",r.key=n,n=""):(o="DEFAULT_VALUE",r.key=n,n=""):t=!0;return"KEY"===o&&(r.key=n),"DEFAULT_VALUE"===o&&(r.defaultValue=n),"PARAM_VALUE"===o&&(r.params[a]=n),"NAMESPACE"===o&&i(n),r}(e);return{translated:n({key:t,params:a,defaultValue:o,ns:r,noWrap:!0}),key:t,params:a,defaultValue:o,ns:r}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e){return"string"==typeof e?e.replace(/[,:|\\]/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:o,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${r(e)}:${r(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==o?`,${r(o)}`:"",u="string"==typeof i?[i]:i,c=(null==u?void 0:u.length)?`|${u.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${c}${l}${s}${t}`},unwrap(n){const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,l=!1,u=0,c="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(c+=f.substr(u,d-u),u=d+t.length,"\\"===e){if(!ge(d,n)){c+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,c+=e+p.translated}return c+=n.substring(u),l?{text:c,keys:i}:{text:n,keys:[]}},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${e}') and contains(., '${t}')]`,getAttributeXPath:({tag:n,attribute:a})=>`descendant-or-self::${n}/@${a}[contains(., '${e}') and contains(., '${t}')]`})}const fe="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function pe(e){const t=fe.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function ve(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|pe(e[i]),n+=5,n>=8&&(r[o++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+o));return a}(r.buffer)}function he(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=ve(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}function me({message:e,recievingMessage:t,data:n,attempts:a=1}){let o=!1;const r=()=>new Promise(((a,o)=>{const r=function(e,t){const n=n=>{var a,o;e.includes(null===(a=n.data)||void 0===a?void 0:a.type)&&t(null===(o=n.data)||void 0===o?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(i),s(),a(e)}));window.postMessage({type:e,data:n},window.origin);const i=setTimeout((function(){s(),o()}),300);function s(){r.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<a;e++){if(o)return new Promise((()=>{}));try{return await r()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}const be="tolgee-in-context-tools.umd.min.js",ye="@tolgee/in-context-tools",Ee="InContextTools",Le="https://cdn.jsdelivr.net/npm";let Oe=null;function we(e){var t;return Oe||(Oe=(t=`${Le}/@tolgee/web@${e}/dist/${be}`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window[ye][Ee]))),Oe}const ke="__tolgee_apiKey",Ae="__tolgee_apiUrl";function je(){const e=sessionStorage.getItem(ke)||void 0,t=sessionStorage.getItem(Ae)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Te(){sessionStorage.removeItem(ke),sessionStorage.removeItem(Ae)}e.BrowserExtensionPlugin=()=>e=>e,"undefined"!=typeof window&&"undefined"!=typeof sessionStorage&&(e.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=me({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(Te)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return je()&&(async()=>{const e=await we("5.9.2-prerelease.41828ff8.0");return t=>{const n=je();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 Pe="__tolgee_currentLanguage";function xe(e){return e.endsWith("/")?e.slice(0,-1):e}const Ne={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${xe(n)}/${e}/${t}.json`:`${xe(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Re(e){const t=Object.assign(Object.assign(Object.assign({},Ne),e),{headers:Object.assign(Object.assign({},Ne.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:a,getData:o,headers:r}=t,i=function(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 o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}(t,["prefix","getPath","getData","headers"]);return{getRecord({namespace:e,language:t}){const s=a({namespace:e,language:t,prefix:n});return fetch(s,Object.assign({headers:r},i)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return o(e)}))}}}e.BackendFetch=e=>(t,n)=>(n.addBackend(Re(e)),t),e.DEVTOOLS_ID=B,e.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o}){var r;const i=null!==(r=he(t))&&void 0!==r?r:o;let s=void 0!==i?`${e}/v2/projects/${i}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(s+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return fetch(s,{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})=>F(e,t)}),e),e.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){G("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=a(window.navigator.language);return e.find((e=>a(e)===o))||void 0}}),e),e.LanguageStorage=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(G("LanguageStorage"),localStorage.getItem(Pe)||void 0),setLanguage(e){G("LanguageStorage"),localStorage.setItem(Pe,e)}}),e),e.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=re();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=de({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(Object.assign(Object.assign({},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&&Z(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=re();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=ce();e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),e.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",e.TOLGEE_ATTRIBUTE_NAME=z,e.TOLGEE_RESTRICT_ATTRIBUTE=V,e.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=M,e.Tolgee=function(){return k().use(e.BrowserExtensionPlugin())},e.TolgeeCore=k,e.getFallback=o,e.getFallbackArray=r,e.getProjectIdFromApiKey=he,e.getTranslateProps=O,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!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"]=e["@tolgee/web"]||{},e["@tolgee/web"].production={}))}(this,(function(e){"use strict";function t(e){return Boolean(e&&"function"==typeof e.then)}function n(e,n){return t(e)?Promise.resolve(e).then(n):n(e)}function a(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 o(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function r(e){return o(e)||[]}function i(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?r(t):r(null==t?void 0:t[e]);var n}function s(e){return Array.from(new Set(e))}function l(e){return e?e.replace(/\/+$/,""):e}function u(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 c(e,t,n){const a=new Set,o=new Set;let i=[];function s(){if(0===i.length)return;const e=i;i=[],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());o.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()&&(i.push(t),n?setTimeout(s,0):s())},listen(e){a.add(e);return{unsubscribe:()=>{a.delete(e)}}},listenSome(e){const t={fn:t=>{e(t)},namespaces:new Set};o.add(t);const a={unsubscribe:()=>{o.delete(t)},subscribeNs:e=>(r(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}const g=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):g(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},d=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},f=({language:e,namespace:t})=>t?`${e}:${t}`:e;function p(e,t,n,a,o,i,l){const u=new Map,c=new Map;let p={},v=0;function h(t,n,a){const o=f(t);c.set(o,{data:g(n),version:a}),e.emit(t)}function m(e){let n;if(!n){const t=p[f(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}const b=Object.freeze({addStaticData(e){e&&(p=Object.assign(Object.assign({},p),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=d(e),a=c.get(e);a&&0!==a.version||h(n,t,0)}})))},invalidate(){u.clear(),v+=1},addRecord(e,t){h(e,t,v)},exists(e,t=!1){const n=c.get(f(e));return n&&t?n.version===v:Boolean(n)},getRecord(e){var t;return null===(t=c.get(f(a(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=c.get(f(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=c.get(f({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return s(e)},getTranslationFallback(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=c.get(f({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var o;const r=null===(o=c.get(f(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(o())return!0;if(void 0===e)return u.size>0;const t=r(e);return Boolean(Array.from(u.keys()).find((e=>t.includes(d(e).namespace))))},isLoading(e,t){const n=r(t);return Boolean(o()||Array.from(u.keys()).find((t=>{const a=d(t);return(!n.length||n.includes(a.namespace))&&!b.exists({namespace:a.namespace,language:e})})))},async loadRecords(e,t){const o=e.map((e=>{const o=a(e),r=f(o),i=u.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const s=function(e,t){var a;let o;return t&&(o=null===(a=n(e))||void 0===a?void 0:a.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),m(e))))),o||(o=m(e)),o}(o,t)||Promise.resolve(void 0);return u.set(r,s),{new:!0,promise:s,keyObject:o,cacheKey:r}}));i.notify(),l.notify();const r=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=u.get(e.cacheKey)!==e.promise;if(e.new&&!n){u.delete(e.cacheKey);const n=r[t];n?b.addRecord(e.keyObject,n):b.getRecord(e.keyObject)||b.addRecord(e.keyObject,{})}})),i.notify(),l.notify(),o.map((e=>b.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(c.entries()).map((([e,t])=>Object.assign(Object.assign({},d(e)),{data:t.data})))});return b}function v(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 o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}const h="invalid",m={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"]},observerType:"invisible",onFormatError:h,apiUrl:"https://app.tolgee.io"},b=(...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 y(e,t){const n=b(m,null==t?void 0:t.initialOptions,e);return n.apiUrl=l(n.apiUrl),{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 E(e,a,o,r,i,s){const l={ui:void 0},u={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},c=async({keysAndDefaults:e,event:t})=>{var n;const a=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,ns:r({key:e,ns:t}),translation:i({key:e,ns:t})})));null===(n=u.ui)||void 0===n||n.handleElementClick(a,t)},g=(e,t)=>{var n;return(null===(n=u.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function d(e){const t=i({key:e.key,ns:e.ns});return A.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function f(e){u.observer=null==e?void 0:e()}function p(){return Boolean(u.observer)}function m(e){e&&u.formatters.push(e)}function b(e){u.finalFormatter=e}function y(e){l.ui=e}function E(){return Boolean(l.ui)}function L(e){u.languageStorage=e}function O(e){u.languageDetector=e}function w(e){e&&u.backends.push(e)}function k(e){u.devBackend=e}const A=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:b,addFormatter:m,setObserver:f,hasObserver:p,setUi:y,hasUi:E,setDevBackend:k,addBackend:w,setLanguageDetector:O,setLanguageStorage:L}))},run(){var e,t;const{apiKey:n,apiUrl:o,projectId:r,observerOptions:i}=a();u.ui=null===(e=l.ui)||void 0===e?void 0:e.call(l,{apiKey:n,apiUrl:o,projectId:r,highlight:A.highlight,changeTranslation:s,findPositions:g}),null===(t=u.observer)||void 0===t||t.run({mouseHighlight:!0,options:i,translate:d,onClick:c})},stop(){var e;u.ui=void 0,null===(e=u.observer)||void 0===e||e.stop()},getLanguageStorage:()=>u.languageStorage,getInitialLanguage(){var e;const t=o();return n(null===(e=u.languageStorage)||void 0===e?void 0:e.getLanguage(),(e=>t&&!t.includes(e)||!e?function(){if(!u.languageDetector)return;const e=o();return u.languageDetector.getLanguage({availableLanguages:e})}():e))},setStoredLanguage(e){var t;null===(t=u.languageStorage)||void 0===t||t.setLanguage(e)},getDevBackend:()=>u.devBackend,getBackendRecord:({language:e,namespace:n})=>{for(const a of u.backends){const o=a.getRecord({language:e,namespace:n});if(t(o))return null==o?void 0:o.catch((e=>(console.error(e),{})));if(void 0!==o)return o}},getBackendDevRecord:({language:e,namespace:t})=>{var n;const{apiKey:o,apiUrl:r,projectId:i}=a();return null===(n=u.devBackend)||void 0===n?void 0:n.getRecord({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:t})},getLanguageDetector:()=>u.languageDetector,retranslate(){var e;null===(e=u.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,a;return(null===(a=null===(n=u.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return u.observer?null===(t=u.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return u.observer?null===(t=u.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(A.getDevBackend()),formatTranslation(t){var n,{formatEnabled:o}=t,r=v(t,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:c,params:g,orEmpty:d,ns:f}=r,p=s||l;let m=p||(d?"":i);const b=e(),y=o||!(null===(n=u.observer)||void 0===n?void 0:n.outputNotFormattable),E=e=>u.observer&&!c?u.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:f}):e;m=E(m);try{if(p&&b&&y)for(const e of u.formatters)m=e.format({translation:m,language:b,params:g});u.finalFormatter&&p&&b&&y&&(m=u.finalFormatter.format({translation:m,language:b,params:g}))}catch(e){console.error(e);const t=("string"==typeof(L=e)?L:"string"==typeof(null==L?void 0:L.message)?L.message:void 0)||h,n=a().onFormatError,o=typeof n;m="string"===o?n:"function"===o?n(t,r):h,m=E(m)}var L;return m}});return A}const L=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const O=(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:o,language:r}=e,i=v(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:r};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function w({options:e}){const o=function(e,t){let n=!0;function a(){return n}const o=Object.freeze({onPendingLanguageChange:u(a),onLanguageChange:u(a),onLoadingChange:u(a),onFetchingChange:u(a),onInitialLoaded:u(a),onRunningChange:u(a),onCacheChange:u(a),onUpdate:c(a,e,t),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.onPendingLanguageChange.listen(t);case"language":return o.onLanguageChange.listen(t);case"loading":return o.onLoadingChange.listen(t);case"fetching":return o.onFetchingChange.listen(t);case"initialLoad":return o.onInitialLoaded.listen(t);case"running":return o.onRunningChange.listen(t);case"cache":return o.onCacheChange.listen(t);case"update":return o.onUpdate.listen(t)}}});return o.onInitialLoaded.listen((()=>o.onUpdate.emit())),o.onLanguageChange.listen((()=>o.onUpdate.emit())),o.onCacheChange.listen((({value:e})=>o.onUpdate.emit([e.namespace],!0))),o}(b,w),g=L(!1,(()=>m.isFetching()),o.onFetchingChange.emit),f=L(!1,(()=>R.isLoading()),o.onLoadingChange.emit),v=function(e,t,n){let a,o=y();const u=Object.freeze({init(e){o=y(e,o)},isRunning:()=>o.isRunning,setRunning(e){o.isRunning!==e&&(o.isRunning=e,n.emit(e))},isInitialLoading:()=>o.isInitialLoading,setInitialLoading(e){o.isInitialLoading=e},getLanguage:()=>o.language||o.initialOptions.language,setLanguage(t){o.language!==t&&(o.language=t,e.emit(t))},getPendingLanguage:()=>o.pendingLanguage||u.getLanguage(),setPendingLanguage(e){o.pendingLanguage!==e&&(o.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},o.initialOptions),a),addActiveNs(e){r(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t?o.activeNamespaces.set(e,t+1):o.activeNamespaces.set(e,1)}))},removeActiveNs(e){r(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t&&t>1?o.activeNamespaces.set(e,t-1):o.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>s([...o.initialOptions.ns||[o.initialOptions.defaultNs],...r(o.initialOptions.fallbackNs),...o.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||u.getLanguage();return t?s([t,...i(t,o.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>r(o.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?o.initialOptions.defaultNs:e,getAvailableLanguages(){if(o.initialOptions.availableLanguages)return o.initialOptions.availableLanguages;if(o.initialOptions.staticData){const e=Object.keys(o.initialOptions.staticData).map((e=>d(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?u.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:l(e.apiUrl)}):void 0}});return u}(o.onLanguageChange,o.onPendingLanguageChange,o.onRunningChange),h=E(v.getLanguage,v.getInitialOptions,v.getAvailableLanguages,(function({key:e,ns:t}){const n=v.getFallbackLangs(),a=k(t||void 0);return m.getTranslationNs(a,n,e)}),x,j),m=p(o.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,v.withDefaultNs,v.isInitialLoading,g,f);function b(){return v.getFallbackNs()}function w(e){return v.getDefaultNs(e)}function k(e){return[...r(w(e)),...b()]}function A(e){return[...r(e||w()),...v.getRequiredNamespaces()]}function j(e,t,n){const a=v.withDefaultNs(e),o=m.getTranslation(a,t);return m.changeTranslation(a,t,n),{revert(){m.changeTranslation(a,t,o)}}}function T(e){v.init(e),m.addStaticData(v.getInitialOptions().staticData)}function P(e,t){const a=function(e,t){const n=v.getFallbackLangs(e),a=A(t),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}(e,t);if(a.length)return n(R.loadRecords(a),(()=>{}))}function x({key:e,ns:t,language:n}){const a=k(t||void 0),o=v.getFallbackLangs(n);return m.getTranslationFallback(a,o,e)}function N(){const e=n(function(){if(v.getLanguage())return;return n(h.getInitialLanguage(),(e=>{const t=e||v.getInitialOptions().defaultLanguage;t&&v.setLanguage(t)}))}(),(()=>P()));if(t(e))return v.setInitialLoading(!0),g.notify(),f.notify(),Promise.resolve(e).then((()=>{v.setInitialLoading(!1),g.notify(),f.notify(),o.onInitialLoaded.emit()}));o.onInitialLoaded.emit()}e&&T(e),o.onUpdate.listen((()=>{v.isRunning()&&h.retranslate()}));const R=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},o),v),h),m),{init:T,getTranslation:x,changeTranslation:j,async changeLanguage(e){v.getPendingLanguage()===e&&v.getLanguage()===e||(v.setPendingLanguage(e),v.isRunning()&&await P(e),e===v.getPendingLanguage()&&(v.setLanguage(e),h.setStoredLanguage(e)))},async addActiveNs(e,t){t||v.addActiveNs(e),v.isRunning()&&await P(void 0,e)},loadRecords:e=>m.loadRecords(e,R.isDev()),loadRecord:async e=>(await R.loadRecords([e]))[0],isLoading:e=>m.isLoading(v.getLanguage(),e),isLoaded(e){const t=v.getLanguage();if(!t)return!1;const n=v.getFallbackLangs(t),a=A(e),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=O(...e),n=x(t);return h.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(v.getInitialOptions().apiKey&&v.getInitialOptions().apiUrl),run(){let e;return function(){if((h.getLanguageDetector()||h.getLanguageStorage())&&!v.getAvailableLanguages())throw new Error(a("availableLanguages"));if(!v.getLanguage()&&!v.getInitialOptions().defaultLanguage)throw new Error(a(["defaultLanguage","language"]))}(),v.isRunning()||(R.isDev()&&m.invalidate(),v.setRunning(!0),h.run(),e=N()),Promise.resolve(e)},stop(){v.isRunning()&&(h.stop(),v.setRunning(!1))}}));return R}const k=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=b(e.options,n),t),init(t){const n=function(e){const t=w({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),n&&t.run()}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,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,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}(b(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},A=0,j=1,T=2;class P extends Error{constructor(e,t,n){let a;a=e===A?"Empty parameter":e===j?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function x(e){return/\s/.test(e)}const N=0,R=1,S=2,C=3,D=4,I=new Set([S,R,N]),$="'",_=new Set(["{","}",$]),U=e=>/[0-9a-zA-Z_]/.test(e);function F(e,t){const[n,a]=function(e){let t=N,n="",a="",o="";const r=[],i=[];let s=0;function l(t){throw new P(t,s,e)}const u=()=>{r.push(n),n=""},c=()=>{""===a&&l(A),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case N:o===$?(n+=o,t=R):"{"===o?(u(),t=C):(n+=o,t=N);break;case R:_.has(o)?(n=n.slice(0,-1)+o,t=S):(n+=o,t=N);break;case S:o===$?t=N:(n+=o,t=S);break;case C:"}"===o?(c(),t=N):x(o)?""!==a&&(c(),t=D):(U(o)||l(j),a+=o,t=C);break;case D:"}"==o?t=N:x(o)?t=D:l(j)}return I.has(t)||l(T),u(),[r,i]}(e),o=[n[0]];for(let r=1;r<n.length;r++){const i=null==t?void 0:t[a[r-1]];if(void 0===i)throw new Error(`Missing parameter "${a[r-1]}" in "${e}"`);o.push(String(i)),o.push(n[r])}return o.join("")}const B="__tolgee_dev_tools",M="data-tolgee-key-only",V="data-tolgee-restricted",z="_tolgee",K="_tolgee-highlighter";function Y(){var e,t;return void 0===(null===(t=null===(e=globalThis.window)||void 0===e?void 0:e.document)||void 0===t?void 0:t.createElement)}function G(e){if(Y())throw new Error(`${e}: Can't run on the server`)}function W(e,t){return{oldTextContent:e,keys:t}}const X={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function H({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(K),Object.entries(X).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const r=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=r.top-t+"px",o.style.left=r.left-t+"px",o.style.width=r.width+"px",o.style.height=r.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,a)}})}function J(e,t){var n;const a=function(e){switch(e.nodeType){case Node.ATTRIBUTE_NODE:return e.ownerElement||void 0;case Node.TEXT_NODE:return e.parentElement||void 0;case Node.DOCUMENT_NODE:case Node.ELEMENT_NODE:return e;default:return}}(t),o=[];if(!a)return o;const r=null===document||void 0===document?void 0:document.evaluate(e,a,void 0,XPathResult.ANY_TYPE);let i;for(;i=null===(n=null==r?void 0:r.iterateNext)||void 0===n?void 0:n.call(r);)o.push(i);return o}function q(e){return e.textContent}function Z(e,t){e.textContent=t}function Q(e,t){if(e.contains(t))return!0;if(t instanceof Attr){const n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}function ee(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null===(n=e.ns)||void 0===n?void 0:n.findIndex((e=>{var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return a&&o}const te={capture:!0},ne={capture:!0,passive:!0};function ae({highlightKeys:e,elementStore:t,onClick:n,options:a}){var o,r;let i,s,l=new Set;const u=(null===(o=a.targetElement)||void 0===o?void 0:o.getRootNode())||document,c=(null===(r=a.targetElement)||void 0===r?void 0:r.ownerDocument)||document;function g(){var e;const n=t.get(i);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),i=void 0)}function d(){const e=s;let n;if(e&&L()){const a=u.elementFromPoint(e.x,e.y);a&&(n=function(e){return E(e,(e=>t.get(e)))}(a))}!function(e){var n;if(i!==e){g();const a=t.get(e);a&&(a.preventClean=!0,null===(n=a.highlight)||void 0===n||n.call(a),i=e)}}(n)}function f(e){var t;L()&&(t=e.target,!Boolean(E(t,(e=>e.id===B))))&&(e.stopPropagation(),e.preventDefault())}function p(e){var t;t={x:e.clientX,y:e.clientY},s=t,d()}function v(){l=new Set,d()}function h(e){const t=e.key;void 0!==t&&l.add(t),d()}function m(e){l.delete(e.key),d()}function b(){var e;const n=t.get(i);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)}function y(e){f(e),L()&&i&&(n(e,i),g())}function E(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?E(e.parentElement,t):void 0}function L(){for(const t of e)if(!l.has(t))return!1;return!0}return Object.freeze({stop(){c.removeEventListener("blur",v,te),c.removeEventListener("keydown",h,te),c.removeEventListener("keyup",m,te),c.removeEventListener("mousemove",p,ne),c.removeEventListener("scroll",b,ne),c.removeEventListener("click",y,te),c.removeEventListener("mouseenter",f,te),c.removeEventListener("mouseover",f,te),c.removeEventListener("mouseout",f,te),c.removeEventListener("mouseleave",f,te),c.removeEventListener("mousedown",f,te),c.removeEventListener("mouseup",f,te)},run(){c.addEventListener("blur",v,te),c.addEventListener("keydown",h,te),c.addEventListener("keyup",m,te),c.addEventListener("mousemove",p,ne),c.addEventListener("scroll",b,ne),c.addEventListener("click",y,te),c.addEventListener("mouseenter",f,te),c.addEventListener("mouseover",f,te),c.addEventListener("mouseout",f,te),c.addEventListener("mouseleave",f,te),c.addEventListener("mousedown",f,te),c.addEventListener("mouseup",f,te)}})}function oe(e,t,n){const a=H({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=ae({highlightKeys:e.highlightKeys,elementStore:t,onClick(e,a){const o=t.get(a);n({event:e,keysAndDefaults:l(o)})},options:e});function i(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())Q(s(),t)&&(yield[t,n])}(e))}function s(){return e.targetElement||document.body}function l(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({register(n,o,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${V}]`)}(n))return;const i=n;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(z,"true")),s.nodes.set(o,r),a.initHighlighter(i,s)},forEachElement:t.forEachElement,refreshAll(){t.forEachElement(((e,n)=>{n.preventClean||(i(n),0===n.nodes.size&&function(e,n){var a;n.highlightEl&&(null===(a=n.unhighlight)||void 0===a||a.call(n)),e.removeAttribute(z),t.remove(e)}(e,n))}))},findAll(e,n){const a=[];return t.forEachElement(((t,r)=>{for(const t of r.nodes.values()){if(t.keys.find((t=>ee({key:e,ns:o(n)},{key:t.key,ns:o(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)||void 0===n||n.call(t))}))}})}function re(){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:o,onClick:r}){if(Y())return;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){let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=J(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a},handleChildList(e){let t=[];return t=t.concat(n.handleAttributes(e)),t=t.concat(n.handleText(e)),t},handleText:e=>J(t.getTextXPath(),e)});return n}(a,o),l=oe(a,n,r);function u(e){for(const t of e){const e=q(t),n=e?o.unwrap(e):null;if(n){const{text:a,keys:o}=n;Z(t,a);const r=W(e,o),s=i.getSuitableParent(t);l.register(s,t,r)}}}function c(e){J(`./descendant-or-self::*[@${M}]`,e).forEach((e=>{const t=e.getAttributeNode(M),n=i.getSuitableParent(t);l.register(n,t,{oldTextContent:"",keys:[{key:q(t)}],keyAttributeOnly:!0})}))}const g=new MutationObserver((e=>{if(t){for(const t of e){let e=[];switch(t.type){case"characterData":e=s.handleText(t.target);break;case"childList":c(t.target),e=s.handleChildList(t.target);break;case"attributes":c(t.target),e=s.handleAttributes(t.target)}u(e)}l.refreshAll()}})),d=a.targetElement||document.body;return t=!0,l.run(e),c(d),u(s.handleChildList(d)),g.observe(d,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),g.disconnect()},elementRegistry:l,wrapper:o}}return Object.freeze({run(t){e=a(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null===(a=null==e?void 0:(n=e.elementRegistry).forEachElement)||void 0===a||a.call(n,t)},highlight(t,n){const a=(null==e?void 0:e.elementRegistry.findAll(t,n))||[];return a.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){a.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}},findPositions(t,n){const a=(null==e?void 0:e.elementRegistry.findAll(t,n))||[],r=[];return a.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),a.forEach((e=>{const a=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{ee({key:t,ns:o(n)},{key:e.key,ns:o(e.ns)})&&r.push({position:{x:a.x,y:a.y,width:a.width,height:a.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),r},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}const ie=["",""],se=RegExp(`([${ie.join("")}]{9})+`,"gu");function le(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=>ie[Number(e)])).join("")}function ue(e){const t=Array.from(e).map((e=>ie.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 ce(){const e=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]})}();return Object.freeze({unwrap(t){const n=[],a=function(e){var t;const n=null===(t=e.match(se))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(ue))||[]}(t);a.forEach((t=>{const[a]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(t),o=e.numberToValue(a),{k:r,d:i,n:s}=(l=o,JSON.parse(l||"{}"));var l;n.push({key:r,defaultValue:i,ns:s})}));const o=function(e){return e.replace(se,"")}(t);return{text:o,keys:n}},wrap({key:t,defaultValue:n,translation:a,ns:o}){const r=function(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}({key:t,ns:o,defaultValue:n}),i=e.valueToNumber(r),s=a||"",l=le(String.fromCodePoint(i));return"string"==typeof s?s+l:s},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${ie[0]}${ie[0]}') or contains(., '${ie[1]}${ie[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${ie[0]}${ie[0]}') or contains(., '${ie[1]}${ie[0]}')]`})}function ge(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function de({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:o,ns:r}=function(e){let t=!1,n="",a="",o="KEY";const r={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{r.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",r.params[a]=n,n=""):(o="PARAM_VALUE",a=n,n=""):(o="PARAM_NAME",r.defaultValue=n,n=""):(o="PARAM_NAME",r.key=n,n=""):(o="DEFAULT_VALUE",i(n),n=""):(o="NAMESPACE",r.key=n,n=""):(o="DEFAULT_VALUE",r.key=n,n=""):t=!0;return"KEY"===o&&(r.key=n),"DEFAULT_VALUE"===o&&(r.defaultValue=n),"PARAM_VALUE"===o&&(r.params[a]=n),"NAMESPACE"===o&&i(n),r}(e);return{translated:n({key:t,params:a,defaultValue:o,ns:r,noWrap:!0}),key:t,params:a,defaultValue:o,ns:r}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e){return"string"==typeof e?e.replace(/[,:|\\]/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:o,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${r(e)}:${r(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==o?`,${r(o)}`:"",u="string"==typeof i?[i]:i,c=(null==u?void 0:u.length)?`|${u.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${c}${l}${s}${t}`},unwrap(n){const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,l=!1,u=0,c="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(c+=f.substr(u,d-u),u=d+t.length,"\\"===e){if(!ge(d,n)){c+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,c+=e+p.translated}return c+=n.substring(u),l?{text:c,keys:i}:{text:n,keys:[]}},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${e}') and contains(., '${t}')]`,getAttributeXPath:({tag:n,attribute:a})=>`descendant-or-self::${n}/@${a}[contains(., '${e}') and contains(., '${t}')]`})}const fe="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function pe(e){const t=fe.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function ve(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|pe(e[i]),n+=5,n>=8&&(r[o++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+o));return a}(r.buffer)}function he(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=ve(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}function me({message:e,recievingMessage:t,data:n,attempts:a=1}){let o=!1;const r=()=>new Promise(((a,o)=>{const r=function(e,t){const n=n=>{var a,o;e.includes(null===(a=n.data)||void 0===a?void 0:a.type)&&t(null===(o=n.data)||void 0===o?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(i),s(),a(e)}));window.postMessage({type:e,data:n},window.origin);const i=setTimeout((function(){s(),o()}),300);function s(){r.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<a;e++){if(o)return new Promise((()=>{}));try{return await r()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}const be="tolgee-in-context-tools.umd.min.js",ye="@tolgee/in-context-tools",Ee="InContextTools",Le="https://cdn.jsdelivr.net/npm";let Oe=null;function we(e){var t;return Oe||(Oe=(t=`${Le}/@tolgee/web@${e}/dist/${be}`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window[ye][Ee]))),Oe}const ke="__tolgee_apiKey",Ae="__tolgee_apiUrl";function je(){const e=sessionStorage.getItem(ke)||void 0,t=sessionStorage.getItem(Ae)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Te(){sessionStorage.removeItem(ke),sessionStorage.removeItem(Ae)}e.BrowserExtensionPlugin=()=>e=>e,"undefined"!=typeof window&&"undefined"!=typeof sessionStorage&&(e.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=me({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(Te)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return je()&&(async()=>{const e=await we("5.9.2-prerelease.ce0c7097.0");return t=>{const n=je();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 Pe="__tolgee_currentLanguage";function xe(e){return e.endsWith("/")?e.slice(0,-1):e}const Ne={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${xe(n)}/${e}/${t}.json`:`${xe(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Re(e){const t=Object.assign(Object.assign(Object.assign({},Ne),e),{headers:Object.assign(Object.assign({},Ne.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:a,getData:o,headers:r}=t,i=function(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 o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}(t,["prefix","getPath","getData","headers"]);return{getRecord({namespace:e,language:t}){const s=a({namespace:e,language:t,prefix:n});return fetch(s,Object.assign({headers:r},i)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return o(e)}))}}}e.BackendFetch=e=>(t,n)=>(n.addBackend(Re(e)),t),e.DEVTOOLS_ID=B,e.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o}){var r;const i=null!==(r=he(t))&&void 0!==r?r:o;let s=void 0!==i?`${e}/v2/projects/${i}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(s+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return fetch(s,{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})=>F(e,t)}),e),e.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){G("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=a(window.navigator.language);return e.find((e=>a(e)===o))||void 0}}),e),e.LanguageStorage=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(G("LanguageStorage"),localStorage.getItem(Pe)||void 0),setLanguage(e){G("LanguageStorage"),localStorage.setItem(Pe,e)}}),e),e.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=re();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=de({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(Object.assign(Object.assign({},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&&Z(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=re();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=ce();e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),e.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",e.TOLGEE_ATTRIBUTE_NAME=z,e.TOLGEE_RESTRICT_ATTRIBUTE=V,e.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=M,e.Tolgee=function(){return k().use(e.BrowserExtensionPlugin())},e.TolgeeCore=k,e.getFallback=o,e.getFallbackArray=r,e.getProjectIdFromApiKey=he,e.getTranslateProps=O,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=tolgee-web.production.umd.min.js.map |
{ | ||
"name": "@tolgee/web", | ||
"version": "5.9.2-prerelease.41828ff8.0", | ||
"version": "5.9.2-prerelease.ce0c7097.0", | ||
"description": "Tolgee for web", | ||
@@ -47,3 +47,3 @@ "declaration": true, | ||
"dependencies": { | ||
"@tolgee/core": "5.9.2-prerelease.41828ff8.0" | ||
"@tolgee/core": "5.9.2-prerelease.ce0c7097.0" | ||
}, | ||
@@ -102,3 +102,3 @@ "devDependencies": { | ||
"homepage": "https://github.com/tolgee/tolgee-js#readme", | ||
"gitHead": "307d5e25cbc19f13c4a18947a2e30dfe93e1ce0f", | ||
"gitHead": "856cbb8a0ab4c3e83000929eff37eff2535891ed", | ||
"publishConfig": { | ||
@@ -105,0 +105,0 @@ "access": "public" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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 too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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 too big to display
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.9.2-prerelease.ce0c7097.0(transitive)
- Removed@tolgee/core@5.9.2-prerelease.41828ff8.0(transitive)