'use strict';function n(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}}function q(a){var b=typeof Symbol!="undefined"&&Symbol.iterator&&a[Symbol.iterator];if(b)return b.call(a);if(typeof a.length=="number")return{next:n(a)};throw Error(String(a)+" is not an iterable or ArrayLike");}var u=typeof Object.defineProperties=="function"?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};
function w(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var y=w(this);function z(a,b){if(b)a:{var c=y;a=a.split(".");for(var g=0;g<a.length-1;g++){var k=a[g];if(!(k in c))break a;c=c[k]}a=a[a.length-1];g=c[a];b=b(g);b!=g&&b!=null&&u(c,a,{configurable:!0,writable:!0,value:b})}}
function A(a){if(!(a instanceof Object))throw new TypeError("Iterator result "+a+" is not an object");}function B(){this.v=!1;this.m=null;this.i=void 0;this.h=1;this.l=this.u=0;this.D=this.j=null}function C(a){if(a.v)throw new TypeError("Generator is already running");a.v=!0}B.prototype.C=function(a){this.i=a};function D(a,b){a.j={K:b,isException:!0};a.h=a.u||a.l}B.prototype.getNextAddressJsc=function(){return this.h};B.prototype.getYieldResultJsc=function(){return this.i};
B.prototype.return=function(a){this.j={return:a};this.h=this.l};B.prototype["return"]=B.prototype.return;B.prototype.N=function(a){this.j={F:a};this.h=this.l};B.prototype.jumpThroughFinallyBlocks=B.prototype.N;B.prototype.g=function(a,b){this.h=b;return{value:a}};B.prototype.yield=B.prototype.g;B.prototype.R=function(a,b){a=q(a);var c=a.next();A(c);if(c.done)this.i=c.value,this.h=b;else return this.m=a,this.g(c.value,b)};B.prototype.yieldAll=B.prototype.R;B.prototype.F=function(a){this.h=a};
B.prototype.jumpTo=B.prototype.F;B.prototype.o=function(){this.h=0};B.prototype.jumpToEnd=B.prototype.o;B.prototype.B=function(a,b){this.u=a;b!=void 0&&(this.l=b)};B.prototype.setCatchFinallyBlocks=B.prototype.B;B.prototype.P=function(a){this.u=0;this.l=a||0};B.prototype.setFinallyBlock=B.prototype.P;B.prototype.G=function(a,b){this.h=a;this.u=b||0};B.prototype.leaveTryBlock=B.prototype.G;B.prototype.A=function(a){this.u=a||0;a=this.j.K;this.j=null;return a};B.prototype.enterCatchBlock=B.prototype.A;
B.prototype.I=function(a,b,c){c?this.D[c]=this.j:this.D=[this.j];this.u=a||0;this.l=b||0};B.prototype.enterFinallyBlock=B.prototype.I;B.prototype.O=function(a,b){b=this.D.splice(b||0)[0];(b=this.j=this.j||b)?b.isException?this.h=this.u||this.l:b.F!=void 0&&this.l<b.F?(this.h=b.F,this.j=null):this.h=this.l:this.h=a};B.prototype.leaveFinallyBlock=B.prototype.O;B.prototype.M=function(a){return new E(a)};B.prototype.forIn=B.prototype.M;
function E(a){this.i=a;this.g=[];for(var b in a)this.g.push(b);this.g.reverse()}E.prototype.h=function(){for(;this.g.length>0;){var a=this.g.pop();if(a in this.i)return a}return null};E.prototype.getNext=E.prototype.h;function F(a){this.g=new B;this.h=a}function G(a,b){C(a.g);var c=a.g.m;if(c)return H(a,"return"in c?c["return"]:function(g){return{value:g,done:!0}},b,a.g.return);a.g.return(b);return I(a)}
function H(a,b,c,g){try{var k=b.call(a.g.m,c);A(k);if(!k.done)return a.g.v=!1,k;var m=k.value}catch(e){return a.g.m=null,D(a.g,e),I(a)}a.g.m=null;g.call(a.g,m);return I(a)}function I(a){for(;a.g.h;)try{var b=a.h(a.g);if(b)return a.g.v=!1,{value:b.value,done:!1}}catch(c){a.g.i=void 0,D(a.g,c)}a.g.v=!1;if(a.g.j){b=a.g.j;a.g.j=null;if(b.isException)throw b.K;return{value:b.return,done:!0}}return{value:void 0,done:!0}}
function aa(a){this.next=function(b){C(a.g);a.g.m?b=H(a,a.g.m.next,b,a.g.C):(a.g.C(b),b=I(a));return b};this.throw=function(b){C(a.g);a.g.m?b=H(a,a.g.m["throw"],b,a.g.C):(D(a.g,b),b=I(a));return b};this.return=function(b){return G(a,b)};this[Symbol.iterator]=function(){return this}}function ba(a){function b(g){return a.next(g)}function c(g){return a.throw(g)}return new Promise(function(g,k){function m(e){e.done?g(e.value):Promise.resolve(e.value).then(b,c).then(m,k)}m(a.next())})}
function J(a){return ba(new aa(new F(a)))}z("Symbol",function(a){function b(m){if(this instanceof b)throw new TypeError("Symbol is not a constructor");return new c(g+(m||"")+"_"+k++,m)}function c(m,e){this.g=m;u(this,"description",{configurable:!0,writable:!0,value:e})}if(a)return a;c.prototype.toString=function(){return this.g};var g="jscomp_symbol_"+(Math.random()*1E9>>>0)+"_",k=0;return b});
z("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");u(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return K(n(this))}});return a});function K(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}
z("Promise",function(a){function b(e){this.h=0;this.i=void 0;this.g=[];this.o=!1;var d=this.j();try{e(d.resolve,d.reject)}catch(f){d.reject(f)}}function c(){this.g=null}function g(e){return e instanceof b?e:new b(function(d){d(e)})}if(a)return a;c.prototype.h=function(e){if(this.g==null){this.g=[];var d=this;this.i(function(){d.l()})}this.g.push(e)};var k=y.setTimeout;c.prototype.i=function(e){k(e,0)};c.prototype.l=function(){for(;this.g&&this.g.length;){var e=this.g;this.g=[];for(var d=0;d<e.length;++d){var f=
e[d];e[d]=null;try{f()}catch(h){this.j(h)}}}this.g=null};c.prototype.j=function(e){this.i(function(){throw e;})};b.prototype.j=function(){function e(h){return function(l){f||(f=!0,h.call(d,l))}}var d=this,f=!1;return{resolve:e(this.C),reject:e(this.l)}};b.prototype.C=function(e){if(e===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(e instanceof b)this.G(e);else{a:switch(typeof e){case "object":var d=e!=null;break a;case "function":d=!0;break a;default:d=!1}d?this.B(e):this.m(e)}};
b.prototype.B=function(e){var d=void 0;try{d=e.then}catch(f){this.l(f);return}typeof d=="function"?this.I(d,e):this.m(e)};b.prototype.l=function(e){this.u(2,e)};b.prototype.m=function(e){this.u(1,e)};b.prototype.u=function(e,d){if(this.h!=0)throw Error("Cannot settle("+e+", "+d+"): Promise already settled in state"+this.h);this.h=e;this.i=d;this.h===2&&this.D();this.v()};b.prototype.D=function(){var e=this;k(function(){if(e.A()){var d=y.console;typeof d!=="undefined"&&d.error(e.i)}},1)};b.prototype.A=
function(){if(this.o)return!1;var e=y.CustomEvent,d=y.Event,f=y.dispatchEvent;if(typeof f==="undefined")return!0;typeof e==="function"?e=new e("unhandledrejection",{cancelable:!0}):typeof d==="function"?e=new d("unhandledrejection",{cancelable:!0}):(e=y.document.createEvent("CustomEvent"),e.initCustomEvent("unhandledrejection",!1,!0,e));e.promise=this;e.reason=this.i;return f(e)};b.prototype.v=function(){if(this.g!=null){for(var e=0;e<this.g.length;++e)m.h(this.g[e]);this.g=null}};var m=new c;b.prototype.G=
function(e){var d=this.j();e.H(d.resolve,d.reject)};b.prototype.I=function(e,d){var f=this.j();try{e.call(d,f.resolve,f.reject)}catch(h){f.reject(h)}};b.prototype.then=function(e,d){function f(p,t){return typeof p=="function"?function(x){try{h(p(x))}catch(v){l(v)}}:t}var h,l,r=new b(function(p,t){h=p;l=t});this.H(f(e,h),f(d,l));return r};b.prototype.catch=function(e){return this.then(void 0,e)};b.prototype.H=function(e,d){function f(){switch(h.h){case 1:e(h.i);break;case 2:d(h.i);break;default:throw Error("Unexpected state: "+
h.h);}}var h=this;this.g==null?m.h(f):this.g.push(f);this.o=!0};b.resolve=g;b.reject=function(e){return new b(function(d,f){f(e)})};b.race=function(e){return new b(function(d,f){for(var h=q(e),l=h.next();!l.done;l=h.next())g(l.value).H(d,f)})};b.all=function(e){var d=q(e),f=d.next();return f.done?g([]):new b(function(h,l){function r(x){return function(v){p[x]=v;t--;t==0&&h(p)}}var p=[],t=0;do p.push(void 0),t++,g(f.value).H(r(p.length-1),l),f=d.next();while(!f.done)})};return b});
function L(a,b){return Object.prototype.hasOwnProperty.call(a,b)}
z("WeakMap",function(a){function b(f){this.g=(d+=Math.random()+1).toString();if(f){f=q(f);for(var h;!(h=f.next()).done;)h=h.value,this.set(h[0],h[1])}}function c(){}function g(f){var h=typeof f;return h==="object"&&f!==null||h==="function"}function k(f){if(!L(f,e)){var h=new c;u(f,e,{value:h})}}function m(f){var h=Object[f];h&&(Object[f]=function(l){if(l instanceof c)return l;Object.isExtensible(l)&&k(l);return h(l)})}if(function(){if(!a||!Object.seal)return!1;try{var f=Object.seal({}),h=Object.seal({}),
l=new a([[f,2],[h,3]]);if(l.get(f)!=2||l.get(h)!=3)return!1;l.delete(f);l.set(h,4);return!l.has(f)&&l.get(h)==4}catch(r){return!1}}())return a;var e="$jscomp_hidden_"+Math.random();m("freeze");m("preventExtensions");m("seal");var d=0;b.prototype.set=function(f,h){if(!g(f))throw Error("Invalid WeakMap key");k(f);if(!L(f,e))throw Error("WeakMap key fail: "+f);f[e][this.g]=h;return this};b.prototype.get=function(f){return g(f)&&L(f,e)?f[e][this.g]:void 0};b.prototype.has=function(f){return g(f)&&L(f,
e)&&L(f[e],this.g)};b.prototype.delete=function(f){return g(f)&&L(f,e)&&L(f[e],this.g)?delete f[e][this.g]:!1};return b});
z("Map",function(a){function b(){var d={};return d.previous=d.next=d.head=d}function c(d,f){var h=d[1];return K(function(){if(h){for(;h.head!=d[1];)h=h.previous;for(;h.next!=h.head;)return h=h.next,{done:!1,value:f(h)};h=null}return{done:!0,value:void 0}})}function g(d,f){var h=f&&typeof f;h=="object"||h=="function"?m.has(f)?h=m.get(f):(h=""+ ++e,m.set(f,h)):h="p_"+f;var l=d[0][h];if(l&&L(d[0],h))for(d=0;d<l.length;d++){var r=l[d];if(f!==f&&r.key!==r.key||f===r.key)return{id:h,list:l,index:d,entry:r}}return{id:h,
list:l,index:-1,entry:void 0}}function k(d){this[0]={};this[1]=b();this.size=0;if(d){d=q(d);for(var f;!(f=d.next()).done;)f=f.value,this.set(f[0],f[1])}}if(function(){if(!a||typeof a!="function"||!a.prototype.entries||typeof Object.seal!="function")return!1;try{var d=Object.seal({x:4}),f=new a(q([[d,"s"]]));if(f.get(d)!="s"||f.size!=1||f.get({x:4})||f.set({x:4},"t")!=f||f.size!=2)return!1;var h=f.entries(),l=h.next();if(l.done||l.value[0]!=d||l.value[1]!="s")return!1;l=h.next();return l.done||l.value[0].x!=
4||l.value[1]!="t"||!h.next().done?!1:!0}catch(r){return!1}}())return a;var m=new WeakMap;k.prototype.set=function(d,f){d=d===0?0:d;var h=g(this,d);h.list||(h.list=this[0][h.id]=[]);h.entry?h.entry.value=f:(h.entry={next:this[1],previous:this[1].previous,head:this[1],key:d,value:f},h.list.push(h.entry),this[1].previous.next=h.entry,this[1].previous=h.entry,this.size++);return this};k.prototype.delete=function(d){d=g(this,d);return d.entry&&d.list?(d.list.splice(d.index,1),d.list.length||delete this[0][d.id],
d.entry.previous.next=d.entry.next,d.entry.next.previous=d.entry.previous,d.entry.head=null,this.size--,!0):!1};k.prototype.clear=function(){this[0]={};this[1]=this[1].previous=b();this.size=0};k.prototype.has=function(d){return!!g(this,d).entry};k.prototype.get=function(d){return(d=g(this,d).entry)&&d.value};k.prototype.entries=function(){return c(this,function(d){return[d.key,d.value]})};k.prototype.keys=function(){return c(this,function(d){return d.key})};k.prototype.values=function(){return c(this,
function(d){return d.value})};k.prototype.forEach=function(d,f){for(var h=this.entries(),l;!(l=h.next()).done;)l=l.value,d.call(f,l[1],l[0],this)};k.prototype[Symbol.iterator]=k.prototype.entries;var e=0;return k});z("Object.entries",function(a){return a?a:function(b){var c=[],g;for(g in b)L(b,g)&&c.push([g,b[g]]);return c}});function ca(a){this.g=a}var M;function da(){var a=M;a.g.runtime.getPlatformInfo();setInterval(function(){a.g.runtime.getPlatformInfo()},2E4)};function ea(a){a.g.ttsEngine.onSpeak.addListener(a.B);a.g.ttsEngine.onStop.addListener(a.C);a.g.ttsEngine.onPause.addListener(a.v);a.g.ttsEngine.onResume.addListener(a.A);a.g.ttsEngine.onInstallLanguageRequest.addListener(a.o);a.g.ttsEngine.onLanguageStatusRequest.addListener(a.u);a.g.ttsEngine.onUninstallLanguageRequest.addListener(a.D);a.g.runtime.onMessage.addListener(function(b){b.type==="offscreenTtsEventResponse"&&N(a,b.event)})}
function O(a,b,c){if(typeof a==="object"&&typeof b==="string"){var g=a;a=b}else if(typeof a==="string"&&typeof b==="function")c=b;else return{lang:"",J:!1};return{lang:a,S:c,L:g,J:!0}}function fa(a){J(function(b){return b.return(ha(a))})}function N(a,b){J(function(c){if(c.h==1)return c.g(P(a),2);if(!c.i)return c.return();Q(a);a.h&&a.h(b);if(b.type==="end"||b.type==="error")R(a),b.type==="error"&&(a.h=void 0);c.o()})}
function P(a){return J(function(b){return b.h==1?b.g(a.g.offscreen.hasDocument(),2):b.return(b.i)})}
function S(a){var b,c;return J(function(g){switch(g.h){case 1:return g.g(P(a),2);case 2:if(g.i)return g.return();g.B(3);return g.g(a.g.offscreen.createDocument({url:"offscreen.html",reasons:[a.g.offscreen.Reason.AUDIO_PLAYBACK,a.g.offscreen.Reason.USER_MEDIA],justification:"Required for Text-to-Speech audio synthesis and playback"}),5);case 5:return b={type:"init"},g.g(a.g.runtime.sendMessage(b),6);case 6:return R(a),g.g(ia(a.i),7);case 7:g.G(0);break;case 3:throw c=g.A(),console.error("Failed to create offscreen document:",
c),c;}})}function T(a){return J(function(b){if(b.h==1)return b.g(P(a),2);if(b.h!=3)return b.i?b.g(a.g.offscreen.closeDocument(),3):b.return();b.o()})}function U(a){var b;return J(function(c){if(c.h==1)return c.B(2),c.g(S(a),4);if(c.h!=2)return c.return(!0);b=c.A();console.error("Error ensuring offscreen document is ready:",b);return c.return(!1)})}function V(a){a.m&&(clearTimeout(a.m),a.m=void 0)}function R(a){V(a);a.m=setTimeout(function(){T(a)},3E5)}
function Q(a){a.j&&(clearTimeout(a.j),a.j=void 0)}function ja(a){Q(a);var b=setTimeout(function(){return J(function(c){if(a.j!==b)return c.return();a.j=void 0;a.h&&(a.h({type:"error",errorMessage:"Timeout waiting for speech to start."}),a.h=void 0);return c.g(T(a),0)})},1E4);a.j=b};function ka(){this.g=chrome;this.h=new Map}function la(a,b){var c,g,k;return J(function(m){if(m.h==1)return c={type:"getLanguageStatus",lang:b},m.g(a.g.runtime.sendMessage(c),2);g=m.i;k={lang:g.lang,installStatus:g.status};a.g.ttsEngine.updateLanguage(k);m.o()})}
function ma(a){var b=W.i,c,g,k,m,e,d,f,h,l,r,p,t;J(function(x){c=[];g=q(Object.entries(a));for(k=g.next();!k.done;k=g.next())for(m=k.value,e=q(m),d=e.next().value,f=e.next().value,h=d,l=f,r=q(l),p=r.next();!p.done;p=r.next())t=p.value,c.push({lang:h,voiceName:t,eventTypes:["start","end","error","word"]});b.g.ttsEngine.updateVoices(c);x.o()})}
function ha(a){var b=W.i,c,g;return J(function(k){if(k.h==1)return b.h.get(a)==="uninstallLanguage"&&b.h.delete(a),k.g(X(b),2);c=k.i;c[a]=Date.now();g={};return k.g(b.g.storage.local.set((g.lastUsedTimestamps=c,g)),0)})}
function ia(a){var b,c,g,k,m,e,d,f,h;return J(function(l){switch(l.h){case 1:return l.g(Y(a),2);case 2:return(b=l.i)?l.g(X(a),3):l.return();case 3:c=l.i;g=na(b,c);if(g.length===0)return l.return();k=q(g);m=k.next();case 4:if(m.done)return f={},l.g(a.g.storage.local.set((f.installedTimestamps=b,f)),8);e=m.value;d={type:"removeUnusedLanguage",lang:e};return l.g(a.g.runtime.sendMessage(d),7);case 7:e in b&&delete b[e];e in c&&delete c[e];m=k.next();l.F(4);break;case 8:return h={},l.g(a.g.storage.local.set((h.lastUsedTimestamps=
c,h)),0)}})}function na(a,b){var c=Date.now();return Object.entries(a).filter(function(g){var k=q(g);g=k.next().value;k=k.next().value;var m=g in b;return c-Number(m?b[g]:k)>(m?7776E6:12096E5)}).map(function(g){return q(g).next().value})}function Z(a){a.i&&clearTimeout(a.i);a.i=setTimeout(function(){oa(a)},200)}
function oa(a){var b,c,g,k,m,e,d,f,h,l,r,p,t,x;J(function(v){switch(v.h){case 1:if(a.h.size===0)return v.return();b=new Map(a.h);a.h.clear();c=[];g=[];k=q(b);m=k.next();case 2:if(m.done)return v.g(pa(a,g),6);e=m.value;d=q(e);f=d.next().value;h=d.next().value;l=f;r=h;p={type:r,lang:l};return v.g(a.g.runtime.sendMessage(p),5);case 5:t=v.i;x={lang:t.lang,installStatus:t.status};a.g.ttsEngine.updateLanguage(x);switch(t.status){case a.g.ttsEngine.LanguageInstallStatus.INSTALLED:c.push(l);break;case a.g.ttsEngine.LanguageInstallStatus.NOT_INSTALLED:g.push(l)}m=
k.next();v.F(2);break;case 6:return v.return(qa(a,c))}})}function pa(a,b){var c,g,k,m,e;return J(function(d){if(d.h==1)return d.g(Y(a),2);c=d.i;g=q(b);for(k=g.next();!k.done;k=g.next())m=k.value,delete c[m];e={};return d.g(a.g.storage.local.set((e.installedTimestamps=c,e)),0)})}function qa(a,b){var c,g,k;return J(function(m){if(m.h==1)return c=Date.now(),m.g(Y(a),2);g=m.i;b.forEach(function(e){g[e]=c});k={};return m.g(a.g.storage.local.set((k.installedTimestamps=g,k)),0)})}
function Y(a){var b;return J(function(c){if(c.h==1)return c.g(a.g.storage.local.get("installedTimestamps"),2);b=c.i;return c.return(b.installedTimestamps||{})})}function X(a){var b;return J(function(c){if(c.h==1)return c.g(a.g.storage.local.get("lastUsedTimestamps"),2);b=c.i;return c.return(b.lastUsedTimestamps||{})})};var W=new function(){var a=new ka,b=this;this.g=chrome;this.i=a;this.B=function(c,g,k){var m,e,d,f;return J(function(h){switch(h.h){case 1:return V(b),b.h=k,ja(b),h.B(2),h.g(U(b),4);case 4:if(!h.i)throw Error("Offscreen document not ready.");m={type:"speak",utterance:c,options:g};return h.g(b.g.runtime.sendMessage(m),5);case 5:if((e=h.i)&&e.error)throw Error(e.error);h.G(0);break;case 2:return d=h.A(),Q(b),f=d instanceof Error?d.message:"Error while trying to speak.",k({type:"error",errorMessage:f}),
b.h=void 0,h.g(T(b),0)}})};this.C=function(){var c;return J(function(g){if(g.h==1)return g.g(P(b),2);if(g.h!=3){if(!g.i)return R(b),g.return();b.h=void 0;c={type:"stop"};Q(b);return g.g(b.g.runtime.sendMessage(c),3)}R(b);g.o()})};this.v=function(){var c;return J(function(g){if(g.h==1)return g.g(U(b),2);if(!g.i)return g.return();c={type:"pause"};return g.g(b.g.runtime.sendMessage(c),0)})};this.A=function(){var c;return J(function(g){if(g.h==1)return g.g(U(b),2);if(!g.i)return g.return();c={type:"resume"};
return g.g(b.g.runtime.sendMessage(c),0)})};this.o=function(c,g,k){var m,e,d,f,h,l,r;return J(function(p){if(p.h==1)return p.g(U(b),2);if(!p.i)return p.return();m=O(c,g,k);e=m.lang;d=m.L;f=m.J;r=(l=(h=d)==null?void 0:h.source)!=null?l:"unknown";if(!f||r!==b.l)return p.return();var t=b.i;t.h.set(e,"installLanguage");Z(t);t.g.ttsEngine.updateLanguage({lang:e,installStatus:t.g.ttsEngine.LanguageInstallStatus.INSTALLING});p.o()})};this.u=function(c,g,k){var m,e,d,f,h,l,r;return J(function(p){if(p.h==
1)return p.g(U(b),2);if(!p.i)return p.return();m=O(c,g,k);e=m.lang;d=m.L;f=m.J;r=(l=(h=d)==null?void 0:h.source)!=null?l:"unknown";return f&&r===b.l?p.return(la(b.i,e)):p.return()})};this.D=function(c,g){return J(function(k){if(k.h==1)return k.g(U(b),2);if(!k.i||c.source!==b.l)return k.return();var m=b.i;m.h.set(g,"uninstallLanguage");Z(m);k.o()})};this.l=this.g.ttsEngine.TtsClientSource.CHROMEFEATURE;this.g.runtime.onInstalled.addListener(function(){return J(function(c){return c.g(S(b),0)})});this.g.runtime.onStartup.addListener(function(){return J(function(c){return c.g(U(b),
0)})});ea(this);M||(M=new ca(this.g),da())};chrome.runtime.onMessage.addListener(function(a){a.type==="offscreenVoicesResponse"?ma(a.voices):a.type==="offscreenTtsEventResponse"?N(W,a.event):a.type==="languageUsed"&&fa(a.language);return!0});
