@internetarchive/bookreader 5.0.0-110 → 5.0.0-111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BookReader/BookReader.css +59 -0
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +74 -77
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +1 -1
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.experiments.js +1 -1
- package/BookReader/plugins/plugin.experiments.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +23 -1
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.translate.js +25 -3
- package/BookReader/plugins/plugin.translate.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +2 -1
- package/BookReader/plugins/plugin.url.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/package.json +2 -1
- package/src/BookReader/Mode2UpLit.js +1 -3
- package/src/BookReader/utils/SelectionObserver.js +9 -1
- package/src/BookReader.js +17 -2
- package/src/css/_TextSelection.scss +59 -0
- package/src/plugins/plugin.chapters.js +8 -3
- package/src/plugins/plugin.experiments.js +21 -3
- package/src/plugins/plugin.text_selection.js +17 -0
- package/src/plugins/url/UrlPlugin.js +23 -3
- package/src/plugins/url/plugin.url.js +63 -7
- package/src/util/TextSelectionManager.js +252 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! For license information please see plugin.translate.js.LICENSE.txt */
|
|
2
|
-
"use strict";(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[444],{8248:function(e,t,n){var r,
|
|
2
|
+
"use strict";(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[444],{8248:function(e,t,n){var r,o=n(5215),i=n(420),a=n(9696);!function(e){e.processing="processing",e.complete="complete"}(r||(r={}));let s=class extends i.WF{constructor(){super(...arguments),this.mode="processing"}render(){return i.qy`
|
|
3
3
|
<div class="${this.mode}">
|
|
4
4
|
<svg
|
|
5
5
|
viewBox="0 0 120 120"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
</g>
|
|
49
49
|
</svg>
|
|
50
50
|
</div>
|
|
51
|
-
`}static get styles(){const e=
|
|
51
|
+
`}static get styles(){const e=i.AH`var(--activityIndicatorCheckmarkColor, #31A481)`,t=i.AH`var(--activityIndicatorCompletedRingColor, #31A481)`,n=i.AH`var(--activityIndicatorLoadingRingColor, #333333)`,r=i.AH`var(--activityIndicatorLoadingDotColor, #333333)`;return i.AH`
|
|
52
52
|
#completed-ring {
|
|
53
53
|
fill: ${t};
|
|
54
54
|
}
|
|
@@ -133,5 +133,27 @@
|
|
|
133
133
|
opacity: 0;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
`}};(0,a.Cg)([(0,i.MZ)({type:String})],s.prototype,"mode",void 0),s=(0,a.Cg)([(0,i.EM)("ia-activity-indicator")],s)},5215:function(e,t,n){function r(e,t,n,r){var a,o=arguments.length,i=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(i=(o<3?a(i):o>3?a(t,n,i):a(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i}n.d(t,{Cg:function(){return r}}),Object.create,Object.create},1041:function(e,t,n){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,o(r.key),r)}}function o(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}n.d(t,{S:function(){return i}}),n(2675),n(9463),n(2259),n(5700),n(3792),n(9572),n(8130),n(9085),n(6099),n(7764),n(2953);var i=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.br=t,this.options},(t=[{key:"setup",value:function(e){this.options=Object.assign({},this.options,e)}},{key:"init",value:function(){}},{key:"_configurePageContainer",value:function(e){}},{key:"_configureToolbar",value:function(e){}},{key:"_bindNavigationHandlers",value:function(){}},{key:"extendNavBar",value:function(e){}}])&&a(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}()},6735:function(e,t,n){n(2675),n(9463),n(2259),n(8125),n(4782),n(4554),n(4731),n(479),n(9085),n(2811),n(3851),n(875),n(825),n(888),n(8781),n(5700),n(8706),n(2008),n(113),n(3418),n(3792),n(2062),n(9572),n(2010),n(8130),n(6099),n(8459),n(8940),n(3362),n(7495),n(7764),n(5440),n(3500),n(2953);var r=n(420),a=n(1041),o=n(9696),i=(n(739),n(6034),n(4565));"undefined"!=typeof window&&window.Worker||(globalThis.Worker=class{#e;constructor(e){this.#e=new Promise(async t=>{const{Worker:n}=await import("node:worker_threads");t(new n(e))})}addEventListener(e,t){this.#e.then(n=>n.on(e,e=>t({data:e})))}postMessage(e){this.#e.then(t=>t.postMessage(e))}terminate(){this.#e.then(e=>e.terminate())}});class s extends Error{}class l{constructor(e){this.options=e||{},this.registryUrl=this.options.registryUrl||"https://bergamot.s3.amazonaws.com/models/index.json",this.downloadTimeout="downloadTimeout"in this.options?parseInt(this.options.downloadTimeout):6e4,this.registry=this.loadModelRegistery(),this.buffers=new Map,this.pivotLanguage="pivotLanguage"in this.options?e.pivotLanguage:"en",this.models=new Map,this.onerror=this.options.onerror||(e=>console.error("WASM Translation Worker error:",e))}async loadWorker(){const e=this.options.workerUrl?new Worker(this.options.workerUrl):new Worker(new URL(n.p+n.u(474),n.b));let t=0;const r=new Map,a=(n,...a)=>new Promise((o,i)=>{const s=++t;r.set(s,{accept:o,reject:i,callsite:{message:`${n}(${a.map(e=>String(e)).join(", ")})`,stack:(new Error).stack}}),e.postMessage({id:s,name:n,args:a})});return e.addEventListener("message",function({data:{id:e,result:t,error:n}}){if(!r.has(e))throw console.debug("Received message with unknown id:",arguments[0]),new Error(`BergamotTranslator received response from worker to unknown call '${e}'`);const{accept:a,reject:o,callsite:i}=r.get(e);r.delete(e),void 0!==n?o(Object.assign(new Error,n,{message:n.message+` (response to ${i.message})`,stack:n.stack?`${n.stack}\n${i.stack}`:i.stack})):a(t)}),e.addEventListener("error",this.onerror.bind(this)),await a("initialize",this.options),{worker:e,exports:new Proxy({},{get(e,t,n){if("then"!==t)return(...e)=>a(t,...e)}})}}async loadModelRegistery(){const e=await fetch(this.registryUrl,{credentials:"omit"}),t=await e.json();return Array.from(Object.entries(t),([e,t])=>{const n=e.match(/^([a-z]{2}(-[a-z]+)?)([a-z]{2}(-[a-z]+)?)/i);return{from:n[1],to:n[3],files:t}})}getTranslationModel({from:e,to:t},n){const r=JSON.stringify({from:e,to:t});if(!this.buffers.has(r)){const a=this.loadTranslationModel({from:e,to:t},n);this.buffers.set(r,a),a.catch(e=>this.buffers.delete(r))}return this.buffers.get(r)}async loadTranslationModel({from:e,to:t},n){performance.mark(`loadTranslationModule.${JSON.stringify({from:e,to:t})}`);const r=(await this.registry).filter(n=>n.from==e&&n.to==t);if(!r)throw new Error(`No model for '${e}' -> '${t}'`);const a=r[0].files,o=()=>reject(new s("abort signal")),i=new Promise((e,t)=>{n?.signal&&n.signal.addEventListener("abort",o)}),l=Object.fromEntries(await Promise.race([Promise.all(Object.entries(a).map(async([r,a])=>{if(void 0===a||void 0===a.name)return[r,null];try{return[r,await this.fetch(a.name,a.expectedSha256Hash,n)]}catch(n){throw new Error(`Could not fetch ${a.name} for ${e}->${t} model`,{cause:n})}})),i]));n?.signal&&n.signal.removeEventListener("abort",o),performance.measure("loadTranslationModel",`loadTranslationModule.${JSON.stringify({from:e,to:t})}`);let c=[];if(l.vocab)c=[l.vocab];else{if(!l.trgvocab||!l.srcvocab)throw new Error(`Could not identify vocab files for ${e}->${t} model among: ${Array.from(Object.keys(a)).join(" ")}`);c=[l.srcvocab,l.trgvocab]}let u={};return a.model.name.endsWith("intgemm8.bin")&&(u["gemm-precision"]="int8shiftAll"),a.qualityModel&&(u["skip-cost"]=!1),a.config&&Object.assign(u,a.config),{model:l.model,shortlist:l.lex,vocabs:c,qualityModel:l.qualityModel,config:u}}async fetch(e,t,n){const r=new AbortController,a=()=>r.abort(),o=this.downloadTimeout?setTimeout(a,this.downloadTimeout):null;try{n?.signal&&n.signal.addEventListener("abort",a);const o={credentials:"omit",signal:r.signal};t&&(o.integrity=`sha256-${this.hexToBase64(t)}`),"undefined"==typeof window&&delete o.integrity;const i=await fetch(e,o);return await i.arrayBuffer()}finally{o&&clearTimeout(o),n?.signal&&n.signal.removeEventListener("abort",a)}}hexToBase64(e){return btoa(e.match(/\w{2}/g).map(function(e){return String.fromCharCode(parseInt(e,16))}).join(""))}getModels({from:e,to:t}){const n=JSON.stringify({from:e,to:t});return this.models.has(n)||this.models.set(n,this.findModels(e,t)),this.models.get(n)}async findModels(e,t){const n=await this.registry;let r=[],a=[],o=[];if(n.forEach(n=>{n.from===e&&n.to===t?r.push(n):n.from===e&&n.to===this.pivotLanguage?a.push(n):n.to===t&&n.from===this.pivotLanguage&&o.push(n)}),r.length)return[r[0]];if(a.length&&o.length)return[a[0],o[0]];throw new Error(`No model available to translate from '${e}' to '${t}'`)}}class c{constructor(e,t){t||(t=new l(e)),this.backing=t,this.workers=[],this.workerLimit=Math.max(e?.workers||0,1),this.queue=[],this.batchSerial=0,this.batchSize=Math.max(e?.batchSize||8,1),this.onerror=e?.onerror||(e=>console.error("WASM Translation Worker error:",e))}async delete(){this.remove(()=>!0),this.workers.forEach(({worker:e})=>e.terminate())}notify(){setTimeout(async()=>{if(!this.queue.length)return;let e=this.workers.find(e=>e.idle);if(!e&&this.workers.length<this.workerLimit)try{const t={idle:!1};this.workers.push(t),Object.assign(t,await this.backing.loadWorker()),e=t}catch(e){this.onerror(new Error(`Could not initialise translation worker: ${e.message}`))}if(!e)return;const t=this.queue.shift();e.idle=!1;try{await this.consumeBatch(t,e.exports)}catch(e){t.requests.forEach(({reject:t})=>t(e))}e.idle=!0,this.queue.length&&this.notify()})}translate(e){const{from:t,to:n,priority:r}=e;return new Promise(async(a,o)=>{try{const i=JSON.stringify({from:t,to:n}),s=await this.backing.getModels(e);this.enqueue({key:i,models:s,request:e,resolve:a,reject:o,priority:r}),this.notify()}catch(e){o(e)}})}remove(e){const t=this.queue;this.queue=[],t.forEach(t=>{t.requests.forEach(({request:n,resolve:r,reject:a})=>{e(n)?a(Object.assign(new s("removed by filter"),{request:n})):this.enqueue({key:t.key,priority:t.priority,models:t.models,request:n,resolve:r,reject:a})})})}enqueue({key:e,models:t,request:n,resolve:r,reject:a,priority:o}){void 0===o&&(o=0);let i=this.queue.find(t=>t.key===e&&t.priority===o&&t.requests.length<this.batchSize);i||(i={id:++this.batchSerial,key:e,priority:o,models:t,requests:[]},this.queue.push(i),this.queue.sort((e,t)=>e.priority-t.priority)),i.requests.push({request:n,resolve:r,reject:a})}async consumeBatch(e,t){performance.mark("BergamotBatchTranslator.start"),await Promise.all(e.models.map(async({from:e,to:n})=>{if(!await t.hasTranslationModel({from:e,to:n})){const r=await this.backing.getTranslationModel({from:e,to:n});await t.loadTranslationModel({from:e,to:n},r)}}));const n=await t.translate({models:e.models.map(({from:e,to:t})=>({from:e,to:t})),texts:e.requests.map(({request:{text:e,html:t,qualityScores:n}})=>({text:e.toString(),html:!!t,qualityScores:!!n}))});e.requests.forEach(({request:e,resolve:t,reject:r},a)=>{t({request:e,...n[a]})}),performance.measure("BergamotBatchTranslator","BergamotBatchTranslator.start")}}var u=n(4160);function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function d(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function o(n,r,a,o){var l=r&&r.prototype instanceof s?r:s,c=Object.create(l.prototype);return h(c,"_invoke",function(n,r,a){var o,s,l,c=0,u=a||[],f=!1,d={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,l=e,d.n=n,i}};function h(n,r){for(s=n,l=r,t=0;!f&&c&&!a&&t<u.length;t++){var a,o=u[t],h=d.p,g=o[2];n>3?(a=g===r)&&(l=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((a=n<2&&h<o[1])?(s=0,d.v=r,d.n=o[1]):h<g&&(a=n<3||o[0]>r||r>g)&&(o[4]=n,o[5]=r,d.n=g,s=0))}if(a||n>1)return i;throw f=!0,r}return function(a,u,g){if(c>1)throw TypeError("Generator is already running");for(f&&1===u&&h(u,g),s=u,l=g;(t=s<2?e:l)||!f;){o||(s?s<3?(s>1&&(d.n=-1),h(s,l)):d.n=l:d.v=l);try{if(c=2,o){if(s||(a="next"),t=o[a]){if(!(t=t.call(o,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(l=TypeError("The iterator does not provide a '"+a+"' method"),s=1);o=e}else if((t=(f=d.n<0)?l:n.call(r,d))!==i)break}catch(t){o=e,s=1,l=t}finally{c=1}}return{value:t,done:f}}}(n,a,o),!0),c}var i={};function s(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(h(t={},r,function(){return this}),t),f=c.prototype=s.prototype=Object.create(u);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,h(e,a,"GeneratorFunction")),e.prototype=Object.create(f),e}return l.prototype=c,h(f,"constructor",c),h(c,"constructor",l),l.displayName="GeneratorFunction",h(c,a,"GeneratorFunction"),h(f),h(f,a,"Generator"),h(f,r,function(){return this}),h(f,"toString",function(){return"[object Generator]"}),(d=function(){return{w:o,m:g}})()}function h(e,t,n,r){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}h=function(e,t,n,r){function o(t,n){h(e,t,function(e){return this._invoke(t,n,e)})}t?a?a(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},h(e,t,n,r)}function g(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var o=e.apply(t,n);function i(e){g(o,r,a,i,s,"next",e)}function s(e){g(o,r,a,i,s,"throw",e)}i(void 0)})}}function m(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,v(r.key),r)}}function y(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e){var t=function(e){if("object"!=f(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==f(t)?t:t+""}var b,w,k,S,T,C,E,j=function(){return e=function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),y(this,"alreadyTranslated",new i.l(100)),y(this,"modelRegistry",{}),y(this,"currentlyTranslating",{}),y(this,"fromLanguages",[]),y(this,"toLanguages",[]),y(this,"active",!1),y(this,"publicPath",""),y(this,"getTranslation",function(){var e=p(d().m(function e(n,r,a,o,i,s){var l,c,u,f,h;return d().w(function(e){for(;;)switch(e.n){case 0:if(t.active=!0,n!=r&&n&&r){e.n=1;break}return e.a(2);case 1:if(l="".concat(n).concat(r,"-").concat(a,":").concat(o),!(c=t.alreadyTranslated.entries.find(function(e){return e.index==l}))){e.n=2;break}return e.a(2,c.response);case 2:if(!(l in t.currentlyTranslating)){e.n=3;break}return e.a(2,t.currentlyTranslating[l].promise);case 3:if(u=null,f=null,h=new Promise(function(e,t){u=e,f=t}),t.currentlyTranslating[l]={promise:h,resolve:u,reject:f},i){e.n=4;break}return t.currentlyTranslating[l].reject("No text was provided"),e.a(2,h);case 4:return t.translator.translate({to:r,from:n,text:i,html:!1,priority:s}).then(function(e){var n=e;t.currentlyTranslating[l].resolve(n.target.text),t.alreadyTranslated.add({index:l,response:n.target.text}),delete t.currentlyTranslating[l]}),e.a(2,h)}},e)}));return function(t,n,r,a,o,i){return e.apply(this,arguments)}}()),y(this,"getTranslationModel",function(){var e=p(d().m(function e(n,r){return d().w(function(e){for(;;)if(0===e.n)return e.a(2,t.translator.backing.getTranslationModel({from:n,to:r}).catch(function(e){console.error("An error occurred while trying to retreive the ".concat(n,"-").concat(r," model"))}))},e)}));return function(t,n){return e.apply(this,arguments)}}());var n={code:"en",name:"English (en)",type:"prod"};this.fromLanguages.push(n),this.toLanguages.push(n)},t=[{key:"initWorker",value:(n=p(d().m(function e(){var t,n,r,a,o,i,s,l,f,h,g,p,m,y,v,b,w,k,S=this;return d().w(function(e){for(;;)switch(e.n){case 0:if(!this.initPromise){e.n=1;break}return e.a(2,this.initPromise);case 1:return this.initPromise=new Promise(function(e,t){S._initResolve=e,S._initReject=t}),t="https://cors.archive.org/cors/mozilla-translate-models/firefox_models/",e.n=2,fetch(t+"registry.json").then(function(e){return e.json()});case 2:for(n=e.v,r=0,a=Object.values(n);r<a.length;r++)for(o=a[r],i=0,s=Object.values(o);i<s.length;i++)(l=s[i]).name=t+l.name;return this.translator=new c({registryUrl:"data:application/json,".concat(encodeURIComponent(JSON.stringify(n))),workers:2,batchSize:4,workerUrl:this.publicPath+"/translator-worker.js"}),e.n=3,this.translator.backing.registry;case 3:for(f=e.v,h={},g=0,p=Object.values(f);g<p.length;g++)m=p[g],y=m.from,v=m.to,b=m.files,h["".concat(y).concat(v)]=b,"en"!==y&&(w="".concat((0,u._4)(y)," (").concat((0,u.YH)(y),")"),this.fromLanguages.push({code:y,name:w,type:"prod"})),"en"!==v&&(k="".concat((0,u._4)(v)," (").concat((0,u.YH)(v),")"),this.toLanguages.push({code:v,name:k,type:"prod"}));return this._initResolve([this.modelRegistry]),e.a(2,this.initPromise)}},e,this)})),function(){return n.apply(this,arguments)})}],t&&m(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n}(),L=n(8004),P=n(593),x=(n(8248),n(1669));function O(e){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},O(e)}function M(e){return function(e){if(Array.isArray(e))return $(e)}(e)||I(e)||G(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(){A=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach(function(n){t.forEach(function(t){t.kind===n&&"own"===t.placement&&this.defineClassElement(e,t)},this)},this)},initializeClassElements:function(e,t){var n=e.prototype;["method","field"].forEach(function(r){t.forEach(function(t){var a=t.placement;if(t.kind===r&&("static"===a||"prototype"===a)){var o="static"===a?e:n;this.defineClassElement(o,t)}},this)},this)},defineClassElement:function(e,t){var n=t.descriptor;if("field"===t.kind){var r=t.initializer;n={enumerable:n.enumerable,writable:n.writable,configurable:n.configurable,value:void 0===r?void 0:r.call(e)}}Object.defineProperty(e,t.key,n)},decorateClass:function(e,t){var n=[],r=[],a={static:[],prototype:[],own:[]};if(e.forEach(function(e){this.addElementPlacement(e,a)},this),e.forEach(function(e){if(!R(e))return n.push(e);var t=this.decorateElement(e,a);n.push(t.element),n.push.apply(n,t.extras),r.push.apply(r,t.finishers)},this),!t)return{elements:n,finishers:r};var o=this.decorateConstructor(n,t);return r.push.apply(r,o.finishers),o.finishers=r,o},addElementPlacement:function(e,t,n){var r=t[e.placement];if(!n&&-1!==r.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");r.push(e.key)},decorateElement:function(e,t){for(var n=[],r=[],a=e.decorators,o=a.length-1;o>=0;o--){var i=t[e.placement];i.splice(i.indexOf(e.key),1);var s=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,a[o])(s)||s);e=l.element,this.addElementPlacement(e,t),l.finisher&&r.push(l.finisher);var c=l.extras;if(c){for(var u=0;u<c.length;u++)this.addElementPlacement(c[u],t);n.push.apply(n,c)}}return{element:e,finishers:r,extras:n}},decorateConstructor:function(e,t){for(var n=[],r=t.length-1;r>=0;r--){var a=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[r])(a)||a);if(void 0!==o.finisher&&n.push(o.finisher),void 0!==o.elements){e=o.elements;for(var i=0;i<e.length-1;i++)for(var s=i+1;s<e.length;s++)if(e[i].key===e[s].key&&e[i].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[i].key+")")}}return{elements:e,finishers:n}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||I(t)||G(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map(function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t},this);var t},toElementDescriptor:function(e){var t=e.kind+"";if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var n=re(e.key),r=e.placement+"";if("static"!==r&&"prototype"!==r&&"own"!==r)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+r+'"');var a=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:n,placement:r,descriptor:Object.assign({},a)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(a,"get","The property descriptor of a field descriptor"),this.disallowProperty(a,"set","The property descriptor of a field descriptor"),this.disallowProperty(a,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:q(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=e.kind+"";if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var n=q(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:n}},runClassFinishers:function(e,t){for(var n=0;n<t.length;n++){var r=(0,t[n])(e);if(void 0!==r){if("function"!=typeof r)throw new TypeError("Finishers must return a constructor.");e=r}}return e},disallowProperty:function(e,t,n){if(void 0!==e[t])throw new TypeError(n+" can't have a ."+t+" property.")}};return e}function _(e){var t,n=re(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var r={kind:"field"===e.kind?"field":"method",key:n,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(r.decorators=e.decorators),"field"===e.kind&&(r.initializer=e.value),r}function z(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function R(e){return e.decorators&&e.decorators.length}function B(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function q(e,t){var n=e[t];if(void 0!==n&&"function"!=typeof n)throw new TypeError("Expected '"+t+"' to be a function");return n}function I(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function F(){return F="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=Q(e)););return e}(e,t);if(r){var a=Object.getOwnPropertyDescriptor(r,t);return a.get?a.get.call(arguments.length<3?e:n):a.value}},F.apply(null,arguments)}function N(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function D(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=G(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){s=!0,o=e},f:function(){try{i||null==n.return||n.return()}finally{if(s)throw o}}}}function G(e,t){if(e){if("string"==typeof e)return $(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$(e,t):void 0}}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function H(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function o(n,r,a,o){var l=r&&r.prototype instanceof s?r:s,c=Object.create(l.prototype);return W(c,"_invoke",function(n,r,a){var o,s,l,c=0,u=a||[],f=!1,d={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,l=e,d.n=n,i}};function h(n,r){for(s=n,l=r,t=0;!f&&c&&!a&&t<u.length;t++){var a,o=u[t],h=d.p,g=o[2];n>3?(a=g===r)&&(l=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((a=n<2&&h<o[1])?(s=0,d.v=r,d.n=o[1]):h<g&&(a=n<3||o[0]>r||r>g)&&(o[4]=n,o[5]=r,d.n=g,s=0))}if(a||n>1)return i;throw f=!0,r}return function(a,u,g){if(c>1)throw TypeError("Generator is already running");for(f&&1===u&&h(u,g),s=u,l=g;(t=s<2?e:l)||!f;){o||(s?s<3?(s>1&&(d.n=-1),h(s,l)):d.n=l:d.v=l);try{if(c=2,o){if(s||(a="next"),t=o[a]){if(!(t=t.call(o,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(l=TypeError("The iterator does not provide a '"+a+"' method"),s=1);o=e}else if((t=(f=d.n<0)?l:n.call(r,d))!==i)break}catch(t){o=e,s=1,l=t}finally{c=1}}return{value:t,done:f}}}(n,a,o),!0),c}var i={};function s(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(W(t={},r,function(){return this}),t),f=c.prototype=s.prototype=Object.create(u);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,W(e,a,"GeneratorFunction")),e.prototype=Object.create(f),e}return l.prototype=c,W(f,"constructor",c),W(c,"constructor",l),l.displayName="GeneratorFunction",W(c,a,"GeneratorFunction"),W(f),W(f,a,"Generator"),W(f,r,function(){return this}),W(f,"toString",function(){return"[object Generator]"}),(H=function(){return{w:o,m:d}})()}function W(e,t,n,r){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}W=function(e,t,n,r){function o(t,n){W(e,t,function(e){return this._invoke(t,n,e)})}t?a?a(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},W(e,t,n,r)}function K(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function U(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var o=e.apply(t,n);function i(e){K(o,r,a,i,s,"next",e)}function s(e){K(o,r,a,i,s,"throw",e)}i(void 0)})}}function Z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function V(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,re(r.key),r)}}function J(e,t,n){return t&&V(e.prototype,t),n&&V(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Y(e,t,n){return t=Q(t),function(e,t){if(t&&("object"==O(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,X()?Reflect.construct(t,n||[],Q(e).constructor):t.apply(e,n))}function X(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(X=function(){return!!e})()}function Q(e){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Q(e)}function ee(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&te(e,t)}function te(e,t){return te=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},te(e,t)}function ne(e,t,n){return(t=re(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function re(e){var t=function(e){if("object"!=O(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=O(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==O(t)?t:t+""}var ae,oe,ie,se,le,ce,ue,fe=window.BookReader,de=function(e){function t(){var e;Z(this,t);for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return ne(e=Y(this,t,[].concat(r)),"options",{enabled:!0,panelDisclaimerText:"Translations are in alpha"}),ne(e,"translationManager",new j),ne(e,"worker",void 0),ne(e,"toLanguages",[]),ne(e,"langFromCode",void 0),ne(e,"langToCode",void 0),ne(e,"_panel",void 0),ne(e,"userToggleTranslate",void 0),ne(e,"loadingModel",!0),ne(e,"textSelectionManager",new P.bg(".BRtranslateLayer",e.br,{selectionElement:[".BRlineElement"]},1)),ne(e,"getParagraphsOnPage",function(e){return e?Array.from(e.querySelectorAll(".BRtextLayer > .BRparagraphElement")):[]}),ne(e,"handleFromLangChange",function(){var t=U(H().m(function t(n){var r;return H().w(function(t){for(;;)switch(t.n){case 0:e.clearAllTranslations(),r=n.detail.value,e.langFromCode=r,e._panel.requestUpdate(),e.translationManager.toLanguages.some(function(e){return e.code===r})||e.translationManager.toLanguages.push({code:r,name:e.translationManager.fromLanguages.find(function(e){return e.code==r}).name}),e._panel.toLanguages=e.translationManager.toLanguages,console.log(e.langFromCode,e.langToCode),e._render(),e.langFromCode!==e.langToCode&&e.translateActivePageContainerElements();case 1:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}()),ne(e,"handleToLangChange",function(){var t=U(H().m(function t(n){return H().w(function(t){for(;;)switch(t.n){case 0:e.clearAllTranslations(),e.langToCode=n.detail.value,e._render(),e.translateActivePageContainerElements();case 1:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}()),ne(e,"handleToggleTranslation",U(H().m(function t(){return H().w(function(t){for(;;)switch(t.n){case 0:e.userToggleTranslate=!e.userToggleTranslate,e.translationManager.active=e.userToggleTranslate,e._render(),e.userToggleTranslate?(e.br.trigger("translationEnabled",{}),e.translateActivePageContainerElements(),e.textSelectionManager.attach()):(e.clearAllTranslations(),e.br.trigger("translationDisabled",{}),e.textSelectionManager.detach());case 1:return t.a(2)}},t)}))),e}return ee(t,e),J(t,[{key:"init",value:(o=U(H().m(function e(){var t,n=this;return H().w(function(e){for(;;)switch(e.n){case 0:if(t=(0,u.YH)(this.br.options.bookLanguage.replace(/[.,/#!$%^&*;:{}=\-_`~()]/g,"")),this.langFromCode=null!=t?t:"en",this.textSelectionManager.init(),this.options.enabled){e.n=1;break}return e.a(2);case 1:return this.translationManager.publicPath=this.br.options.imagesBaseURL.replace(/\/+$/,"")+"/..",this.br.on("textLayerRendered",function(){var e=U(H().m(function e(t,r){var a,o;return H().w(function(e){for(;;)switch(e.n){case 0:if(r.pageIndex,a=r.pageContainer,n.translationManager){e.n=1;break}return e.a(2);case 1:n.translationManager.active&&(o=a.$container[0],n.translateRenderedLayer(o));case 2:return e.a(2)}},e)}));return function(t,n){return e.apply(this,arguments)}}()),this.br.on("pageVisible",function(e,t){var r=t.pageContainerEl;if(n.translationManager.active){var a,o=D(r.querySelectorAll(".BRtranslateLayer > .BRparagraphElement"));try{for(o.s();!(a=o.n()).done;){var i=a.value;i.textContent&&n.fitVisiblePage(i)}}catch(e){o.e(e)}finally{o.f()}}}),e.n=2,this.translationManager.initWorker();case 2:this.langToCode=this.translationManager.toLanguages[0].code,this._render();case 3:return e.a(2)}},e,this)})),function(){return o.apply(this,arguments)})},{key:"translateActivePageContainerElements",value:function(){var e,t=this.br.getActivePageContainerElements(),n=t.filter(function(e){return e.classList.contains("BRpage-visible")}),r=t.filter(function(e){return!e.classList.contains("BRpage-visible")}),a=D(n);try{for(a.s();!(e=a.n()).done;){var o=e.value;this.translateRenderedLayer(o,0)}}catch(e){a.e(e)}finally{a.f()}var i,s=D(r);try{for(s.s();!(i=s.n()).done;){var l=i.value;this.translateRenderedLayer(l,1e3)}}catch(e){s.e(e)}finally{s.f()}}},{key:"translateRenderedLayer",value:(a=U(H().m(function e(t,n){var r,a,o,i,s,l,c=this;return H().w(function(e){for(;;)switch(e.n){case 0:if(this.br.mode!=this.br.constModeThumb&&this.userToggleTranslate&&this.langFromCode!=this.langToCode){e.n=1;break}return e.a(2);case 1:return a=t.dataset.index,t.querySelector(".BRPageLayer.BRtranslateLayer")?o=t.querySelector(".BRPageLayer.BRtranslateLayer"):((o=document.createElement("div")).classList.add("BRPageLayer","BRtranslateLayer","BRtranslateLayerLoading"),o.setAttribute("lang","".concat(this.langToCode)),t.prepend(o)),i=t.querySelector(".BRtextLayer"),x(o).css({width:i.style.width,height:i.style.height,transform:i.style.transform,"pointer-events":i.style.pointerEvents,"z-index":3}),i.classList.add("showingTranslation"),s=this.getParagraphsOnPage(t),l=s.map(function(){var e=U(H().m(function e(r,i){var l,u,f,d,h,g,p,m,y;return H().w(function(e){for(;;)switch(e.n){case 0:if((l=t.querySelector("[data-translate-index='".concat(a,"-").concat(i,"']")))||((l=document.createElement("p")).setAttribute("data-translate-index","".concat(a,"-").concat(i)),l.className="BRparagraphElement",u=s[i],r.classList.contains("ocr-role-header-footer")&&(l.ariaHidden="true",l.classList.add("ocr-role-header-footer")),f="".concat(parseInt(x(u).css("font-size")),"px"),x(l).css({"margin-left":x(u).css("margin-left"),"margin-top":x(u).css("margin-top"),top:x(u).css("top"),height:x(u).css("height"),width:x(u).css("width"),"font-size":f}),o.append(l)),0===r.textContent.length){e.n=2;break}return g=parseFloat(a)+n+i,c.translationManager.getTranslationModel(c.langFromCode,c.langToCode).then(function(){c._panel.loadingModel=!1,c.loadingModel=!1}),e.n=1,c.translationManager.getTranslation(c.langFromCode,c.langToCode,a,i,r.textContent,g);case 1:p=e.v,null===(d=l.firstElementChild)||void 0===d||d.remove(),m=null===(h=s[i])||void 0===h||null===(h=h.firstChild)||void 0===h?void 0:h.firstChild,(y=document.createElement("span")).className="BRlineElement",y.textContent=p,l.appendChild(y),x(y).css({"text-indent":x(m).css("padding-left")}),t.classList.contains("BRpage-visible")&&c.fitVisiblePage(l);case 2:return e.a(2)}},e)}));return function(t,n){return e.apply(this,arguments)}}()),null===(r=this.textSelectionManager)||void 0===r||r.stopPageFlip(this.br.refs.$brContainer),e.n=2,Promise.all(l);case 2:this.br.trigger("translateLayerRendered",{leafIndex:a,translateLayer:o});case 3:return e.a(2)}},e,this)})),function(e,t){return a.apply(this,arguments)})},{key:"getTranslateLayers",value:(n=U(H().m(function e(t){var n,r,a=this;return H().w(function(e){for(;;)switch(e.n){case 0:if(n=this.br.getActivePageContainerElementsForIndex(t),!(r=x(n).filter("[data-index='".concat(t,"']")).find(".BRtranslateLayer")).length){e.n=1;break}return e.a(2,r.toArray());case 1:return e.a(2,new Promise(function(e,n){var r=function(){var n=U(H().m(function n(o,i){return H().w(function(n){for(;;)switch(n.n){case 0:i.leafIndex==t&&(a.br.off("translateLayerRendered",r),e([i.translateLayer]));case 1:return n.a(2)}},n)}));return function(e,t){return n.apply(this,arguments)}}();a.br.on("translateLayerRendered",r)}))}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"clearAllTranslations",value:function(){document.querySelectorAll(".BRtranslateLayer").forEach(function(e){return e.remove()}),document.querySelectorAll(".showingTranslation").forEach(function(e){return e.classList.remove("showingTranslation")})}},{key:"fitVisiblePage",value:function(e){for(var t=parseInt(x(e).css("font-size"));e.clientHeight<e.scrollHeight&&t>0;)t--,x(e).css({"font-size":"".concat(t,"px")});var n=e.firstElementChild.clientHeight,r=e.scrollHeight;if(n<r){var a=r/(n/t);x(e).css({"line-height":"".concat(a,"px"),overflow:"visible"})}}},{key:"_render",value:function(){var e=this;this.br.shell.menuProviders.translate={id:"translate",icon:(0,r.qy)(b||(b=N(["<img src='",'/translate.svg\' width="26"/>'])),this.br.options.imagesBaseURL),label:"Translate",component:(0,r.qy)(w||(w=N(['<br-translate-panel\n @connected="','"\n @langFromChanged="','"\n @langToChanged="','"\n @toggleTranslation="','"\n .fromLanguages="','"\n .toLanguages="','"\n .disclaimerMessage="','"\n .userTranslationActive=',"\n .detectedFromLang=","\n .detectedToLang=","\n .loadingModel=",'\n class="translate-panel"\n />'])),function(t){e._panel=t.target,e._panel.fromLanguages=e.translationManager.fromLanguages,e._panel.toLanguages=e.translationManager.toLanguages,e._panel.userTranslationActive=e.userToggleTranslate,e._panel.detectedToLang=e.langToCode,e._panel.detectedFromLang=e.langFromCode,e._panel.loadingModel=e.loadingModel},this.handleFromLangChange,this.handleToLangChange,this.handleToggleTranslation,this.translationManager.fromLanguages,this.translationManager.toLanguages,this.options.panelDisclaimerText,this.userToggleTranslate,this.langFromCode,this.langToCode,this.loadingModel)},this.br.shell.updateMenuContents()}}]);var n,a,o}(a.S);null==fe||fe.registerPlugin("translate",de),ae=[(0,o.EM)("br-translate-panel")],oe=r.WF,le=A(),ie=function(e){le.initializeInstanceElements(e,ue.elements)},se=function(e){function t(){var e;Z(this,t);for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return e=Y(this,t,[].concat(r)),ie(e),e}return ee(t,e),J(t)}(oe),ce={F:se,d:[{kind:"field",decorators:[(0,o.MZ)({type:Array})],key:"fromLanguages",value:function(){return[]}},{kind:"field",decorators:[(0,o.MZ)({type:Array})],key:"toLanguages",value:function(){return[]}},{kind:"field",decorators:[(0,o.MZ)({type:String})],key:"prevSelectedLang",value:function(){return""}},{kind:"field",decorators:[(0,o.MZ)({type:String})],key:"disclaimerMessage",value:function(){return""}},{kind:"field",decorators:[(0,o.MZ)({type:Boolean})],key:"userTranslationActive",value:function(){return!1}},{kind:"field",decorators:[(0,o.MZ)({type:String})],key:"detectedFromLang",value:function(){return""}},{kind:"field",decorators:[(0,o.MZ)({type:String})],key:"detectedToLang",value:function(){return""}},{kind:"field",decorators:[(0,o.MZ)({type:Boolean})],key:"loadingModel",value:void 0},{kind:"method",key:"createRenderRoot",value:function(){return this}},{kind:"method",key:"connectedCallback",value:function(){var e,t,n,r,a;(e=se,t="connectedCallback",n=this,a=F(Q(1&(r=3)?e.prototype:e),t,n),2&r&&"function"==typeof a?function(e){return a.apply(n,e)}:a)([]),this.dispatchEvent(new CustomEvent("connected"))}},{kind:"method",key:"render",value:function(){var e=this;return(0,r.qy)(k||(k=N(['<div class="app" style="margin-top: 5%;padding-right: 5px;">\n <div\n class="disclaimer"\n id="disclaimerMessage"\n style="background-color: rgba(255,255,255,0.1);padding: 10px;border-radius: 8px;font-size: 12px;margin-bottom: 10px;color: rgba(255,255,255, 0.9);"\n >','</div>\n\n <div class="panel panel--to" style="padding: 0 10px;">\n <label>\n <span style="font-size: 12px;color: #ccc;">Translate To</span>\n <select id="lang-to" name="to" class="lang-select" style="display:block; width:100%;" @change="','">\n ','\n </select>\n </label>\n </div>\n\n <div class="panel panel--start" style="text-align: right;padding: 0 10px;/*! font-size: 18px; */margin-top: 10px;">\n <button class="start-translation-brn" @click="','">\n ','\n </button>\n </div>\n\n <div class="panel panel--from" style="font-size: 12px;color: #ccc;text-align: center;padding: 8px 10px;">\n <details style="display: contents">\n <summary style="text-decoration: underline white; cursor:pointer; display:inline-block"> \n <i>\n Source: '," ",' \n </i> Change \n </summary>\n <select id="lang-from" name="from" class="lang-select" value=',' @change="','" style="width:65%; margin-top: 3%; margin-bottom: 3%">\n ','\n </select>\n </details>\n <div class="footer" id="status" style="margin-top:5%">\n ','\n </div>\n\n <div class="lang-models-loading"> \n ',"\n </div>\n </div>"])),this.disclaimerMessage,this._onLangToChange,(0,L.sortBy)(this.toLanguages,function(e){return e.name.toLowerCase()}).map(function(t){return(0,r.qy)(S||(S=N(['<option value="','" \n ?selected=',"\n > "," </option>"])),t.code,t.code==e.detectedToLang,t.name?t.name:t.code)}),this._toggleTranslation,this.userTranslationActive?"Stop Translating":"Translate",this._getLangName(this.detectedFromLang),this.prevSelectedLang?"":"(detected)",this.detectedFromLang,this._onLangFromChange,(0,L.sortBy)(this.fromLanguages,function(e){return e.name.toLowerCase()}).map(function(t){return(0,r.qy)(T||(T=N(['<option value="','"\n ?selected=',"\n >"," </option>"])),t.code,t.code==e.detectedFromLang,t.name?t.name:t.code)}),this._statusWarning(),this._languageModelStatus())}},{kind:"method",key:"_onLangFromChange",value:function(e){var t=new CustomEvent("langFromChanged",{detail:{value:e.target.value},bubbles:!0,composed:!0});this.dispatchEvent(t),this._getSelectedLang("to")!==this._getSelectedLang("from")&&(this.prevSelectedLang=this._getSelectedLang("from")),this.loadingModel=!0,this.detectedFromLang=e.target.value}},{kind:"method",key:"_onLangToChange",value:function(e){var t=new CustomEvent("langToChanged",{detail:{value:e.target.value},bubbles:!0,composed:!0});this.dispatchEvent(t),this._getSelectedLang("from")!==e.target.value&&(this.prevSelectedLang=this._getSelectedLang("from")),this.loadingModel=!0,this.detectedToLang=e.target.value}},{kind:"method",key:"_getSelectedLang",value:function(e){var t=this.querySelector("#lang-".concat(e));return t?t.value:""}},{kind:"method",key:"_getLangName",value:function(e){var t=[].concat(M(this.fromLanguages),M(this.toLanguages)).find(function(t){return t.code===e});return t?t.name:""}},{kind:"method",key:"_toggleTranslation",value:function(e){var t=new CustomEvent("toggleTranslation",{detail:{value:e.target.value},bubbles:!0,composed:!0});this.userTranslationActive=!this.userTranslationActive,this.dispatchEvent(t)}},{kind:"method",key:"_statusWarning",value:function(){return this.detectedFromLang==this.detectedToLang?"Translate To language is the same as the Source language":""}},{kind:"method",key:"_languageModelStatus",value:function(){return this.userTranslationActive?this.loadingModel?(0,r.qy)(C||(C=N(['\n <ia-activity-indicator mode="processing" style="display:block; width: 40px; height: 40px; margin: 0 auto;"></ia-activity-indicator>\n <p>Downloading language model</p>\n ']))):(0,r.qy)(E||(E=N(["<p>Language model loaded</p>"]))):""}}]},ue=le.decorateClass(function(e){for(var t=[],n=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},r=0;r<e.length;r++){var a,o=e[r];if("method"===o.kind&&(a=t.find(n)))if(B(o.descriptor)||B(a.descriptor)){if(R(o)||R(a))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");a.descriptor=o.descriptor}else{if(R(o)){if(R(a))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");a.decorators=o.decorators}z(o,a)}else t.push(o)}return t}(ce.d.map(_)),ae),le.initializeClassElements(ce.F,ue.elements),le.runClassFinishers(ce.F,ue.finishers)},4160:function(e,t,n){n.d(t,{$x:function(){return y},EF:function(){return u},ND:function(){return m},m0:function(){return f},YH:function(){return h},_4:function(){return g}}),n(2675),n(9463),n(2259),n(3418),n(4423),n(3792),n(4782),n(2010),n(875),n(6099),n(3362),n(7495),n(8781),n(1699),n(7764),n(1761),n(2953);var r=[],a={},o={},i={};[["Serbian","српски језик","sr","srp","srp"],["Romanian, Moldavian, Moldovan","Română","ro","ron","rum"],["Sichuan Yi, Nuosu","ꆈꌠ꒿ Nuosuhxop","ii","iii","iii"],["Tahitian","Reo Tahiti","ty","tah","tah"],["Tagalog","Wikang Tagalog","tl","tgl","tgl"],["Yiddish","ייִדיש","yi","yid","yid"],["Akan","Akan","ak","aka","aka"],["Malay","Bahasa Melayu, بهاس ملايو","ms","msa","may"],["Arabic","العربية","ar","ara","ara"],["Norwegian","Norsk","no","nor","nor"],["Ojibwa","ᐊᓂᔑᓈᐯᒧᐎᓐ","oj","oji","oji"],["Fulah","Fulfulde, Pulaar, Pular","ff","ful","ful"],["Persian","فارسی","fa","fas","per"],["Albanian","Shqip","sq","sqi","alb"],["Aymara","aymar aru","ay","aym","aym"],["Azerbaijani","azərbaycan dili","az","aze","aze"],["Chinese","中文 (Zhōngwén), 汉语, 漢語","zh","zho","chi"],["Cree","ᓀᐦᐃᔭᐍᐏᐣ","cr","cre","cre"],["Estonian","eesti, eesti keel","et","est","est"],["Guaraní","Avañe'ẽ","gn","grn","grn"],["Inupiaq","Iñupiaq, Iñupiatun","ik","ipk","ipk"],["Inuktitut","ᐃᓄᒃᑎᑐᑦ","iu","iku","iku"],["Kanuri","Kanuri","kr","kau","kau"],["Komi","коми кыв","kv","kom","kom"],["Kongo","Kikongo","kg","kon","kon"],["Kurdish","Kurdî, أۇزبېك","ku","kur","kur"],["Latvian","latviešu valoda","lv","lav","lav"],["Malagasy","fiteny malagasy","mg","mlg","mlg"],["Mongolian","Монгол хэл","mn","mon","mon"],["Oromo","Afaan Oromoo","om","orm","orm"],["Pashto, Pushto","پښتو","ps","pus","pus"],["Quechua","Runa Simi, Kichwa","qu","que","que"],["Sardinian","sardu","sc","srd","srd"],["Swahili","Kiswahili","sw","swa","swa"],["Uzbek","Oʻzbek, Ўзбек, ","uz","uzb","uzb"],["Zhuang, Chuang","Saɯ cueŋƅ, Saw cuengh","za","zha","zha"],["Bislama","Bislama","bi","bis","bis"],["Norwegian Bokmål","Norsk Bokmål","nb","nob","nob"],["Norwegian Nynorsk","Norsk Nynorsk","nn","nno","nno"],["Indonesian","Bahasa Indonesia","id","ind","ind"],["Twi","Twi","tw","twi","twi"],["Esperanto","Esperanto","eo","epo","epo"],["Interlingua","Interlingua","ia","ina","ina"],["Interlingue","Originally called Occidental; then Interlingue after WWII","ie","ile","ile"],["Ido","Ido","io","ido","ido"],["Volapük","Volapük","vo","vol","vol"],["Bihari languages","भोजपुरी","bh","bih","bih"],["Hebrew (modern)","עברית","he","heb","heb"],["Sanskrit","संस्कृतम्","sa","san","san"],["Church Slavic, Church Slavonic, Old Church Slavonic, Old Slavonic, Old Bulgarian","ѩзыкъ словѣньскъ","cu","chu","chu"],["Pali","पाऴि","pi","pli","pli"],["Avestan","avesta","ae","ave","ave"],["Latin","latine, lingua latina","la","lat","lat"],["Armenian","Հայերեն","hy","hye","arm"],["Swati","SiSwati","ss","ssw","ssw"],["Tibetan","བོད་ཡིག","bo","bod","tib"],["South Ndebele","isiNdebele","nr","nbl","nbl"],["Slovene","Slovenski Jezik, Slovenščina","sl","slv","slv"],["Oriya","ଓଡ଼ିଆ","or","ori","ori"],["North Ndebele","isiNdebele","nd","nde","nde"],["Nauru","Dorerin Naoero","na","nau","nau"],["Maori","te reo Māori","mi","mri","mao"],["Marathi","मराठी","mr","mar","mar"],["Luba-Katanga","Kiluba","lu","lub","lub"],["Rundi","Ikirundi","rn","run","run"],["Central Khmer","ខ្មែរ, ខេមរភាសា, ភាសាខ្មែរ","km","khm","khm"],["Western Frisian","Frysk","fy","fry","fry"],["Bengali","বাংলা","bn","ben","ben"],["Avaric","авар мацӀ, магӀарул мацӀ","av","ava","ava"],["Abkhazian","аҧсуа бызшәа, аҧсшәа","ab","abk","abk"],["Afar","Afaraf","aa","aar","aar"],["Afrikaans","Afrikaans","af","afr","afr"],["Amharic","አማርኛ","am","amh","amh"],["Aragonese","aragonés","an","arg","arg"],["Assamese","অসমীয়া","as","asm","asm"],["Bambara","bamanankan","bm","bam","bam"],["Bashkir","башҡорт теле","ba","bak","bak"],["Basque","euskara, euskera","eu","eus","baq"],["Belarusian","беларуская мова","be","bel","bel"],["Bosnian","bosanski jezik","bs","bos","bos"],["Breton","brezhoneg","br","bre","bre"],["Bulgarian","български език","bg","bul","bul"],["Burmese","ဗမာစာ","my","mya","bur"],["Catalan, Valencian","català, valencià","ca","cat","cat"],["Chamorro","Chamoru","ch","cha","cha"],["Chechen","нохчийн мотт","ce","che","che"],["Chichewa, Chewa, Nyanja","chiCheŵa, chinyanja","ny","nya","nya"],["Chuvash","чӑваш чӗлхи","cv","chv","chv"],["Cornish","Kernewek","kw","cor","cor"],["Corsican","corsu, lingua corsa","co","cos","cos"],["Croatian","hrvatski jezik","hr","hrv","hrv"],["Czech","čeština, český jazyk","cs","ces","cze"],["Danish","dansk","da","dan","dan"],["Divehi, Dhivehi, Maldivian","ދިވެހި","dv","div","div"],["Dutch, Flemish","Nederlands, Vlaams","nl","nld","dut"],["Dzongkha","རྫོང་ཁ","dz","dzo","dzo"],["English","English","en","eng","eng"],["Ewe","Eʋegbe","ee","ewe","ewe"],["Faroese","føroyskt","fo","fao","fao"],["Fijian","vosa Vakaviti","fj","fij","fij"],["Finnish","suomi, suomen kieli","fi","fin","fin"],["French","français, langue française","fr","fra","fre"],["Galician","Galego","gl","glg","glg"],["Georgian","ქართული","ka","kat","geo"],["German","Deutsch","de","deu","ger"],["Greek (modern)","ελληνικά","el","ell","gre"],["Gujarati","ગુજરાતી","gu","guj","guj"],["Haitian, Haitian Creole","Kreyòl ayisyen","ht","hat","hat"],["Hausa","(Hausa) هَوُسَ","ha","hau","hau"],["Herero","Otjiherero","hz","her","her"],["Hindi","हिन्दी, हिंदी","hi","hin","hin"],["Hiri Motu","Hiri Motu","ho","hmo","hmo"],["Hungarian","magyar","hu","hun","hun"],["Irish","Gaeilge","ga","gle","gle"],["Igbo","Asụsụ Igbo","ig","ibo","ibo"],["Icelandic","Íslenska","is","isl","ice"],["Italian","Italiano","it","ita","ita"],["Japanese","日本語 (にほんご)","ja","jpn","jpn"],["Javanese","ꦧꦱꦗꦮ, Basa Jawa","jv","jav","jav"],["Kalaallisut, Greenlandic","kalaallisut, kalaallit oqaasii","kl","kal","kal"],["Kannada","ಕನ್ನಡ","kn","kan","kan"],["Kashmiri","कश्मीरी, كشميري","ks","kas","kas"],["Kazakh","қазақ тілі","kk","kaz","kaz"],["Kikuyu, Gikuyu","Gĩkũyũ","ki","kik","kik"],["Kinyarwanda","Ikinyarwanda","rw","kin","kin"],["Kirghiz, Kyrgyz","Кыргызча, Кыргыз тили","ky","kir","kir"],["Korean","한국어","ko","kor","kor"],["Kuanyama, Kwanyama","Kuanyama","kj","kua","kua"],["Luxembourgish, Letzeburgesch","Lëtzebuergesch","lb","ltz","ltz"],["Ganda","Luganda","lg","lug","lug"],["Limburgan, Limburger, Limburgish","Limburgs","li","lim","lim"],["Lingala","Lingála","ln","lin","lin"],["Lao","ພາສາລາວ","lo","lao","lao"],["Lithuanian","lietuvių kalba","lt","lit","lit"],["Manx","Gaelg, Gailck","gv","glv","glv"],["Macedonian","македонски јазик","mk","mkd","mac"],["Malayalam","മലയാളം","ml","mal","mal"],["Maltese","Malti","mt","mlt","mlt"],["Marshallese","Kajin M̧ajeļ","mh","mah","mah"],["Navajo, Navaho","Diné bizaad","nv","nav","nav"],["Nepali","नेपाली","ne","nep","nep"],["Ndonga","Owambo","ng","ndo","ndo"],["Occitan","occitan, lenga d'òc","oc","oci","oci"],["Ossetian, Ossetic","ирон æвзаг","os","oss","oss"],["Panjabi, Punjabi","ਪੰਜਾਬੀ","pa","pan","pan"],["Polish","język polski, polszczyzna","pl","pol","pol"],["Portuguese","Português","pt","por","por"],["Romansh","Rumantsch Grischun","rm","roh","roh"],["Russian","русский","ru","rus","rus"],["Sindhi","सिन्धी, سنڌي، سندھی","sd","snd","snd"],["Northern Sami","Davvisámegiella","se","sme","sme"],["Samoan","gagana fa'a Samoa","sm","smo","smo"],["Sango","yângâ tî sängö","sg","sag","sag"],["Gaelic, Scottish Gaelic","Gàidhlig","gd","gla","gla"],["Shona","chiShona","sn","sna","sna"],["Sinhala, Sinhalese","සිංහල","si","sin","sin"],["Slovak","Slovenčina, Slovenský Jazyk","sk","slk","slo"],["Somali","Soomaaliga, af Soomaali","so","som","som"],["Southern Sotho","Sesotho","st","sot","sot"],["Spanish, Castilian","Español","es","spa","spa"],["Sundanese","Basa Sunda","su","sun","sun"],["Swedish","Svenska","sv","swe","swe"],["Tamil","தமிழ்","ta","tam","tam"],["Telugu","తెలుగు","te","tel","tel"],["Tajik","тоҷикӣ, toçikī, تاجیکی","tg","tgk","tgk"],["Thai","ไทย","th","tha","tha"],["Tigrinya","ትግርኛ","ti","tir","tir"],["Turkmen","Türkmen, Түркмен","tk","tuk","tuk"],["Tswana","Setswana","tn","tsn","tsn"],["Tongan (Tonga Islands)","Faka Tonga","to","ton","ton"],["Turkish","Türkçe","tr","tur","tur"],["Tsonga","Xitsonga","ts","tso","tso"],["Tatar","татар теле, tatar tele","tt","tat","tat"],["Uighur, Uyghur","ئۇيغۇرچە, Uyghurche","ug","uig","uig"],["Ukrainian","Українська","uk","ukr","ukr"],["Urdu","اردو","ur","urd","urd"],["Venda","Tshivenḓa","ve","ven","ven"],["Vietnamese","Tiếng Việt","vi","vie","vie"],["Walloon","Walon","wa","wln","wln"],["Welsh","Cymraeg","cy","cym","wel"],["Wolof","Wollof","wo","wol","wol"],["Xhosa","isiXhosa","xh","xho","xho"],["Yoruba","Yorùbá","yo","yor","yor"],["Zulu","isiZulu","zu","zul","zul"]].forEach(e=>{var t={name:e[0],nativeName:e[1],iso639_1:e[2],iso639_2T:e[3],iso639_2B:e[4]};a[e[2]]=o[e[3]]=i[e[4]]=t,r.push(t)});var s=r;function l(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return c(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){s=!0,o=e},f:function(){try{i||null==n.return||n.return()}finally{if(s)throw o}}}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function u(e){var t=e.match(/\S+/g);return t?t.length:0}function f(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:navigator.userAgent;return/android/i.test(e)}var d={"zh-hans":"中文 (Zhōngwén)"};function h(e){if(!e)return null;if(e=e.toLocaleLowerCase(),d[e])return e;var t=p(e,["iso639_1"])||p(e,["iso639_2T"])||p(e,["iso639_2B","name","nativeName"]);return t?t.iso639_1:null}function g(e){if(!e)return null;if(e=e.toLocaleLowerCase(),d[e])return d[e];var t=p(e,["iso639_1"])||p(e,["iso639_2T"])||p(e,["iso639_2B","name","nativeName"]);return null!=t&&t.nativeName?t.nativeName.split(", ")[0]:null}function p(e,t){if(!e)return null;e=e.toLowerCase();var n,r=l(s);try{for(r.s();!(n=r.n()).done;){var a,o=n.value,i=l(t);try{for(i.s();!(a=i.n()).done;){var c;if(null!==(c=o[a.value])&&void 0!==c&&c.toLowerCase().split(", ").includes(e))return o}}catch(e){i.e(e)}finally{i.f()}}}catch(e){r.e(e)}finally{r.f()}return null}function m(){try{return!!window.localStorage}catch(e){return!1}}var y=-1!=location.toString().indexOf("_debugReadAloud=true")},593:function(e,t,n){n.d(t,{bg:function(){return k}}),n(2675),n(9463),n(2259),n(5700),n(113),n(3418),n(3792),n(8598),n(4782),n(9572),n(2010),n(8130),n(875),n(6099),n(3362),n(7495),n(8781),n(7764),n(5440),n(2953);var r=n(1669);function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,s(r.key),r)}}function i(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=a(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}var l=function(){return e=function e(t,n){var a=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i(this,"selecting",!1),i(this,"startedInSelector",!1),i(this,"target",null),i(this,"_onSelectionChange",function(){var e=window.getSelection();if(!a.selecting&&e.toString()){var t=r(e.anchorNode).closest(a.selector)[0];if(!t)return;a.target=t,a.selecting=!0,a.handler("started",a.target)}!a.selecting||!e.isCollapsed&&e.toString()&&r(e.anchorNode).closest(a.selector)[0]||(a.selecting=!1,a.handler("cleared",a.target))}),this.selector=t,this.handler=n},(t=[{key:"attach",value:function(){document.addEventListener("selectionchange",this._onSelectionChange)}},{key:"detach",value:function(){document.removeEventListener("selectionchange",this._onSelectionChange)}}])&&o(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}(),c=n(1669);function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function f(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(u(e)+" is not iterable")}function d(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function o(n,r,a,o){var l=r&&r.prototype instanceof s?r:s,c=Object.create(l.prototype);return h(c,"_invoke",function(n,r,a){var o,s,l,c=0,u=a||[],f=!1,d={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return o=t,s=0,l=e,d.n=n,i}};function h(n,r){for(s=n,l=r,t=0;!f&&c&&!a&&t<u.length;t++){var a,o=u[t],h=d.p,g=o[2];n>3?(a=g===r)&&(l=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=h&&((a=n<2&&h<o[1])?(s=0,d.v=r,d.n=o[1]):h<g&&(a=n<3||o[0]>r||r>g)&&(o[4]=n,o[5]=r,d.n=g,s=0))}if(a||n>1)return i;throw f=!0,r}return function(a,u,g){if(c>1)throw TypeError("Generator is already running");for(f&&1===u&&h(u,g),s=u,l=g;(t=s<2?e:l)||!f;){o||(s?s<3?(s>1&&(d.n=-1),h(s,l)):d.n=l:d.v=l);try{if(c=2,o){if(s||(a="next"),t=o[a]){if(!(t=t.call(o,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(l=TypeError("The iterator does not provide a '"+a+"' method"),s=1);o=e}else if((t=(f=d.n<0)?l:n.call(r,d))!==i)break}catch(t){o=e,s=1,l=t}finally{c=1}}return{value:t,done:f}}}(n,a,o),!0),c}var i={};function s(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(h(t={},r,function(){return this}),t),f=c.prototype=s.prototype=Object.create(u);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,h(e,a,"GeneratorFunction")),e.prototype=Object.create(f),e}return l.prototype=c,h(f,"constructor",c),h(c,"constructor",l),l.displayName="GeneratorFunction",h(c,a,"GeneratorFunction"),h(f),h(f,a,"Generator"),h(f,r,function(){return this}),h(f,"toString",function(){return"[object Generator]"}),(d=function(){return{w:o,m:g}})()}function h(e,t,n,r){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}h=function(e,t,n,r){function o(t,n){h(e,t,function(e){return this._invoke(t,n,e)})}t?a?a(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},h(e,t,n,r)}var g=d().m(S),p=d().m(T);function m(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return y(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){s=!0,o=e},f:function(){try{i||null==n.return||n.return()}finally{if(s)throw o}}}}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function v(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,w(r.key),r)}}function b(e,t,n){return(t=w(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e){var t=function(e){if("object"!=u(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=u(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==u(t)?t:t+""}var k=function(){return e=function e(t,n,r,a){var o=this,i=r.selectionElement;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),b(this,"options",{maxProtectedWords:200}),b(this,"_onSelectionChange",function(e,t){if("started"===e)o.textSelectingMode(t);else{if("cleared"!==e)throw new Error("Unknown type ".concat(e));o.defaultMode(t)}}),b(this,"_limitSelection",function(){var e=window.getSelection();if(e.rangeCount){var t=e.getRangeAt(0),n=!!t.startContainer.parentElement.closest(".BRcontainer"),r=!!t.endContainer.parentElement.closest(".BRcontainer");if(n||r)if(n&&r){var a=function(e,t){var n,r=0,a=m(e);try{for(a.s();!(n=a.n()).done;){var o=n.value;if(r==t)return o;r++}}catch(e){a.e(e)}finally{a.f()}}(S(T(t.startContainer,t.endContainer),function(e){var t;return null===(t=e.classList)||void 0===t?void 0:t.contains(o.selectionElement[0].replace(".",""))}),o.options.maxProtectedWords-1);if(a&&t.endContainer.parentNode!=a){var i=document.createRange();i.setStart(t.startContainer,t.startOffset),i.setEnd(a.firstChild,a.textContent.length),e.removeAllRanges(),e.addRange(i)}}else e.removeAllRanges()}}),this.layer=t,this.br=n,this.selectionElement=i,this.selectionObserver=new l(this.layer,this._onSelectionChange),this.options.maxProtectedWords=a||200},t=[{key:"init",value:function(){var e=this;this.attach(),new l(this.layer,function(t){var n;"started"==t&&(null===(n=e.br.plugins.archiveAnalytics)||void 0===n||n.sendEvent("BookReader","SelectStart"),e.br.refs.$br.find(".BRpagecontainer--hasSelection").removeClass("BRpagecontainer--hasSelection"),c(window.getSelection().anchorNode).closest(".BRpagecontainer").addClass("BRpagecontainer--hasSelection"))}).attach()}},{key:"attach",value:function(){var e=this;this.selectionObserver.attach(),this.br.protected&&(document.addEventListener("selectionchange",this._limitSelection),c(document.body).on("contextmenu dragstart copy",function(t){var n=document.getSelection();if(null!=n&&n.toString()&&c(e.layer).toArray().some(function(e){return n.containsNode(e,!0)}))return t.preventDefault(),!1}))}},{key:"detach",value:function(){this.selectionObserver.detach(),this.br.protected&&document.removeEventListener("selectionchange",this._limitSelection)}},{key:"interceptCopy",value:function(e){e[0].addEventListener("copy",function(e){var t=document.getSelection();e.clipboardData.setData("text/plain",t.toString()),e.preventDefault()})}},{key:"stopPageFlip",value:function(e){var t=this,n=e.find(this.layer);n.length&&(n.each(function(e,n){return t.defaultMode(n)}),this.br.protected||this.interceptCopy(e))}},{key:"defaultMode",value:function(e){var t=this,n=c(e).closest(".BRpagecontainer");e.style.pointerEvents="none",n.find("img").css("pointer-events","auto"),c(e).off(".textSelectPluginHandler");var r=this.mouseIsDown,a=this.mouseIsDown;r&&(e.style.pointerEvents="auto"),c(e).on("mousedown.textSelectPluginHandler",function(e){t.mouseIsDown=!0,c(e.target).is(t.selectionElement.join(", "))&&e.stopPropagation()}),c(e).on("mouseup.textSelectPluginHandler",function(n){t.mouseIsDown=!1,e.style.pointerEvents="none",a&&(a=!1,n.stopPropagation())})}},{key:"textSelectingMode",value:function(e){var t=this,n=c(e).closest(".BRpagecontainer");e.style.pointerEvents="all",n.find("img").css("pointer-events","none"),c(e).off(".textSelectPluginHandler"),c(e).on("mousedown.textSelectPluginHandler",function(e){t.mouseIsDown=!0,e.stopPropagation()}),c(e).on("mouseup.textSelectPluginHandler",function(e){t.mouseIsDown=!1,e.stopPropagation()})}}],t&&v(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function S(e,t){var n,r,a,o;return d().w(function(i){for(;;)switch(i.p=i.n){case 0:n=m(e),i.p=1,n.s();case 2:if((r=n.n()).done){i.n=4;break}if(a=r.value,!t(a)){i.n=3;break}return i.n=3,a;case 3:i.n=2;break;case 4:i.n=6;break;case 5:i.p=5,o=i.v,n.e(o);case 6:return i.p=6,n.f(),i.f(6);case 7:return i.a(2)}},g,null,[[1,5,6,7]])}function T(e,t){var n,r;return d().w(function(a){for(;;)switch(a.n){case 0:return r=function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=a.children,i=void 0===o||o,s=a.parents,l=void 0===s||s,c=a.siblings,u=void 0===c||c;return d().m(function a(){var o;return d().w(function(a){for(;;)switch(a.n){case 0:if(e!==t){a.n=2;break}return n=!0,a.n=1,e;case 1:return a.a(2);case 2:return a.n=3,e;case 3:if(!i||!e.firstChild){a.n=5;break}return a.d(f(r(e.firstChild,{children:!0,parents:!1,siblings:!0})),4);case 4:if(!n){a.n=5;break}return a.a(2);case 5:if(!u){a.n=9;break}o=e.nextSibling;case 6:if(!o){a.n=9;break}return a.d(f(r(o,{children:!0,parents:!1,siblings:!1})),7);case 7:if(!n){a.n=8;break}return a.a(2);case 8:o=o.nextSibling,a.n=6;break;case 9:if(!l||!e.parentNode){a.n=11;break}return a.d(f(r(e.parentNode,{children:!1,parents:!0,siblings:!0})),10);case 10:if(!n){a.n=11;break}return a.a(2);case 11:return a.a(2)}},a)})()},n=!1,a.d(f(r(e)),1);case 1:return a.a(2)}},p)}},4565:function(e,t,n){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,o(r.key),r)}}function o(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}n.d(t,{l:function(){return i}}),n(2675),n(9463),n(2259),n(5700),n(3792),n(9572),n(8130),n(6099),n(7764),n(2953);var i=function(){return e=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.maxSize=t,this.entries=[]},(t=[{key:"add",value:function(e){this.entries.length>=this.maxSize&&this.entries.shift(),this.entries.push(e)}}])&&a(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}()}},function(e){e(e.s=6735)}]);
|
|
136
|
+
`}};(0,o.Cg)([(0,a.MZ)({type:String})],s.prototype,"mode",void 0),s=(0,o.Cg)([(0,a.EM)("ia-activity-indicator")],s)},90:function(e,t,n){var r=n(420),o=r.qy`
|
|
137
|
+
<svg
|
|
138
|
+
viewBox="0 0 100 100"
|
|
139
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
140
|
+
>
|
|
141
|
+
<g class="fill-color">
|
|
142
|
+
<path d="M70.6784759,10 L70.6784759,21.3240186 C64.5020053,21.66334 58.9104278,22.5826126 53.9037433,24.0818363 C48.8970588,25.5810601 44.8495989,27.4085163 41.7613636,29.5642049 C38.6731283,31.7198935 35.9982175,34.0552229 33.736631,36.5701929 C31.4750446,39.085163 29.8217469,41.5657574 28.776738,44.011976 C27.7317291,46.4581947 26.9173351,48.6848525 26.3335561,50.6919494 C25.7497772,52.6990464 25.4088681,54.3324462 25.3108289,55.592149 L25.2372995,57.4085163 C29.0296346,54.1661122 33.1751337,51.5524507 37.6737968,49.5675316 C42.1724599,47.5826126 46.2934492,46.3118208 50.0367647,45.7551564 C53.7800802,45.1984919 57.2571301,44.8713684 60.4679144,44.7737858 C63.6786988,44.6762031 66.1831551,44.7726769 67.9812834,45.0632069 L70.6784759,45.499002 L70.6784759,57.4051896 L100,33.3765802 L70.6784759,10 Z M76.4438503,62.4883566 L82.8609626,57.1157685 C82.9099822,57.0669772 82.9946524,57.0303837 83.1149733,57.005988 C83.2352941,56.9815924 83.4536542,56.9571967 83.7700535,56.9328011 C84.0864528,56.9084054 84.3905971,56.9449989 84.6824866,57.0425815 C84.9743761,57.1401641 85.217246,57.2854291 85.4110963,57.4783766 C85.6049465,57.671324 85.7263815,57.8409847 85.7754011,57.9873586 L85.8489305,58.2035928 L85.8489305,90 L0,90 L0,17.910845 L43.1784759,17.910845 C43.2765152,17.9596363 43.410205,18.0317143 43.5795455,18.1270792 C43.7488859,18.222444 43.9438503,18.4519849 44.1644385,18.8157019 C44.3850267,19.1794189 44.469697,19.5542249 44.4184492,19.9401198 C44.4184492,20.2794411 44.3092692,20.582169 44.0909091,20.8483034 C43.872549,21.1144378 43.6664439,21.3206919 43.4725936,21.4670659 L43.1818182,21.6134398 C40.557041,23.06609 38.2954545,24.396762 36.3970588,25.6054558 L30.7820856,29.8170326 L11.5274064,29.8170326 L11.5274064,78.1669993 L74.1811497,78.1669993 L74.1811497,65.5355955 C74.1811497,65.1009093 74.3995098,64.6407186 74.8362299,64.1550233 L76.4438503,62.4883566 Z" id="Shape"></path>
|
|
143
|
+
</g>
|
|
144
|
+
</svg>
|
|
145
|
+
`;class i extends r.WF{static get styles(){return r.AH`
|
|
146
|
+
:host {
|
|
147
|
+
width: var(--iconWidth, 'auto');
|
|
148
|
+
height: var(--iconHeight, 'auto');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.fill-color {
|
|
152
|
+
fill: var(--iconFillColor);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.stroke-color {
|
|
156
|
+
stroke: var(--iconStrokeColor);
|
|
157
|
+
}
|
|
158
|
+
`}render(){return o}}customElements.define("ia-icon-share",i)},5215:function(e,t,n){function r(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}n.d(t,{Cg:function(){return r}}),Object.create,Object.create},706:function(e,t,n){var r=n(350).PROPER,o=n(9039),i=n(7452);e.exports=function(e){return o(function(){return!!i[e]()||"
"!=="
"[e]()||r&&i[e].name!==e})}},8543:function(e,t,n){var r=n(6518),o=n(9565),i=n(7476),a=n(3994),s=n(2529),l=n(7750),c=n(8014),u=n(655),d=n(8551),f=n(34),h=n(2195),p=n(788),g=n(1034),m=n(5966),y=n(6840),v=n(9039),b=n(8227),w=n(2293),k=n(7829),S=n(6682),C=n(1181),E=n(6395),T=b("matchAll"),x="RegExp String",j=x+" Iterator",L=C.set,P=C.getterFor(j),O=RegExp.prototype,M=TypeError,A=i("".indexOf),_=i("".matchAll),R=!!_&&!v(function(){_("a",/./)}),z=a(function(e,t,n,r){L(this,{type:j,regexp:e,string:t,global:n,unicode:r,done:!1})},x,function(){var e=P(this);if(e.done)return s(void 0,!0);var t=e.regexp,n=e.string,r=S(t,n);return null===r?(e.done=!0,s(void 0,!0)):e.global?(""===u(r[0])&&(t.lastIndex=k(n,c(t.lastIndex),e.unicode)),s(r,!1)):(e.done=!0,s(r,!1))}),B=function(e){var t,n,r,o=d(this),i=u(e),a=w(o,RegExp),s=u(g(o));return t=new a(a===RegExp?o.source:o,s),n=!!~A(s,"g"),r=!!~A(s,"u")||!!~A(s,"v"),t.lastIndex=c(o.lastIndex),new z(t,i,n,r)};r({target:"String",proto:!0,forced:R},{matchAll:function(e){var t,n,r,i,a=l(this);if(f(e)){if(p(e)&&(t=u(l(g(e))),!~A(t,"g")))throw new M("`.matchAll` does not allow non-global regexes");if(R)return _(a,e);if(void 0===(r=m(e,T))&&E&&"RegExp"===h(e)&&(r=B),r)return o(r,e,a)}else if(R)return _(a,e);return n=u(a),i=new RegExp(e,"g"),E?o(B,i,n):i[T](n)}}),E||T in O||y(O,T,B)},5906:function(e,t,n){var r=n(6518),o=n(9504),i=n(5397),a=n(8981),s=n(655),l=n(6198),c=o([].push),u=o([].join);r({target:"String",stat:!0},{raw:function(e){var t=i(a(e).raw),n=l(t);if(!n)return"";for(var r=arguments.length,o=[],d=0;;){if(c(o,s(t[d++])),d===n)return u(o,"");d<r&&c(o,s(arguments[d]))}}})},2762:function(e,t,n){var r=n(6518),o=n(3802).trim;r({target:"String",proto:!0,forced:n(706)("trim")},{trim:function(){return o(this)}})},8344:function(e,t,n){n(8543)},1041:function(e,t,n){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,i(r.key),r)}}function i(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}n.d(t,{S:function(){return a}}),n(2675),n(9463),n(2259),n(5700),n(3792),n(9572),n(8130),n(9085),n(6099),n(7764),n(2953);var a=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.br=t,this.options},(t=[{key:"setup",value:function(e){this.options=Object.assign({},this.options,e)}},{key:"init",value:function(){}},{key:"_configurePageContainer",value:function(e){}},{key:"_configureToolbar",value:function(e){}},{key:"_bindNavigationHandlers",value:function(){}},{key:"extendNavBar",value:function(e){}}])&&o(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}()},6735:function(e,t,n){n(2675),n(9463),n(2259),n(8125),n(4782),n(4554),n(4731),n(479),n(9085),n(2811),n(3851),n(875),n(825),n(888),n(8781),n(5700),n(8706),n(2008),n(113),n(3418),n(3792),n(2062),n(9572),n(2010),n(8130),n(6099),n(8459),n(8940),n(3362),n(7495),n(7764),n(5440),n(3500),n(2953);var r=n(420),o=n(1041),i=n(9696),a=(n(739),n(6034),n(4565));"undefined"!=typeof window&&window.Worker||(globalThis.Worker=class{#e;constructor(e){this.#e=new Promise(async t=>{const{Worker:n}=await import("node:worker_threads");t(new n(e))})}addEventListener(e,t){this.#e.then(n=>n.on(e,e=>t({data:e})))}postMessage(e){this.#e.then(t=>t.postMessage(e))}terminate(){this.#e.then(e=>e.terminate())}});class s extends Error{}class l{constructor(e){this.options=e||{},this.registryUrl=this.options.registryUrl||"https://bergamot.s3.amazonaws.com/models/index.json",this.downloadTimeout="downloadTimeout"in this.options?parseInt(this.options.downloadTimeout):6e4,this.registry=this.loadModelRegistery(),this.buffers=new Map,this.pivotLanguage="pivotLanguage"in this.options?e.pivotLanguage:"en",this.models=new Map,this.onerror=this.options.onerror||(e=>console.error("WASM Translation Worker error:",e))}async loadWorker(){const e=this.options.workerUrl?new Worker(this.options.workerUrl):new Worker(new URL(n.p+n.u(474),n.b));let t=0;const r=new Map,o=(n,...o)=>new Promise((i,a)=>{const s=++t;r.set(s,{accept:i,reject:a,callsite:{message:`${n}(${o.map(e=>String(e)).join(", ")})`,stack:(new Error).stack}}),e.postMessage({id:s,name:n,args:o})});return e.addEventListener("message",function({data:{id:e,result:t,error:n}}){if(!r.has(e))throw console.debug("Received message with unknown id:",arguments[0]),new Error(`BergamotTranslator received response from worker to unknown call '${e}'`);const{accept:o,reject:i,callsite:a}=r.get(e);r.delete(e),void 0!==n?i(Object.assign(new Error,n,{message:n.message+` (response to ${a.message})`,stack:n.stack?`${n.stack}\n${a.stack}`:a.stack})):o(t)}),e.addEventListener("error",this.onerror.bind(this)),await o("initialize",this.options),{worker:e,exports:new Proxy({},{get(e,t,n){if("then"!==t)return(...e)=>o(t,...e)}})}}async loadModelRegistery(){const e=await fetch(this.registryUrl,{credentials:"omit"}),t=await e.json();return Array.from(Object.entries(t),([e,t])=>{const n=e.match(/^([a-z]{2}(-[a-z]+)?)([a-z]{2}(-[a-z]+)?)/i);return{from:n[1],to:n[3],files:t}})}getTranslationModel({from:e,to:t},n){const r=JSON.stringify({from:e,to:t});if(!this.buffers.has(r)){const o=this.loadTranslationModel({from:e,to:t},n);this.buffers.set(r,o),o.catch(e=>this.buffers.delete(r))}return this.buffers.get(r)}async loadTranslationModel({from:e,to:t},n){performance.mark(`loadTranslationModule.${JSON.stringify({from:e,to:t})}`);const r=(await this.registry).filter(n=>n.from==e&&n.to==t);if(!r)throw new Error(`No model for '${e}' -> '${t}'`);const o=r[0].files,i=()=>reject(new s("abort signal")),a=new Promise((e,t)=>{n?.signal&&n.signal.addEventListener("abort",i)}),l=Object.fromEntries(await Promise.race([Promise.all(Object.entries(o).map(async([r,o])=>{if(void 0===o||void 0===o.name)return[r,null];try{return[r,await this.fetch(o.name,o.expectedSha256Hash,n)]}catch(n){throw new Error(`Could not fetch ${o.name} for ${e}->${t} model`,{cause:n})}})),a]));n?.signal&&n.signal.removeEventListener("abort",i),performance.measure("loadTranslationModel",`loadTranslationModule.${JSON.stringify({from:e,to:t})}`);let c=[];if(l.vocab)c=[l.vocab];else{if(!l.trgvocab||!l.srcvocab)throw new Error(`Could not identify vocab files for ${e}->${t} model among: ${Array.from(Object.keys(o)).join(" ")}`);c=[l.srcvocab,l.trgvocab]}let u={};return o.model.name.endsWith("intgemm8.bin")&&(u["gemm-precision"]="int8shiftAll"),o.qualityModel&&(u["skip-cost"]=!1),o.config&&Object.assign(u,o.config),{model:l.model,shortlist:l.lex,vocabs:c,qualityModel:l.qualityModel,config:u}}async fetch(e,t,n){const r=new AbortController,o=()=>r.abort(),i=this.downloadTimeout?setTimeout(o,this.downloadTimeout):null;try{n?.signal&&n.signal.addEventListener("abort",o);const i={credentials:"omit",signal:r.signal};t&&(i.integrity=`sha256-${this.hexToBase64(t)}`),"undefined"==typeof window&&delete i.integrity;const a=await fetch(e,i);return await a.arrayBuffer()}finally{i&&clearTimeout(i),n?.signal&&n.signal.removeEventListener("abort",o)}}hexToBase64(e){return btoa(e.match(/\w{2}/g).map(function(e){return String.fromCharCode(parseInt(e,16))}).join(""))}getModels({from:e,to:t}){const n=JSON.stringify({from:e,to:t});return this.models.has(n)||this.models.set(n,this.findModels(e,t)),this.models.get(n)}async findModels(e,t){const n=await this.registry;let r=[],o=[],i=[];if(n.forEach(n=>{n.from===e&&n.to===t?r.push(n):n.from===e&&n.to===this.pivotLanguage?o.push(n):n.to===t&&n.from===this.pivotLanguage&&i.push(n)}),r.length)return[r[0]];if(o.length&&i.length)return[o[0],i[0]];throw new Error(`No model available to translate from '${e}' to '${t}'`)}}class c{constructor(e,t){t||(t=new l(e)),this.backing=t,this.workers=[],this.workerLimit=Math.max(e?.workers||0,1),this.queue=[],this.batchSerial=0,this.batchSize=Math.max(e?.batchSize||8,1),this.onerror=e?.onerror||(e=>console.error("WASM Translation Worker error:",e))}async delete(){this.remove(()=>!0),this.workers.forEach(({worker:e})=>e.terminate())}notify(){setTimeout(async()=>{if(!this.queue.length)return;let e=this.workers.find(e=>e.idle);if(!e&&this.workers.length<this.workerLimit)try{const t={idle:!1};this.workers.push(t),Object.assign(t,await this.backing.loadWorker()),e=t}catch(e){this.onerror(new Error(`Could not initialise translation worker: ${e.message}`))}if(!e)return;const t=this.queue.shift();e.idle=!1;try{await this.consumeBatch(t,e.exports)}catch(e){t.requests.forEach(({reject:t})=>t(e))}e.idle=!0,this.queue.length&&this.notify()})}translate(e){const{from:t,to:n,priority:r}=e;return new Promise(async(o,i)=>{try{const a=JSON.stringify({from:t,to:n}),s=await this.backing.getModels(e);this.enqueue({key:a,models:s,request:e,resolve:o,reject:i,priority:r}),this.notify()}catch(e){i(e)}})}remove(e){const t=this.queue;this.queue=[],t.forEach(t=>{t.requests.forEach(({request:n,resolve:r,reject:o})=>{e(n)?o(Object.assign(new s("removed by filter"),{request:n})):this.enqueue({key:t.key,priority:t.priority,models:t.models,request:n,resolve:r,reject:o})})})}enqueue({key:e,models:t,request:n,resolve:r,reject:o,priority:i}){void 0===i&&(i=0);let a=this.queue.find(t=>t.key===e&&t.priority===i&&t.requests.length<this.batchSize);a||(a={id:++this.batchSerial,key:e,priority:i,models:t,requests:[]},this.queue.push(a),this.queue.sort((e,t)=>e.priority-t.priority)),a.requests.push({request:n,resolve:r,reject:o})}async consumeBatch(e,t){performance.mark("BergamotBatchTranslator.start"),await Promise.all(e.models.map(async({from:e,to:n})=>{if(!await t.hasTranslationModel({from:e,to:n})){const r=await this.backing.getTranslationModel({from:e,to:n});await t.loadTranslationModel({from:e,to:n},r)}}));const n=await t.translate({models:e.models.map(({from:e,to:t})=>({from:e,to:t})),texts:e.requests.map(({request:{text:e,html:t,qualityScores:n}})=>({text:e.toString(),html:!!t,qualityScores:!!n}))});e.requests.forEach(({request:e,resolve:t,reject:r},o)=>{t({request:e,...n[o]})}),performance.measure("BergamotBatchTranslator","BergamotBatchTranslator.start")}}var u=n(4160);function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function f(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var l=r&&r.prototype instanceof s?r:s,c=Object.create(l.prototype);return h(c,"_invoke",function(n,r,o){var i,s,l,c=0,u=o||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return i=t,s=0,l=e,f.n=n,a}};function h(n,r){for(s=n,l=r,t=0;!d&&c&&!o&&t<u.length;t++){var o,i=u[t],h=f.p,p=i[2];n>3?(o=p===r)&&(l=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=h&&((o=n<2&&h<i[1])?(s=0,f.v=r,f.n=i[1]):h<p&&(o=n<3||i[0]>r||r>p)&&(i[4]=n,i[5]=r,f.n=p,s=0))}if(o||n>1)return a;throw d=!0,r}return function(o,u,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===u&&h(u,p),s=u,l=p;(t=s<2?e:l)||!d;){i||(s?s<3?(s>1&&(f.n=-1),h(s,l)):f.n=l:f.v=l);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(d=f.n<0)?l:n.call(r,f))!==a)break}catch(t){i=e,s=1,l=t}finally{c=1}}return{value:t,done:d}}}(n,o,i),!0),c}var a={};function s(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(h(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(u);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,h(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=c,h(d,"constructor",c),h(c,"constructor",l),l.displayName="GeneratorFunction",h(c,o,"GeneratorFunction"),h(d),h(d,o,"Generator"),h(d,r,function(){return this}),h(d,"toString",function(){return"[object Generator]"}),(f=function(){return{w:i,m:p}})()}function h(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}h=function(e,t,n,r){function i(t,n){h(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},h(e,t,n,r)}function p(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function g(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){p(i,r,o,a,s,"next",e)}function s(e){p(i,r,o,a,s,"throw",e)}a(void 0)})}}function m(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,v(r.key),r)}}function y(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e){var t=function(e){if("object"!=d(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=d(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==d(t)?t:t+""}var b,w,k,S,C,E,T,x=function(){return e=function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),y(this,"alreadyTranslated",new a.l(100)),y(this,"modelRegistry",{}),y(this,"currentlyTranslating",{}),y(this,"fromLanguages",[]),y(this,"toLanguages",[]),y(this,"active",!1),y(this,"publicPath",""),y(this,"getTranslation",function(){var e=g(f().m(function e(n,r,o,i,a,s){var l,c,u,d,h;return f().w(function(e){for(;;)switch(e.n){case 0:if(t.active=!0,n!=r&&n&&r){e.n=1;break}return e.a(2);case 1:if(l="".concat(n).concat(r,"-").concat(o,":").concat(i),!(c=t.alreadyTranslated.entries.find(function(e){return e.index==l}))){e.n=2;break}return e.a(2,c.response);case 2:if(!(l in t.currentlyTranslating)){e.n=3;break}return e.a(2,t.currentlyTranslating[l].promise);case 3:if(u=null,d=null,h=new Promise(function(e,t){u=e,d=t}),t.currentlyTranslating[l]={promise:h,resolve:u,reject:d},a){e.n=4;break}return t.currentlyTranslating[l].reject("No text was provided"),e.a(2,h);case 4:return t.translator.translate({to:r,from:n,text:a,html:!1,priority:s}).then(function(e){var n=e;t.currentlyTranslating[l].resolve(n.target.text),t.alreadyTranslated.add({index:l,response:n.target.text}),delete t.currentlyTranslating[l]}),e.a(2,h)}},e)}));return function(t,n,r,o,i,a){return e.apply(this,arguments)}}()),y(this,"getTranslationModel",function(){var e=g(f().m(function e(n,r){return f().w(function(e){for(;;)if(0===e.n)return e.a(2,t.translator.backing.getTranslationModel({from:n,to:r}).catch(function(e){console.error("An error occurred while trying to retreive the ".concat(n,"-").concat(r," model"))}))},e)}));return function(t,n){return e.apply(this,arguments)}}());var n={code:"en",name:"English (en)",type:"prod"};this.fromLanguages.push(n),this.toLanguages.push(n)},t=[{key:"initWorker",value:(n=g(f().m(function e(){var t,n,r,o,i,a,s,l,d,h,p,g,m,y,v,b,w,k,S=this;return f().w(function(e){for(;;)switch(e.n){case 0:if(!this.initPromise){e.n=1;break}return e.a(2,this.initPromise);case 1:return this.initPromise=new Promise(function(e,t){S._initResolve=e,S._initReject=t}),t="https://cors.archive.org/cors/mozilla-translate-models/firefox_models/",e.n=2,fetch(t+"registry.json").then(function(e){return e.json()});case 2:for(n=e.v,r=0,o=Object.values(n);r<o.length;r++)for(i=o[r],a=0,s=Object.values(i);a<s.length;a++)(l=s[a]).name=t+l.name;return this.translator=new c({registryUrl:"data:application/json,".concat(encodeURIComponent(JSON.stringify(n))),workers:2,batchSize:4,workerUrl:this.publicPath+"/translator-worker.js"}),e.n=3,this.translator.backing.registry;case 3:for(d=e.v,h={},p=0,g=Object.values(d);p<g.length;p++)m=g[p],y=m.from,v=m.to,b=m.files,h["".concat(y).concat(v)]=b,"en"!==y&&(w="".concat((0,u._4)(y)," (").concat((0,u.YH)(y),")"),this.fromLanguages.push({code:y,name:w,type:"prod"})),"en"!==v&&(k="".concat((0,u._4)(v)," (").concat((0,u.YH)(v),")"),this.toLanguages.push({code:v,name:k,type:"prod"}));return this._initResolve([this.modelRegistry]),e.a(2,this.initPromise)}},e,this)})),function(){return n.apply(this,arguments)})}],t&&m(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n}(),j=n(8004),L=n(593),P=(n(8248),n(1669));function O(e){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},O(e)}function M(e){return function(e){if(Array.isArray(e))return H(e)}(e)||F(e)||$(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(){A=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach(function(n){t.forEach(function(t){t.kind===n&&"own"===t.placement&&this.defineClassElement(e,t)},this)},this)},initializeClassElements:function(e,t){var n=e.prototype;["method","field"].forEach(function(r){t.forEach(function(t){var o=t.placement;if(t.kind===r&&("static"===o||"prototype"===o)){var i="static"===o?e:n;this.defineClassElement(i,t)}},this)},this)},defineClassElement:function(e,t){var n=t.descriptor;if("field"===t.kind){var r=t.initializer;n={enumerable:n.enumerable,writable:n.writable,configurable:n.configurable,value:void 0===r?void 0:r.call(e)}}Object.defineProperty(e,t.key,n)},decorateClass:function(e,t){var n=[],r=[],o={static:[],prototype:[],own:[]};if(e.forEach(function(e){this.addElementPlacement(e,o)},this),e.forEach(function(e){if(!z(e))return n.push(e);var t=this.decorateElement(e,o);n.push(t.element),n.push.apply(n,t.extras),r.push.apply(r,t.finishers)},this),!t)return{elements:n,finishers:r};var i=this.decorateConstructor(n,t);return r.push.apply(r,i.finishers),i.finishers=r,i},addElementPlacement:function(e,t,n){var r=t[e.placement];if(!n&&-1!==r.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");r.push(e.key)},decorateElement:function(e,t){for(var n=[],r=[],o=e.decorators,i=o.length-1;i>=0;i--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,o[i])(s)||s);e=l.element,this.addElementPlacement(e,t),l.finisher&&r.push(l.finisher);var c=l.extras;if(c){for(var u=0;u<c.length;u++)this.addElementPlacement(c[u],t);n.push.apply(n,c)}}return{element:e,finishers:r,extras:n}},decorateConstructor:function(e,t){for(var n=[],r=t.length-1;r>=0;r--){var o=this.fromClassDescriptor(e),i=this.toClassDescriptor((0,t[r])(o)||o);if(void 0!==i.finisher&&n.push(i.finisher),void 0!==i.elements){e=i.elements;for(var a=0;a<e.length-1;a++)for(var s=a+1;s<e.length;s++)if(e[a].key===e[s].key&&e[a].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:n}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||F(t)||$(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map(function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t},this);var t},toElementDescriptor:function(e){var t=e.kind+"";if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var n=re(e.key),r=e.placement+"";if("static"!==r&&"prototype"!==r&&"own"!==r)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+r+'"');var o=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var i={kind:t,key:n,placement:r,descriptor:Object.assign({},o)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(o,"get","The property descriptor of a field descriptor"),this.disallowProperty(o,"set","The property descriptor of a field descriptor"),this.disallowProperty(o,"value","The property descriptor of a field descriptor"),i.initializer=e.initializer),i},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:I(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=e.kind+"";if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var n=I(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:n}},runClassFinishers:function(e,t){for(var n=0;n<t.length;n++){var r=(0,t[n])(e);if(void 0!==r){if("function"!=typeof r)throw new TypeError("Finishers must return a constructor.");e=r}}return e},disallowProperty:function(e,t,n){if(void 0!==e[t])throw new TypeError(n+" can't have a ."+t+" property.")}};return e}function _(e){var t,n=re(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var r={kind:"field"===e.kind?"field":"method",key:n,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(r.decorators=e.decorators),"field"===e.kind&&(r.initializer=e.value),r}function R(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function z(e){return e.decorators&&e.decorators.length}function B(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function I(e,t){var n=e[t];if(void 0!==n&&"function"!=typeof n)throw new TypeError("Expected '"+t+"' to be a function");return n}function F(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function D(){return D="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=Q(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(arguments.length<3?e:n):o.value}},D.apply(null,arguments)}function N(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function q(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=$(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function $(e,t){if(e){if("string"==typeof e)return H(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?H(e,t):void 0}}function H(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function G(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var l=r&&r.prototype instanceof s?r:s,c=Object.create(l.prototype);return W(c,"_invoke",function(n,r,o){var i,s,l,c=0,u=o||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return i=t,s=0,l=e,f.n=n,a}};function h(n,r){for(s=n,l=r,t=0;!d&&c&&!o&&t<u.length;t++){var o,i=u[t],h=f.p,p=i[2];n>3?(o=p===r)&&(l=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=h&&((o=n<2&&h<i[1])?(s=0,f.v=r,f.n=i[1]):h<p&&(o=n<3||i[0]>r||r>p)&&(i[4]=n,i[5]=r,f.n=p,s=0))}if(o||n>1)return a;throw d=!0,r}return function(o,u,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===u&&h(u,p),s=u,l=p;(t=s<2?e:l)||!d;){i||(s?s<3?(s>1&&(f.n=-1),h(s,l)):f.n=l:f.v=l);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(d=f.n<0)?l:n.call(r,f))!==a)break}catch(t){i=e,s=1,l=t}finally{c=1}}return{value:t,done:d}}}(n,o,i),!0),c}var a={};function s(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(W(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,W(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=c,W(d,"constructor",c),W(c,"constructor",l),l.displayName="GeneratorFunction",W(c,o,"GeneratorFunction"),W(d),W(d,o,"Generator"),W(d,r,function(){return this}),W(d,"toString",function(){return"[object Generator]"}),(G=function(){return{w:i,m:f}})()}function W(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}W=function(e,t,n,r){function i(t,n){W(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},W(e,t,n,r)}function K(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function U(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){K(i,r,o,a,s,"next",e)}function s(e){K(i,r,o,a,s,"throw",e)}a(void 0)})}}function Z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function V(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,re(r.key),r)}}function J(e,t,n){return t&&V(e.prototype,t),n&&V(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Y(e,t,n){return t=Q(t),function(e,t){if(t&&("object"==O(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,X()?Reflect.construct(t,n||[],Q(e).constructor):t.apply(e,n))}function X(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(X=function(){return!!e})()}function Q(e){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Q(e)}function ee(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&te(e,t)}function te(e,t){return te=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},te(e,t)}function ne(e,t,n){return(t=re(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function re(e){var t=function(e){if("object"!=O(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=O(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==O(t)?t:t+""}var oe,ie,ae,se,le,ce,ue,de=window.BookReader,fe=function(e){function t(){var e;Z(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return ne(e=Y(this,t,[].concat(r)),"options",{enabled:!0,panelDisclaimerText:"Translations are in alpha"}),ne(e,"translationManager",new x),ne(e,"worker",void 0),ne(e,"toLanguages",[]),ne(e,"langFromCode",void 0),ne(e,"langToCode",void 0),ne(e,"_panel",void 0),ne(e,"userToggleTranslate",void 0),ne(e,"loadingModel",!0),ne(e,"textSelectionManager",new L.bg(".BRtranslateLayer",e.br,{selectionElement:[".BRlineElement"]},1)),ne(e,"getParagraphsOnPage",function(e){return e?Array.from(e.querySelectorAll(".BRtextLayer > .BRparagraphElement")):[]}),ne(e,"handleFromLangChange",function(){var t=U(G().m(function t(n){var r;return G().w(function(t){for(;;)switch(t.n){case 0:e.clearAllTranslations(),r=n.detail.value,e.langFromCode=r,e._panel.requestUpdate(),e.translationManager.toLanguages.some(function(e){return e.code===r})||e.translationManager.toLanguages.push({code:r,name:e.translationManager.fromLanguages.find(function(e){return e.code==r}).name}),e._panel.toLanguages=e.translationManager.toLanguages,console.log(e.langFromCode,e.langToCode),e._render(),e.langFromCode!==e.langToCode&&e.translateActivePageContainerElements();case 1:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}()),ne(e,"handleToLangChange",function(){var t=U(G().m(function t(n){return G().w(function(t){for(;;)switch(t.n){case 0:e.clearAllTranslations(),e.langToCode=n.detail.value,e._render(),e.translateActivePageContainerElements();case 1:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}()),ne(e,"handleToggleTranslation",U(G().m(function t(){return G().w(function(t){for(;;)switch(t.n){case 0:e.userToggleTranslate=!e.userToggleTranslate,e.translationManager.active=e.userToggleTranslate,e._render(),e.userToggleTranslate?(e.br.trigger("translationEnabled",{}),e.translateActivePageContainerElements(),e.textSelectionManager.attach()):(e.clearAllTranslations(),e.br.trigger("translationDisabled",{}),e.textSelectionManager.detach());case 1:return t.a(2)}},t)}))),e}return ee(t,e),J(t,[{key:"init",value:(i=U(G().m(function e(){var t,n=this;return G().w(function(e){for(;;)switch(e.n){case 0:if(t=(0,u.YH)(this.br.options.bookLanguage.replace(/[.,/#!$%^&*;:{}=\-_`~()]/g,"")),this.langFromCode=null!=t?t:"en",this.textSelectionManager.init(),this.options.enabled){e.n=1;break}return e.a(2);case 1:return this.translationManager.publicPath=this.br.options.imagesBaseURL.replace(/\/+$/,"")+"/..",this.br.on("textLayerRendered",function(){var e=U(G().m(function e(t,r){var o,i;return G().w(function(e){for(;;)switch(e.n){case 0:if(r.pageIndex,o=r.pageContainer,n.translationManager){e.n=1;break}return e.a(2);case 1:n.translationManager.active&&(i=o.$container[0],n.translateRenderedLayer(i));case 2:return e.a(2)}},e)}));return function(t,n){return e.apply(this,arguments)}}()),this.br.on("pageVisible",function(e,t){var r=t.pageContainerEl;if(n.translationManager.active){var o,i=q(r.querySelectorAll(".BRtranslateLayer > .BRparagraphElement"));try{for(i.s();!(o=i.n()).done;){var a=o.value;a.textContent&&n.fitVisiblePage(a)}}catch(e){i.e(e)}finally{i.f()}}}),e.n=2,this.translationManager.initWorker();case 2:this.langToCode=this.translationManager.toLanguages[0].code,this._render();case 3:return e.a(2)}},e,this)})),function(){return i.apply(this,arguments)})},{key:"translateActivePageContainerElements",value:function(){var e,t=this.br.getActivePageContainerElements(),n=t.filter(function(e){return e.classList.contains("BRpage-visible")}),r=t.filter(function(e){return!e.classList.contains("BRpage-visible")}),o=q(n);try{for(o.s();!(e=o.n()).done;){var i=e.value;this.translateRenderedLayer(i,0)}}catch(e){o.e(e)}finally{o.f()}var a,s=q(r);try{for(s.s();!(a=s.n()).done;){var l=a.value;this.translateRenderedLayer(l,1e3)}}catch(e){s.e(e)}finally{s.f()}}},{key:"translateRenderedLayer",value:(o=U(G().m(function e(t,n){var r,o,i,a,s,l,c=this;return G().w(function(e){for(;;)switch(e.n){case 0:if(this.br.mode!=this.br.constModeThumb&&this.userToggleTranslate&&this.langFromCode!=this.langToCode){e.n=1;break}return e.a(2);case 1:return o=t.dataset.index,t.querySelector(".BRPageLayer.BRtranslateLayer")?i=t.querySelector(".BRPageLayer.BRtranslateLayer"):((i=document.createElement("div")).classList.add("BRPageLayer","BRtranslateLayer","BRtranslateLayerLoading"),i.setAttribute("lang","".concat(this.langToCode)),t.prepend(i)),a=t.querySelector(".BRtextLayer"),P(i).css({width:a.style.width,height:a.style.height,transform:a.style.transform,"pointer-events":a.style.pointerEvents,"z-index":3}),a.classList.add("showingTranslation"),s=this.getParagraphsOnPage(t),l=s.map(function(){var e=U(G().m(function e(r,a){var l,u,d,f,h,p,g,m,y;return G().w(function(e){for(;;)switch(e.n){case 0:if((l=t.querySelector("[data-translate-index='".concat(o,"-").concat(a,"']")))||((l=document.createElement("p")).setAttribute("data-translate-index","".concat(o,"-").concat(a)),l.className="BRparagraphElement",u=s[a],r.classList.contains("ocr-role-header-footer")&&(l.ariaHidden="true",l.classList.add("ocr-role-header-footer")),d="".concat(parseInt(P(u).css("font-size")),"px"),P(l).css({"margin-left":P(u).css("margin-left"),"margin-top":P(u).css("margin-top"),top:P(u).css("top"),height:P(u).css("height"),width:P(u).css("width"),"font-size":d}),i.append(l)),0===r.textContent.length){e.n=2;break}return p=parseFloat(o)+n+a,c.translationManager.getTranslationModel(c.langFromCode,c.langToCode).then(function(){c._panel.loadingModel=!1,c.loadingModel=!1}),e.n=1,c.translationManager.getTranslation(c.langFromCode,c.langToCode,o,a,r.textContent,p);case 1:g=e.v,null===(f=l.firstElementChild)||void 0===f||f.remove(),m=null===(h=s[a])||void 0===h||null===(h=h.firstChild)||void 0===h?void 0:h.firstChild,(y=document.createElement("span")).className="BRlineElement",y.textContent=g,l.appendChild(y),P(y).css({"text-indent":P(m).css("padding-left")}),t.classList.contains("BRpage-visible")&&c.fitVisiblePage(l);case 2:return e.a(2)}},e)}));return function(t,n){return e.apply(this,arguments)}}()),null===(r=this.textSelectionManager)||void 0===r||r.stopPageFlip(this.br.refs.$brContainer),e.n=2,Promise.all(l);case 2:this.br.trigger("translateLayerRendered",{leafIndex:o,translateLayer:i});case 3:return e.a(2)}},e,this)})),function(e,t){return o.apply(this,arguments)})},{key:"getTranslateLayers",value:(n=U(G().m(function e(t){var n,r,o=this;return G().w(function(e){for(;;)switch(e.n){case 0:if(n=this.br.getActivePageContainerElementsForIndex(t),!(r=P(n).filter("[data-index='".concat(t,"']")).find(".BRtranslateLayer")).length){e.n=1;break}return e.a(2,r.toArray());case 1:return e.a(2,new Promise(function(e,n){var r=function(){var n=U(G().m(function n(i,a){return G().w(function(n){for(;;)switch(n.n){case 0:a.leafIndex==t&&(o.br.off("translateLayerRendered",r),e([a.translateLayer]));case 1:return n.a(2)}},n)}));return function(e,t){return n.apply(this,arguments)}}();o.br.on("translateLayerRendered",r)}))}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"clearAllTranslations",value:function(){document.querySelectorAll(".BRtranslateLayer").forEach(function(e){return e.remove()}),document.querySelectorAll(".showingTranslation").forEach(function(e){return e.classList.remove("showingTranslation")})}},{key:"fitVisiblePage",value:function(e){for(var t=parseInt(P(e).css("font-size"));e.clientHeight<e.scrollHeight&&t>0;)t--,P(e).css({"font-size":"".concat(t,"px")});var n=e.firstElementChild.clientHeight,r=e.scrollHeight;if(n<r){var o=r/(n/t);P(e).css({"line-height":"".concat(o,"px"),overflow:"visible"})}}},{key:"_render",value:function(){var e=this;this.br.shell.menuProviders.translate={id:"translate",icon:(0,r.qy)(b||(b=N(["<img src='",'/translate.svg\' width="26"/>'])),this.br.options.imagesBaseURL),label:"Translate",component:(0,r.qy)(w||(w=N(['<br-translate-panel\n @connected="','"\n @langFromChanged="','"\n @langToChanged="','"\n @toggleTranslation="','"\n .fromLanguages="','"\n .toLanguages="','"\n .disclaimerMessage="','"\n .userTranslationActive=',"\n .detectedFromLang=","\n .detectedToLang=","\n .loadingModel=",'\n class="translate-panel"\n />'])),function(t){e._panel=t.target,e._panel.fromLanguages=e.translationManager.fromLanguages,e._panel.toLanguages=e.translationManager.toLanguages,e._panel.userTranslationActive=e.userToggleTranslate,e._panel.detectedToLang=e.langToCode,e._panel.detectedFromLang=e.langFromCode,e._panel.loadingModel=e.loadingModel},this.handleFromLangChange,this.handleToLangChange,this.handleToggleTranslation,this.translationManager.fromLanguages,this.translationManager.toLanguages,this.options.panelDisclaimerText,this.userToggleTranslate,this.langFromCode,this.langToCode,this.loadingModel)},this.br.shell.updateMenuContents()}}]);var n,o,i}(o.S);null==de||de.registerPlugin("translate",fe),oe=[(0,i.EM)("br-translate-panel")],ie=r.WF,le=A(),ae=function(e){le.initializeInstanceElements(e,ue.elements)},se=function(e){function t(){var e;Z(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e=Y(this,t,[].concat(r)),ae(e),e}return ee(t,e),J(t)}(ie),ce={F:se,d:[{kind:"field",decorators:[(0,i.MZ)({type:Array})],key:"fromLanguages",value:function(){return[]}},{kind:"field",decorators:[(0,i.MZ)({type:Array})],key:"toLanguages",value:function(){return[]}},{kind:"field",decorators:[(0,i.MZ)({type:String})],key:"prevSelectedLang",value:function(){return""}},{kind:"field",decorators:[(0,i.MZ)({type:String})],key:"disclaimerMessage",value:function(){return""}},{kind:"field",decorators:[(0,i.MZ)({type:Boolean})],key:"userTranslationActive",value:function(){return!1}},{kind:"field",decorators:[(0,i.MZ)({type:String})],key:"detectedFromLang",value:function(){return""}},{kind:"field",decorators:[(0,i.MZ)({type:String})],key:"detectedToLang",value:function(){return""}},{kind:"field",decorators:[(0,i.MZ)({type:Boolean})],key:"loadingModel",value:void 0},{kind:"method",key:"createRenderRoot",value:function(){return this}},{kind:"method",key:"connectedCallback",value:function(){var e,t,n,r,o;(e=se,t="connectedCallback",n=this,o=D(Q(1&(r=3)?e.prototype:e),t,n),2&r&&"function"==typeof o?function(e){return o.apply(n,e)}:o)([]),this.dispatchEvent(new CustomEvent("connected"))}},{kind:"method",key:"render",value:function(){var e=this;return(0,r.qy)(k||(k=N(['<div class="app" style="margin-top: 5%;padding-right: 5px;">\n <div\n class="disclaimer"\n id="disclaimerMessage"\n style="background-color: rgba(255,255,255,0.1);padding: 10px;border-radius: 8px;font-size: 12px;margin-bottom: 10px;color: rgba(255,255,255, 0.9);"\n >','</div>\n\n <div class="panel panel--to" style="padding: 0 10px;">\n <label>\n <span style="font-size: 12px;color: #ccc;">Translate To</span>\n <select id="lang-to" name="to" class="lang-select" style="display:block; width:100%;" @change="','">\n ','\n </select>\n </label>\n </div>\n\n <div class="panel panel--start" style="text-align: right;padding: 0 10px;/*! font-size: 18px; */margin-top: 10px;">\n <button class="start-translation-brn" @click="','">\n ','\n </button>\n </div>\n\n <div class="panel panel--from" style="font-size: 12px;color: #ccc;text-align: center;padding: 8px 10px;">\n <details style="display: contents">\n <summary style="text-decoration: underline white; cursor:pointer; display:inline-block"> \n <i>\n Source: '," ",' \n </i> Change \n </summary>\n <select id="lang-from" name="from" class="lang-select" value=',' @change="','" style="width:65%; margin-top: 3%; margin-bottom: 3%">\n ','\n </select>\n </details>\n <div class="footer" id="status" style="margin-top:5%">\n ','\n </div>\n\n <div class="lang-models-loading"> \n ',"\n </div>\n </div>"])),this.disclaimerMessage,this._onLangToChange,(0,j.sortBy)(this.toLanguages,function(e){return e.name.toLowerCase()}).map(function(t){return(0,r.qy)(S||(S=N(['<option value="','" \n ?selected=',"\n > "," </option>"])),t.code,t.code==e.detectedToLang,t.name?t.name:t.code)}),this._toggleTranslation,this.userTranslationActive?"Stop Translating":"Translate",this._getLangName(this.detectedFromLang),this.prevSelectedLang?"":"(detected)",this.detectedFromLang,this._onLangFromChange,(0,j.sortBy)(this.fromLanguages,function(e){return e.name.toLowerCase()}).map(function(t){return(0,r.qy)(C||(C=N(['<option value="','"\n ?selected=',"\n >"," </option>"])),t.code,t.code==e.detectedFromLang,t.name?t.name:t.code)}),this._statusWarning(),this._languageModelStatus())}},{kind:"method",key:"_onLangFromChange",value:function(e){var t=new CustomEvent("langFromChanged",{detail:{value:e.target.value},bubbles:!0,composed:!0});this.dispatchEvent(t),this._getSelectedLang("to")!==this._getSelectedLang("from")&&(this.prevSelectedLang=this._getSelectedLang("from")),this.loadingModel=!0,this.detectedFromLang=e.target.value}},{kind:"method",key:"_onLangToChange",value:function(e){var t=new CustomEvent("langToChanged",{detail:{value:e.target.value},bubbles:!0,composed:!0});this.dispatchEvent(t),this._getSelectedLang("from")!==e.target.value&&(this.prevSelectedLang=this._getSelectedLang("from")),this.loadingModel=!0,this.detectedToLang=e.target.value}},{kind:"method",key:"_getSelectedLang",value:function(e){var t=this.querySelector("#lang-".concat(e));return t?t.value:""}},{kind:"method",key:"_getLangName",value:function(e){var t=[].concat(M(this.fromLanguages),M(this.toLanguages)).find(function(t){return t.code===e});return t?t.name:""}},{kind:"method",key:"_toggleTranslation",value:function(e){var t=new CustomEvent("toggleTranslation",{detail:{value:e.target.value},bubbles:!0,composed:!0});this.userTranslationActive=!this.userTranslationActive,this.dispatchEvent(t)}},{kind:"method",key:"_statusWarning",value:function(){return this.detectedFromLang==this.detectedToLang?"Translate To language is the same as the Source language":""}},{kind:"method",key:"_languageModelStatus",value:function(){return this.userTranslationActive?this.loadingModel?(0,r.qy)(E||(E=N(['\n <ia-activity-indicator mode="processing" style="display:block; width: 40px; height: 40px; margin: 0 auto;"></ia-activity-indicator>\n <p>Downloading language model</p>\n ']))):(0,r.qy)(T||(T=N(["<p>Language model loaded</p>"]))):""}}]},ue=le.decorateClass(function(e){for(var t=[],n=function(e){return"method"===e.kind&&e.key===i.key&&e.placement===i.placement},r=0;r<e.length;r++){var o,i=e[r];if("method"===i.kind&&(o=t.find(n)))if(B(i.descriptor)||B(o.descriptor)){if(z(i)||z(o))throw new ReferenceError("Duplicated methods ("+i.key+") can't be decorated.");o.descriptor=i.descriptor}else{if(z(i)){if(z(o))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+i.key+").");o.decorators=i.decorators}R(i,o)}else t.push(i)}return t}(ce.d.map(_)),oe),le.initializeClassElements(ce.F,ue.elements),le.runClassFinishers(ce.F,ue.finishers)},4160:function(e,t,n){n.d(t,{$x:function(){return y},EF:function(){return u},ND:function(){return m},m0:function(){return d},YH:function(){return h},_4:function(){return p}}),n(2675),n(9463),n(2259),n(3418),n(4423),n(3792),n(4782),n(2010),n(875),n(6099),n(3362),n(7495),n(8781),n(1699),n(7764),n(1761),n(2953);var r=[],o={},i={},a={};[["Serbian","српски језик","sr","srp","srp"],["Romanian, Moldavian, Moldovan","Română","ro","ron","rum"],["Sichuan Yi, Nuosu","ꆈꌠ꒿ Nuosuhxop","ii","iii","iii"],["Tahitian","Reo Tahiti","ty","tah","tah"],["Tagalog","Wikang Tagalog","tl","tgl","tgl"],["Yiddish","ייִדיש","yi","yid","yid"],["Akan","Akan","ak","aka","aka"],["Malay","Bahasa Melayu, بهاس ملايو","ms","msa","may"],["Arabic","العربية","ar","ara","ara"],["Norwegian","Norsk","no","nor","nor"],["Ojibwa","ᐊᓂᔑᓈᐯᒧᐎᓐ","oj","oji","oji"],["Fulah","Fulfulde, Pulaar, Pular","ff","ful","ful"],["Persian","فارسی","fa","fas","per"],["Albanian","Shqip","sq","sqi","alb"],["Aymara","aymar aru","ay","aym","aym"],["Azerbaijani","azərbaycan dili","az","aze","aze"],["Chinese","中文 (Zhōngwén), 汉语, 漢語","zh","zho","chi"],["Cree","ᓀᐦᐃᔭᐍᐏᐣ","cr","cre","cre"],["Estonian","eesti, eesti keel","et","est","est"],["Guaraní","Avañe'ẽ","gn","grn","grn"],["Inupiaq","Iñupiaq, Iñupiatun","ik","ipk","ipk"],["Inuktitut","ᐃᓄᒃᑎᑐᑦ","iu","iku","iku"],["Kanuri","Kanuri","kr","kau","kau"],["Komi","коми кыв","kv","kom","kom"],["Kongo","Kikongo","kg","kon","kon"],["Kurdish","Kurdî, أۇزبېك","ku","kur","kur"],["Latvian","latviešu valoda","lv","lav","lav"],["Malagasy","fiteny malagasy","mg","mlg","mlg"],["Mongolian","Монгол хэл","mn","mon","mon"],["Oromo","Afaan Oromoo","om","orm","orm"],["Pashto, Pushto","پښتو","ps","pus","pus"],["Quechua","Runa Simi, Kichwa","qu","que","que"],["Sardinian","sardu","sc","srd","srd"],["Swahili","Kiswahili","sw","swa","swa"],["Uzbek","Oʻzbek, Ўзбек, ","uz","uzb","uzb"],["Zhuang, Chuang","Saɯ cueŋƅ, Saw cuengh","za","zha","zha"],["Bislama","Bislama","bi","bis","bis"],["Norwegian Bokmål","Norsk Bokmål","nb","nob","nob"],["Norwegian Nynorsk","Norsk Nynorsk","nn","nno","nno"],["Indonesian","Bahasa Indonesia","id","ind","ind"],["Twi","Twi","tw","twi","twi"],["Esperanto","Esperanto","eo","epo","epo"],["Interlingua","Interlingua","ia","ina","ina"],["Interlingue","Originally called Occidental; then Interlingue after WWII","ie","ile","ile"],["Ido","Ido","io","ido","ido"],["Volapük","Volapük","vo","vol","vol"],["Bihari languages","भोजपुरी","bh","bih","bih"],["Hebrew (modern)","עברית","he","heb","heb"],["Sanskrit","संस्कृतम्","sa","san","san"],["Church Slavic, Church Slavonic, Old Church Slavonic, Old Slavonic, Old Bulgarian","ѩзыкъ словѣньскъ","cu","chu","chu"],["Pali","पाऴि","pi","pli","pli"],["Avestan","avesta","ae","ave","ave"],["Latin","latine, lingua latina","la","lat","lat"],["Armenian","Հայերեն","hy","hye","arm"],["Swati","SiSwati","ss","ssw","ssw"],["Tibetan","བོད་ཡིག","bo","bod","tib"],["South Ndebele","isiNdebele","nr","nbl","nbl"],["Slovene","Slovenski Jezik, Slovenščina","sl","slv","slv"],["Oriya","ଓଡ଼ିଆ","or","ori","ori"],["North Ndebele","isiNdebele","nd","nde","nde"],["Nauru","Dorerin Naoero","na","nau","nau"],["Maori","te reo Māori","mi","mri","mao"],["Marathi","मराठी","mr","mar","mar"],["Luba-Katanga","Kiluba","lu","lub","lub"],["Rundi","Ikirundi","rn","run","run"],["Central Khmer","ខ្មែរ, ខេមរភាសា, ភាសាខ្មែរ","km","khm","khm"],["Western Frisian","Frysk","fy","fry","fry"],["Bengali","বাংলা","bn","ben","ben"],["Avaric","авар мацӀ, магӀарул мацӀ","av","ava","ava"],["Abkhazian","аҧсуа бызшәа, аҧсшәа","ab","abk","abk"],["Afar","Afaraf","aa","aar","aar"],["Afrikaans","Afrikaans","af","afr","afr"],["Amharic","አማርኛ","am","amh","amh"],["Aragonese","aragonés","an","arg","arg"],["Assamese","অসমীয়া","as","asm","asm"],["Bambara","bamanankan","bm","bam","bam"],["Bashkir","башҡорт теле","ba","bak","bak"],["Basque","euskara, euskera","eu","eus","baq"],["Belarusian","беларуская мова","be","bel","bel"],["Bosnian","bosanski jezik","bs","bos","bos"],["Breton","brezhoneg","br","bre","bre"],["Bulgarian","български език","bg","bul","bul"],["Burmese","ဗမာစာ","my","mya","bur"],["Catalan, Valencian","català, valencià","ca","cat","cat"],["Chamorro","Chamoru","ch","cha","cha"],["Chechen","нохчийн мотт","ce","che","che"],["Chichewa, Chewa, Nyanja","chiCheŵa, chinyanja","ny","nya","nya"],["Chuvash","чӑваш чӗлхи","cv","chv","chv"],["Cornish","Kernewek","kw","cor","cor"],["Corsican","corsu, lingua corsa","co","cos","cos"],["Croatian","hrvatski jezik","hr","hrv","hrv"],["Czech","čeština, český jazyk","cs","ces","cze"],["Danish","dansk","da","dan","dan"],["Divehi, Dhivehi, Maldivian","ދިވެހި","dv","div","div"],["Dutch, Flemish","Nederlands, Vlaams","nl","nld","dut"],["Dzongkha","རྫོང་ཁ","dz","dzo","dzo"],["English","English","en","eng","eng"],["Ewe","Eʋegbe","ee","ewe","ewe"],["Faroese","føroyskt","fo","fao","fao"],["Fijian","vosa Vakaviti","fj","fij","fij"],["Finnish","suomi, suomen kieli","fi","fin","fin"],["French","français, langue française","fr","fra","fre"],["Galician","Galego","gl","glg","glg"],["Georgian","ქართული","ka","kat","geo"],["German","Deutsch","de","deu","ger"],["Greek (modern)","ελληνικά","el","ell","gre"],["Gujarati","ગુજરાતી","gu","guj","guj"],["Haitian, Haitian Creole","Kreyòl ayisyen","ht","hat","hat"],["Hausa","(Hausa) هَوُسَ","ha","hau","hau"],["Herero","Otjiherero","hz","her","her"],["Hindi","हिन्दी, हिंदी","hi","hin","hin"],["Hiri Motu","Hiri Motu","ho","hmo","hmo"],["Hungarian","magyar","hu","hun","hun"],["Irish","Gaeilge","ga","gle","gle"],["Igbo","Asụsụ Igbo","ig","ibo","ibo"],["Icelandic","Íslenska","is","isl","ice"],["Italian","Italiano","it","ita","ita"],["Japanese","日本語 (にほんご)","ja","jpn","jpn"],["Javanese","ꦧꦱꦗꦮ, Basa Jawa","jv","jav","jav"],["Kalaallisut, Greenlandic","kalaallisut, kalaallit oqaasii","kl","kal","kal"],["Kannada","ಕನ್ನಡ","kn","kan","kan"],["Kashmiri","कश्मीरी, كشميري","ks","kas","kas"],["Kazakh","қазақ тілі","kk","kaz","kaz"],["Kikuyu, Gikuyu","Gĩkũyũ","ki","kik","kik"],["Kinyarwanda","Ikinyarwanda","rw","kin","kin"],["Kirghiz, Kyrgyz","Кыргызча, Кыргыз тили","ky","kir","kir"],["Korean","한국어","ko","kor","kor"],["Kuanyama, Kwanyama","Kuanyama","kj","kua","kua"],["Luxembourgish, Letzeburgesch","Lëtzebuergesch","lb","ltz","ltz"],["Ganda","Luganda","lg","lug","lug"],["Limburgan, Limburger, Limburgish","Limburgs","li","lim","lim"],["Lingala","Lingála","ln","lin","lin"],["Lao","ພາສາລາວ","lo","lao","lao"],["Lithuanian","lietuvių kalba","lt","lit","lit"],["Manx","Gaelg, Gailck","gv","glv","glv"],["Macedonian","македонски јазик","mk","mkd","mac"],["Malayalam","മലയാളം","ml","mal","mal"],["Maltese","Malti","mt","mlt","mlt"],["Marshallese","Kajin M̧ajeļ","mh","mah","mah"],["Navajo, Navaho","Diné bizaad","nv","nav","nav"],["Nepali","नेपाली","ne","nep","nep"],["Ndonga","Owambo","ng","ndo","ndo"],["Occitan","occitan, lenga d'òc","oc","oci","oci"],["Ossetian, Ossetic","ирон æвзаг","os","oss","oss"],["Panjabi, Punjabi","ਪੰਜਾਬੀ","pa","pan","pan"],["Polish","język polski, polszczyzna","pl","pol","pol"],["Portuguese","Português","pt","por","por"],["Romansh","Rumantsch Grischun","rm","roh","roh"],["Russian","русский","ru","rus","rus"],["Sindhi","सिन्धी, سنڌي، سندھی","sd","snd","snd"],["Northern Sami","Davvisámegiella","se","sme","sme"],["Samoan","gagana fa'a Samoa","sm","smo","smo"],["Sango","yângâ tî sängö","sg","sag","sag"],["Gaelic, Scottish Gaelic","Gàidhlig","gd","gla","gla"],["Shona","chiShona","sn","sna","sna"],["Sinhala, Sinhalese","සිංහල","si","sin","sin"],["Slovak","Slovenčina, Slovenský Jazyk","sk","slk","slo"],["Somali","Soomaaliga, af Soomaali","so","som","som"],["Southern Sotho","Sesotho","st","sot","sot"],["Spanish, Castilian","Español","es","spa","spa"],["Sundanese","Basa Sunda","su","sun","sun"],["Swedish","Svenska","sv","swe","swe"],["Tamil","தமிழ்","ta","tam","tam"],["Telugu","తెలుగు","te","tel","tel"],["Tajik","тоҷикӣ, toçikī, تاجیکی","tg","tgk","tgk"],["Thai","ไทย","th","tha","tha"],["Tigrinya","ትግርኛ","ti","tir","tir"],["Turkmen","Türkmen, Түркмен","tk","tuk","tuk"],["Tswana","Setswana","tn","tsn","tsn"],["Tongan (Tonga Islands)","Faka Tonga","to","ton","ton"],["Turkish","Türkçe","tr","tur","tur"],["Tsonga","Xitsonga","ts","tso","tso"],["Tatar","татар теле, tatar tele","tt","tat","tat"],["Uighur, Uyghur","ئۇيغۇرچە, Uyghurche","ug","uig","uig"],["Ukrainian","Українська","uk","ukr","ukr"],["Urdu","اردو","ur","urd","urd"],["Venda","Tshivenḓa","ve","ven","ven"],["Vietnamese","Tiếng Việt","vi","vie","vie"],["Walloon","Walon","wa","wln","wln"],["Welsh","Cymraeg","cy","cym","wel"],["Wolof","Wollof","wo","wol","wol"],["Xhosa","isiXhosa","xh","xho","xho"],["Yoruba","Yorùbá","yo","yor","yor"],["Zulu","isiZulu","zu","zul","zul"]].forEach(e=>{var t={name:e[0],nativeName:e[1],iso639_1:e[2],iso639_2T:e[3],iso639_2B:e[4]};o[e[2]]=i[e[3]]=a[e[4]]=t,r.push(t)});var s=r;function l(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return c(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function u(e){var t=e.match(/\S+/g);return t?t.length:0}function d(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:navigator.userAgent;return/android/i.test(e)}var f={"zh-hans":"中文 (Zhōngwén)"};function h(e){if(!e)return null;if(e=e.toLocaleLowerCase(),f[e])return e;var t=g(e,["iso639_1"])||g(e,["iso639_2T"])||g(e,["iso639_2B","name","nativeName"]);return t?t.iso639_1:null}function p(e){if(!e)return null;if(e=e.toLocaleLowerCase(),f[e])return f[e];var t=g(e,["iso639_1"])||g(e,["iso639_2T"])||g(e,["iso639_2B","name","nativeName"]);return null!=t&&t.nativeName?t.nativeName.split(", ")[0]:null}function g(e,t){if(!e)return null;e=e.toLowerCase();var n,r=l(s);try{for(r.s();!(n=r.n()).done;){var o,i=n.value,a=l(t);try{for(a.s();!(o=a.n()).done;){var c;if(null!==(c=i[o.value])&&void 0!==c&&c.toLowerCase().split(", ").includes(e))return i}}catch(e){a.e(e)}finally{a.f()}}}catch(e){r.e(e)}finally{r.f()}return null}function m(){try{return!!window.localStorage}catch(e){return!1}}var y=-1!=location.toString().indexOf("_debugReadAloud=true")},593:function(e,t,n){n.d(t,{bg:function(){return $}}),n(5700),n(2675),n(9463),n(2259),n(8125),n(8706),n(113),n(3418),n(4423),n(3792),n(8598),n(2062),n(4782),n(4554),n(9572),n(4731),n(479),n(8130),n(2010),n(9085),n(2811),n(875),n(6099),n(3362),n(825),n(4864),n(7495),n(8781),n(1699),n(7764),n(1761),n(5906),n(5440),n(744),n(2762),n(8344),n(3500),n(2953);var r=n(1669);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,s(r.key),r)}}function a(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}var l,c,u,d,f,h=function(){return e=function e(t,n){var o=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),a(this,"selecting",!1),a(this,"startedInSelector",!1),a(this,"target",null),a(this,"lastKnownFocusNode",null),a(this,"_onSelectionChange",function(){var e=window.getSelection();if(!o.selecting&&e.toString()){var t=r(e.anchorNode).closest(o.selector)[0];if(!t)return;o.target=t,o.selecting=!0,o.lastKnownFocusNode=e.focusNode,o.handler("started",o.target)}o.selecting&&(o.lastKnownFocusNode!=e.focusNode||e.toString()&&!e.isCollapsed)&&(o.lastKnownFocusNode=e.focusNode,o.handler("focusChanged",o.target)),!o.selecting||!e.isCollapsed&&e.toString()&&r(e.anchorNode).closest(o.selector)[0]||(o.selecting=!1,o.handler("cleared",o.target))}),this.selector=t,this.handler=n},(t=[{key:"attach",value:function(){document.addEventListener("selectionchange",this._onSelectionChange)}},{key:"detach",value:function(){document.removeEventListener("selectionchange",this._onSelectionChange)}}])&&i(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}(),p=n(420),g=n(9696),m=(n(90),n(1669));function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function v(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(v=function(){return!!e})()}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}function w(e,t){return w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},w(e,t)}function k(){k=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach(function(n){t.forEach(function(t){t.kind===n&&"own"===t.placement&&this.defineClassElement(e,t)},this)},this)},initializeClassElements:function(e,t){var n=e.prototype;["method","field"].forEach(function(r){t.forEach(function(t){var o=t.placement;if(t.kind===r&&("static"===o||"prototype"===o)){var i="static"===o?e:n;this.defineClassElement(i,t)}},this)},this)},defineClassElement:function(e,t){var n=t.descriptor;if("field"===t.kind){var r=t.initializer;n={enumerable:n.enumerable,writable:n.writable,configurable:n.configurable,value:void 0===r?void 0:r.call(e)}}Object.defineProperty(e,t.key,n)},decorateClass:function(e,t){var n=[],r=[],o={static:[],prototype:[],own:[]};if(e.forEach(function(e){this.addElementPlacement(e,o)},this),e.forEach(function(e){if(!E(e))return n.push(e);var t=this.decorateElement(e,o);n.push(t.element),n.push.apply(n,t.extras),r.push.apply(r,t.finishers)},this),!t)return{elements:n,finishers:r};var i=this.decorateConstructor(n,t);return r.push.apply(r,i.finishers),i.finishers=r,i},addElementPlacement:function(e,t,n){var r=t[e.placement];if(!n&&-1!==r.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");r.push(e.key)},decorateElement:function(e,t){for(var n=[],r=[],o=e.decorators,i=o.length-1;i>=0;i--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,o[i])(s)||s);e=l.element,this.addElementPlacement(e,t),l.finisher&&r.push(l.finisher);var c=l.extras;if(c){for(var u=0;u<c.length;u++)this.addElementPlacement(c[u],t);n.push.apply(n,c)}}return{element:e,finishers:r,extras:n}},decorateConstructor:function(e,t){for(var n=[],r=t.length-1;r>=0;r--){var o=this.fromClassDescriptor(e),i=this.toClassDescriptor((0,t[r])(o)||o);if(void 0!==i.finisher&&n.push(i.finisher),void 0!==i.elements){e=i.elements;for(var a=0;a<e.length-1;a++)for(var s=a+1;s<e.length;s++)if(e[a].key===e[s].key&&e[a].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:n}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||R(t)||_(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map(function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t},this);var t},toElementDescriptor:function(e){var t=e.kind+"";if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var n=q(e.key),r=e.placement+"";if("static"!==r&&"prototype"!==r&&"own"!==r)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+r+'"');var o=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var i={kind:t,key:n,placement:r,descriptor:Object.assign({},o)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(o,"get","The property descriptor of a field descriptor"),this.disallowProperty(o,"set","The property descriptor of a field descriptor"),this.disallowProperty(o,"value","The property descriptor of a field descriptor"),i.initializer=e.initializer),i},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:x(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=e.kind+"";if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var n=x(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:n}},runClassFinishers:function(e,t){for(var n=0;n<t.length;n++){var r=(0,t[n])(e);if(void 0!==r){if("function"!=typeof r)throw new TypeError("Finishers must return a constructor.");e=r}}return e},disallowProperty:function(e,t,n){if(void 0!==e[t])throw new TypeError(n+" can't have a ."+t+" property.")}};return e}function S(e){var t,n=q(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var r={kind:"field"===e.kind?"field":"method",key:n,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(r.decorators=e.decorators),"field"===e.kind&&(r.initializer=e.value),r}function C(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function E(e){return e.decorators&&e.decorators.length}function T(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function x(e,t){var n=e[t];if(void 0!==n&&"function"!=typeof n)throw new TypeError("Expected '"+t+"' to be a function");return n}function j(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],n=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}throw new TypeError(y(e)+" is not iterable")}function L(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var l=r&&r.prototype instanceof s?r:s,c=Object.create(l.prototype);return P(c,"_invoke",function(n,r,o){var i,s,l,c=0,u=o||[],d=!1,f={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return i=t,s=0,l=e,f.n=n,a}};function h(n,r){for(s=n,l=r,t=0;!d&&c&&!o&&t<u.length;t++){var o,i=u[t],h=f.p,p=i[2];n>3?(o=p===r)&&(l=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=h&&((o=n<2&&h<i[1])?(s=0,f.v=r,f.n=i[1]):h<p&&(o=n<3||i[0]>r||r>p)&&(i[4]=n,i[5]=r,f.n=p,s=0))}if(o||n>1)return a;throw d=!0,r}return function(o,u,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===u&&h(u,p),s=u,l=p;(t=s<2?e:l)||!d;){i||(s?s<3?(s>1&&(f.n=-1),h(s,l)):f.n=l:f.v=l);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,l)))throw TypeError("iterator result is not an object");if(!t.done)return t;l=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(d=f.n<0)?l:n.call(r,f))!==a)break}catch(t){i=e,s=1,l=t}finally{c=1}}return{value:t,done:d}}}(n,o,i),!0),c}var a={};function s(){}function l(){}function c(){}t=Object.getPrototypeOf;var u=[][r]?t(t([][r]())):(P(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,P(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return l.prototype=c,P(d,"constructor",c),P(c,"constructor",l),l.displayName="GeneratorFunction",P(c,o,"GeneratorFunction"),P(d),P(d,o,"Generator"),P(d,r,function(){return this}),P(d,"toString",function(){return"[object Generator]"}),(L=function(){return{w:i,m:f}})()}function P(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}P=function(e,t,n,r){function i(t,n){P(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},P(e,t,n,r)}var O=L().m(G),M=L().m(W);function A(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=_(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function _(e,t){if(e){if("string"==typeof e)return z(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?z(e,t):void 0}}function R(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function B(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function I(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function F(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,q(r.key),r)}}function D(e,t,n){return t&&F(e.prototype,t),n&&F(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function N(e,t,n){return(t=q(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function q(e){var t=function(e){if("object"!=y(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=y(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==y(t)?t:t+""}var $=function(){return D(function e(t,n,r,o){var i=this,a=r.selectionElement;I(this,e),N(this,"options",{maxProtectedWords:200}),N(this,"selectMenu",void 0),N(this,"selectionMenuEnabled",!1),N(this,"_onSelectionChange",function(e,t){if("started"===e)i.textSelectingMode(t);else if("cleared"===e)i.defaultMode(t);else if("focusChanged"!==e)throw new Error("Unknown type ".concat(e))}),N(this,"_limitSelection",function(){var e=window.getSelection();if(e.rangeCount){var t=e.getRangeAt(0),n=!!t.startContainer.parentElement.closest(".BRcontainer"),r=!!t.endContainer.parentElement.closest(".BRcontainer");if(n||r)if(n&&r){var o=function(e,t){var n,r=0,o=A(e);try{for(o.s();!(n=o.n()).done;){var i=n.value;if(r==t)return i;r++}}catch(e){o.e(e)}finally{o.f()}}(G(W(t.startContainer,t.endContainer),function(e){var t;return null===(t=e.classList)||void 0===t?void 0:t.contains(i.selectionElement[0].replace(".",""))}),i.options.maxProtectedWords-1);if(o&&t.endContainer.parentNode!=o){var a=document.createRange();a.setStart(t.startContainer,t.startOffset),a.setEnd(o.firstChild,o.textContent.length),e.removeAllRanges(),e.addRange(a)}}else e.removeAllRanges()}}),this.layer=t,this.br=n,this.selectionElement=a,this.selectionObserver=new h(this.layer,this._onSelectionChange),this.options.maxProtectedWords=o||200,this.selectMenu=new X(n),this.selectMenu.className="br-select-menu__root"},[{key:"init",value:function(){var e=this;this.attach(),new h(this.layer,function(t){var n;"started"==t&&(null===(n=e.br.plugins.archiveAnalytics)||void 0===n||n.sendEvent("BookReader","SelectStart"),e.br.refs.$br.find(".BRpagecontainer--hasSelection").removeClass("BRpagecontainer--hasSelection"),m(window.getSelection().anchorNode).closest(".BRpagecontainer").addClass("BRpagecontainer--hasSelection"),e.selectMenu.showMenu()),"focusChanged"==t&&(e.mouseIsDown?e.selectMenu.hideMenu():window.getSelection().toString()&&e.selectMenu.showMenu()),"cleared"==t&&e.selectMenu.hideMenu()}).attach()}},{key:"attach",value:function(){var e=this;this.selectionObserver.attach(),this.selectionMenuEnabled&&this.renderSelectionMenu(),this.br.protected&&(document.addEventListener("selectionchange",this._limitSelection),m(document.body).on("contextmenu dragstart copy",function(t){var n=document.getSelection();if(null!=n&&n.toString()&&m(e.layer).toArray().some(function(e){return n.containsNode(e,!0)}))return t.preventDefault(),!1}))}},{key:"detach",value:function(){this.selectionObserver.detach(),this.br.protected&&document.removeEventListener("selectionchange",this._limitSelection)}},{key:"renderSelectionMenu",value:function(){document.querySelector(".br-select-menu__option")||document.body.append(this.selectMenu)}},{key:"interceptCopy",value:function(e){e[0].addEventListener("copy",function(e){var t=document.getSelection();e.clipboardData.setData("text/plain",t.toString()),e.preventDefault()})}},{key:"stopPageFlip",value:function(e){var t=this,n=e.find(this.layer);n.length&&(n.each(function(e,n){return t.defaultMode(n)}),this.br.protected||this.interceptCopy(e))}},{key:"defaultMode",value:function(e){var t=this,n=m(e).closest(".BRpagecontainer");e.style.pointerEvents="none",n.find("img").css("pointer-events","auto"),m(e).off(".textSelectPluginHandler");var r=this.mouseIsDown,o=this.mouseIsDown;r&&(e.style.pointerEvents="auto"),m(e).on("mousedown.textSelectPluginHandler",function(e){t.mouseIsDown=!0,t.selectMenu.hideMenu(),m(e.target).is(t.selectionElement.join(", "))&&e.stopPropagation()}),m(e).on("mouseup.textSelectPluginHandler",function(n){t.mouseIsDown=!1,t.selectMenu.hideMenu(),e.style.pointerEvents="none",o&&(o=!1,n.stopPropagation())})}},{key:"textSelectingMode",value:function(e){var t=this,n=m(e).closest(".BRpagecontainer");e.style.pointerEvents="all",n.find("img").css("pointer-events","none"),m(e).off(".textSelectPluginHandler"),m(e).on("mousedown.textSelectPluginHandler",function(e){1==e.which&&(t.mouseIsDown=!0,e.stopPropagation(),t.selectMenu.hideMenu())}),m(e).on("mouseup.textSelectPluginHandler",function(e){t.mouseIsDown=!1,1==e.which&&(e.stopPropagation(),t.selectMenu.showMenu())})}}])}();function H(e,t){var n=e.toString().replace(/[\s]+/g," ").trim().split(" "),r=e.direction,o="backward"==r?e.focusNode:e.anchorNode,i="backward"==r?e.anchorNode:e.focusNode,a=o.textContent.replace(/[\s]+/g,"")?o.textContent:n[0],s=i.textContent.replace(/[\s]+/g,"")?i.textContent:n[n.length-1],u=RegExp.escape(a),h=RegExp.escape(s),p=new RegExp(String.raw(l||(l=B(["(?<=(",").*?)(",")"])),u,h),"gis"),g=new RegExp(String.raw(c||(c=B(["(",")(?=.*?(","))"])),u,h),"gis"),m=t.map(function(e){return e.textContent}).join(" ").replace(/\s+/g," "),y=m.matchAll(p).toArray(),v=m.matchAll(g).toArray();if(1==y.length&&1==v.length)return"text=".concat(encodeURIComponent(a),",").concat(encodeURIComponent(s));var b=document.createRange();b.setStart(t[0].firstElementChild,0),b.setEnd(o,0);var w=document.createRange();w.setStart(i,i.textContent.length);var k=function(e){for(;e.lastElementChild;)e=e.lastElementChild;return e}(t[t.length-1]);w.setEnd(k,Math.max(0,k.textContent.length-1));var S=function(e,t){t=t.trim();var n=new RegExp(String.raw(f||(f=B(["((^|s+)S+){1,","}s*?$"],["((^|\\s+)\\S+){1,","}\\s*?$"])),3)),r=t.match(n);return r?r[0].trim():""}(0,b.toString()).replace(/[ ]+/g," ").trim().replace(/^[^\n]*\n/gm,""),C=function(e,t){t=t.trim();var n=new RegExp(String.raw(d||(d=B(["^(S+(s+|$)){1,","}"],["^(\\S+(\\s+|$)){1,","}"])),3)),r=t.match(n);return r?r[0].trim():""}(0,w.toString()).replace(/[ ]+/g," ").trim().replace(/\n[^\n]*$/gm,""),E=e.toString().replace(/\s+/g," ").trim().split(/\s/g);0!=o.textContent.trim().length&&(o.textContent.includes(E[0])?E[0]=o.textContent:E.unshift(o.textContent)),0!=i.textContent.trim().length&&(i.textContent.includes(E[E.length-1])||E.push(i.textContent),E[E.length-1]=i.textContent);var T=[E.join(" ")];E.length>6&&(T=[E.slice(0,3).join(" "),E.slice(-3).join(" ")]);var x,j=[];return S&&j.push("".concat(S,"-")),j.push.apply(j,function(e){if(Array.isArray(e))return z(e)}(x=T)||R(x)||_(x)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),C&&j.push("-".concat(C)),"text=".concat(j.map(encodeURIComponent).join(","))}function G(e,t){var n,r,o,i;return L().w(function(a){for(;;)switch(a.p=a.n){case 0:n=A(e),a.p=1,n.s();case 2:if((r=n.n()).done){a.n=4;break}if(o=r.value,!t(o)){a.n=3;break}return a.n=3,o;case 3:a.n=2;break;case 4:a.n=6;break;case 5:a.p=5,i=a.v,n.e(i);case 6:return a.p=6,n.f(),a.f(6);case 7:return a.a(2)}},O,null,[[1,5,6,7]])}function W(e,t){var n,r;return L().w(function(o){for(;;)switch(o.n){case 0:return r=function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.children,a=void 0===i||i,s=o.parents,l=void 0===s||s,c=o.siblings,u=void 0===c||c;return L().m(function o(){var i;return L().w(function(o){for(;;)switch(o.n){case 0:if(e!==t){o.n=2;break}return n=!0,o.n=1,e;case 1:return o.a(2);case 2:return o.n=3,e;case 3:if(!a||!e.firstChild){o.n=5;break}return o.d(j(r(e.firstChild,{children:!0,parents:!1,siblings:!0})),4);case 4:if(!n){o.n=5;break}return o.a(2);case 5:if(!u){o.n=9;break}i=e.nextSibling;case 6:if(!i){o.n=9;break}return o.d(j(r(i,{children:!0,parents:!1,siblings:!1})),7);case 7:if(!n){o.n=8;break}return o.a(2);case 8:i=i.nextSibling,o.n=6;break;case 9:if(!l||!e.parentNode){o.n=11;break}return o.d(j(r(e.parentNode,{children:!1,parents:!0,siblings:!0})),10);case 10:if(!n){o.n=11;break}return o.a(2);case 11:return o.a(2)}},o)})()},n=!1,o.d(j(r(e)),1);case 1:return o.a(2)}},M)}var K,U,Z,V,J,Y,X=(K=[(0,g.EM)("br-select-menu")],U=p.WF,V=k(),Z=function(e){V.initializeInstanceElements(e,Y.elements)},J={F:function(e){function t(e){var n;return I(this,t),n=function(e,t,n){return t=b(t),function(e,t){if(t&&("object"==y(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,v()?Reflect.construct(t,n||[],b(e).constructor):t.apply(e,n))}(this,t),Z(n),n.br=e,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&w(e,t)}(t,e),D(t)}(U),d:[{kind:"field",key:"br",value:void 0},{kind:"method",key:"createRenderRoot",value:function(){return this}},{kind:"method",key:"render",value:function(){return(0,p.qy)(u||(u=B(["\n <button @click=",' class="br-select-menu__option">\n <ia-icon-share class="br-select-menu__icon" aria-hidden="true"></ia-icon-share>\n <span class="br-select-menu__label">Copy Link to Highlight</span>\n </button>\n '])),this.handleCopyLinkToHighlight)}},{kind:"method",key:"handleCopyLinkToHighlight",value:function(e){e.preventDefault();var t=this.br.readQueryString(),n=window.getSelection(),r=n.anchorNode.parentElement.closest(".BRtextLayer"),o=H(n,Array.from(document.querySelectorAll(".BRpage-visible"))),i=t;t.includes("text=")?i=t.replace(/(text=)[\w\W\d%]+/,o):i+="".concat(i?"&":"?").concat(o);var a=window.location,s=a.pathname.toString().replace(/(?<=\/page\/)\d+(?=\/)/,r.parentElement.getAttribute("data-page-num")),l="".concat(a.origin).concat(s).concat(i).concat((null==a?void 0:a.hash)||"");navigator.clipboard.writeText(l)}},{kind:"method",key:"showMenu",value:function(){var e;if(null===(e=this.br.plugins.translate)||void 0===e||!e.userToggleTranslate){var t=window.getSelection(),n=t.anchorNode.parentElement,r=t.focusNode.parentElement,o=n.getBoundingClientRect(),i=r.getBoundingClientRect(),a=o.top-30,s=o.left-60;"backward"==t.direction&&(a=i.top-30,s=i.left-60),this.style.top="".concat(a,"px"),this.style.left="".concat(s,"px"),this.style.zIndex="1",this.style.position="absolute",this.style.display="block"}}},{kind:"field",key:"hideMenu",value:function(){var e=this;return function(){e.style.display="none"}}}]},Y=V.decorateClass(function(e){for(var t=[],n=function(e){return"method"===e.kind&&e.key===i.key&&e.placement===i.placement},r=0;r<e.length;r++){var o,i=e[r];if("method"===i.kind&&(o=t.find(n)))if(T(i.descriptor)||T(o.descriptor)){if(E(i)||E(o))throw new ReferenceError("Duplicated methods ("+i.key+") can't be decorated.");o.descriptor=i.descriptor}else{if(E(i)){if(E(o))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+i.key+").");o.decorators=i.decorators}C(i,o)}else t.push(i)}return t}(J.d.map(S)),K),V.initializeClassElements(J.F,Y.elements),V.runClassFinishers(J.F,Y.finishers))},4565:function(e,t,n){function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,i(r.key),r)}}function i(e){var t=function(e){if("object"!=r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==r(t)?t:t+""}n.d(t,{l:function(){return a}}),n(2675),n(9463),n(2259),n(5700),n(3792),n(9572),n(8130),n(6099),n(7764),n(2953);var a=function(){return e=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.maxSize=t,this.entries=[]},(t=[{key:"add",value:function(e){this.entries.length>=this.maxSize&&this.entries.shift(),this.entries.push(e)}}])&&o(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}()}},function(e){e(e.s=6735)}]);
|
|
137
159
|
//# sourceMappingURL=plugin.translate.js.map
|