var cx_libtranslate=(()=>{var l=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var c=l(q=>{var p=class{#e;#t;constructor(e,t=!0){if(typeof e!="string")throw new TypeError("Translated content must be string.");if(typeof t!="boolean")throw new TypeError("Result of translation must be boolean.");this.#e=e,this.#t=t,Object.freeze(this)}toString(){return this.#e}get text(){return this.#e}get valid(){return this.translated}format(e){if(typeof e!="object")throw new TypeError("Content to format from must be object.");return this.#t?this.#r(e):this.#e}#r(e){let t=this.#e.split("#{"),r=t[0];for(let s=1;s{var f=c().translation,g=class o{#e;#t;constructor(e,t=null){if(!(e instanceof Map))throw new TypeError("Phrases must an map.");if(t!==null&&typeof t!="object")throw new TypeError("Objects must be null or object.");this.#e=e,this.#t=t}translate(e){if(typeof e!="string")throw new TypeError("Phrase to translate must be an string.");return this.#r(e)?this.#o(e):this.#s(e)}get(e){return this.translate(e)}#r(e){return e.indexOf(".")!==-1}#o(e){if(this.#t===null)return this.#s(e);let t=e.trim().split("."),r=this.#t;for(let s in t){let n=t[s];if(!(n in r))return new f(e,!1);r=r[n]}return typeof r!="string"?new f(e,!1):new f(r,!0)}#s(e){let t=o.prepare(e),r=this.#e.has(t),s=r?this.#e.get(t):e;return new f(s,r)}static prepare(e){if(typeof e!="string")throw new TypeError("Content to prepare must be an string.");return e.trim().replaceAll(" ","_").replaceAll(".","_").toLowerCase()}};j.phrasebook=g});var h=l(k=>{var w=u().phrasebook,d=class{#e;#t;constructor(e,t=!1){if(typeof e!="string")throw new TypeError("Path of the file must be string.");if(typeof t!="boolean")throw new TypeError("Local must be bool variable.");this.#e=e,this.#t=t}async#r(){let t=await(await fetch(this.#e)).json();return this.#s(t)}async#o(){let e=null;if(e===null)throw new Error("Could not use ndoe:fs in browser.");let t=await e.readFile(this.#e,{encoding:"utf8"}),r=JSON.parse(t);return this.#s(r)}load(){return this.#t?this.#o():this.#r()}#s(e){let t="objects"in e&&typeof e.objects=="object",r="phrases"in e&&typeof e.phrases=="object";if(t||r){let n=r?e.phrases:{},a=t?e.objects:{};return new w(this.#n(n),a)}return new w(this.#n(e))}#n(e){let t=new Map;return Object.keys(e).forEach(r=>{let s=w.prepare(r),n=e[r];t.set(s,n)}),t}};k.loader=d});var y=l(T=>{var _=h().loader,x=u().phrasebook,b=class o{#e;#t;#r;constructor(e,t=!1){if(typeof e!="string")throw new TypeError("Path to the phrasebooks must be string.");if(typeof t!="boolean")throw new TypeError("Local must be bool variable.");this.#r=t,this.#e=e,this.#t=new Map}add(e,t){if(typeof e!="string")throw new TypeError("Name of the language must be sting.");if(typeof t!="string")throw new TypeError("File on in the directory must be string.");return this.#t.has(e)?(console.error('Language "'+e+'" already loaded.'),console.error("It could not being loaded twice."),this):this.#n(e)?(this.#t.set(e,t),this):(console.error('Language name "'+e+'" invalid formated.'),console.error("It could not being loaded."),this)}async load(e){if(typeof e!="string")throw new TypeError("Name of index file is not string.");let t=await this.#o(e),r=new o(this.#e,this.#r);return Object.keys(t).forEach(s=>{if(typeof s!="string"){console.error("Name of the language must be string."),console.error("Check languages index."),console.error("Skipping it.");return}if(typeof t[s]!="string"){console.error("Name of phrasebook file must be string."),console.error("Check languages index."),console.error("Skipping it.");return}r.add(s,t[s])}),r}async#o(e){let t=this.#s(e);if(this.#r){let s=null;if(s===null)throw new Error("Could not use ndoe:fs in browser.");return JSON.parse(await s.readFile(t,{encoding:"utf-8"}))}return await(await fetch(t)).json()}has(e){return this.#t.has(e)}get avairable(){let e=new Array;return this.#t.keys().forEach(t=>{e.push(t)}),e}select(e){if(typeof e!="string")throw new TypeError("Name of the language must be string.");if(!this.has(e))return new x(new Map);let t=this.#t.get(e),r=this.#s(t);return new _(r,this.#r).load()}#s(e){let t="/";return this.#e[this.#e.length-1]===t&&(t=""),this.#e+t+e}#n(e){let t=e.split("_");if(t.length!==2)return!1;let r=t[0],s=t[1];return!(r.toLowerCase()!==r||r.length!==2||s.toUpperCase()!==s||s.length!==2)}};T.languages=b});var C=l((M,i)=>{typeof i<"u"&&i.exports?(i.exports.phrasebook=u().phrasebook,i.exports.loader=h().loader,i.exports.languages=y().languages,i.exports.loader=h().loader):window.cx_libtranslate={phrasebook:u().phrasebook,loader:h().loader,languages:y().languages,translation:c().translation}});return C();})(); //# sourceMappingURL=cx-libtranslate.min.js.map