@tolgee/web
Advanced tools
Comparing version 5.3.1 to 5.3.2-rc.7c739ee7.0
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});function e(){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 t(t){if(e())throw new Error(`${t}: Can't run on the server`)}function n(e,t){return{oldTextContent:e,keys:t}}function a(e){return Boolean(e&&"function"==typeof e.then)}const o=(e,t)=>a(e)?Promise.resolve(e).then(t):t(e),r=e=>`Tolgee: You need to specify '${e}' option`;function i(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function s(e){return i(e)||[]}function l(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?s(t):s(null==t?void 0:t[e]);var n}function u(e){return Array.from(new Set(e))}function c(e){return e?e.replace(/\/+$/,""):e}const g=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})))}})},d=(e,t,n)=>{const a=new Set,o=new Set;let r=[];const i=()=>{if(0===r.length)return;const e=r;r=[],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)))}));(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({listenSome:e=>{const t={fn:t=>{e(t)},namespaces:new Set};o.add(t);const a={unsubscribe:()=>{o.delete(t)},subscribeNs:e=>(s(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a},listen:e=>{a.add(e);return{unsubscribe:()=>{a.delete(e)}}},emit:(t,n)=>{e()&&(r.push(t),n?setTimeout(i,0):i())}})},f=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):f(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},p=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},v=({language:e,namespace:t})=>t?`${e}:${t}`:e,h=(e,t,n,a,o,r,i)=>{const l=new Map,c=new Map;let g={},d=0;function h(t,n,a){const o=v(t);c.set(o,{data:f(n),version:a}),e.emit(t)}function m(e,t){h(e,t,d)}function b(e,t=!1){const n=c.get(v(e));return n&&t?n.version===d:Boolean(n)}function y(e){var t;return null===(t=c.get(v(a(e))))||void 0===t?void 0:t.data}function E(e){let n;if(!n){const t=g[v(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}return Object.freeze({addStaticData:function(e){e&&(g=Object.assign(Object.assign({},g),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=p(e),a=c.get(e);a&&0!==a.version||h(n,t,0)}})))},invalidate:function(){l.clear(),d+=1},addRecord:m,exists:b,getRecord:y,getTranslation:function(e,t){var n;return null===(n=c.get(v(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs:function(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=c.get(v({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return u(e)},getTranslationFallback:function(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=c.get(v({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation:function(t,n,a){var o;const r=null===(o=c.get(v(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching:function(e){if(o())return!0;if(void 0===e)return l.size>0;const t=s(e);return Boolean(Array.from(l.keys()).find((e=>t.includes(p(e).namespace))))},isLoading:function(e,t){const n=s(t);return Boolean(o()||Array.from(l.keys()).find((t=>{const a=p(t);return(!n.length||n.includes(a.namespace))&&!b({namespace:a.namespace,language:e})})))},loadRecords:async function(e,t){const o=e.map((e=>{const o=a(e),r=v(o),i=l.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"),E(e))))),o||(o=E(e)),o}(o,t)||Promise.resolve(void 0);return l.set(r,s),{new:!0,promise:s,keyObject:o,cacheKey:r}}));r.notify(),i.notify();const s=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=l.get(e.cacheKey)!==e.promise;if(e.new&&!n){l.delete(e.cacheKey);const n=s[t];n?m(e.keyObject,n):y(e.keyObject)||m(e.keyObject,{})}})),r.notify(),i.notify(),o.map((e=>y(e.keyObject)))},getAllRecords:function(){return Array.from(c.entries()).map((([e,t])=>Object.assign(Object.assign({},p(e)),{data:t.data})))}})};function m(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 b={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:"invalid",apiUrl:"https://app.tolgee.io"},y=(...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},E=(e,t)=>{const n=y(b,null==t?void 0:t.initialOptions,e);return n.apiUrl=c(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}},w=(e,t,n,r,i,s)=>{const l={ui:void 0,observer: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,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(){}}},d=e=>{const t=i({key:e.key,ns:e.ns});return A(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))},f=e=>{l.observer=e},p=()=>Boolean(l.observer),v=e=>{e&&u.formatters.push(e)},h=e=>{u.finalFormatter=e},b=e=>{l.ui=e},y=()=>Boolean(l.ui),E=e=>{u.languageStorage=e},w=e=>{u.languageDetector=e},L=e=>{e&&u.backends.push(e)},O=e=>{u.devBackend=e},k=()=>u.devBackend;function A(n){var a,{formatEnabled:o}=n,r=m(n,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:c,params:g,orEmpty:d,ns:f}=r,p=s||l;let v=p||(d?"":i);const h=e(),b=o||!(null===(a=u.observer)||void 0===a?void 0:a.outputNotFormattable),y=e=>u.observer&&!c?u.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:f}):e;v=y(v);try{if(p&&h&&b)for(const e of u.formatters)v=e.format({translation:v,language:h,params:g});u.finalFormatter&&p&&h&&b&&(v=u.finalFormatter.format({translation:v,language:h,params:g}))}catch(e){console.error(e);const n=("string"==typeof(E=e)?E:"string"==typeof(null==E?void 0:E.message)?E.message:void 0)||"invalid",a=t().onFormatError,o=typeof a;v="string"===o?a:"function"===o?a(n,r):"invalid",v=y(v)}var E;return v}return Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:h,addFormatter:v,setObserver:f,hasObserver:p,setUi:b,hasUi:y,setDevBackend:O,addBackend:L,setLanguageDetector:w,setLanguageStorage:E}))},formatTranslation:A,getDevBackend:k,getBackendRecord:({language:e,namespace:t})=>{for(const n of u.backends){const o=n.getRecord({language:e,namespace:t});if(a(o))return null==o?void 0:o.catch((e=>(console.error(e),{})));if(void 0!==o)return o}},getBackendDevRecord:({language:e,namespace:n})=>{var a;const{apiKey:o,apiUrl:r,projectId:i}=t();return null===(a=u.devBackend)||void 0===a?void 0:a.getRecord({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:n})},getLanguageDetector:()=>u.languageDetector,getLanguageStorage:()=>u.languageStorage,getInitialLanguage:()=>{var e;const t=n(),a=null===(e=u.languageStorage)||void 0===e?void 0:e.getLanguage();return o(a,(e=>t&&!t.includes(e)||!e?(()=>{if(!u.languageDetector)return;const e=n();return u.languageDetector.getLanguage({availableLanguages:e})})():e))},setStoredLanguage:e=>{var t;null===(t=u.languageStorage)||void 0===t||t.setLanguage(e)},run:()=>{var e,n,a;if(!u.ui){const{apiKey:n,apiUrl:a,projectId:o}=t();u.ui=null===(e=l.ui)||void 0===e?void 0:e.call(l,{apiKey:n,apiUrl:a,projectId:o,highlight:g,changeTranslation:s})}u.observer||(u.observer=null===(n=l.observer)||void 0===n?void 0:n.call(l,{translate:d,onClick:c,options:t().observerOptions})),null===(a=u.observer)||void 0===a||a.run({mouseHighlight:!0})},stop:()=>{var e;u.ui=void 0,null===(e=u.observer)||void 0===e||e.stop()},retranslate:()=>{var e;null===(e=u.observer)||void 0===e||e.retranslate()},highlight:g,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:function(){return Boolean(k())}})},L=(e,t,n)=>{let a=e;return Object.freeze({init:function(e){a=e},notify:function(){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}=e,r=m(e,["ns","noWrap","orEmpty","params"]);const i={ns:t,noWrap:n,orEmpty:a};return Object.assign(Object.assign({},i),{params:Object.assign({},r)})}(n)),a)),a},k=({options:e})=>{const t=((e,t)=>{let n=!0;function a(){return n}const o=g(a),r=g(a),i=g(a),s=g(a),l=g(a),u=g(a),c=g(a),f=d(a,e,t);return l.listen((()=>f.emit())),r.listen((()=>f.emit())),c.listen((({value:e})=>{f.emit([e.namespace],!0)})),Object.freeze({onPendingLanguageChange:o,onLanguageChange:r,onLoadingChange:i,onFetchingChange:s,onInitialLoaded:l,onRunningChange:u,onCacheChange:c,onUpdate:f,setEmmiterActive:function(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.listen(t);case"language":return r.listen(t);case"loading":return i.listen(t);case"fetching":return s.listen(t);case"initialLoad":return l.listen(t);case"running":return u.listen(t);case"cache":return c.listen(t);case"update":return f.listen(t)}}})})(b,y),n=L(!1,(()=>m.isFetching()),t.onFetchingChange.emit),i=L(!1,(()=>T()),t.onLoadingChange.emit),f=((e,t,n)=>{let a,o=E();function r(){return o.language||o.initialOptions.language}function i(){return Object.assign(Object.assign({},o.initialOptions),a)}return Object.freeze({init:function(e){o=E(e,o)},isRunning:function(){return o.isRunning},setRunning:function(e){o.isRunning!==e&&(o.isRunning=e,n.emit(e))},isInitialLoading:function(){return o.isInitialLoading},setInitialLoading:function(e){o.isInitialLoading=e},getLanguage:r,setLanguage:function(t){o.language!==t&&(o.language=t,e.emit(t))},getPendingLanguage:function(){return o.pendingLanguage||r()},setPendingLanguage:function(e){o.pendingLanguage!==e&&(o.pendingLanguage=e,t.emit(e))},getInitialOptions:i,addActiveNs:function(e){s(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t?o.activeNamespaces.set(e,t+1):o.activeNamespaces.set(e,1)}))},removeActiveNs:function(e){s(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:function(){return u([...o.initialOptions.ns||[o.initialOptions.defaultNs],...s(o.initialOptions.fallbackNs),...o.activeNamespaces.keys()])},getFallbackLangs:function(e){const t=e||r();return t?u([t,...l(t,o.initialOptions.fallbackLanguage)]):[]},getFallbackNs:function(){return s(o.initialOptions.fallbackNs)},getDefaultNs:function(e){return void 0===e?o.initialOptions.defaultNs:e},getAvailableLanguages:function(){if(o.initialOptions.availableLanguages)return o.initialOptions.availableLanguages;if(o.initialOptions.staticData){const e=Object.keys(o.initialOptions.staticData).map((e=>p(e).language));return Array.from(new Set(e))}},withDefaultNs:function(e){return{namespace:void 0===e.namespace?i().defaultNs:e.namespace,language:e.language}},overrideCredentials:function(e){a=e?Object.assign(Object.assign({},e),{apiUrl:c(e.apiUrl)}):void 0}})})(t.onLanguageChange,t.onPendingLanguageChange,t.onRunningChange),v=w(f.getLanguage,f.getInitialOptions,f.getAvailableLanguages,(function({key:e,ns:t}){const n=f.getFallbackLangs(),a=k(t||void 0);return m.getTranslationNs(a,n,e)}),_,j),m=h(t.onCacheChange,v.getBackendRecord,v.getBackendDevRecord,f.withDefaultNs,f.isInitialLoading,n,i);function b(){return f.getFallbackNs()}function y(e){return f.getDefaultNs(e)}function k(e){return[...s(y(e)),...b()]}function A(e){return[...s(e||y()),...f.getRequiredNamespaces()]}function j(e,t,n){const a=f.withDefaultNs(e),o=m.getTranslation(a,t);return m.changeTranslation(a,t,n),{revert:()=>{m.changeTranslation(a,t,o)}}}function x(e){f.init(e),m.addStaticData(f.getInitialOptions().staticData)}function T(e){return m.isLoading(f.getLanguage(),e)}function P(){return Boolean(f.getInitialOptions().apiKey&&f.getInitialOptions().apiUrl)}function N(e,t){const n=function(e,t){const n=f.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(n.length)return o(R(n),(()=>{}))}function _({key:e,ns:t}){const n=k(t||void 0),a=f.getFallbackLangs();return m.getTranslationFallback(n,a,e)}function S(){const e=o(function(){if(f.getLanguage())return;if(!f.getInitialOptions().defaultLanguage)throw new Error(r("defaultLanguage"));const e=v.getInitialLanguage();return o(e,(e=>{const t=e||f.getInitialOptions().defaultLanguage;t&&f.setLanguage(t)}))}(),(()=>N()));if(a(e))return f.setInitialLoading(!0),n.notify(),i.notify(),Promise.resolve(e).then((()=>{f.setInitialLoading(!1),n.notify(),i.notify(),t.onInitialLoaded.emit()}));t.onInitialLoaded.emit()}function R(e){return m.loadRecords(e,P())}e&&x(e),t.onUpdate.listen((()=>{f.isRunning()&&v.retranslate()}));return Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),f),v),m),{init:x,changeLanguage:async function(e){f.getPendingLanguage()===e&&f.getLanguage()===e||(f.setPendingLanguage(e),f.isRunning()&&await N(e),e===f.getPendingLanguage()&&(f.setLanguage(e),v.setStoredLanguage(e)))},getTranslation:_,changeTranslation:j,addActiveNs:async function(e,t){t||f.addActiveNs(e),f.isRunning()&&await N(void 0,e)},loadRecords:R,loadRecord:async function(e){return(await R([e]))[0]},isLoading:T,isLoaded:function(e){const t=f.getLanguage();if(!t)return!1;const n=f.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=_(t);return v.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:P,run:function(){let e;return(()=>{const e=v.getLanguageDetector()||v.getLanguageStorage();if(e&&!f.getAvailableLanguages())throw new Error(r("availableLanguages"));if(!f.getLanguage()&&!f.getInitialOptions().defaultLanguage)throw e?new Error(r("defaultLanguage")):new Error(r("language"))})(),f.isRunning()||(P()&&m.invalidate(),f.setRunning(!0),v.run(),e=S()),Promise.resolve(e)},stop:function(){f.isRunning()&&(v.stop(),f.setRunning(!1))}}))},A=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=y(e.options,n),t),init(t){const n=(e=>{const t=k({options:e}),n=e=>{const n=t.isRunning();n&&t.stop(),e(),n&&t.run()},a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmmiterActive:t.setEmmiterActive,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})(y(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t};class j extends Error{constructor(e,t,n){let a;a=0===e?"Empty parameter":1===e?"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 T=new Set([2,1,0]),P=new Set(["{","}","'"]);function N(e,t){const[n,a]=function(e){let t=0,n="",a="",o="";const r=[],i=[];let s=0;function l(t){throw new j(t,s,e)}const u=()=>{r.push(n),n=""},c=()=>{""===a&&l(0),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case 0:"'"===o?(n+=o,t=1):"{"===o?(u(),t=3):(n+=o,t=0);break;case 1:P.has(o)?(n=n.slice(0,-1)+o,t=2):(n+=o,t=0);break;case 2:"'"===o?t=0:(n+=o,t=2);break;case 3:"}"===o?(c(),t=0):x(o)?""!==a&&(c(),t=4):(/[0-9a-zA-Z_]/.test(o)||l(1),a+=o,t=3);break;case 4:"}"==o?t=0:x(o)?t=4:l(1)}return T.has(t)||l(2),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 _={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"},S=({highlightColor:e,highlightWidth:t})=>Object.freeze({initHighlighter:function(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add("_tolgee-highlighter"),Object.entries(_).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 R(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 D(e){return e.textContent}function C(e,t){e.textContent=t}function I(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}const $=(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},U={capture:!0},F={capture:!0,passive:!0},B=({highlightKeys:e,elementStore:t,onClick:n})=>{let a,o,r=new Set;const i=()=>{var e;const n=t.get(a);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),a=void 0)};function s(){const e=o;let n;if(e&&m()){const t=document.elementFromPoint(e.x,e.y);t&&(n=v(t))}(e=>{var n;if(a!==e){i();const o=t.get(e);o&&(o.preventClean=!0,null===(n=o.highlight)||void 0===n||n.call(o),a=e)}})(n)}const l=e=>{var t;m()&&(t=e.target,!Boolean(h(t,(e=>"__tolgee_dev_tools"===e.id))))&&(e.stopPropagation(),e.preventDefault())},u=e=>{var t;t={x:e.clientX,y:e.clientY},o=t,s()},c=()=>{r=new Set,s()},g=e=>{const t=e.key;void 0!==t&&r.add(t),s()},d=e=>{r.delete(e.key),s()},f=()=>{var e;const n=t.get(a);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)},p=e=>{if(l(e),m()){const t=v(e.target);t&&t===a&&(n(e,t),i())}};function v(e){return h(e,(e=>t.get(e)))}function h(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?h(e.parentElement,t):void 0}function m(){for(const t of e)if(!r.has(t))return!1;return!0}return Object.freeze({run:function(){window.addEventListener("blur",c,U),window.addEventListener("keydown",g,U),window.addEventListener("keyup",d,U),window.addEventListener("mousemove",u,F),window.addEventListener("scroll",f,F),window.addEventListener("click",p,U),window.addEventListener("mouseenter",l,U),window.addEventListener("mouseover",l,U),window.addEventListener("mouseout",l,U),window.addEventListener("mouseleave",l,U),window.addEventListener("mousedown",l,U),window.addEventListener("mouseup",l,U)},stop:function(){window.removeEventListener("blur",c,U),window.removeEventListener("keydown",g,U),window.removeEventListener("keyup",d,U),window.removeEventListener("mousemove",u,F),window.removeEventListener("scroll",f,F),window.removeEventListener("click",p,U),window.removeEventListener("mouseenter",l,U),window.removeEventListener("mouseover",l,U),window.removeEventListener("mouseout",l,U),window.removeEventListener("mouseleave",l,U),window.removeEventListener("mousedown",l,U),window.removeEventListener("mouseup",l,U)}})},M=(e,t)=>{const n=(()=>{const e=new Map;return Object.freeze({set:function(t,n){e.set(t,n)},get:function(t){return t&&e.get(t)},remove:function(t){return e.delete(t)},forEachElement:function(t){e.forEach(((e,n)=>t(n,e)))}})})(),a=S({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),o=B({highlightKeys:e.highlightKeys,elementStore:n,onClick:(e,a)=>{const o=n.get(a);t({event:e,keysAndDefaults:s(o)})}});function r(){return e.targetElement||document.body}function s(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({register:function(t,o,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest("[data-tolgee-restricted]")}(t))return;const i=t;let s=n.get(i);s||(s={nodes:new Map},n.set(i,s),i.setAttribute("_tolgee","true")),s.nodes.set(o,r),a.initHighlighter(i,s)},forEachElement:n.forEachElement,findAll:function(e,t){const a=[];return n.forEachElement(((n,o)=>{for(const n of o.nodes.values()){if(n.keys.find((n=>$({key:e,ns:i(t)},{key:n.key,ns:i(n.ns)})))){a.push(o);break}}})),a},refreshAll:function(){n.forEachElement(((e,t)=>{t.preventClean||(function(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())I(r(),t)&&(yield[t,n])}(e))}(t),0===t.nodes.size&&function(e,t){var a;t.highlightEl&&(null===(a=t.unhighlight)||void 0===a||a.call(t));e.removeAttribute("_tolgee"),n.remove(e)}(e,t))}))},run:function(e){e&&o.run()},stop:function(){o.stop()}})},V=(t,a,o)=>{let r=!1;const i=(e=>Object.freeze({getSuitableParent:function t(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(a):a}}))(a),s=((e,t)=>{const n=e=>R(t.getTextXPath(),e),a=n=>{let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=R(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a};return Object.freeze({handleAttributes:a,handleChildList:e=>{let t=[];return t=t.concat(a(e)),t=t.concat(n(e)),t},handleText:n})})(a,t),l=M(a,o);function u(e){for(const a of e){const e=D(a),o=e?t.unwrap(e):null;if(o){const{text:t,keys:r}=o;C(a,t);const s=n(e,r),u=i.getSuitableParent(a);l.register(u,a,s)}}}const c=e=>{R("./descendant-or-self::*[@data-tolgee-key-only]",e).forEach((e=>{const t=e.getAttributeNode("data-tolgee-key-only"),n=i.getSuitableParent(t);l.register(n,t,{oldTextContent:"",keys:[{key:D(t)}],keyAttributeOnly:!0})}))};let g;return Object.freeze({run:({mouseHighlight:t})=>{if(e())return;g||(g=new MutationObserver((e=>{if(r)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()}})));const n=a.targetElement||document.body;r=!0,l.run(t),c(n),u(s.handleChildList(n)),g.observe(a.targetElement||document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0})},stop:()=>{r=!1,l.stop(),g.disconnect()},wrap:t.wrap,unwrap:t.unwrap,forEachElement:l.forEachElement,highlight:(e,t)=>{const n=l.findAll(e,t);return n.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){n.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}}})};function K(){}function z(){}K.prototype.encode=function(e){const t=[],n=e.length;let a=0;for(;a<n;){const n=e.codePointAt(a);let o=0,r=0;for(n<=127?(o=0,r=0):n<=2047?(o=6,r=192):n<=65535?(o=12,r=224):n<=2097151&&(o=18,r=240),t.push(r|n>>o),o-=6;o>=0;)t.push(128|n>>o&63),o-=6;a+=n>=65536?2:1}return t},z.prototype.decode=function(e){let t="",n=0;for(;n<e.length;){let a=e[n],o=0,r=0;if(a<=127?(o=0,r=255&a):a<=223?(o=1,r=31&a):a<=239?(o=2,r=15&a):a<=244&&(o=3,r=7&a),e.length-n-o>0){let t=0;for(;t<o;)a=e[n+t+1],r=r<<6|63&a,t+=1}else r=65533,o=e.length-n;t+=String.fromCodePoint(r),n+=o+1}return t};const Y="undefined"==typeof TextEncoder?K:TextEncoder,G="undefined"==typeof TextDecoder?z:TextDecoder,W=["",""],X=RegExp(`([${W.join("")}]{9})+`,"gu"),H=e=>{const t=(e=>Array.from((new Y).encode(e)))(e).map(Number),n=t.map((e=>(e=>{const t=8-e.length;return"0".repeat(t)+e})(e.toString(2))+"0")).join("");return Array.from(n).map((e=>W[Number(e)])).join("")},J=e=>{const t=Array.from(e).map((e=>W.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 G).decode(new Uint8Array(a));var a},q=()=>{const e=(()=>{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]})})(),t=e=>JSON.parse(e);return Object.freeze({unwrap:n=>{const a=[],o=(e=>{var t;const n=null===(t=e.match(X))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(J))||[]})(n);o.forEach((n=>{const[o]=(e=>{const t=[];for(const n of e)t.push(n.codePointAt(0));return t})(n),r=e.numberToValue(o),{k:i,d:s,n:l}=t(r);a.push({key:i,defaultValue:s,ns:l})}));const r=(e=>e.replace(X,""))(n);return{text:r,keys:a}},wrap:({key:t,defaultValue:n,translation:a,ns:o})=>{const r=(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=H(String.fromCodePoint(i));return"string"==typeof s?s+l:s},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${W[0]}${W[0]}') or contains(., '${W[1]}${W[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${W[0]}${W[0]}') or contains(., '${W[1]}${W[0]}')]`})};function Z(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}const Q=({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}}const o=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=e=>"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(!Z(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}')]`})};function ee(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function te(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|ee(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 ne(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=te(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}function ae({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((()=>{}))})()}}let oe=null;function re(e){var t;return oe||(oe=(t=`https://cdn.jsdelivr.net/npm/@tolgee/web@${e||"rc"}/dist/tolgee-in-context-tools.umd.min.js`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window["@tolgee/in-context-tools"].InContextTools))),oe}function ie(){const e=sessionStorage.getItem("__tolgee_apiKey")||void 0,t=sessionStorage.getItem("__tolgee_apiUrl")||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function se(){sessionStorage.removeItem("__tolgee_apiKey"),sessionStorage.removeItem("__tolgee_apiUrl")}exports.BrowserExtensionPlugin=()=>e=>e,"undefined"!=typeof window&&(exports.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=ae({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(se)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return ie()&&(async()=>{const e=await re("rc");return t=>{const n=ie();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 le=e=>e.endsWith("/")?e.slice(0,-1):e,ue={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${le(n)}/${e}/${t}.json`:`${le(n)}/${t}.json`,getData:e=>e.json(),headers:{Accept:"application/json"}},ce=e=>{const t=Object.assign(Object.assign(Object.assign({},ue),e),{headers:Object.assign(Object.assign({},ue.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(ce(e)),t),exports.DEVTOOLS_ID="__tolgee_dev_tools",exports.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o}){var r;const i=null!==(r=ne(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})=>N(e,t)}),e),exports.LanguageDetector=()=>(e,n)=>(n.setLanguageDetector({getLanguage({availableLanguages:e}){t("LanguageDetector");const n=window.navigator.language,a=e.find((e=>e===n));if(a)return a;const o=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),r=o(window.navigator.language);return e.find((e=>o(e)===r))||void 0}}),e),exports.LanguageStorage=()=>(e,n)=>(n.setLanguageStorage({getLanguage:()=>(t("LanguageStorage"),localStorage.getItem("__tolgee_currentLanguage")||void 0),setLanguage(e){t("LanguageStorage"),localStorage.setItem("__tolgee_currentLanguage",e)}}),e),exports.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((({translate:e,onClick:t,options:n})=>{const a=Q({inputPrefix:n.inputPrefix,inputSuffix:n.inputSuffix,translate:e}),{wrap:o,unwrap:r,stop:i,forEachElement:s,highlight:l,run:u}=V(a,n,t);return{wrap:o,unwrap:r,stop:i,run:u,retranslate:()=>{s(((e,t)=>{for(const[e,n]of t.nodes.entries()){if(n.keyAttributeOnly)return;const t=a.unwrap(n.oldTextContent);t&&C(e,t.text)}}))},highlight:l,outputNotFormattable:!0}})):t.setObserver((({onClick:e,options:t})=>{const n=q(),a=V(n,t,e);return Object.assign(Object.assign({},a),{retranslate:()=>{},outputNotFormattable:!1})})),e),exports.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",exports.TOLGEE_ATTRIBUTE_NAME="_tolgee",exports.TOLGEE_RESTRICT_ATTRIBUTE="data-tolgee-restricted",exports.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE="data-tolgee-key-only",exports.Tolgee=()=>A().use(exports.BrowserExtensionPlugin()),exports.TolgeeCore=A,exports.getFallback=i,exports.getFallbackArray=s,exports.getProjectIdFromApiKey=ne,exports.getTranslateProps=O; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e="__tolgee_dev_tools",t="data-tolgee-key-only",n="data-tolgee-restricted",a="_tolgee",o="_tolgee-highlighter";function r(){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 i(e){if(r())throw new Error(`${e}: Can't run on the server`)}function s(e,t){return{oldTextContent:e,keys:t}}function u(e){return Boolean(e&&"function"==typeof e.then)}const l=(e,t)=>u(e)?Promise.resolve(e).then(t):t(e),c=e=>`Tolgee: You need to specify '${e}' option`;function g(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function d(e){return g(e)||[]}function f(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?d(t):d(null==t?void 0:t[e]);var n}function p(e){return Array.from(new Set(e))}function v(e){return e?e.replace(/\/+$/,""):e}const h=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})))}})},m=(e,t,n)=>{const a=new Set,o=new Set;let r=[];const i=()=>{if(0===r.length)return;const e=r;r=[],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)))}));(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({listenSome:e=>{const t={fn:t=>{e(t)},namespaces:new Set};o.add(t);const a={unsubscribe:()=>{o.delete(t)},subscribeNs:e=>(d(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a},listen:e=>{a.add(e);return{unsubscribe:()=>{a.delete(e)}}},emit:(t,n)=>{e()&&(r.push(t),n?setTimeout(i,0):i())}})},b=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):b(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},y=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},E=({language:e,namespace:t})=>t?`${e}:${t}`:e,w=(e,t,n,a,o,r,i)=>{const s=new Map,u=new Map;let l={},c=0;function g(t,n,a){const o=E(t);u.set(o,{data:b(n),version:a}),e.emit(t)}function f(e,t){g(e,t,c)}function v(e,t=!1){const n=u.get(E(e));return n&&t?n.version===c:Boolean(n)}function h(e){var t;return null===(t=u.get(E(a(e))))||void 0===t?void 0:t.data}function m(e){let n;if(!n){const t=l[E(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}return Object.freeze({addStaticData:function(e){e&&(l=Object.assign(Object.assign({},l),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=y(e),a=u.get(e);a&&0!==a.version||g(n,t,0)}})))},invalidate:function(){s.clear(),c+=1},addRecord:f,exists:v,getRecord:h,getTranslation:function(e,t){var n;return null===(n=u.get(E(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs:function(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(E({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return p(e)},getTranslationFallback:function(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(E({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation:function(t,n,a){var o;const r=null===(o=u.get(E(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching:function(e){if(o())return!0;if(void 0===e)return s.size>0;const t=d(e);return Boolean(Array.from(s.keys()).find((e=>t.includes(y(e).namespace))))},isLoading:function(e,t){const n=d(t);return Boolean(o()||Array.from(s.keys()).find((t=>{const a=y(t);return(!n.length||n.includes(a.namespace))&&!v({namespace:a.namespace,language:e})})))},loadRecords:async function(e,t){const o=e.map((e=>{const o=a(e),r=E(o),i=s.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const u=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 s.set(r,u),{new:!0,promise:u,keyObject:o,cacheKey:r}}));r.notify(),i.notify();const u=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=s.get(e.cacheKey)!==e.promise;if(e.new&&!n){s.delete(e.cacheKey);const n=u[t];n?f(e.keyObject,n):h(e.keyObject)||f(e.keyObject,{})}})),r.notify(),i.notify(),o.map((e=>h(e.keyObject)))},getAllRecords:function(){return Array.from(u.entries()).map((([e,t])=>Object.assign(Object.assign({},y(e)),{data:t.data})))}})};function L(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 O="invalid",k={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:O,apiUrl:"https://app.tolgee.io"},A=(...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},j=(e,t)=>{const n=A(k,null==t?void 0:t.initialOptions,e);return n.apiUrl=v(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}},x=(e,t,n,a,o,r)=>{const i={ui:void 0,observer:void 0},s={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 r=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,ns:a({key:e,ns:t}),translation:o({key:e,ns:t})})));null===(n=s.ui)||void 0===n||n.handleElementClick(r,t)},g=(e,t)=>{var n,a;return(null===(a=null===(n=s.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},d=e=>{const t=o({key:e.key,ns:e.ns});return j(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))},f=e=>{i.observer=e},p=()=>Boolean(i.observer),v=e=>{e&&s.formatters.push(e)},h=e=>{s.finalFormatter=e},m=e=>{i.ui=e},b=()=>Boolean(i.ui),y=e=>{s.languageStorage=e},E=e=>{s.languageDetector=e},w=e=>{e&&s.backends.push(e)},k=e=>{s.devBackend=e},A=()=>s.devBackend;function j(n){var a,{formatEnabled:o}=n,r=L(n,["formatEnabled"]);const{key:i,translation:u,defaultValue:l,noWrap:c,params:g,orEmpty:d,ns:f}=r,p=u||l;let v=p||(d?"":i);const h=e(),m=o||!(null===(a=s.observer)||void 0===a?void 0:a.outputNotFormattable),b=e=>s.observer&&!c?s.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:f}):e;v=b(v);try{if(p&&h&&m)for(const e of s.formatters)v=e.format({translation:v,language:h,params:g});s.finalFormatter&&p&&h&&m&&(v=s.finalFormatter.format({translation:v,language:h,params:g}))}catch(e){console.error(e);const n=("string"==typeof(y=e)?y:"string"==typeof(null==y?void 0:y.message)?y.message:void 0)||O,a=t().onFormatError,o=typeof a;v="string"===o?a:"function"===o?a(n,r):O,v=b(v)}var y;return v}return Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:h,addFormatter:v,setObserver:f,hasObserver:p,setUi:m,hasUi:b,setDevBackend:k,addBackend:w,setLanguageDetector:E,setLanguageStorage:y}))},formatTranslation:j,getDevBackend:A,getBackendRecord:({language:e,namespace:t})=>{for(const n of s.backends){const a=n.getRecord({language:e,namespace:t});if(u(a))return null==a?void 0:a.catch((e=>(console.error(e),{})));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:n})=>{var a;const{apiKey:o,apiUrl:r,projectId:i}=t();return null===(a=s.devBackend)||void 0===a?void 0:a.getRecord({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:n})},getLanguageDetector:()=>s.languageDetector,getLanguageStorage:()=>s.languageStorage,getInitialLanguage:()=>{var e;const t=n(),a=null===(e=s.languageStorage)||void 0===e?void 0:e.getLanguage();return l(a,(e=>t&&!t.includes(e)||!e?(()=>{if(!s.languageDetector)return;const e=n();return s.languageDetector.getLanguage({availableLanguages:e})})():e))},setStoredLanguage:e=>{var t;null===(t=s.languageStorage)||void 0===t||t.setLanguage(e)},run:()=>{var e,n,a;if(!s.ui){const{apiKey:n,apiUrl:a,projectId:o}=t();s.ui=null===(e=i.ui)||void 0===e?void 0:e.call(i,{apiKey:n,apiUrl:a,projectId:o,highlight:g,changeTranslation:r})}s.observer||(s.observer=null===(n=i.observer)||void 0===n?void 0:n.call(i,{translate:d,onClick:c,options:t().observerOptions})),null===(a=s.observer)||void 0===a||a.run({mouseHighlight:!0})},stop:()=>{var e;s.ui=void 0,null===(e=s.observer)||void 0===e||e.stop()},retranslate:()=>{var e;null===(e=s.observer)||void 0===e||e.retranslate()},highlight:g,unwrap:e=>{var t;return s.observer?null===(t=s.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap:e=>{var t;return s.observer?null===(t=s.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:function(){return Boolean(A())}})},T=(e,t,n)=>{let a=e;return Object.freeze({init:function(e){a=e},notify:function(){const e=t();a!==e&&n(e),a=e}})};const P=(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}=e,r=L(e,["ns","noWrap","orEmpty","params"]);const i={ns:t,noWrap:n,orEmpty:a};return Object.assign(Object.assign({},i),{params:Object.assign({},r)})}(n)),a)),a},N=({options:e})=>{const t=((e,t)=>{let n=!0;function a(){return n}const o=h(a),r=h(a),i=h(a),s=h(a),u=h(a),l=h(a),c=h(a),g=m(a,e,t);return u.listen((()=>g.emit())),r.listen((()=>g.emit())),c.listen((({value:e})=>{g.emit([e.namespace],!0)})),Object.freeze({onPendingLanguageChange:o,onLanguageChange:r,onLoadingChange:i,onFetchingChange:s,onInitialLoaded:u,onRunningChange:l,onCacheChange:c,onUpdate:g,setEmmiterActive:function(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.listen(t);case"language":return r.listen(t);case"loading":return i.listen(t);case"fetching":return s.listen(t);case"initialLoad":return u.listen(t);case"running":return l.listen(t);case"cache":return c.listen(t);case"update":return g.listen(t)}}})})(s,g),n=T(!1,(()=>i.isFetching()),t.onFetchingChange.emit),a=T(!1,(()=>k()),t.onLoadingChange.emit),o=((e,t,n)=>{let a,o=j();function r(){return o.language||o.initialOptions.language}function i(){return Object.assign(Object.assign({},o.initialOptions),a)}return Object.freeze({init:function(e){o=j(e,o)},isRunning:function(){return o.isRunning},setRunning:function(e){o.isRunning!==e&&(o.isRunning=e,n.emit(e))},isInitialLoading:function(){return o.isInitialLoading},setInitialLoading:function(e){o.isInitialLoading=e},getLanguage:r,setLanguage:function(t){o.language!==t&&(o.language=t,e.emit(t))},getPendingLanguage:function(){return o.pendingLanguage||r()},setPendingLanguage:function(e){o.pendingLanguage!==e&&(o.pendingLanguage=e,t.emit(e))},getInitialOptions:i,addActiveNs:function(e){d(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t?o.activeNamespaces.set(e,t+1):o.activeNamespaces.set(e,1)}))},removeActiveNs:function(e){d(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:function(){return p([...o.initialOptions.ns||[o.initialOptions.defaultNs],...d(o.initialOptions.fallbackNs),...o.activeNamespaces.keys()])},getFallbackLangs:function(e){const t=e||r();return t?p([t,...f(t,o.initialOptions.fallbackLanguage)]):[]},getFallbackNs:function(){return d(o.initialOptions.fallbackNs)},getDefaultNs:function(e){return void 0===e?o.initialOptions.defaultNs:e},getAvailableLanguages:function(){if(o.initialOptions.availableLanguages)return o.initialOptions.availableLanguages;if(o.initialOptions.staticData){const e=Object.keys(o.initialOptions.staticData).map((e=>y(e).language));return Array.from(new Set(e))}},withDefaultNs:function(e){return{namespace:void 0===e.namespace?i().defaultNs:e.namespace,language:e.language}},overrideCredentials:function(e){a=e?Object.assign(Object.assign({},e),{apiUrl:v(e.apiUrl)}):void 0}})})(t.onLanguageChange,t.onPendingLanguageChange,t.onRunningChange),r=x(o.getLanguage,o.getInitialOptions,o.getAvailableLanguages,(function({key:e,ns:t}){const n=o.getFallbackLangs(),a=b(t||void 0);return i.getTranslationNs(a,n,e)}),S,L),i=w(t.onCacheChange,r.getBackendRecord,r.getBackendDevRecord,o.withDefaultNs,o.isInitialLoading,n,a);function s(){return o.getFallbackNs()}function g(e){return o.getDefaultNs(e)}function b(e){return[...d(g(e)),...s()]}function E(e){return[...d(e||g()),...o.getRequiredNamespaces()]}function L(e,t,n){const a=o.withDefaultNs(e),r=i.getTranslation(a,t);return i.changeTranslation(a,t,n),{revert:()=>{i.changeTranslation(a,t,r)}}}function O(e){o.init(e),i.addStaticData(o.getInitialOptions().staticData)}function k(e){return i.isLoading(o.getLanguage(),e)}function A(){return Boolean(o.getInitialOptions().apiKey&&o.getInitialOptions().apiUrl)}function N(e,t){const n=function(e,t){const n=o.getFallbackLangs(e),a=E(t),r=[];return n.forEach((e=>{a.forEach((t=>{i.exists({language:e,namespace:t},!0)||r.push({language:e,namespace:t})}))})),r}(e,t);if(n.length)return l(D(n),(()=>{}))}function S({key:e,ns:t}){const n=b(t||void 0),a=o.getFallbackLangs();return i.getTranslationFallback(n,a,e)}function R(){const e=l(function(){if(o.getLanguage())return;if(!o.getInitialOptions().defaultLanguage)throw new Error(c("defaultLanguage"));const e=r.getInitialLanguage();return l(e,(e=>{const t=e||o.getInitialOptions().defaultLanguage;t&&o.setLanguage(t)}))}(),(()=>N()));if(u(e))return o.setInitialLoading(!0),n.notify(),a.notify(),Promise.resolve(e).then((()=>{o.setInitialLoading(!1),n.notify(),a.notify(),t.onInitialLoaded.emit()}));t.onInitialLoaded.emit()}function D(e){return i.loadRecords(e,A())}e&&O(e),t.onUpdate.listen((()=>{o.isRunning()&&r.retranslate()}));const $=()=>{const e=r.getLanguageDetector()||r.getLanguageStorage();if(e){if(!o.getAvailableLanguages())throw new Error(c("availableLanguages"))}if(!o.getLanguage()&&!o.getInitialOptions().defaultLanguage)throw e?new Error(c("defaultLanguage")):new Error(c("language"))};return Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),o),r),i),{init:O,changeLanguage:async function(e){o.getPendingLanguage()===e&&o.getLanguage()===e||(o.setPendingLanguage(e),o.isRunning()&&await N(e),e===o.getPendingLanguage()&&(o.setLanguage(e),r.setStoredLanguage(e)))},getTranslation:S,changeTranslation:L,addActiveNs:async function(e,t){t||o.addActiveNs(e),o.isRunning()&&await N(void 0,e)},loadRecords:D,loadRecord:async function(e){return(await D([e]))[0]},isLoading:k,isLoaded:function(e){const t=o.getLanguage();if(!t)return!1;const n=o.getFallbackLangs(t),a=E(e),r=[];return n.forEach((e=>{a.forEach((t=>{i.exists({language:e,namespace:t})||r.push({language:e,namespace:t})}))})),0===r.length},t:(...e)=>{const t=P(...e),n=S(t);return r.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:A,run:function(){let e;return $(),o.isRunning()||(A()&&i.invalidate(),o.setRunning(!0),r.run(),e=R()),Promise.resolve(e)},stop:function(){o.isRunning()&&(r.stop(),o.setRunning(!1))}}))},S=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=A(e.options,n),t),init(t){const n=(e=>{const t=N({options:e}),n=e=>{const n=t.isRunning();n&&t.stop(),e(),n&&t.run()},a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmmiterActive:t.setEmmiterActive,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})(A(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},R=0,D=1,$=2;class C extends Error{constructor(e,t,n){let a;a=e===R?"Empty parameter":e===D?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function I(e){return/\s/.test(e)}const _=0,U=1,F=2,B=3,M=4,V=new Set([F,U,_]),K="'",z=new Set(["{","}",K]),Y=e=>/[0-9a-zA-Z_]/.test(e);function G(e,t){const[n,a]=function(e){let t=_,n="",a="",o="";const r=[],i=[];let s=0;function u(t){throw new C(t,s,e)}const l=()=>{r.push(n),n=""},c=()=>{""===a&&u(R),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case _:o===K?(n+=o,t=U):"{"===o?(l(),t=B):(n+=o,t=_);break;case U:z.has(o)?(n=n.slice(0,-1)+o,t=F):(n+=o,t=_);break;case F:o===K?t=_:(n+=o,t=F);break;case B:"}"===o?(c(),t=_):I(o)?""!==a&&(c(),t=M):(Y(o)||u(D),a+=o,t=B);break;case M:"}"==o?t=_:I(o)?t=M:u(D)}return V.has(t)||u($),l(),[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 W={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"},X=({highlightColor:e,highlightWidth:t})=>Object.freeze({initHighlighter:function(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let r=a.highlightEl;r||(r=document.createElement("div"),r.classList.add(o),Object.entries(W).forEach((([e,t])=>{r.style[e]=t})),r.style.borderColor=e,a.highlightEl=r,document.body.appendChild(r));const i=n.getBoundingClientRect();r.style.borderWidth=t+"px",r.style.top=i.top-t+"px",r.style.left=i.left-t+"px",r.style.width=i.width+"px",r.style.height=i.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}const 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},ee={capture:!0},te={capture:!0,passive:!0},ne=({highlightKeys:t,elementStore:n,onClick:a})=>{let o,r,i=new Set;const s=e=>{var t;if(o!==e){u();const a=n.get(e);a&&(a.preventClean=!0,null===(t=a.highlight)||void 0===t||t.call(a),o=e)}},u=()=>{var e;const t=n.get(o);t&&(t.preventClean=!1,null===(e=t.unhighlight)||void 0===e||e.call(t),o=void 0)};function l(){const e=r;let t;if(e&&y()){const n=document.elementFromPoint(e.x,e.y);n&&(t=m(n))}s(t)}const c=t=>{var n;y()&&(n=t.target,!Boolean(b(n,(t=>t.id===e))))&&(t.stopPropagation(),t.preventDefault())},g=e=>{var t;t={x:e.clientX,y:e.clientY},r=t,l()},d=()=>{i=new Set,l()},f=e=>{const t=e.key;void 0!==t&&i.add(t),l()},p=e=>{i.delete(e.key),l()},v=()=>{var e;const t=n.get(o);null===(e=null==t?void 0:t.highlight)||void 0===e||e.call(t)},h=e=>{if(c(e),y()){const t=m(e.target);t&&t===o&&(a(e,t),u())}};function m(e){return b(e,(e=>n.get(e)))}function b(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?b(e.parentElement,t):void 0}function y(){for(const e of t)if(!i.has(e))return!1;return!0}return Object.freeze({run:function(){window.addEventListener("blur",d,ee),window.addEventListener("keydown",f,ee),window.addEventListener("keyup",p,ee),window.addEventListener("mousemove",g,te),window.addEventListener("scroll",v,te),window.addEventListener("click",h,ee),window.addEventListener("mouseenter",c,ee),window.addEventListener("mouseover",c,ee),window.addEventListener("mouseout",c,ee),window.addEventListener("mouseleave",c,ee),window.addEventListener("mousedown",c,ee),window.addEventListener("mouseup",c,ee)},stop:function(){window.removeEventListener("blur",d,ee),window.removeEventListener("keydown",f,ee),window.removeEventListener("keyup",p,ee),window.removeEventListener("mousemove",g,te),window.removeEventListener("scroll",v,te),window.removeEventListener("click",h,ee),window.removeEventListener("mouseenter",c,ee),window.removeEventListener("mouseover",c,ee),window.removeEventListener("mouseout",c,ee),window.removeEventListener("mouseleave",c,ee),window.removeEventListener("mousedown",c,ee),window.removeEventListener("mouseup",c,ee)}})},ae=(e,t)=>{const o=(()=>{const e=new Map;return Object.freeze({set:function(t,n){e.set(t,n)},get:function(t){return t&&e.get(t)},remove:function(t){return e.delete(t)},forEachElement:function(t){e.forEach(((e,n)=>t(n,e)))}})})(),r=X({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),i=ne({highlightKeys:e.highlightKeys,elementStore:o,onClick:(e,n)=>{const a=o.get(n);t({event:e,keysAndDefaults:u(a)})}});function s(){return e.targetElement||document.body}function u(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:function(t,i,s){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${n}]`)}(t))return;const u=t;let l=o.get(u);l||(l={nodes:new Map},o.set(u,l),u.setAttribute(a,"true")),l.nodes.set(i,s),r.initHighlighter(u,l)},forEachElement:o.forEachElement,findAll:function(e,t){const n=[];return o.forEachElement(((a,o)=>{for(const a of o.nodes.values()){if(a.keys.find((n=>Q({key:e,ns:g(t)},{key:n.key,ns:g(n.ns)})))){n.push(o);break}}})),n},refreshAll:function(){o.forEachElement(((e,t)=>{t.preventClean||(function(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())Z(s(),t)&&(yield[t,n])}(e))}(t),0===t.nodes.size&&function(e,t){var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||n.call(t));e.removeAttribute(a),o.remove(e)}(e,t))}))},run:function(e){e&&i.run()},stop:function(){i.stop()}})},oe=(e,n,a)=>{let o=!1;const i=(e=>Object.freeze({getSuitableParent:function t(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(a):a}}))(n),u=((e,t)=>{const n=e=>H(t.getTextXPath(),e),a=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};return Object.freeze({handleAttributes:a,handleChildList:e=>{let t=[];return t=t.concat(a(e)),t=t.concat(n(e)),t},handleText:n})})(n,e),l=ae(n,a);function c(t){for(const n of t){const t=J(n),a=t?e.unwrap(t):null;if(a){const{text:e,keys:o}=a;q(n,e);const r=s(t,o),u=i.getSuitableParent(n);l.register(u,n,r)}}}const g=e=>{H(`./descendant-or-self::*[@${t}]`,e).forEach((e=>{const n=e.getAttributeNode(t),a=i.getSuitableParent(n);l.register(a,n,{oldTextContent:"",keys:[{key:J(n)}],keyAttributeOnly:!0})}))};let d;return Object.freeze({run:({mouseHighlight:e})=>{if(r())return;d||(d=new MutationObserver((e=>{if(o)for(const t of e){let e=[];switch(t.type){case"characterData":e=u.handleText(t.target);break;case"childList":g(t.target),e=u.handleChildList(t.target);break;case"attributes":g(t.target),e=u.handleAttributes(t.target)}c(e),l.refreshAll()}})));const t=n.targetElement||document.body;o=!0,l.run(e),g(t),c(u.handleChildList(t)),d.observe(n.targetElement||document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0})},stop:()=>{o=!1,l.stop(),d.disconnect()},wrap:e.wrap,unwrap:e.unwrap,forEachElement:l.forEachElement,highlight:(e,t)=>{const n=l.findAll(e,t);return n.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){n.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}}})};function re(){}function ie(){}re.prototype.encode=function(e){const t=[],n=e.length;let a=0;for(;a<n;){const n=e.codePointAt(a);let o=0,r=0;for(n<=127?(o=0,r=0):n<=2047?(o=6,r=192):n<=65535?(o=12,r=224):n<=2097151&&(o=18,r=240),t.push(r|n>>o),o-=6;o>=0;)t.push(128|n>>o&63),o-=6;a+=n>=65536?2:1}return t},ie.prototype.decode=function(e){let t="",n=0;for(;n<e.length;){let a=e[n],o=0,r=0;if(a<=127?(o=0,r=255&a):a<=223?(o=1,r=31&a):a<=239?(o=2,r=15&a):a<=244&&(o=3,r=7&a),e.length-n-o>0){let t=0;for(;t<o;)a=e[n+t+1],r=r<<6|63&a,t+=1}else r=65533,o=e.length-n;t+=String.fromCodePoint(r),n+=o+1}return t};const se="undefined"==typeof TextEncoder?re:TextEncoder,ue="undefined"==typeof TextDecoder?ie:TextDecoder,le=["",""],ce=RegExp(`([${le.join("")}]{9})+`,"gu"),ge=e=>{const t=(e=>Array.from((new se).encode(e)))(e).map(Number),n=t.map((e=>(e=>{const t=8-e.length;return"0".repeat(t)+e})(e.toString(2))+"0")).join("");return Array.from(n).map((e=>le[Number(e)])).join("")},de=e=>{const t=Array.from(e).map((e=>le.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 ue).decode(new Uint8Array(a));var a},fe=()=>{const e=(()=>{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]})})(),t=e=>JSON.parse(e);return Object.freeze({unwrap:n=>{const a=[],o=(e=>{var t;const n=null===(t=e.match(ce))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(de))||[]})(n);o.forEach((n=>{const[o]=(e=>{const t=[];for(const n of e)t.push(n.codePointAt(0));return t})(n),r=e.numberToValue(o),{k:i,d:s,n:u}=t(r);a.push({key:i,defaultValue:s,ns:u})}));const r=(e=>e.replace(ce,""))(n);return{text:r,keys:a}},wrap:({key:t,defaultValue:n,translation:a,ns:o})=>{const r=(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||"",u=ge(String.fromCodePoint(i));return"string"==typeof s?s+u:s},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${le[0]}${le[0]}') or contains(., '${le[1]}${le[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${le[0]}${le[0]}') or contains(., '${le[1]}${le[0]}')]`})};function pe(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}const ve=({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}}const o=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=e=>"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 u=void 0!==o?`,${r(o)}`:"",l="string"==typeof i?[i]:i,c=(null==l?void 0:l.length)?`|${l.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${c}${u}${s}${t}`},unwrap:n=>{const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,u=!1,l=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(l,d-l),l=d+t.length,"\\"===e){if(!pe(d,n)){c+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),u=!0,c+=e+p.translated}return c+=n.substring(l),u?{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}')]`})},he="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function me(e){const t=he.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function be(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|me(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 ye(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=be(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}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 we="tolgee-in-context-tools.umd.min.js",Le="@tolgee/in-context-tools",Oe="InContextTools",ke="https://cdn.jsdelivr.net/npm";let Ae=null;function je(e){var t;return Ae||(Ae=(t=`${ke}/@tolgee/web@${e||"rc"}/dist/${we}`,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[Le][Oe]))),Ae}const xe="__tolgee_apiKey",Te="__tolgee_apiUrl";function Pe(){const e=sessionStorage.getItem(xe)||void 0,t=sessionStorage.getItem(Te)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Ne(){sessionStorage.removeItem(xe),sessionStorage.removeItem(Te)}exports.BrowserExtensionPlugin=()=>e=>e,"undefined"!=typeof window&&(exports.BrowserExtensionPlugin=()=>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(Ne)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Pe()&&(async()=>{const e=await je("rc");return t=>{const n=Pe();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 Se="__tolgee_currentLanguage";const Re=e=>e.endsWith("/")?e.slice(0,-1):e,De={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${Re(n)}/${e}/${t}.json`:`${Re(n)}/${t}.json`,getData:e=>e.json(),headers:{Accept:"application/json"}},$e=e=>{const t=Object.assign(Object.assign(Object.assign({},De),e),{headers:Object.assign(Object.assign({},De.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($e(e)),t),exports.DEVTOOLS_ID=e,exports.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o}){var r;const i=null!==(r=ye(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})=>G(e,t)}),e),exports.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){i("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:()=>(i("LanguageStorage"),localStorage.getItem(Se)||void 0),setLanguage(e){i("LanguageStorage"),localStorage.setItem(Se,e)}}),e),exports.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((({translate:e,onClick:t,options:n})=>{const a=ve({inputPrefix:n.inputPrefix,inputSuffix:n.inputSuffix,translate:e}),{wrap:o,unwrap:r,stop:i,forEachElement:s,highlight:u,run:l}=oe(a,n,t);return{wrap:o,unwrap:r,stop:i,run:l,retranslate:()=>{s(((e,t)=>{for(const[e,n]of t.nodes.entries()){if(n.keyAttributeOnly)return;const t=a.unwrap(n.oldTextContent);t&&q(e,t.text)}}))},highlight:u,outputNotFormattable:!0}})):t.setObserver((({onClick:e,options:t})=>{const n=fe(),a=oe(n,t,e);return Object.assign(Object.assign({},a),{retranslate:()=>{},outputNotFormattable:!1})})),e),exports.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",exports.TOLGEE_ATTRIBUTE_NAME=a,exports.TOLGEE_RESTRICT_ATTRIBUTE=n,exports.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=t,exports.Tolgee=()=>S().use(exports.BrowserExtensionPlugin()),exports.TolgeeCore=S,exports.getFallback=g,exports.getFallbackArray=d,exports.getProjectIdFromApiKey=ye,exports.getTranslateProps=P; | ||
//# sourceMappingURL=tolgee-web.production.cjs.min.js.map |
@@ -1,2 +0,2 @@ | ||
const e="__tolgee_dev_tools",t="__tolgee_preferredLanguages",n="data-tolgee-key-only",a="data-tolgee-restricted",o="_tolgee";function r(){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 i(e){if(r())throw new Error(`${e}: Can't run on the server`)}function s(e,t){return{oldTextContent:e,keys:t}}function u(e){return Boolean(e&&"function"==typeof e.then)}const l=(e,t)=>u(e)?Promise.resolve(e).then(t):t(e),c=e=>`Tolgee: You need to specify '${e}' option`;function g(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function d(e){return g(e)||[]}function f(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?d(t):d(null==t?void 0:t[e]);var n}function p(e){return Array.from(new Set(e))}function v(e){return e?e.replace(/\/+$/,""):e}const h=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})))}})},m=(e,t,n)=>{const a=new Set,o=new Set;let r=[];const i=()=>{if(0===r.length)return;const e=r;r=[],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)))}));(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({listenSome:e=>{const t={fn:t=>{e(t)},namespaces:new Set};o.add(t);const a={unsubscribe:()=>{o.delete(t)},subscribeNs:e=>(d(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a},listen:e=>{a.add(e);return{unsubscribe:()=>{a.delete(e)}}},emit:(t,n)=>{e()&&(r.push(t),n?setTimeout(i,0):i())}})},b=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):b(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},y=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},w=({language:e,namespace:t})=>t?`${e}:${t}`:e,E=(e,t,n,a,o,r,i)=>{const s=new Map,u=new Map;let l={},c=0;function g(t,n,a){const o=w(t);u.set(o,{data:b(n),version:a}),e.emit(t)}function f(e,t){g(e,t,c)}function v(e,t=!1){const n=u.get(w(e));return n&&t?n.version===c:Boolean(n)}function h(e){var t;return null===(t=u.get(w(a(e))))||void 0===t?void 0:t.data}function m(e){let n;if(!n){const t=l[w(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}return Object.freeze({addStaticData:function(e){e&&(l=Object.assign(Object.assign({},l),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=y(e),a=u.get(e);a&&0!==a.version||g(n,t,0)}})))},invalidate:function(){s.clear(),c+=1},addRecord:f,exists:v,getRecord:h,getTranslation:function(e,t){var n;return null===(n=u.get(w(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs:function(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(w({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return p(e)},getTranslationFallback:function(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(w({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation:function(t,n,a){var o;const r=null===(o=u.get(w(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching:function(e){if(o())return!0;if(void 0===e)return s.size>0;const t=d(e);return Boolean(Array.from(s.keys()).find((e=>t.includes(y(e).namespace))))},isLoading:function(e,t){const n=d(t);return Boolean(o()||Array.from(s.keys()).find((t=>{const a=y(t);return(!n.length||n.includes(a.namespace))&&!v({namespace:a.namespace,language:e})})))},loadRecords:async function(e,t){const o=e.map((e=>{const o=a(e),r=w(o),i=s.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const u=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 s.set(r,u),{new:!0,promise:u,keyObject:o,cacheKey:r}}));r.notify(),i.notify();const u=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=s.get(e.cacheKey)!==e.promise;if(e.new&&!n){s.delete(e.cacheKey);const n=u[t];n?f(e.keyObject,n):h(e.keyObject)||f(e.keyObject,{})}})),r.notify(),i.notify(),o.map((e=>h(e.keyObject)))},getAllRecords:function(){return Array.from(u.entries()).map((([e,t])=>Object.assign(Object.assign({},y(e)),{data:t.data})))}})};function L(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 O={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:"invalid",apiUrl:"https://app.tolgee.io"},k=(...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},j=(e,t)=>{const n=k(O,null==t?void 0:t.initialOptions,e);return n.apiUrl=v(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}},A=(e,t,n,a,o,r)=>{const i={ui:void 0,observer:void 0},s={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 r=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,ns:a({key:e,ns:t}),translation:o({key:e,ns:t})})));null===(n=s.ui)||void 0===n||n.handleElementClick(r,t)},g=(e,t)=>{var n,a;return(null===(a=null===(n=s.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},d=e=>{const t=o({key:e.key,ns:e.ns});return j(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))},f=e=>{i.observer=e},p=()=>Boolean(i.observer),v=e=>{e&&s.formatters.push(e)},h=e=>{s.finalFormatter=e},m=e=>{i.ui=e},b=()=>Boolean(i.ui),y=e=>{s.languageStorage=e},w=e=>{s.languageDetector=e},E=e=>{e&&s.backends.push(e)},O=e=>{s.devBackend=e},k=()=>s.devBackend;function j(n){var a,{formatEnabled:o}=n,r=L(n,["formatEnabled"]);const{key:i,translation:u,defaultValue:l,noWrap:c,params:g,orEmpty:d,ns:f}=r,p=u||l;let v=p||(d?"":i);const h=e(),m=o||!(null===(a=s.observer)||void 0===a?void 0:a.outputNotFormattable),b=e=>s.observer&&!c?s.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:f}):e;v=b(v);try{if(p&&h&&m)for(const e of s.formatters)v=e.format({translation:v,language:h,params:g});s.finalFormatter&&p&&h&&m&&(v=s.finalFormatter.format({translation:v,language:h,params:g}))}catch(e){console.error(e);const n=("string"==typeof(y=e)?y:"string"==typeof(null==y?void 0:y.message)?y.message:void 0)||"invalid",a=t().onFormatError,o=typeof a;v="string"===o?a:"function"===o?a(n,r):"invalid",v=b(v)}var y;return v}return Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:h,addFormatter:v,setObserver:f,hasObserver:p,setUi:m,hasUi:b,setDevBackend:O,addBackend:E,setLanguageDetector:w,setLanguageStorage:y}))},formatTranslation:j,getDevBackend:k,getBackendRecord:({language:e,namespace:t})=>{for(const n of s.backends){const a=n.getRecord({language:e,namespace:t});if(u(a))return null==a?void 0:a.catch((e=>(console.error(e),{})));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:n})=>{var a;const{apiKey:o,apiUrl:r,projectId:i}=t();return null===(a=s.devBackend)||void 0===a?void 0:a.getRecord({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:n})},getLanguageDetector:()=>s.languageDetector,getLanguageStorage:()=>s.languageStorage,getInitialLanguage:()=>{var e;const t=n(),a=null===(e=s.languageStorage)||void 0===e?void 0:e.getLanguage();return l(a,(e=>t&&!t.includes(e)||!e?(()=>{if(!s.languageDetector)return;const e=n();return s.languageDetector.getLanguage({availableLanguages:e})})():e))},setStoredLanguage:e=>{var t;null===(t=s.languageStorage)||void 0===t||t.setLanguage(e)},run:()=>{var e,n,a;if(!s.ui){const{apiKey:n,apiUrl:a,projectId:o}=t();s.ui=null===(e=i.ui)||void 0===e?void 0:e.call(i,{apiKey:n,apiUrl:a,projectId:o,highlight:g,changeTranslation:r})}s.observer||(s.observer=null===(n=i.observer)||void 0===n?void 0:n.call(i,{translate:d,onClick:c,options:t().observerOptions})),null===(a=s.observer)||void 0===a||a.run({mouseHighlight:!0})},stop:()=>{var e;s.ui=void 0,null===(e=s.observer)||void 0===e||e.stop()},retranslate:()=>{var e;null===(e=s.observer)||void 0===e||e.retranslate()},highlight:g,unwrap:e=>{var t;return s.observer?null===(t=s.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap:e=>{var t;return s.observer?null===(t=s.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:function(){return Boolean(k())}})},x=(e,t,n)=>{let a=e;return Object.freeze({init:function(e){a=e},notify:function(){const e=t();a!==e&&n(e),a=e}})};const P=(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}=e,r=L(e,["ns","noWrap","orEmpty","params"]);const i={ns:t,noWrap:n,orEmpty:a};return Object.assign(Object.assign({},i),{params:Object.assign({},r)})}(n)),a)),a},N=({options:e})=>{const t=((e,t)=>{let n=!0;function a(){return n}const o=h(a),r=h(a),i=h(a),s=h(a),u=h(a),l=h(a),c=h(a),g=m(a,e,t);return u.listen((()=>g.emit())),r.listen((()=>g.emit())),c.listen((({value:e})=>{g.emit([e.namespace],!0)})),Object.freeze({onPendingLanguageChange:o,onLanguageChange:r,onLoadingChange:i,onFetchingChange:s,onInitialLoaded:u,onRunningChange:l,onCacheChange:c,onUpdate:g,setEmmiterActive:function(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.listen(t);case"language":return r.listen(t);case"loading":return i.listen(t);case"fetching":return s.listen(t);case"initialLoad":return u.listen(t);case"running":return l.listen(t);case"cache":return c.listen(t);case"update":return g.listen(t)}}})})(s,g),n=x(!1,(()=>i.isFetching()),t.onFetchingChange.emit),a=x(!1,(()=>k()),t.onLoadingChange.emit),o=((e,t,n)=>{let a,o=j();function r(){return o.language||o.initialOptions.language}function i(){return Object.assign(Object.assign({},o.initialOptions),a)}return Object.freeze({init:function(e){o=j(e,o)},isRunning:function(){return o.isRunning},setRunning:function(e){o.isRunning!==e&&(o.isRunning=e,n.emit(e))},isInitialLoading:function(){return o.isInitialLoading},setInitialLoading:function(e){o.isInitialLoading=e},getLanguage:r,setLanguage:function(t){o.language!==t&&(o.language=t,e.emit(t))},getPendingLanguage:function(){return o.pendingLanguage||r()},setPendingLanguage:function(e){o.pendingLanguage!==e&&(o.pendingLanguage=e,t.emit(e))},getInitialOptions:i,addActiveNs:function(e){d(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t?o.activeNamespaces.set(e,t+1):o.activeNamespaces.set(e,1)}))},removeActiveNs:function(e){d(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:function(){return p([...o.initialOptions.ns||[o.initialOptions.defaultNs],...d(o.initialOptions.fallbackNs),...o.activeNamespaces.keys()])},getFallbackLangs:function(e){const t=e||r();return t?p([t,...f(t,o.initialOptions.fallbackLanguage)]):[]},getFallbackNs:function(){return d(o.initialOptions.fallbackNs)},getDefaultNs:function(e){return void 0===e?o.initialOptions.defaultNs:e},getAvailableLanguages:function(){if(o.initialOptions.availableLanguages)return o.initialOptions.availableLanguages;if(o.initialOptions.staticData){const e=Object.keys(o.initialOptions.staticData).map((e=>y(e).language));return Array.from(new Set(e))}},withDefaultNs:function(e){return{namespace:void 0===e.namespace?i().defaultNs:e.namespace,language:e.language}},overrideCredentials:function(e){a=e?Object.assign(Object.assign({},e),{apiUrl:v(e.apiUrl)}):void 0}})})(t.onLanguageChange,t.onPendingLanguageChange,t.onRunningChange),r=A(o.getLanguage,o.getInitialOptions,o.getAvailableLanguages,(function({key:e,ns:t}){const n=o.getFallbackLangs(),a=b(t||void 0);return i.getTranslationNs(a,n,e)}),S,L),i=E(t.onCacheChange,r.getBackendRecord,r.getBackendDevRecord,o.withDefaultNs,o.isInitialLoading,n,a);function s(){return o.getFallbackNs()}function g(e){return o.getDefaultNs(e)}function b(e){return[...d(g(e)),...s()]}function w(e){return[...d(e||g()),...o.getRequiredNamespaces()]}function L(e,t,n){const a=o.withDefaultNs(e),r=i.getTranslation(a,t);return i.changeTranslation(a,t,n),{revert:()=>{i.changeTranslation(a,t,r)}}}function O(e){o.init(e),i.addStaticData(o.getInitialOptions().staticData)}function k(e){return i.isLoading(o.getLanguage(),e)}function N(){return Boolean(o.getInitialOptions().apiKey&&o.getInitialOptions().apiUrl)}function T(e,t){const n=function(e,t){const n=o.getFallbackLangs(e),a=w(t),r=[];return n.forEach((e=>{a.forEach((t=>{i.exists({language:e,namespace:t},!0)||r.push({language:e,namespace:t})}))})),r}(e,t);if(n.length)return l(C(n),(()=>{}))}function S({key:e,ns:t}){const n=b(t||void 0),a=o.getFallbackLangs();return i.getTranslationFallback(n,a,e)}function $(){const e=l(function(){if(o.getLanguage())return;if(!o.getInitialOptions().defaultLanguage)throw new Error(c("defaultLanguage"));const e=r.getInitialLanguage();return l(e,(e=>{const t=e||o.getInitialOptions().defaultLanguage;t&&o.setLanguage(t)}))}(),(()=>T()));if(u(e))return o.setInitialLoading(!0),n.notify(),a.notify(),Promise.resolve(e).then((()=>{o.setInitialLoading(!1),n.notify(),a.notify(),t.onInitialLoaded.emit()}));t.onInitialLoaded.emit()}function C(e){return i.loadRecords(e,N())}e&&O(e),t.onUpdate.listen((()=>{o.isRunning()&&r.retranslate()}));return Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),o),r),i),{init:O,changeLanguage:async function(e){o.getPendingLanguage()===e&&o.getLanguage()===e||(o.setPendingLanguage(e),o.isRunning()&&await T(e),e===o.getPendingLanguage()&&(o.setLanguage(e),r.setStoredLanguage(e)))},getTranslation:S,changeTranslation:L,addActiveNs:async function(e,t){t||o.addActiveNs(e),o.isRunning()&&await T(void 0,e)},loadRecords:C,loadRecord:async function(e){return(await C([e]))[0]},isLoading:k,isLoaded:function(e){const t=o.getLanguage();if(!t)return!1;const n=o.getFallbackLangs(t),a=w(e),r=[];return n.forEach((e=>{a.forEach((t=>{i.exists({language:e,namespace:t})||r.push({language:e,namespace:t})}))})),0===r.length},t:(...e)=>{const t=P(...e),n=S(t);return r.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:N,run:function(){let e;return(()=>{const e=r.getLanguageDetector()||r.getLanguageStorage();if(e&&!o.getAvailableLanguages())throw new Error(c("availableLanguages"));if(!o.getLanguage()&&!o.getInitialOptions().defaultLanguage)throw e?new Error(c("defaultLanguage")):new Error(c("language"))})(),o.isRunning()||(N()&&i.invalidate(),o.setRunning(!0),r.run(),e=$()),Promise.resolve(e)},stop:function(){o.isRunning()&&(r.stop(),o.setRunning(!1))}}))},T=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=k(e.options,n),t),init(t){const n=(e=>{const t=N({options:e}),n=e=>{const n=t.isRunning();n&&t.stop(),e(),n&&t.run()},a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmmiterActive:t.setEmmiterActive,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})(k(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t};class S extends Error{constructor(e,t,n){let a;a=0===e?"Empty parameter":1===e?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function $(e){return/\s/.test(e)}const C=new Set([2,1,0]),R=new Set(["{","}","'"]);function _(e,t){const[n,a]=function(e){let t=0,n="",a="",o="";const r=[],i=[];let s=0;function u(t){throw new S(t,s,e)}const l=()=>{r.push(n),n=""},c=()=>{""===a&&u(0),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case 0:"'"===o?(n+=o,t=1):"{"===o?(l(),t=3):(n+=o,t=0);break;case 1:R.has(o)?(n=n.slice(0,-1)+o,t=2):(n+=o,t=0);break;case 2:"'"===o?t=0:(n+=o,t=2);break;case 3:"}"===o?(c(),t=0):$(o)?""!==a&&(c(),t=4):(/[0-9a-zA-Z_]/.test(o)||u(1),a+=o,t=3);break;case 4:"}"==o?t=0:$(o)?t=4:u(1)}return C.has(t)||u(2),l(),[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 D=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>_(e,t)}),e),I={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"},U=({highlightColor:e,highlightWidth:t})=>Object.freeze({initHighlighter:function(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add("_tolgee-highlighter"),Object.entries(I).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 F(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 M(e){return e.textContent}function V(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}const B=(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},K={capture:!0},Y={capture:!0,passive:!0},W=({highlightKeys:e,elementStore:t,onClick:n})=>{let a,o,r=new Set;const i=()=>{var e;const n=t.get(a);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),a=void 0)};function s(){const e=o;let n;if(e&&m()){const t=document.elementFromPoint(e.x,e.y);t&&(n=v(t))}(e=>{var n;if(a!==e){i();const o=t.get(e);o&&(o.preventClean=!0,null===(n=o.highlight)||void 0===n||n.call(o),a=e)}})(n)}const u=e=>{var t;m()&&(t=e.target,!Boolean(h(t,(e=>"__tolgee_dev_tools"===e.id))))&&(e.stopPropagation(),e.preventDefault())},l=e=>{var t;t={x:e.clientX,y:e.clientY},o=t,s()},c=()=>{r=new Set,s()},g=e=>{const t=e.key;void 0!==t&&r.add(t),s()},d=e=>{r.delete(e.key),s()},f=()=>{var e;const n=t.get(a);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)},p=e=>{if(u(e),m()){const t=v(e.target);t&&t===a&&(n(e,t),i())}};function v(e){return h(e,(e=>t.get(e)))}function h(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?h(e.parentElement,t):void 0}function m(){for(const t of e)if(!r.has(t))return!1;return!0}return Object.freeze({run:function(){window.addEventListener("blur",c,K),window.addEventListener("keydown",g,K),window.addEventListener("keyup",d,K),window.addEventListener("mousemove",l,Y),window.addEventListener("scroll",f,Y),window.addEventListener("click",p,K),window.addEventListener("mouseenter",u,K),window.addEventListener("mouseover",u,K),window.addEventListener("mouseout",u,K),window.addEventListener("mouseleave",u,K),window.addEventListener("mousedown",u,K),window.addEventListener("mouseup",u,K)},stop:function(){window.removeEventListener("blur",c,K),window.removeEventListener("keydown",g,K),window.removeEventListener("keyup",d,K),window.removeEventListener("mousemove",l,Y),window.removeEventListener("scroll",f,Y),window.removeEventListener("click",p,K),window.removeEventListener("mouseenter",u,K),window.removeEventListener("mouseover",u,K),window.removeEventListener("mouseout",u,K),window.removeEventListener("mouseleave",u,K),window.removeEventListener("mousedown",u,K),window.removeEventListener("mouseup",u,K)}})},X=(e,t)=>{const n=(()=>{const e=new Map;return Object.freeze({set:function(t,n){e.set(t,n)},get:function(t){return t&&e.get(t)},remove:function(t){return e.delete(t)},forEachElement:function(t){e.forEach(((e,n)=>t(n,e)))}})})(),a=U({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),o=W({highlightKeys:e.highlightKeys,elementStore:n,onClick:(e,a)=>{const o=n.get(a);t({event:e,keysAndDefaults:i(o)})}});function r(){return e.targetElement||document.body}function i(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:function(t,o,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest("[data-tolgee-restricted]")}(t))return;const i=t;let s=n.get(i);s||(s={nodes:new Map},n.set(i,s),i.setAttribute("_tolgee","true")),s.nodes.set(o,r),a.initHighlighter(i,s)},forEachElement:n.forEachElement,findAll:function(e,t){const a=[];return n.forEachElement(((n,o)=>{for(const n of o.nodes.values()){if(n.keys.find((n=>B({key:e,ns:g(t)},{key:n.key,ns:g(n.ns)})))){a.push(o);break}}})),a},refreshAll:function(){n.forEachElement(((e,t)=>{t.preventClean||(function(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())z(r(),t)&&(yield[t,n])}(e))}(t),0===t.nodes.size&&function(e,t){var a;t.highlightEl&&(null===(a=t.unhighlight)||void 0===a||a.call(t));e.removeAttribute("_tolgee"),n.remove(e)}(e,t))}))},run:function(e){e&&o.run()},stop:function(){o.stop()}})},G=(e,t,n)=>{let a=!1;const o=(e=>Object.freeze({getSuitableParent:function t(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(a):a}}))(t),i=((e,t)=>{const n=e=>F(t.getTextXPath(),e),a=n=>{let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=F(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a};return Object.freeze({handleAttributes:a,handleChildList:e=>{let t=[];return t=t.concat(a(e)),t=t.concat(n(e)),t},handleText:n})})(t,e),u=X(t,n);function l(t){for(const n of t){const t=M(n),a=t?e.unwrap(t):null;if(a){const{text:e,keys:r}=a;V(n,e);const i=s(t,r),l=o.getSuitableParent(n);u.register(l,n,i)}}}const c=e=>{F("./descendant-or-self::*[@data-tolgee-key-only]",e).forEach((e=>{const t=e.getAttributeNode("data-tolgee-key-only"),n=o.getSuitableParent(t);u.register(n,t,{oldTextContent:"",keys:[{key:M(t)}],keyAttributeOnly:!0})}))};let g;return Object.freeze({run:({mouseHighlight:e})=>{if(r())return;g||(g=new MutationObserver((e=>{if(a)for(const t of e){let e=[];switch(t.type){case"characterData":e=i.handleText(t.target);break;case"childList":c(t.target),e=i.handleChildList(t.target);break;case"attributes":c(t.target),e=i.handleAttributes(t.target)}l(e),u.refreshAll()}})));const n=t.targetElement||document.body;a=!0,u.run(e),c(n),l(i.handleChildList(n)),g.observe(t.targetElement||document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0})},stop:()=>{a=!1,u.stop(),g.disconnect()},wrap:e.wrap,unwrap:e.unwrap,forEachElement:u.forEachElement,highlight:(e,t)=>{const n=u.findAll(e,t);return n.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){n.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}}})};function H(){}function J(){}H.prototype.encode=function(e){const t=[],n=e.length;let a=0;for(;a<n;){const n=e.codePointAt(a);let o=0,r=0;for(n<=127?(o=0,r=0):n<=2047?(o=6,r=192):n<=65535?(o=12,r=224):n<=2097151&&(o=18,r=240),t.push(r|n>>o),o-=6;o>=0;)t.push(128|n>>o&63),o-=6;a+=n>=65536?2:1}return t},J.prototype.decode=function(e){let t="",n=0;for(;n<e.length;){let a=e[n],o=0,r=0;if(a<=127?(o=0,r=255&a):a<=223?(o=1,r=31&a):a<=239?(o=2,r=15&a):a<=244&&(o=3,r=7&a),e.length-n-o>0){let t=0;for(;t<o;)a=e[n+t+1],r=r<<6|63&a,t+=1}else r=65533,o=e.length-n;t+=String.fromCodePoint(r),n+=o+1}return t};const q="undefined"==typeof TextEncoder?H:TextEncoder,Z="undefined"==typeof TextDecoder?J:TextDecoder,Q=["",""],ee=RegExp(`([${Q.join("")}]{9})+`,"gu"),te=e=>{const t=(e=>Array.from((new q).encode(e)))(e).map(Number),n=t.map((e=>(e=>{const t=8-e.length;return"0".repeat(t)+e})(e.toString(2))+"0")).join("");return Array.from(n).map((e=>Q[Number(e)])).join("")},ne=e=>{const t=Array.from(e).map((e=>Q.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 Z).decode(new Uint8Array(a));var a},ae=()=>{const e=(()=>{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]})})(),t=e=>JSON.parse(e);return Object.freeze({unwrap:n=>{const a=[],o=(e=>{var t;const n=null===(t=e.match(ee))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(ne))||[]})(n);o.forEach((n=>{const[o]=(e=>{const t=[];for(const n of e)t.push(n.codePointAt(0));return t})(n),r=e.numberToValue(o),{k:i,d:s,n:u}=t(r);a.push({key:i,defaultValue:s,ns:u})}));const r=(e=>e.replace(ee,""))(n);return{text:r,keys:a}},wrap:({key:t,defaultValue:n,translation:a,ns:o})=>{const r=(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||"",u=te(String.fromCodePoint(i));return"string"==typeof s?s+u:s},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${Q[0]}${Q[0]}') or contains(., '${Q[1]}${Q[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${Q[0]}${Q[0]}') or contains(., '${Q[1]}${Q[0]}')]`})};function oe(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}const re=({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}}const o=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=e=>"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 u=void 0!==o?`,${r(o)}`:"",l="string"==typeof i?[i]:i,c=(null==l?void 0:l.length)?`|${l.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${c}${u}${s}${t}`},unwrap:n=>{const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,u=!1,l=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(l,d-l),l=d+t.length,"\\"===e){if(!oe(d,n)){c+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),u=!0,c+=e+p.translated}return c+=n.substring(l),u?{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}')]`})},ie=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((({translate:e,onClick:t,options:n})=>{const a=re({inputPrefix:n.inputPrefix,inputSuffix:n.inputSuffix,translate:e}),{wrap:o,unwrap:r,stop:i,forEachElement:s,highlight:u,run:l}=G(a,n,t);return{wrap:o,unwrap:r,stop:i,run:l,retranslate:()=>{s(((e,t)=>{for(const[e,n]of t.nodes.entries()){if(n.keyAttributeOnly)return;const t=a.unwrap(n.oldTextContent);t&&V(e,t.text)}}))},highlight:u,outputNotFormattable:!0}})):t.setObserver((({onClick:e,options:t})=>{const n=ae(),a=G(n,t,e);return Object.assign(Object.assign({},a),{retranslate:()=>{},outputNotFormattable:!1})})),e);function se(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function ue(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|se(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 le(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=ue(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}const ce=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o}){var r;const i=null!==(r=le(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 ge({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((()=>{}))})()}}let de=null;function fe(e){var t;return de||(de=(t=`https://cdn.jsdelivr.net/npm/@tolgee/web@${e||"rc"}/dist/tolgee-in-context-tools.umd.min.js`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window["@tolgee/in-context-tools"].InContextTools))),de}function pe(){const e=sessionStorage.getItem("__tolgee_apiKey")||void 0,t=sessionStorage.getItem("__tolgee_apiUrl")||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function ve(){sessionStorage.removeItem("__tolgee_apiKey"),sessionStorage.removeItem("__tolgee_apiUrl")}let he=()=>e=>e;"undefined"!=typeof window&&(he=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=ge({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(ve)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return pe()&&(async()=>{const e=await fe("rc");return t=>{const n=pe();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 me=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(i("LanguageStorage"),localStorage.getItem("__tolgee_currentLanguage")||void 0),setLanguage(e){i("LanguageStorage"),localStorage.setItem("__tolgee_currentLanguage",e)}}),e),be=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){i("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);const ye=e=>e.endsWith("/")?e.slice(0,-1):e,we={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${ye(n)}/${e}/${t}.json`:`${ye(n)}/${t}.json`,getData:e=>e.json(),headers:{Accept:"application/json"}},Ee=e=>{const t=Object.assign(Object.assign(Object.assign({},we),e),{headers:Object.assign(Object.assign({},we.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)}))}}},Le=e=>(t,n)=>(n.addBackend(Ee(e)),t),Oe=()=>T().use(he()),ke=()=>e=>e;export{Le as BackendFetch,he as BrowserExtensionPlugin,e as DEVTOOLS_ID,ce as DevBackend,ke as DevTools,D as FormatSimple,be as LanguageDetector,me as LanguageStorage,ie as ObserverPlugin,t as PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY,o as TOLGEE_ATTRIBUTE_NAME,a as TOLGEE_RESTRICT_ATTRIBUTE,n as TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE,Oe as Tolgee,T as TolgeeCore,g as getFallback,d as getFallbackArray,le as getProjectIdFromApiKey,P as getTranslateProps}; | ||
const e="__tolgee_dev_tools",t="__tolgee_preferredLanguages",n="data-tolgee-key-only",a="data-tolgee-restricted",o="_tolgee",r="_tolgee-highlighter";function i(){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 s(e){if(i())throw new Error(`${e}: Can't run on the server`)}function u(e,t){return{oldTextContent:e,keys:t}}function c(e){return Boolean(e&&"function"==typeof e.then)}const l=(e,t)=>c(e)?Promise.resolve(e).then(t):t(e),g=e=>`Tolgee: You need to specify '${e}' option`;function d(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function f(e){return d(e)||[]}function p(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?f(t):f(null==t?void 0:t[e]);var n}function v(e){return Array.from(new Set(e))}function h(e){return e?e.replace(/\/+$/,""):e}const m=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})))}})},b=(e,t,n)=>{const a=new Set,o=new Set;let r=[];const i=()=>{if(0===r.length)return;const e=r;r=[],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)))}));(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({listenSome:e=>{const t={fn:t=>{e(t)},namespaces:new Set};o.add(t);const a={unsubscribe:()=>{o.delete(t)},subscribeNs:e=>(f(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a},listen:e=>{a.add(e);return{unsubscribe:()=>{a.delete(e)}}},emit:(t,n)=>{e()&&(r.push(t),n?setTimeout(i,0):i())}})},y=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):y(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},w=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},E=({language:e,namespace:t})=>t?`${e}:${t}`:e,L=(e,t,n,a,o,r,i)=>{const s=new Map,u=new Map;let c={},l=0;function g(t,n,a){const o=E(t);u.set(o,{data:y(n),version:a}),e.emit(t)}function d(e,t){g(e,t,l)}function p(e,t=!1){const n=u.get(E(e));return n&&t?n.version===l:Boolean(n)}function h(e){var t;return null===(t=u.get(E(a(e))))||void 0===t?void 0:t.data}function m(e){let n;if(!n){const t=c[E(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}return Object.freeze({addStaticData:function(e){e&&(c=Object.assign(Object.assign({},c),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=w(e),a=u.get(e);a&&0!==a.version||g(n,t,0)}})))},invalidate:function(){s.clear(),l+=1},addRecord:d,exists:p,getRecord:h,getTranslation:function(e,t){var n;return null===(n=u.get(E(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs:function(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(E({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return v(e)},getTranslationFallback:function(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(E({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation:function(t,n,a){var o;const r=null===(o=u.get(E(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching:function(e){if(o())return!0;if(void 0===e)return s.size>0;const t=f(e);return Boolean(Array.from(s.keys()).find((e=>t.includes(w(e).namespace))))},isLoading:function(e,t){const n=f(t);return Boolean(o()||Array.from(s.keys()).find((t=>{const a=w(t);return(!n.length||n.includes(a.namespace))&&!p({namespace:a.namespace,language:e})})))},loadRecords:async function(e,t){const o=e.map((e=>{const o=a(e),r=E(o),i=s.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const u=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 s.set(r,u),{new:!0,promise:u,keyObject:o,cacheKey:r}}));r.notify(),i.notify();const u=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=s.get(e.cacheKey)!==e.promise;if(e.new&&!n){s.delete(e.cacheKey);const n=u[t];n?d(e.keyObject,n):h(e.keyObject)||d(e.keyObject,{})}})),r.notify(),i.notify(),o.map((e=>h(e.keyObject)))},getAllRecords:function(){return Array.from(u.entries()).map((([e,t])=>Object.assign(Object.assign({},w(e)),{data:t.data})))}})};function O(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 k="invalid",j={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:k,apiUrl:"https://app.tolgee.io"},A=(...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},x=(e,t)=>{const n=A(j,null==t?void 0:t.initialOptions,e);return n.apiUrl=h(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}},P=(e,t,n,a,o,r)=>{const i={ui:void 0,observer:void 0},s={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 r=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,ns:a({key:e,ns:t}),translation:o({key:e,ns:t})})));null===(n=s.ui)||void 0===n||n.handleElementClick(r,t)},g=(e,t)=>{var n,a;return(null===(a=null===(n=s.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},d=e=>{const t=o({key:e.key,ns:e.ns});return A(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))},f=e=>{i.observer=e},p=()=>Boolean(i.observer),v=e=>{e&&s.formatters.push(e)},h=e=>{s.finalFormatter=e},m=e=>{i.ui=e},b=()=>Boolean(i.ui),y=e=>{s.languageStorage=e},w=e=>{s.languageDetector=e},E=e=>{e&&s.backends.push(e)},L=e=>{s.devBackend=e},j=()=>s.devBackend;function A(n){var a,{formatEnabled:o}=n,r=O(n,["formatEnabled"]);const{key:i,translation:u,defaultValue:c,noWrap:l,params:g,orEmpty:d,ns:f}=r,p=u||c;let v=p||(d?"":i);const h=e(),m=o||!(null===(a=s.observer)||void 0===a?void 0:a.outputNotFormattable),b=e=>s.observer&&!l?s.observer.wrap({key:i,translation:e,defaultValue:c,params:g,ns:f}):e;v=b(v);try{if(p&&h&&m)for(const e of s.formatters)v=e.format({translation:v,language:h,params:g});s.finalFormatter&&p&&h&&m&&(v=s.finalFormatter.format({translation:v,language:h,params:g}))}catch(e){console.error(e);const n=("string"==typeof(y=e)?y:"string"==typeof(null==y?void 0:y.message)?y.message:void 0)||k,a=t().onFormatError,o=typeof a;v="string"===o?a:"function"===o?a(n,r):k,v=b(v)}var y;return v}return Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:h,addFormatter:v,setObserver:f,hasObserver:p,setUi:m,hasUi:b,setDevBackend:L,addBackend:E,setLanguageDetector:w,setLanguageStorage:y}))},formatTranslation:A,getDevBackend:j,getBackendRecord:({language:e,namespace:t})=>{for(const n of s.backends){const a=n.getRecord({language:e,namespace:t});if(c(a))return null==a?void 0:a.catch((e=>(console.error(e),{})));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:n})=>{var a;const{apiKey:o,apiUrl:r,projectId:i}=t();return null===(a=s.devBackend)||void 0===a?void 0:a.getRecord({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:n})},getLanguageDetector:()=>s.languageDetector,getLanguageStorage:()=>s.languageStorage,getInitialLanguage:()=>{var e;const t=n(),a=null===(e=s.languageStorage)||void 0===e?void 0:e.getLanguage();return l(a,(e=>t&&!t.includes(e)||!e?(()=>{if(!s.languageDetector)return;const e=n();return s.languageDetector.getLanguage({availableLanguages:e})})():e))},setStoredLanguage:e=>{var t;null===(t=s.languageStorage)||void 0===t||t.setLanguage(e)},run:()=>{var e,n,a;if(!s.ui){const{apiKey:n,apiUrl:a,projectId:o}=t();s.ui=null===(e=i.ui)||void 0===e?void 0:e.call(i,{apiKey:n,apiUrl:a,projectId:o,highlight:g,changeTranslation:r})}s.observer||(s.observer=null===(n=i.observer)||void 0===n?void 0:n.call(i,{translate:d,onClick:u,options:t().observerOptions})),null===(a=s.observer)||void 0===a||a.run({mouseHighlight:!0})},stop:()=>{var e;s.ui=void 0,null===(e=s.observer)||void 0===e||e.stop()},retranslate:()=>{var e;null===(e=s.observer)||void 0===e||e.retranslate()},highlight:g,unwrap:e=>{var t;return s.observer?null===(t=s.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap:e=>{var t;return s.observer?null===(t=s.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:function(){return Boolean(j())}})},N=(e,t,n)=>{let a=e;return Object.freeze({init:function(e){a=e},notify:function(){const e=t();a!==e&&n(e),a=e}})};const T=(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}=e,r=O(e,["ns","noWrap","orEmpty","params"]);const i={ns:t,noWrap:n,orEmpty:a};return Object.assign(Object.assign({},i),{params:Object.assign({},r)})}(n)),a)),a},S=({options:e})=>{const t=((e,t)=>{let n=!0;function a(){return n}const o=m(a),r=m(a),i=m(a),s=m(a),u=m(a),c=m(a),l=m(a),g=b(a,e,t);return u.listen((()=>g.emit())),r.listen((()=>g.emit())),l.listen((({value:e})=>{g.emit([e.namespace],!0)})),Object.freeze({onPendingLanguageChange:o,onLanguageChange:r,onLoadingChange:i,onFetchingChange:s,onInitialLoaded:u,onRunningChange:c,onCacheChange:l,onUpdate:g,setEmmiterActive:function(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.listen(t);case"language":return r.listen(t);case"loading":return i.listen(t);case"fetching":return s.listen(t);case"initialLoad":return u.listen(t);case"running":return c.listen(t);case"cache":return l.listen(t);case"update":return g.listen(t)}}})})(s,u),n=N(!1,(()=>i.isFetching()),t.onFetchingChange.emit),a=N(!1,(()=>k()),t.onLoadingChange.emit),o=((e,t,n)=>{let a,o=x();function r(){return o.language||o.initialOptions.language}function i(){return Object.assign(Object.assign({},o.initialOptions),a)}return Object.freeze({init:function(e){o=x(e,o)},isRunning:function(){return o.isRunning},setRunning:function(e){o.isRunning!==e&&(o.isRunning=e,n.emit(e))},isInitialLoading:function(){return o.isInitialLoading},setInitialLoading:function(e){o.isInitialLoading=e},getLanguage:r,setLanguage:function(t){o.language!==t&&(o.language=t,e.emit(t))},getPendingLanguage:function(){return o.pendingLanguage||r()},setPendingLanguage:function(e){o.pendingLanguage!==e&&(o.pendingLanguage=e,t.emit(e))},getInitialOptions:i,addActiveNs:function(e){f(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t?o.activeNamespaces.set(e,t+1):o.activeNamespaces.set(e,1)}))},removeActiveNs:function(e){f(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:function(){return v([...o.initialOptions.ns||[o.initialOptions.defaultNs],...f(o.initialOptions.fallbackNs),...o.activeNamespaces.keys()])},getFallbackLangs:function(e){const t=e||r();return t?v([t,...p(t,o.initialOptions.fallbackLanguage)]):[]},getFallbackNs:function(){return f(o.initialOptions.fallbackNs)},getDefaultNs:function(e){return void 0===e?o.initialOptions.defaultNs:e},getAvailableLanguages:function(){if(o.initialOptions.availableLanguages)return o.initialOptions.availableLanguages;if(o.initialOptions.staticData){const e=Object.keys(o.initialOptions.staticData).map((e=>w(e).language));return Array.from(new Set(e))}},withDefaultNs:function(e){return{namespace:void 0===e.namespace?i().defaultNs:e.namespace,language:e.language}},overrideCredentials:function(e){a=e?Object.assign(Object.assign({},e),{apiUrl:h(e.apiUrl)}):void 0}})})(t.onLanguageChange,t.onPendingLanguageChange,t.onRunningChange),r=P(o.getLanguage,o.getInitialOptions,o.getAvailableLanguages,(function({key:e,ns:t}){const n=o.getFallbackLangs(),a=d(t||void 0);return i.getTranslationNs(a,n,e)}),S,E),i=L(t.onCacheChange,r.getBackendRecord,r.getBackendDevRecord,o.withDefaultNs,o.isInitialLoading,n,a);function s(){return o.getFallbackNs()}function u(e){return o.getDefaultNs(e)}function d(e){return[...f(u(e)),...s()]}function y(e){return[...f(e||u()),...o.getRequiredNamespaces()]}function E(e,t,n){const a=o.withDefaultNs(e),r=i.getTranslation(a,t);return i.changeTranslation(a,t,n),{revert:()=>{i.changeTranslation(a,t,r)}}}function O(e){o.init(e),i.addStaticData(o.getInitialOptions().staticData)}function k(e){return i.isLoading(o.getLanguage(),e)}function j(){return Boolean(o.getInitialOptions().apiKey&&o.getInitialOptions().apiUrl)}function A(e,t){const n=function(e,t){const n=o.getFallbackLangs(e),a=y(t),r=[];return n.forEach((e=>{a.forEach((t=>{i.exists({language:e,namespace:t},!0)||r.push({language:e,namespace:t})}))})),r}(e,t);if(n.length)return l(C(n),(()=>{}))}function S({key:e,ns:t}){const n=d(t||void 0),a=o.getFallbackLangs();return i.getTranslationFallback(n,a,e)}function $(){const e=l(function(){if(o.getLanguage())return;if(!o.getInitialOptions().defaultLanguage)throw new Error(g("defaultLanguage"));const e=r.getInitialLanguage();return l(e,(e=>{const t=e||o.getInitialOptions().defaultLanguage;t&&o.setLanguage(t)}))}(),(()=>A()));if(c(e))return o.setInitialLoading(!0),n.notify(),a.notify(),Promise.resolve(e).then((()=>{o.setInitialLoading(!1),n.notify(),a.notify(),t.onInitialLoaded.emit()}));t.onInitialLoaded.emit()}function C(e){return i.loadRecords(e,j())}e&&O(e),t.onUpdate.listen((()=>{o.isRunning()&&r.retranslate()}));const R=()=>{const e=r.getLanguageDetector()||r.getLanguageStorage();if(e){if(!o.getAvailableLanguages())throw new Error(g("availableLanguages"))}if(!o.getLanguage()&&!o.getInitialOptions().defaultLanguage)throw e?new Error(g("defaultLanguage")):new Error(g("language"))};return Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),o),r),i),{init:O,changeLanguage:async function(e){o.getPendingLanguage()===e&&o.getLanguage()===e||(o.setPendingLanguage(e),o.isRunning()&&await A(e),e===o.getPendingLanguage()&&(o.setLanguage(e),r.setStoredLanguage(e)))},getTranslation:S,changeTranslation:E,addActiveNs:async function(e,t){t||o.addActiveNs(e),o.isRunning()&&await A(void 0,e)},loadRecords:C,loadRecord:async function(e){return(await C([e]))[0]},isLoading:k,isLoaded:function(e){const t=o.getLanguage();if(!t)return!1;const n=o.getFallbackLangs(t),a=y(e),r=[];return n.forEach((e=>{a.forEach((t=>{i.exists({language:e,namespace:t})||r.push({language:e,namespace:t})}))})),0===r.length},t:(...e)=>{const t=T(...e),n=S(t);return r.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:j,run:function(){let e;return R(),o.isRunning()||(j()&&i.invalidate(),o.setRunning(!0),r.run(),e=$()),Promise.resolve(e)},stop:function(){o.isRunning()&&(r.stop(),o.setRunning(!1))}}))},$=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=A(e.options,n),t),init(t){const n=(e=>{const t=S({options:e}),n=e=>{const n=t.isRunning();n&&t.stop(),e(),n&&t.run()},a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmmiterActive:t.setEmmiterActive,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})(A(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},C=0,R=1,D=2;class I extends Error{constructor(e,t,n){let a;a=e===C?"Empty parameter":e===R?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function U(e){return/\s/.test(e)}const _=0,F=1,M=2,V=3,z=4,B=new Set([M,F,_]),K="'",Y=new Set(["{","}",K]),W=e=>/[0-9a-zA-Z_]/.test(e);function X(e,t){const[n,a]=function(e){let t=_,n="",a="",o="";const r=[],i=[];let s=0;function u(t){throw new I(t,s,e)}const c=()=>{r.push(n),n=""},l=()=>{""===a&&u(C),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case _:o===K?(n+=o,t=F):"{"===o?(c(),t=V):(n+=o,t=_);break;case F:Y.has(o)?(n=n.slice(0,-1)+o,t=M):(n+=o,t=_);break;case M:o===K?t=_:(n+=o,t=M);break;case V:"}"===o?(l(),t=_):U(o)?""!==a&&(l(),t=z):(W(o)||u(R),a+=o,t=V);break;case z:"}"==o?t=_:U(o)?t=z:u(R)}return B.has(t)||u(D),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 G=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>X(e,t)}),e),H={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"},J=({highlightColor:e,highlightWidth:t})=>Object.freeze({initHighlighter:function(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(r),Object.entries(H).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const i=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=i.top-t+"px",o.style.left=i.left-t+"px",o.style.width=i.width+"px",o.style.height=i.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null===(e=t.highlightEl)||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}const 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},ne={capture:!0},ae={capture:!0,passive:!0},oe=({highlightKeys:t,elementStore:n,onClick:a})=>{let o,r,i=new Set;const s=e=>{var t;if(o!==e){u();const a=n.get(e);a&&(a.preventClean=!0,null===(t=a.highlight)||void 0===t||t.call(a),o=e)}},u=()=>{var e;const t=n.get(o);t&&(t.preventClean=!1,null===(e=t.unhighlight)||void 0===e||e.call(t),o=void 0)};function c(){const e=r;let t;if(e&&y()){const n=document.elementFromPoint(e.x,e.y);n&&(t=m(n))}s(t)}const l=t=>{var n;y()&&(n=t.target,!Boolean(b(n,(t=>t.id===e))))&&(t.stopPropagation(),t.preventDefault())},g=e=>{var t;t={x:e.clientX,y:e.clientY},r=t,c()},d=()=>{i=new Set,c()},f=e=>{const t=e.key;void 0!==t&&i.add(t),c()},p=e=>{i.delete(e.key),c()},v=()=>{var e;const t=n.get(o);null===(e=null==t?void 0:t.highlight)||void 0===e||e.call(t)},h=e=>{if(l(e),y()){const t=m(e.target);t&&t===o&&(a(e,t),u())}};function m(e){return b(e,(e=>n.get(e)))}function b(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?b(e.parentElement,t):void 0}function y(){for(const e of t)if(!i.has(e))return!1;return!0}return Object.freeze({run:function(){window.addEventListener("blur",d,ne),window.addEventListener("keydown",f,ne),window.addEventListener("keyup",p,ne),window.addEventListener("mousemove",g,ae),window.addEventListener("scroll",v,ae),window.addEventListener("click",h,ne),window.addEventListener("mouseenter",l,ne),window.addEventListener("mouseover",l,ne),window.addEventListener("mouseout",l,ne),window.addEventListener("mouseleave",l,ne),window.addEventListener("mousedown",l,ne),window.addEventListener("mouseup",l,ne)},stop:function(){window.removeEventListener("blur",d,ne),window.removeEventListener("keydown",f,ne),window.removeEventListener("keyup",p,ne),window.removeEventListener("mousemove",g,ae),window.removeEventListener("scroll",v,ae),window.removeEventListener("click",h,ne),window.removeEventListener("mouseenter",l,ne),window.removeEventListener("mouseover",l,ne),window.removeEventListener("mouseout",l,ne),window.removeEventListener("mouseleave",l,ne),window.removeEventListener("mousedown",l,ne),window.removeEventListener("mouseup",l,ne)}})},re=(e,t)=>{const n=(()=>{const e=new Map;return Object.freeze({set:function(t,n){e.set(t,n)},get:function(t){return t&&e.get(t)},remove:function(t){return e.delete(t)},forEachElement:function(t){e.forEach(((e,n)=>t(n,e)))}})})(),r=J({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),i=oe({highlightKeys:e.highlightKeys,elementStore:n,onClick:(e,a)=>{const o=n.get(a);t({event:e,keysAndDefaults:u(o)})}});function s(){return e.targetElement||document.body}function u(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:function(t,i,s){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${a}]`)}(t))return;const u=t;let c=n.get(u);c||(c={nodes:new Map},n.set(u,c),u.setAttribute(o,"true")),c.nodes.set(i,s),r.initHighlighter(u,c)},forEachElement:n.forEachElement,findAll:function(e,t){const a=[];return n.forEachElement(((n,o)=>{for(const n of o.nodes.values()){if(n.keys.find((n=>te({key:e,ns:d(t)},{key:n.key,ns:d(n.ns)})))){a.push(o);break}}})),a},refreshAll:function(){n.forEachElement(((e,t)=>{t.preventClean||(function(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())ee(s(),t)&&(yield[t,n])}(e))}(t),0===t.nodes.size&&function(e,t){var a;t.highlightEl&&(null===(a=t.unhighlight)||void 0===a||a.call(t));e.removeAttribute(o),n.remove(e)}(e,t))}))},run:function(e){e&&i.run()},stop:function(){i.stop()}})},ie=(e,t,a)=>{let o=!1;const r=(e=>Object.freeze({getSuitableParent:function t(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(a):a}}))(t),s=((e,t)=>{const n=e=>q(t.getTextXPath(),e),a=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};return Object.freeze({handleAttributes:a,handleChildList:e=>{let t=[];return t=t.concat(a(e)),t=t.concat(n(e)),t},handleText:n})})(t,e),c=re(t,a);function l(t){for(const n of t){const t=Z(n),a=t?e.unwrap(t):null;if(a){const{text:e,keys:o}=a;Q(n,e);const i=u(t,o),s=r.getSuitableParent(n);c.register(s,n,i)}}}const g=e=>{q(`./descendant-or-self::*[@${n}]`,e).forEach((e=>{const t=e.getAttributeNode(n),a=r.getSuitableParent(t);c.register(a,t,{oldTextContent:"",keys:[{key:Z(t)}],keyAttributeOnly:!0})}))};let d;return Object.freeze({run:({mouseHighlight:e})=>{if(i())return;d||(d=new MutationObserver((e=>{if(o)for(const t of e){let e=[];switch(t.type){case"characterData":e=s.handleText(t.target);break;case"childList":g(t.target),e=s.handleChildList(t.target);break;case"attributes":g(t.target),e=s.handleAttributes(t.target)}l(e),c.refreshAll()}})));const n=t.targetElement||document.body;o=!0,c.run(e),g(n),l(s.handleChildList(n)),d.observe(t.targetElement||document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0})},stop:()=>{o=!1,c.stop(),d.disconnect()},wrap:e.wrap,unwrap:e.unwrap,forEachElement:c.forEachElement,highlight:(e,t)=>{const n=c.findAll(e,t);return n.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){n.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}}})};function se(){}function ue(){}se.prototype.encode=function(e){const t=[],n=e.length;let a=0;for(;a<n;){const n=e.codePointAt(a);let o=0,r=0;for(n<=127?(o=0,r=0):n<=2047?(o=6,r=192):n<=65535?(o=12,r=224):n<=2097151&&(o=18,r=240),t.push(r|n>>o),o-=6;o>=0;)t.push(128|n>>o&63),o-=6;a+=n>=65536?2:1}return t},ue.prototype.decode=function(e){let t="",n=0;for(;n<e.length;){let a=e[n],o=0,r=0;if(a<=127?(o=0,r=255&a):a<=223?(o=1,r=31&a):a<=239?(o=2,r=15&a):a<=244&&(o=3,r=7&a),e.length-n-o>0){let t=0;for(;t<o;)a=e[n+t+1],r=r<<6|63&a,t+=1}else r=65533,o=e.length-n;t+=String.fromCodePoint(r),n+=o+1}return t};const ce="undefined"==typeof TextEncoder?se:TextEncoder,le="undefined"==typeof TextDecoder?ue:TextDecoder,ge=["",""],de=RegExp(`([${ge.join("")}]{9})+`,"gu"),fe=e=>{const t=(e=>Array.from((new ce).encode(e)))(e).map(Number),n=t.map((e=>(e=>{const t=8-e.length;return"0".repeat(t)+e})(e.toString(2))+"0")).join("");return Array.from(n).map((e=>ge[Number(e)])).join("")},pe=e=>{const t=Array.from(e).map((e=>ge.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 le).decode(new Uint8Array(a));var a},ve=()=>{const e=(()=>{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]})})(),t=e=>JSON.parse(e);return Object.freeze({unwrap:n=>{const a=[],o=(e=>{var t;const n=null===(t=e.match(de))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(pe))||[]})(n);o.forEach((n=>{const[o]=(e=>{const t=[];for(const n of e)t.push(n.codePointAt(0));return t})(n),r=e.numberToValue(o),{k:i,d:s,n:u}=t(r);a.push({key:i,defaultValue:s,ns:u})}));const r=(e=>e.replace(de,""))(n);return{text:r,keys:a}},wrap:({key:t,defaultValue:n,translation:a,ns:o})=>{const r=(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||"",u=fe(String.fromCodePoint(i));return"string"==typeof s?s+u:s},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${ge[0]}${ge[0]}') or contains(., '${ge[1]}${ge[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${ge[0]}${ge[0]}') or contains(., '${ge[1]}${ge[0]}')]`})};function he(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}const me=({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}}const o=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=e=>"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 u=void 0!==o?`,${r(o)}`:"",c="string"==typeof i?[i]:i,l=(null==c?void 0:c.length)?`|${c.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${l}${u}${s}${t}`},unwrap:n=>{const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,u=!1,c=0,l="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(l+=f.substr(c,d-c),c=d+t.length,"\\"===e){if(!he(d,n)){l+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),u=!0,l+=e+p.translated}return l+=n.substring(c),u?{text:l,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}')]`})},be=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((({translate:e,onClick:t,options:n})=>{const a=me({inputPrefix:n.inputPrefix,inputSuffix:n.inputSuffix,translate:e}),{wrap:o,unwrap:r,stop:i,forEachElement:s,highlight:u,run:c}=ie(a,n,t);return{wrap:o,unwrap:r,stop:i,run:c,retranslate:()=>{s(((e,t)=>{for(const[e,n]of t.nodes.entries()){if(n.keyAttributeOnly)return;const t=a.unwrap(n.oldTextContent);t&&Q(e,t.text)}}))},highlight:u,outputNotFormattable:!0}})):t.setObserver((({onClick:e,options:t})=>{const n=ve(),a=ie(n,t,e);return Object.assign(Object.assign({},a),{retranslate:()=>{},outputNotFormattable:!1})})),e),ye="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function we(e){const t=ye.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function Ee(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|we(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 Le(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=Ee(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}const Oe=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o}){var r;const i=null!==(r=Le(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 ke({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 je="tolgee-in-context-tools.umd.min.js",Ae="@tolgee/in-context-tools",xe="InContextTools",Pe="https://cdn.jsdelivr.net/npm";let Ne=null;function Te(e){var t;return Ne||(Ne=(t=`${Pe}/@tolgee/web@${e||"rc"}/dist/${je}`,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[Ae][xe]))),Ne}const Se="__tolgee_apiKey",$e="__tolgee_apiUrl";function Ce(){const e=sessionStorage.getItem(Se)||void 0,t=sessionStorage.getItem($e)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Re(){sessionStorage.removeItem(Se),sessionStorage.removeItem($e)}let De=()=>e=>e;"undefined"!=typeof window&&(De=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=ke({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(Re)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Ce()&&(async()=>{const e=await Te("rc");return t=>{const n=Ce();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 Ie="__tolgee_currentLanguage",Ue=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(s("LanguageStorage"),localStorage.getItem(Ie)||void 0),setLanguage(e){s("LanguageStorage"),localStorage.setItem(Ie,e)}}),e),_e=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){s("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);const Fe=e=>e.endsWith("/")?e.slice(0,-1):e,Me={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${Fe(n)}/${e}/${t}.json`:`${Fe(n)}/${t}.json`,getData:e=>e.json(),headers:{Accept:"application/json"}},Ve=e=>{const t=Object.assign(Object.assign(Object.assign({},Me),e),{headers:Object.assign(Object.assign({},Me.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)}))}}},ze=e=>(t,n)=>(n.addBackend(Ve(e)),t),Be=()=>$().use(De()),Ke=()=>e=>e;export{ze as BackendFetch,De as BrowserExtensionPlugin,e as DEVTOOLS_ID,Oe as DevBackend,Ke as DevTools,G as FormatSimple,_e as LanguageDetector,Ue as LanguageStorage,be as ObserverPlugin,t as PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY,o as TOLGEE_ATTRIBUTE_NAME,a as TOLGEE_RESTRICT_ATTRIBUTE,n as TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE,Be as Tolgee,$ as TolgeeCore,d as getFallback,f as getFallbackArray,Le as getProjectIdFromApiKey,T 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";const t="__tolgee_dev_tools",n="data-tolgee-key-only",a="data-tolgee-restricted",o="_tolgee";function r(){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 i(e){if(r())throw new Error(`${e}: Can't run on the server`)}function s(e,t){return{oldTextContent:e,keys:t}}function u(e){return Boolean(e&&"function"==typeof e.then)}const l=(e,t)=>u(e)?Promise.resolve(e).then(t):t(e),c=e=>`Tolgee: You need to specify '${e}' option`;function g(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function d(e){return g(e)||[]}function f(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?d(t):d(null==t?void 0:t[e]);var n}function p(e){return Array.from(new Set(e))}function v(e){return e?e.replace(/\/+$/,""):e}const h=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})))}})},m=(e,t,n)=>{const a=new Set,o=new Set;let r=[];const i=()=>{if(0===r.length)return;const e=r;r=[],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)))}));(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({listenSome:e=>{const t={fn:t=>{e(t)},namespaces:new Set};o.add(t);const a={unsubscribe:()=>{o.delete(t)},subscribeNs:e=>(d(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a},listen:e=>{a.add(e);return{unsubscribe:()=>{a.delete(e)}}},emit:(t,n)=>{e()&&(r.push(t),n?setTimeout(i,0):i())}})},b=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):b(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},y=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},E=({language:e,namespace:t})=>t?`${e}:${t}`:e,w=(e,t,n,a,o,r,i)=>{const s=new Map,u=new Map;let l={},c=0;function g(t,n,a){const o=E(t);u.set(o,{data:b(n),version:a}),e.emit(t)}function f(e,t){g(e,t,c)}function v(e,t=!1){const n=u.get(E(e));return n&&t?n.version===c:Boolean(n)}function h(e){var t;return null===(t=u.get(E(a(e))))||void 0===t?void 0:t.data}function m(e){let n;if(!n){const t=l[E(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}return Object.freeze({addStaticData:function(e){e&&(l=Object.assign(Object.assign({},l),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=y(e),a=u.get(e);a&&0!==a.version||g(n,t,0)}})))},invalidate:function(){s.clear(),c+=1},addRecord:f,exists:v,getRecord:h,getTranslation:function(e,t){var n;return null===(n=u.get(E(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs:function(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(E({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return p(e)},getTranslationFallback:function(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(E({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation:function(t,n,a){var o;const r=null===(o=u.get(E(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching:function(e){if(o())return!0;if(void 0===e)return s.size>0;const t=d(e);return Boolean(Array.from(s.keys()).find((e=>t.includes(y(e).namespace))))},isLoading:function(e,t){const n=d(t);return Boolean(o()||Array.from(s.keys()).find((t=>{const a=y(t);return(!n.length||n.includes(a.namespace))&&!v({namespace:a.namespace,language:e})})))},loadRecords:async function(e,t){const o=e.map((e=>{const o=a(e),r=E(o),i=s.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const u=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 s.set(r,u),{new:!0,promise:u,keyObject:o,cacheKey:r}}));r.notify(),i.notify();const u=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=s.get(e.cacheKey)!==e.promise;if(e.new&&!n){s.delete(e.cacheKey);const n=u[t];n?f(e.keyObject,n):h(e.keyObject)||f(e.keyObject,{})}})),r.notify(),i.notify(),o.map((e=>h(e.keyObject)))},getAllRecords:function(){return Array.from(u.entries()).map((([e,t])=>Object.assign(Object.assign({},y(e)),{data:t.data})))}})};function L(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 O="invalid",k={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:O,apiUrl:"https://app.tolgee.io"},A=(...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},j=(e,t)=>{const n=A(k,null==t?void 0:t.initialOptions,e);return n.apiUrl=v(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}},T=(e,t,n,a,o,r)=>{const i={ui:void 0,observer:void 0},s={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 r=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,ns:a({key:e,ns:t}),translation:o({key:e,ns:t})})));null===(n=s.ui)||void 0===n||n.handleElementClick(r,t)},g=(e,t)=>{var n,a;return(null===(a=null===(n=s.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},d=e=>{const t=o({key:e.key,ns:e.ns});return j(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))},f=e=>{i.observer=e},p=()=>Boolean(i.observer),v=e=>{e&&s.formatters.push(e)},h=e=>{s.finalFormatter=e},m=e=>{i.ui=e},b=()=>Boolean(i.ui),y=e=>{s.languageStorage=e},E=e=>{s.languageDetector=e},w=e=>{e&&s.backends.push(e)},k=e=>{s.devBackend=e},A=()=>s.devBackend;function j(n){var a,{formatEnabled:o}=n,r=L(n,["formatEnabled"]);const{key:i,translation:u,defaultValue:l,noWrap:c,params:g,orEmpty:d,ns:f}=r,p=u||l;let v=p||(d?"":i);const h=e(),m=o||!(null===(a=s.observer)||void 0===a?void 0:a.outputNotFormattable),b=e=>s.observer&&!c?s.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:f}):e;v=b(v);try{if(p&&h&&m)for(const e of s.formatters)v=e.format({translation:v,language:h,params:g});s.finalFormatter&&p&&h&&m&&(v=s.finalFormatter.format({translation:v,language:h,params:g}))}catch(e){console.error(e);const n=("string"==typeof(y=e)?y:"string"==typeof(null==y?void 0:y.message)?y.message:void 0)||O,a=t().onFormatError,o=typeof a;v="string"===o?a:"function"===o?a(n,r):O,v=b(v)}var y;return v}return Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:h,addFormatter:v,setObserver:f,hasObserver:p,setUi:m,hasUi:b,setDevBackend:k,addBackend:w,setLanguageDetector:E,setLanguageStorage:y}))},formatTranslation:j,getDevBackend:A,getBackendRecord:({language:e,namespace:t})=>{for(const n of s.backends){const a=n.getRecord({language:e,namespace:t});if(u(a))return null==a?void 0:a.catch((e=>(console.error(e),{})));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:n})=>{var a;const{apiKey:o,apiUrl:r,projectId:i}=t();return null===(a=s.devBackend)||void 0===a?void 0:a.getRecord({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:n})},getLanguageDetector:()=>s.languageDetector,getLanguageStorage:()=>s.languageStorage,getInitialLanguage:()=>{var e;const t=n(),a=null===(e=s.languageStorage)||void 0===e?void 0:e.getLanguage();return l(a,(e=>t&&!t.includes(e)||!e?(()=>{if(!s.languageDetector)return;const e=n();return s.languageDetector.getLanguage({availableLanguages:e})})():e))},setStoredLanguage:e=>{var t;null===(t=s.languageStorage)||void 0===t||t.setLanguage(e)},run:()=>{var e,n,a;if(!s.ui){const{apiKey:n,apiUrl:a,projectId:o}=t();s.ui=null===(e=i.ui)||void 0===e?void 0:e.call(i,{apiKey:n,apiUrl:a,projectId:o,highlight:g,changeTranslation:r})}s.observer||(s.observer=null===(n=i.observer)||void 0===n?void 0:n.call(i,{translate:d,onClick:c,options:t().observerOptions})),null===(a=s.observer)||void 0===a||a.run({mouseHighlight:!0})},stop:()=>{var e;s.ui=void 0,null===(e=s.observer)||void 0===e||e.stop()},retranslate:()=>{var e;null===(e=s.observer)||void 0===e||e.retranslate()},highlight:g,unwrap:e=>{var t;return s.observer?null===(t=s.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap:e=>{var t;return s.observer?null===(t=s.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:function(){return Boolean(A())}})},P=(e,t,n)=>{let a=e;return Object.freeze({init:function(e){a=e},notify:function(){const e=t();a!==e&&n(e),a=e}})};const x=(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}=e,r=L(e,["ns","noWrap","orEmpty","params"]);const i={ns:t,noWrap:n,orEmpty:a};return Object.assign(Object.assign({},i),{params:Object.assign({},r)})}(n)),a)),a},N=({options:e})=>{const t=((e,t)=>{let n=!0;function a(){return n}const o=h(a),r=h(a),i=h(a),s=h(a),u=h(a),l=h(a),c=h(a),g=m(a,e,t);return u.listen((()=>g.emit())),r.listen((()=>g.emit())),c.listen((({value:e})=>{g.emit([e.namespace],!0)})),Object.freeze({onPendingLanguageChange:o,onLanguageChange:r,onLoadingChange:i,onFetchingChange:s,onInitialLoaded:u,onRunningChange:l,onCacheChange:c,onUpdate:g,setEmmiterActive:function(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.listen(t);case"language":return r.listen(t);case"loading":return i.listen(t);case"fetching":return s.listen(t);case"initialLoad":return u.listen(t);case"running":return l.listen(t);case"cache":return c.listen(t);case"update":return g.listen(t)}}})})(s,g),n=P(!1,(()=>i.isFetching()),t.onFetchingChange.emit),a=P(!1,(()=>k()),t.onLoadingChange.emit),o=((e,t,n)=>{let a,o=j();function r(){return o.language||o.initialOptions.language}function i(){return Object.assign(Object.assign({},o.initialOptions),a)}return Object.freeze({init:function(e){o=j(e,o)},isRunning:function(){return o.isRunning},setRunning:function(e){o.isRunning!==e&&(o.isRunning=e,n.emit(e))},isInitialLoading:function(){return o.isInitialLoading},setInitialLoading:function(e){o.isInitialLoading=e},getLanguage:r,setLanguage:function(t){o.language!==t&&(o.language=t,e.emit(t))},getPendingLanguage:function(){return o.pendingLanguage||r()},setPendingLanguage:function(e){o.pendingLanguage!==e&&(o.pendingLanguage=e,t.emit(e))},getInitialOptions:i,addActiveNs:function(e){d(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t?o.activeNamespaces.set(e,t+1):o.activeNamespaces.set(e,1)}))},removeActiveNs:function(e){d(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:function(){return p([...o.initialOptions.ns||[o.initialOptions.defaultNs],...d(o.initialOptions.fallbackNs),...o.activeNamespaces.keys()])},getFallbackLangs:function(e){const t=e||r();return t?p([t,...f(t,o.initialOptions.fallbackLanguage)]):[]},getFallbackNs:function(){return d(o.initialOptions.fallbackNs)},getDefaultNs:function(e){return void 0===e?o.initialOptions.defaultNs:e},getAvailableLanguages:function(){if(o.initialOptions.availableLanguages)return o.initialOptions.availableLanguages;if(o.initialOptions.staticData){const e=Object.keys(o.initialOptions.staticData).map((e=>y(e).language));return Array.from(new Set(e))}},withDefaultNs:function(e){return{namespace:void 0===e.namespace?i().defaultNs:e.namespace,language:e.language}},overrideCredentials:function(e){a=e?Object.assign(Object.assign({},e),{apiUrl:v(e.apiUrl)}):void 0}})})(t.onLanguageChange,t.onPendingLanguageChange,t.onRunningChange),r=T(o.getLanguage,o.getInitialOptions,o.getAvailableLanguages,(function({key:e,ns:t}){const n=o.getFallbackLangs(),a=b(t||void 0);return i.getTranslationNs(a,n,e)}),S,L),i=w(t.onCacheChange,r.getBackendRecord,r.getBackendDevRecord,o.withDefaultNs,o.isInitialLoading,n,a);function s(){return o.getFallbackNs()}function g(e){return o.getDefaultNs(e)}function b(e){return[...d(g(e)),...s()]}function E(e){return[...d(e||g()),...o.getRequiredNamespaces()]}function L(e,t,n){const a=o.withDefaultNs(e),r=i.getTranslation(a,t);return i.changeTranslation(a,t,n),{revert:()=>{i.changeTranslation(a,t,r)}}}function O(e){o.init(e),i.addStaticData(o.getInitialOptions().staticData)}function k(e){return i.isLoading(o.getLanguage(),e)}function A(){return Boolean(o.getInitialOptions().apiKey&&o.getInitialOptions().apiUrl)}function N(e,t){const n=function(e,t){const n=o.getFallbackLangs(e),a=E(t),r=[];return n.forEach((e=>{a.forEach((t=>{i.exists({language:e,namespace:t},!0)||r.push({language:e,namespace:t})}))})),r}(e,t);if(n.length)return l(D(n),(()=>{}))}function S({key:e,ns:t}){const n=b(t||void 0),a=o.getFallbackLangs();return i.getTranslationFallback(n,a,e)}function R(){const e=l(function(){if(o.getLanguage())return;if(!o.getInitialOptions().defaultLanguage)throw new Error(c("defaultLanguage"));const e=r.getInitialLanguage();return l(e,(e=>{const t=e||o.getInitialOptions().defaultLanguage;t&&o.setLanguage(t)}))}(),(()=>N()));if(u(e))return o.setInitialLoading(!0),n.notify(),a.notify(),Promise.resolve(e).then((()=>{o.setInitialLoading(!1),n.notify(),a.notify(),t.onInitialLoaded.emit()}));t.onInitialLoaded.emit()}function D(e){return i.loadRecords(e,A())}e&&O(e),t.onUpdate.listen((()=>{o.isRunning()&&r.retranslate()}));return Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),o),r),i),{init:O,changeLanguage:async function(e){o.getPendingLanguage()===e&&o.getLanguage()===e||(o.setPendingLanguage(e),o.isRunning()&&await N(e),e===o.getPendingLanguage()&&(o.setLanguage(e),r.setStoredLanguage(e)))},getTranslation:S,changeTranslation:L,addActiveNs:async function(e,t){t||o.addActiveNs(e),o.isRunning()&&await N(void 0,e)},loadRecords:D,loadRecord:async function(e){return(await D([e]))[0]},isLoading:k,isLoaded:function(e){const t=o.getLanguage();if(!t)return!1;const n=o.getFallbackLangs(t),a=E(e),r=[];return n.forEach((e=>{a.forEach((t=>{i.exists({language:e,namespace:t})||r.push({language:e,namespace:t})}))})),0===r.length},t:(...e)=>{const t=x(...e),n=S(t);return r.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:A,run:function(){let e;return(()=>{const e=r.getLanguageDetector()||r.getLanguageStorage();if(e&&!o.getAvailableLanguages())throw new Error(c("availableLanguages"));if(!o.getLanguage()&&!o.getInitialOptions().defaultLanguage)throw e?new Error(c("defaultLanguage")):new Error(c("language"))})(),o.isRunning()||(A()&&i.invalidate(),o.setRunning(!0),r.run(),e=R()),Promise.resolve(e)},stop:function(){o.isRunning()&&(r.stop(),o.setRunning(!1))}}))},S=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=A(e.options,n),t),init(t){const n=(e=>{const t=N({options:e}),n=e=>{const n=t.isRunning();n&&t.stop(),e(),n&&t.run()},a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmmiterActive:t.setEmmiterActive,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})(A(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t};class R extends Error{constructor(e,t,n){let a;a=0===e?"Empty parameter":1===e?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function D(e){return/\s/.test(e)}const C=new Set([2,1,0]),I=new Set(["{","}","'"]);function $(e,t){const[n,a]=function(e){let t=0,n="",a="",o="";const r=[],i=[];let s=0;function u(t){throw new R(t,s,e)}const l=()=>{r.push(n),n=""},c=()=>{""===a&&u(0),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case 0:"'"===o?(n+=o,t=1):"{"===o?(l(),t=3):(n+=o,t=0);break;case 1:I.has(o)?(n=n.slice(0,-1)+o,t=2):(n+=o,t=0);break;case 2:"'"===o?t=0:(n+=o,t=2);break;case 3:"}"===o?(c(),t=0):D(o)?""!==a&&(c(),t=4):(/[0-9a-zA-Z_]/.test(o)||u(1),a+=o,t=3);break;case 4:"}"==o?t=0:D(o)?t=4:u(1)}return C.has(t)||u(2),l(),[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 _={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"},U=({highlightColor:e,highlightWidth:t})=>Object.freeze({initHighlighter:function(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add("_tolgee-highlighter"),Object.entries(_).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 F(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 B(e){return e.textContent}function M(e,t){e.textContent=t}function V(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}const K=(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},z={capture:!0},Y={capture:!0,passive:!0},G=({highlightKeys:e,elementStore:n,onClick:a})=>{let o,r,i=new Set;const s=()=>{var e;const t=n.get(o);t&&(t.preventClean=!1,null===(e=t.unhighlight)||void 0===e||e.call(t),o=void 0)};function u(){const e=r;let t;if(e&&b()){const n=document.elementFromPoint(e.x,e.y);n&&(t=h(n))}(e=>{var t;if(o!==e){s();const a=n.get(e);a&&(a.preventClean=!0,null===(t=a.highlight)||void 0===t||t.call(a),o=e)}})(t)}const l=e=>{var n;b()&&(n=e.target,!Boolean(m(n,(e=>e.id===t))))&&(e.stopPropagation(),e.preventDefault())},c=e=>{var t;t={x:e.clientX,y:e.clientY},r=t,u()},g=()=>{i=new Set,u()},d=e=>{const t=e.key;void 0!==t&&i.add(t),u()},f=e=>{i.delete(e.key),u()},p=()=>{var e;const t=n.get(o);null===(e=null==t?void 0:t.highlight)||void 0===e||e.call(t)},v=e=>{if(l(e),b()){const t=h(e.target);t&&t===o&&(a(e,t),s())}};function h(e){return m(e,(e=>n.get(e)))}function m(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?m(e.parentElement,t):void 0}function b(){for(const t of e)if(!i.has(t))return!1;return!0}return Object.freeze({run:function(){window.addEventListener("blur",g,z),window.addEventListener("keydown",d,z),window.addEventListener("keyup",f,z),window.addEventListener("mousemove",c,Y),window.addEventListener("scroll",p,Y),window.addEventListener("click",v,z),window.addEventListener("mouseenter",l,z),window.addEventListener("mouseover",l,z),window.addEventListener("mouseout",l,z),window.addEventListener("mouseleave",l,z),window.addEventListener("mousedown",l,z),window.addEventListener("mouseup",l,z)},stop:function(){window.removeEventListener("blur",g,z),window.removeEventListener("keydown",d,z),window.removeEventListener("keyup",f,z),window.removeEventListener("mousemove",c,Y),window.removeEventListener("scroll",p,Y),window.removeEventListener("click",v,z),window.removeEventListener("mouseenter",l,z),window.removeEventListener("mouseover",l,z),window.removeEventListener("mouseout",l,z),window.removeEventListener("mouseleave",l,z),window.removeEventListener("mousedown",l,z),window.removeEventListener("mouseup",l,z)}})},W=(e,t)=>{const n=(()=>{const e=new Map;return Object.freeze({set:function(t,n){e.set(t,n)},get:function(t){return t&&e.get(t)},remove:function(t){return e.delete(t)},forEachElement:function(t){e.forEach(((e,n)=>t(n,e)))}})})(),a=U({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=G({highlightKeys:e.highlightKeys,elementStore:n,onClick:(e,a)=>{const o=n.get(a);t({event:e,keysAndDefaults:s(o)})}});function i(){return e.targetElement||document.body}function s(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({register:function(t,r,i){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest("[data-tolgee-restricted]")}(t))return;const s=t;let u=n.get(s);u||(u={nodes:new Map},n.set(s,u),s.setAttribute(o,"true")),u.nodes.set(r,i),a.initHighlighter(s,u)},forEachElement:n.forEachElement,findAll:function(e,t){const a=[];return n.forEachElement(((n,o)=>{for(const n of o.nodes.values()){if(n.keys.find((n=>K({key:e,ns:g(t)},{key:n.key,ns:g(n.ns)})))){a.push(o);break}}})),a},refreshAll:function(){n.forEachElement(((e,t)=>{t.preventClean||(function(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())V(i(),t)&&(yield[t,n])}(e))}(t),0===t.nodes.size&&function(e,t){var a;t.highlightEl&&(null===(a=t.unhighlight)||void 0===a||a.call(t));e.removeAttribute(o),n.remove(e)}(e,t))}))},run:function(e){e&&r.run()},stop:function(){r.stop()}})},X=(e,t,a)=>{let o=!1;const i=(e=>Object.freeze({getSuitableParent:function t(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(a):a}}))(t),u=((e,t)=>{const n=e=>F(t.getTextXPath(),e),a=n=>{let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=F(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a};return Object.freeze({handleAttributes:a,handleChildList:e=>{let t=[];return t=t.concat(a(e)),t=t.concat(n(e)),t},handleText:n})})(t,e),l=W(t,a);function c(t){for(const n of t){const t=B(n),a=t?e.unwrap(t):null;if(a){const{text:e,keys:o}=a;M(n,e);const r=s(t,o),u=i.getSuitableParent(n);l.register(u,n,r)}}}const g=e=>{F("./descendant-or-self::*[@data-tolgee-key-only]",e).forEach((e=>{const t=e.getAttributeNode(n),a=i.getSuitableParent(t);l.register(a,t,{oldTextContent:"",keys:[{key:B(t)}],keyAttributeOnly:!0})}))};let d;return Object.freeze({run:({mouseHighlight:e})=>{if(r())return;d||(d=new MutationObserver((e=>{if(o)for(const t of e){let e=[];switch(t.type){case"characterData":e=u.handleText(t.target);break;case"childList":g(t.target),e=u.handleChildList(t.target);break;case"attributes":g(t.target),e=u.handleAttributes(t.target)}c(e),l.refreshAll()}})));const n=t.targetElement||document.body;o=!0,l.run(e),g(n),c(u.handleChildList(n)),d.observe(t.targetElement||document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0})},stop:()=>{o=!1,l.stop(),d.disconnect()},wrap:e.wrap,unwrap:e.unwrap,forEachElement:l.forEachElement,highlight:(e,t)=>{const n=l.findAll(e,t);return n.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){n.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}}})};function H(){}function J(){}H.prototype.encode=function(e){const t=[],n=e.length;let a=0;for(;a<n;){const n=e.codePointAt(a);let o=0,r=0;for(n<=127?(o=0,r=0):n<=2047?(o=6,r=192):n<=65535?(o=12,r=224):n<=2097151&&(o=18,r=240),t.push(r|n>>o),o-=6;o>=0;)t.push(128|n>>o&63),o-=6;a+=n>=65536?2:1}return t},J.prototype.decode=function(e){let t="",n=0;for(;n<e.length;){let a=e[n],o=0,r=0;if(a<=127?(o=0,r=255&a):a<=223?(o=1,r=31&a):a<=239?(o=2,r=15&a):a<=244&&(o=3,r=7&a),e.length-n-o>0){let t=0;for(;t<o;)a=e[n+t+1],r=r<<6|63&a,t+=1}else r=65533,o=e.length-n;t+=String.fromCodePoint(r),n+=o+1}return t};const q="undefined"==typeof TextEncoder?H:TextEncoder,Z="undefined"==typeof TextDecoder?J:TextDecoder,Q=["",""],ee=RegExp(`([${Q.join("")}]{9})+`,"gu"),te=e=>{const t=(e=>Array.from((new q).encode(e)))(e).map(Number),n=t.map((e=>(e=>{const t=8-e.length;return"0".repeat(t)+e})(e.toString(2))+"0")).join("");return Array.from(n).map((e=>Q[Number(e)])).join("")},ne=e=>{const t=Array.from(e).map((e=>Q.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 Z).decode(new Uint8Array(a));var a},ae=()=>{const e=(()=>{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]})})(),t=e=>JSON.parse(e);return Object.freeze({unwrap:n=>{const a=[],o=(e=>{var t;const n=null===(t=e.match(ee))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(ne))||[]})(n);o.forEach((n=>{const[o]=(e=>{const t=[];for(const n of e)t.push(n.codePointAt(0));return t})(n),r=e.numberToValue(o),{k:i,d:s,n:u}=t(r);a.push({key:i,defaultValue:s,ns:u})}));const r=(e=>e.replace(ee,""))(n);return{text:r,keys:a}},wrap:({key:t,defaultValue:n,translation:a,ns:o})=>{const r=(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||"",u=te(String.fromCodePoint(i));return"string"==typeof s?s+u:s},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${Q[0]}${Q[0]}') or contains(., '${Q[1]}${Q[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${Q[0]}${Q[0]}') or contains(., '${Q[1]}${Q[0]}')]`})};function oe(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}const re=({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}}const o=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=e=>"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 u=void 0!==o?`,${r(o)}`:"",l="string"==typeof i?[i]:i,c=(null==l?void 0:l.length)?`|${l.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${c}${u}${s}${t}`},unwrap:n=>{const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,u=!1,l=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(l,d-l),l=d+t.length,"\\"===e){if(!oe(d,n)){c+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),u=!0,c+=e+p.translated}return c+=n.substring(l),u?{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}')]`})};function ie(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function se(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|ie(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 ue(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=se(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}function le({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((()=>{}))})()}}let ce=null;function ge(e){var t;return ce||(ce=(t=`https://cdn.jsdelivr.net/npm/@tolgee/web@${e||"rc"}/dist/tolgee-in-context-tools.umd.min.js`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window["@tolgee/in-context-tools"].InContextTools))),ce}const de="__tolgee_apiKey",fe="__tolgee_apiUrl";function pe(){const e=sessionStorage.getItem(de)||void 0,t=sessionStorage.getItem(fe)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function ve(){sessionStorage.removeItem(de),sessionStorage.removeItem(fe)}e.BrowserExtensionPlugin=()=>e=>e,"undefined"!=typeof window&&(e.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=le({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(ve)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return pe()&&(async()=>{const e=await ge("rc");return t=>{const n=pe();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 he="__tolgee_currentLanguage";const me=e=>e.endsWith("/")?e.slice(0,-1):e,be={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${me(n)}/${e}/${t}.json`:`${me(n)}/${t}.json`,getData:e=>e.json(),headers:{Accept:"application/json"}},ye=e=>{const t=Object.assign(Object.assign(Object.assign({},be),e),{headers:Object.assign(Object.assign({},be.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(ye(e)),t),e.DEVTOOLS_ID=t,e.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o}){var r;const i=null!==(r=ue(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})=>$(e,t)}),e),e.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){i("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:()=>(i("LanguageStorage"),localStorage.getItem(he)||void 0),setLanguage(e){i("LanguageStorage"),localStorage.setItem(he,e)}}),e),e.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((({translate:e,onClick:t,options:n})=>{const a=re({inputPrefix:n.inputPrefix,inputSuffix:n.inputSuffix,translate:e}),{wrap:o,unwrap:r,stop:i,forEachElement:s,highlight:u,run:l}=X(a,n,t);return{wrap:o,unwrap:r,stop:i,run:l,retranslate:()=>{s(((e,t)=>{for(const[e,n]of t.nodes.entries()){if(n.keyAttributeOnly)return;const t=a.unwrap(n.oldTextContent);t&&M(e,t.text)}}))},highlight:u,outputNotFormattable:!0}})):t.setObserver((({onClick:e,options:t})=>{const n=ae(),a=X(n,t,e);return Object.assign(Object.assign({},a),{retranslate:()=>{},outputNotFormattable:!1})})),e),e.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",e.TOLGEE_ATTRIBUTE_NAME=o,e.TOLGEE_RESTRICT_ATTRIBUTE=a,e.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=n,e.Tolgee=()=>S().use(e.BrowserExtensionPlugin()),e.TolgeeCore=S,e.getFallback=g,e.getFallbackArray=d,e.getProjectIdFromApiKey=ue,e.getTranslateProps=x,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";const t="__tolgee_dev_tools",n="data-tolgee-key-only",a="data-tolgee-restricted",o="_tolgee",r="_tolgee-highlighter";function i(){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 s(e){if(i())throw new Error(`${e}: Can't run on the server`)}function u(e,t){return{oldTextContent:e,keys:t}}function l(e){return Boolean(e&&"function"==typeof e.then)}const c=(e,t)=>l(e)?Promise.resolve(e).then(t):t(e),g=e=>`Tolgee: You need to specify '${e}' option`;function d(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function f(e){return d(e)||[]}function p(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?f(t):f(null==t?void 0:t[e]);var n}function v(e){return Array.from(new Set(e))}function h(e){return e?e.replace(/\/+$/,""):e}const m=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})))}})},b=(e,t,n)=>{const a=new Set,o=new Set;let r=[];const i=()=>{if(0===r.length)return;const e=r;r=[],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)))}));(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({listenSome:e=>{const t={fn:t=>{e(t)},namespaces:new Set};o.add(t);const a={unsubscribe:()=>{o.delete(t)},subscribeNs:e=>(f(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a},listen:e=>{a.add(e);return{unsubscribe:()=>{a.delete(e)}}},emit:(t,n)=>{e()&&(r.push(t),n?setTimeout(i,0):i())}})},y=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):y(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},E=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},w=({language:e,namespace:t})=>t?`${e}:${t}`:e,L=(e,t,n,a,o,r,i)=>{const s=new Map,u=new Map;let l={},c=0;function g(t,n,a){const o=w(t);u.set(o,{data:y(n),version:a}),e.emit(t)}function d(e,t){g(e,t,c)}function p(e,t=!1){const n=u.get(w(e));return n&&t?n.version===c:Boolean(n)}function h(e){var t;return null===(t=u.get(w(a(e))))||void 0===t?void 0:t.data}function m(e){let n;if(!n){const t=l[w(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}return Object.freeze({addStaticData:function(e){e&&(l=Object.assign(Object.assign({},l),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=E(e),a=u.get(e);a&&0!==a.version||g(n,t,0)}})))},invalidate:function(){s.clear(),c+=1},addRecord:d,exists:p,getRecord:h,getTranslation:function(e,t){var n;return null===(n=u.get(w(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs:function(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(w({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return v(e)},getTranslationFallback:function(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(w({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation:function(t,n,a){var o;const r=null===(o=u.get(w(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching:function(e){if(o())return!0;if(void 0===e)return s.size>0;const t=f(e);return Boolean(Array.from(s.keys()).find((e=>t.includes(E(e).namespace))))},isLoading:function(e,t){const n=f(t);return Boolean(o()||Array.from(s.keys()).find((t=>{const a=E(t);return(!n.length||n.includes(a.namespace))&&!p({namespace:a.namespace,language:e})})))},loadRecords:async function(e,t){const o=e.map((e=>{const o=a(e),r=w(o),i=s.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const u=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 s.set(r,u),{new:!0,promise:u,keyObject:o,cacheKey:r}}));r.notify(),i.notify();const u=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=s.get(e.cacheKey)!==e.promise;if(e.new&&!n){s.delete(e.cacheKey);const n=u[t];n?d(e.keyObject,n):h(e.keyObject)||d(e.keyObject,{})}})),r.notify(),i.notify(),o.map((e=>h(e.keyObject)))},getAllRecords:function(){return Array.from(u.entries()).map((([e,t])=>Object.assign(Object.assign({},E(e)),{data:t.data})))}})};function O(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 k="invalid",A={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:k,apiUrl:"https://app.tolgee.io"},j=(...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},T=(e,t)=>{const n=j(A,null==t?void 0:t.initialOptions,e);return n.apiUrl=h(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}},P=(e,t,n,a,o,r)=>{const i={ui:void 0,observer:void 0},s={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 r=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,ns:a({key:e,ns:t}),translation:o({key:e,ns:t})})));null===(n=s.ui)||void 0===n||n.handleElementClick(r,t)},g=(e,t)=>{var n,a;return(null===(a=null===(n=s.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},d=e=>{const t=o({key:e.key,ns:e.ns});return j(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))},f=e=>{i.observer=e},p=()=>Boolean(i.observer),v=e=>{e&&s.formatters.push(e)},h=e=>{s.finalFormatter=e},m=e=>{i.ui=e},b=()=>Boolean(i.ui),y=e=>{s.languageStorage=e},E=e=>{s.languageDetector=e},w=e=>{e&&s.backends.push(e)},L=e=>{s.devBackend=e},A=()=>s.devBackend;function j(n){var a,{formatEnabled:o}=n,r=O(n,["formatEnabled"]);const{key:i,translation:u,defaultValue:l,noWrap:c,params:g,orEmpty:d,ns:f}=r,p=u||l;let v=p||(d?"":i);const h=e(),m=o||!(null===(a=s.observer)||void 0===a?void 0:a.outputNotFormattable),b=e=>s.observer&&!c?s.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:f}):e;v=b(v);try{if(p&&h&&m)for(const e of s.formatters)v=e.format({translation:v,language:h,params:g});s.finalFormatter&&p&&h&&m&&(v=s.finalFormatter.format({translation:v,language:h,params:g}))}catch(e){console.error(e);const n=("string"==typeof(y=e)?y:"string"==typeof(null==y?void 0:y.message)?y.message:void 0)||k,a=t().onFormatError,o=typeof a;v="string"===o?a:"function"===o?a(n,r):k,v=b(v)}var y;return v}return Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:h,addFormatter:v,setObserver:f,hasObserver:p,setUi:m,hasUi:b,setDevBackend:L,addBackend:w,setLanguageDetector:E,setLanguageStorage:y}))},formatTranslation:j,getDevBackend:A,getBackendRecord:({language:e,namespace:t})=>{for(const n of s.backends){const a=n.getRecord({language:e,namespace:t});if(l(a))return null==a?void 0:a.catch((e=>(console.error(e),{})));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:n})=>{var a;const{apiKey:o,apiUrl:r,projectId:i}=t();return null===(a=s.devBackend)||void 0===a?void 0:a.getRecord({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:n})},getLanguageDetector:()=>s.languageDetector,getLanguageStorage:()=>s.languageStorage,getInitialLanguage:()=>{var e;const t=n(),a=null===(e=s.languageStorage)||void 0===e?void 0:e.getLanguage();return c(a,(e=>t&&!t.includes(e)||!e?(()=>{if(!s.languageDetector)return;const e=n();return s.languageDetector.getLanguage({availableLanguages:e})})():e))},setStoredLanguage:e=>{var t;null===(t=s.languageStorage)||void 0===t||t.setLanguage(e)},run:()=>{var e,n,a;if(!s.ui){const{apiKey:n,apiUrl:a,projectId:o}=t();s.ui=null===(e=i.ui)||void 0===e?void 0:e.call(i,{apiKey:n,apiUrl:a,projectId:o,highlight:g,changeTranslation:r})}s.observer||(s.observer=null===(n=i.observer)||void 0===n?void 0:n.call(i,{translate:d,onClick:u,options:t().observerOptions})),null===(a=s.observer)||void 0===a||a.run({mouseHighlight:!0})},stop:()=>{var e;s.ui=void 0,null===(e=s.observer)||void 0===e||e.stop()},retranslate:()=>{var e;null===(e=s.observer)||void 0===e||e.retranslate()},highlight:g,unwrap:e=>{var t;return s.observer?null===(t=s.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap:e=>{var t;return s.observer?null===(t=s.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:function(){return Boolean(A())}})},x=(e,t,n)=>{let a=e;return Object.freeze({init:function(e){a=e},notify:function(){const e=t();a!==e&&n(e),a=e}})};const N=(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}=e,r=O(e,["ns","noWrap","orEmpty","params"]);const i={ns:t,noWrap:n,orEmpty:a};return Object.assign(Object.assign({},i),{params:Object.assign({},r)})}(n)),a)),a},S=({options:e})=>{const t=((e,t)=>{let n=!0;function a(){return n}const o=m(a),r=m(a),i=m(a),s=m(a),u=m(a),l=m(a),c=m(a),g=b(a,e,t);return u.listen((()=>g.emit())),r.listen((()=>g.emit())),c.listen((({value:e})=>{g.emit([e.namespace],!0)})),Object.freeze({onPendingLanguageChange:o,onLanguageChange:r,onLoadingChange:i,onFetchingChange:s,onInitialLoaded:u,onRunningChange:l,onCacheChange:c,onUpdate:g,setEmmiterActive:function(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.listen(t);case"language":return r.listen(t);case"loading":return i.listen(t);case"fetching":return s.listen(t);case"initialLoad":return u.listen(t);case"running":return l.listen(t);case"cache":return c.listen(t);case"update":return g.listen(t)}}})})(s,u),n=x(!1,(()=>i.isFetching()),t.onFetchingChange.emit),a=x(!1,(()=>k()),t.onLoadingChange.emit),o=((e,t,n)=>{let a,o=T();function r(){return o.language||o.initialOptions.language}function i(){return Object.assign(Object.assign({},o.initialOptions),a)}return Object.freeze({init:function(e){o=T(e,o)},isRunning:function(){return o.isRunning},setRunning:function(e){o.isRunning!==e&&(o.isRunning=e,n.emit(e))},isInitialLoading:function(){return o.isInitialLoading},setInitialLoading:function(e){o.isInitialLoading=e},getLanguage:r,setLanguage:function(t){o.language!==t&&(o.language=t,e.emit(t))},getPendingLanguage:function(){return o.pendingLanguage||r()},setPendingLanguage:function(e){o.pendingLanguage!==e&&(o.pendingLanguage=e,t.emit(e))},getInitialOptions:i,addActiveNs:function(e){f(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t?o.activeNamespaces.set(e,t+1):o.activeNamespaces.set(e,1)}))},removeActiveNs:function(e){f(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:function(){return v([...o.initialOptions.ns||[o.initialOptions.defaultNs],...f(o.initialOptions.fallbackNs),...o.activeNamespaces.keys()])},getFallbackLangs:function(e){const t=e||r();return t?v([t,...p(t,o.initialOptions.fallbackLanguage)]):[]},getFallbackNs:function(){return f(o.initialOptions.fallbackNs)},getDefaultNs:function(e){return void 0===e?o.initialOptions.defaultNs:e},getAvailableLanguages:function(){if(o.initialOptions.availableLanguages)return o.initialOptions.availableLanguages;if(o.initialOptions.staticData){const e=Object.keys(o.initialOptions.staticData).map((e=>E(e).language));return Array.from(new Set(e))}},withDefaultNs:function(e){return{namespace:void 0===e.namespace?i().defaultNs:e.namespace,language:e.language}},overrideCredentials:function(e){a=e?Object.assign(Object.assign({},e),{apiUrl:h(e.apiUrl)}):void 0}})})(t.onLanguageChange,t.onPendingLanguageChange,t.onRunningChange),r=P(o.getLanguage,o.getInitialOptions,o.getAvailableLanguages,(function({key:e,ns:t}){const n=o.getFallbackLangs(),a=d(t||void 0);return i.getTranslationNs(a,n,e)}),S,w),i=L(t.onCacheChange,r.getBackendRecord,r.getBackendDevRecord,o.withDefaultNs,o.isInitialLoading,n,a);function s(){return o.getFallbackNs()}function u(e){return o.getDefaultNs(e)}function d(e){return[...f(u(e)),...s()]}function y(e){return[...f(e||u()),...o.getRequiredNamespaces()]}function w(e,t,n){const a=o.withDefaultNs(e),r=i.getTranslation(a,t);return i.changeTranslation(a,t,n),{revert:()=>{i.changeTranslation(a,t,r)}}}function O(e){o.init(e),i.addStaticData(o.getInitialOptions().staticData)}function k(e){return i.isLoading(o.getLanguage(),e)}function A(){return Boolean(o.getInitialOptions().apiKey&&o.getInitialOptions().apiUrl)}function j(e,t){const n=function(e,t){const n=o.getFallbackLangs(e),a=y(t),r=[];return n.forEach((e=>{a.forEach((t=>{i.exists({language:e,namespace:t},!0)||r.push({language:e,namespace:t})}))})),r}(e,t);if(n.length)return c(D(n),(()=>{}))}function S({key:e,ns:t}){const n=d(t||void 0),a=o.getFallbackLangs();return i.getTranslationFallback(n,a,e)}function R(){const e=c(function(){if(o.getLanguage())return;if(!o.getInitialOptions().defaultLanguage)throw new Error(g("defaultLanguage"));const e=r.getInitialLanguage();return c(e,(e=>{const t=e||o.getInitialOptions().defaultLanguage;t&&o.setLanguage(t)}))}(),(()=>j()));if(l(e))return o.setInitialLoading(!0),n.notify(),a.notify(),Promise.resolve(e).then((()=>{o.setInitialLoading(!1),n.notify(),a.notify(),t.onInitialLoaded.emit()}));t.onInitialLoaded.emit()}function D(e){return i.loadRecords(e,A())}e&&O(e),t.onUpdate.listen((()=>{o.isRunning()&&r.retranslate()}));const $=()=>{const e=r.getLanguageDetector()||r.getLanguageStorage();if(e){if(!o.getAvailableLanguages())throw new Error(g("availableLanguages"))}if(!o.getLanguage()&&!o.getInitialOptions().defaultLanguage)throw e?new Error(g("defaultLanguage")):new Error(g("language"))};return Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),o),r),i),{init:O,changeLanguage:async function(e){o.getPendingLanguage()===e&&o.getLanguage()===e||(o.setPendingLanguage(e),o.isRunning()&&await j(e),e===o.getPendingLanguage()&&(o.setLanguage(e),r.setStoredLanguage(e)))},getTranslation:S,changeTranslation:w,addActiveNs:async function(e,t){t||o.addActiveNs(e),o.isRunning()&&await j(void 0,e)},loadRecords:D,loadRecord:async function(e){return(await D([e]))[0]},isLoading:k,isLoaded:function(e){const t=o.getLanguage();if(!t)return!1;const n=o.getFallbackLangs(t),a=y(e),r=[];return n.forEach((e=>{a.forEach((t=>{i.exists({language:e,namespace:t})||r.push({language:e,namespace:t})}))})),0===r.length},t:(...e)=>{const t=N(...e),n=S(t);return r.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:A,run:function(){let e;return $(),o.isRunning()||(A()&&i.invalidate(),o.setRunning(!0),r.run(),e=R()),Promise.resolve(e)},stop:function(){o.isRunning()&&(r.stop(),o.setRunning(!1))}}))},R=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=j(e.options,n),t),init(t){const n=(e=>{const t=S({options:e}),n=e=>{const n=t.isRunning();n&&t.stop(),e(),n&&t.run()},a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmmiterActive:t.setEmmiterActive,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})(j(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},D=0,$=1,C=2;class I extends Error{constructor(e,t,n){let a;a=e===D?"Empty parameter":e===$?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function _(e){return/\s/.test(e)}const U=0,F=1,B=2,M=3,V=4,K=new Set([B,F,U]),z="'",Y=new Set(["{","}",z]),G=e=>/[0-9a-zA-Z_]/.test(e);function W(e,t){const[n,a]=function(e){let t=U,n="",a="",o="";const r=[],i=[];let s=0;function u(t){throw new I(t,s,e)}const l=()=>{r.push(n),n=""},c=()=>{""===a&&u(D),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case U:o===z?(n+=o,t=F):"{"===o?(l(),t=M):(n+=o,t=U);break;case F:Y.has(o)?(n=n.slice(0,-1)+o,t=B):(n+=o,t=U);break;case B:o===z?t=U:(n+=o,t=B);break;case M:"}"===o?(c(),t=U):_(o)?""!==a&&(c(),t=V):(G(o)||u($),a+=o,t=M);break;case V:"}"==o?t=U:_(o)?t=V:u($)}return K.has(t)||u(C),l(),[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 X={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"},H=({highlightColor:e,highlightWidth:t})=>Object.freeze({initHighlighter:function(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(r),Object.entries(X).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const i=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=i.top-t+"px",o.style.left=i.left-t+"px",o.style.width=i.width+"px",o.style.height=i.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null===(e=t.highlightEl)||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}const 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},te={capture:!0},ne={capture:!0,passive:!0},ae=({highlightKeys:e,elementStore:n,onClick:a})=>{let o,r,i=new Set;const s=e=>{var t;if(o!==e){u();const a=n.get(e);a&&(a.preventClean=!0,null===(t=a.highlight)||void 0===t||t.call(a),o=e)}},u=()=>{var e;const t=n.get(o);t&&(t.preventClean=!1,null===(e=t.unhighlight)||void 0===e||e.call(t),o=void 0)};function l(){const e=r;let t;if(e&&y()){const n=document.elementFromPoint(e.x,e.y);n&&(t=m(n))}s(t)}const c=e=>{var n;y()&&(n=e.target,!Boolean(b(n,(e=>e.id===t))))&&(e.stopPropagation(),e.preventDefault())},g=e=>{var t;t={x:e.clientX,y:e.clientY},r=t,l()},d=()=>{i=new Set,l()},f=e=>{const t=e.key;void 0!==t&&i.add(t),l()},p=e=>{i.delete(e.key),l()},v=()=>{var e;const t=n.get(o);null===(e=null==t?void 0:t.highlight)||void 0===e||e.call(t)},h=e=>{if(c(e),y()){const t=m(e.target);t&&t===o&&(a(e,t),u())}};function m(e){return b(e,(e=>n.get(e)))}function b(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?b(e.parentElement,t):void 0}function y(){for(const t of e)if(!i.has(t))return!1;return!0}return Object.freeze({run:function(){window.addEventListener("blur",d,te),window.addEventListener("keydown",f,te),window.addEventListener("keyup",p,te),window.addEventListener("mousemove",g,ne),window.addEventListener("scroll",v,ne),window.addEventListener("click",h,te),window.addEventListener("mouseenter",c,te),window.addEventListener("mouseover",c,te),window.addEventListener("mouseout",c,te),window.addEventListener("mouseleave",c,te),window.addEventListener("mousedown",c,te),window.addEventListener("mouseup",c,te)},stop:function(){window.removeEventListener("blur",d,te),window.removeEventListener("keydown",f,te),window.removeEventListener("keyup",p,te),window.removeEventListener("mousemove",g,ne),window.removeEventListener("scroll",v,ne),window.removeEventListener("click",h,te),window.removeEventListener("mouseenter",c,te),window.removeEventListener("mouseover",c,te),window.removeEventListener("mouseout",c,te),window.removeEventListener("mouseleave",c,te),window.removeEventListener("mousedown",c,te),window.removeEventListener("mouseup",c,te)}})},oe=(e,t)=>{const n=(()=>{const e=new Map;return Object.freeze({set:function(t,n){e.set(t,n)},get:function(t){return t&&e.get(t)},remove:function(t){return e.delete(t)},forEachElement:function(t){e.forEach(((e,n)=>t(n,e)))}})})(),r=H({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),i=ae({highlightKeys:e.highlightKeys,elementStore:n,onClick:(e,a)=>{const o=n.get(a);t({event:e,keysAndDefaults:u(o)})}});function s(){return e.targetElement||document.body}function u(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:function(t,i,s){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${a}]`)}(t))return;const u=t;let l=n.get(u);l||(l={nodes:new Map},n.set(u,l),u.setAttribute(o,"true")),l.nodes.set(i,s),r.initHighlighter(u,l)},forEachElement:n.forEachElement,findAll:function(e,t){const a=[];return n.forEachElement(((n,o)=>{for(const n of o.nodes.values()){if(n.keys.find((n=>ee({key:e,ns:d(t)},{key:n.key,ns:d(n.ns)})))){a.push(o);break}}})),a},refreshAll:function(){n.forEachElement(((e,t)=>{t.preventClean||(function(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())Q(s(),t)&&(yield[t,n])}(e))}(t),0===t.nodes.size&&function(e,t){var a;t.highlightEl&&(null===(a=t.unhighlight)||void 0===a||a.call(t));e.removeAttribute(o),n.remove(e)}(e,t))}))},run:function(e){e&&i.run()},stop:function(){i.stop()}})},re=(e,t,a)=>{let o=!1;const r=(e=>Object.freeze({getSuitableParent:function t(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(a):a}}))(t),s=((e,t)=>{const n=e=>J(t.getTextXPath(),e),a=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};return Object.freeze({handleAttributes:a,handleChildList:e=>{let t=[];return t=t.concat(a(e)),t=t.concat(n(e)),t},handleText:n})})(t,e),l=oe(t,a);function c(t){for(const n of t){const t=q(n),a=t?e.unwrap(t):null;if(a){const{text:e,keys:o}=a;Z(n,e);const i=u(t,o),s=r.getSuitableParent(n);l.register(s,n,i)}}}const g=e=>{J(`./descendant-or-self::*[@${n}]`,e).forEach((e=>{const t=e.getAttributeNode(n),a=r.getSuitableParent(t);l.register(a,t,{oldTextContent:"",keys:[{key:q(t)}],keyAttributeOnly:!0})}))};let d;return Object.freeze({run:({mouseHighlight:e})=>{if(i())return;d||(d=new MutationObserver((e=>{if(o)for(const t of e){let e=[];switch(t.type){case"characterData":e=s.handleText(t.target);break;case"childList":g(t.target),e=s.handleChildList(t.target);break;case"attributes":g(t.target),e=s.handleAttributes(t.target)}c(e),l.refreshAll()}})));const n=t.targetElement||document.body;o=!0,l.run(e),g(n),c(s.handleChildList(n)),d.observe(t.targetElement||document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0})},stop:()=>{o=!1,l.stop(),d.disconnect()},wrap:e.wrap,unwrap:e.unwrap,forEachElement:l.forEachElement,highlight:(e,t)=>{const n=l.findAll(e,t);return n.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){n.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}}})};function ie(){}function se(){}ie.prototype.encode=function(e){const t=[],n=e.length;let a=0;for(;a<n;){const n=e.codePointAt(a);let o=0,r=0;for(n<=127?(o=0,r=0):n<=2047?(o=6,r=192):n<=65535?(o=12,r=224):n<=2097151&&(o=18,r=240),t.push(r|n>>o),o-=6;o>=0;)t.push(128|n>>o&63),o-=6;a+=n>=65536?2:1}return t},se.prototype.decode=function(e){let t="",n=0;for(;n<e.length;){let a=e[n],o=0,r=0;if(a<=127?(o=0,r=255&a):a<=223?(o=1,r=31&a):a<=239?(o=2,r=15&a):a<=244&&(o=3,r=7&a),e.length-n-o>0){let t=0;for(;t<o;)a=e[n+t+1],r=r<<6|63&a,t+=1}else r=65533,o=e.length-n;t+=String.fromCodePoint(r),n+=o+1}return t};const ue="undefined"==typeof TextEncoder?ie:TextEncoder,le="undefined"==typeof TextDecoder?se:TextDecoder,ce=["",""],ge=RegExp(`([${ce.join("")}]{9})+`,"gu"),de=e=>{const t=(e=>Array.from((new ue).encode(e)))(e).map(Number),n=t.map((e=>(e=>{const t=8-e.length;return"0".repeat(t)+e})(e.toString(2))+"0")).join("");return Array.from(n).map((e=>ce[Number(e)])).join("")},fe=e=>{const t=Array.from(e).map((e=>ce.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 le).decode(new Uint8Array(a));var a},pe=()=>{const e=(()=>{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]})})(),t=e=>JSON.parse(e);return Object.freeze({unwrap:n=>{const a=[],o=(e=>{var t;const n=null===(t=e.match(ge))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(fe))||[]})(n);o.forEach((n=>{const[o]=(e=>{const t=[];for(const n of e)t.push(n.codePointAt(0));return t})(n),r=e.numberToValue(o),{k:i,d:s,n:u}=t(r);a.push({key:i,defaultValue:s,ns:u})}));const r=(e=>e.replace(ge,""))(n);return{text:r,keys:a}},wrap:({key:t,defaultValue:n,translation:a,ns:o})=>{const r=(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||"",u=de(String.fromCodePoint(i));return"string"==typeof s?s+u:s},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${ce[0]}${ce[0]}') or contains(., '${ce[1]}${ce[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${ce[0]}${ce[0]}') or contains(., '${ce[1]}${ce[0]}')]`})};function ve(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}const he=({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}}const o=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=e=>"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 u=void 0!==o?`,${r(o)}`:"",l="string"==typeof i?[i]:i,c=(null==l?void 0:l.length)?`|${l.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${c}${u}${s}${t}`},unwrap:n=>{const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,u=!1,l=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(l,d-l),l=d+t.length,"\\"===e){if(!ve(d,n)){c+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),u=!0,c+=e+p.translated}return c+=n.substring(l),u?{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}')]`})},me="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function be(e){const t=me.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function ye(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|be(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 Ee(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=ye(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}function we({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",ke="InContextTools",Ae="https://cdn.jsdelivr.net/npm";let je=null;function Te(e){var t;return je||(je=(t=`${Ae}/@tolgee/web@${e||"rc"}/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][ke]))),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 Se(){sessionStorage.removeItem(Pe),sessionStorage.removeItem(xe)}e.BrowserExtensionPlugin=()=>e=>e,"undefined"!=typeof window&&(e.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=we({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(Se)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Ne()&&(async()=>{const e=await Te("rc");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 Re="__tolgee_currentLanguage";const De=e=>e.endsWith("/")?e.slice(0,-1):e,$e={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${De(n)}/${e}/${t}.json`:`${De(n)}/${t}.json`,getData:e=>e.json(),headers:{Accept:"application/json"}},Ce=e=>{const t=Object.assign(Object.assign(Object.assign({},$e),e),{headers:Object.assign(Object.assign({},$e.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(Ce(e)),t),e.DEVTOOLS_ID=t,e.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o}){var r;const i=null!==(r=Ee(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})=>W(e,t)}),e),e.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){s("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:()=>(s("LanguageStorage"),localStorage.getItem(Re)||void 0),setLanguage(e){s("LanguageStorage"),localStorage.setItem(Re,e)}}),e),e.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((({translate:e,onClick:t,options:n})=>{const a=he({inputPrefix:n.inputPrefix,inputSuffix:n.inputSuffix,translate:e}),{wrap:o,unwrap:r,stop:i,forEachElement:s,highlight:u,run:l}=re(a,n,t);return{wrap:o,unwrap:r,stop:i,run:l,retranslate:()=>{s(((e,t)=>{for(const[e,n]of t.nodes.entries()){if(n.keyAttributeOnly)return;const t=a.unwrap(n.oldTextContent);t&&Z(e,t.text)}}))},highlight:u,outputNotFormattable:!0}})):t.setObserver((({onClick:e,options:t})=>{const n=pe(),a=re(n,t,e);return Object.assign(Object.assign({},a),{retranslate:()=>{},outputNotFormattable:!1})})),e),e.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",e.TOLGEE_ATTRIBUTE_NAME=o,e.TOLGEE_RESTRICT_ATTRIBUTE=a,e.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=n,e.Tolgee=()=>R().use(e.BrowserExtensionPlugin()),e.TolgeeCore=R,e.getFallback=d,e.getFallbackArray=f,e.getProjectIdFromApiKey=Ee,e.getTranslateProps=N,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=tolgee-web.production.umd.min.js.map |
{ | ||
"name": "@tolgee/web", | ||
"version": "5.3.1", | ||
"version": "5.3.2-rc.7c739ee7.0", | ||
"description": "Tolgee for web", | ||
@@ -51,3 +51,3 @@ "declaration": true, | ||
"dependencies": { | ||
"@tolgee/core": "5.3.0" | ||
"@tolgee/core": "5.3.2-rc.7c739ee7.0" | ||
}, | ||
@@ -106,3 +106,3 @@ "devDependencies": { | ||
"homepage": "https://github.com/tolgee/tolgee-js#readme", | ||
"gitHead": "9effde66ac551642a3bbdb5148e0469d50c9a90a", | ||
"gitHead": "ca49f7454043f0a77e04c8401857ca812538e0a4", | ||
"publishConfig": { | ||
@@ -109,0 +109,0 @@ "access": "public" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
51677674
250916
1
+ Added@tolgee/core@5.3.2-rc.7c739ee7.0(transitive)
- Removed@tolgee/core@5.3.0(transitive)