@internetarchive/bookreader 5.0.0-100 → 5.0.0-102
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/474.js +1 -1
- package/BookReader/474.js.map +1 -1
- package/BookReader/BookReader.css +79 -8
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.LICENSE.txt +1 -1
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +52 -52
- package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +7 -1
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/icons/1up.svg +1 -1
- package/BookReader/icons/2up.svg +1 -1
- package/BookReader/icons/advance.svg +1 -1
- package/BookReader/icons/chevron-right.svg +1 -1
- package/BookReader/icons/close-circle-dark.svg +1 -1
- package/BookReader/icons/close-circle.svg +1 -1
- package/BookReader/icons/fullscreen.svg +1 -1
- package/BookReader/icons/fullscreen_exit.svg +1 -1
- package/BookReader/icons/hamburger.svg +1 -1
- package/BookReader/icons/left-arrow.svg +1 -1
- package/BookReader/icons/magnify-minus.svg +1 -1
- package/BookReader/icons/magnify-plus.svg +1 -1
- package/BookReader/icons/magnify.svg +1 -1
- package/BookReader/icons/pause.svg +1 -1
- package/BookReader/icons/play.svg +1 -1
- package/BookReader/icons/playback-speed.svg +1 -1
- package/BookReader/icons/read-aloud.svg +1 -1
- package/BookReader/icons/review.svg +1 -1
- package/BookReader/icons/slider-toggle.svg +1 -0
- package/BookReader/icons/thumbnails.svg +1 -1
- package/BookReader/icons/voice.svg +1 -1
- package/BookReader/icons/volume-full.svg +1 -1
- package/BookReader/images/BRicons.svg +2 -2
- package/BookReader/images/books_graphic.svg +1 -1
- package/BookReader/images/icon_book.svg +1 -1
- package/BookReader/images/icon_bookmark.svg +1 -1
- package/BookReader/images/icon_gear.svg +1 -1
- package/BookReader/images/icon_hamburger.svg +1 -1
- package/BookReader/images/icon_home.svg +1 -1
- package/BookReader/images/icon_info.svg +1 -1
- package/BookReader/images/icon_one_page.svg +1 -1
- package/BookReader/images/icon_pause.svg +1 -1
- package/BookReader/images/icon_play.svg +1 -1
- package/BookReader/images/icon_playback-rate.svg +1 -1
- package/BookReader/images/icon_search_button.svg +1 -1
- package/BookReader/images/icon_share.svg +1 -1
- package/BookReader/images/icon_skip-back.svg +1 -1
- package/BookReader/images/icon_speaker.svg +1 -1
- package/BookReader/images/icon_speaker_open.svg +1 -1
- package/BookReader/images/icon_thumbnails.svg +1 -1
- package/BookReader/images/icon_toc.svg +1 -1
- package/BookReader/images/icon_two_pages.svg +1 -1
- package/BookReader/images/marker_chap-off.svg +1 -1
- package/BookReader/images/marker_chap-on.svg +1 -1
- package/BookReader/images/marker_srch-on.svg +1 -1
- package/BookReader/images/translate.svg +1 -1
- package/BookReader/jquery-3.js +1 -1
- package/BookReader/plugins/plugin.archive_analytics.js +1 -1
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -1
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +2 -2
- package/BookReader/plugins/plugin.chapters.js.LICENSE.txt +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.LICENSE.txt +1 -1
- package/BookReader/plugins/plugin.experiments.js.map +1 -1
- package/BookReader/plugins/plugin.iframe.js +1 -1
- package/BookReader/plugins/plugin.iframe.js.map +1 -1
- package/BookReader/plugins/plugin.iiif.js +1 -1
- package/BookReader/plugins/plugin.iiif.js.map +1 -1
- package/BookReader/plugins/plugin.resume.js +1 -1
- package/BookReader/plugins/plugin.resume.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1
- package/BookReader/plugins/plugin.search.js.LICENSE.txt +1 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +1 -1
- package/BookReader/plugins/plugin.text_selection.js.LICENSE.txt +1 -1
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.translate.js +4 -4
- package/BookReader/plugins/plugin.translate.js.LICENSE.txt +1 -1
- package/BookReader/plugins/plugin.translate.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.LICENSE.txt +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -1
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
- package/BookReader/plugins/translator-worker.js +1 -1
- package/BookReader/plugins/translator-worker.js.map +1 -1
- package/BookReader/webcomponents-bundle.js +1 -1
- package/BookReader/webcomponents-bundle.js.map +1 -1
- package/package.json +20 -20
- package/src/BookNavigator/search/search-results.js +84 -63
- package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +4 -4
- package/src/BookNavigator/visual-adjustments/visual-adjustments.js +77 -59
- package/src/BookReader/Navbar/Navbar.js +54 -71
- package/src/BookReader/options.js +6 -0
- package/src/BookReader.js +12 -0
- package/src/assets/icons/slider-toggle.svg +1 -0
- package/src/css/_BRnav.scss +57 -4
- package/src/css/_BRpages.scss +9 -0
- package/src/css/_icons.scss +7 -0
- package/src/plugins/plugin.text_selection.js +9 -0
- package/src/plugins/search/plugin.search.js +4 -0
- package/src/plugins/search/utils.js +8 -1
- package/src/plugins/search/view.js +1 -1
|
@@ -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],{4360:function(e,t,r){var n=r(420);const a=Object.freeze({processing:"processing",complete:"complete"});class o extends n.WF{static get properties(){return{mode:{type:String}}}constructor(){super(),this.mode=a.processing}render(){return n.qy`
|
|
2
|
+
"use strict";(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[444],{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)}},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}()},4160:function(e,t,n){n.d(t,{$x:function(){return m},EF:function(){return u},ND:function(){return p},m0:function(){return f},YH:function(){return h}}),n(2675),n(9463),n(2259),n(8706),n(3418),n(3792),n(2062),n(4782),n(2010),n(875),n(6099),n(3362),n(7495),n(8781),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){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e?g(e=e.toLowerCase(),["iso639_1"],t)||g(e,["iso639_2T"],t)||g(e,["iso639_2B","nativeName","name"],t):null}function g(e,t,n){var r,a=l(s);try{for(a.s();!(r=a.n()).done;){var o,i=r.value,c=l(t);try{for(c.s();!(o=c.n()).done;)if(-1!=i[o.value].split(", ").map(function(e){return e.toLowerCase()}).indexOf(e))return n?"".concat(i.nativeName.split(", ")[0]," (").concat(i.iso639_1,")"):i.iso639_1}catch(e){c.e(e)}finally{c.f()}}}catch(e){a.e(e)}finally{a.f()}return d[e]?"".concat(d[e]," (").concat(e,")"):null}function p(){try{return!!window.localStorage}catch(e){return!1}}var m=-1!=location.toString().indexOf("_debugReadAloud=true")},4360:function(e,t,n){var r=n(420);const a=Object.freeze({processing:"processing",complete:"complete"});class o extends r.WF{static get properties(){return{mode:{type:String}}}constructor(){super(),this.mode=a.processing}render(){return r.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=r.AH`var(--activityIndicatorCheckmarkColor, #31A481)`,t=r.AH`var(--activityIndicatorCompletedRingColor, #31A481)`,n=r.AH`var(--activityIndicatorLoadingRingColor, #333333)`,a=r.AH`var(--activityIndicatorLoadingDotColor, #333333)`;return r.AH`
|
|
52
52
|
#completed-ring {
|
|
53
53
|
fill: ${t};
|
|
54
54
|
}
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
#activity-ring {
|
|
61
|
-
fill: ${
|
|
61
|
+
fill: ${n};
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
#activity-dots {
|
|
@@ -133,5 +133,5 @@
|
|
|
133
133
|
opacity: 0;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
`}}window.customElements.define("ia-activity-indicator",o)},1041:function(e,t,r){function n(e){return n="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},n(e)}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}function o(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,"string");if("object"!=n(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==n(t)?t:t+""}r.d(t,{S:function(){return i}}),r(2675),r(9463),r(2259),r(5700),r(3792),r(9572),r(8130),r(9085),r(6099),r(7764),r(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,r){r(2675),r(9463),r(6412),r(2259),r(8125),r(4490),r(4782),r(4554),r(4731),r(479),r(9085),r(2811),r(3851),r(875),r(825),r(888),r(8781),r(5700),r(8706),r(2008),r(113),r(3418),r(3792),r(2062),r(9572),r(2010),r(8130),r(6099),r(8459),r(8940),r(3362),r(7495),r(7764),r(5440),r(3500),r(2953);var n=r(420),a=r(1041),o=r(9696),i=(r(739),r(6034),r(4565));"undefined"!=typeof window&&window.Worker||(globalThis.Worker=class{#e;constructor(e){this.#e=new Promise((async t=>{const{Worker:r}=await import("node:worker_threads");t(new r(e))}))}addEventListener(e,t){this.#e.then((r=>r.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(r.p+r.u(474),r.b));let t=0;const n=new Map,a=(r,...a)=>new Promise(((o,i)=>{const s=++t;n.set(s,{accept:o,reject:i,callsite:{message:`${r}(${a.map((e=>String(e))).join(", ")})`,stack:(new Error).stack}}),e.postMessage({id:s,name:r,args:a})}));return e.addEventListener("message",(function({data:{id:e,result:t,error:r}}){if(!n.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}=n.get(e);n.delete(e),void 0!==r?o(Object.assign(new Error,r,{message:r.message+` (response to ${i.message})`,stack:r.stack?`${r.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,r){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 r=e.match(/^([a-z]{2}(-[a-z]+)?)([a-z]{2}(-[a-z]+)?)/i);return{from:r[1],to:r[3],files:t}}))}getTranslationModel({from:e,to:t},r){const n=JSON.stringify({from:e,to:t});if(!this.buffers.has(n)){const a=this.loadTranslationModel({from:e,to:t},r);this.buffers.set(n,a),a.catch((e=>this.buffers.delete(n)))}return this.buffers.get(n)}async loadTranslationModel({from:e,to:t},r){performance.mark(`loadTranslationModule.${JSON.stringify({from:e,to:t})}`);const n=(await this.registry).filter((r=>r.from==e&&r.to==t));if(!n)throw new Error(`No model for '${e}' -> '${t}'`);const a=n[0].files,o=()=>reject(new s("abort signal")),i=new Promise(((e,t)=>{r?.signal&&r.signal.addEventListener("abort",o)})),l=Object.fromEntries(await Promise.race([Promise.all(Object.entries(a).map((async([n,a])=>{if(void 0===a||void 0===a.name)return[n,null];try{return[n,await this.fetch(a.name,a.expectedSha256Hash,r)]}catch(r){throw new Error(`Could not fetch ${a.name} for ${e}->${t} model`,{cause:r})}}))),i]));r?.signal&&r.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,r){const n=new AbortController,a=()=>n.abort(),o=this.downloadTimeout?setTimeout(a,this.downloadTimeout):null;try{r?.signal&&r.signal.addEventListener("abort",a);const o={credentials:"omit",signal:n.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),r?.signal&&r.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 r=JSON.stringify({from:e,to:t});return this.models.has(r)||this.models.set(r,this.findModels(e,t)),this.models.get(r)}async findModels(e,t){const r=await this.registry;let n=[],a=[],o=[];if(r.forEach((r=>{r.from===e&&r.to===t?n.push(r):r.from===e&&r.to===this.pivotLanguage?a.push(r):r.to===t&&r.from===this.pivotLanguage&&o.push(r)})),n.length)return[n[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:r,priority:n}=e;return new Promise((async(a,o)=>{try{const i=JSON.stringify({from:t,to:r}),s=await this.backing.getModels(e);this.enqueue({key:i,models:s,request:e,resolve:a,reject:o,priority:n}),this.notify()}catch(e){o(e)}}))}remove(e){const t=this.queue;this.queue=[],t.forEach((t=>{t.requests.forEach((({request:r,resolve:n,reject:a})=>{e(r)?a(Object.assign(new s("removed by filter"),{request:r})):this.enqueue({key:t.key,priority:t.priority,models:t.models,request:r,resolve:n,reject:a})}))}))}enqueue({key:e,models:t,request:r,resolve:n,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:r,resolve:n,reject:a})}async consumeBatch(e,t){performance.mark("BergamotBatchTranslator.start"),await Promise.all(e.models.map((async({from:e,to:r})=>{if(!await t.hasTranslationModel({from:e,to:r})){const n=await this.backing.getTranslationModel({from:e,to:r});await t.loadTranslationModel({from:e,to:r},n)}})));const r=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:r}})=>({text:e.toString(),html:!!t,qualityScores:!!r})))});e.requests.forEach((({request:e,resolve:t,reject:n},a)=>{t({request:e,...r[a]})})),performance.measure("BergamotBatchTranslator","BergamotBatchTranslator.start")}}var u=r(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 h(){h=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var o=t&&t.prototype instanceof b?t:b,i=Object.create(o.prototype),s=new A(n||[]);return a(i,"_invoke",{value:j(e,r,s)}),i}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var p="suspendedStart",g="suspendedYield",m="executing",y="completed",v={};function b(){}function w(){}function k(){}var x={};c(x,i,(function(){return this}));var L=Object.getPrototypeOf,S=L&&L(L(M([])));S&&S!==r&&n.call(S,i)&&(x=S);var E=k.prototype=b.prototype=Object.create(x);function T(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function r(a,o,i,s){var l=d(e[a],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==f(u)&&n.call(u,"__await")?t.resolve(u.__await).then((function(e){r("next",e,i,s)}),(function(e){r("throw",e,i,s)})):t.resolve(u).then((function(e){c.value=e,i(c)}),(function(e){return r("throw",e,i,s)}))}s(l.arg)}var o;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return o=o?o.then(a,a):a()}})}function j(t,r,n){var a=p;return function(o,i){if(a===m)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:e,done:!0}}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var l=P(s,n);if(l){if(l===v)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===p)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=m;var c=d(t,r,n);if("normal"===c.type){if(a=n.done?y:g,c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(a=y,n.method="throw",n.arg=c.arg)}}}function P(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,P(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=d(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function M(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,o=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(f(t)+" is not iterable")}return w.prototype=k,a(E,"constructor",{value:k,configurable:!0}),a(k,"constructor",{value:w,configurable:!0}),w.displayName=c(k,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,k):(e.__proto__=k,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},T(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,r,n,a,o){void 0===o&&(o=Promise);var i=new C(u(e,r,n,a),o);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},T(E),c(E,l,"Generator"),c(E,i,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=M,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(_),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(l&&c){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(l){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),_(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;_(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:M(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}function d(e,t,r,n,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void r(e)}s.done?t(l):Promise.resolve(l).then(n,a)}function p(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){d(o,n,a,i,s,"next",e)}function s(e){d(o,n,a,i,s,"throw",e)}i(void 0)}))}}function g(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,y(n.key),n)}}function m(e,t,r){return(t=y(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function y(e){var t=function(e,t){if("object"!=f(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.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 v,b,w,k,x,L,S,E=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),m(this,"alreadyTranslated",new i.l(100)),m(this,"modelRegistry",{}),m(this,"currentlyTranslating",{}),m(this,"fromLanguages",[]),m(this,"toLanguages",[]),m(this,"active",!1),m(this,"publicPath",""),m(this,"getTranslation",function(){var e=p(h().mark((function e(r,n,a,o,i,s){var l,c,u,f,d;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.active=!0,r!=n&&r&&n){e.next=3;break}return e.abrupt("return");case 3:if(l="".concat(r).concat(n,"-").concat(a,":").concat(o),!(c=t.alreadyTranslated.entries.find((function(e){return e.index==l})))){e.next=7;break}return e.abrupt("return",c.response);case 7:if(!(l in t.currentlyTranslating)){e.next=9;break}return e.abrupt("return",t.currentlyTranslating[l].promise);case 9:if(u=null,f=null,d=new Promise((function(e,t){u=e,f=t})),t.currentlyTranslating[l]={promise:d,resolve:u,reject:f},i){e.next=16;break}return t.currentlyTranslating[l].reject("No text was provided"),e.abrupt("return",d);case 16:return t.translator.translate({to:n,from:r,text:i,html:!1,priority:s}).then((function(e){var r=e;t.currentlyTranslating[l].resolve(r.target.text),t.alreadyTranslated.add({index:l,response:r.target.text}),delete t.currentlyTranslating[l]})),e.abrupt("return",d);case 18:case"end":return e.stop()}}),e)})));return function(t,r,n,a,o,i){return e.apply(this,arguments)}}()),m(this,"getTranslationModel",function(){var e=p(h().mark((function e(r,n){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.translator.backing.getTranslationModel({from:r,to:n}).catch((function(e){console.error("An error occurred while trying to retreive the ".concat(r,"-").concat(n," model"))})));case 1:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}());var r={code:"en",name:"English",type:"prod"};this.fromLanguages.push(r),this.toLanguages.push(r)},t=[{key:"initWorker",value:(r=p(h().mark((function e(){var t,r,n,a,o,i,s,l,f,d,p,g,m,y,v,b,w=this;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.initPromise){e.next=2;break}return e.abrupt("return",this.initPromise);case 2:return this.initPromise=new Promise((function(e,t){w._initResolve=e,w._initReject=t})),t="https://cors.archive.org/cors/mozilla-translate-models/firefox_models/",e.next=6,fetch(t+"registry.json").then((function(e){return e.json()}));case 6:for(r=e.sent,n=0,a=Object.values(r);n<a.length;n++)for(o=a[n],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(r))),workers:2,batchSize:4,workerUrl:this.publicPath+"/translator-worker.js"}),e.next=11,this.translator.backing.registry;case 11:for(f=e.sent,d={},p=0,g=Object.values(f);p<g.length;p++)m=g[p],y=m.from,v=m.to,b=m.files,d["".concat(y).concat(v)]=b,"en"!==y&&this.fromLanguages.push({code:y,name:(0,u.YH)(y,!0),type:"prod"}),"en"!==v&&this.toLanguages.push({code:v,name:(0,u.YH)(v,!0),type:"prod"});return this._initResolve([this.modelRegistry]),e.abrupt("return",this.initPromise);case 16:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})}],t&&g(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}(),T=r(8004),C=r(593),j=(r(4360),r(1669));function P(e){return P="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},P(e)}function O(e){return function(e){if(Array.isArray(e))return G(e)}(e)||N(e)||D(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 _(){_=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(n){t.forEach((function(t){var a=t.placement;if(t.kind===n&&("static"===a||"prototype"===a)){var o="static"===a?e:r;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var n=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===n?void 0:n.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],n=[],a={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,a)}),this),e.forEach((function(e){if(!z(e))return r.push(e);var t=this.decorateElement(e,a);r.push(t.element),r.push.apply(r,t.extras),n.push.apply(n,t.finishers)}),this),!t)return{elements:r,finishers:n};var o=this.decorateConstructor(r,t);return n.push.apply(n,o.finishers),o.finishers=n,o},addElementPlacement:function(e,t,r){var n=t[e.placement];if(!r&&-1!==n.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");n.push(e.key)},decorateElement:function(e,t){for(var r=[],n=[],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&&n.push(l.finisher);var c=l.extras;if(c){for(var u=0;u<c.length;u++)this.addElementPlacement(c[u],t);r.push.apply(r,c)}}return{element:e,finishers:n,extras:r}},decorateConstructor:function(e,t){for(var r=[],n=t.length-1;n>=0;n--){var a=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[n])(a)||a);if(void 0!==o.finisher&&r.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:r}},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)||N(t)||D(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 r=te(e.key),n=e.placement+"";if("static"!==n&&"prototype"!==n&&"own"!==n)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 "'+n+'"');var a=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:r,placement:n,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:B(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 r=B(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var n=(0,t[r])(e);if(void 0!==n){if("function"!=typeof n)throw new TypeError("Finishers must return a constructor.");e=n}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function A(e){var t,r=te(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 n={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(n.decorators=e.decorators),"field"===e.kind&&(n.initializer=e.value),n}function M(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 R(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function B(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function N(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function I(){return I="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=J(e)););return e}(e,t);if(n){var a=Object.getOwnPropertyDescriptor(n,t);return a.get?a.get.call(arguments.length<3?e:r):a.value}},I.apply(null,arguments)}function q(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function F(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=D(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},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(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){s=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw o}}}}function D(e,t){if(e){if("string"==typeof e)return G(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?G(e,t):void 0}}function G(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function $(){$=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var o=t&&t.prototype instanceof y?t:y,i=Object.create(o.prototype),s=new _(n||[]);return a(i,"_invoke",{value:T(e,r,s)}),i}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var h="suspendedStart",d="suspendedYield",p="executing",g="completed",m={};function y(){}function v(){}function b(){}var w={};c(w,i,(function(){return this}));var k=Object.getPrototypeOf,x=k&&k(k(A([])));x&&x!==r&&n.call(x,i)&&(w=x);var L=b.prototype=y.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function r(a,o,i,s){var l=f(e[a],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==P(u)&&n.call(u,"__await")?t.resolve(u.__await).then((function(e){r("next",e,i,s)}),(function(e){r("throw",e,i,s)})):t.resolve(u).then((function(e){c.value=e,i(c)}),(function(e){return r("throw",e,i,s)}))}s(l.arg)}var o;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return o=o?o.then(a,a):a()}})}function T(t,r,n){var a=h;return function(o,i){if(a===p)throw Error("Generator is already running");if(a===g){if("throw"===o)throw i;return{value:e,done:!0}}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var l=C(s,n);if(l){if(l===m)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var c=f(t,r,n);if("normal"===c.type){if(a=n.done?g:d,c.arg===m)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(a=g,n.method="throw",n.arg=c.arg)}}}function C(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,C(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var o=f(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,m;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function A(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,o=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(P(t)+" is not iterable")}return v.prototype=b,a(L,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:v,configurable:!0}),v.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(L),e},t.awrap=function(e){return{__await:e}},S(E.prototype),c(E.prototype,s,(function(){return this})),t.AsyncIterator=E,t.async=function(e,r,n,a,o){void 0===o&&(o=Promise);var i=new E(u(e,r,n,a),o);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},S(L),c(L,l,"Generator"),c(L,i,(function(){return this})),c(L,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=A,_.prototype={constructor:_,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(l&&c){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(l){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;O(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:A(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function H(e,t,r,n,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void r(e)}s.done?t(l):Promise.resolve(l).then(n,a)}function W(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){H(o,n,a,i,s,"next",e)}function s(e){H(o,n,a,i,s,"throw",e)}i(void 0)}))}}function K(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function U(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,te(n.key),n)}}function Y(e,t,r){return t&&U(e.prototype,t),r&&U(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Z(e,t,r){return t=J(t),function(e,t){if(t&&("object"==P(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,r||[],J(e).constructor):t.apply(e,r))}function V(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(V=function(){return!!e})()}function J(e){return J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},J(e)}function X(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&&Q(e,t)}function Q(e,t){return Q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Q(e,t)}function ee(e,t,r){return(t=te(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function te(e){var t=function(e,t){if("object"!=P(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=P(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==P(t)?t:t+""}var re,ne,ae,oe,ie,se,le,ce=window.BookReader,ue=function(e){function t(){var e;K(this,t);for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return ee(e=Z(this,t,[].concat(n)),"options",{enabled:!0,panelDisclaimerText:"Translations are in alpha"}),ee(e,"translationManager",new E),ee(e,"worker",void 0),ee(e,"toLanguages",[]),ee(e,"langFromCode",void 0),ee(e,"langToCode",void 0),ee(e,"_panel",void 0),ee(e,"userToggleTranslate",void 0),ee(e,"loadingModel",!0),ee(e,"textSelectionManager",new C.bg(".BRtranslateLayer",e.br,{selectionElement:[".BRlineElement"]},1)),ee(e,"getParagraphsOnPage",(function(e){return e?Array.from(e.querySelectorAll(".BRtextLayer > .BRparagraphElement")):[]})),ee(e,"handleFromLangChange",function(){var t=W($().mark((function t(r){var n;return $().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.clearAllTranslations(),n=r.detail.value,e.langFromCode=n,e._panel.requestUpdate(),e.translationManager.toLanguages.some((function(e){return e.code===n}))||e.translationManager.toLanguages.push({code:n,name:e.translationManager.fromLanguages.find((function(e){return e.code==n})).name}),e._panel.toLanguages=e.translationManager.toLanguages,console.log(e.langFromCode,e.langToCode),e._render(),e.langFromCode!==e.langToCode&&e.translateActivePageContainerElements();case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),ee(e,"handleToLangChange",function(){var t=W($().mark((function t(r){return $().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.clearAllTranslations(),e.langToCode=r.detail.value,e._render(),e.translateActivePageContainerElements();case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),ee(e,"handleToggleTranslation",W($().mark((function t(){return $().wrap((function(t){for(;;)switch(t.prev=t.next){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 4:case"end":return t.stop()}}),t)})))),e}return X(t,e),Y(t,[{key:"init",value:(o=W($().mark((function e(){var t,r=this;return $().wrap((function(e){for(;;)switch(e.prev=e.next){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.next=5;break}return e.abrupt("return");case 5:return this.translationManager.publicPath=this.br.options.imagesBaseURL.replace(/\/+$/,"")+"/..",this.br.on("textLayerRendered",function(){var e=W($().mark((function e(t,n){var a,o;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.pageIndex,a=n.pageContainer,r.translationManager){e.next=3;break}return e.abrupt("return");case 3:r.translationManager.active&&(o=a.$container[0],r.translateRenderedLayer(o));case 4:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}()),this.br.on("pageVisible",(function(e,t){var n=t.pageContainerEl;if(r.translationManager.active){var a,o=F(n.querySelectorAll(".BRtranslateLayer > .BRparagraphElement"));try{for(o.s();!(a=o.n()).done;){var i=a.value;i.textContent&&r.fitVisiblePage(i)}}catch(e){o.e(e)}finally{o.f()}}})),e.next=10,this.translationManager.initWorker();case 10:this.langToCode=this.translationManager.toLanguages[0].code,this._render();case 12:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"translateActivePageContainerElements",value:function(){var e,t=this.br.getActivePageContainerElements(),r=t.filter((function(e){return e.classList.contains("BRpage-visible")})),n=t.filter((function(e){return!e.classList.contains("BRpage-visible")})),a=F(r);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=F(n);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=W($().mark((function e(t,r){var n,a,o,i,s,l,c=this;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.br.mode!=this.br.constModeThumb&&this.userToggleTranslate&&this.langFromCode!=this.langToCode){e.next=2;break}return e.abrupt("return");case 2: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")).classList.add("showingTranslation"),j(o).css({width:j(i).css("width"),height:j(i).css("height"),transform:j(i).css("transform"),"pointer-events":j(i).css("pointer-events"),"z-index":3}),s=this.getParagraphsOnPage(t),l=s.map(function(){var e=W($().mark((function e(n,i){var l,u,f,h,d,p,g,m,y;return $().wrap((function(e){for(;;)switch(e.prev=e.next){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],n.classList.contains("ocr-role-header-footer")&&(l.ariaHidden="true",l.classList.add("ocr-role-header-footer")),f="".concat(parseInt(j(u).css("font-size")),"px"),j(l).css({"margin-left":j(u).css("margin-left"),"margin-top":j(u).css("margin-top"),top:j(u).css("top"),height:j(u).css("height"),width:j(u).css("width"),"font-size":f}),o.append(l)),0===n.textContent.length){e.next=16;break}return p=parseFloat(a)+r+i,c.translationManager.getTranslationModel(c.langFromCode,c.langToCode).then((function(){c._panel.loadingModel=!1,c.loadingModel=!1})),e.next=7,c.translationManager.getTranslation(c.langFromCode,c.langToCode,a,i,n.textContent,p);case 7:g=e.sent,null===(h=l.firstElementChild)||void 0===h||h.remove(),m=null===(d=s[i])||void 0===d||null===(d=d.firstChild)||void 0===d?void 0:d.firstChild,(y=document.createElement("span")).className="BRlineElement",y.textContent=g,l.appendChild(y),j(y).css({"text-indent":j(m).css("padding-left")}),t.classList.contains("BRpage-visible")&&c.fitVisiblePage(l);case 16:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}()),null===(n=this.textSelectionManager)||void 0===n||n.stopPageFlip(this.br.refs.$brContainer),e.next=12,Promise.all(l);case 12:this.br.trigger("translateLayerRendered",{leafIndex:a,translateLayer:o});case 13:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"getTranslateLayers",value:(r=W($().mark((function e(t){var r,n,a=this;return $().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.br.getActivePageContainerElementsForIndex(t),!(n=j(r).filter("[data-index='".concat(t,"']")).find(".BRtranslateLayer")).length){e.next=4;break}return e.abrupt("return",n.toArray());case 4:return e.abrupt("return",new Promise((function(e,r){var n=function(){var r=W($().mark((function r(o,i){return $().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:i.leafIndex==t&&(a.br.off("translateLayerRendered",n),e([i.translateLayer]));case 1:case"end":return r.stop()}}),r)})));return function(e,t){return r.apply(this,arguments)}}();a.br.on("translateLayerRendered",n)})));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return r.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){var t=e.parentElement;if("none"==j(t).css("transform")){var r=e.getAttribute("data-translate-index").split("-")[0],n=document.querySelector("[data-index='".concat(r,"'] .BRtextLayer"));j(t).css({transform:n.style.transform})}for(var a=parseInt(j(e).css("font-size"));e.clientHeight<e.scrollHeight&&a>0;)a--,j(e).css({"font-size":"".concat(a,"px")});var o=e.firstElementChild.clientHeight,i=e.scrollHeight;if(o<i){var s=i/(o/a);j(e).css({"line-height":"".concat(s,"px"),overflow:"visible"})}}},{key:"_render",value:function(){var e=this;this.br.shell.menuProviders.translate={id:"translate",icon:(0,n.qy)(v||(v=q(["<img src='",'/translate.svg\' width="26"/>'])),this.br.options.imagesBaseURL),label:"Translate",component:(0,n.qy)(b||(b=q(['<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 r,a,o}(a.S);null==ce||ce.registerPlugin("translate",ue),re=[(0,o.EM)("br-translate-panel")],ne=n.WF,ie=_(),ae=function(e){ie.initializeInstanceElements(e,le.elements)},oe=function(e){function t(){var e;K(this,t);for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return e=Z(this,t,[].concat(n)),ae(e),e}return X(t,e),Y(t)}(ne),se={F:oe,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,r,n,a;(e=oe,t="connectedCallback",r=this,a=I(J(1&(n=3)?e.prototype:e),t,r),2&n&&"function"==typeof a?function(e){return a.apply(r,e)}:a)([]),this.dispatchEvent(new CustomEvent("connected"))}},{kind:"method",key:"render",value:function(){var e=this;return(0,n.qy)(w||(w=q(['<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,T.sortBy)(this.toLanguages,(function(e){return e.name.toLowerCase()})).map((function(t){return(0,n.qy)(k||(k=q(['<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,T.sortBy)(this.fromLanguages,(function(e){return e.name.toLowerCase()})).map((function(t){return(0,n.qy)(x||(x=q(['<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(O(this.fromLanguages),O(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,n.qy)(L||(L=q(['\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,n.qy)(S||(S=q(["<p>Language model loaded</p>"]))):""}}]},le=ie.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},n=0;n<e.length;n++){var a,o=e[n];if("method"===o.kind&&(a=t.find(r)))if(R(o.descriptor)||R(a.descriptor)){if(z(o)||z(a))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");a.descriptor=o.descriptor}else{if(z(o)){if(z(a))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");a.decorators=o.decorators}M(o,a)}else t.push(o)}return t}(se.d.map(A)),re),ie.initializeClassElements(se.F,le.elements),ie.runClassFinishers(se.F,le.finishers)},4160:function(e,t,r){r.d(t,{$x:function(){return m},EF:function(){return u},ND:function(){return g},m0:function(){return f},YH:function(){return d}}),r(2675),r(9463),r(6412),r(2259),r(8125),r(8706),r(3418),r(3792),r(2062),r(4490),r(4782),r(2010),r(4731),r(479),r(875),r(6099),r(3362),r(7495),r(8781),r(7764),r(1761),r(3500),r(2953);var n=[],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,n.push(t)}));var s=n;function l(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return c(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},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(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){s=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw o}}}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}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 h={"zh-hans":"中文 (Zhōngwén)"};function d(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e?p(e=e.toLowerCase(),["iso639_1"],t)||p(e,["iso639_2T"],t)||p(e,["iso639_2B","nativeName","name"],t):null}function p(e,t,r){var n,a=l(s);try{for(a.s();!(n=a.n()).done;){var o,i=n.value,c=l(t);try{for(c.s();!(o=c.n()).done;)if(-1!=i[o.value].split(", ").map((function(e){return e.toLowerCase()})).indexOf(e))return r?"".concat(i.nativeName.split(", ")[0]," (").concat(i.iso639_1,")"):i.iso639_1}catch(e){c.e(e)}finally{c.f()}}}catch(e){a.e(e)}finally{a.f()}return h[e]?"".concat(h[e]," (").concat(e,")"):null}function g(){try{return!!window.localStorage}catch(e){return!1}}var m=-1!=location.toString().indexOf("_debugReadAloud=true")},593:function(e,t,r){r.d(t,{bg:function(){return b}}),r(2675),r(9463),r(6412),r(2259),r(5700),r(8125),r(113),r(3418),r(3792),r(8598),r(4490),r(4782),r(9572),r(2010),r(4731),r(479),r(8130),r(875),r(6099),r(3362),r(7495),r(8781),r(7764),r(5440),r(3500),r(2953);var n=r(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 r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,s(n.key),n)}}function i(e,t,r){return(t=s(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e){var t=function(e,t){if("object"!=a(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.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,r){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=n(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()&&n(e.anchorNode).closest(a.selector)[0]||(a.selecting=!1,a.handler("cleared",a.target))})),this.selector=t,this.handler=r},(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=r(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(){f=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function h(e,t,r,n){var o=t&&t.prototype instanceof b?t:b,i=Object.create(o.prototype),s=new A(n||[]);return a(i,"_invoke",{value:j(e,r,s)}),i}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=h;var p="suspendedStart",g="suspendedYield",m="executing",y="completed",v={};function b(){}function w(){}function k(){}var x={};c(x,i,(function(){return this}));var L=Object.getPrototypeOf,S=L&&L(L(M([])));S&&S!==r&&n.call(S,i)&&(x=S);var E=k.prototype=b.prototype=Object.create(x);function T(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function r(a,o,i,s){var l=d(e[a],e,o);if("throw"!==l.type){var c=l.arg,f=c.value;return f&&"object"==u(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,i,s)}),(function(e){r("throw",e,i,s)})):t.resolve(f).then((function(e){c.value=e,i(c)}),(function(e){return r("throw",e,i,s)}))}s(l.arg)}var o;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return o=o?o.then(a,a):a()}})}function j(t,r,n){var a=p;return function(o,i){if(a===m)throw Error("Generator is already running");if(a===y){if("throw"===o)throw i;return{value:e,done:!0}}for(n.method=o,n.arg=i;;){var s=n.delegate;if(s){var l=P(s,n);if(l){if(l===v)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===p)throw a=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=m;var c=d(t,r,n);if("normal"===c.type){if(a=n.done?y:g,c.arg===v)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(a=y,n.method="throw",n.arg=c.arg)}}}function P(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,P(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=d(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function M(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,o=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(u(t)+" is not iterable")}return w.prototype=k,a(E,"constructor",{value:k,configurable:!0}),a(k,"constructor",{value:w,configurable:!0}),w.displayName=c(k,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,k):(e.__proto__=k,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},T(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,r,n,a,o){void 0===o&&(o=Promise);var i=new C(h(e,r,n,a),o);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},T(E),c(E,l,"Generator"),c(E,i,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=M,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(_),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(l&&c){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(l){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),_(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;_(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:M(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}var h=f().mark(w),d=f().mark(k);function p(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return g(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},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(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){s=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(s)throw o}}}}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function m(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,v(n.key),n)}}function y(e,t,r){return(t=v(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(e){var t=function(e,t){if("object"!=u(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.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 b=function(){return e=function e(t,r,n,a){var o=this,i=n.selectionElement;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),y(this,"options",{maxProtectedWords:200}),y(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)}})),y(this,"_limitSelection",(function(){var e=window.getSelection();if(e.rangeCount){var t=e.getRangeAt(0),r=!!t.startContainer.parentElement.closest(".BRcontainer"),n=!!t.endContainer.parentElement.closest(".BRcontainer");if(r||n)if(r&&n){var a=function(e,t){var r,n=0,a=p(e);try{for(a.s();!(r=a.n()).done;){var o=r.value;if(n==t)return o;n++}}catch(e){a.e(e)}finally{a.f()}}(w(k(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=r,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 r;"started"==t&&(null===(r=e.br.plugins.archiveAnalytics)||void 0===r||r.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 r=document.getSelection();if(null!=r&&r.toString()&&c(e.layer).toArray().some((function(e){return r.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,r=e.find(this.layer);r.length&&(r.each((function(e,r){return t.defaultMode(r)})),this.br.protected||this.interceptCopy(e))}},{key:"defaultMode",value:function(e){var t=this,r=c(e).closest(".BRpagecontainer");e.style.pointerEvents="none",r.find("img").css("pointer-events","auto"),c(e).off(".textSelectPluginHandler");var n=this.mouseIsDown,a=this.mouseIsDown;n&&(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(r){t.mouseIsDown=!1,e.style.pointerEvents="none",a&&(a=!1,r.stopPropagation())}))}},{key:"textSelectingMode",value:function(e){var t=this,r=c(e).closest(".BRpagecontainer");e.style.pointerEvents="all",r.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&&m(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function w(e,t){var r,n,a;return f().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:r=p(e),o.prev=1,r.s();case 3:if((n=r.n()).done){o.next=10;break}if(a=n.value,!t(a)){o.next=8;break}return o.next=8,a;case 8:o.next=3;break;case 10:o.next=15;break;case 12:o.prev=12,o.t0=o.catch(1),r.e(o.t0);case 15:return o.prev=15,r.f(),o.finish(15);case 18:case"end":return o.stop()}}),h,null,[[1,12,15,18]])}function k(e,t){var r,n;return f().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return n=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 f().mark((function a(){var o;return f().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(e!==t){a.next=5;break}return r=!0,a.next=4,e;case 4:return a.abrupt("return");case 5:return a.next=7,e;case 7:if(!i||!e.firstChild){a.next=11;break}return a.delegateYield(n(e.firstChild,{children:!0,parents:!1,siblings:!0}),"t0",9);case 9:if(!r){a.next=11;break}return a.abrupt("return");case 11:if(!u){a.next=20;break}o=e.nextSibling;case 13:if(!o){a.next=20;break}return a.delegateYield(n(o,{children:!0,parents:!1,siblings:!1}),"t1",15);case 15:if(!r){a.next=17;break}return a.abrupt("return");case 17:o=o.nextSibling,a.next=13;break;case 20:if(!l||!e.parentNode){a.next=24;break}return a.delegateYield(n(e.parentNode,{children:!1,parents:!0,siblings:!0}),"t2",22);case 22:if(!r){a.next=24;break}return a.abrupt("return");case 24:case"end":return a.stop()}}),a)}))()},r=!1,a.delegateYield(n(e),"t0",3);case 3:case"end":return a.stop()}}),d)}},4565:function(e,t,r){function n(e){return n="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},n(e)}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}function o(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,"string");if("object"!=n(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==n(t)?t:t+""}r.d(t,{l:function(){return i}}),r(2675),r(9463),r(2259),r(5700),r(3792),r(9572),r(8130),r(6099),r(7764),r(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
|
+
`}}window.customElements.define("ia-activity-indicator",o)},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}()},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",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=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){w._initResolve=e,w._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&&this.fromLanguages.push({code:y,name:(0,u.YH)(y,!0),type:"prod"}),"en"!==v&&this.toLanguages.push({code:v,name:(0,u.YH)(v,!0),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),x=n(593),P=(n(4360),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 x.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")).classList.add("showingTranslation"),P(o).css({width:P(i).css("width"),height:P(i).css("height"),transform:P(i).css("transform"),"pointer-events":P(i).css("pointer-events"),"z-index":3}),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(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":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),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: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=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(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){var t=e.parentElement;if("none"==P(t).css("transform")){var n=e.getAttribute("data-translate-index").split("-")[0],r=document.querySelector("[data-index='".concat(n,"'] .BRtextLayer"));P(t).css({transform:r.style.transform})}for(var a=parseInt(P(e).css("font-size"));e.clientHeight<e.scrollHeight&&a>0;)a--,P(e).css({"font-size":"".concat(a,"px")});var o=e.firstElementChild.clientHeight,i=e.scrollHeight;if(o<i){var s=i/(o/a);P(e).css({"line-height":"".concat(s,"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)}},function(e){e(e.s=6735)}]);
|
|
137
137
|
//# sourceMappingURL=plugin.translate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/
|
|
1
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|