@vkontakte/videoplayer-core 2.0.119-dev.c81726f6.0 → 2.0.119-dev.dc40b896.0

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/es2015.cjs.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @vkontakte/videoplayer-core v2.0.119-dev.c81726f6.0
3
- * Tue, 10 Dec 2024 13:48:30 GMT
2
+ * @vkontakte/videoplayer-core v2.0.119-dev.dc40b896.0
3
+ * Wed, 11 Dec 2024 12:41:21 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/2-0-119/doc/
5
5
  */
6
- "use strict";var xS=Object.create;var fi=Object.defineProperty,PS=Object.defineProperties,AS=Object.getOwnPropertyDescriptor,wS=Object.getOwnPropertyDescriptors,kS=Object.getOwnPropertyNames,ts=Object.getOwnPropertySymbols,RS=Object.getPrototypeOf,En=Object.prototype.hasOwnProperty,Wl=Object.prototype.propertyIsEnumerable;var $S=(a,e)=>(e=Symbol[a])?e:Symbol.for("Symbol."+a);var ct=Math.pow,Ql=(a,e,t)=>e in a?fi(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,R=(a,e)=>{for(var t in e||(e={}))En.call(e,t)&&Ql(a,t,e[t]);if(ts)for(var t of ts(e))Wl.call(e,t)&&Ql(a,t,e[t]);return a},H=(a,e)=>PS(a,wS(e));var Yl=(a,e)=>{var t={};for(var r in a)En.call(a,r)&&e.indexOf(r)<0&&(t[r]=a[r]);if(a!=null&&ts)for(var r of ts(a))e.indexOf(r)<0&&Wl.call(a,r)&&(t[r]=a[r]);return t};var b=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports),LS=(a,e)=>{for(var t in e)fi(a,t,{get:e[t],enumerable:!0})},zl=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of kS(e))!En.call(a,i)&&i!==t&&fi(a,i,{get:()=>e[i],enumerable:!(r=AS(e,i))||r.enumerable});return a};var X=(a,e,t)=>(t=a!=null?xS(RS(a)):{},zl(e||!a||!a.__esModule?fi(t,"default",{value:a,enumerable:!0}):t,a)),MS=a=>zl(fi({},"__esModule",{value:!0}),a);var O=(a,e,t)=>new Promise((r,i)=>{var s=u=>{try{o(t.next(u))}catch(l){i(l)}},n=u=>{try{o(t.throw(u))}catch(l){i(l)}},o=u=>u.done?r(u.value):Promise.resolve(u.value).then(s,n);o((t=t.apply(a,e)).next())}),xn=function(a,e){this[0]=a,this[1]=e},me=(a,e,t)=>{var r=(n,o,u,l)=>{try{var d=t[n](o),c=(o=d.value)instanceof xn,p=d.done;Promise.resolve(c?o[0]:o).then(h=>c?r(n==="return"?n:"next",o[1]?{done:h.done,value:h.value}:h,u,l):u({value:h,done:p})).catch(h=>r("throw",h,u,l))}catch(h){l(h)}},i=n=>s[n]=o=>new Promise((u,l)=>r(n,o,u,l)),s={};return t=t.apply(a,e),s[$S("asyncIterator")]=()=>s,i("next"),i("throw"),i("return"),s};var he=b((An,Kl)=>{"use strict";var bi=function(a){return a&&a.Math===Math&&a};Kl.exports=bi(typeof globalThis=="object"&&globalThis)||bi(typeof window=="object"&&window)||bi(typeof self=="object"&&self)||bi(typeof global=="object"&&global)||bi(typeof An=="object"&&An)||function(){return this}()||Function("return this")()});var Pe=b((l$,Jl)=>{"use strict";Jl.exports=function(a){try{return!!a()}catch(e){return!0}}});var gi=b((c$,Xl)=>{"use strict";var CS=Pe();Xl.exports=!CS(function(){var a=function(){}.bind();return typeof a!="function"||a.hasOwnProperty("prototype")})});var wn=b((d$,rc)=>{"use strict";var DS=gi(),tc=Function.prototype,Zl=tc.apply,ec=tc.call;rc.exports=typeof Reflect=="object"&&Reflect.apply||(DS?ec.bind(Zl):function(){return ec.apply(Zl,arguments)})});var ve=b((p$,sc)=>{"use strict";var ic=gi(),ac=Function.prototype,kn=ac.call,OS=ic&&ac.bind.bind(kn,kn);sc.exports=ic?OS:function(a){return function(){return kn.apply(a,arguments)}}});var or=b((h$,oc)=>{"use strict";var nc=ve(),BS=nc({}.toString),VS=nc("".slice);oc.exports=function(a){return VS(BS(a),8,-1)}});var Rn=b((f$,uc)=>{"use strict";var _S=or(),NS=ve();uc.exports=function(a){if(_S(a)==="Function")return NS(a)}});var pe=b((m$,lc)=>{"use strict";var $n=typeof document=="object"&&document.all;lc.exports=typeof $n=="undefined"&&$n!==void 0?function(a){return typeof a=="function"||a===$n}:function(a){return typeof a=="function"}});var _e=b((b$,cc)=>{"use strict";var FS=Pe();cc.exports=!FS(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Ne=b((g$,dc)=>{"use strict";var qS=gi(),as=Function.prototype.call;dc.exports=qS?as.bind(as):function(){return as.apply(as,arguments)}});var Ln=b(fc=>{"use strict";var pc={}.propertyIsEnumerable,hc=Object.getOwnPropertyDescriptor,US=hc&&!pc.call({1:2},1);fc.f=US?function(e){var t=hc(this,e);return!!t&&t.enumerable}:pc});var vi=b((S$,mc)=>{"use strict";mc.exports=function(a,e){return{enumerable:!(a&1),configurable:!(a&2),writable:!(a&4),value:e}}});var gc=b((y$,bc)=>{"use strict";var HS=ve(),jS=Pe(),GS=or(),Mn=Object,QS=HS("".split);bc.exports=jS(function(){return!Mn("z").propertyIsEnumerable(0)})?function(a){return GS(a)==="String"?QS(a,""):Mn(a)}:Mn});var Lr=b((T$,vc)=>{"use strict";vc.exports=function(a){return a==null}});var jt=b((I$,Sc)=>{"use strict";var WS=Lr(),YS=TypeError;Sc.exports=function(a){if(WS(a))throw new YS("Can't call method on "+a);return a}});var ur=b((E$,yc)=>{"use strict";var zS=gc(),KS=jt();yc.exports=function(a){return zS(KS(a))}});var Fe=b((x$,Tc)=>{"use strict";var JS=pe();Tc.exports=function(a){return typeof a=="object"?a!==null:JS(a)}});var Mr=b((P$,Ic)=>{"use strict";Ic.exports={}});var It=b((A$,xc)=>{"use strict";var Cn=Mr(),Dn=he(),XS=pe(),Ec=function(a){return XS(a)?a:void 0};xc.exports=function(a,e){return arguments.length<2?Ec(Cn[a])||Ec(Dn[a]):Cn[a]&&Cn[a][e]||Dn[a]&&Dn[a][e]}});var Si=b((w$,Pc)=>{"use strict";var ZS=ve();Pc.exports=ZS({}.isPrototypeOf)});var lr=b((k$,kc)=>{"use strict";var ey=he(),Ac=ey.navigator,wc=Ac&&Ac.userAgent;kc.exports=wc?String(wc):""});var Bn=b((R$,Dc)=>{"use strict";var Cc=he(),On=lr(),Rc=Cc.process,$c=Cc.Deno,Lc=Rc&&Rc.versions||$c&&$c.version,Mc=Lc&&Lc.v8,rt,ss;Mc&&(rt=Mc.split("."),ss=rt[0]>0&&rt[0]<4?1:+(rt[0]+rt[1]));!ss&&On&&(rt=On.match(/Edge\/(\d+)/),(!rt||rt[1]>=74)&&(rt=On.match(/Chrome\/(\d+)/),rt&&(ss=+rt[1])));Dc.exports=ss});var Vn=b(($$,Bc)=>{"use strict";var Oc=Bn(),ty=Pe(),ry=he(),iy=ry.String;Bc.exports=!!Object.getOwnPropertySymbols&&!ty(function(){var a=Symbol("symbol detection");return!iy(a)||!(Object(a)instanceof Symbol)||!Symbol.sham&&Oc&&Oc<41})});var _n=b((L$,Vc)=>{"use strict";var ay=Vn();Vc.exports=ay&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Nn=b((M$,_c)=>{"use strict";var sy=It(),ny=pe(),oy=Si(),uy=_n(),ly=Object;_c.exports=uy?function(a){return typeof a=="symbol"}:function(a){var e=sy("Symbol");return ny(e)&&oy(e.prototype,ly(a))}});var yi=b((C$,Nc)=>{"use strict";var cy=String;Nc.exports=function(a){try{return cy(a)}catch(e){return"Object"}}});var dt=b((D$,Fc)=>{"use strict";var dy=pe(),py=yi(),hy=TypeError;Fc.exports=function(a){if(dy(a))return a;throw new hy(py(a)+" is not a function")}});var Ti=b((O$,qc)=>{"use strict";var fy=dt(),my=Lr();qc.exports=function(a,e){var t=a[e];return my(t)?void 0:fy(t)}});var Hc=b((B$,Uc)=>{"use strict";var Fn=Ne(),qn=pe(),Un=Fe(),by=TypeError;Uc.exports=function(a,e){var t,r;if(e==="string"&&qn(t=a.toString)&&!Un(r=Fn(t,a))||qn(t=a.valueOf)&&!Un(r=Fn(t,a))||e!=="string"&&qn(t=a.toString)&&!Un(r=Fn(t,a)))return r;throw new by("Can't convert object to primitive value")}});var it=b((V$,jc)=>{"use strict";jc.exports=!0});var Wc=b((_$,Qc)=>{"use strict";var Gc=he(),gy=Object.defineProperty;Qc.exports=function(a,e){try{gy(Gc,a,{value:e,configurable:!0,writable:!0})}catch(t){Gc[a]=e}return e}});var Ii=b((N$,Kc)=>{"use strict";var vy=it(),Sy=he(),yy=Wc(),Yc="__core-js_shared__",zc=Kc.exports=Sy[Yc]||yy(Yc,{});(zc.versions||(zc.versions=[])).push({version:"3.38.0",mode:vy?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Hn=b((F$,Xc)=>{"use strict";var Jc=Ii();Xc.exports=function(a,e){return Jc[a]||(Jc[a]=e||{})}});var Cr=b((q$,Zc)=>{"use strict";var Ty=jt(),Iy=Object;Zc.exports=function(a){return Iy(Ty(a))}});var at=b((U$,ed)=>{"use strict";var Ey=ve(),xy=Cr(),Py=Ey({}.hasOwnProperty);ed.exports=Object.hasOwn||function(e,t){return Py(xy(e),t)}});var jn=b((H$,td)=>{"use strict";var Ay=ve(),wy=0,ky=Math.random(),Ry=Ay(1 .toString);td.exports=function(a){return"Symbol("+(a===void 0?"":a)+")_"+Ry(++wy+ky,36)}});var Ae=b((j$,id)=>{"use strict";var $y=he(),Ly=Hn(),rd=at(),My=jn(),Cy=Vn(),Dy=_n(),Dr=$y.Symbol,Gn=Ly("wks"),Oy=Dy?Dr.for||Dr:Dr&&Dr.withoutSetter||My;id.exports=function(a){return rd(Gn,a)||(Gn[a]=Cy&&rd(Dr,a)?Dr[a]:Oy("Symbol."+a)),Gn[a]}});var od=b((G$,nd)=>{"use strict";var By=Ne(),ad=Fe(),sd=Nn(),Vy=Ti(),_y=Hc(),Ny=Ae(),Fy=TypeError,qy=Ny("toPrimitive");nd.exports=function(a,e){if(!ad(a)||sd(a))return a;var t=Vy(a,qy),r;if(t){if(e===void 0&&(e="default"),r=By(t,a,e),!ad(r)||sd(r))return r;throw new Fy("Can't convert object to primitive value")}return e===void 0&&(e="number"),_y(a,e)}});var Qn=b((Q$,ud)=>{"use strict";var Uy=od(),Hy=Nn();ud.exports=function(a){var e=Uy(a,"string");return Hy(e)?e:e+""}});var ns=b((W$,cd)=>{"use strict";var jy=he(),ld=Fe(),Wn=jy.document,Gy=ld(Wn)&&ld(Wn.createElement);cd.exports=function(a){return Gy?Wn.createElement(a):{}}});var Yn=b((Y$,dd)=>{"use strict";var Qy=_e(),Wy=Pe(),Yy=ns();dd.exports=!Qy&&!Wy(function(){return Object.defineProperty(Yy("div"),"a",{get:function(){return 7}}).a!==7})});var fd=b(hd=>{"use strict";var zy=_e(),Ky=Ne(),Jy=Ln(),Xy=vi(),Zy=ur(),eT=Qn(),tT=at(),rT=Yn(),pd=Object.getOwnPropertyDescriptor;hd.f=zy?pd:function(e,t){if(e=Zy(e),t=eT(t),rT)try{return pd(e,t)}catch(r){}if(tT(e,t))return Xy(!Ky(Jy.f,e,t),e[t])}});var zn=b((K$,md)=>{"use strict";var iT=Pe(),aT=pe(),sT=/#|\.prototype\./,Ei=function(a,e){var t=oT[nT(a)];return t===lT?!0:t===uT?!1:aT(e)?iT(e):!!e},nT=Ei.normalize=function(a){return String(a).replace(sT,".").toLowerCase()},oT=Ei.data={},uT=Ei.NATIVE="N",lT=Ei.POLYFILL="P";md.exports=Ei});var Or=b((J$,gd)=>{"use strict";var bd=Rn(),cT=dt(),dT=gi(),pT=bd(bd.bind);gd.exports=function(a,e){return cT(a),e===void 0?a:dT?pT(a,e):function(){return a.apply(e,arguments)}}});var Kn=b((X$,vd)=>{"use strict";var hT=_e(),fT=Pe();vd.exports=hT&&fT(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var pt=b((Z$,Sd)=>{"use strict";var mT=Fe(),bT=String,gT=TypeError;Sd.exports=function(a){if(mT(a))return a;throw new gT(bT(a)+" is not an object")}});var cr=b(Td=>{"use strict";var vT=_e(),ST=Yn(),yT=Kn(),os=pt(),yd=Qn(),TT=TypeError,Jn=Object.defineProperty,IT=Object.getOwnPropertyDescriptor,Xn="enumerable",Zn="configurable",eo="writable";Td.f=vT?yT?function(e,t,r){if(os(e),t=yd(t),os(r),typeof e=="function"&&t==="prototype"&&"value"in r&&eo in r&&!r[eo]){var i=IT(e,t);i&&i[eo]&&(e[t]=r.value,r={configurable:Zn in r?r[Zn]:i[Zn],enumerable:Xn in r?r[Xn]:i[Xn],writable:!1})}return Jn(e,t,r)}:Jn:function(e,t,r){if(os(e),t=yd(t),os(r),ST)try{return Jn(e,t,r)}catch(i){}if("get"in r||"set"in r)throw new TT("Accessors not supported");return"value"in r&&(e[t]=r.value),e}});var Br=b((tL,Id)=>{"use strict";var ET=_e(),xT=cr(),PT=vi();Id.exports=ET?function(a,e,t){return xT.f(a,e,PT(1,t))}:function(a,e,t){return a[e]=t,a}});var fe=b((rL,xd)=>{"use strict";var xi=he(),AT=wn(),wT=Rn(),kT=pe(),RT=fd().f,$T=zn(),Vr=Mr(),LT=Or(),_r=Br(),Ed=at();Ii();var MT=function(a){var e=function(t,r,i){if(this instanceof e){switch(arguments.length){case 0:return new a;case 1:return new a(t);case 2:return new a(t,r)}return new a(t,r,i)}return AT(a,this,arguments)};return e.prototype=a.prototype,e};xd.exports=function(a,e){var t=a.target,r=a.global,i=a.stat,s=a.proto,n=r?xi:i?xi[t]:xi[t]&&xi[t].prototype,o=r?Vr:Vr[t]||_r(Vr,t,{})[t],u=o.prototype,l,d,c,p,h,m,g,v,I;for(p in e)l=$T(r?p:t+(i?".":"#")+p,a.forced),d=!l&&n&&Ed(n,p),m=o[p],d&&(a.dontCallGetSet?(I=RT(n,p),g=I&&I.value):g=n[p]),h=d&&g?g:e[p],!(!l&&!s&&typeof m==typeof h)&&(a.bind&&d?v=LT(h,xi):a.wrap&&d?v=MT(h):s&&kT(h)?v=wT(h):v=h,(a.sham||h&&h.sham||m&&m.sham)&&_r(v,"sham",!0),_r(o,p,v),s&&(c=t+"Prototype",Ed(Vr,c)||_r(Vr,c,{}),_r(Vr[c],p,h),a.real&&u&&(l||!u[p])&&_r(u,p,h)))}});var Ad=b((iL,Pd)=>{"use strict";var CT=Math.ceil,DT=Math.floor;Pd.exports=Math.trunc||function(e){var t=+e;return(t>0?DT:CT)(t)}});var Pi=b((aL,wd)=>{"use strict";var OT=Ad();wd.exports=function(a){var e=+a;return e!==e||e===0?0:OT(e)}});var Rd=b((sL,kd)=>{"use strict";var BT=Pi(),VT=Math.max,_T=Math.min;kd.exports=function(a,e){var t=BT(a);return t<0?VT(t+e,0):_T(t,e)}});var to=b((nL,$d)=>{"use strict";var NT=Pi(),FT=Math.min;$d.exports=function(a){var e=NT(a);return e>0?FT(e,9007199254740991):0}});var Nr=b((oL,Ld)=>{"use strict";var qT=to();Ld.exports=function(a){return qT(a.length)}});var ro=b((uL,Cd)=>{"use strict";var UT=ur(),HT=Rd(),jT=Nr(),Md=function(a){return function(e,t,r){var i=UT(e),s=jT(i);if(s===0)return!a&&-1;var n=HT(r,s),o;if(a&&t!==t){for(;s>n;)if(o=i[n++],o!==o)return!0}else for(;s>n;n++)if((a||n in i)&&i[n]===t)return a||n||0;return!a&&-1}};Cd.exports={includes:Md(!0),indexOf:Md(!1)}});var Ai=b((lL,Dd)=>{"use strict";Dd.exports=function(){}});var Od=b(()=>{"use strict";var GT=fe(),QT=ro().includes,WT=Pe(),YT=Ai(),zT=WT(function(){return!Array(1).includes()});GT({target:"Array",proto:!0,forced:zT},{includes:function(e){return QT(this,e,arguments.length>1?arguments[1]:void 0)}});YT("includes")});var Gt=b((pL,Bd)=>{"use strict";var KT=It();Bd.exports=KT});var _d=b((hL,Vd)=>{"use strict";Od();var JT=Gt();Vd.exports=JT("Array","includes")});var Fd=b((fL,Nd)=>{"use strict";var XT=_d();Nd.exports=XT});var ht=b((mL,qd)=>{"use strict";var ZT=Fd();qd.exports=ZT});var ls=b((AL,jd)=>{"use strict";var tI=Hn(),rI=jn(),Hd=tI("keys");jd.exports=function(a){return Hd[a]||(Hd[a]=rI(a))}});var Qd=b((wL,Gd)=>{"use strict";var iI=Pe();Gd.exports=!iI(function(){function a(){}return a.prototype.constructor=null,Object.getPrototypeOf(new a)!==a.prototype})});var cs=b((kL,Yd)=>{"use strict";var aI=at(),sI=pe(),nI=Cr(),oI=ls(),uI=Qd(),Wd=oI("IE_PROTO"),io=Object,lI=io.prototype;Yd.exports=uI?io.getPrototypeOf:function(a){var e=nI(a);if(aI(e,Wd))return e[Wd];var t=e.constructor;return sI(t)&&e instanceof t?t.prototype:e instanceof io?lI:null}});var ds=b((RL,zd)=>{"use strict";zd.exports={}});var Xd=b(($L,Jd)=>{"use strict";var cI=ve(),ao=at(),dI=ur(),pI=ro().indexOf,hI=ds(),Kd=cI([].push);Jd.exports=function(a,e){var t=dI(a),r=0,i=[],s;for(s in t)!ao(hI,s)&&ao(t,s)&&Kd(i,s);for(;e.length>r;)ao(t,s=e[r++])&&(~pI(i,s)||Kd(i,s));return i}});var so=b((LL,Zd)=>{"use strict";Zd.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var no=b((ML,ep)=>{"use strict";var fI=Xd(),mI=so();ep.exports=Object.keys||function(e){return fI(e,mI)}});var oo=b((CL,sp)=>{"use strict";var rp=_e(),bI=Pe(),ip=ve(),gI=cs(),vI=no(),SI=ur(),yI=Ln().f,ap=ip(yI),TI=ip([].push),II=rp&&bI(function(){var a=Object.create(null);return a[2]=2,!ap(a,2)}),tp=function(a){return function(e){for(var t=SI(e),r=vI(t),i=II&&gI(t)===null,s=r.length,n=0,o=[],u;s>n;)u=r[n++],(!rp||(i?u in t:ap(t,u)))&&TI(o,a?[u,t[u]]:t[u]);return o}};sp.exports={entries:tp(!0),values:tp(!1)}});var np=b(()=>{"use strict";var EI=fe(),xI=oo().entries;EI({target:"Object",stat:!0},{entries:function(e){return xI(e)}})});var up=b((BL,op)=>{"use strict";np();var PI=Mr();op.exports=PI.Object.entries});var cp=b((VL,lp)=>{"use strict";var AI=up();lp.exports=AI});var Fr=b((_L,dp)=>{"use strict";var wI=cp();dp.exports=wI});var dr=b((NL,pp)=>{"use strict";pp.exports={}});var mp=b((FL,fp)=>{"use strict";var kI=he(),RI=pe(),hp=kI.WeakMap;fp.exports=RI(hp)&&/native code/.test(String(hp))});var po=b((qL,vp)=>{"use strict";var $I=mp(),gp=he(),LI=Fe(),MI=Br(),uo=at(),lo=Ii(),CI=ls(),DI=ds(),bp="Object already initialized",co=gp.TypeError,OI=gp.WeakMap,ps,wi,hs,BI=function(a){return hs(a)?wi(a):ps(a,{})},VI=function(a){return function(e){var t;if(!LI(e)||(t=wi(e)).type!==a)throw new co("Incompatible receiver, "+a+" required");return t}};$I||lo.state?(st=lo.state||(lo.state=new OI),st.get=st.get,st.has=st.has,st.set=st.set,ps=function(a,e){if(st.has(a))throw new co(bp);return e.facade=a,st.set(a,e),e},wi=function(a){return st.get(a)||{}},hs=function(a){return st.has(a)}):(pr=CI("state"),DI[pr]=!0,ps=function(a,e){if(uo(a,pr))throw new co(bp);return e.facade=a,MI(a,pr,e),e},wi=function(a){return uo(a,pr)?a[pr]:{}},hs=function(a){return uo(a,pr)});var st,pr;vp.exports={set:ps,get:wi,has:hs,enforce:BI,getterFor:VI}});var mo=b((UL,yp)=>{"use strict";var ho=_e(),_I=at(),Sp=Function.prototype,NI=ho&&Object.getOwnPropertyDescriptor,fo=_I(Sp,"name"),FI=fo&&function(){}.name==="something",qI=fo&&(!ho||ho&&NI(Sp,"name").configurable);yp.exports={EXISTS:fo,PROPER:FI,CONFIGURABLE:qI}});var Ip=b(Tp=>{"use strict";var UI=_e(),HI=Kn(),jI=cr(),GI=pt(),QI=ur(),WI=no();Tp.f=UI&&!HI?Object.defineProperties:function(e,t){GI(e);for(var r=QI(t),i=WI(t),s=i.length,n=0,o;s>n;)jI.f(e,o=i[n++],r[o]);return e}});var bo=b((jL,Ep)=>{"use strict";var YI=It();Ep.exports=YI("document","documentElement")});var yo=b((GL,$p)=>{"use strict";var zI=pt(),KI=Ip(),xp=so(),JI=ds(),XI=bo(),ZI=ns(),eE=ls(),Pp=">",Ap="<",vo="prototype",So="script",kp=eE("IE_PROTO"),go=function(){},Rp=function(a){return Ap+So+Pp+a+Ap+"/"+So+Pp},wp=function(a){a.write(Rp("")),a.close();var e=a.parentWindow.Object;return a=null,e},tE=function(){var a=ZI("iframe"),e="java"+So+":",t;return a.style.display="none",XI.appendChild(a),a.src=String(e),t=a.contentWindow.document,t.open(),t.write(Rp("document.F=Object")),t.close(),t.F},fs,ms=function(){try{fs=new ActiveXObject("htmlfile")}catch(e){}ms=typeof document!="undefined"?document.domain&&fs?wp(fs):tE():wp(fs);for(var a=xp.length;a--;)delete ms[vo][xp[a]];return ms()};JI[kp]=!0;$p.exports=Object.create||function(e,t){var r;return e!==null?(go[vo]=zI(e),r=new go,go[vo]=null,r[kp]=e):r=ms(),t===void 0?r:KI.f(r,t)}});var qr=b((QL,Lp)=>{"use strict";var rE=Br();Lp.exports=function(a,e,t,r){return r&&r.enumerable?a[e]=t:rE(a,e,t),a}});var xo=b((WL,Dp)=>{"use strict";var iE=Pe(),aE=pe(),sE=Fe(),nE=yo(),Mp=cs(),oE=qr(),uE=Ae(),lE=it(),Eo=uE("iterator"),Cp=!1,Et,To,Io;[].keys&&(Io=[].keys(),"next"in Io?(To=Mp(Mp(Io)),To!==Object.prototype&&(Et=To)):Cp=!0);var cE=!sE(Et)||iE(function(){var a={};return Et[Eo].call(a)!==a});cE?Et={}:lE&&(Et=nE(Et));aE(Et[Eo])||oE(Et,Eo,function(){return this});Dp.exports={IteratorPrototype:Et,BUGGY_SAFARI_ITERATORS:Cp}});var bs=b((YL,Bp)=>{"use strict";var dE=Ae(),pE=dE("toStringTag"),Op={};Op[pE]="z";Bp.exports=String(Op)==="[object z]"});var ki=b((zL,Vp)=>{"use strict";var hE=bs(),fE=pe(),gs=or(),mE=Ae(),bE=mE("toStringTag"),gE=Object,vE=gs(function(){return arguments}())==="Arguments",SE=function(a,e){try{return a[e]}catch(t){}};Vp.exports=hE?gs:function(a){var e,t,r;return a===void 0?"Undefined":a===null?"Null":typeof(t=SE(e=gE(a),bE))=="string"?t:vE?gs(e):(r=gs(e))==="Object"&&fE(e.callee)?"Arguments":r}});var Np=b((KL,_p)=>{"use strict";var yE=bs(),TE=ki();_p.exports=yE?{}.toString:function(){return"[object "+TE(this)+"]"}});var Ri=b((JL,qp)=>{"use strict";var IE=bs(),EE=cr().f,xE=Br(),PE=at(),AE=Np(),wE=Ae(),Fp=wE("toStringTag");qp.exports=function(a,e,t,r){var i=t?a:a&&a.prototype;i&&(PE(i,Fp)||EE(i,Fp,{configurable:!0,value:e}),r&&!IE&&xE(i,"toString",AE))}});var Hp=b((XL,Up)=>{"use strict";var kE=xo().IteratorPrototype,RE=yo(),$E=vi(),LE=Ri(),ME=dr(),CE=function(){return this};Up.exports=function(a,e,t,r){var i=e+" Iterator";return a.prototype=RE(kE,{next:$E(+!r,t)}),LE(a,i,!1,!0),ME[i]=CE,a}});var Gp=b((ZL,jp)=>{"use strict";var DE=ve(),OE=dt();jp.exports=function(a,e,t){try{return DE(OE(Object.getOwnPropertyDescriptor(a,e)[t]))}catch(r){}}});var Wp=b((eM,Qp)=>{"use strict";var BE=Fe();Qp.exports=function(a){return BE(a)||a===null}});var zp=b((tM,Yp)=>{"use strict";var VE=Wp(),_E=String,NE=TypeError;Yp.exports=function(a){if(VE(a))return a;throw new NE("Can't set "+_E(a)+" as a prototype")}});var Po=b((rM,Kp)=>{"use strict";var FE=Gp(),qE=Fe(),UE=jt(),HE=zp();Kp.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var a=!1,e={},t;try{t=FE(Object.prototype,"__proto__","set"),t(e,[]),a=e instanceof Array}catch(r){}return function(i,s){return UE(i),HE(s),qE(i)&&(a?t(i,s):i.__proto__=s),i}}():void 0)});var oh=b((iM,nh)=>{"use strict";var jE=fe(),GE=Ne(),vs=it(),ah=mo(),QE=pe(),WE=Hp(),Jp=cs(),Xp=Po(),YE=Ri(),zE=Br(),Ao=qr(),KE=Ae(),Zp=dr(),sh=xo(),JE=ah.PROPER,XE=ah.CONFIGURABLE,eh=sh.IteratorPrototype,Ss=sh.BUGGY_SAFARI_ITERATORS,$i=KE("iterator"),th="keys",Li="values",rh="entries",ih=function(){return this};nh.exports=function(a,e,t,r,i,s,n){WE(t,e,r);var o=function(I){if(I===i&&p)return p;if(!Ss&&I&&I in d)return d[I];switch(I){case th:return function(){return new t(this,I)};case Li:return function(){return new t(this,I)};case rh:return function(){return new t(this,I)}}return function(){return new t(this)}},u=e+" Iterator",l=!1,d=a.prototype,c=d[$i]||d["@@iterator"]||i&&d[i],p=!Ss&&c||o(i),h=e==="Array"&&d.entries||c,m,g,v;if(h&&(m=Jp(h.call(new a)),m!==Object.prototype&&m.next&&(!vs&&Jp(m)!==eh&&(Xp?Xp(m,eh):QE(m[$i])||Ao(m,$i,ih)),YE(m,u,!0,!0),vs&&(Zp[u]=ih))),JE&&i===Li&&c&&c.name!==Li&&(!vs&&XE?zE(d,"name",Li):(l=!0,p=function(){return GE(c,this)})),i)if(g={values:o(Li),keys:s?p:o(th),entries:o(rh)},n)for(v in g)(Ss||l||!(v in d))&&Ao(d,v,g[v]);else jE({target:e,proto:!0,forced:Ss||l},g);return(!vs||n)&&d[$i]!==p&&Ao(d,$i,p,{name:i}),Zp[e]=p,g}});var lh=b((aM,uh)=>{"use strict";uh.exports=function(a,e){return{value:a,done:e}}});var ko=b((sM,fh)=>{"use strict";var ZE=ur(),wo=Ai(),ch=dr(),ph=po(),ex=cr().f,tx=oh(),ys=lh(),rx=it(),ix=_e(),hh="Array Iterator",ax=ph.set,sx=ph.getterFor(hh);fh.exports=tx(Array,"Array",function(a,e){ax(this,{type:hh,target:ZE(a),index:0,kind:e})},function(){var a=sx(this),e=a.target,t=a.index++;if(!e||t>=e.length)return a.target=void 0,ys(void 0,!0);switch(a.kind){case"keys":return ys(t,!1);case"values":return ys(e[t],!1)}return ys([t,e[t]],!1)},"values");var dh=ch.Arguments=ch.Array;wo("keys");wo("values");wo("entries");if(!rx&&ix&&dh.name!=="values")try{ex(dh,"name",{value:"values"})}catch(a){}});var bh=b((nM,mh)=>{"use strict";var nx=Ae(),ox=dr(),ux=nx("iterator"),lx=Array.prototype;mh.exports=function(a){return a!==void 0&&(ox.Array===a||lx[ux]===a)}});var Ro=b((oM,vh)=>{"use strict";var cx=ki(),gh=Ti(),dx=Lr(),px=dr(),hx=Ae(),fx=hx("iterator");vh.exports=function(a){if(!dx(a))return gh(a,fx)||gh(a,"@@iterator")||px[cx(a)]}});var yh=b((uM,Sh)=>{"use strict";var mx=Ne(),bx=dt(),gx=pt(),vx=yi(),Sx=Ro(),yx=TypeError;Sh.exports=function(a,e){var t=arguments.length<2?Sx(a):e;if(bx(t))return gx(mx(t,a));throw new yx(vx(a)+" is not iterable")}});var Eh=b((lM,Ih)=>{"use strict";var Tx=Ne(),Th=pt(),Ix=Ti();Ih.exports=function(a,e,t){var r,i;Th(a);try{if(r=Ix(a,"return"),!r){if(e==="throw")throw t;return t}r=Tx(r,a)}catch(s){i=!0,r=s}if(e==="throw")throw t;if(i)throw r;return Th(r),t}});var Is=b((cM,wh)=>{"use strict";var Ex=Or(),xx=Ne(),Px=pt(),Ax=yi(),wx=bh(),kx=Nr(),xh=Si(),Rx=yh(),$x=Ro(),Ph=Eh(),Lx=TypeError,Ts=function(a,e){this.stopped=a,this.result=e},Ah=Ts.prototype;wh.exports=function(a,e,t){var r=t&&t.that,i=!!(t&&t.AS_ENTRIES),s=!!(t&&t.IS_RECORD),n=!!(t&&t.IS_ITERATOR),o=!!(t&&t.INTERRUPTED),u=Ex(e,r),l,d,c,p,h,m,g,v=function(T){return l&&Ph(l,"normal",T),new Ts(!0,T)},I=function(T){return i?(Px(T),o?u(T[0],T[1],v):u(T[0],T[1])):o?u(T,v):u(T)};if(s)l=a.iterator;else if(n)l=a;else{if(d=$x(a),!d)throw new Lx(Ax(a)+" is not iterable");if(wx(d)){for(c=0,p=kx(a);p>c;c++)if(h=I(a[c]),h&&xh(Ah,h))return h;return new Ts(!1)}l=Rx(a,d)}for(m=s?a.next:l.next;!(g=xx(m,l)).done;){try{h=I(g.value)}catch(T){Ph(l,"throw",T)}if(typeof h=="object"&&h&&xh(Ah,h))return h}return new Ts(!1)}});var Rh=b((dM,kh)=>{"use strict";var Mx=_e(),Cx=cr(),Dx=vi();kh.exports=function(a,e,t){Mx?Cx.f(a,e,Dx(0,t)):a[e]=t}});var $h=b(()=>{"use strict";var Ox=fe(),Bx=Is(),Vx=Rh();Ox({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Bx(e,function(r,i){Vx(t,r,i)},{AS_ENTRIES:!0}),t}})});var Mh=b((fM,Lh)=>{"use strict";ko();$h();var _x=Mr();Lh.exports=_x.Object.fromEntries});var Dh=b((mM,Ch)=>{"use strict";Ch.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}});var Bh=b(()=>{"use strict";ko();var Nx=Dh(),Fx=he(),qx=Ri(),Oh=dr();for(Es in Nx)qx(Fx[Es],Es),Oh[Es]=Oh.Array;var Es});var _h=b((vM,Vh)=>{"use strict";var Ux=Mh();Bh();Vh.exports=Ux});var $o=b((SM,Nh)=>{"use strict";var Hx=_h();Nh.exports=Hx});var Fh=b(()=>{"use strict"});var Lo=b((IM,qh)=>{"use strict";var Mi=he(),jx=lr(),Gx=or(),xs=function(a){return jx.slice(0,a.length)===a};qh.exports=function(){return xs("Bun/")?"BUN":xs("Cloudflare-Workers")?"CLOUDFLARE":xs("Deno/")?"DENO":xs("Node.js/")?"NODE":Mi.Bun&&typeof Bun.version=="string"?"BUN":Mi.Deno&&typeof Deno.version=="object"?"DENO":Gx(Mi.process)==="process"?"NODE":Mi.window&&Mi.document?"BROWSER":"REST"}()});var Ps=b((EM,Uh)=>{"use strict";var Qx=Lo();Uh.exports=Qx==="NODE"});var jh=b((xM,Hh)=>{"use strict";var Wx=cr();Hh.exports=function(a,e,t){return Wx.f(a,e,t)}});var Wh=b((PM,Qh)=>{"use strict";var Yx=It(),zx=jh(),Kx=Ae(),Jx=_e(),Gh=Kx("species");Qh.exports=function(a){var e=Yx(a);Jx&&e&&!e[Gh]&&zx(e,Gh,{configurable:!0,get:function(){return this}})}});var zh=b((AM,Yh)=>{"use strict";var Xx=Si(),Zx=TypeError;Yh.exports=function(a,e){if(Xx(e,a))return a;throw new Zx("Incorrect invocation")}});var Co=b((wM,Kh)=>{"use strict";var eP=ve(),tP=pe(),Mo=Ii(),rP=eP(Function.toString);tP(Mo.inspectSource)||(Mo.inspectSource=function(a){return rP(a)});Kh.exports=Mo.inspectSource});var Oo=b((kM,tf)=>{"use strict";var iP=ve(),aP=Pe(),Jh=pe(),sP=ki(),nP=It(),oP=Co(),Xh=function(){},Zh=nP("Reflect","construct"),Do=/^\s*(?:class|function)\b/,uP=iP(Do.exec),lP=!Do.test(Xh),Ci=function(e){if(!Jh(e))return!1;try{return Zh(Xh,[],e),!0}catch(t){return!1}},ef=function(e){if(!Jh(e))return!1;switch(sP(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return lP||!!uP(Do,oP(e))}catch(t){return!0}};ef.sham=!0;tf.exports=!Zh||aP(function(){var a;return Ci(Ci.call)||!Ci(Object)||!Ci(function(){a=!0})||a})?ef:Ci});var af=b((RM,rf)=>{"use strict";var cP=Oo(),dP=yi(),pP=TypeError;rf.exports=function(a){if(cP(a))return a;throw new pP(dP(a)+" is not a constructor")}});var Bo=b(($M,nf)=>{"use strict";var sf=pt(),hP=af(),fP=Lr(),mP=Ae(),bP=mP("species");nf.exports=function(a,e){var t=sf(a).constructor,r;return t===void 0||fP(r=sf(t)[bP])?e:hP(r)}});var uf=b((LM,of)=>{"use strict";var gP=ve();of.exports=gP([].slice)});var cf=b((MM,lf)=>{"use strict";var vP=TypeError;lf.exports=function(a,e){if(a<e)throw new vP("Not enough arguments");return a}});var Vo=b((CM,df)=>{"use strict";var SP=lr();df.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(SP)});var Qo=b((DM,yf)=>{"use strict";var qe=he(),yP=wn(),TP=Or(),pf=pe(),IP=at(),Sf=Pe(),hf=bo(),EP=uf(),ff=ns(),xP=cf(),PP=Vo(),AP=Ps(),Ho=qe.setImmediate,jo=qe.clearImmediate,wP=qe.process,_o=qe.Dispatch,kP=qe.Function,mf=qe.MessageChannel,RP=qe.String,No=0,Di={},bf="onreadystatechange",Oi,hr,Fo,qo;Sf(function(){Oi=qe.location});var Go=function(a){if(IP(Di,a)){var e=Di[a];delete Di[a],e()}},Uo=function(a){return function(){Go(a)}},gf=function(a){Go(a.data)},vf=function(a){qe.postMessage(RP(a),Oi.protocol+"//"+Oi.host)};(!Ho||!jo)&&(Ho=function(e){xP(arguments.length,1);var t=pf(e)?e:kP(e),r=EP(arguments,1);return Di[++No]=function(){yP(t,void 0,r)},hr(No),No},jo=function(e){delete Di[e]},AP?hr=function(a){wP.nextTick(Uo(a))}:_o&&_o.now?hr=function(a){_o.now(Uo(a))}:mf&&!PP?(Fo=new mf,qo=Fo.port2,Fo.port1.onmessage=gf,hr=TP(qo.postMessage,qo)):qe.addEventListener&&pf(qe.postMessage)&&!qe.importScripts&&Oi&&Oi.protocol!=="file:"&&!Sf(vf)?(hr=vf,qe.addEventListener("message",gf,!1)):bf in ff("script")?hr=function(a){hf.appendChild(ff("script"))[bf]=function(){hf.removeChild(this),Go(a)}}:hr=function(a){setTimeout(Uo(a),0)});yf.exports={set:Ho,clear:jo}});var Ef=b((OM,If)=>{"use strict";var Tf=he(),$P=_e(),LP=Object.getOwnPropertyDescriptor;If.exports=function(a){if(!$P)return Tf[a];var e=LP(Tf,a);return e&&e.value}});var Wo=b((BM,Pf)=>{"use strict";var xf=function(){this.head=null,this.tail=null};xf.prototype={add:function(a){var e={item:a,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var a=this.head;if(a){var e=this.head=a.next;return e===null&&(this.tail=null),a.item}}};Pf.exports=xf});var wf=b((VM,Af)=>{"use strict";var MP=lr();Af.exports=/ipad|iphone|ipod/i.test(MP)&&typeof Pebble!="undefined"});var Rf=b((_M,kf)=>{"use strict";var CP=lr();kf.exports=/web0s(?!.*chrome)/i.test(CP)});var Bf=b((NM,Of)=>{"use strict";var Hr=he(),DP=Ef(),$f=Or(),Yo=Qo().set,OP=Wo(),BP=Vo(),VP=wf(),_P=Rf(),zo=Ps(),Lf=Hr.MutationObserver||Hr.WebKitMutationObserver,Mf=Hr.document,Cf=Hr.process,As=Hr.Promise,Xo=DP("queueMicrotask"),Ur,Ko,Jo,ws,Df;Xo||(Bi=new OP,Vi=function(){var a,e;for(zo&&(a=Cf.domain)&&a.exit();e=Bi.get();)try{e()}catch(t){throw Bi.head&&Ur(),t}a&&a.enter()},!BP&&!zo&&!_P&&Lf&&Mf?(Ko=!0,Jo=Mf.createTextNode(""),new Lf(Vi).observe(Jo,{characterData:!0}),Ur=function(){Jo.data=Ko=!Ko}):!VP&&As&&As.resolve?(ws=As.resolve(void 0),ws.constructor=As,Df=$f(ws.then,ws),Ur=function(){Df(Vi)}):zo?Ur=function(){Cf.nextTick(Vi)}:(Yo=$f(Yo,Hr),Ur=function(){Yo(Vi)}),Xo=function(a){Bi.head||Ur(),Bi.add(a)});var Bi,Vi;Of.exports=Xo});var _f=b((FM,Vf)=>{"use strict";Vf.exports=function(a,e){try{arguments.length===1?console.error(a):console.error(a,e)}catch(t){}}});var ks=b((qM,Nf)=>{"use strict";Nf.exports=function(a){try{return{error:!1,value:a()}}catch(e){return{error:!0,value:e}}}});var fr=b((UM,Ff)=>{"use strict";var NP=he();Ff.exports=NP.Promise});var jr=b((HM,jf)=>{"use strict";var FP=he(),_i=fr(),qP=pe(),UP=zn(),HP=Co(),jP=Ae(),qf=Lo(),GP=it(),Zo=Bn(),Uf=_i&&_i.prototype,QP=jP("species"),eu=!1,Hf=qP(FP.PromiseRejectionEvent),WP=UP("Promise",function(){var a=HP(_i),e=a!==String(_i);if(!e&&Zo===66||GP&&!(Uf.catch&&Uf.finally))return!0;if(!Zo||Zo<51||!/native code/.test(a)){var t=new _i(function(s){s(1)}),r=function(s){s(function(){},function(){})},i=t.constructor={};if(i[QP]=r,eu=t.then(function(){})instanceof r,!eu)return!0}return!e&&(qf==="BROWSER"||qf==="DENO")&&!Hf});jf.exports={CONSTRUCTOR:WP,REJECTION_EVENT:Hf,SUBCLASSING:eu}});var Gr=b((jM,Qf)=>{"use strict";var Gf=dt(),YP=TypeError,zP=function(a){var e,t;this.promise=new a(function(r,i){if(e!==void 0||t!==void 0)throw new YP("Bad Promise constructor");e=r,t=i}),this.resolve=Gf(e),this.reject=Gf(t)};Qf.exports.f=function(a){return new zP(a)}});var dm=b(()=>{"use strict";var KP=fe(),JP=it(),Ms=Ps(),Qt=he(),zr=Ne(),Wf=qr(),Yf=Po(),XP=Ri(),ZP=Wh(),eA=dt(),Ls=pe(),tA=Fe(),rA=zh(),iA=Bo(),Zf=Qo().set,su=Bf(),aA=_f(),sA=ks(),nA=Wo(),em=po(),Cs=fr(),nu=jr(),tm=Gr(),Ds="Promise",rm=nu.CONSTRUCTOR,oA=nu.REJECTION_EVENT,uA=nu.SUBCLASSING,tu=em.getterFor(Ds),lA=em.set,Qr=Cs&&Cs.prototype,mr=Cs,Rs=Qr,im=Qt.TypeError,ru=Qt.document,ou=Qt.process,iu=tm.f,cA=iu,dA=!!(ru&&ru.createEvent&&Qt.dispatchEvent),am="unhandledrejection",pA="rejectionhandled",zf=0,sm=1,hA=2,uu=1,nm=2,$s,Kf,fA,Jf,om=function(a){var e;return tA(a)&&Ls(e=a.then)?e:!1},um=function(a,e){var t=e.value,r=e.state===sm,i=r?a.ok:a.fail,s=a.resolve,n=a.reject,o=a.domain,u,l,d;try{i?(r||(e.rejection===nm&&bA(e),e.rejection=uu),i===!0?u=t:(o&&o.enter(),u=i(t),o&&(o.exit(),d=!0)),u===a.promise?n(new im("Promise-chain cycle")):(l=om(u))?zr(l,u,s,n):s(u)):n(t)}catch(c){o&&!d&&o.exit(),n(c)}},lm=function(a,e){a.notified||(a.notified=!0,su(function(){for(var t=a.reactions,r;r=t.get();)um(r,a);a.notified=!1,e&&!a.rejection&&mA(a)}))},cm=function(a,e,t){var r,i;dA?(r=ru.createEvent("Event"),r.promise=e,r.reason=t,r.initEvent(a,!1,!0),Qt.dispatchEvent(r)):r={promise:e,reason:t},!oA&&(i=Qt["on"+a])?i(r):a===am&&aA("Unhandled promise rejection",t)},mA=function(a){zr(Zf,Qt,function(){var e=a.facade,t=a.value,r=Xf(a),i;if(r&&(i=sA(function(){Ms?ou.emit("unhandledRejection",t,e):cm(am,e,t)}),a.rejection=Ms||Xf(a)?nm:uu,i.error))throw i.value})},Xf=function(a){return a.rejection!==uu&&!a.parent},bA=function(a){zr(Zf,Qt,function(){var e=a.facade;Ms?ou.emit("rejectionHandled",e):cm(pA,e,a.value)})},Wr=function(a,e,t){return function(r){a(e,r,t)}},Yr=function(a,e,t){a.done||(a.done=!0,t&&(a=t),a.value=e,a.state=hA,lm(a,!0))},au=function(a,e,t){if(!a.done){a.done=!0,t&&(a=t);try{if(a.facade===e)throw new im("Promise can't be resolved itself");var r=om(e);r?su(function(){var i={done:!1};try{zr(r,e,Wr(au,i,a),Wr(Yr,i,a))}catch(s){Yr(i,s,a)}}):(a.value=e,a.state=sm,lm(a,!1))}catch(i){Yr({done:!1},i,a)}}};if(rm&&(mr=function(e){rA(this,Rs),eA(e),zr($s,this);var t=tu(this);try{e(Wr(au,t),Wr(Yr,t))}catch(r){Yr(t,r)}},Rs=mr.prototype,$s=function(e){lA(this,{type:Ds,done:!1,notified:!1,parent:!1,reactions:new nA,rejection:!1,state:zf,value:void 0})},$s.prototype=Wf(Rs,"then",function(e,t){var r=tu(this),i=iu(iA(this,mr));return r.parent=!0,i.ok=Ls(e)?e:!0,i.fail=Ls(t)&&t,i.domain=Ms?ou.domain:void 0,r.state===zf?r.reactions.add(i):su(function(){um(i,r)}),i.promise}),Kf=function(){var a=new $s,e=tu(a);this.promise=a,this.resolve=Wr(au,e),this.reject=Wr(Yr,e)},tm.f=iu=function(a){return a===mr||a===fA?new Kf(a):cA(a)},!JP&&Ls(Cs)&&Qr!==Object.prototype)){Jf=Qr.then,uA||Wf(Qr,"then",function(e,t){var r=this;return new mr(function(i,s){zr(Jf,r,i,s)}).then(e,t)},{unsafe:!0});try{delete Qr.constructor}catch(a){}Yf&&Yf(Qr,Rs)}KP({global:!0,constructor:!0,wrap:!0,forced:rm},{Promise:mr});XP(mr,Ds,!1,!0);ZP(Ds)});var bm=b((WM,mm)=>{"use strict";var gA=Ae(),hm=gA("iterator"),fm=!1;try{pm=0,lu={next:function(){return{done:!!pm++}},return:function(){fm=!0}},lu[hm]=function(){return this},Array.from(lu,function(){throw 2})}catch(a){}var pm,lu;mm.exports=function(a,e){try{if(!e&&!fm)return!1}catch(i){return!1}var t=!1;try{var r={};r[hm]=function(){return{next:function(){return{done:t=!0}}}},a(r)}catch(i){}return t}});var cu=b((YM,gm)=>{"use strict";var vA=fr(),SA=bm(),yA=jr().CONSTRUCTOR;gm.exports=yA||!SA(function(a){vA.all(a).then(void 0,function(){})})});var vm=b(()=>{"use strict";var TA=fe(),IA=Ne(),EA=dt(),xA=Gr(),PA=ks(),AA=Is(),wA=cu();TA({target:"Promise",stat:!0,forced:wA},{all:function(e){var t=this,r=xA.f(t),i=r.resolve,s=r.reject,n=PA(function(){var o=EA(t.resolve),u=[],l=0,d=1;AA(e,function(c){var p=l++,h=!1;d++,IA(o,t,c).then(function(m){h||(h=!0,u[p]=m,--d||i(u))},s)}),--d||i(u)});return n.error&&s(n.value),r.promise}})});var ym=b(()=>{"use strict";var kA=fe(),RA=it(),$A=jr().CONSTRUCTOR,pu=fr(),LA=It(),MA=pe(),CA=qr(),Sm=pu&&pu.prototype;kA({target:"Promise",proto:!0,forced:$A,real:!0},{catch:function(a){return this.then(void 0,a)}});!RA&&MA(pu)&&(du=LA("Promise").prototype.catch,Sm.catch!==du&&CA(Sm,"catch",du,{unsafe:!0}));var du});var Tm=b(()=>{"use strict";var DA=fe(),OA=Ne(),BA=dt(),VA=Gr(),_A=ks(),NA=Is(),FA=cu();DA({target:"Promise",stat:!0,forced:FA},{race:function(e){var t=this,r=VA.f(t),i=r.reject,s=_A(function(){var n=BA(t.resolve);NA(e,function(o){OA(n,t,o).then(r.resolve,i)})});return s.error&&i(s.value),r.promise}})});var Im=b(()=>{"use strict";var qA=fe(),UA=Gr(),HA=jr().CONSTRUCTOR;qA({target:"Promise",stat:!0,forced:HA},{reject:function(e){var t=UA.f(this),r=t.reject;return r(e),t.promise}})});var hu=b((i0,Em)=>{"use strict";var jA=pt(),GA=Fe(),QA=Gr();Em.exports=function(a,e){if(jA(a),GA(e)&&e.constructor===a)return e;var t=QA.f(a),r=t.resolve;return r(e),t.promise}});var Am=b(()=>{"use strict";var WA=fe(),YA=It(),xm=it(),zA=fr(),Pm=jr().CONSTRUCTOR,KA=hu(),JA=YA("Promise"),XA=xm&&!Pm;WA({target:"Promise",stat:!0,forced:xm||Pm},{resolve:function(e){return KA(XA&&this===JA?zA:this,e)}})});var wm=b(()=>{"use strict";dm();vm();ym();Tm();Im();Am()});var Lm=b(()=>{"use strict";var ZA=fe(),ew=it(),Os=fr(),tw=Pe(),Rm=It(),$m=pe(),rw=Bo(),km=hu(),iw=qr(),mu=Os&&Os.prototype,aw=!!Os&&tw(function(){mu.finally.call({then:function(){}},function(){})});ZA({target:"Promise",proto:!0,real:!0,forced:aw},{finally:function(a){var e=rw(this,Rm("Promise")),t=$m(a);return this.then(t?function(r){return km(e,a()).then(function(){return r})}:a,t?function(r){return km(e,a()).then(function(){throw r})}:a)}});!ew&&$m(Os)&&(fu=Rm("Promise").prototype.finally,mu.finally!==fu&&iw(mu,"finally",fu,{unsafe:!0}));var fu});var Cm=b((c0,Mm)=>{"use strict";Fh();wm();Lm();var sw=Gt();Mm.exports=sw("Promise","finally")});var Om=b((d0,Dm)=>{"use strict";var nw=Cm();Dm.exports=nw});var Bs=b((p0,Bm)=>{"use strict";var ow=Om();Bm.exports=ow});var Hm=b(()=>{"use strict";var pw=fe(),hw=oo().values;pw({target:"Object",stat:!0},{values:function(e){return hw(e)}})});var Gm=b((H0,jm)=>{"use strict";Hm();var fw=Mr();jm.exports=fw.Object.values});var Wm=b((j0,Qm)=>{"use strict";var mw=Gm();Qm.exports=mw});var Fi=b((G0,Ym)=>{"use strict";var bw=Wm();Ym.exports=bw});var Xm=b(()=>{"use strict";var yw=fe(),Tw=Cr(),Iw=Nr(),Ew=Pi(),xw=Ai();yw({target:"Array",proto:!0},{at:function(e){var t=Tw(this),r=Iw(t),i=Ew(e),s=i>=0?i:r+i;return s<0||s>=r?void 0:t[s]}});xw("at")});var eb=b((mC,Zm)=>{"use strict";Xm();var Pw=Gt();Zm.exports=Pw("Array","at")});var rb=b((bC,tb)=>{"use strict";var Aw=eb();tb.exports=Aw});var Kr=b((gC,ib)=>{"use strict";var ww=rb();ib.exports=ww});var Mu=b((_D,Eb)=>{"use strict";var _w=or();Eb.exports=Array.isArray||function(e){return _w(e)==="Array"}});var Pb=b((ND,xb)=>{"use strict";var Nw=TypeError,Fw=9007199254740991;xb.exports=function(a){if(a>Fw)throw Nw("Maximum allowed index exceeded");return a}});var kb=b((FD,wb)=>{"use strict";var qw=Mu(),Uw=Nr(),Hw=Pb(),jw=Or(),Ab=function(a,e,t,r,i,s,n,o){for(var u=i,l=0,d=n?jw(n,o):!1,c,p;l<r;)l in t&&(c=d?d(t[l],l,e):t[l],s>0&&qw(c)?(p=Uw(c),u=Ab(a,e,c,p,u,s-1)-1):(Hw(u+1),a[u]=c),u++),l++;return u};wb.exports=Ab});var Mb=b((qD,Lb)=>{"use strict";var Rb=Mu(),Gw=Oo(),Qw=Fe(),Ww=Ae(),Yw=Ww("species"),$b=Array;Lb.exports=function(a){var e;return Rb(a)&&(e=a.constructor,Gw(e)&&(e===$b||Rb(e.prototype))?e=void 0:Qw(e)&&(e=e[Yw],e===null&&(e=void 0))),e===void 0?$b:e}});var Db=b((UD,Cb)=>{"use strict";var zw=Mb();Cb.exports=function(a,e){return new(zw(a))(e===0?0:e)}});var Ob=b(()=>{"use strict";var Kw=fe(),Jw=kb(),Xw=dt(),Zw=Cr(),ek=Nr(),tk=Db();Kw({target:"Array",proto:!0},{flatMap:function(e){var t=Zw(this),r=ek(t),i;return Xw(e),i=tk(t,0),i.length=Jw(i,t,t,r,0,1,e,arguments.length>1?arguments[1]:void 0),i}})});var Bb=b(()=>{"use strict";var rk=Ai();rk("flatMap")});var _b=b((WD,Vb)=>{"use strict";Ob();Bb();var ik=Gt();Vb.exports=ik("Array","flatMap")});var Fb=b((YD,Nb)=>{"use strict";var ak=_b();Nb.exports=ak});var Cu=b((zD,qb)=>{"use strict";var sk=Fb();qb.exports=sk});var Ji=b((sO,og)=>{"use strict";var hk=ki(),fk=String;og.exports=function(a){if(hk(a)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return fk(a)}});var Ou=b((nO,ug)=>{"use strict";ug.exports=`
7
- \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF`});var dg=b((oO,cg)=>{"use strict";var mk=ve(),bk=jt(),gk=Ji(),Vu=Ou(),lg=mk("".replace),vk=RegExp("^["+Vu+"]+"),Sk=RegExp("(^|[^"+Vu+"])["+Vu+"]+$"),Bu=function(a){return function(e){var t=gk(bk(e));return a&1&&(t=lg(t,vk,"")),a&2&&(t=lg(t,Sk,"$1")),t}};cg.exports={start:Bu(1),end:Bu(2),trim:Bu(3)}});var mg=b((uO,fg)=>{"use strict";var yk=mo().PROPER,Tk=Pe(),pg=Ou(),hg="\u200B\x85\u180E";fg.exports=function(a){return Tk(function(){return!!pg[a]()||hg[a]()!==hg||yk&&pg[a].name!==a})}});var _u=b((lO,bg)=>{"use strict";var Ik=dg().start,Ek=mg();bg.exports=Ek("trimStart")?function(){return Ik(this)}:"".trimStart});var vg=b(()=>{"use strict";var xk=fe(),gg=_u();xk({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==gg},{trimLeft:gg})});var yg=b(()=>{"use strict";vg();var Pk=fe(),Sg=_u();Pk({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==Sg},{trimStart:Sg})});var Ig=b((fO,Tg)=>{"use strict";yg();var Ak=Gt();Tg.exports=Ak("String","trimLeft")});var xg=b((mO,Eg)=>{"use strict";var wk=Ig();Eg.exports=wk});var Ag=b((bO,Pg)=>{"use strict";var kk=xg();Pg.exports=kk});var Fg=b(()=>{"use strict"});var qg=b(()=>{"use strict"});var Hg=b((NV,Ug)=>{"use strict";var Yk=Fe(),zk=or(),Kk=Ae(),Jk=Kk("match");Ug.exports=function(a){var e;return Yk(a)&&((e=a[Jk])!==void 0?!!e:zk(a)==="RegExp")}});var Gg=b((FV,jg)=>{"use strict";var Xk=pt();jg.exports=function(){var a=Xk(this),e="";return a.hasIndices&&(e+="d"),a.global&&(e+="g"),a.ignoreCase&&(e+="i"),a.multiline&&(e+="m"),a.dotAll&&(e+="s"),a.unicode&&(e+="u"),a.unicodeSets&&(e+="v"),a.sticky&&(e+="y"),e}});var Yg=b((qV,Wg)=>{"use strict";var Zk=Ne(),eR=at(),tR=Si(),rR=Gg(),Qg=RegExp.prototype;Wg.exports=function(a){var e=a.flags;return e===void 0&&!("flags"in Qg)&&!eR(a,"flags")&&tR(Qg,a)?Zk(rR,a):e}});var Kg=b((UV,zg)=>{"use strict";var Gu=ve(),iR=Cr(),aR=Math.floor,Hu=Gu("".charAt),sR=Gu("".replace),ju=Gu("".slice),nR=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,oR=/\$([$&'`]|\d{1,2})/g;zg.exports=function(a,e,t,r,i,s){var n=t+a.length,o=r.length,u=oR;return i!==void 0&&(i=iR(i),u=nR),sR(s,u,function(l,d){var c;switch(Hu(d,0)){case"$":return"$";case"&":return a;case"`":return ju(e,0,t);case"'":return ju(e,n);case"<":c=i[ju(d,1,-1)];break;default:var p=+d;if(p===0)return l;if(p>o){var h=aR(p/10);return h===0?l:h<=o?r[h-1]===void 0?Hu(d,1):r[h-1]+Hu(d,1):l}c=r[p-1]}return c===void 0?"":c})}});var Zg=b(()=>{"use strict";var uR=fe(),lR=Ne(),Wu=ve(),Jg=jt(),cR=pe(),dR=Lr(),pR=Hg(),ii=Ji(),hR=Ti(),fR=Yg(),mR=Kg(),bR=Ae(),gR=it(),vR=bR("replace"),SR=TypeError,Qu=Wu("".indexOf),yR=Wu("".replace),Xg=Wu("".slice),TR=Math.max;uR({target:"String",proto:!0},{replaceAll:function(e,t){var r=Jg(this),i,s,n,o,u,l,d,c,p,h,m=0,g="";if(!dR(e)){if(i=pR(e),i&&(s=ii(Jg(fR(e))),!~Qu(s,"g")))throw new SR("`.replaceAll` does not allow non-global regexes");if(n=hR(e,vR),n)return lR(n,e,r,t);if(gR&&i)return yR(ii(r),e,t)}for(o=ii(r),u=ii(e),l=cR(t),l||(t=ii(t)),d=u.length,c=TR(1,d),p=Qu(o,u);p!==-1;)h=l?ii(t(u,p,o)):mR(u,o,p,[],void 0,t),g+=Xg(o,m,p)+h,m=p+d,p=p+c>o.length?-1:Qu(o,u,p+c);return m<o.length&&(g+=Xg(o,m)),g}})});var tv=b((GV,ev)=>{"use strict";Fg();qg();Zg();var IR=Gt();ev.exports=IR("String","replaceAll")});var iv=b((QV,rv)=>{"use strict";var ER=tv();rv.exports=ER});var sv=b((WV,av)=>{"use strict";var xR=iv();av.exports=xR});var ov=b((YV,nv)=>{"use strict";var PR=Pi(),AR=Ji(),wR=jt(),kR=RangeError;nv.exports=function(e){var t=AR(wR(this)),r="",i=PR(e);if(i<0||i===1/0)throw new kR("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))i&1&&(r+=t);return r}});var pv=b((zV,dv)=>{"use strict";var cv=ve(),RR=to(),uv=Ji(),$R=ov(),LR=jt(),MR=cv($R),CR=cv("".slice),DR=Math.ceil,lv=function(a){return function(e,t,r){var i=uv(LR(e)),s=RR(t),n=i.length,o=r===void 0?" ":uv(r),u,l;return s<=n||o===""?i:(u=s-n,l=MR(o,DR(u/o.length)),l.length>u&&(l=CR(l,0,u)),a?i+l:l+i)}};dv.exports={start:lv(!1),end:lv(!0)}});var fv=b((KV,hv)=>{"use strict";var OR=lr();hv.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(OR)});var mv=b(()=>{"use strict";var BR=fe(),VR=pv().start,_R=fv();BR({target:"String",proto:!0,forced:_R},{padStart:function(e){return VR(this,e,arguments.length>1?arguments[1]:void 0)}})});var gv=b((ZV,bv)=>{"use strict";mv();var NR=Gt();bv.exports=NR("String","padStart")});var Sv=b((e_,vv)=>{"use strict";var FR=gv();vv.exports=FR});var Tv=b((t_,yv)=>{"use strict";var qR=Sv();yv.exports=qR});var s$={};LS(s$,{ChromecastState:()=>mi,HttpConnectionType:()=>rs,Observable:()=>St.Observable,PlaybackState:()=>Re,Player:()=>qa,SDK_VERSION:()=>a$,Subject:()=>St.Subject,Subscription:()=>St.Subscription,Surface:()=>is,VERSION:()=>Pn,ValueSubject:()=>St.ValueSubject,VideoFormat:()=>Tt,VideoQuality:()=>St.VideoQuality});module.exports=MS(s$);var Pn="2.0.119-dev.c81726f6.0";var Re=(i=>(i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused",i))(Re||{}),Tt=(x=>(x.MPEG="MPEG",x.DASH="DASH",x.DASH_SEP="DASH_SEP",x.DASH_SEP_VK="DASH_SEP",x.DASH_WEBM="DASH_WEBM",x.DASH_WEBM_AV1="DASH_WEBM_AV1",x.DASH_STREAMS="DASH_STREAMS",x.DASH_WEBM_VK="DASH_WEBM",x.DASH_ONDEMAND="DASH_ONDEMAND",x.DASH_ONDEMAND_VK="DASH_ONDEMAND",x.DASH_LIVE="DASH_LIVE",x.DASH_LIVE_CMAF="DASH_LIVE_CMAF",x.DASH_LIVE_WEBM="DASH_LIVE_WEBM",x.HLS="HLS",x.HLS_ONDEMAND="HLS_ONDEMAND",x.HLS_JS="HLS",x.HLS_LIVE="HLS_LIVE",x.HLS_LIVE_CMAF="HLS_LIVE_CMAF",x.WEB_RTC_LIVE="WEB_RTC_LIVE",x))(Tt||{});var mi=(i=>(i.NOT_AVAILABLE="NOT_AVAILABLE",i.AVAILABLE="AVAILABLE",i.CONNECTING="CONNECTING",i.CONNECTED="CONNECTED",i))(mi||{}),rs=(r=>(r.HTTP1="http1",r.HTTP2="http2",r.QUIC="quic",r))(rs||{});var is=(n=>(n.NONE="none",n.INLINE="inline",n.FULLSCREEN="fullscreen",n.SECOND_SCREEN="second_screen",n.PIP="pip",n.INVISIBLE="invisible",n))(is||{});var pS=X(ht(),1);var q=require("@vkontakte/videoplayer-shared/es2015");var Ud=a=>new Promise((e,t)=>{let r=document.createElement("script");r.setAttribute("src",a),r.onload=()=>e,r.onerror=()=>t,document.body.appendChild(r)});var us=class{constructor(e){this.connection$=new q.ValueSubject(void 0);this.castState$=new q.ValueSubject("NOT_AVAILABLE");this.errorEvent$=new q.Subject;this.realCastState$=new q.ValueSubject("NOT_AVAILABLE");this.subscription=new q.Subscription;var s;this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastInitializer");let t="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${t}`}),e.isDisabled||!t)return;let r=(0,q.isNonNullable)((s=window.chrome)==null?void 0:s.cast),i=!!window.__onGCastApiAvailable;r?this.initializeCastApi():(window.__onGCastApiAvailable=n=>{delete window.__onGCastApiAvailable,n&&this.initializeCastApi()},i||Ud("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:q.ErrorCategory.NETWORK,message:"Script loading failed!"})))}connect(){var e;(e=cast.framework.CastContext.getInstance())==null||e.requestSession()}disconnect(){var e,t;(t=(e=cast.framework.CastContext.getInstance())==null?void 0:e.getCurrentSession())==null||t.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var r,i,s;(s=(i=(r=cast.framework.CastContext.getInstance())==null?void 0:r.getCurrentSession())==null?void 0:i.getMediaSession())==null||s.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){(0,q.isNonNullable)(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){let t=this.connection$.getValue();(0,q.isNullable)(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){let t=this.connection$.getValue();(0,q.isNullable)(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.subscription.unsubscribe()}initListeners(){let e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),r=cast.framework.CastContext.getInstance();this.subscription.add((0,q.fromEvent)(r,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(i=>{var s,n,o;switch(i.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(o=(n=(s=r.getCurrentSession())==null?void 0:s.getMediaSession())==null?void 0:n.media)==null?void 0:o.contentId;break;case cast.framework.SessionState.NO_SESSION:case cast.framework.SessionState.SESSION_ENDING:case cast.framework.SessionState.SESSION_ENDED:case cast.framework.SessionState.SESSION_START_FAILED:this.contentId=void 0;break;default:return(0,q.assertNever)(i.sessionState)}})).add((0,q.merge)((0,q.fromEvent)(r,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe((0,q.tap)(i=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(i)}`})}),(0,q.map)(i=>i.castState)),(0,q.observableFrom)([r.getCastState()])).pipe((0,q.filterChanged)(),(0,q.map)(eI),(0,q.tap)(i=>{this.log({message:`realCastState$: ${i}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(i=>{var o,u;let s=i==="CONNECTED",n=(0,q.isNonNullable)(this.connection$.getValue());if(s&&!n){let l=r.getCurrentSession();(0,q.assertNonNullable)(l);let d=l.getCastDevice(),c=(u=(o=l.getMediaSession())==null?void 0:o.media)==null?void 0:u.contentId;((0,q.isNullable)(c)||c===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:l,castDevice:d}))}else!s&&n&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(i==="CONNECTED"?(0,q.isNonNullable)(this.connection$.getValue())?"CONNECTED":"AVAILABLE":i)}))}initializeCastApi(){var i;let e,t,r;try{e=cast.framework.CastContext.getInstance(),t=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,r=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(s){return}try{e.setOptions({receiverApplicationId:(i=this.params.receiverApplicationId)!=null?i:t,autoJoinPolicy:r}),this.initListeners()}catch(s){this.errorEvent$.next({id:"ChromecastInitializer",category:q.ErrorCategory.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:s})}}},eI=a=>{switch(a){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return"NOT_AVAILABLE";case cast.framework.CastState.NOT_CONNECTED:return"AVAILABLE";case cast.framework.CastState.CONNECTING:return"CONNECTING";case cast.framework.CastState.CONNECTED:return"CONNECTED";default:return(0,q.assertNever)(a)}};var cl=X(ht(),1),Zv=X(Fr(),1),eS=X($o(),1);var Fm=X(Bs(),1);var bu=require("@vkontakte/videoplayer-shared/es2015");var we=(a,e=0,t=0)=>{switch(t){case 0:return a.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case 1:{if(e===0)return a;let r=new URL(a);return r.searchParams.append("playback_shift",e.toFixed(0)),r.toString()}case 2:{let r=new URL(a);return!r.searchParams.get("offset_p")&&e===0?a:(r.searchParams.set("offset_p",e.toFixed(0)),r.toString())}default:(0,bu.assertNever)(t)}return a},Vs=(a,e)=>{var t;switch(e){case 0:return NaN;case 1:{let r=new URL(a);return Number(r.searchParams.get("playback_shift"))}case 2:{let r=new URL(a);return Number((t=r.searchParams.get("offset_p"))!=null?t:0)}default:(0,bu.assertNever)(e)}};var k=(a,e,t=!1)=>{let r=a.getTransition();(t||!r||r.to===e)&&a.setState(e)};var ft=require("@vkontakte/videoplayer-shared/es2015"),j=class{constructor(e){this.transitionStarted$=new ft.Subject;this.transitionEnded$=new ft.Subject;this.transitionUpdated$=new ft.Subject;this.forceChanged$=new ft.Subject;this.stateChangeStarted$=(0,ft.merge)(this.transitionStarted$,this.transitionUpdated$);this.stateChangeEnded$=(0,ft.merge)(this.transitionEnded$,this.forceChanged$);this.state=e,this.prevState=void 0}setState(e){let t=this.transition,r=this.state;this.transition=void 0,this.prevState=r,this.state=e,t?t.to===e?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:r,to:e,canceledTransition:t})}startTransitionTo(e){let t=this.transition,r=this.state;r===e||(0,ft.isNonNullable)(t)&&t.to===e||(this.prevState=r,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:r,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}};var Vm=require("@vkontakte/videoplayer-shared/es2015"),_m=a=>{switch(a){case"MPEG":case"DASH":case"DASH_SEP":case"DASH_ONDEMAND":case"DASH_WEBM":case"DASH_WEBM_AV1":case"DASH_STREAMS":case"HLS":case"HLS_ONDEMAND":return!1;case"DASH_LIVE":case"DASH_LIVE_CMAF":case"HLS_LIVE":case"HLS_LIVE_CMAF":case"DASH_LIVE_WEBM":case"WEB_RTC_LIVE":return!0;default:return(0,Vm.assertNever)(a)}};var L=require("@vkontakte/videoplayer-shared/es2015");var uw=5,lw=5,cw=500,Nm=7e3,Ni=class{constructor(e){this.subscription=new L.Subscription;this.loadMediaTimeoutSubscription=new L.Subscription;this.videoState=new j("stopped");this.syncPlayback=()=>{let e=this.videoState.getState(),t=this.videoState.getTransition(),r=this.params.desiredState.playbackState.getState(),i=this.params.desiredState.playbackState.getTransition(),s=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${e}; videoTransition: ${JSON.stringify(t)}; desiredPlaybackState: ${r}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(s)};`}),r==="stopped"){e!=="stopped"&&(this.videoState.startTransitionTo("stopped"),this.stop());return}if(!t){if((i==null?void 0:i.to)!=="paused"&&s.state==="requested"&&e!=="stopped"){this.seek(s.position/1e3);return}switch(r){case"ready":{switch(e){case"playing":case"paused":case"ready":break;case"stopped":this.videoState.startTransitionTo("ready"),this.prepare();break;default:(0,L.assertNever)(e)}break}case"playing":{switch(e){case"playing":break;case"paused":this.videoState.startTransitionTo("playing"),this.params.connection.remotePlayerController.playOrPause();break;case"ready":this.videoState.startTransitionTo("playing"),this.params.connection.remotePlayerController.playOrPause();break;case"stopped":this.videoState.startTransitionTo("ready"),this.prepare();break;default:(0,L.assertNever)(e)}break}case"paused":{switch(e){case"playing":this.videoState.startTransitionTo("paused"),this.params.connection.remotePlayerController.playOrPause();break;case"paused":break;case"ready":this.videoState.startTransitionTo("paused"),this.videoState.setState("paused");break;case"stopped":this.videoState.startTransitionTo("ready"),this.prepare();break;default:(0,L.assertNever)(e)}break}default:(0,L.assertNever)(r)}}};this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastProvider"),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(_m(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});let t=this.params.connection.session.getMediaSession();t&&this.restoreSession(t),this.subscribe()}destroy(){this.log({message:"[destroy]"}),this.subscription.unsubscribe()}subscribe(){this.subscription.add(this.loadMediaTimeoutSubscription);let e=new L.Subscription;this.subscription.add(e),this.subscription.add((0,L.merge)(this.videoState.stateChangeStarted$.pipe((0,L.map)(i=>`stateChangeStarted$ ${JSON.stringify(i)}`)),this.videoState.stateChangeEnded$.pipe((0,L.map)(i=>`stateChangeEnded$ ${JSON.stringify(i)}`))).subscribe(i=>this.log({message:`[videoState] ${i}`})));let t=(i,s)=>this.subscription.add(i.subscribe(s));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{let i=new L.Subject;e.add(i.pipe((0,L.debounce)(cw)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let s=NaN;e.add((0,L.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(n=>{this.logRemoteEvent(n);let o=n.value;this.params.output.position$.next(o),(this.params.desiredState.seekState.getState().state==="applying"||Math.abs(o-s)>uw)&&i.next(o),s=o})),e.add((0,L.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(n=>{this.logRemoteEvent(n),this.params.output.duration$.next(n.value)}))}t((0,L.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),i=>{this.logRemoteEvent(i),i.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t((0,L.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),i=>{this.logRemoteEvent(i),i.value?this.handleRemotePause():this.handleRemotePlay()}),t((0,L.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),i=>{this.logRemoteEvent(i);let{remotePlayer:s}=this.params.connection,n=i.value,o=this.params.output.isBuffering$.getValue(),u=n===chrome.cast.media.PlayerState.BUFFERING;switch(o!==u&&this.params.output.isBuffering$.next(u),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&s.duration-s.currentTime<lw&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),k(this.params.desiredState.playbackState,"stopped");break;case chrome.cast.media.PlayerState.PAUSED:{this.handleRemotePause();break}case chrome.cast.media.PlayerState.PLAYING:this.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:(0,L.assertNever)(n)}}),t((0,L.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),i=>{this.logRemoteEvent(i),this.handleRemoteVolumeChange({volume:i.value})}),t((0,L.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),i=>{this.logRemoteEvent(i),this.handleRemoteVolumeChange({muted:i.value})});let r=(0,L.merge)(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,(0,L.observableFrom)(["init"])).pipe((0,L.debounce)(0));t(r,this.syncPlayback)}restoreSession(e){this.log({message:"restoreSession"});let{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused")):(this.videoState.setState("playing"),k(this.params.desiredState.playbackState,"playing"));let r=this.params.output.isLive$.getValue();this.params.output.duration$.next(r?0:t.duration),this.params.output.position$.next(r?0:t.currentTime),this.params.desiredState.seekState.setState({state:"none"})}}prepare(){let e=this.params.format;this.log({message:`[prepare] format: ${e}`});let t=this.createMediaInfo(e),r=this.createLoadRequest(t);this.loadMedia(r)}handleRemotePause(){let e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)==="paused"||e==="playing")&&(this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused"))}handleRemotePlay(){let e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)==="playing"||e==="paused")&&(this.videoState.setState("playing"),k(this.params.desiredState.playbackState,"playing"))}handleRemoteReady(){var t;let e=this.videoState.getTransition();(e==null?void 0:e.to)==="ready"&&this.videoState.setState("ready"),((t=this.params.desiredState.playbackState.getTransition())==null?void 0:t.to)==="ready"&&k(this.params.desiredState.playbackState,"ready")}handleRemoteStop(){this.videoState.getState()!=="stopped"&&this.videoState.setState("stopped")}handleRemoteVolumeChange(e){var i,s;let t=this.params.output.volume$.getValue(),r={volume:(i=e.volume)!=null?i:t.volume,muted:(s=e.muted)!=null?s:t.muted};(r.volume!==t.volume||r.muted!==r.muted)&&this.params.output.volume$.next(r)}seek(e){this.params.output.willSeekEvent$.next();let{remotePlayer:t,remotePlayerController:r}=this.params.connection;t.currentTime=e,r.seek()}stop(){let{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var l;let t=this.params.source,r,i,s;switch(e){case"MPEG":{let d=t[e];(0,L.assertNonNullable)(d);let c=(0,L.getHighestQuality)(Object.keys(d));(0,L.assertNonNullable)(c);let p=d[c];(0,L.assertNonNullable)(p),r=p,i="video/mp4",s=chrome.cast.media.StreamType.BUFFERED;break}case"HLS":case"HLS_ONDEMAND":{let d=t[e];(0,L.assertNonNullable)(d),r=d.url,i="application/x-mpegurl",s=chrome.cast.media.StreamType.BUFFERED;break}case"DASH_SEP":case"DASH_ONDEMAND":case"DASH_WEBM":case"DASH_WEBM_AV1":case"DASH_STREAMS":{let d=t[e];(0,L.assertNonNullable)(d),r=d.url,i="application/dash+xml",s=chrome.cast.media.StreamType.BUFFERED;break}case"DASH_LIVE_CMAF":{let d=t[e];(0,L.assertNonNullable)(d),r=d.url,i="application/dash+xml",s=chrome.cast.media.StreamType.LIVE;break}case"HLS_LIVE":case"HLS_LIVE_CMAF":{let d=t[e];(0,L.assertNonNullable)(d),r=we(d.url),i="application/x-mpegurl",s=chrome.cast.media.StreamType.LIVE;break}case"DASH_LIVE":case"WEB_RTC_LIVE":{let d="Unsupported format for Chromecast",c=new Error(d);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:L.ErrorCategory.VIDEO_PIPELINE,message:d,thrown:c}),c}case"DASH":case"DASH_LIVE_WEBM":throw new Error(`${e} is no longer supported`);default:return(0,L.assertNever)(e)}let n=new chrome.cast.media.MediaInfo((l=this.params.meta.videoId)!=null?l:r,i);n.contentUrl=r,n.streamType=s,n.metadata=new chrome.cast.media.GenericMediaMetadata;let{title:o,subtitle:u}=this.params.meta;return(0,L.isNonNullable)(o)&&(n.metadata.title=o),(0,L.isNonNullable)(u)&&(n.metadata.subtitle=u),n}createLoadRequest(e){let t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;let r=this.params.desiredState.seekState.getState();return r.state==="applying"||r.state==="requested"?t.currentTime=this.params.output.isLive$.getValue()?0:r.position/1e3:t.currentTime=0,t}loadMedia(e){let t=this.params.connection.session.loadMedia(e),r=new Promise((i,s)=>{this.loadMediaTimeoutSubscription.add((0,L.timeout)(Nm).subscribe(()=>s(`timeout(${Nm})`)))});(0,Fm.default)(Promise.race([t,r]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state==="applying"&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},i=>{let s=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${i}`;this.log({message:s}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:L.ErrorCategory.VIDEO_PIPELINE,message:s,thrown:i})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}};var $u=X(ht(),1);var yu=require("@vkontakte/videoplayer-shared/es2015");var qm=require("@vkontakte/videoplayer-shared/es2015"),Um=a=>{try{a.pause(),a.playbackRate=0,(0,qm.clearVideoElement)(a),a.remove()}catch(e){console.error(e)}};var _s=require("@vkontakte/videoplayer-shared/es2015"),gu=class{constructor(){this.attribute="data-pool-reused"}get(e){return e.hasAttribute(this.attribute)}set(e,t){e.toggleAttribute(this.attribute,t)}delete(e){e.removeAttribute(this.attribute)}},vu=window.WeakMap?new WeakMap:new gu,Su=window.WeakMap?new WeakMap:new Map,dw=(a,e=20)=>{let t=0;return(0,_s.fromEvent)(a,"ratechange").subscribe(r=>{t++,t>=e&&(a.currentTime=a.currentTime,t=0)})},Le=(a,{audioVideoSyncRate:e})=>{let t=a.querySelector("video"),r=!!t;t?(0,yu.clearVideoElement)(t):(t=document.createElement("video"),a.appendChild(t)),vu.set(t,r);let i=new _s.Subscription;return i.add(dw(t,e)),Su.set(t,i),t.setAttribute("crossorigin","anonymous"),t.setAttribute("playsinline","playsinline"),t.controls=!1,t.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),t},Me=a=>{let e=Su.get(a);e==null||e.unsubscribe(),Su.delete(a);let t=vu.get(a);vu.delete(a),t?(0,yu.clearVideoElement)(a):Um(a)};var Tu=X(Fi(),1),M=require("@vkontakte/videoplayer-shared/es2015");var Wt=require("@vkontakte/videoplayer-shared/es2015"),Ns=(a,e,t,{equal:r=(n,o)=>n===o,changed$:i,onError:s}={})=>{let n=a.getState(),o=e(),u=(0,Wt.isNullable)(i),l=new Wt.Subscription;return i&&l.add(i.subscribe(d=>{let c=a.getState();r(d,c)&&a.setState(d)},s)),r(o,n)||(t(n),u&&a.setState(n)),l.add(a.stateChangeStarted$.subscribe(d=>{t(d.to),u&&a.setState(d.to)},s)),l},mt=(a,e,t)=>Ns(e,()=>a.loop,r=>{(0,Wt.isNonNullable)(r)&&(a.loop=r)},{onError:t}),Ce=(a,e,t,r)=>Ns(e,()=>({muted:a.muted,volume:a.volume}),i=>{(0,Wt.isNonNullable)(i)&&(a.muted=i.muted,a.volume=i.volume)},{equal:(i,s)=>i===s||(i==null?void 0:i.muted)===(s==null?void 0:s.muted)&&(i==null?void 0:i.volume)===(s==null?void 0:s.volume),changed$:t,onError:r}),Ye=(a,e,t,r)=>Ns(e,()=>a.playbackRate,i=>{(0,Wt.isNonNullable)(i)&&(a.playbackRate=i)},{changed$:t,onError:r}),Yt=Ns;var gw=a=>["__",a.language,a.label].join("|"),vw=(a,e)=>{if(a.id===e)return!0;let[t,r,i]=e.split("|");return a.language===r&&a.label===i},Iu=class a{constructor(){this.available$=new M.Subject;this.current$=new M.ValueSubject(void 0);this.error$=new M.Subject;this.subscription=new M.Subscription;this.externalTracks=new Map;this.internalTracks=new Map}connect(e,t,r){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();let i=s=>{this.error$.next({id:"TextTracksManager",category:M.ErrorCategory.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:s})};this.subscription.add(this.available$.subscribe(r.availableTextTracks$)),this.subscription.add(this.current$.subscribe(r.currentTextTrack$)),this.subscription.add(this.error$.subscribe(r.error$)),this.subscription.add(Yt(t.internalTextTracks,()=>(0,Tu.default)(this.internalTracks),s=>{(0,M.isNonNullable)(s)&&this.setInternal(s)},{equal:(s,n)=>(0,M.isNonNullable)(s)&&(0,M.isNonNullable)(n)&&s.length===n.length&&s.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe((0,M.map)(s=>s.filter(({type:n})=>n==="internal"))),onError:i})),this.subscription.add(Yt(t.externalTextTracks,()=>(0,Tu.default)(this.externalTracks),s=>{(0,M.isNonNullable)(s)&&this.setExternal(s)},{equal:(s,n)=>(0,M.isNonNullable)(s)&&(0,M.isNonNullable)(n)&&s.length===n.length&&s.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe((0,M.map)(s=>s.filter(({type:n})=>n==="external"))),onError:i})),this.subscription.add(Yt(t.currentTextTrack,()=>{if(this.video)return;let s=this.htmlTextTracksAsArray().find(({mode:n})=>n==="showing");return s&&this.htmlTextTrackToITextTrack(s).id},s=>this.select(s),{changed$:this.current$,onError:i})),this.subscription.add(Yt(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(let s of this.htmlTextTracksAsArray())this.applyCueSettings(s.cues),this.applyCueSettings(s.activeCues)}))}subscribe(){(0,M.assertNonNullable)(this.video);let{textTracks:e}=this.video;this.subscription.add((0,M.fromEvent)(e,"addtrack").subscribe(()=>{let r=this.current$.getValue();r&&this.select(r)})),this.subscription.add((0,M.merge)((0,M.fromEvent)(e,"addtrack"),(0,M.fromEvent)(e,"removetrack"),(0,M.observableFrom)(["init"])).pipe((0,M.map)(()=>this.htmlTextTracksAsArray().map(r=>this.htmlTextTrackToITextTrack(r))),(0,M.filterChanged)((r,i)=>r.length===i.length&&r.every(({id:s},n)=>s===i[n].id))).subscribe(this.available$)),this.subscription.add((0,M.merge)((0,M.fromEvent)(e,"change"),(0,M.observableFrom)(["init"])).pipe((0,M.map)(()=>this.htmlTextTracksAsArray().find(({mode:r})=>r==="showing")),(0,M.map)(r=>r&&this.htmlTextTrackToITextTrack(r).id),(0,M.filterChanged)()).subscribe(this.current$));let t=r=>{var i,s;return this.applyCueSettings((s=(i=r.target)==null?void 0:i.activeCues)!=null?s:null)};this.subscription.add((0,M.fromEvent)(e,"addtrack").subscribe(r=>{var s,n;(s=r.track)==null||s.addEventListener("cuechange",t);let i=o=>{var l,d,c,p,h;let u=(d=(l=o.target)==null?void 0:l.cues)!=null?d:null;u&&u.length&&(this.applyCueSettings((p=(c=o.target)==null?void 0:c.cues)!=null?p:null),(h=o.target)==null||h.removeEventListener("cuechange",i))};(n=r.track)==null||n.addEventListener("cuechange",i)})),this.subscription.add((0,M.fromEvent)(e,"removetrack").subscribe(r=>{var i;(i=r.track)==null||i.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;let t=this.cueSettings.getState();for(let r of Array.from(e)){let i=r;(0,M.isNonNullable)(t.align)&&(i.align=t.align),(0,M.isNonNullable)(t.position)&&(i.position=t.position),(0,M.isNonNullable)(t.size)&&(i.size=t.size),(0,M.isNonNullable)(t.line)&&(i.line=t.line)}}htmlTextTracksAsArray(e=!1){(0,M.assertNonNullable)(this.video);let t=[...this.video.textTracks];return e?t:t.filter(a.isHealthyTrack)}htmlTextTrackToITextTrack(e){var o,u,l,d,c;let{language:t,label:r}=e,i=e.id?e.id:gw(e),s=this.externalTracks.has(i),n=(l=s?(o=this.externalTracks.get(i))==null?void 0:o.isAuto:(u=this.internalTracks.get(i))==null?void 0:u.isAuto)!=null?l:i.includes("auto");return s?{id:i,type:"external",isAuto:n,language:t,label:r,url:(d=this.externalTracks.get(i))==null?void 0:d.url}:{id:i,type:"internal",isAuto:n,language:t,label:r,url:(c=this.internalTracks.get(i))==null?void 0:c.url}}static isHealthyTrack(e){return!(e.kind==="metadata"||e.groupId||e.id===""&&e.label===""&&e.language==="")}setExternal(e){this.internalTracks.size>0&&Array.from(this.internalTracks).forEach(([,t])=>this.detach(t)),e.filter(({id:t})=>!this.externalTracks.has(t)).forEach(t=>this.attach(t)),Array.from(this.externalTracks).filter(([t])=>!e.find(r=>r.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){let t=[...this.externalTracks];e.filter(({id:r,language:i,isAuto:s})=>!this.internalTracks.has(r)&&!t.some(([,n])=>n.language===i&&n.isAuto===s)).forEach(r=>this.attach(r)),Array.from(this.internalTracks).filter(([r])=>!e.find(i=>i.id===r)).forEach(([,r])=>this.detach(r))}select(e){(0,M.assertNonNullable)(this.video);for(let t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(let t of this.htmlTextTracksAsArray(!0))((0,M.isNullable)(e)||!vw(t,e))&&(t.mode="disabled")}destroy(){if(this.subscription.unsubscribe(),this.video)for(let e of Array.from(this.video.getElementsByTagName("track"))){let t=e.getAttribute("id");t&&this.externalTracks.has(t)&&this.video.removeChild(e)}this.externalTracks.clear()}attach(e){(0,M.assertNonNullable)(this.video);let t=document.createElement("track");t.setAttribute("src",e.url),t.setAttribute("id",e.id),e.label&&t.setAttribute("label",e.label),e.language&&t.setAttribute("srclang",e.language),e.type==="external"?this.externalTracks.set(e.id,e):e.type==="internal"&&this.internalTracks.set(e.id,e),this.video.appendChild(t)}detach(e){(0,M.assertNonNullable)(this.video);let t=Array.prototype.find.call(this.video.getElementsByTagName("track"),r=>r.getAttribute("id")===e.id);t&&this.video.removeChild(t),e.type==="external"?this.externalTracks.delete(e.id):e.type==="internal"&&this.internalTracks.delete(e.id)}},ze=Iu;var Pt=class{constructor(){this.pausedTime=0;this.streamOffset=0;this.pauseTimestamp=0}getTotalPausedTime(){return this.pausedTime+this.getCurrentPausedTime()}getCurrentPausedTime(){return this.pauseTimestamp>0?Date.now()-this.pauseTimestamp:0}getStreamOffset(){return this.streamOffset}getTotalOffset(){return this.getTotalPausedTime()+this.streamOffset}pause(){this.pauseTimestamp===0&&(this.pauseTimestamp=Date.now())}resume(){this.pauseTimestamp>0&&(this.pausedTime+=this.getCurrentPausedTime(),this.pauseTimestamp=0)}resetTo(e,t=!1){this.streamOffset=e,this.pauseTimestamp=0,this.pausedTime=0,t&&this.pause()}};var zm=a=>{let e=a;for(;!(e instanceof Document)&&!(e instanceof ShadowRoot)&&e!==null;)e=e==null?void 0:e.parentNode;return e!=null?e:void 0},Eu=a=>{let e=zm(a);return!!(e&&e.fullscreenElement&&e.fullscreenElement===a)},Km=a=>{let e=zm(a);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===a)};var D=require("@vkontakte/videoplayer-shared/es2015");var Sw=3,Jm=(a,e,t=Sw)=>{let r=0,i=0;for(let s=0;s<a.length;s++){let n=a.start(s),o=a.end(s);if(n<=e&&e<=o){if(r=n,i=o,!t)return{from:r,to:i};for(let u=s-1;u>=0;u--)a.end(u)+t>=r&&(r=a.start(u));for(let u=s+1;u<a.length;u++)a.start(u)-t<=i&&(i=a.end(u))}}return{from:r,to:i}};var De=a=>{let e=x=>(0,D.fromEvent)(a,x).pipe((0,D.mapTo)(void 0)),r=(0,D.merge)(...["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"].map(x=>(0,D.fromEvent)(a,x))).pipe((0,D.map)(x=>x.type==="ended"?a.readyState<2:a.readyState<3),(0,D.filterChanged)()),i=(0,D.merge)((0,D.fromEvent)(a,"progress"),(0,D.fromEvent)(a,"timeupdate")).pipe((0,D.map)(()=>Jm(a.buffered,a.currentTime))),s=D.clientChecker.isSafari?(0,D.combine)({play:e("play").pipe((0,D.once)()),playing:e("playing")}).pipe((0,D.mapTo)(void 0)):e("playing"),n=(0,D.fromEvent)(a,"volumechange").pipe((0,D.map)(()=>({muted:a.muted,volume:a.volume}))),o=(0,D.fromEvent)(a,"ratechange").pipe((0,D.map)(()=>a.playbackRate)),u=(0,D.fromEvent)(a,"error").pipe((0,D.filter)(()=>!!(a.error||a.played.length)),(0,D.map)(()=>{var A;let x=a.error;return{id:x?`MediaError#${x.code}`:"HtmlVideoError",category:D.ErrorCategory.VIDEO_PIPELINE,message:x?x.message:"Error event from HTML video element",thrown:(A=a.error)!=null?A:void 0}})),l=(0,D.fromEvent)(a,"timeupdate").pipe((0,D.map)(()=>a.currentTime)),d=new D.Subject,c=.3,p;l.subscribe(x=>{a.loop&&(0,D.isNonNullable)(p)&&(0,D.isNonNullable)(x)&&p>=a.duration-c&&x<=c&&d.next(p),p=x});let h=e("pause").pipe((0,D.filter)(()=>!a.error&&p!==a.duration)),m=(0,D.fromEvent)(a,"enterpictureinpicture"),g=(0,D.fromEvent)(a,"leavepictureinpicture"),v=new D.ValueSubject(Km(a));m.subscribe(()=>v.next(!0)),g.subscribe(()=>v.next(!1));let I=new D.ValueSubject(Eu(a));return(0,D.fromEvent)(a,"fullscreenchange").pipe((0,D.map)(()=>Eu(a))).subscribe(I),{playing$:s,pause$:h,canplay$:e("canplay"),ended$:e("ended"),looped$:d,error$:u,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:l,durationChange$:(0,D.fromEvent)(a,"durationchange").pipe((0,D.map)(()=>a.duration)),isBuffering$:r,currentBuffer$:i,volumeState$:n,playbackRateState$:o,inPiP$:v,inFullscreen$:I}};var At=require("@vkontakte/videoplayer-shared/es2015"),zt=a=>{switch(a){case"mobile":return At.VideoQuality.Q_144P;case"lowest":return At.VideoQuality.Q_240P;case"low":return At.VideoQuality.Q_360P;case"sd":case"medium":return At.VideoQuality.Q_480P;case"hd":case"high":return At.VideoQuality.Q_720P;case"fullhd":case"full":return At.VideoQuality.Q_1080P;case"quadhd":case"quad":return At.VideoQuality.Q_1440P;case"ultrahd":case"ultra":return At.VideoQuality.Q_2160P}};var Kt=X(Kr(),1),ub=X(ht(),1),Fs=X(Fr(),1),C=require("@vkontakte/videoplayer-shared/es2015");var xu=!1,wt={},ab=a=>{xu=a},sb=()=>{wt={}},nb=a=>{a(wt)},qi=(a,e)=>{var t;xu&&(wt.meta=(t=wt.meta)!=null?t:{},wt.meta[a]=e)},$e=class{constructor(e){this.name=e}next(e){var r,i;if(!xu)return;wt.series=(r=wt.series)!=null?r:{};let t=(i=wt.series[this.name])!=null?i:[];t.push([Date.now(),e]),wt.series[this.name]=t}};var kw=new $e("best_bitrate"),lb=(a,e,t)=>(e-t)*Math.pow(2,-10*a)+t;var Pu=a=>(e,t)=>a*(Number(e.bitrate)-Number(t.bitrate)),Ui=class{constructor(){this.history={}}recordSelection(e){this.history[e.id]=(0,C.now)()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}},cb='Assertion "ABR Tracks is empty array" failed',qs=(a,e,t,r)=>{var u;let i=[...e].sort(Pu(1)),s=[...t].sort(Pu(1)),n=s.filter(l=>(0,C.isNonNullable)(l.bitrate)&&(0,C.isNonNullable)(a.bitrate)?a.bitrate/l.bitrate>r:!0),o=(u=(0,Kt.default)(s,Math.round(s.length*i.indexOf(a)/(i.length+1))))!=null?u:(0,Kt.default)(s,-1);return o&&(0,ub.default)(n,o)?o:n.length?(0,Kt.default)(n,-1):(0,Kt.default)(s,0)},ob=a=>"quality"in a,db=(a,e,t,r)=>{var n;let i=(0,C.isNonNullable)((n=r==null?void 0:r.last)==null?void 0:n.bitrate)&&(0,C.isNonNullable)(t==null?void 0:t.bitrate)&&r.last.bitrate<t.bitrate?a.trackCooldownIncreaseQuality:a.trackCooldownDecreaseQuality,s=t&&r&&r.history[t.id]&&(0,C.now)()-r.history[t.id]<=i&&(!r.last||t.id!==r.last.id);if(t!=null&&t.id&&r&&!s&&r.recordSelection(t),s&&(r!=null&&r.last)){let o=r.last;r==null||r.recordSwitch(o);let u=ob(o)?"video":"audio",l=ob(o)?o.quality:o.bitrate;return e({message:`
6
+ "use strict";var xS=Object.create;var fi=Object.defineProperty,PS=Object.defineProperties,AS=Object.getOwnPropertyDescriptor,wS=Object.getOwnPropertyDescriptors,kS=Object.getOwnPropertyNames,ts=Object.getOwnPropertySymbols,RS=Object.getPrototypeOf,En=Object.prototype.hasOwnProperty,Wl=Object.prototype.propertyIsEnumerable;var $S=(a,e)=>(e=Symbol[a])?e:Symbol.for("Symbol."+a);var ct=Math.pow,Ql=(a,e,t)=>e in a?fi(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,R=(a,e)=>{for(var t in e||(e={}))En.call(e,t)&&Ql(a,t,e[t]);if(ts)for(var t of ts(e))Wl.call(e,t)&&Ql(a,t,e[t]);return a},H=(a,e)=>PS(a,wS(e));var Yl=(a,e)=>{var t={};for(var r in a)En.call(a,r)&&e.indexOf(r)<0&&(t[r]=a[r]);if(a!=null&&ts)for(var r of ts(a))e.indexOf(r)<0&&Wl.call(a,r)&&(t[r]=a[r]);return t};var b=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports),LS=(a,e)=>{for(var t in e)fi(a,t,{get:e[t],enumerable:!0})},zl=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of kS(e))!En.call(a,i)&&i!==t&&fi(a,i,{get:()=>e[i],enumerable:!(r=AS(e,i))||r.enumerable});return a};var X=(a,e,t)=>(t=a!=null?xS(RS(a)):{},zl(e||!a||!a.__esModule?fi(t,"default",{value:a,enumerable:!0}):t,a)),MS=a=>zl(fi({},"__esModule",{value:!0}),a);var O=(a,e,t)=>new Promise((r,i)=>{var s=u=>{try{o(t.next(u))}catch(l){i(l)}},n=u=>{try{o(t.throw(u))}catch(l){i(l)}},o=u=>u.done?r(u.value):Promise.resolve(u.value).then(s,n);o((t=t.apply(a,e)).next())}),xn=function(a,e){this[0]=a,this[1]=e},me=(a,e,t)=>{var r=(n,o,u,l)=>{try{var d=t[n](o),c=(o=d.value)instanceof xn,p=d.done;Promise.resolve(c?o[0]:o).then(h=>c?r(n==="return"?n:"next",o[1]?{done:h.done,value:h.value}:h,u,l):u({value:h,done:p})).catch(h=>r("throw",h,u,l))}catch(h){l(h)}},i=n=>s[n]=o=>new Promise((u,l)=>r(n,o,u,l)),s={};return t=t.apply(a,e),s[$S("asyncIterator")]=()=>s,i("next"),i("throw"),i("return"),s};var he=b((An,Kl)=>{"use strict";var bi=function(a){return a&&a.Math===Math&&a};Kl.exports=bi(typeof globalThis=="object"&&globalThis)||bi(typeof window=="object"&&window)||bi(typeof self=="object"&&self)||bi(typeof global=="object"&&global)||bi(typeof An=="object"&&An)||function(){return this}()||Function("return this")()});var Pe=b((l$,Jl)=>{"use strict";Jl.exports=function(a){try{return!!a()}catch(e){return!0}}});var gi=b((c$,Xl)=>{"use strict";var CS=Pe();Xl.exports=!CS(function(){var a=function(){}.bind();return typeof a!="function"||a.hasOwnProperty("prototype")})});var wn=b((d$,rc)=>{"use strict";var DS=gi(),tc=Function.prototype,Zl=tc.apply,ec=tc.call;rc.exports=typeof Reflect=="object"&&Reflect.apply||(DS?ec.bind(Zl):function(){return ec.apply(Zl,arguments)})});var ve=b((p$,sc)=>{"use strict";var ic=gi(),ac=Function.prototype,kn=ac.call,OS=ic&&ac.bind.bind(kn,kn);sc.exports=ic?OS:function(a){return function(){return kn.apply(a,arguments)}}});var or=b((h$,oc)=>{"use strict";var nc=ve(),BS=nc({}.toString),VS=nc("".slice);oc.exports=function(a){return VS(BS(a),8,-1)}});var Rn=b((f$,uc)=>{"use strict";var _S=or(),NS=ve();uc.exports=function(a){if(_S(a)==="Function")return NS(a)}});var pe=b((m$,lc)=>{"use strict";var $n=typeof document=="object"&&document.all;lc.exports=typeof $n=="undefined"&&$n!==void 0?function(a){return typeof a=="function"||a===$n}:function(a){return typeof a=="function"}});var _e=b((b$,cc)=>{"use strict";var FS=Pe();cc.exports=!FS(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Ne=b((g$,dc)=>{"use strict";var qS=gi(),as=Function.prototype.call;dc.exports=qS?as.bind(as):function(){return as.apply(as,arguments)}});var Ln=b(fc=>{"use strict";var pc={}.propertyIsEnumerable,hc=Object.getOwnPropertyDescriptor,US=hc&&!pc.call({1:2},1);fc.f=US?function(e){var t=hc(this,e);return!!t&&t.enumerable}:pc});var vi=b((S$,mc)=>{"use strict";mc.exports=function(a,e){return{enumerable:!(a&1),configurable:!(a&2),writable:!(a&4),value:e}}});var gc=b((y$,bc)=>{"use strict";var HS=ve(),jS=Pe(),GS=or(),Mn=Object,QS=HS("".split);bc.exports=jS(function(){return!Mn("z").propertyIsEnumerable(0)})?function(a){return GS(a)==="String"?QS(a,""):Mn(a)}:Mn});var Lr=b((T$,vc)=>{"use strict";vc.exports=function(a){return a==null}});var jt=b((I$,Sc)=>{"use strict";var WS=Lr(),YS=TypeError;Sc.exports=function(a){if(WS(a))throw new YS("Can't call method on "+a);return a}});var ur=b((E$,yc)=>{"use strict";var zS=gc(),KS=jt();yc.exports=function(a){return zS(KS(a))}});var Fe=b((x$,Tc)=>{"use strict";var JS=pe();Tc.exports=function(a){return typeof a=="object"?a!==null:JS(a)}});var Mr=b((P$,Ic)=>{"use strict";Ic.exports={}});var It=b((A$,xc)=>{"use strict";var Cn=Mr(),Dn=he(),XS=pe(),Ec=function(a){return XS(a)?a:void 0};xc.exports=function(a,e){return arguments.length<2?Ec(Cn[a])||Ec(Dn[a]):Cn[a]&&Cn[a][e]||Dn[a]&&Dn[a][e]}});var Si=b((w$,Pc)=>{"use strict";var ZS=ve();Pc.exports=ZS({}.isPrototypeOf)});var lr=b((k$,kc)=>{"use strict";var ey=he(),Ac=ey.navigator,wc=Ac&&Ac.userAgent;kc.exports=wc?String(wc):""});var Bn=b((R$,Dc)=>{"use strict";var Cc=he(),On=lr(),Rc=Cc.process,$c=Cc.Deno,Lc=Rc&&Rc.versions||$c&&$c.version,Mc=Lc&&Lc.v8,rt,ss;Mc&&(rt=Mc.split("."),ss=rt[0]>0&&rt[0]<4?1:+(rt[0]+rt[1]));!ss&&On&&(rt=On.match(/Edge\/(\d+)/),(!rt||rt[1]>=74)&&(rt=On.match(/Chrome\/(\d+)/),rt&&(ss=+rt[1])));Dc.exports=ss});var Vn=b(($$,Bc)=>{"use strict";var Oc=Bn(),ty=Pe(),ry=he(),iy=ry.String;Bc.exports=!!Object.getOwnPropertySymbols&&!ty(function(){var a=Symbol("symbol detection");return!iy(a)||!(Object(a)instanceof Symbol)||!Symbol.sham&&Oc&&Oc<41})});var _n=b((L$,Vc)=>{"use strict";var ay=Vn();Vc.exports=ay&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Nn=b((M$,_c)=>{"use strict";var sy=It(),ny=pe(),oy=Si(),uy=_n(),ly=Object;_c.exports=uy?function(a){return typeof a=="symbol"}:function(a){var e=sy("Symbol");return ny(e)&&oy(e.prototype,ly(a))}});var yi=b((C$,Nc)=>{"use strict";var cy=String;Nc.exports=function(a){try{return cy(a)}catch(e){return"Object"}}});var dt=b((D$,Fc)=>{"use strict";var dy=pe(),py=yi(),hy=TypeError;Fc.exports=function(a){if(dy(a))return a;throw new hy(py(a)+" is not a function")}});var Ti=b((O$,qc)=>{"use strict";var fy=dt(),my=Lr();qc.exports=function(a,e){var t=a[e];return my(t)?void 0:fy(t)}});var Hc=b((B$,Uc)=>{"use strict";var Fn=Ne(),qn=pe(),Un=Fe(),by=TypeError;Uc.exports=function(a,e){var t,r;if(e==="string"&&qn(t=a.toString)&&!Un(r=Fn(t,a))||qn(t=a.valueOf)&&!Un(r=Fn(t,a))||e!=="string"&&qn(t=a.toString)&&!Un(r=Fn(t,a)))return r;throw new by("Can't convert object to primitive value")}});var it=b((V$,jc)=>{"use strict";jc.exports=!0});var Wc=b((_$,Qc)=>{"use strict";var Gc=he(),gy=Object.defineProperty;Qc.exports=function(a,e){try{gy(Gc,a,{value:e,configurable:!0,writable:!0})}catch(t){Gc[a]=e}return e}});var Ii=b((N$,Kc)=>{"use strict";var vy=it(),Sy=he(),yy=Wc(),Yc="__core-js_shared__",zc=Kc.exports=Sy[Yc]||yy(Yc,{});(zc.versions||(zc.versions=[])).push({version:"3.38.0",mode:vy?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Hn=b((F$,Xc)=>{"use strict";var Jc=Ii();Xc.exports=function(a,e){return Jc[a]||(Jc[a]=e||{})}});var Cr=b((q$,Zc)=>{"use strict";var Ty=jt(),Iy=Object;Zc.exports=function(a){return Iy(Ty(a))}});var at=b((U$,ed)=>{"use strict";var Ey=ve(),xy=Cr(),Py=Ey({}.hasOwnProperty);ed.exports=Object.hasOwn||function(e,t){return Py(xy(e),t)}});var jn=b((H$,td)=>{"use strict";var Ay=ve(),wy=0,ky=Math.random(),Ry=Ay(1 .toString);td.exports=function(a){return"Symbol("+(a===void 0?"":a)+")_"+Ry(++wy+ky,36)}});var Ae=b((j$,id)=>{"use strict";var $y=he(),Ly=Hn(),rd=at(),My=jn(),Cy=Vn(),Dy=_n(),Dr=$y.Symbol,Gn=Ly("wks"),Oy=Dy?Dr.for||Dr:Dr&&Dr.withoutSetter||My;id.exports=function(a){return rd(Gn,a)||(Gn[a]=Cy&&rd(Dr,a)?Dr[a]:Oy("Symbol."+a)),Gn[a]}});var od=b((G$,nd)=>{"use strict";var By=Ne(),ad=Fe(),sd=Nn(),Vy=Ti(),_y=Hc(),Ny=Ae(),Fy=TypeError,qy=Ny("toPrimitive");nd.exports=function(a,e){if(!ad(a)||sd(a))return a;var t=Vy(a,qy),r;if(t){if(e===void 0&&(e="default"),r=By(t,a,e),!ad(r)||sd(r))return r;throw new Fy("Can't convert object to primitive value")}return e===void 0&&(e="number"),_y(a,e)}});var Qn=b((Q$,ud)=>{"use strict";var Uy=od(),Hy=Nn();ud.exports=function(a){var e=Uy(a,"string");return Hy(e)?e:e+""}});var ns=b((W$,cd)=>{"use strict";var jy=he(),ld=Fe(),Wn=jy.document,Gy=ld(Wn)&&ld(Wn.createElement);cd.exports=function(a){return Gy?Wn.createElement(a):{}}});var Yn=b((Y$,dd)=>{"use strict";var Qy=_e(),Wy=Pe(),Yy=ns();dd.exports=!Qy&&!Wy(function(){return Object.defineProperty(Yy("div"),"a",{get:function(){return 7}}).a!==7})});var fd=b(hd=>{"use strict";var zy=_e(),Ky=Ne(),Jy=Ln(),Xy=vi(),Zy=ur(),eT=Qn(),tT=at(),rT=Yn(),pd=Object.getOwnPropertyDescriptor;hd.f=zy?pd:function(e,t){if(e=Zy(e),t=eT(t),rT)try{return pd(e,t)}catch(r){}if(tT(e,t))return Xy(!Ky(Jy.f,e,t),e[t])}});var zn=b((K$,md)=>{"use strict";var iT=Pe(),aT=pe(),sT=/#|\.prototype\./,Ei=function(a,e){var t=oT[nT(a)];return t===lT?!0:t===uT?!1:aT(e)?iT(e):!!e},nT=Ei.normalize=function(a){return String(a).replace(sT,".").toLowerCase()},oT=Ei.data={},uT=Ei.NATIVE="N",lT=Ei.POLYFILL="P";md.exports=Ei});var Or=b((J$,gd)=>{"use strict";var bd=Rn(),cT=dt(),dT=gi(),pT=bd(bd.bind);gd.exports=function(a,e){return cT(a),e===void 0?a:dT?pT(a,e):function(){return a.apply(e,arguments)}}});var Kn=b((X$,vd)=>{"use strict";var hT=_e(),fT=Pe();vd.exports=hT&&fT(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var pt=b((Z$,Sd)=>{"use strict";var mT=Fe(),bT=String,gT=TypeError;Sd.exports=function(a){if(mT(a))return a;throw new gT(bT(a)+" is not an object")}});var cr=b(Td=>{"use strict";var vT=_e(),ST=Yn(),yT=Kn(),os=pt(),yd=Qn(),TT=TypeError,Jn=Object.defineProperty,IT=Object.getOwnPropertyDescriptor,Xn="enumerable",Zn="configurable",eo="writable";Td.f=vT?yT?function(e,t,r){if(os(e),t=yd(t),os(r),typeof e=="function"&&t==="prototype"&&"value"in r&&eo in r&&!r[eo]){var i=IT(e,t);i&&i[eo]&&(e[t]=r.value,r={configurable:Zn in r?r[Zn]:i[Zn],enumerable:Xn in r?r[Xn]:i[Xn],writable:!1})}return Jn(e,t,r)}:Jn:function(e,t,r){if(os(e),t=yd(t),os(r),ST)try{return Jn(e,t,r)}catch(i){}if("get"in r||"set"in r)throw new TT("Accessors not supported");return"value"in r&&(e[t]=r.value),e}});var Br=b((tL,Id)=>{"use strict";var ET=_e(),xT=cr(),PT=vi();Id.exports=ET?function(a,e,t){return xT.f(a,e,PT(1,t))}:function(a,e,t){return a[e]=t,a}});var fe=b((rL,xd)=>{"use strict";var xi=he(),AT=wn(),wT=Rn(),kT=pe(),RT=fd().f,$T=zn(),Vr=Mr(),LT=Or(),_r=Br(),Ed=at();Ii();var MT=function(a){var e=function(t,r,i){if(this instanceof e){switch(arguments.length){case 0:return new a;case 1:return new a(t);case 2:return new a(t,r)}return new a(t,r,i)}return AT(a,this,arguments)};return e.prototype=a.prototype,e};xd.exports=function(a,e){var t=a.target,r=a.global,i=a.stat,s=a.proto,n=r?xi:i?xi[t]:xi[t]&&xi[t].prototype,o=r?Vr:Vr[t]||_r(Vr,t,{})[t],u=o.prototype,l,d,c,p,h,m,g,v,I;for(p in e)l=$T(r?p:t+(i?".":"#")+p,a.forced),d=!l&&n&&Ed(n,p),m=o[p],d&&(a.dontCallGetSet?(I=RT(n,p),g=I&&I.value):g=n[p]),h=d&&g?g:e[p],!(!l&&!s&&typeof m==typeof h)&&(a.bind&&d?v=LT(h,xi):a.wrap&&d?v=MT(h):s&&kT(h)?v=wT(h):v=h,(a.sham||h&&h.sham||m&&m.sham)&&_r(v,"sham",!0),_r(o,p,v),s&&(c=t+"Prototype",Ed(Vr,c)||_r(Vr,c,{}),_r(Vr[c],p,h),a.real&&u&&(l||!u[p])&&_r(u,p,h)))}});var Ad=b((iL,Pd)=>{"use strict";var CT=Math.ceil,DT=Math.floor;Pd.exports=Math.trunc||function(e){var t=+e;return(t>0?DT:CT)(t)}});var Pi=b((aL,wd)=>{"use strict";var OT=Ad();wd.exports=function(a){var e=+a;return e!==e||e===0?0:OT(e)}});var Rd=b((sL,kd)=>{"use strict";var BT=Pi(),VT=Math.max,_T=Math.min;kd.exports=function(a,e){var t=BT(a);return t<0?VT(t+e,0):_T(t,e)}});var to=b((nL,$d)=>{"use strict";var NT=Pi(),FT=Math.min;$d.exports=function(a){var e=NT(a);return e>0?FT(e,9007199254740991):0}});var Nr=b((oL,Ld)=>{"use strict";var qT=to();Ld.exports=function(a){return qT(a.length)}});var ro=b((uL,Cd)=>{"use strict";var UT=ur(),HT=Rd(),jT=Nr(),Md=function(a){return function(e,t,r){var i=UT(e),s=jT(i);if(s===0)return!a&&-1;var n=HT(r,s),o;if(a&&t!==t){for(;s>n;)if(o=i[n++],o!==o)return!0}else for(;s>n;n++)if((a||n in i)&&i[n]===t)return a||n||0;return!a&&-1}};Cd.exports={includes:Md(!0),indexOf:Md(!1)}});var Ai=b((lL,Dd)=>{"use strict";Dd.exports=function(){}});var Od=b(()=>{"use strict";var GT=fe(),QT=ro().includes,WT=Pe(),YT=Ai(),zT=WT(function(){return!Array(1).includes()});GT({target:"Array",proto:!0,forced:zT},{includes:function(e){return QT(this,e,arguments.length>1?arguments[1]:void 0)}});YT("includes")});var Gt=b((pL,Bd)=>{"use strict";var KT=It();Bd.exports=KT});var _d=b((hL,Vd)=>{"use strict";Od();var JT=Gt();Vd.exports=JT("Array","includes")});var Fd=b((fL,Nd)=>{"use strict";var XT=_d();Nd.exports=XT});var ht=b((mL,qd)=>{"use strict";var ZT=Fd();qd.exports=ZT});var ls=b((AL,jd)=>{"use strict";var tI=Hn(),rI=jn(),Hd=tI("keys");jd.exports=function(a){return Hd[a]||(Hd[a]=rI(a))}});var Qd=b((wL,Gd)=>{"use strict";var iI=Pe();Gd.exports=!iI(function(){function a(){}return a.prototype.constructor=null,Object.getPrototypeOf(new a)!==a.prototype})});var cs=b((kL,Yd)=>{"use strict";var aI=at(),sI=pe(),nI=Cr(),oI=ls(),uI=Qd(),Wd=oI("IE_PROTO"),io=Object,lI=io.prototype;Yd.exports=uI?io.getPrototypeOf:function(a){var e=nI(a);if(aI(e,Wd))return e[Wd];var t=e.constructor;return sI(t)&&e instanceof t?t.prototype:e instanceof io?lI:null}});var ds=b((RL,zd)=>{"use strict";zd.exports={}});var Xd=b(($L,Jd)=>{"use strict";var cI=ve(),ao=at(),dI=ur(),pI=ro().indexOf,hI=ds(),Kd=cI([].push);Jd.exports=function(a,e){var t=dI(a),r=0,i=[],s;for(s in t)!ao(hI,s)&&ao(t,s)&&Kd(i,s);for(;e.length>r;)ao(t,s=e[r++])&&(~pI(i,s)||Kd(i,s));return i}});var so=b((LL,Zd)=>{"use strict";Zd.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var no=b((ML,ep)=>{"use strict";var fI=Xd(),mI=so();ep.exports=Object.keys||function(e){return fI(e,mI)}});var oo=b((CL,sp)=>{"use strict";var rp=_e(),bI=Pe(),ip=ve(),gI=cs(),vI=no(),SI=ur(),yI=Ln().f,ap=ip(yI),TI=ip([].push),II=rp&&bI(function(){var a=Object.create(null);return a[2]=2,!ap(a,2)}),tp=function(a){return function(e){for(var t=SI(e),r=vI(t),i=II&&gI(t)===null,s=r.length,n=0,o=[],u;s>n;)u=r[n++],(!rp||(i?u in t:ap(t,u)))&&TI(o,a?[u,t[u]]:t[u]);return o}};sp.exports={entries:tp(!0),values:tp(!1)}});var np=b(()=>{"use strict";var EI=fe(),xI=oo().entries;EI({target:"Object",stat:!0},{entries:function(e){return xI(e)}})});var up=b((BL,op)=>{"use strict";np();var PI=Mr();op.exports=PI.Object.entries});var cp=b((VL,lp)=>{"use strict";var AI=up();lp.exports=AI});var Fr=b((_L,dp)=>{"use strict";var wI=cp();dp.exports=wI});var dr=b((NL,pp)=>{"use strict";pp.exports={}});var mp=b((FL,fp)=>{"use strict";var kI=he(),RI=pe(),hp=kI.WeakMap;fp.exports=RI(hp)&&/native code/.test(String(hp))});var po=b((qL,vp)=>{"use strict";var $I=mp(),gp=he(),LI=Fe(),MI=Br(),uo=at(),lo=Ii(),CI=ls(),DI=ds(),bp="Object already initialized",co=gp.TypeError,OI=gp.WeakMap,ps,wi,hs,BI=function(a){return hs(a)?wi(a):ps(a,{})},VI=function(a){return function(e){var t;if(!LI(e)||(t=wi(e)).type!==a)throw new co("Incompatible receiver, "+a+" required");return t}};$I||lo.state?(st=lo.state||(lo.state=new OI),st.get=st.get,st.has=st.has,st.set=st.set,ps=function(a,e){if(st.has(a))throw new co(bp);return e.facade=a,st.set(a,e),e},wi=function(a){return st.get(a)||{}},hs=function(a){return st.has(a)}):(pr=CI("state"),DI[pr]=!0,ps=function(a,e){if(uo(a,pr))throw new co(bp);return e.facade=a,MI(a,pr,e),e},wi=function(a){return uo(a,pr)?a[pr]:{}},hs=function(a){return uo(a,pr)});var st,pr;vp.exports={set:ps,get:wi,has:hs,enforce:BI,getterFor:VI}});var mo=b((UL,yp)=>{"use strict";var ho=_e(),_I=at(),Sp=Function.prototype,NI=ho&&Object.getOwnPropertyDescriptor,fo=_I(Sp,"name"),FI=fo&&function(){}.name==="something",qI=fo&&(!ho||ho&&NI(Sp,"name").configurable);yp.exports={EXISTS:fo,PROPER:FI,CONFIGURABLE:qI}});var Ip=b(Tp=>{"use strict";var UI=_e(),HI=Kn(),jI=cr(),GI=pt(),QI=ur(),WI=no();Tp.f=UI&&!HI?Object.defineProperties:function(e,t){GI(e);for(var r=QI(t),i=WI(t),s=i.length,n=0,o;s>n;)jI.f(e,o=i[n++],r[o]);return e}});var bo=b((jL,Ep)=>{"use strict";var YI=It();Ep.exports=YI("document","documentElement")});var yo=b((GL,$p)=>{"use strict";var zI=pt(),KI=Ip(),xp=so(),JI=ds(),XI=bo(),ZI=ns(),eE=ls(),Pp=">",Ap="<",vo="prototype",So="script",kp=eE("IE_PROTO"),go=function(){},Rp=function(a){return Ap+So+Pp+a+Ap+"/"+So+Pp},wp=function(a){a.write(Rp("")),a.close();var e=a.parentWindow.Object;return a=null,e},tE=function(){var a=ZI("iframe"),e="java"+So+":",t;return a.style.display="none",XI.appendChild(a),a.src=String(e),t=a.contentWindow.document,t.open(),t.write(Rp("document.F=Object")),t.close(),t.F},fs,ms=function(){try{fs=new ActiveXObject("htmlfile")}catch(e){}ms=typeof document!="undefined"?document.domain&&fs?wp(fs):tE():wp(fs);for(var a=xp.length;a--;)delete ms[vo][xp[a]];return ms()};JI[kp]=!0;$p.exports=Object.create||function(e,t){var r;return e!==null?(go[vo]=zI(e),r=new go,go[vo]=null,r[kp]=e):r=ms(),t===void 0?r:KI.f(r,t)}});var qr=b((QL,Lp)=>{"use strict";var rE=Br();Lp.exports=function(a,e,t,r){return r&&r.enumerable?a[e]=t:rE(a,e,t),a}});var xo=b((WL,Dp)=>{"use strict";var iE=Pe(),aE=pe(),sE=Fe(),nE=yo(),Mp=cs(),oE=qr(),uE=Ae(),lE=it(),Eo=uE("iterator"),Cp=!1,Et,To,Io;[].keys&&(Io=[].keys(),"next"in Io?(To=Mp(Mp(Io)),To!==Object.prototype&&(Et=To)):Cp=!0);var cE=!sE(Et)||iE(function(){var a={};return Et[Eo].call(a)!==a});cE?Et={}:lE&&(Et=nE(Et));aE(Et[Eo])||oE(Et,Eo,function(){return this});Dp.exports={IteratorPrototype:Et,BUGGY_SAFARI_ITERATORS:Cp}});var bs=b((YL,Bp)=>{"use strict";var dE=Ae(),pE=dE("toStringTag"),Op={};Op[pE]="z";Bp.exports=String(Op)==="[object z]"});var ki=b((zL,Vp)=>{"use strict";var hE=bs(),fE=pe(),gs=or(),mE=Ae(),bE=mE("toStringTag"),gE=Object,vE=gs(function(){return arguments}())==="Arguments",SE=function(a,e){try{return a[e]}catch(t){}};Vp.exports=hE?gs:function(a){var e,t,r;return a===void 0?"Undefined":a===null?"Null":typeof(t=SE(e=gE(a),bE))=="string"?t:vE?gs(e):(r=gs(e))==="Object"&&fE(e.callee)?"Arguments":r}});var Np=b((KL,_p)=>{"use strict";var yE=bs(),TE=ki();_p.exports=yE?{}.toString:function(){return"[object "+TE(this)+"]"}});var Ri=b((JL,qp)=>{"use strict";var IE=bs(),EE=cr().f,xE=Br(),PE=at(),AE=Np(),wE=Ae(),Fp=wE("toStringTag");qp.exports=function(a,e,t,r){var i=t?a:a&&a.prototype;i&&(PE(i,Fp)||EE(i,Fp,{configurable:!0,value:e}),r&&!IE&&xE(i,"toString",AE))}});var Hp=b((XL,Up)=>{"use strict";var kE=xo().IteratorPrototype,RE=yo(),$E=vi(),LE=Ri(),ME=dr(),CE=function(){return this};Up.exports=function(a,e,t,r){var i=e+" Iterator";return a.prototype=RE(kE,{next:$E(+!r,t)}),LE(a,i,!1,!0),ME[i]=CE,a}});var Gp=b((ZL,jp)=>{"use strict";var DE=ve(),OE=dt();jp.exports=function(a,e,t){try{return DE(OE(Object.getOwnPropertyDescriptor(a,e)[t]))}catch(r){}}});var Wp=b((eM,Qp)=>{"use strict";var BE=Fe();Qp.exports=function(a){return BE(a)||a===null}});var zp=b((tM,Yp)=>{"use strict";var VE=Wp(),_E=String,NE=TypeError;Yp.exports=function(a){if(VE(a))return a;throw new NE("Can't set "+_E(a)+" as a prototype")}});var Po=b((rM,Kp)=>{"use strict";var FE=Gp(),qE=Fe(),UE=jt(),HE=zp();Kp.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var a=!1,e={},t;try{t=FE(Object.prototype,"__proto__","set"),t(e,[]),a=e instanceof Array}catch(r){}return function(i,s){return UE(i),HE(s),qE(i)&&(a?t(i,s):i.__proto__=s),i}}():void 0)});var oh=b((iM,nh)=>{"use strict";var jE=fe(),GE=Ne(),vs=it(),ah=mo(),QE=pe(),WE=Hp(),Jp=cs(),Xp=Po(),YE=Ri(),zE=Br(),Ao=qr(),KE=Ae(),Zp=dr(),sh=xo(),JE=ah.PROPER,XE=ah.CONFIGURABLE,eh=sh.IteratorPrototype,Ss=sh.BUGGY_SAFARI_ITERATORS,$i=KE("iterator"),th="keys",Li="values",rh="entries",ih=function(){return this};nh.exports=function(a,e,t,r,i,s,n){WE(t,e,r);var o=function(I){if(I===i&&p)return p;if(!Ss&&I&&I in d)return d[I];switch(I){case th:return function(){return new t(this,I)};case Li:return function(){return new t(this,I)};case rh:return function(){return new t(this,I)}}return function(){return new t(this)}},u=e+" Iterator",l=!1,d=a.prototype,c=d[$i]||d["@@iterator"]||i&&d[i],p=!Ss&&c||o(i),h=e==="Array"&&d.entries||c,m,g,v;if(h&&(m=Jp(h.call(new a)),m!==Object.prototype&&m.next&&(!vs&&Jp(m)!==eh&&(Xp?Xp(m,eh):QE(m[$i])||Ao(m,$i,ih)),YE(m,u,!0,!0),vs&&(Zp[u]=ih))),JE&&i===Li&&c&&c.name!==Li&&(!vs&&XE?zE(d,"name",Li):(l=!0,p=function(){return GE(c,this)})),i)if(g={values:o(Li),keys:s?p:o(th),entries:o(rh)},n)for(v in g)(Ss||l||!(v in d))&&Ao(d,v,g[v]);else jE({target:e,proto:!0,forced:Ss||l},g);return(!vs||n)&&d[$i]!==p&&Ao(d,$i,p,{name:i}),Zp[e]=p,g}});var lh=b((aM,uh)=>{"use strict";uh.exports=function(a,e){return{value:a,done:e}}});var ko=b((sM,fh)=>{"use strict";var ZE=ur(),wo=Ai(),ch=dr(),ph=po(),ex=cr().f,tx=oh(),ys=lh(),rx=it(),ix=_e(),hh="Array Iterator",ax=ph.set,sx=ph.getterFor(hh);fh.exports=tx(Array,"Array",function(a,e){ax(this,{type:hh,target:ZE(a),index:0,kind:e})},function(){var a=sx(this),e=a.target,t=a.index++;if(!e||t>=e.length)return a.target=void 0,ys(void 0,!0);switch(a.kind){case"keys":return ys(t,!1);case"values":return ys(e[t],!1)}return ys([t,e[t]],!1)},"values");var dh=ch.Arguments=ch.Array;wo("keys");wo("values");wo("entries");if(!rx&&ix&&dh.name!=="values")try{ex(dh,"name",{value:"values"})}catch(a){}});var bh=b((nM,mh)=>{"use strict";var nx=Ae(),ox=dr(),ux=nx("iterator"),lx=Array.prototype;mh.exports=function(a){return a!==void 0&&(ox.Array===a||lx[ux]===a)}});var Ro=b((oM,vh)=>{"use strict";var cx=ki(),gh=Ti(),dx=Lr(),px=dr(),hx=Ae(),fx=hx("iterator");vh.exports=function(a){if(!dx(a))return gh(a,fx)||gh(a,"@@iterator")||px[cx(a)]}});var yh=b((uM,Sh)=>{"use strict";var mx=Ne(),bx=dt(),gx=pt(),vx=yi(),Sx=Ro(),yx=TypeError;Sh.exports=function(a,e){var t=arguments.length<2?Sx(a):e;if(bx(t))return gx(mx(t,a));throw new yx(vx(a)+" is not iterable")}});var Eh=b((lM,Ih)=>{"use strict";var Tx=Ne(),Th=pt(),Ix=Ti();Ih.exports=function(a,e,t){var r,i;Th(a);try{if(r=Ix(a,"return"),!r){if(e==="throw")throw t;return t}r=Tx(r,a)}catch(s){i=!0,r=s}if(e==="throw")throw t;if(i)throw r;return Th(r),t}});var Is=b((cM,wh)=>{"use strict";var Ex=Or(),xx=Ne(),Px=pt(),Ax=yi(),wx=bh(),kx=Nr(),xh=Si(),Rx=yh(),$x=Ro(),Ph=Eh(),Lx=TypeError,Ts=function(a,e){this.stopped=a,this.result=e},Ah=Ts.prototype;wh.exports=function(a,e,t){var r=t&&t.that,i=!!(t&&t.AS_ENTRIES),s=!!(t&&t.IS_RECORD),n=!!(t&&t.IS_ITERATOR),o=!!(t&&t.INTERRUPTED),u=Ex(e,r),l,d,c,p,h,m,g,v=function(T){return l&&Ph(l,"normal",T),new Ts(!0,T)},I=function(T){return i?(Px(T),o?u(T[0],T[1],v):u(T[0],T[1])):o?u(T,v):u(T)};if(s)l=a.iterator;else if(n)l=a;else{if(d=$x(a),!d)throw new Lx(Ax(a)+" is not iterable");if(wx(d)){for(c=0,p=kx(a);p>c;c++)if(h=I(a[c]),h&&xh(Ah,h))return h;return new Ts(!1)}l=Rx(a,d)}for(m=s?a.next:l.next;!(g=xx(m,l)).done;){try{h=I(g.value)}catch(T){Ph(l,"throw",T)}if(typeof h=="object"&&h&&xh(Ah,h))return h}return new Ts(!1)}});var Rh=b((dM,kh)=>{"use strict";var Mx=_e(),Cx=cr(),Dx=vi();kh.exports=function(a,e,t){Mx?Cx.f(a,e,Dx(0,t)):a[e]=t}});var $h=b(()=>{"use strict";var Ox=fe(),Bx=Is(),Vx=Rh();Ox({target:"Object",stat:!0},{fromEntries:function(e){var t={};return Bx(e,function(r,i){Vx(t,r,i)},{AS_ENTRIES:!0}),t}})});var Mh=b((fM,Lh)=>{"use strict";ko();$h();var _x=Mr();Lh.exports=_x.Object.fromEntries});var Dh=b((mM,Ch)=>{"use strict";Ch.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}});var Bh=b(()=>{"use strict";ko();var Nx=Dh(),Fx=he(),qx=Ri(),Oh=dr();for(Es in Nx)qx(Fx[Es],Es),Oh[Es]=Oh.Array;var Es});var _h=b((vM,Vh)=>{"use strict";var Ux=Mh();Bh();Vh.exports=Ux});var $o=b((SM,Nh)=>{"use strict";var Hx=_h();Nh.exports=Hx});var Fh=b(()=>{"use strict"});var Lo=b((IM,qh)=>{"use strict";var Mi=he(),jx=lr(),Gx=or(),xs=function(a){return jx.slice(0,a.length)===a};qh.exports=function(){return xs("Bun/")?"BUN":xs("Cloudflare-Workers")?"CLOUDFLARE":xs("Deno/")?"DENO":xs("Node.js/")?"NODE":Mi.Bun&&typeof Bun.version=="string"?"BUN":Mi.Deno&&typeof Deno.version=="object"?"DENO":Gx(Mi.process)==="process"?"NODE":Mi.window&&Mi.document?"BROWSER":"REST"}()});var Ps=b((EM,Uh)=>{"use strict";var Qx=Lo();Uh.exports=Qx==="NODE"});var jh=b((xM,Hh)=>{"use strict";var Wx=cr();Hh.exports=function(a,e,t){return Wx.f(a,e,t)}});var Wh=b((PM,Qh)=>{"use strict";var Yx=It(),zx=jh(),Kx=Ae(),Jx=_e(),Gh=Kx("species");Qh.exports=function(a){var e=Yx(a);Jx&&e&&!e[Gh]&&zx(e,Gh,{configurable:!0,get:function(){return this}})}});var zh=b((AM,Yh)=>{"use strict";var Xx=Si(),Zx=TypeError;Yh.exports=function(a,e){if(Xx(e,a))return a;throw new Zx("Incorrect invocation")}});var Co=b((wM,Kh)=>{"use strict";var eP=ve(),tP=pe(),Mo=Ii(),rP=eP(Function.toString);tP(Mo.inspectSource)||(Mo.inspectSource=function(a){return rP(a)});Kh.exports=Mo.inspectSource});var Oo=b((kM,tf)=>{"use strict";var iP=ve(),aP=Pe(),Jh=pe(),sP=ki(),nP=It(),oP=Co(),Xh=function(){},Zh=nP("Reflect","construct"),Do=/^\s*(?:class|function)\b/,uP=iP(Do.exec),lP=!Do.test(Xh),Ci=function(e){if(!Jh(e))return!1;try{return Zh(Xh,[],e),!0}catch(t){return!1}},ef=function(e){if(!Jh(e))return!1;switch(sP(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return lP||!!uP(Do,oP(e))}catch(t){return!0}};ef.sham=!0;tf.exports=!Zh||aP(function(){var a;return Ci(Ci.call)||!Ci(Object)||!Ci(function(){a=!0})||a})?ef:Ci});var af=b((RM,rf)=>{"use strict";var cP=Oo(),dP=yi(),pP=TypeError;rf.exports=function(a){if(cP(a))return a;throw new pP(dP(a)+" is not a constructor")}});var Bo=b(($M,nf)=>{"use strict";var sf=pt(),hP=af(),fP=Lr(),mP=Ae(),bP=mP("species");nf.exports=function(a,e){var t=sf(a).constructor,r;return t===void 0||fP(r=sf(t)[bP])?e:hP(r)}});var uf=b((LM,of)=>{"use strict";var gP=ve();of.exports=gP([].slice)});var cf=b((MM,lf)=>{"use strict";var vP=TypeError;lf.exports=function(a,e){if(a<e)throw new vP("Not enough arguments");return a}});var Vo=b((CM,df)=>{"use strict";var SP=lr();df.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(SP)});var Qo=b((DM,yf)=>{"use strict";var qe=he(),yP=wn(),TP=Or(),pf=pe(),IP=at(),Sf=Pe(),hf=bo(),EP=uf(),ff=ns(),xP=cf(),PP=Vo(),AP=Ps(),Ho=qe.setImmediate,jo=qe.clearImmediate,wP=qe.process,_o=qe.Dispatch,kP=qe.Function,mf=qe.MessageChannel,RP=qe.String,No=0,Di={},bf="onreadystatechange",Oi,hr,Fo,qo;Sf(function(){Oi=qe.location});var Go=function(a){if(IP(Di,a)){var e=Di[a];delete Di[a],e()}},Uo=function(a){return function(){Go(a)}},gf=function(a){Go(a.data)},vf=function(a){qe.postMessage(RP(a),Oi.protocol+"//"+Oi.host)};(!Ho||!jo)&&(Ho=function(e){xP(arguments.length,1);var t=pf(e)?e:kP(e),r=EP(arguments,1);return Di[++No]=function(){yP(t,void 0,r)},hr(No),No},jo=function(e){delete Di[e]},AP?hr=function(a){wP.nextTick(Uo(a))}:_o&&_o.now?hr=function(a){_o.now(Uo(a))}:mf&&!PP?(Fo=new mf,qo=Fo.port2,Fo.port1.onmessage=gf,hr=TP(qo.postMessage,qo)):qe.addEventListener&&pf(qe.postMessage)&&!qe.importScripts&&Oi&&Oi.protocol!=="file:"&&!Sf(vf)?(hr=vf,qe.addEventListener("message",gf,!1)):bf in ff("script")?hr=function(a){hf.appendChild(ff("script"))[bf]=function(){hf.removeChild(this),Go(a)}}:hr=function(a){setTimeout(Uo(a),0)});yf.exports={set:Ho,clear:jo}});var Ef=b((OM,If)=>{"use strict";var Tf=he(),$P=_e(),LP=Object.getOwnPropertyDescriptor;If.exports=function(a){if(!$P)return Tf[a];var e=LP(Tf,a);return e&&e.value}});var Wo=b((BM,Pf)=>{"use strict";var xf=function(){this.head=null,this.tail=null};xf.prototype={add:function(a){var e={item:a,next:null},t=this.tail;t?t.next=e:this.head=e,this.tail=e},get:function(){var a=this.head;if(a){var e=this.head=a.next;return e===null&&(this.tail=null),a.item}}};Pf.exports=xf});var wf=b((VM,Af)=>{"use strict";var MP=lr();Af.exports=/ipad|iphone|ipod/i.test(MP)&&typeof Pebble!="undefined"});var Rf=b((_M,kf)=>{"use strict";var CP=lr();kf.exports=/web0s(?!.*chrome)/i.test(CP)});var Bf=b((NM,Of)=>{"use strict";var Hr=he(),DP=Ef(),$f=Or(),Yo=Qo().set,OP=Wo(),BP=Vo(),VP=wf(),_P=Rf(),zo=Ps(),Lf=Hr.MutationObserver||Hr.WebKitMutationObserver,Mf=Hr.document,Cf=Hr.process,As=Hr.Promise,Xo=DP("queueMicrotask"),Ur,Ko,Jo,ws,Df;Xo||(Bi=new OP,Vi=function(){var a,e;for(zo&&(a=Cf.domain)&&a.exit();e=Bi.get();)try{e()}catch(t){throw Bi.head&&Ur(),t}a&&a.enter()},!BP&&!zo&&!_P&&Lf&&Mf?(Ko=!0,Jo=Mf.createTextNode(""),new Lf(Vi).observe(Jo,{characterData:!0}),Ur=function(){Jo.data=Ko=!Ko}):!VP&&As&&As.resolve?(ws=As.resolve(void 0),ws.constructor=As,Df=$f(ws.then,ws),Ur=function(){Df(Vi)}):zo?Ur=function(){Cf.nextTick(Vi)}:(Yo=$f(Yo,Hr),Ur=function(){Yo(Vi)}),Xo=function(a){Bi.head||Ur(),Bi.add(a)});var Bi,Vi;Of.exports=Xo});var _f=b((FM,Vf)=>{"use strict";Vf.exports=function(a,e){try{arguments.length===1?console.error(a):console.error(a,e)}catch(t){}}});var ks=b((qM,Nf)=>{"use strict";Nf.exports=function(a){try{return{error:!1,value:a()}}catch(e){return{error:!0,value:e}}}});var fr=b((UM,Ff)=>{"use strict";var NP=he();Ff.exports=NP.Promise});var jr=b((HM,jf)=>{"use strict";var FP=he(),_i=fr(),qP=pe(),UP=zn(),HP=Co(),jP=Ae(),qf=Lo(),GP=it(),Zo=Bn(),Uf=_i&&_i.prototype,QP=jP("species"),eu=!1,Hf=qP(FP.PromiseRejectionEvent),WP=UP("Promise",function(){var a=HP(_i),e=a!==String(_i);if(!e&&Zo===66||GP&&!(Uf.catch&&Uf.finally))return!0;if(!Zo||Zo<51||!/native code/.test(a)){var t=new _i(function(s){s(1)}),r=function(s){s(function(){},function(){})},i=t.constructor={};if(i[QP]=r,eu=t.then(function(){})instanceof r,!eu)return!0}return!e&&(qf==="BROWSER"||qf==="DENO")&&!Hf});jf.exports={CONSTRUCTOR:WP,REJECTION_EVENT:Hf,SUBCLASSING:eu}});var Gr=b((jM,Qf)=>{"use strict";var Gf=dt(),YP=TypeError,zP=function(a){var e,t;this.promise=new a(function(r,i){if(e!==void 0||t!==void 0)throw new YP("Bad Promise constructor");e=r,t=i}),this.resolve=Gf(e),this.reject=Gf(t)};Qf.exports.f=function(a){return new zP(a)}});var dm=b(()=>{"use strict";var KP=fe(),JP=it(),Ms=Ps(),Qt=he(),zr=Ne(),Wf=qr(),Yf=Po(),XP=Ri(),ZP=Wh(),eA=dt(),Ls=pe(),tA=Fe(),rA=zh(),iA=Bo(),Zf=Qo().set,su=Bf(),aA=_f(),sA=ks(),nA=Wo(),em=po(),Cs=fr(),nu=jr(),tm=Gr(),Ds="Promise",rm=nu.CONSTRUCTOR,oA=nu.REJECTION_EVENT,uA=nu.SUBCLASSING,tu=em.getterFor(Ds),lA=em.set,Qr=Cs&&Cs.prototype,mr=Cs,Rs=Qr,im=Qt.TypeError,ru=Qt.document,ou=Qt.process,iu=tm.f,cA=iu,dA=!!(ru&&ru.createEvent&&Qt.dispatchEvent),am="unhandledrejection",pA="rejectionhandled",zf=0,sm=1,hA=2,uu=1,nm=2,$s,Kf,fA,Jf,om=function(a){var e;return tA(a)&&Ls(e=a.then)?e:!1},um=function(a,e){var t=e.value,r=e.state===sm,i=r?a.ok:a.fail,s=a.resolve,n=a.reject,o=a.domain,u,l,d;try{i?(r||(e.rejection===nm&&bA(e),e.rejection=uu),i===!0?u=t:(o&&o.enter(),u=i(t),o&&(o.exit(),d=!0)),u===a.promise?n(new im("Promise-chain cycle")):(l=om(u))?zr(l,u,s,n):s(u)):n(t)}catch(c){o&&!d&&o.exit(),n(c)}},lm=function(a,e){a.notified||(a.notified=!0,su(function(){for(var t=a.reactions,r;r=t.get();)um(r,a);a.notified=!1,e&&!a.rejection&&mA(a)}))},cm=function(a,e,t){var r,i;dA?(r=ru.createEvent("Event"),r.promise=e,r.reason=t,r.initEvent(a,!1,!0),Qt.dispatchEvent(r)):r={promise:e,reason:t},!oA&&(i=Qt["on"+a])?i(r):a===am&&aA("Unhandled promise rejection",t)},mA=function(a){zr(Zf,Qt,function(){var e=a.facade,t=a.value,r=Xf(a),i;if(r&&(i=sA(function(){Ms?ou.emit("unhandledRejection",t,e):cm(am,e,t)}),a.rejection=Ms||Xf(a)?nm:uu,i.error))throw i.value})},Xf=function(a){return a.rejection!==uu&&!a.parent},bA=function(a){zr(Zf,Qt,function(){var e=a.facade;Ms?ou.emit("rejectionHandled",e):cm(pA,e,a.value)})},Wr=function(a,e,t){return function(r){a(e,r,t)}},Yr=function(a,e,t){a.done||(a.done=!0,t&&(a=t),a.value=e,a.state=hA,lm(a,!0))},au=function(a,e,t){if(!a.done){a.done=!0,t&&(a=t);try{if(a.facade===e)throw new im("Promise can't be resolved itself");var r=om(e);r?su(function(){var i={done:!1};try{zr(r,e,Wr(au,i,a),Wr(Yr,i,a))}catch(s){Yr(i,s,a)}}):(a.value=e,a.state=sm,lm(a,!1))}catch(i){Yr({done:!1},i,a)}}};if(rm&&(mr=function(e){rA(this,Rs),eA(e),zr($s,this);var t=tu(this);try{e(Wr(au,t),Wr(Yr,t))}catch(r){Yr(t,r)}},Rs=mr.prototype,$s=function(e){lA(this,{type:Ds,done:!1,notified:!1,parent:!1,reactions:new nA,rejection:!1,state:zf,value:void 0})},$s.prototype=Wf(Rs,"then",function(e,t){var r=tu(this),i=iu(iA(this,mr));return r.parent=!0,i.ok=Ls(e)?e:!0,i.fail=Ls(t)&&t,i.domain=Ms?ou.domain:void 0,r.state===zf?r.reactions.add(i):su(function(){um(i,r)}),i.promise}),Kf=function(){var a=new $s,e=tu(a);this.promise=a,this.resolve=Wr(au,e),this.reject=Wr(Yr,e)},tm.f=iu=function(a){return a===mr||a===fA?new Kf(a):cA(a)},!JP&&Ls(Cs)&&Qr!==Object.prototype)){Jf=Qr.then,uA||Wf(Qr,"then",function(e,t){var r=this;return new mr(function(i,s){zr(Jf,r,i,s)}).then(e,t)},{unsafe:!0});try{delete Qr.constructor}catch(a){}Yf&&Yf(Qr,Rs)}KP({global:!0,constructor:!0,wrap:!0,forced:rm},{Promise:mr});XP(mr,Ds,!1,!0);ZP(Ds)});var bm=b((WM,mm)=>{"use strict";var gA=Ae(),hm=gA("iterator"),fm=!1;try{pm=0,lu={next:function(){return{done:!!pm++}},return:function(){fm=!0}},lu[hm]=function(){return this},Array.from(lu,function(){throw 2})}catch(a){}var pm,lu;mm.exports=function(a,e){try{if(!e&&!fm)return!1}catch(i){return!1}var t=!1;try{var r={};r[hm]=function(){return{next:function(){return{done:t=!0}}}},a(r)}catch(i){}return t}});var cu=b((YM,gm)=>{"use strict";var vA=fr(),SA=bm(),yA=jr().CONSTRUCTOR;gm.exports=yA||!SA(function(a){vA.all(a).then(void 0,function(){})})});var vm=b(()=>{"use strict";var TA=fe(),IA=Ne(),EA=dt(),xA=Gr(),PA=ks(),AA=Is(),wA=cu();TA({target:"Promise",stat:!0,forced:wA},{all:function(e){var t=this,r=xA.f(t),i=r.resolve,s=r.reject,n=PA(function(){var o=EA(t.resolve),u=[],l=0,d=1;AA(e,function(c){var p=l++,h=!1;d++,IA(o,t,c).then(function(m){h||(h=!0,u[p]=m,--d||i(u))},s)}),--d||i(u)});return n.error&&s(n.value),r.promise}})});var ym=b(()=>{"use strict";var kA=fe(),RA=it(),$A=jr().CONSTRUCTOR,pu=fr(),LA=It(),MA=pe(),CA=qr(),Sm=pu&&pu.prototype;kA({target:"Promise",proto:!0,forced:$A,real:!0},{catch:function(a){return this.then(void 0,a)}});!RA&&MA(pu)&&(du=LA("Promise").prototype.catch,Sm.catch!==du&&CA(Sm,"catch",du,{unsafe:!0}));var du});var Tm=b(()=>{"use strict";var DA=fe(),OA=Ne(),BA=dt(),VA=Gr(),_A=ks(),NA=Is(),FA=cu();DA({target:"Promise",stat:!0,forced:FA},{race:function(e){var t=this,r=VA.f(t),i=r.reject,s=_A(function(){var n=BA(t.resolve);NA(e,function(o){OA(n,t,o).then(r.resolve,i)})});return s.error&&i(s.value),r.promise}})});var Im=b(()=>{"use strict";var qA=fe(),UA=Gr(),HA=jr().CONSTRUCTOR;qA({target:"Promise",stat:!0,forced:HA},{reject:function(e){var t=UA.f(this),r=t.reject;return r(e),t.promise}})});var hu=b((iC,Em)=>{"use strict";var jA=pt(),GA=Fe(),QA=Gr();Em.exports=function(a,e){if(jA(a),GA(e)&&e.constructor===a)return e;var t=QA.f(a),r=t.resolve;return r(e),t.promise}});var Am=b(()=>{"use strict";var WA=fe(),YA=It(),xm=it(),zA=fr(),Pm=jr().CONSTRUCTOR,KA=hu(),JA=YA("Promise"),XA=xm&&!Pm;WA({target:"Promise",stat:!0,forced:xm||Pm},{resolve:function(e){return KA(XA&&this===JA?zA:this,e)}})});var wm=b(()=>{"use strict";dm();vm();ym();Tm();Im();Am()});var Lm=b(()=>{"use strict";var ZA=fe(),ew=it(),Os=fr(),tw=Pe(),Rm=It(),$m=pe(),rw=Bo(),km=hu(),iw=qr(),mu=Os&&Os.prototype,aw=!!Os&&tw(function(){mu.finally.call({then:function(){}},function(){})});ZA({target:"Promise",proto:!0,real:!0,forced:aw},{finally:function(a){var e=rw(this,Rm("Promise")),t=$m(a);return this.then(t?function(r){return km(e,a()).then(function(){return r})}:a,t?function(r){return km(e,a()).then(function(){throw r})}:a)}});!ew&&$m(Os)&&(fu=Rm("Promise").prototype.finally,mu.finally!==fu&&iw(mu,"finally",fu,{unsafe:!0}));var fu});var Cm=b((cC,Mm)=>{"use strict";Fh();wm();Lm();var sw=Gt();Mm.exports=sw("Promise","finally")});var Om=b((dC,Dm)=>{"use strict";var nw=Cm();Dm.exports=nw});var Bs=b((pC,Bm)=>{"use strict";var ow=Om();Bm.exports=ow});var Hm=b(()=>{"use strict";var pw=fe(),hw=oo().values;pw({target:"Object",stat:!0},{values:function(e){return hw(e)}})});var Gm=b((HC,jm)=>{"use strict";Hm();var fw=Mr();jm.exports=fw.Object.values});var Wm=b((jC,Qm)=>{"use strict";var mw=Gm();Qm.exports=mw});var Fi=b((GC,Ym)=>{"use strict";var bw=Wm();Ym.exports=bw});var Xm=b(()=>{"use strict";var yw=fe(),Tw=Cr(),Iw=Nr(),Ew=Pi(),xw=Ai();yw({target:"Array",proto:!0},{at:function(e){var t=Tw(this),r=Iw(t),i=Ew(e),s=i>=0?i:r+i;return s<0||s>=r?void 0:t[s]}});xw("at")});var eb=b((m0,Zm)=>{"use strict";Xm();var Pw=Gt();Zm.exports=Pw("Array","at")});var rb=b((b0,tb)=>{"use strict";var Aw=eb();tb.exports=Aw});var Kr=b((g0,ib)=>{"use strict";var ww=rb();ib.exports=ww});var Mu=b((_D,Eb)=>{"use strict";var _w=or();Eb.exports=Array.isArray||function(e){return _w(e)==="Array"}});var Pb=b((ND,xb)=>{"use strict";var Nw=TypeError,Fw=9007199254740991;xb.exports=function(a){if(a>Fw)throw Nw("Maximum allowed index exceeded");return a}});var kb=b((FD,wb)=>{"use strict";var qw=Mu(),Uw=Nr(),Hw=Pb(),jw=Or(),Ab=function(a,e,t,r,i,s,n,o){for(var u=i,l=0,d=n?jw(n,o):!1,c,p;l<r;)l in t&&(c=d?d(t[l],l,e):t[l],s>0&&qw(c)?(p=Uw(c),u=Ab(a,e,c,p,u,s-1)-1):(Hw(u+1),a[u]=c),u++),l++;return u};wb.exports=Ab});var Mb=b((qD,Lb)=>{"use strict";var Rb=Mu(),Gw=Oo(),Qw=Fe(),Ww=Ae(),Yw=Ww("species"),$b=Array;Lb.exports=function(a){var e;return Rb(a)&&(e=a.constructor,Gw(e)&&(e===$b||Rb(e.prototype))?e=void 0:Qw(e)&&(e=e[Yw],e===null&&(e=void 0))),e===void 0?$b:e}});var Db=b((UD,Cb)=>{"use strict";var zw=Mb();Cb.exports=function(a,e){return new(zw(a))(e===0?0:e)}});var Ob=b(()=>{"use strict";var Kw=fe(),Jw=kb(),Xw=dt(),Zw=Cr(),ek=Nr(),tk=Db();Kw({target:"Array",proto:!0},{flatMap:function(e){var t=Zw(this),r=ek(t),i;return Xw(e),i=tk(t,0),i.length=Jw(i,t,t,r,0,1,e,arguments.length>1?arguments[1]:void 0),i}})});var Bb=b(()=>{"use strict";var rk=Ai();rk("flatMap")});var _b=b((WD,Vb)=>{"use strict";Ob();Bb();var ik=Gt();Vb.exports=ik("Array","flatMap")});var Fb=b((YD,Nb)=>{"use strict";var ak=_b();Nb.exports=ak});var Cu=b((zD,qb)=>{"use strict";var sk=Fb();qb.exports=sk});var Ji=b((sO,og)=>{"use strict";var hk=ki(),fk=String;og.exports=function(a){if(hk(a)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return fk(a)}});var Ou=b((nO,ug)=>{"use strict";ug.exports=`
7
+ \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF`});var dg=b((oO,cg)=>{"use strict";var mk=ve(),bk=jt(),gk=Ji(),Vu=Ou(),lg=mk("".replace),vk=RegExp("^["+Vu+"]+"),Sk=RegExp("(^|[^"+Vu+"])["+Vu+"]+$"),Bu=function(a){return function(e){var t=gk(bk(e));return a&1&&(t=lg(t,vk,"")),a&2&&(t=lg(t,Sk,"$1")),t}};cg.exports={start:Bu(1),end:Bu(2),trim:Bu(3)}});var mg=b((uO,fg)=>{"use strict";var yk=mo().PROPER,Tk=Pe(),pg=Ou(),hg="\u200B\x85\u180E";fg.exports=function(a){return Tk(function(){return!!pg[a]()||hg[a]()!==hg||yk&&pg[a].name!==a})}});var _u=b((lO,bg)=>{"use strict";var Ik=dg().start,Ek=mg();bg.exports=Ek("trimStart")?function(){return Ik(this)}:"".trimStart});var vg=b(()=>{"use strict";var xk=fe(),gg=_u();xk({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==gg},{trimLeft:gg})});var yg=b(()=>{"use strict";vg();var Pk=fe(),Sg=_u();Pk({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==Sg},{trimStart:Sg})});var Ig=b((fO,Tg)=>{"use strict";yg();var Ak=Gt();Tg.exports=Ak("String","trimLeft")});var xg=b((mO,Eg)=>{"use strict";var wk=Ig();Eg.exports=wk});var Ag=b((bO,Pg)=>{"use strict";var kk=xg();Pg.exports=kk});var Fg=b(()=>{"use strict"});var qg=b(()=>{"use strict"});var Hg=b((NV,Ug)=>{"use strict";var Yk=Fe(),zk=or(),Kk=Ae(),Jk=Kk("match");Ug.exports=function(a){var e;return Yk(a)&&((e=a[Jk])!==void 0?!!e:zk(a)==="RegExp")}});var Gg=b((FV,jg)=>{"use strict";var Xk=pt();jg.exports=function(){var a=Xk(this),e="";return a.hasIndices&&(e+="d"),a.global&&(e+="g"),a.ignoreCase&&(e+="i"),a.multiline&&(e+="m"),a.dotAll&&(e+="s"),a.unicode&&(e+="u"),a.unicodeSets&&(e+="v"),a.sticky&&(e+="y"),e}});var Yg=b((qV,Wg)=>{"use strict";var Zk=Ne(),eR=at(),tR=Si(),rR=Gg(),Qg=RegExp.prototype;Wg.exports=function(a){var e=a.flags;return e===void 0&&!("flags"in Qg)&&!eR(a,"flags")&&tR(Qg,a)?Zk(rR,a):e}});var Kg=b((UV,zg)=>{"use strict";var Gu=ve(),iR=Cr(),aR=Math.floor,Hu=Gu("".charAt),sR=Gu("".replace),ju=Gu("".slice),nR=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,oR=/\$([$&'`]|\d{1,2})/g;zg.exports=function(a,e,t,r,i,s){var n=t+a.length,o=r.length,u=oR;return i!==void 0&&(i=iR(i),u=nR),sR(s,u,function(l,d){var c;switch(Hu(d,0)){case"$":return"$";case"&":return a;case"`":return ju(e,0,t);case"'":return ju(e,n);case"<":c=i[ju(d,1,-1)];break;default:var p=+d;if(p===0)return l;if(p>o){var h=aR(p/10);return h===0?l:h<=o?r[h-1]===void 0?Hu(d,1):r[h-1]+Hu(d,1):l}c=r[p-1]}return c===void 0?"":c})}});var Zg=b(()=>{"use strict";var uR=fe(),lR=Ne(),Wu=ve(),Jg=jt(),cR=pe(),dR=Lr(),pR=Hg(),ii=Ji(),hR=Ti(),fR=Yg(),mR=Kg(),bR=Ae(),gR=it(),vR=bR("replace"),SR=TypeError,Qu=Wu("".indexOf),yR=Wu("".replace),Xg=Wu("".slice),TR=Math.max;uR({target:"String",proto:!0},{replaceAll:function(e,t){var r=Jg(this),i,s,n,o,u,l,d,c,p,h,m=0,g="";if(!dR(e)){if(i=pR(e),i&&(s=ii(Jg(fR(e))),!~Qu(s,"g")))throw new SR("`.replaceAll` does not allow non-global regexes");if(n=hR(e,vR),n)return lR(n,e,r,t);if(gR&&i)return yR(ii(r),e,t)}for(o=ii(r),u=ii(e),l=cR(t),l||(t=ii(t)),d=u.length,c=TR(1,d),p=Qu(o,u);p!==-1;)h=l?ii(t(u,p,o)):mR(u,o,p,[],void 0,t),g+=Xg(o,m,p)+h,m=p+d,p=p+c>o.length?-1:Qu(o,u,p+c);return m<o.length&&(g+=Xg(o,m)),g}})});var tv=b((GV,ev)=>{"use strict";Fg();qg();Zg();var IR=Gt();ev.exports=IR("String","replaceAll")});var iv=b((QV,rv)=>{"use strict";var ER=tv();rv.exports=ER});var sv=b((WV,av)=>{"use strict";var xR=iv();av.exports=xR});var ov=b((YV,nv)=>{"use strict";var PR=Pi(),AR=Ji(),wR=jt(),kR=RangeError;nv.exports=function(e){var t=AR(wR(this)),r="",i=PR(e);if(i<0||i===1/0)throw new kR("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))i&1&&(r+=t);return r}});var pv=b((zV,dv)=>{"use strict";var cv=ve(),RR=to(),uv=Ji(),$R=ov(),LR=jt(),MR=cv($R),CR=cv("".slice),DR=Math.ceil,lv=function(a){return function(e,t,r){var i=uv(LR(e)),s=RR(t),n=i.length,o=r===void 0?" ":uv(r),u,l;return s<=n||o===""?i:(u=s-n,l=MR(o,DR(u/o.length)),l.length>u&&(l=CR(l,0,u)),a?i+l:l+i)}};dv.exports={start:lv(!1),end:lv(!0)}});var fv=b((KV,hv)=>{"use strict";var OR=lr();hv.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(OR)});var mv=b(()=>{"use strict";var BR=fe(),VR=pv().start,_R=fv();BR({target:"String",proto:!0,forced:_R},{padStart:function(e){return VR(this,e,arguments.length>1?arguments[1]:void 0)}})});var gv=b((ZV,bv)=>{"use strict";mv();var NR=Gt();bv.exports=NR("String","padStart")});var Sv=b((e_,vv)=>{"use strict";var FR=gv();vv.exports=FR});var Tv=b((t_,yv)=>{"use strict";var qR=Sv();yv.exports=qR});var s$={};LS(s$,{ChromecastState:()=>mi,HttpConnectionType:()=>rs,Observable:()=>St.Observable,PlaybackState:()=>Re,Player:()=>qa,SDK_VERSION:()=>a$,Subject:()=>St.Subject,Subscription:()=>St.Subscription,Surface:()=>is,VERSION:()=>Pn,ValueSubject:()=>St.ValueSubject,VideoFormat:()=>Tt,VideoQuality:()=>St.VideoQuality});module.exports=MS(s$);var Pn="2.0.119-dev.dc40b896.0";var Re=(i=>(i.STOPPED="stopped",i.READY="ready",i.PLAYING="playing",i.PAUSED="paused",i))(Re||{}),Tt=(x=>(x.MPEG="MPEG",x.DASH="DASH",x.DASH_SEP="DASH_SEP",x.DASH_SEP_VK="DASH_SEP",x.DASH_WEBM="DASH_WEBM",x.DASH_WEBM_AV1="DASH_WEBM_AV1",x.DASH_STREAMS="DASH_STREAMS",x.DASH_WEBM_VK="DASH_WEBM",x.DASH_ONDEMAND="DASH_ONDEMAND",x.DASH_ONDEMAND_VK="DASH_ONDEMAND",x.DASH_LIVE="DASH_LIVE",x.DASH_LIVE_CMAF="DASH_LIVE_CMAF",x.DASH_LIVE_WEBM="DASH_LIVE_WEBM",x.HLS="HLS",x.HLS_ONDEMAND="HLS_ONDEMAND",x.HLS_JS="HLS",x.HLS_LIVE="HLS_LIVE",x.HLS_LIVE_CMAF="HLS_LIVE_CMAF",x.WEB_RTC_LIVE="WEB_RTC_LIVE",x))(Tt||{});var mi=(i=>(i.NOT_AVAILABLE="NOT_AVAILABLE",i.AVAILABLE="AVAILABLE",i.CONNECTING="CONNECTING",i.CONNECTED="CONNECTED",i))(mi||{}),rs=(r=>(r.HTTP1="http1",r.HTTP2="http2",r.QUIC="quic",r))(rs||{});var is=(n=>(n.NONE="none",n.INLINE="inline",n.FULLSCREEN="fullscreen",n.SECOND_SCREEN="second_screen",n.PIP="pip",n.INVISIBLE="invisible",n))(is||{});var pS=X(ht(),1);var q=require("@vkontakte/videoplayer-shared/es2015");var Ud=a=>new Promise((e,t)=>{let r=document.createElement("script");r.setAttribute("src",a),r.onload=()=>e,r.onerror=()=>t,document.body.appendChild(r)});var us=class{constructor(e){this.connection$=new q.ValueSubject(void 0);this.castState$=new q.ValueSubject("NOT_AVAILABLE");this.errorEvent$=new q.Subject;this.realCastState$=new q.ValueSubject("NOT_AVAILABLE");this.subscription=new q.Subscription;var s;this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastInitializer");let t="chrome"in window;if(this.log({message:`[constructor] receiverApplicationId: ${this.params.receiverApplicationId}, isDisabled: ${this.params.isDisabled}, isSupported: ${t}`}),e.isDisabled||!t)return;let r=(0,q.isNonNullable)((s=window.chrome)==null?void 0:s.cast),i=!!window.__onGCastApiAvailable;r?this.initializeCastApi():(window.__onGCastApiAvailable=n=>{delete window.__onGCastApiAvailable,n&&this.initializeCastApi()},i||Ud("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1").catch(()=>this.errorEvent$.next({id:"ChromecastLoading",category:q.ErrorCategory.NETWORK,message:"Script loading failed!"})))}connect(){var e;(e=cast.framework.CastContext.getInstance())==null||e.requestSession()}disconnect(){var e,t;(t=(e=cast.framework.CastContext.getInstance())==null?void 0:e.getCurrentSession())==null||t.endSession(!0)}stopMedia(){return new Promise((e,t)=>{var r,i,s;(s=(i=(r=cast.framework.CastContext.getInstance())==null?void 0:r.getCurrentSession())==null?void 0:i.getMediaSession())==null||s.stop(new chrome.cast.media.StopRequest,e,t)})}toggleConnection(){(0,q.isNonNullable)(this.connection$.getValue())?this.disconnect():this.connect()}setVolume(e){let t=this.connection$.getValue();(0,q.isNullable)(t)||(t.remotePlayer.volumeLevel=e,t.remotePlayerController.setVolumeLevel())}setMuted(e){let t=this.connection$.getValue();(0,q.isNullable)(t)||e!==t.remotePlayer.isMuted&&t.remotePlayerController.muteOrUnmute()}destroy(){this.subscription.unsubscribe()}initListeners(){let e=new cast.framework.RemotePlayer,t=new cast.framework.RemotePlayerController(e),r=cast.framework.CastContext.getInstance();this.subscription.add((0,q.fromEvent)(r,cast.framework.CastContextEventType.SESSION_STATE_CHANGED).subscribe(i=>{var s,n,o;switch(i.sessionState){case cast.framework.SessionState.SESSION_STARTED:case cast.framework.SessionState.SESSION_STARTING:case cast.framework.SessionState.SESSION_RESUMED:this.contentId=(o=(n=(s=r.getCurrentSession())==null?void 0:s.getMediaSession())==null?void 0:n.media)==null?void 0:o.contentId;break;case cast.framework.SessionState.NO_SESSION:case cast.framework.SessionState.SESSION_ENDING:case cast.framework.SessionState.SESSION_ENDED:case cast.framework.SessionState.SESSION_START_FAILED:this.contentId=void 0;break;default:return(0,q.assertNever)(i.sessionState)}})).add((0,q.merge)((0,q.fromEvent)(r,cast.framework.CastContextEventType.CAST_STATE_CHANGED).pipe((0,q.tap)(i=>{this.log({message:`[cast.framework.RemotePlayerEventType.CAST_STATE_CHANGED]: ${JSON.stringify(i)}`})}),(0,q.map)(i=>i.castState)),(0,q.observableFrom)([r.getCastState()])).pipe((0,q.filterChanged)(),(0,q.map)(eI),(0,q.tap)(i=>{this.log({message:`realCastState$: ${i}`})})).subscribe(this.realCastState$)).add(this.realCastState$.subscribe(i=>{var o,u;let s=i==="CONNECTED",n=(0,q.isNonNullable)(this.connection$.getValue());if(s&&!n){let l=r.getCurrentSession();(0,q.assertNonNullable)(l);let d=l.getCastDevice(),c=(u=(o=l.getMediaSession())==null?void 0:o.media)==null?void 0:u.contentId;((0,q.isNullable)(c)||c===this.contentId)&&(this.log({message:"connection created"}),this.connection$.next({remotePlayer:e,remotePlayerController:t,session:l,castDevice:d}))}else!s&&n&&(this.log({message:"connection destroyed"}),this.connection$.next(void 0));this.castState$.next(i==="CONNECTED"?(0,q.isNonNullable)(this.connection$.getValue())?"CONNECTED":"AVAILABLE":i)}))}initializeCastApi(){var i;let e,t,r;try{e=cast.framework.CastContext.getInstance(),t=chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,r=chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}catch(s){return}try{e.setOptions({receiverApplicationId:(i=this.params.receiverApplicationId)!=null?i:t,autoJoinPolicy:r}),this.initListeners()}catch(s){this.errorEvent$.next({id:"ChromecastInitializer",category:q.ErrorCategory.EXTERNAL_API,message:"[initializeCastApi] failed",thrown:s})}}},eI=a=>{switch(a){case cast.framework.CastState.NO_DEVICES_AVAILABLE:return"NOT_AVAILABLE";case cast.framework.CastState.NOT_CONNECTED:return"AVAILABLE";case cast.framework.CastState.CONNECTING:return"CONNECTING";case cast.framework.CastState.CONNECTED:return"CONNECTED";default:return(0,q.assertNever)(a)}};var cl=X(ht(),1),Zv=X(Fr(),1),eS=X($o(),1);var Fm=X(Bs(),1);var bu=require("@vkontakte/videoplayer-shared/es2015");var we=(a,e=0,t=0)=>{switch(t){case 0:return a.replace("_offset_p",e===0?"":"_"+e.toFixed(0));case 1:{if(e===0)return a;let r=new URL(a);return r.searchParams.append("playback_shift",e.toFixed(0)),r.toString()}case 2:{let r=new URL(a);return!r.searchParams.get("offset_p")&&e===0?a:(r.searchParams.set("offset_p",e.toFixed(0)),r.toString())}default:(0,bu.assertNever)(t)}return a},Vs=(a,e)=>{var t;switch(e){case 0:return NaN;case 1:{let r=new URL(a);return Number(r.searchParams.get("playback_shift"))}case 2:{let r=new URL(a);return Number((t=r.searchParams.get("offset_p"))!=null?t:0)}default:(0,bu.assertNever)(e)}};var k=(a,e,t=!1)=>{let r=a.getTransition();(t||!r||r.to===e)&&a.setState(e)};var ft=require("@vkontakte/videoplayer-shared/es2015"),j=class{constructor(e){this.transitionStarted$=new ft.Subject;this.transitionEnded$=new ft.Subject;this.transitionUpdated$=new ft.Subject;this.forceChanged$=new ft.Subject;this.stateChangeStarted$=(0,ft.merge)(this.transitionStarted$,this.transitionUpdated$);this.stateChangeEnded$=(0,ft.merge)(this.transitionEnded$,this.forceChanged$);this.state=e,this.prevState=void 0}setState(e){let t=this.transition,r=this.state;this.transition=void 0,this.prevState=r,this.state=e,t?t.to===e?this.transitionEnded$.next(t):this.forceChanged$.next({from:t.from,to:e,canceledTransition:t}):this.forceChanged$.next({from:r,to:e,canceledTransition:t})}startTransitionTo(e){let t=this.transition,r=this.state;r===e||(0,ft.isNonNullable)(t)&&t.to===e||(this.prevState=r,this.state=e,t?(this.transition={from:t.from,to:e,canceledTransition:t},this.transitionUpdated$.next(this.transition)):(this.transition={from:r,to:e},this.transitionStarted$.next(this.transition)))}getTransition(){return this.transition}getState(){return this.state}getPrevState(){return this.prevState}};var Vm=require("@vkontakte/videoplayer-shared/es2015"),_m=a=>{switch(a){case"MPEG":case"DASH":case"DASH_SEP":case"DASH_ONDEMAND":case"DASH_WEBM":case"DASH_WEBM_AV1":case"DASH_STREAMS":case"HLS":case"HLS_ONDEMAND":return!1;case"DASH_LIVE":case"DASH_LIVE_CMAF":case"HLS_LIVE":case"HLS_LIVE_CMAF":case"DASH_LIVE_WEBM":case"WEB_RTC_LIVE":return!0;default:return(0,Vm.assertNever)(a)}};var L=require("@vkontakte/videoplayer-shared/es2015");var uw=5,lw=5,cw=500,Nm=7e3,Ni=class{constructor(e){this.subscription=new L.Subscription;this.loadMediaTimeoutSubscription=new L.Subscription;this.videoState=new j("stopped");this.syncPlayback=()=>{let e=this.videoState.getState(),t=this.videoState.getTransition(),r=this.params.desiredState.playbackState.getState(),i=this.params.desiredState.playbackState.getTransition(),s=this.params.desiredState.seekState.getState();if(this.log({message:`[syncPlayback] videoState: ${e}; videoTransition: ${JSON.stringify(t)}; desiredPlaybackState: ${r}; desiredPlaybackStateTransition: ${this.params.desiredState.playbackState.getTransition()}; seekState: ${JSON.stringify(s)};`}),r==="stopped"){e!=="stopped"&&(this.videoState.startTransitionTo("stopped"),this.stop());return}if(!t){if((i==null?void 0:i.to)!=="paused"&&s.state==="requested"&&e!=="stopped"){this.seek(s.position/1e3);return}switch(r){case"ready":{switch(e){case"playing":case"paused":case"ready":break;case"stopped":this.videoState.startTransitionTo("ready"),this.prepare();break;default:(0,L.assertNever)(e)}break}case"playing":{switch(e){case"playing":break;case"paused":this.videoState.startTransitionTo("playing"),this.params.connection.remotePlayerController.playOrPause();break;case"ready":this.videoState.startTransitionTo("playing"),this.params.connection.remotePlayerController.playOrPause();break;case"stopped":this.videoState.startTransitionTo("ready"),this.prepare();break;default:(0,L.assertNever)(e)}break}case"paused":{switch(e){case"playing":this.videoState.startTransitionTo("paused"),this.params.connection.remotePlayerController.playOrPause();break;case"paused":break;case"ready":this.videoState.startTransitionTo("paused"),this.videoState.setState("paused");break;case"stopped":this.videoState.startTransitionTo("ready"),this.prepare();break;default:(0,L.assertNever)(e)}break}default:(0,L.assertNever)(r)}}};this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ChromecastProvider"),this.log({message:`constructor, format: ${e.format}`}),this.params.output.isLive$.next(_m(e.format)),this.params.output.isAudioAvailable$.next(!0),this.handleRemoteVolumeChange({volume:this.params.connection.remotePlayer.volumeLevel,muted:this.params.connection.remotePlayer.isMuted});let t=this.params.connection.session.getMediaSession();t&&this.restoreSession(t),this.subscribe()}destroy(){this.log({message:"[destroy]"}),this.subscription.unsubscribe()}subscribe(){this.subscription.add(this.loadMediaTimeoutSubscription);let e=new L.Subscription;this.subscription.add(e),this.subscription.add((0,L.merge)(this.videoState.stateChangeStarted$.pipe((0,L.map)(i=>`stateChangeStarted$ ${JSON.stringify(i)}`)),this.videoState.stateChangeEnded$.pipe((0,L.map)(i=>`stateChangeEnded$ ${JSON.stringify(i)}`))).subscribe(i=>this.log({message:`[videoState] ${i}`})));let t=(i,s)=>this.subscription.add(i.subscribe(s));if(this.params.output.isLive$.getValue())this.params.output.position$.next(0),this.params.output.duration$.next(0);else{let i=new L.Subject;e.add(i.pipe((0,L.debounce)(cw)).subscribe(()=>{this.params.output.seekedEvent$.next()}));let s=NaN;e.add((0,L.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED).subscribe(n=>{this.logRemoteEvent(n);let o=n.value;this.params.output.position$.next(o),(this.params.desiredState.seekState.getState().state==="applying"||Math.abs(o-s)>uw)&&i.next(o),s=o})),e.add((0,L.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.DURATION_CHANGED).subscribe(n=>{this.logRemoteEvent(n),this.params.output.duration$.next(n.value)}))}t((0,L.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED),i=>{this.logRemoteEvent(i),i.value?this.handleRemoteReady():(this.handleRemoteStop(),e.unsubscribe())}),t((0,L.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED),i=>{this.logRemoteEvent(i),i.value?this.handleRemotePause():this.handleRemotePlay()}),t((0,L.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED),i=>{this.logRemoteEvent(i);let{remotePlayer:s}=this.params.connection,n=i.value,o=this.params.output.isBuffering$.getValue(),u=n===chrome.cast.media.PlayerState.BUFFERING;switch(o!==u&&this.params.output.isBuffering$.next(u),n){case chrome.cast.media.PlayerState.IDLE:!this.params.output.isLive$.getValue()&&s.duration-s.currentTime<lw&&this.params.output.endedEvent$.next(),this.handleRemoteStop(),k(this.params.desiredState.playbackState,"stopped");break;case chrome.cast.media.PlayerState.PAUSED:{this.handleRemotePause();break}case chrome.cast.media.PlayerState.PLAYING:this.handleRemotePlay();break;case chrome.cast.media.PlayerState.BUFFERING:break;default:(0,L.assertNever)(n)}}),t((0,L.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED),i=>{this.logRemoteEvent(i),this.handleRemoteVolumeChange({volume:i.value})}),t((0,L.fromEvent)(this.params.connection.remotePlayerController,cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED),i=>{this.logRemoteEvent(i),this.handleRemoteVolumeChange({muted:i.value})});let r=(0,L.merge)(this.params.desiredState.playbackState.stateChangeStarted$,this.params.desiredState.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,(0,L.observableFrom)(["init"])).pipe((0,L.debounce)(0));t(r,this.syncPlayback)}restoreSession(e){this.log({message:"restoreSession"});let{remotePlayer:t}=this.params.connection;if(e.playerState!==chrome.cast.media.PlayerState.IDLE){t.isPaused?(this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused")):(this.videoState.setState("playing"),k(this.params.desiredState.playbackState,"playing"));let r=this.params.output.isLive$.getValue();this.params.output.duration$.next(r?0:t.duration),this.params.output.position$.next(r?0:t.currentTime),this.params.desiredState.seekState.setState({state:"none"})}}prepare(){let e=this.params.format;this.log({message:`[prepare] format: ${e}`});let t=this.createMediaInfo(e),r=this.createLoadRequest(t);this.loadMedia(r)}handleRemotePause(){let e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)==="paused"||e==="playing")&&(this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused"))}handleRemotePlay(){let e=this.videoState.getState(),t=this.videoState.getTransition();((t==null?void 0:t.to)==="playing"||e==="paused")&&(this.videoState.setState("playing"),k(this.params.desiredState.playbackState,"playing"))}handleRemoteReady(){var t;let e=this.videoState.getTransition();(e==null?void 0:e.to)==="ready"&&this.videoState.setState("ready"),((t=this.params.desiredState.playbackState.getTransition())==null?void 0:t.to)==="ready"&&k(this.params.desiredState.playbackState,"ready")}handleRemoteStop(){this.videoState.getState()!=="stopped"&&this.videoState.setState("stopped")}handleRemoteVolumeChange(e){var i,s;let t=this.params.output.volume$.getValue(),r={volume:(i=e.volume)!=null?i:t.volume,muted:(s=e.muted)!=null?s:t.muted};(r.volume!==t.volume||r.muted!==r.muted)&&this.params.output.volume$.next(r)}seek(e){this.params.output.willSeekEvent$.next();let{remotePlayer:t,remotePlayerController:r}=this.params.connection;t.currentTime=e,r.seek()}stop(){let{remotePlayerController:e}=this.params.connection;e.stop()}createMediaInfo(e){var l;let t=this.params.source,r,i,s;switch(e){case"MPEG":{let d=t[e];(0,L.assertNonNullable)(d);let c=(0,L.getHighestQuality)(Object.keys(d));(0,L.assertNonNullable)(c);let p=d[c];(0,L.assertNonNullable)(p),r=p,i="video/mp4",s=chrome.cast.media.StreamType.BUFFERED;break}case"HLS":case"HLS_ONDEMAND":{let d=t[e];(0,L.assertNonNullable)(d),r=d.url,i="application/x-mpegurl",s=chrome.cast.media.StreamType.BUFFERED;break}case"DASH_SEP":case"DASH_ONDEMAND":case"DASH_WEBM":case"DASH_WEBM_AV1":case"DASH_STREAMS":{let d=t[e];(0,L.assertNonNullable)(d),r=d.url,i="application/dash+xml",s=chrome.cast.media.StreamType.BUFFERED;break}case"DASH_LIVE_CMAF":{let d=t[e];(0,L.assertNonNullable)(d),r=d.url,i="application/dash+xml",s=chrome.cast.media.StreamType.LIVE;break}case"HLS_LIVE":case"HLS_LIVE_CMAF":{let d=t[e];(0,L.assertNonNullable)(d),r=we(d.url),i="application/x-mpegurl",s=chrome.cast.media.StreamType.LIVE;break}case"DASH_LIVE":case"WEB_RTC_LIVE":{let d="Unsupported format for Chromecast",c=new Error(d);throw this.params.output.error$.next({id:"ChromecastProvider.createMediaInfo()",category:L.ErrorCategory.VIDEO_PIPELINE,message:d,thrown:c}),c}case"DASH":case"DASH_LIVE_WEBM":throw new Error(`${e} is no longer supported`);default:return(0,L.assertNever)(e)}let n=new chrome.cast.media.MediaInfo((l=this.params.meta.videoId)!=null?l:r,i);n.contentUrl=r,n.streamType=s,n.metadata=new chrome.cast.media.GenericMediaMetadata;let{title:o,subtitle:u}=this.params.meta;return(0,L.isNonNullable)(o)&&(n.metadata.title=o),(0,L.isNonNullable)(u)&&(n.metadata.subtitle=u),n}createLoadRequest(e){let t=new chrome.cast.media.LoadRequest(e);t.autoplay=!1;let r=this.params.desiredState.seekState.getState();return r.state==="applying"||r.state==="requested"?t.currentTime=this.params.output.isLive$.getValue()?0:r.position/1e3:t.currentTime=0,t}loadMedia(e){let t=this.params.connection.session.loadMedia(e),r=new Promise((i,s)=>{this.loadMediaTimeoutSubscription.add((0,L.timeout)(Nm).subscribe(()=>s(`timeout(${Nm})`)))});(0,Fm.default)(Promise.race([t,r]).then(()=>{this.log({message:`[loadMedia] completed, format: ${this.params.format}`}),this.params.desiredState.seekState.getState().state==="applying"&&this.params.output.seekedEvent$.next(),this.handleRemoteReady()},i=>{let s=`[prepare] loadMedia failed, format: ${this.params.format}, reason: ${i}`;this.log({message:s}),this.params.output.error$.next({id:"ChromecastProvider.loadMedia",category:L.ErrorCategory.VIDEO_PIPELINE,message:s,thrown:i})}),()=>{this.loadMediaTimeoutSubscription.unsubscribe()})}logRemoteEvent(e){this.log({message:`[remoteEvent] ${JSON.stringify(e)}`})}};var $u=X(ht(),1);var yu=require("@vkontakte/videoplayer-shared/es2015");var qm=require("@vkontakte/videoplayer-shared/es2015"),Um=a=>{try{a.pause(),a.playbackRate=0,(0,qm.clearVideoElement)(a),a.remove()}catch(e){console.error(e)}};var _s=require("@vkontakte/videoplayer-shared/es2015"),gu=class{constructor(){this.attribute="data-pool-reused"}get(e){return e.hasAttribute(this.attribute)}set(e,t){e.toggleAttribute(this.attribute,t)}delete(e){e.removeAttribute(this.attribute)}},vu=window.WeakMap?new WeakMap:new gu,Su=window.WeakMap?new WeakMap:new Map,dw=(a,e=20)=>{let t=0;return(0,_s.fromEvent)(a,"ratechange").subscribe(r=>{t++,t>=e&&(a.currentTime=a.currentTime,t=0)})},Le=(a,{audioVideoSyncRate:e})=>{let t=a.querySelector("video"),r=!!t;t?(0,yu.clearVideoElement)(t):(t=document.createElement("video"),a.appendChild(t)),vu.set(t,r);let i=new _s.Subscription;return i.add(dw(t,e)),Su.set(t,i),t.setAttribute("crossorigin","anonymous"),t.setAttribute("playsinline","playsinline"),t.controls=!1,t.setAttribute("poster","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),t},Me=a=>{let e=Su.get(a);e==null||e.unsubscribe(),Su.delete(a);let t=vu.get(a);vu.delete(a),t?(0,yu.clearVideoElement)(a):Um(a)};var Tu=X(Fi(),1),M=require("@vkontakte/videoplayer-shared/es2015");var Wt=require("@vkontakte/videoplayer-shared/es2015"),Ns=(a,e,t,{equal:r=(n,o)=>n===o,changed$:i,onError:s}={})=>{let n=a.getState(),o=e(),u=(0,Wt.isNullable)(i),l=new Wt.Subscription;return i&&l.add(i.subscribe(d=>{let c=a.getState();r(d,c)&&a.setState(d)},s)),r(o,n)||(t(n),u&&a.setState(n)),l.add(a.stateChangeStarted$.subscribe(d=>{t(d.to),u&&a.setState(d.to)},s)),l},mt=(a,e,t)=>Ns(e,()=>a.loop,r=>{(0,Wt.isNonNullable)(r)&&(a.loop=r)},{onError:t}),Ce=(a,e,t,r)=>Ns(e,()=>({muted:a.muted,volume:a.volume}),i=>{(0,Wt.isNonNullable)(i)&&(a.muted=i.muted,a.volume=i.volume)},{equal:(i,s)=>i===s||(i==null?void 0:i.muted)===(s==null?void 0:s.muted)&&(i==null?void 0:i.volume)===(s==null?void 0:s.volume),changed$:t,onError:r}),Ye=(a,e,t,r)=>Ns(e,()=>a.playbackRate,i=>{(0,Wt.isNonNullable)(i)&&(a.playbackRate=i)},{changed$:t,onError:r}),Yt=Ns;var gw=a=>["__",a.language,a.label].join("|"),vw=(a,e)=>{if(a.id===e)return!0;let[t,r,i]=e.split("|");return a.language===r&&a.label===i},Iu=class a{constructor(){this.available$=new M.Subject;this.current$=new M.ValueSubject(void 0);this.error$=new M.Subject;this.subscription=new M.Subscription;this.externalTracks=new Map;this.internalTracks=new Map}connect(e,t,r){this.video=e,this.cueSettings=t.textTrackCuesSettings,this.subscribe();let i=s=>{this.error$.next({id:"TextTracksManager",category:M.ErrorCategory.WTF,message:"Generic HtmlVideoTextTrackManager error",thrown:s})};this.subscription.add(this.available$.subscribe(r.availableTextTracks$)),this.subscription.add(this.current$.subscribe(r.currentTextTrack$)),this.subscription.add(this.error$.subscribe(r.error$)),this.subscription.add(Yt(t.internalTextTracks,()=>(0,Tu.default)(this.internalTracks),s=>{(0,M.isNonNullable)(s)&&this.setInternal(s)},{equal:(s,n)=>(0,M.isNonNullable)(s)&&(0,M.isNonNullable)(n)&&s.length===n.length&&s.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe((0,M.map)(s=>s.filter(({type:n})=>n==="internal"))),onError:i})),this.subscription.add(Yt(t.externalTextTracks,()=>(0,Tu.default)(this.externalTracks),s=>{(0,M.isNonNullable)(s)&&this.setExternal(s)},{equal:(s,n)=>(0,M.isNonNullable)(s)&&(0,M.isNonNullable)(n)&&s.length===n.length&&s.every(({id:o},u)=>o===n[u].id),changed$:this.available$.pipe((0,M.map)(s=>s.filter(({type:n})=>n==="external"))),onError:i})),this.subscription.add(Yt(t.currentTextTrack,()=>{if(this.video)return;let s=this.htmlTextTracksAsArray().find(({mode:n})=>n==="showing");return s&&this.htmlTextTrackToITextTrack(s).id},s=>this.select(s),{changed$:this.current$,onError:i})),this.subscription.add(Yt(t.textTrackCuesSettings,()=>({}),()=>{if(this.video)for(let s of this.htmlTextTracksAsArray())this.applyCueSettings(s.cues),this.applyCueSettings(s.activeCues)}))}subscribe(){(0,M.assertNonNullable)(this.video);let{textTracks:e}=this.video;this.subscription.add((0,M.fromEvent)(e,"addtrack").subscribe(()=>{let r=this.current$.getValue();r&&this.select(r)})),this.subscription.add((0,M.merge)((0,M.fromEvent)(e,"addtrack"),(0,M.fromEvent)(e,"removetrack"),(0,M.observableFrom)(["init"])).pipe((0,M.map)(()=>this.htmlTextTracksAsArray().map(r=>this.htmlTextTrackToITextTrack(r))),(0,M.filterChanged)((r,i)=>r.length===i.length&&r.every(({id:s},n)=>s===i[n].id))).subscribe(this.available$)),this.subscription.add((0,M.merge)((0,M.fromEvent)(e,"change"),(0,M.observableFrom)(["init"])).pipe((0,M.map)(()=>this.htmlTextTracksAsArray().find(({mode:r})=>r==="showing")),(0,M.map)(r=>r&&this.htmlTextTrackToITextTrack(r).id),(0,M.filterChanged)()).subscribe(this.current$));let t=r=>{var i,s;return this.applyCueSettings((s=(i=r.target)==null?void 0:i.activeCues)!=null?s:null)};this.subscription.add((0,M.fromEvent)(e,"addtrack").subscribe(r=>{var s,n;(s=r.track)==null||s.addEventListener("cuechange",t);let i=o=>{var l,d,c,p,h;let u=(d=(l=o.target)==null?void 0:l.cues)!=null?d:null;u&&u.length&&(this.applyCueSettings((p=(c=o.target)==null?void 0:c.cues)!=null?p:null),(h=o.target)==null||h.removeEventListener("cuechange",i))};(n=r.track)==null||n.addEventListener("cuechange",i)})),this.subscription.add((0,M.fromEvent)(e,"removetrack").subscribe(r=>{var i;(i=r.track)==null||i.removeEventListener("cuechange",t)}))}applyCueSettings(e){if(!e||!e.length)return;let t=this.cueSettings.getState();for(let r of Array.from(e)){let i=r;(0,M.isNonNullable)(t.align)&&(i.align=t.align),(0,M.isNonNullable)(t.position)&&(i.position=t.position),(0,M.isNonNullable)(t.size)&&(i.size=t.size),(0,M.isNonNullable)(t.line)&&(i.line=t.line)}}htmlTextTracksAsArray(e=!1){(0,M.assertNonNullable)(this.video);let t=[...this.video.textTracks];return e?t:t.filter(a.isHealthyTrack)}htmlTextTrackToITextTrack(e){var o,u,l,d,c;let{language:t,label:r}=e,i=e.id?e.id:gw(e),s=this.externalTracks.has(i),n=(l=s?(o=this.externalTracks.get(i))==null?void 0:o.isAuto:(u=this.internalTracks.get(i))==null?void 0:u.isAuto)!=null?l:i.includes("auto");return s?{id:i,type:"external",isAuto:n,language:t,label:r,url:(d=this.externalTracks.get(i))==null?void 0:d.url}:{id:i,type:"internal",isAuto:n,language:t,label:r,url:(c=this.internalTracks.get(i))==null?void 0:c.url}}static isHealthyTrack(e){return!(e.kind==="metadata"||e.groupId||e.id===""&&e.label===""&&e.language==="")}setExternal(e){this.internalTracks.size>0&&Array.from(this.internalTracks).forEach(([,t])=>this.detach(t)),e.filter(({id:t})=>!this.externalTracks.has(t)).forEach(t=>this.attach(t)),Array.from(this.externalTracks).filter(([t])=>!e.find(r=>r.id===t)).forEach(([,t])=>this.detach(t))}setInternal(e){let t=[...this.externalTracks];e.filter(({id:r,language:i,isAuto:s})=>!this.internalTracks.has(r)&&!t.some(([,n])=>n.language===i&&n.isAuto===s)).forEach(r=>this.attach(r)),Array.from(this.internalTracks).filter(([r])=>!e.find(i=>i.id===r)).forEach(([,r])=>this.detach(r))}select(e){(0,M.assertNonNullable)(this.video);for(let t of this.htmlTextTracksAsArray(!0))t.mode="showing";for(let t of this.htmlTextTracksAsArray(!0))((0,M.isNullable)(e)||!vw(t,e))&&(t.mode="disabled")}destroy(){if(this.subscription.unsubscribe(),this.video)for(let e of Array.from(this.video.getElementsByTagName("track"))){let t=e.getAttribute("id");t&&this.externalTracks.has(t)&&this.video.removeChild(e)}this.externalTracks.clear()}attach(e){(0,M.assertNonNullable)(this.video);let t=document.createElement("track");t.setAttribute("src",e.url),t.setAttribute("id",e.id),e.label&&t.setAttribute("label",e.label),e.language&&t.setAttribute("srclang",e.language),e.type==="external"?this.externalTracks.set(e.id,e):e.type==="internal"&&this.internalTracks.set(e.id,e),this.video.appendChild(t)}detach(e){(0,M.assertNonNullable)(this.video);let t=Array.prototype.find.call(this.video.getElementsByTagName("track"),r=>r.getAttribute("id")===e.id);t&&this.video.removeChild(t),e.type==="external"?this.externalTracks.delete(e.id):e.type==="internal"&&this.internalTracks.delete(e.id)}},ze=Iu;var Pt=class{constructor(){this.pausedTime=0;this.streamOffset=0;this.pauseTimestamp=0}getTotalPausedTime(){return this.pausedTime+this.getCurrentPausedTime()}getCurrentPausedTime(){return this.pauseTimestamp>0?Date.now()-this.pauseTimestamp:0}getStreamOffset(){return this.streamOffset}getTotalOffset(){return this.getTotalPausedTime()+this.streamOffset}pause(){this.pauseTimestamp===0&&(this.pauseTimestamp=Date.now())}resume(){this.pauseTimestamp>0&&(this.pausedTime+=this.getCurrentPausedTime(),this.pauseTimestamp=0)}resetTo(e,t=!1){this.streamOffset=e,this.pauseTimestamp=0,this.pausedTime=0,t&&this.pause()}};var zm=a=>{let e=a;for(;!(e instanceof Document)&&!(e instanceof ShadowRoot)&&e!==null;)e=e==null?void 0:e.parentNode;return e!=null?e:void 0},Eu=a=>{let e=zm(a);return!!(e&&e.fullscreenElement&&e.fullscreenElement===a)},Km=a=>{let e=zm(a);return!!(e&&e.pictureInPictureElement&&e.pictureInPictureElement===a)};var D=require("@vkontakte/videoplayer-shared/es2015");var Sw=3,Jm=(a,e,t=Sw)=>{let r=0,i=0;for(let s=0;s<a.length;s++){let n=a.start(s),o=a.end(s);if(n<=e&&e<=o){if(r=n,i=o,!t)return{from:r,to:i};for(let u=s-1;u>=0;u--)a.end(u)+t>=r&&(r=a.start(u));for(let u=s+1;u<a.length;u++)a.start(u)-t<=i&&(i=a.end(u))}}return{from:r,to:i}};var De=a=>{let e=x=>(0,D.fromEvent)(a,x).pipe((0,D.mapTo)(void 0)),r=(0,D.merge)(...["waiting","pause","canplay","play","canplaythrough","playing","seeking","seeked","ended"].map(x=>(0,D.fromEvent)(a,x))).pipe((0,D.map)(x=>x.type==="ended"?a.readyState<2:a.readyState<3),(0,D.filterChanged)()),i=(0,D.merge)((0,D.fromEvent)(a,"progress"),(0,D.fromEvent)(a,"timeupdate")).pipe((0,D.map)(()=>Jm(a.buffered,a.currentTime))),s=D.clientChecker.isSafari?(0,D.combine)({play:e("play").pipe((0,D.once)()),playing:e("playing")}).pipe((0,D.mapTo)(void 0)):e("playing"),n=(0,D.fromEvent)(a,"volumechange").pipe((0,D.map)(()=>({muted:a.muted,volume:a.volume}))),o=(0,D.fromEvent)(a,"ratechange").pipe((0,D.map)(()=>a.playbackRate)),u=(0,D.fromEvent)(a,"error").pipe((0,D.filter)(()=>!!(a.error||a.played.length)),(0,D.map)(()=>{var A;let x=a.error;return{id:x?`MediaError#${x.code}`:"HtmlVideoError",category:D.ErrorCategory.VIDEO_PIPELINE,message:x?x.message:"Error event from HTML video element",thrown:(A=a.error)!=null?A:void 0}})),l=(0,D.fromEvent)(a,"timeupdate").pipe((0,D.map)(()=>a.currentTime)),d=new D.Subject,c=.3,p;l.subscribe(x=>{a.loop&&(0,D.isNonNullable)(p)&&(0,D.isNonNullable)(x)&&p>=a.duration-c&&x<=c&&d.next(p),p=x});let h=e("pause").pipe((0,D.filter)(()=>!a.error&&p!==a.duration)),m=(0,D.fromEvent)(a,"enterpictureinpicture"),g=(0,D.fromEvent)(a,"leavepictureinpicture"),v=new D.ValueSubject(Km(a));m.subscribe(()=>v.next(!0)),g.subscribe(()=>v.next(!1));let I=new D.ValueSubject(Eu(a));return(0,D.fromEvent)(a,"fullscreenchange").pipe((0,D.map)(()=>Eu(a))).subscribe(I),{playing$:s,pause$:h,canplay$:e("canplay"),ended$:e("ended"),looped$:d,error$:u,seeked$:e("seeked"),seeking$:e("seeking"),progress$:e("progress"),loadStart$:e("loadstart"),loadedMetadata$:e("loadedmetadata"),loadedData$:e("loadeddata"),timeUpdate$:l,durationChange$:(0,D.fromEvent)(a,"durationchange").pipe((0,D.map)(()=>a.duration)),isBuffering$:r,currentBuffer$:i,volumeState$:n,playbackRateState$:o,inPiP$:v,inFullscreen$:I}};var At=require("@vkontakte/videoplayer-shared/es2015"),zt=a=>{switch(a){case"mobile":return At.VideoQuality.Q_144P;case"lowest":return At.VideoQuality.Q_240P;case"low":return At.VideoQuality.Q_360P;case"sd":case"medium":return At.VideoQuality.Q_480P;case"hd":case"high":return At.VideoQuality.Q_720P;case"fullhd":case"full":return At.VideoQuality.Q_1080P;case"quadhd":case"quad":return At.VideoQuality.Q_1440P;case"ultrahd":case"ultra":return At.VideoQuality.Q_2160P}};var Kt=X(Kr(),1),ub=X(ht(),1),Fs=X(Fr(),1),C=require("@vkontakte/videoplayer-shared/es2015");var xu=!1,wt={},ab=a=>{xu=a},sb=()=>{wt={}},nb=a=>{a(wt)},qi=(a,e)=>{var t;xu&&(wt.meta=(t=wt.meta)!=null?t:{},wt.meta[a]=e)},$e=class{constructor(e){this.name=e}next(e){var r,i;if(!xu)return;wt.series=(r=wt.series)!=null?r:{};let t=(i=wt.series[this.name])!=null?i:[];t.push([Date.now(),e]),wt.series[this.name]=t}};var kw=new $e("best_bitrate"),lb=(a,e,t)=>(e-t)*Math.pow(2,-10*a)+t;var Pu=a=>(e,t)=>a*(Number(e.bitrate)-Number(t.bitrate)),Ui=class{constructor(){this.history={}}recordSelection(e){this.history[e.id]=(0,C.now)()}recordSwitch(e){this.last=e}clear(){this.last=void 0,this.history={}}},cb='Assertion "ABR Tracks is empty array" failed',qs=(a,e,t,r)=>{var u;let i=[...e].sort(Pu(1)),s=[...t].sort(Pu(1)),n=s.filter(l=>(0,C.isNonNullable)(l.bitrate)&&(0,C.isNonNullable)(a.bitrate)?a.bitrate/l.bitrate>r:!0),o=(u=(0,Kt.default)(s,Math.round(s.length*i.indexOf(a)/(i.length+1))))!=null?u:(0,Kt.default)(s,-1);return o&&(0,ub.default)(n,o)?o:n.length?(0,Kt.default)(n,-1):(0,Kt.default)(s,0)},ob=a=>"quality"in a,db=(a,e,t,r)=>{var n;let i=(0,C.isNonNullable)((n=r==null?void 0:r.last)==null?void 0:n.bitrate)&&(0,C.isNonNullable)(t==null?void 0:t.bitrate)&&r.last.bitrate<t.bitrate?a.trackCooldownIncreaseQuality:a.trackCooldownDecreaseQuality,s=t&&r&&r.history[t.id]&&(0,C.now)()-r.history[t.id]<=i&&(!r.last||t.id!==r.last.id);if(t!=null&&t.id&&r&&!s&&r.recordSelection(t),s&&(r!=null&&r.last)){let o=r.last;r==null||r.recordSwitch(o);let u=ob(o)?"video":"audio",l=ob(o)?o.quality:o.bitrate;return e({message:`
8
8
  [last ${u} selected] ${l}
9
9
  `}),o}return r==null||r.recordSwitch(t),t},Rw=(a,e)=>Math.log(e)/Math.log(a),Jt=(a,{container:e,estimatedThroughput:t,tuning:r,limits:i,reserve:s=0,forwardBufferHealth:n,playbackRate:o,current:u,history:l,visible:d,droppedVideoMaxQualityLimit:c,stallsVideoMaxQualityLimit:p,stallsPredictedThroughput:h,abrLogger:m})=>{var te,_,ie,U,ne,$;(0,C.assertNotEmptyArray)(a,cb);let g=r.containerSizeFactor;if(r.usePixelRatio&&window.devicePixelRatio){let P=window.devicePixelRatio;if(r.pixelRatioMultiplier)g*=r.pixelRatioMultiplier*(P-1)+1;else{let K=r.pixelRatioLogBase,[Y=0,be=0,Ge=0]=r.pixelRatioLogCoefficients,Bt=Rw(K,Y*P+be)+Ge;Number.isFinite(Bt)&&(g*=Bt)}}let v=r.limitByContainer&&e&&e.width>0&&e.height>0?{width:e.width*g,height:e.height*g}:void 0,I=r.considerPlaybackRate&&(0,C.isNonNullable)(o)?o:1,T=a.filter(P=>!(0,C.isInvariantQuality)(P.quality)).sort((P,K)=>(0,C.isHigher)(P.quality,K.quality)?-1:1),x=(te=(0,Kt.default)(T,-1))==null?void 0:te.quality,A=(_=(0,Kt.default)(T,0))==null?void 0:_.quality,w=(0,C.isNullable)(i)||(0,C.isNonNullable)(i.min)&&(0,C.isNonNullable)(i.max)&&(0,C.isLower)(i.max,i.min)||(0,C.isNonNullable)(i.min)&&A&&(0,C.isHigher)(i.min,A)||(0,C.isNonNullable)(i.max)&&x&&(0,C.isLower)(i.max,x),F=I*lb(n!=null?n:.5,r.bitrateFactorAtEmptyBuffer,r.bitrateFactorAtFullBuffer),Q={},J=T.filter(P=>{let K=!0;if(v)if(P.size)K=P.size.width<=v.width&&P.size.height<=v.height;else{let Ee=v&&(0,C.videoSizeToQuality)(v);K=Ee?(0,C.isLowerOrEqual)(P.quality,Ee):!0}if(!K)return Q[P.quality]="FitsContainer",!1;let Y=h||t;if(!((0,C.isNonNullable)(Y)&&isFinite(Y)&&(0,C.isNonNullable)(P.bitrate)?Y-s>=P.bitrate*F:!0))return Q[P.quality]="FitsThroughput",!1;if(r.lazyQualitySwitch&&(0,C.isNonNullable)(r.minBufferToSwitchUp)&&u&&!(0,C.isInvariantQuality)(u.quality)&&(n!=null?n:0)<r.minBufferToSwitchUp&&(0,C.isHigher)(P.quality,u.quality))return Q[P.quality]="Buffer",!1;if(!!c&&(0,C.isHigherOrEqual)(P.quality,c))return Q[P.quality]="DroppedFramesLimit",!1;if(!!p&&(0,C.isHigherOrEqual)(P.quality,p))return Q[P.quality]="StallsLimit",!1;let re=w||((0,C.isNullable)(i.max)||(0,C.isLowerOrEqual)(P.quality,i.max))&&((0,C.isNullable)(i.min)||(0,C.isHigherOrEqual)(P.quality,i.min)),Ie=(0,C.isNonNullable)(d)&&!d?(0,C.isLowerOrEqual)(P.quality,r.backgroundVideoQualityLimit):!0;return!re||!Ie?(Q[P.quality]="FitsQualityLimits",!1):!0})[0];J&&J.bitrate&&kw.next(J.bitrate);let W=(ie=J!=null?J:(0,Kt.default)(T,-1))!=null?ie:a[0];return W.quality!==((U=l==null?void 0:l.last)==null?void 0:U.quality)&&m({message:`
10
10
  [VIDEO TRACKS ABR]
@@ -120,5 +120,5 @@ void main(void) {
120
120
  // sample using new coordinates
121
121
  gl_FragColor = texture2D(u_texture, tc);
122
122
  }
123
- `;var hn=class{constructor(e,t,r){this.videoInitialized=!1;this.active=!1;this.container=e,this.sourceVideoElement=t,this.params=r,this.canvas=this.createCanvas();let i=this.canvas.getContext("webgl");if(!i)throw new Error("Could not initialize WebGL context");this.gl=i,this.container.appendChild(this.canvas),this.camera=new dn(this.params.fov,this.params.orientation),this.cameraRotationManager=new pn(this.camera,{rotationSpeed:this.params.rotationSpeed,maxYawAngle:this.params.maxYawAngle,rotationSpeedCorrection:this.params.rotationSpeedCorrection,degreeToPixelCorrection:this.params.degreeToPixelCorrection,speedFadeTime:this.params.speedFadeTime,speedFadeThreshold:this.params.speedFadeThreshold}),this.updateFrameSize(),this.vertexBuffer=this.createVertexBuffer(),this.textureMappingBuffer=this.createTextureMappingBuffer(),this.updateTextureMappingBuffer(),this.program=this.createProgram(),this.videoTexture=this.createTexture(),this.gl.useProgram(this.program),this.videoElementDataLoadedFn=this.onDataLoadedHandler.bind(this),this.renderFn=this.render.bind(this)}play(){this.active||(this.videoInitialized?this.doPlay():this.sourceVideoElement.readyState>=2?(this.videoInitialized=!0,this.doPlay()):this.sourceVideoElement.addEventListener("loadeddata",this.videoElementDataLoadedFn))}stop(){this.active=!1}startCameraManualRotation(e,t){this.cameraRotationManager.setRotationSpeed(e*this.params.rotationSpeed,t*this.params.rotationSpeed,0),this.cameraRotationManager.startRotation()}stopCameraManualRotation(e=!1){this.cameraRotationManager.stopRotation(e)}turnCamera(e,t){this.cameraRotationManager.turnCamera(e,t)}pointCameraTo(e,t){this.cameraRotationManager.pointCameraTo(e,t)}pixelToDegree(e){return{x:this.params.degreeToPixelCorrection*this.params.fov.x*-e.x/this.viewportWidth,y:this.params.degreeToPixelCorrection*this.params.fov.y*e.y/this.viewportHeight}}getCameraRotation(){return this.camera.orientation}holdCamera(){this.cameraRotationManager.stopRotation(!0)}releaseCamera(){this.cameraRotationManager.onCameraRelease()}destroy(){this.sourceVideoElement.removeEventListener("loadeddata",this.videoElementDataLoadedFn),this.stop(),this.canvas.remove()}setViewportSize(e,t){this.viewportWidth=e,this.viewportHeight=t,this.canvas.width=this.viewportWidth,this.canvas.height=this.viewportHeight,this.gl.viewport(0,0,this.canvas.width,this.canvas.height)}onDataLoadedHandler(){this.videoInitialized=!0,this.doPlay()}doPlay(){this.updateFrameSize(),this.vertexBuffer=this.createVertexBuffer(),this.active=!0,this.sourceVideoElement.removeEventListener("loadeddata",this.videoElementDataLoadedFn),requestAnimationFrame(this.renderFn)}render(e){this.cameraRotationManager.tick(e),this.updateTexture(),this.updateTextureMappingBuffer();let t=this.gl.getAttribLocation(this.program,"a_vertex"),r=this.gl.getAttribLocation(this.program,"a_texel"),i=this.gl.getUniformLocation(this.program,"u_texture"),s=this.gl.getUniformLocation(this.program,"u_focus");this.gl.enableVertexAttribArray(t),this.gl.enableVertexAttribArray(r),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuffer),this.gl.vertexAttribPointer(t,2,this.gl.FLOAT,!1,0,0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.textureMappingBuffer),this.gl.vertexAttribPointer(r,2,this.gl.FLOAT,!1,0,0),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.videoTexture),this.gl.uniform1i(i,0),this.gl.uniform2f(s,-this.camera.orientation.x,-this.camera.orientation.y),this.gl.drawArrays(this.gl.TRIANGLE_FAN,0,4),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.disableVertexAttribArray(t),this.gl.disableVertexAttribArray(r),this.active&&requestAnimationFrame(this.renderFn)}createShader(e,t){let r=this.gl.createShader(t);if(!r)throw this.destroy(),new Error(`Could not create shader (${t})`);if(this.gl.shaderSource(r,e),this.gl.compileShader(r),!this.gl.getShaderParameter(r,this.gl.COMPILE_STATUS))throw this.destroy(),new Error("An error occurred while compiling the shader: "+this.gl.getShaderInfoLog(r));return r}createProgram(){let e=this.gl.createProgram();if(!e)throw this.destroy(),new Error("Could not create shader program");let t=this.createShader(Fv,this.gl.VERTEX_SHADER),r=this.createShader(qv,this.gl.FRAGMENT_SHADER);if(this.gl.attachShader(e,t),this.gl.attachShader(e,r),this.gl.linkProgram(e),!this.gl.getProgramParameter(e,this.gl.LINK_STATUS))throw this.destroy(),new Error("Could not link shader program.");return e}createTexture(){let e=this.gl.createTexture();if(!e)throw this.destroy(),new Error("Could not create texture");return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.bindTexture(this.gl.TEXTURE_2D,null),e}updateTexture(){this.gl.bindTexture(this.gl.TEXTURE_2D,this.videoTexture),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!0),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,this.sourceVideoElement),this.gl.bindTexture(this.gl.TEXTURE_2D,null)}createVertexBuffer(){let e=this.gl.createBuffer();if(!e)throw this.destroy(),new Error("Could not create vertex buffer");let t=1,r=1,i=this.frameHeight/(this.frameWidth/this.viewportWidth);return i>this.viewportHeight?t=this.viewportHeight/i:r=i/this.viewportHeight,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([-t,-r,t,-r,t,r,-t,r]),this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),e}createTextureMappingBuffer(){let e=this.gl.createBuffer();if(!e)throw this.destroy(),new Error("Could not create texture mapping buffer");return e}calculateTexturePosition(){let e=.5-this.camera.orientation.x/360,t=.5-this.camera.orientation.y/180,r=this.camera.fov.x/360/2,i=this.camera.fov.y/180/2,s=e-r,n=t-i,o=e+r,u=t-i,l=e+r,d=t+i,c=e-r,p=t+i;return[s,n,o,u,l,d,c,p]}updateTextureMappingBuffer(){this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.textureMappingBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([...this.calculateTexturePosition()]),this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null)}updateFrameSize(){this.frameWidth=this.sourceVideoElement.videoWidth,this.frameHeight=this.sourceVideoElement.videoHeight}createCanvas(){let e=document.createElement("canvas");return e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.width="100%",e.style.height="100%",e}};var Te=require("@vkontakte/videoplayer-shared/es2015"),sl=class{constructor(){this.isSeeked$=new Te.ValueSubject(!1);this.isBuffering$=new Te.ValueSubject(!1);this.currentStallsCount=0;this.maxQualityLimit=void 0;this.lastUniqueVideoTrackSelectedTimestamp=0;this.predictedThroughputWithoutData=0;this.subscription=new Te.Subscription}connect(e){this.currentStallDuration$=e.currentStallDuration$,this.videoLastDataObtainedTimestamp$=e.videoLastDataObtainedTimestamp$,this.throughput$=e.throughput$,this.rtt$=e.rtt$,this.qualityLimitsOnStall=e.qualityLimitsOnStall,this.subscription.add(e.isSeeked$.subscribe(this.isSeeked$)),this.subscription.add(e.isBuffering$.subscribe(this.isBuffering$)),this.subscription.add((0,Te.combine)({isBuffering:this.isBuffering$,isSeeked:this.isSeeked$}).pipe((0,Te.filter)(({isBuffering:t,isSeeked:r})=>t&&!r)).subscribe(()=>{this.currentStallsCount++})),this.subscription.add((0,Te.combine)({currentStallDuration:this.currentStallDuration$,isSeeked:this.isSeeked$}).subscribe(({currentStallDuration:t,isSeeked:r})=>{if((0,Te.isNullable)(this.lastUniqueVideoTrackSelected))return;let{stallDurationBeforeQualityDecrease:i,stallDurationNoDataBeforeQualityDecrease:s,stallCountBeforeQualityDecrease:n,resetQualityRestrictionTimeout:o}=this.qualityLimitsOnStall,u=this.rtt$.getValue(),l=this.throughput$.getValue(),d=this.videoLastDataObtainedTimestamp$.getValue(),c=(0,Te.now)(),p=n&&this.currentStallsCount>=n,h=i&&!r&&c-this.lastUniqueVideoTrackSelectedTimestamp>=i+u&&t>=i,m=s&&c-this.lastUniqueVideoTrackSelectedTimestamp>=s+u&&c-d>=s+u&&t>=s;(p||h||m)&&(window.clearTimeout(this.qualityRestrictionTimer),this.maxQualityLimit=this.lastUniqueVideoTrackSelected.quality,(0,Te.isNonNullable)(this.lastUniqueVideoTrackSelected.bitrate)&&l>this.lastUniqueVideoTrackSelected.bitrate&&(this.predictedThroughputWithoutData=this.lastUniqueVideoTrackSelected.bitrate)),t||(window.clearTimeout(this.qualityRestrictionTimer),this.qualityRestrictionTimer=window.setTimeout(()=>{this.maxQualityLimit=void 0,this.predictedThroughputWithoutData=0},o))}))}get videoMaxQualityLimit(){return this.maxQualityLimit}get predictedThroughput(){return this.predictedThroughputWithoutData}set lastVideoTrackSelected(e){var t;((t=this.lastUniqueVideoTrackSelected)==null?void 0:t.id)!==e.id&&(this.lastUniqueVideoTrackSelected=e,this.lastUniqueVideoTrackSelectedTimestamp=(0,Te.now)(),this.currentStallsCount=0)}destroy(){window.clearTimeout(this.qualityRestrictionTimer),this.subscription.unsubscribe()}},Uv=sl;var Tr=class{constructor(e){this.subscription=new V.Subscription;this.videoState=new j("stopped");this.elementSize$=new V.ValueSubject(void 0);this.textTracksManager=new ze;this.droppedFramesManager=new Hs;this.stallsManager=new Uv;this.videoTracksMap=new Map;this.audioTracksMap=new Map;this.textTracksMap=new Map;this.videoStreamsMap=new Map;this.audioStreamsMap=new Map;this.videoTrackSwitchHistory=new Ui;this.audioTrackSwitchHistory=new Ui;this.syncPlayback=()=>{var n,o,u;let e=this.videoState.getState(),t=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),i=this.params.desiredState.seekState.getState();if(!this.videoState.getTransition()){if(i.state==="requested"&&(r==null?void 0:r.to)!=="paused"&&e!=="stopped"&&t!=="stopped"){let l=(o=(n=this.liveOffset)==null?void 0:n.getTotalPausedTime())!=null?o:0;this.seek(i.position-l,i.forcePrecise)}if(t==="stopped"){e!=="stopped"&&(this.videoState.startTransitionTo("stopped"),this.player.stop(),this.video.removeAttribute("src"),this.video.load(),this.params.output.position$.next(0),this.params.output.duration$.next(1/0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.videoState.setState("stopped"),k(this.params.desiredState.playbackState,"stopped",!0));return}switch(e){case"stopped":this.videoState.startTransitionTo("ready"),this.prepare();return;case"ready":t==="paused"?(this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused")):t==="playing"?(this.videoState.startTransitionTo("playing"),this.playIfAllowed()):(r==null?void 0:r.to)==="ready"&&k(this.params.desiredState.playbackState,"ready");return;case"playing":t==="paused"?(this.videoState.startTransitionTo("paused"),(u=this.liveOffset)==null||u.pause(),this.video.paused?this.videoState.setState("paused"):this.video.pause()):(r==null?void 0:r.to)==="playing"&&k(this.params.desiredState.playbackState,"playing");return;case"paused":t==="playing"?(this.videoState.startTransitionTo("playing"),this.liveOffset?this.liveOffset.getTotalOffset()/1e3<Math.abs(this.params.output.duration$.getValue())?(this.liveOffset.resume(),this.playIfAllowed(),this.params.output.position$.next(-this.liveOffset.getTotalOffset()/1e3)):this.seek(0,!1):this.playIfAllowed()):(r==null?void 0:r.to)==="paused"&&k(this.params.desiredState.playbackState,"paused");return;default:return(0,V.assertNever)(e)}}};this.init3DScene=e=>{var r,i,s;if(this.scene3D)return;this.scene3D=new hn(this.params.container,this.video,{fov:this.params.tuning.spherical.fov,orientation:this.params.tuning.spherical.orientation||{x:((r=e.projectionData)==null?void 0:r.pose.yaw)||0,y:((i=e.projectionData)==null?void 0:i.pose.pitch)||0,z:((s=e.projectionData)==null?void 0:s.pose.roll)||0},rotationSpeed:this.params.tuning.spherical.rotationSpeed,maxYawAngle:this.params.tuning.spherical.maxYawAngle,rotationSpeedCorrection:this.params.tuning.spherical.rotationSpeedCorrection,degreeToPixelCorrection:this.params.tuning.spherical.degreeToPixelCorrection,speedFadeTime:this.params.tuning.spherical.speedFadeTime,speedFadeThreshold:this.params.tuning.spherical.speedFadeThreshold});let t=this.elementSize$.getValue();t&&this.scene3D.setViewportSize(t.width,t.height)};this.destroy3DScene=()=>{this.scene3D&&(this.scene3D.destroy(),this.scene3D=void 0)};this.params=e,this.video=Le(e.container,e.tuning),this.tracer=e.dependencies.tracer.createComponentTracer(this.constructor.name),this.params.output.element$.next(this.video),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.hostname$.next(Se(this.params.source.url)),this.params.output.isLive$.next(!1),this.params.output.autoVideoTrackLimitingAvailable$.next(!0),this.params.output.availableTextTracks$.next([]),this.params.desiredState.internalTextTracks.setState([]),this.player=new cn({throughputEstimator:this.params.dependencies.throughputEstimator,tuning:this.params.tuning,compatibilityMode:this.params.source.compatibilityMode,tracer:this.tracer}),this.subscribe()}getProviderSubscriptionInfo(){let{output:e,desiredState:t}=this.params,r=De(this.video),i=this.constructor.name,s=o=>{e.error$.next({id:i,category:V.ErrorCategory.WTF,message:`${i} internal logic error`,thrown:o})};return{output:e,desiredState:t,observableVideo:r,genericErrorListener:s,connect:(o,u)=>this.subscription.add(o.subscribe(u,s))}}subscribe(){var d;let{output:e,desiredState:t,observableVideo:r,genericErrorListener:i,connect:s}=this.getProviderSubscriptionInfo();this.subscription.add(this.params.output.availableVideoTracks$.pipe((0,V.filter)(c=>!!c.length),(0,V.once)()).subscribe(c=>{this.droppedFramesManager.connect({logger:this.params.dependencies.logger,video:this.video,droppedFramesChecker:this.params.tuning.droppedFramesChecker,isAuto:this.params.desiredState.autoVideoTrackSwitching,playing$:r.playing$,pause$:r.pause$,tracks:c})}));let n=this.params.desiredState.seekState.stateChangeEnded$.pipe((0,V.map)(c=>c.to.state!=="none"),(0,V.filterChanged)());this.stallsManager.connect({isSeeked$:n,currentStallDuration$:this.player.currentStallDuration$.pipe((0,V.filterChanged)()),videoLastDataObtainedTimestamp$:this.player.videoLastDataObtainedTimestamp$,throughput$:this.params.dependencies.throughputEstimator.throughput$,rtt$:this.params.dependencies.throughputEstimator.rtt$,qualityLimitsOnStall:this.params.tuning.dash.qualityLimitsOnStall,isBuffering$:r.isBuffering$}),s(r.ended$,e.endedEvent$),s(r.looped$,e.loopedEvent$),s(r.error$,e.error$),s(r.isBuffering$,e.isBuffering$),s(r.currentBuffer$,e.currentBuffer$),s(r.playing$,e.firstFrameEvent$),s(r.canplay$,e.canplay$),s(r.inPiP$,e.inPiP$),s(r.inFullscreen$,e.inFullscreen$),s(r.loadedMetadata$,e.loadedMetadataEvent$),s(this.player.error$,e.error$),s(this.player.lastConnectionType$,e.httpConnectionType$),s(this.player.lastConnectionReused$,e.httpConnectionReused$),s(this.player.isLive$,e.isLive$),s(this.player.lastRequestFirstBytes$.pipe((0,V.filter)(V.isNonNullable),(0,V.once)()),e.firstBytesEvent$),s(this.videoState.stateChangeEnded$.pipe((0,V.map)(c=>c.to)),this.params.output.playbackState$),this.subscription.add(r.seeked$.subscribe(e.seekedEvent$,i)),this.subscription.add(mt(this.video,t.isLooped,i)),this.subscription.add(Ce(this.video,t.volume,r.volumeState$,i)),this.subscription.add(r.volumeState$.subscribe(this.params.output.volume$,i)),this.subscription.add(Ye(this.video,t.playbackRate,r.playbackRateState$,i)),s((0,V.observeElementSize)(this.video),this.elementSize$),s(Ke(this.video,{threshold:this.params.tuning.autoTrackSelection.activeVideoAreaThreshold}),e.elementVisible$),this.subscription.add(r.playing$.subscribe(()=>{this.videoState.setState("playing"),k(t.playbackState,"playing"),this.scene3D&&this.scene3D.play()},i)).add(r.pause$.subscribe(()=>{this.videoState.setState("paused"),k(t.playbackState,"paused")},i)).add(r.canplay$.subscribe(()=>{this.videoState.getState()==="playing"&&this.playIfAllowed()},i)),this.subscription.add(this.player.state$.stateChangeEnded$.subscribe(({to:c})=>{if(c==="manifest_ready"){this.videoTracksMap=new Map,this.audioTracksMap=new Map,this.textTracksMap=new Map;let p=this.player.getStreams();if((0,V.assertNonNullable)(p,"Manifest not loaded or empty"),!this.params.tuning.isAudioDisabled){let m=[];for(let g of p.audio){m.push(Zu(g));let v=[];for(let I of g.representations){let T=Mv(I);v.push(T),this.audioTracksMap.set(T,{stream:g,representation:I})}this.audioStreamsMap.set(g,v)}this.params.output.availableAudioStreams$.next(m)}let h=[];for(let m of p.video){h.push(el(m));let g=[];for(let v of m.representations){let I=Lv(H(R({},v),{streamId:m.id}));I&&(g.push(I),this.videoTracksMap.set(I,{stream:m,representation:v}))}this.videoStreamsMap.set(m,g)}if(this.params.output.availableVideoStreams$.next(h),this.textTracksManager)for(let m of p.text)for(let g of m.representations){let v=Cv(m,g);this.textTracksMap.set(v,{stream:m,representation:g})}this.params.output.availableVideoTracks$.next(Array.from(this.videoTracksMap.keys())),this.params.output.availableAudioTracks$.next(Array.from(this.audioTracksMap.keys())),this.params.output.isAudioAvailable$.next(!!this.audioTracksMap.size),this.audioTracksMap.size&&this.textTracksMap.size&&this.params.desiredState.internalTextTracks.startTransitionTo(Array.from(this.textTracksMap.keys()))}else c==="representations_ready"&&(this.videoState.setState("ready"),this.player.initBuffer())},i));let o=c=>e.error$.next({id:"RepresentationSwitch",category:V.ErrorCategory.WTF,message:"Switching representations threw",thrown:c});this.subscription.add((0,V.merge)(this.player.currentStallDuration$,this.player.state$.stateChangeEnded$,t.videoTrack.stateChangeStarted$,t.autoVideoTrackSwitching.transitionStarted$,this.params.dependencies.throughputEstimator.rttAdjustedThroughput$,t.autoVideoTrackLimits.stateChangeStarted$,t.videoStream.stateChangeStarted$,t.audioStream.stateChangeStarted$,this.elementSize$,this.params.output.elementVisible$,this.droppedFramesManager.onDroopedVideoFramesLimit$,(0,V.fromEvent)(this.video,"progress")).subscribe(()=>{let c=this.player.state$.getState(),p=this.player.state$.getTransition();if(!(0,Hv.default)(["manifest_ready","running"],c)||p)return;t.autoVideoTrackSwitching.getTransition()&&t.autoVideoTrackSwitching.setState(t.autoVideoTrackSwitching.getState());let h=this.selectVideoAudioRepresentations();if(!h)return;let[m,g]=h,v=[...this.videoTracksMap.keys()].find(T=>{var x;return((x=this.videoTracksMap.get(T))==null?void 0:x.representation.id)===m.id});(0,V.isNonNullable)(v)&&(this.stallsManager.lastVideoTrackSelected=v);let I=this.params.desiredState.autoVideoTrackLimits.getTransition();if(I&&this.params.output.autoVideoTrackLimits$.next(I.to),c==="manifest_ready")this.player.initRepresentations(m.id,g==null?void 0:g.id,this.params.sourceHls);else if(this.player.switchRepresentation("video",m.id).catch(o),g){let T=!!t.audioStream.getTransition();this.player.switchRepresentation("audio",g.id,T).catch(o)}},i)),this.subscription.add(t.cameraOrientation.stateChangeEnded$.subscribe(({to:c})=>{this.scene3D&&c&&this.scene3D.pointCameraTo(c.x,c.y)})),this.subscription.add(this.elementSize$.subscribe(c=>{this.scene3D&&c&&this.scene3D.setViewportSize(c.width,c.height)})),this.subscription.add(this.player.currentVideoRepresentation$.pipe((0,V.filterChanged)()).subscribe(c=>{let p=[...this.videoTracksMap.entries()].find(([,{representation:v}])=>v.id===c);if(!p){e.currentVideoTrack$.next(void 0),e.currentVideoStream$.next(void 0);return}let[h,{stream:m}]=p,g=this.params.desiredState.videoStream.getTransition();g&&g.to&&g.to.id===m.id&&this.params.desiredState.videoStream.setState(g.to),e.currentVideoTrack$.next(h),e.currentVideoStream$.next(el(m))},i)),this.subscription.add(this.player.currentAudioRepresentation$.pipe((0,V.filterChanged)()).subscribe(c=>{let p=[...this.audioTracksMap.entries()].find(([,{representation:v}])=>v.id===c);if(!p){e.currentAudioStream$.next(void 0);return}let[h,{stream:m}]=p,g=this.params.desiredState.audioStream.getTransition();g&&g.to&&g.to.id===m.id&&this.params.desiredState.audioStream.setState(g.to),e.currentAudioStream$.next(Zu(m))},i)),this.subscription.add(this.player.currentVideoRepresentationInit$.subscribe(c=>{var p,h;if(c!=null&&c.is3dVideo&&((p=this.params.tuning.spherical)!=null&&p.enabled))try{this.init3DScene(c),e.is3DVideo$.next(!0)}catch(m){e.warning$.next({id:"DashProvider",message:`DashProvider could not initialize 3D-scene: ${m}`})}else this.destroy3DScene(),(h=this.params.tuning.spherical)!=null&&h.enabled&&e.is3DVideo$.next(!1)},i)),this.subscription.add(this.player.currentVideoSegmentLength$.subscribe(e.currentVideoSegmentLength$,i)),this.subscription.add(this.player.currentAudioSegmentLength$.subscribe(e.currentAudioSegmentLength$,i)),(d=this.textTracksManager)==null||d.connect(this.video,t,e);let u=t.playbackState.stateChangeStarted$.pipe((0,V.map)(({to:c})=>c==="ready"),(0,V.filterChanged)());this.subscription.add((0,V.merge)(u,t.autoVideoTrackSwitching.stateChangeStarted$,this.player.state$.stateChangeEnded$).subscribe(()=>{let c=t.autoVideoTrackSwitching.getState(),h=t.playbackState.getState()==="ready"?this.params.tuning.dash.forwardBufferTargetPreload:c?this.params.tuning.dash.forwardBufferTargetAuto:this.params.tuning.dash.forwardBufferTargetManual;this.player.setBufferTarget(h)})),this.subscription.add((0,V.merge)(u,this.player.state$.stateChangeEnded$).subscribe(()=>this.player.setPreloadOnly(t.playbackState.getState()==="ready")));let l=(0,V.merge)(t.playbackState.stateChangeStarted$,t.videoTrack.stateChangeStarted$,t.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,(0,V.observableFrom)(["init"])).pipe((0,V.debounce)(0));this.subscription.add(l.subscribe(this.syncPlayback,i))}selectVideoAudioRepresentations(){var F,Q,oe,J,W,te,_,ie,U,ne,$,P,K;let{desiredState:e,output:t}=this.params,r=e.autoVideoTrackSwitching.getState(),i=(F=e.videoTrack.getState())==null?void 0:F.id,n=[...this.videoTracksMap.keys()].find(({id:Y})=>Y===i),o=t.currentVideoTrack$.getValue(),u=((J=(oe=e.videoStream.getState())!=null?oe:n&&((Q=this.videoTracksMap.get(n))==null?void 0:Q.stream))!=null?J:this.videoStreamsMap.size===1)?this.videoStreamsMap.keys().next().value:void 0;if(!u)return;let l=[...this.videoStreamsMap.keys()].find(({id:Y})=>Y===u.id),d=l&&this.videoStreamsMap.get(l);if(!d)return;let c=gt(this.video.buffered,this.video.currentTime*1e3),p=r?this.params.tuning.dash.forwardBufferTargetAuto:this.params.tuning.dash.forwardBufferTargetManual,h=Math.min(c/Math.min(p,(this.video.duration*1e3||1/0)-this.video.currentTime*1e3),1),m=(W=e.audioStream.getState())!=null?W:this.audioStreamsMap.size===1?this.audioStreamsMap.keys().next().value:void 0,g=(te=[...this.audioStreamsMap.keys()].find(({id:Y})=>Y===(m==null?void 0:m.id)))!=null?te:this.audioStreamsMap.keys().next().value,v=0;if(g){if(n&&!r){let Y=qs(n,d,(_=this.audioStreamsMap.get(g))!=null?_:[],this.params.tuning.autoTrackSelection.minVideoAudioRatio);v=Math.max(v,(ie=Y==null?void 0:Y.bitrate)!=null?ie:-1/0)}if(o){let Y=qs(o,d,(U=this.audioStreamsMap.get(g))!=null?U:[],this.params.tuning.autoTrackSelection.minVideoAudioRatio);v=Math.max(v,(ne=Y==null?void 0:Y.bitrate)!=null?ne:-1/0)}}let I=Jt(d,{container:this.elementSize$.getValue(),estimatedThroughput:this.params.dependencies.throughputEstimator.rttAdjustedThroughput$.getValue(),tuning:this.params.tuning.autoTrackSelection,limits:this.params.desiredState.autoVideoTrackLimits.getState(),reserve:v,forwardBufferHealth:h,current:o,visible:this.params.output.elementVisible$.getValue(),history:this.videoTrackSwitchHistory,playbackRate:this.video.playbackRate,droppedVideoMaxQualityLimit:this.droppedFramesManager.droppedVideoMaxQualityLimit,stallsVideoMaxQualityLimit:this.stallsManager.videoMaxQualityLimit,stallsPredictedThroughput:this.stallsManager.predictedThroughput,abrLogger:this.params.dependencies.abrLogger}),T=r?I!=null?I:n:n!=null?n:I,x=g&&pb(T,d,($=this.audioStreamsMap.get(g))!=null?$:[],{estimatedThroughput:this.params.dependencies.throughputEstimator.rttAdjustedThroughput$.getValue(),stallsPredictedThroughput:this.stallsManager.predictedThroughput,tuning:this.params.tuning.autoTrackSelection,forwardBufferHealth:h,history:this.audioTrackSwitchHistory,playbackRate:this.video.playbackRate,abrLogger:this.params.dependencies.abrLogger}),A=(P=this.videoTracksMap.get(T))==null?void 0:P.representation,w=x&&((K=this.audioTracksMap.get(x))==null?void 0:K.representation);if(A&&w)return[A,w];if(A&&!w&&this.audioTracksMap.size===0)return[A,void 0]}prepare(e=0){this.player.initManifest(this.video,this.params.source.url,e)}playIfAllowed(){Oe(this.video,()=>{this.params.output.soundProhibitedEvent$.next()}).then(e=>{var t;e||((t=this.liveOffset)==null||t.pause(),this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused",!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:V.ErrorCategory.DOM,thrown:e}))}destroy(){var e;this.subscription.unsubscribe(),this.droppedFramesManager.destroy(),this.stallsManager.destroy(),this.destroy3DScene(),(e=this.textTracksManager)==null||e.destroy(),this.player.destroy(),this.params.output.element$.next(void 0),Me(this.video),this.tracer.end()}};var Ra=class extends Tr{subscribe(){super.subscribe();let{output:e,observableVideo:t,connect:r}=this.getProviderSubscriptionInfo();r(t.timeUpdate$,e.position$),r(t.durationChange$,e.duration$)}seek(e,t){this.params.output.willSeekEvent$.next(),this.player.seek(e,t)}};var tr=require("@vkontakte/videoplayer-shared/es2015");var $a=class extends Tr{constructor(e){var t;super(e),this.liveOffset=new Pt,(t=this.textTracksManager)==null||t.destroy()}subscribe(){super.subscribe();let{output:e,observableVideo:t,desiredState:r,connect:i}=this.getProviderSubscriptionInfo();this.params.output.position$.next(0),this.params.output.isLive$.next(!0),i(t.timeUpdate$,e.liveBufferTime$),i(this.player.liveDuration$,e.duration$),i(this.player.liveLatency$,e.liveLatency$),this.subscription.add(r.isLowLatency.stateChangeEnded$.pipe((0,tr.map)(s=>s.to)).subscribe(this.player.isLowLatency$)).add(this.params.output.position$.subscribe(this.player.livePositionFromPlayer$)).add((0,tr.combine)({interval:(0,tr.interval)(1e3),playbackRate:t.playbackRateState$}).subscribe(({playbackRate:s})=>{var n;if(this.videoState.getState()==="playing"){let o=e.position$.getValue()+(s-1);o<=0&&e.position$.next(o),(n=this.liveOffset)==null||n.resetTo(-o*1e3)}})).add((0,tr.combine)({liveBufferTime:e.liveBufferTime$,liveAvailabilityStartTime:this.player.liveAvailabilityStartTime$}).pipe((0,tr.map)(({liveBufferTime:s,liveAvailabilityStartTime:n})=>s&&n?s+n:void 0)).subscribe(e.liveTime$)).add(this.player.currentLiveTextRepresentation$.subscribe(s=>{if(s){let n=Dv(s);this.params.output.availableTextTracks$.next([n])}}))}seek(e){this.params.output.willSeekEvent$.next();let t=this.params.desiredState.playbackState.getState(),r=this.videoState.getState(),i=t==="paused"&&r==="paused",s=-e,n=Math.trunc(s/1e3<=Math.abs(this.params.output.duration$.getValue())?s:0);this.player.seekLive(n).then(()=>{var o;this.params.output.position$.next(e/1e3),(o=this.liveOffset)==null||o.resetTo(n,i)})}};var jv=X(Bs(),1);var z=require("@vkontakte/videoplayer-shared/es2015");var ot={};var ni=(a,e)=>new z.Observable(t=>{let r=(i,s)=>t.next(s);return a.on(e,r),()=>a.off(e,r)}),La=class{constructor(e){this.subscription=new z.Subscription;this.videoState=new j("initializing");this.textTracksManager=new ze;this.trackLevels=new Map;this.syncPlayback=()=>{let e=this.videoState.getState(),t=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),i=this.params.desiredState.seekState.getState();if(e!=="initializing")switch((r==null?void 0:r.to)!=="paused"&&i.state==="requested"&&this.seek(i.position),t){case"stopped":switch(e){case"stopped":break;case"ready":case"playing":case"paused":this.stop();break;default:(0,z.assertNever)(e)}break;case"ready":switch(e){case"stopped":this.prepare();break;case"ready":case"playing":case"paused":break;default:(0,z.assertNever)(e)}break;case"playing":switch(e){case"playing":break;case"stopped":this.prepare();break;case"ready":case"paused":this.playIfAllowed();break;default:(0,z.assertNever)(e)}break;case"paused":switch(e){case"paused":break;case"stopped":this.prepare();break;case"ready":this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused");break;case"playing":this.pause();break;default:(0,z.assertNever)(e)}break;default:(0,z.assertNever)(t)}};this.video=Le(e.container,e.tuning),this.params=e,this.params.output.element$.next(this.video),this.params.output.isLive$.next(!1),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.hostname$.next(Se(this.params.source.url)),this.loadHlsJs()}destroy(){var e,t;this.subscription.unsubscribe(),this.trackLevels.clear(),this.textTracksManager.destroy(),(e=this.hls)==null||e.detachMedia(),(t=this.hls)==null||t.destroy(),this.params.output.element$.next(void 0),Me(this.video)}loadHlsJs(){let e=!1,t=i=>{e||this.params.output.error$.next({id:i==="timeout"?"HlsJsTimeout":"HlsJsLoadError",category:z.ErrorCategory.NETWORK,message:"Failed to load Hls.js",thrown:i}),e=!0},r=window.setTimeout(()=>t("timeout"),this.params.tuning.dynamicImportTimeout);(0,jv.default)(import("hls.js").then(i=>{e||(ot.Hls=i.default,ot.Events=i.default.Events,this.init())},t),()=>{window.clearTimeout(r),e=!0})}init(){(0,z.assertNonNullable)(ot.Hls,"hls.js not loaded"),this.hls=new ot.Hls({fragLoadingMaxRetry:5,levelLoadingMaxRetry:2,manifestLoadingMaxRetry:2,fragLoadingMaxRetryTimeout:16e3,manifestLoadingMaxRetryTimeout:2e3,levelLoadingMaxRetryTimeout:2e3}),this.subscribe(),this.videoState.setState("stopped")}subscribe(){(0,z.assertNonNullable)(ot.Events,"hls.js not loaded");let{desiredState:e,output:t}=this.params,r=l=>{t.error$.next({id:"HlsJsProvider",category:z.ErrorCategory.WTF,message:"HlsJsProvider internal logic error",thrown:l})},i=De(this.video),s=(l,d)=>this.subscription.add(l.subscribe(d,r));s(i.timeUpdate$,t.position$),s(i.durationChange$,t.duration$),s(i.ended$,t.endedEvent$),s(i.looped$,t.loopedEvent$),s(i.error$,t.error$),s(i.isBuffering$,t.isBuffering$),s(i.currentBuffer$,t.currentBuffer$),s(i.loadStart$,t.firstBytesEvent$),s(i.loadedMetadata$,t.loadedMetadataEvent$),s(i.playing$,t.firstFrameEvent$),s(i.canplay$,t.canplay$),s(i.seeked$,t.seekedEvent$),s(i.inPiP$,t.inPiP$),s(i.inFullscreen$,t.inFullscreen$),this.subscription.add(mt(this.video,e.isLooped,r)),this.subscription.add(Ce(this.video,e.volume,i.volumeState$,r)),this.subscription.add(i.volumeState$.subscribe(this.params.output.volume$)),this.subscription.add(Ye(this.video,e.playbackRate,i.playbackRateState$,r)),s(Ke(this.video),t.elementVisible$),s(this.videoState.stateChangeEnded$.pipe((0,z.map)(l=>l.to)),this.params.output.playbackState$),this.subscription.add(ni(this.hls,ot.Events.ERROR).subscribe(l=>{var d;l.fatal&&t.error$.next({id:["HlsJsFatal",l.type,l.details].join("_"),category:z.ErrorCategory.WTF,message:`HlsJs fatal ${l.type} ${l.details}, ${(d=l.err)==null?void 0:d.message} ${l.reason}`,thrown:l.error})})),this.subscription.add(i.playing$.subscribe(()=>{this.videoState.setState("playing"),k(e.playbackState,"playing")},r)).add(i.pause$.subscribe(()=>{this.videoState.setState("paused"),k(e.playbackState,"paused")},r)).add(i.canplay$.subscribe(()=>{var l;((l=this.videoState.getTransition())==null?void 0:l.to)==="ready"&&this.videoState.setState("ready"),this.videoState.getState()==="playing"&&this.playIfAllowed()},r)),s(ni(this.hls,ot.Events.MANIFEST_PARSED).pipe((0,z.map)(({levels:l})=>l.reduce((d,c)=>{var T,x;let p=c.name||c.height.toString(10),{width:h,height:m}=c,g=(x=zt((T=c.attrs.QUALITY)!=null?T:""))!=null?x:(0,z.videoSizeToQuality)({width:h,height:m});if(!g)return d;let v=c.attrs["FRAME-RATE"]?parseFloat(c.attrs["FRAME-RATE"]):void 0,I={id:p.toString(),quality:g,bitrate:c.bitrate/1e3,size:{width:h,height:m},fps:v};return this.trackLevels.set(p,{track:I,level:c}),d.push(I),d},[]))),t.availableVideoTracks$),s(ni(this.hls,ot.Events.MANIFEST_PARSED),l=>{if(l.subtitleTracks.length>0){let d=[];for(let c of l.subtitleTracks){let p=c.name,h=c.attrs.URI||"",m=c.lang;d.push({id:p,url:h,language:m,type:"internal"})}e.internalTextTracks.startTransitionTo(d)}}),s(ni(this.hls,ot.Events.LEVEL_LOADING).pipe((0,z.map)(({url:l})=>Se(l))),t.hostname$),s(ni(this.hls,ot.Events.FRAG_CHANGED),l=>{var p,h,m,g;let{video:d,audio:c}=l.frag.elementaryStreams;t.currentVideoSegmentLength$.next((((p=d==null?void 0:d.endPTS)!=null?p:0)-((h=d==null?void 0:d.startPTS)!=null?h:0))*1e3),t.currentAudioSegmentLength$.next((((m=c==null?void 0:c.endPTS)!=null?m:0)-((g=c==null?void 0:c.startPTS)!=null?g:0))*1e3)}),this.subscription.add(Yt(e.autoVideoTrackSwitching,()=>this.hls.autoLevelEnabled,l=>{this.hls.nextLevel=l?-1:this.hls.currentLevel,this.hls.loadLevel=l?-1:this.hls.loadLevel},{onError:r}));let n=l=>{var d;return(d=Array.from(this.trackLevels.values()).find(({level:c})=>c===l))==null?void 0:d.track},o=ni(this.hls,ot.Events.LEVEL_SWITCHED).pipe((0,z.map)(({level:l})=>n(this.hls.levels[l])));o.pipe((0,z.filter)(z.isNonNullable)).subscribe(t.currentVideoTrack$,r),this.subscription.add(Yt(e.videoTrack,()=>n(this.hls.levels[this.hls.currentLevel]),l=>{var m;if((0,z.isNullable)(l))return;let d=(m=this.trackLevels.get(l.id))==null?void 0:m.level;if(!d)return;let c=this.hls.levels.indexOf(d),p=this.hls.currentLevel,h=this.hls.levels[p];!h||d.bitrate>h.bitrate?this.hls.nextLevel=c:(this.hls.loadLevel=c,this.hls.loadLevel=c)},{changed$:o,onError:r})),s(i.progress$,()=>{this.params.dependencies.throughputEstimator.addRawThroughput(this.hls.bandwidthEstimate/1e3)}),this.textTracksManager.connect(this.video,e,t);let u=(0,z.merge)(e.playbackState.stateChangeStarted$,e.videoTrack.stateChangeStarted$,e.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,(0,z.observableFrom)(["init"])).pipe((0,z.debounce)(0));this.subscription.add(u.subscribe(this.syncPlayback,r))}prepare(){this.videoState.startTransitionTo("ready"),this.hls.attachMedia(this.video),this.hls.loadSource(this.params.source.url)}playIfAllowed(){return O(this,null,function*(){this.videoState.startTransitionTo("playing"),(yield Oe(this.video,()=>{this.params.output.soundProhibitedEvent$.next()}).catch(t=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:z.ErrorCategory.DOM,thrown:t})))||(this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused",!0))})}pause(){this.videoState.startTransitionTo("paused"),this.video.paused?this.videoState.setState("paused"):this.video.pause()}seek(e){this.params.output.willSeekEvent$.next(),this.video.currentTime=e/1e3}stop(){this.params.output.position$.next(0),this.params.output.duration$.next(1/0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.hls.stopLoad(),this.hls.detachMedia(),this.video.removeAttribute("src"),this.video.load(),this.videoState.setState("stopped"),k(this.params.desiredState.playbackState,"stopped",!0)}};var Gv="X-Playback-Duration",nl=a=>O(void 0,null,function*(){var i;let e=yield kt(a),t=yield e.text(),r=(i=/#EXT-X-VK-PLAYBACK-DURATION:(\d+)/m.exec(t))==null?void 0:i[1];return r?parseInt(r,10):e.headers.has(Gv)?parseInt(e.headers.get(Gv),10):void 0});var G=require("@vkontakte/videoplayer-shared/es2015");var ul=X($o(),1);var fn=require("@vkontakte/videoplayer-shared/es2015");var JR=a=>{let e=null;if(a.QUALITY&&(e=zt(a.QUALITY)),!e&&a.RESOLUTION){let[t,r]=a.RESOLUTION.split("x").map(i=>parseInt(i,10));e=(0,fn.videoSizeToQuality)({width:t,height:r})}return e!=null?e:null},XR=(a,e)=>{var s,n;let t=a.split(`
123
+ `;var hn=class{constructor(e,t,r){this.videoInitialized=!1;this.active=!1;this.container=e,this.sourceVideoElement=t,this.params=r,this.canvas=this.createCanvas();let i=this.canvas.getContext("webgl");if(!i)throw new Error("Could not initialize WebGL context");this.gl=i,this.container.appendChild(this.canvas),this.camera=new dn(this.params.fov,this.params.orientation),this.cameraRotationManager=new pn(this.camera,{rotationSpeed:this.params.rotationSpeed,maxYawAngle:this.params.maxYawAngle,rotationSpeedCorrection:this.params.rotationSpeedCorrection,degreeToPixelCorrection:this.params.degreeToPixelCorrection,speedFadeTime:this.params.speedFadeTime,speedFadeThreshold:this.params.speedFadeThreshold}),this.updateFrameSize(),this.vertexBuffer=this.createVertexBuffer(),this.textureMappingBuffer=this.createTextureMappingBuffer(),this.updateTextureMappingBuffer(),this.program=this.createProgram(),this.videoTexture=this.createTexture(),this.gl.useProgram(this.program),this.videoElementDataLoadedFn=this.onDataLoadedHandler.bind(this),this.renderFn=this.render.bind(this)}play(){this.active||(this.videoInitialized?this.doPlay():this.sourceVideoElement.readyState>=2?(this.videoInitialized=!0,this.doPlay()):this.sourceVideoElement.addEventListener("loadeddata",this.videoElementDataLoadedFn))}stop(){this.active=!1}startCameraManualRotation(e,t){this.cameraRotationManager.setRotationSpeed(e*this.params.rotationSpeed,t*this.params.rotationSpeed,0),this.cameraRotationManager.startRotation()}stopCameraManualRotation(e=!1){this.cameraRotationManager.stopRotation(e)}turnCamera(e,t){this.cameraRotationManager.turnCamera(e,t)}pointCameraTo(e,t){this.cameraRotationManager.pointCameraTo(e,t)}pixelToDegree(e){return{x:this.params.degreeToPixelCorrection*this.params.fov.x*-e.x/this.viewportWidth,y:this.params.degreeToPixelCorrection*this.params.fov.y*e.y/this.viewportHeight}}getCameraRotation(){return this.camera.orientation}holdCamera(){this.cameraRotationManager.stopRotation(!0)}releaseCamera(){this.cameraRotationManager.onCameraRelease()}destroy(){this.sourceVideoElement.removeEventListener("loadeddata",this.videoElementDataLoadedFn),this.stop(),this.canvas.remove()}setViewportSize(e,t){this.viewportWidth=e,this.viewportHeight=t,this.canvas.width=this.viewportWidth,this.canvas.height=this.viewportHeight,this.gl.viewport(0,0,this.canvas.width,this.canvas.height)}onDataLoadedHandler(){this.videoInitialized=!0,this.doPlay()}doPlay(){this.updateFrameSize(),this.vertexBuffer=this.createVertexBuffer(),this.active=!0,this.sourceVideoElement.removeEventListener("loadeddata",this.videoElementDataLoadedFn),requestAnimationFrame(this.renderFn)}render(e){this.cameraRotationManager.tick(e),this.updateTexture(),this.updateTextureMappingBuffer();let t=this.gl.getAttribLocation(this.program,"a_vertex"),r=this.gl.getAttribLocation(this.program,"a_texel"),i=this.gl.getUniformLocation(this.program,"u_texture"),s=this.gl.getUniformLocation(this.program,"u_focus");this.gl.enableVertexAttribArray(t),this.gl.enableVertexAttribArray(r),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuffer),this.gl.vertexAttribPointer(t,2,this.gl.FLOAT,!1,0,0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.textureMappingBuffer),this.gl.vertexAttribPointer(r,2,this.gl.FLOAT,!1,0,0),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.videoTexture),this.gl.uniform1i(i,0),this.gl.uniform2f(s,-this.camera.orientation.x,-this.camera.orientation.y),this.gl.drawArrays(this.gl.TRIANGLE_FAN,0,4),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.disableVertexAttribArray(t),this.gl.disableVertexAttribArray(r),this.active&&requestAnimationFrame(this.renderFn)}createShader(e,t){let r=this.gl.createShader(t);if(!r)throw this.destroy(),new Error(`Could not create shader (${t})`);if(this.gl.shaderSource(r,e),this.gl.compileShader(r),!this.gl.getShaderParameter(r,this.gl.COMPILE_STATUS))throw this.destroy(),new Error("An error occurred while compiling the shader: "+this.gl.getShaderInfoLog(r));return r}createProgram(){let e=this.gl.createProgram();if(!e)throw this.destroy(),new Error("Could not create shader program");let t=this.createShader(Fv,this.gl.VERTEX_SHADER),r=this.createShader(qv,this.gl.FRAGMENT_SHADER);if(this.gl.attachShader(e,t),this.gl.attachShader(e,r),this.gl.linkProgram(e),!this.gl.getProgramParameter(e,this.gl.LINK_STATUS))throw this.destroy(),new Error("Could not link shader program.");return e}createTexture(){let e=this.gl.createTexture();if(!e)throw this.destroy(),new Error("Could not create texture");return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.bindTexture(this.gl.TEXTURE_2D,null),e}updateTexture(){this.gl.bindTexture(this.gl.TEXTURE_2D,this.videoTexture),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!0),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,this.sourceVideoElement),this.gl.bindTexture(this.gl.TEXTURE_2D,null)}createVertexBuffer(){let e=this.gl.createBuffer();if(!e)throw this.destroy(),new Error("Could not create vertex buffer");let t=1,r=1,i=this.frameHeight/(this.frameWidth/this.viewportWidth);return i>this.viewportHeight?t=this.viewportHeight/i:r=i/this.viewportHeight,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,e),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([-t,-r,t,-r,t,r,-t,r]),this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),e}createTextureMappingBuffer(){let e=this.gl.createBuffer();if(!e)throw this.destroy(),new Error("Could not create texture mapping buffer");return e}calculateTexturePosition(){let e=.5-this.camera.orientation.x/360,t=.5-this.camera.orientation.y/180,r=this.camera.fov.x/360/2,i=this.camera.fov.y/180/2,s=e-r,n=t-i,o=e+r,u=t-i,l=e+r,d=t+i,c=e-r,p=t+i;return[s,n,o,u,l,d,c,p]}updateTextureMappingBuffer(){this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.textureMappingBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([...this.calculateTexturePosition()]),this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null)}updateFrameSize(){this.frameWidth=this.sourceVideoElement.videoWidth,this.frameHeight=this.sourceVideoElement.videoHeight}createCanvas(){let e=document.createElement("canvas");return e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.width="100%",e.style.height="100%",e}};var Te=require("@vkontakte/videoplayer-shared/es2015"),sl=class{constructor(){this.isSeeked$=new Te.ValueSubject(!1);this.isBuffering$=new Te.ValueSubject(!1);this.currentStallsCount=0;this.maxQualityLimit=void 0;this.lastUniqueVideoTrackSelectedTimestamp=0;this.predictedThroughputWithoutData=0;this.subscription=new Te.Subscription}connect(e){this.currentStallDuration$=e.currentStallDuration$,this.videoLastDataObtainedTimestamp$=e.videoLastDataObtainedTimestamp$,this.throughput$=e.throughput$,this.rtt$=e.rtt$,this.qualityLimitsOnStall=e.qualityLimitsOnStall,this.subscription.add(e.isSeeked$.subscribe(this.isSeeked$)),this.subscription.add(e.isBuffering$.subscribe(this.isBuffering$)),this.subscription.add((0,Te.combine)({isBuffering:this.isBuffering$,isSeeked:this.isSeeked$}).pipe((0,Te.filter)(({isBuffering:t,isSeeked:r})=>t&&!r)).subscribe(()=>{this.currentStallsCount++})),this.subscription.add((0,Te.combine)({currentStallDuration:this.currentStallDuration$,isSeeked:this.isSeeked$}).subscribe(({currentStallDuration:t,isSeeked:r})=>{if((0,Te.isNullable)(this.lastUniqueVideoTrackSelected))return;let{stallDurationBeforeQualityDecrease:i,stallDurationNoDataBeforeQualityDecrease:s,stallCountBeforeQualityDecrease:n,resetQualityRestrictionTimeout:o}=this.qualityLimitsOnStall,u=this.rtt$.getValue(),l=this.throughput$.getValue(),d=this.videoLastDataObtainedTimestamp$.getValue(),c=(0,Te.now)(),p=n&&this.currentStallsCount>=n,h=i&&!r&&c-this.lastUniqueVideoTrackSelectedTimestamp>=i+u&&t>=i,m=s&&c-this.lastUniqueVideoTrackSelectedTimestamp>=s+u&&c-d>=s+u&&t>=s;(p||h||m)&&(window.clearTimeout(this.qualityRestrictionTimer),this.maxQualityLimit=this.lastUniqueVideoTrackSelected.quality,(0,Te.isNonNullable)(this.lastUniqueVideoTrackSelected.bitrate)&&l>this.lastUniqueVideoTrackSelected.bitrate&&(this.predictedThroughputWithoutData=this.lastUniqueVideoTrackSelected.bitrate)),t||(window.clearTimeout(this.qualityRestrictionTimer),this.qualityRestrictionTimer=window.setTimeout(()=>{this.maxQualityLimit=void 0,this.predictedThroughputWithoutData=0},o))}))}get videoMaxQualityLimit(){return this.maxQualityLimit}get predictedThroughput(){return this.predictedThroughputWithoutData}set lastVideoTrackSelected(e){var t;((t=this.lastUniqueVideoTrackSelected)==null?void 0:t.id)!==e.id&&(this.lastUniqueVideoTrackSelected=e,this.lastUniqueVideoTrackSelectedTimestamp=(0,Te.now)(),this.currentStallsCount=0)}destroy(){window.clearTimeout(this.qualityRestrictionTimer),this.subscription.unsubscribe()}},Uv=sl;var Tr=class{constructor(e){this.subscription=new V.Subscription;this.videoState=new j("stopped");this.elementSize$=new V.ValueSubject(void 0);this.textTracksManager=new ze;this.droppedFramesManager=new Hs;this.stallsManager=new Uv;this.videoTracksMap=new Map;this.audioTracksMap=new Map;this.textTracksMap=new Map;this.videoStreamsMap=new Map;this.audioStreamsMap=new Map;this.videoTrackSwitchHistory=new Ui;this.audioTrackSwitchHistory=new Ui;this.syncPlayback=()=>{var n,o,u;let e=this.videoState.getState(),t=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),i=this.params.desiredState.seekState.getState();if(!this.videoState.getTransition()){if(i.state==="requested"&&(r==null?void 0:r.to)!=="paused"&&e!=="stopped"&&t!=="stopped"){let l=(o=(n=this.liveOffset)==null?void 0:n.getTotalPausedTime())!=null?o:0;this.seek(i.position-l,i.forcePrecise)}if(t==="stopped"){e!=="stopped"&&(this.videoState.startTransitionTo("stopped"),this.player.stop(),this.video.removeAttribute("src"),this.video.load(),this.params.output.position$.next(0),this.params.output.duration$.next(1/0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.videoState.setState("stopped"),k(this.params.desiredState.playbackState,"stopped",!0));return}switch(e){case"stopped":this.videoState.startTransitionTo("ready"),this.prepare();return;case"ready":t==="paused"?(this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused")):t==="playing"?(this.videoState.startTransitionTo("playing"),this.playIfAllowed()):(r==null?void 0:r.to)==="ready"&&k(this.params.desiredState.playbackState,"ready");return;case"playing":t==="paused"?(this.videoState.startTransitionTo("paused"),(u=this.liveOffset)==null||u.pause(),this.video.paused?this.videoState.setState("paused"):this.video.pause()):(r==null?void 0:r.to)==="playing"&&k(this.params.desiredState.playbackState,"playing");return;case"paused":t==="playing"?(this.videoState.startTransitionTo("playing"),this.liveOffset?this.liveOffset.getTotalOffset()/1e3<Math.abs(this.params.output.duration$.getValue())?(this.liveOffset.resume(),this.playIfAllowed(),this.params.output.position$.next(-this.liveOffset.getTotalOffset()/1e3)):this.seek(0,!1):this.playIfAllowed()):(r==null?void 0:r.to)==="paused"&&k(this.params.desiredState.playbackState,"paused");return;default:return(0,V.assertNever)(e)}}};this.init3DScene=e=>{var r,i,s;if(this.scene3D)return;this.scene3D=new hn(this.params.container,this.video,{fov:this.params.tuning.spherical.fov,orientation:this.params.tuning.spherical.orientation||{x:((r=e.projectionData)==null?void 0:r.pose.yaw)||0,y:((i=e.projectionData)==null?void 0:i.pose.pitch)||0,z:((s=e.projectionData)==null?void 0:s.pose.roll)||0},rotationSpeed:this.params.tuning.spherical.rotationSpeed,maxYawAngle:this.params.tuning.spherical.maxYawAngle,rotationSpeedCorrection:this.params.tuning.spherical.rotationSpeedCorrection,degreeToPixelCorrection:this.params.tuning.spherical.degreeToPixelCorrection,speedFadeTime:this.params.tuning.spherical.speedFadeTime,speedFadeThreshold:this.params.tuning.spherical.speedFadeThreshold});let t=this.elementSize$.getValue();t&&this.scene3D.setViewportSize(t.width,t.height)};this.destroy3DScene=()=>{this.scene3D&&(this.scene3D.destroy(),this.scene3D=void 0)};this.params=e,this.video=Le(e.container,e.tuning),this.tracer=e.dependencies.tracer.createComponentTracer(this.constructor.name),this.params.output.element$.next(this.video),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.hostname$.next(Se(this.params.source.url)),this.params.output.isLive$.next(!1),this.params.output.autoVideoTrackLimitingAvailable$.next(!0),this.params.output.availableTextTracks$.next([]),this.params.desiredState.internalTextTracks.setState([]),this.player=new cn({throughputEstimator:this.params.dependencies.throughputEstimator,tuning:this.params.tuning,compatibilityMode:this.params.source.compatibilityMode,tracer:this.tracer}),this.subscribe()}getProviderSubscriptionInfo(){let{output:e,desiredState:t}=this.params,r=De(this.video),i=this.constructor.name,s=o=>{e.error$.next({id:i,category:V.ErrorCategory.WTF,message:`${i} internal logic error`,thrown:o})};return{output:e,desiredState:t,observableVideo:r,genericErrorListener:s,connect:(o,u)=>this.subscription.add(o.subscribe(u,s))}}subscribe(){var d;let{output:e,desiredState:t,observableVideo:r,genericErrorListener:i,connect:s}=this.getProviderSubscriptionInfo();this.subscription.add(this.params.output.availableVideoTracks$.pipe((0,V.filter)(c=>!!c.length),(0,V.once)()).subscribe(c=>{this.droppedFramesManager.connect({logger:this.params.dependencies.logger,video:this.video,droppedFramesChecker:this.params.tuning.droppedFramesChecker,isAuto:this.params.desiredState.autoVideoTrackSwitching,playing$:r.playing$,pause$:r.pause$,tracks:c})}));let n=this.params.desiredState.seekState.stateChangeEnded$.pipe((0,V.map)(c=>c.to.state!=="none"),(0,V.filterChanged)());this.stallsManager.connect({isSeeked$:n,currentStallDuration$:this.player.currentStallDuration$.pipe((0,V.filterChanged)()),videoLastDataObtainedTimestamp$:this.player.videoLastDataObtainedTimestamp$,throughput$:this.params.dependencies.throughputEstimator.throughput$,rtt$:this.params.dependencies.throughputEstimator.rtt$,qualityLimitsOnStall:this.params.tuning.dash.qualityLimitsOnStall,isBuffering$:r.isBuffering$}),s(r.ended$,e.endedEvent$),s(r.looped$,e.loopedEvent$),s(r.error$,e.error$),s(r.isBuffering$,e.isBuffering$),s(r.currentBuffer$,e.currentBuffer$),s(r.playing$,e.firstFrameEvent$),s(r.canplay$,e.canplay$),s(r.inPiP$,e.inPiP$),s(r.inFullscreen$,e.inFullscreen$),s(r.loadedMetadata$,e.loadedMetadataEvent$),s(this.player.error$,e.error$),s(this.player.lastConnectionType$,e.httpConnectionType$),s(this.player.lastConnectionReused$,e.httpConnectionReused$),s(this.player.isLive$,e.isLive$),s(this.player.lastRequestFirstBytes$.pipe((0,V.filter)(V.isNonNullable),(0,V.once)()),e.firstBytesEvent$),s(this.videoState.stateChangeEnded$.pipe((0,V.map)(c=>c.to)),this.params.output.playbackState$),this.subscription.add(r.seeked$.subscribe(e.seekedEvent$,i)),this.subscription.add(mt(this.video,t.isLooped,i)),this.subscription.add(Ce(this.video,t.volume,r.volumeState$,i)),this.subscription.add(r.volumeState$.subscribe(this.params.output.volume$,i)),this.subscription.add(Ye(this.video,t.playbackRate,r.playbackRateState$,i)),s((0,V.observeElementSize)(this.video),this.elementSize$),s(Ke(this.video,{threshold:this.params.tuning.autoTrackSelection.activeVideoAreaThreshold}),e.elementVisible$),this.subscription.add(r.playing$.subscribe(()=>{this.videoState.setState("playing"),k(t.playbackState,"playing"),this.scene3D&&this.scene3D.play()},i)).add(r.pause$.subscribe(()=>{this.videoState.setState("paused"),k(t.playbackState,"paused")},i)).add(r.canplay$.subscribe(()=>{this.videoState.getState()==="playing"&&this.playIfAllowed()},i)),this.subscription.add(this.player.state$.stateChangeEnded$.subscribe(({to:c})=>{if(c==="manifest_ready"){this.videoTracksMap=new Map,this.audioTracksMap=new Map,this.textTracksMap=new Map;let p=this.player.getStreams();if((0,V.assertNonNullable)(p,"Manifest not loaded or empty"),!this.params.tuning.isAudioDisabled){let m=[];for(let g of p.audio){m.push(Zu(g));let v=[];for(let I of g.representations){let T=Mv(I);v.push(T),this.audioTracksMap.set(T,{stream:g,representation:I})}this.audioStreamsMap.set(g,v)}this.params.output.availableAudioStreams$.next(m)}let h=[];for(let m of p.video){h.push(el(m));let g=[];for(let v of m.representations){let I=Lv(H(R({},v),{streamId:m.id}));I&&(g.push(I),this.videoTracksMap.set(I,{stream:m,representation:v}))}this.videoStreamsMap.set(m,g)}if(this.params.output.availableVideoStreams$.next(h),this.textTracksManager)for(let m of p.text)for(let g of m.representations){let v=Cv(m,g);this.textTracksMap.set(v,{stream:m,representation:g})}this.params.output.availableVideoTracks$.next(Array.from(this.videoTracksMap.keys())),this.params.output.availableAudioTracks$.next(Array.from(this.audioTracksMap.keys())),this.params.output.isAudioAvailable$.next(!!this.audioTracksMap.size),this.audioTracksMap.size&&this.textTracksMap.size&&this.params.desiredState.internalTextTracks.startTransitionTo(Array.from(this.textTracksMap.keys()))}else c==="representations_ready"&&(this.videoState.setState("ready"),this.player.initBuffer())},i));let o=c=>e.error$.next({id:"RepresentationSwitch",category:V.ErrorCategory.WTF,message:"Switching representations threw",thrown:c});this.subscription.add((0,V.merge)(this.player.currentStallDuration$,this.player.state$.stateChangeEnded$,t.videoTrack.stateChangeStarted$,t.autoVideoTrackSwitching.transitionStarted$,this.params.dependencies.throughputEstimator.rttAdjustedThroughput$,t.autoVideoTrackLimits.stateChangeStarted$,t.videoStream.stateChangeStarted$,t.audioStream.stateChangeStarted$,this.elementSize$,this.params.output.elementVisible$,this.droppedFramesManager.onDroopedVideoFramesLimit$,(0,V.fromEvent)(this.video,"progress")).subscribe(()=>{let c=this.player.state$.getState(),p=this.player.state$.getTransition();if(!(0,Hv.default)(["manifest_ready","running"],c)||p)return;t.autoVideoTrackSwitching.getTransition()&&t.autoVideoTrackSwitching.setState(t.autoVideoTrackSwitching.getState());let h=this.selectVideoAudioRepresentations();if(!h)return;let[m,g]=h,v=[...this.videoTracksMap.keys()].find(T=>{var x;return((x=this.videoTracksMap.get(T))==null?void 0:x.representation.id)===m.id});(0,V.isNonNullable)(v)&&(this.stallsManager.lastVideoTrackSelected=v);let I=this.params.desiredState.autoVideoTrackLimits.getTransition();if(I&&this.params.output.autoVideoTrackLimits$.next(I.to),c==="manifest_ready")this.player.initRepresentations(m.id,g==null?void 0:g.id,this.params.sourceHls);else if(this.player.switchRepresentation("video",m.id).catch(o),g){let T=!!t.audioStream.getTransition();this.player.switchRepresentation("audio",g.id,T).catch(o)}},i)),this.subscription.add(t.cameraOrientation.stateChangeEnded$.subscribe(({to:c})=>{this.scene3D&&c&&this.scene3D.pointCameraTo(c.x,c.y)})),this.subscription.add(this.elementSize$.subscribe(c=>{this.scene3D&&c&&this.scene3D.setViewportSize(c.width,c.height)})),this.subscription.add(this.player.currentVideoRepresentation$.pipe((0,V.filterChanged)()).subscribe(c=>{let p=[...this.videoTracksMap.entries()].find(([,{representation:v}])=>v.id===c);if(!p){e.currentVideoTrack$.next(void 0),e.currentVideoStream$.next(void 0);return}let[h,{stream:m}]=p,g=this.params.desiredState.videoStream.getTransition();g&&g.to&&g.to.id===m.id&&this.params.desiredState.videoStream.setState(g.to),e.currentVideoTrack$.next(h),e.currentVideoStream$.next(el(m))},i)),this.subscription.add(this.player.currentAudioRepresentation$.pipe((0,V.filterChanged)()).subscribe(c=>{let p=[...this.audioTracksMap.entries()].find(([,{representation:v}])=>v.id===c);if(!p){e.currentAudioStream$.next(void 0);return}let[h,{stream:m}]=p,g=this.params.desiredState.audioStream.getTransition();g&&g.to&&g.to.id===m.id&&this.params.desiredState.audioStream.setState(g.to),e.currentAudioStream$.next(Zu(m))},i)),this.subscription.add(this.player.currentVideoRepresentationInit$.subscribe(c=>{var p,h;if(c!=null&&c.is3dVideo&&((p=this.params.tuning.spherical)!=null&&p.enabled))try{this.init3DScene(c),e.is3DVideo$.next(!0)}catch(m){e.warning$.next({id:"DashProvider",message:`DashProvider could not initialize 3D-scene: ${m}`})}else this.destroy3DScene(),(h=this.params.tuning.spherical)!=null&&h.enabled&&e.is3DVideo$.next(!1)},i)),this.subscription.add(this.player.currentVideoSegmentLength$.subscribe(e.currentVideoSegmentLength$,i)),this.subscription.add(this.player.currentAudioSegmentLength$.subscribe(e.currentAudioSegmentLength$,i)),(d=this.textTracksManager)==null||d.connect(this.video,t,e);let u=t.playbackState.stateChangeStarted$.pipe((0,V.map)(({to:c})=>c==="ready"),(0,V.filterChanged)());this.subscription.add((0,V.merge)(u,t.autoVideoTrackSwitching.stateChangeStarted$,this.player.state$.stateChangeEnded$).subscribe(()=>{let c=t.autoVideoTrackSwitching.getState(),h=t.playbackState.getState()==="ready"?this.params.tuning.dash.forwardBufferTargetPreload:c?this.params.tuning.dash.forwardBufferTargetAuto:this.params.tuning.dash.forwardBufferTargetManual;this.player.setBufferTarget(h)})),this.subscription.add((0,V.merge)(u,this.player.state$.stateChangeEnded$).subscribe(()=>this.player.setPreloadOnly(t.playbackState.getState()==="ready")));let l=(0,V.merge)(t.playbackState.stateChangeStarted$,t.videoTrack.stateChangeStarted$,t.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,(0,V.observableFrom)(["init"])).pipe((0,V.debounce)(0));this.subscription.add(l.subscribe(this.syncPlayback,i))}selectVideoAudioRepresentations(){var F,Q,oe,J,W,te,_,ie,U,ne,$,P,K;let{desiredState:e,output:t}=this.params,r=e.autoVideoTrackSwitching.getState(),i=(F=e.videoTrack.getState())==null?void 0:F.id,n=[...this.videoTracksMap.keys()].find(({id:Y})=>Y===i),o=t.currentVideoTrack$.getValue(),u=((J=(oe=e.videoStream.getState())!=null?oe:n&&((Q=this.videoTracksMap.get(n))==null?void 0:Q.stream))!=null?J:this.videoStreamsMap.size===1)?this.videoStreamsMap.keys().next().value:void 0;if(!u)return;let l=[...this.videoStreamsMap.keys()].find(({id:Y})=>Y===u.id),d=l&&this.videoStreamsMap.get(l);if(!d)return;let c=gt(this.video.buffered,this.video.currentTime*1e3),p=r?this.params.tuning.dash.forwardBufferTargetAuto:this.params.tuning.dash.forwardBufferTargetManual,h=Math.min(c/Math.min(p,(this.video.duration*1e3||1/0)-this.video.currentTime*1e3),1),m=(W=e.audioStream.getState())!=null?W:this.audioStreamsMap.size===1?this.audioStreamsMap.keys().next().value:void 0,g=(te=[...this.audioStreamsMap.keys()].find(({id:Y})=>Y===(m==null?void 0:m.id)))!=null?te:this.audioStreamsMap.keys().next().value,v=0;if(g){if(n&&!r){let Y=qs(n,d,(_=this.audioStreamsMap.get(g))!=null?_:[],this.params.tuning.autoTrackSelection.minVideoAudioRatio);v=Math.max(v,(ie=Y==null?void 0:Y.bitrate)!=null?ie:-1/0)}if(o){let Y=qs(o,d,(U=this.audioStreamsMap.get(g))!=null?U:[],this.params.tuning.autoTrackSelection.minVideoAudioRatio);v=Math.max(v,(ne=Y==null?void 0:Y.bitrate)!=null?ne:-1/0)}}let I=Jt(d,{container:this.elementSize$.getValue(),estimatedThroughput:this.params.dependencies.throughputEstimator.rttAdjustedThroughput$.getValue(),tuning:this.params.tuning.autoTrackSelection,limits:this.params.desiredState.autoVideoTrackLimits.getState(),reserve:v,forwardBufferHealth:h,current:o,visible:this.params.output.elementVisible$.getValue(),history:this.videoTrackSwitchHistory,playbackRate:this.video.playbackRate,droppedVideoMaxQualityLimit:this.droppedFramesManager.droppedVideoMaxQualityLimit,stallsVideoMaxQualityLimit:this.stallsManager.videoMaxQualityLimit,stallsPredictedThroughput:this.stallsManager.predictedThroughput,abrLogger:this.params.dependencies.abrLogger}),T=r?I!=null?I:n:n!=null?n:I,x=g&&pb(T,d,($=this.audioStreamsMap.get(g))!=null?$:[],{estimatedThroughput:this.params.dependencies.throughputEstimator.rttAdjustedThroughput$.getValue(),stallsPredictedThroughput:this.stallsManager.predictedThroughput,tuning:this.params.tuning.autoTrackSelection,forwardBufferHealth:h,history:this.audioTrackSwitchHistory,playbackRate:this.video.playbackRate,abrLogger:this.params.dependencies.abrLogger}),A=(P=this.videoTracksMap.get(T))==null?void 0:P.representation,w=x&&((K=this.audioTracksMap.get(x))==null?void 0:K.representation);if(A&&w)return[A,w];if(A&&!w&&this.audioTracksMap.size===0)return[A,void 0]}prepare(e=0){this.player.initManifest(this.video,this.params.source.url,e)}playIfAllowed(){Oe(this.video,()=>{this.params.output.soundProhibitedEvent$.next()}).then(e=>{var t;e||((t=this.liveOffset)==null||t.pause(),this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused",!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:V.ErrorCategory.DOM,thrown:e}))}destroy(){var e;this.subscription.unsubscribe(),this.droppedFramesManager.destroy(),this.stallsManager.destroy(),this.destroy3DScene(),(e=this.textTracksManager)==null||e.destroy(),this.player.destroy(),this.params.output.element$.next(void 0),Me(this.video),this.tracer.end()}};var Ra=class extends Tr{subscribe(){super.subscribe();let{output:e,observableVideo:t,connect:r}=this.getProviderSubscriptionInfo();r(t.timeUpdate$,e.position$),r(t.durationChange$,e.duration$)}seek(e,t){this.params.output.willSeekEvent$.next(),this.player.seek(e,t)}};var tr=require("@vkontakte/videoplayer-shared/es2015");var $a=class extends Tr{constructor(e){super(e),this.liveOffset=new Pt,this.textTracksManager=null}subscribe(){super.subscribe();let{output:e,observableVideo:t,desiredState:r,connect:i}=this.getProviderSubscriptionInfo();this.params.output.position$.next(0),this.params.output.isLive$.next(!0),i(t.timeUpdate$,e.liveBufferTime$),i(this.player.liveDuration$,e.duration$),i(this.player.liveLatency$,e.liveLatency$),this.subscription.add(r.isLowLatency.stateChangeEnded$.pipe((0,tr.map)(s=>s.to)).subscribe(this.player.isLowLatency$)).add(this.params.output.position$.subscribe(this.player.livePositionFromPlayer$)).add((0,tr.combine)({interval:(0,tr.interval)(1e3),playbackRate:t.playbackRateState$}).subscribe(({playbackRate:s})=>{var n;if(this.videoState.getState()==="playing"){let o=e.position$.getValue()+(s-1);o<=0&&e.position$.next(o),(n=this.liveOffset)==null||n.resetTo(-o*1e3)}})).add((0,tr.combine)({liveBufferTime:e.liveBufferTime$,liveAvailabilityStartTime:this.player.liveAvailabilityStartTime$}).pipe((0,tr.map)(({liveBufferTime:s,liveAvailabilityStartTime:n})=>s&&n?s+n:void 0)).subscribe(e.liveTime$)).add(this.player.currentLiveTextRepresentation$.subscribe(s=>{if(s){let n=Dv(s);this.params.output.availableTextTracks$.next([n])}}))}seek(e){this.params.output.willSeekEvent$.next();let t=this.params.desiredState.playbackState.getState(),r=this.videoState.getState(),i=t==="paused"&&r==="paused",s=-e,n=Math.trunc(s/1e3<=Math.abs(this.params.output.duration$.getValue())?s:0);this.player.seekLive(n).then(()=>{var o;this.params.output.position$.next(e/1e3),(o=this.liveOffset)==null||o.resetTo(n,i)})}};var jv=X(Bs(),1);var z=require("@vkontakte/videoplayer-shared/es2015");var ot={};var ni=(a,e)=>new z.Observable(t=>{let r=(i,s)=>t.next(s);return a.on(e,r),()=>a.off(e,r)}),La=class{constructor(e){this.subscription=new z.Subscription;this.videoState=new j("initializing");this.textTracksManager=new ze;this.trackLevels=new Map;this.syncPlayback=()=>{let e=this.videoState.getState(),t=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition(),i=this.params.desiredState.seekState.getState();if(e!=="initializing")switch((r==null?void 0:r.to)!=="paused"&&i.state==="requested"&&this.seek(i.position),t){case"stopped":switch(e){case"stopped":break;case"ready":case"playing":case"paused":this.stop();break;default:(0,z.assertNever)(e)}break;case"ready":switch(e){case"stopped":this.prepare();break;case"ready":case"playing":case"paused":break;default:(0,z.assertNever)(e)}break;case"playing":switch(e){case"playing":break;case"stopped":this.prepare();break;case"ready":case"paused":this.playIfAllowed();break;default:(0,z.assertNever)(e)}break;case"paused":switch(e){case"paused":break;case"stopped":this.prepare();break;case"ready":this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused");break;case"playing":this.pause();break;default:(0,z.assertNever)(e)}break;default:(0,z.assertNever)(t)}};this.video=Le(e.container,e.tuning),this.params=e,this.params.output.element$.next(this.video),this.params.output.isLive$.next(!1),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.hostname$.next(Se(this.params.source.url)),this.loadHlsJs()}destroy(){var e,t;this.subscription.unsubscribe(),this.trackLevels.clear(),this.textTracksManager.destroy(),(e=this.hls)==null||e.detachMedia(),(t=this.hls)==null||t.destroy(),this.params.output.element$.next(void 0),Me(this.video)}loadHlsJs(){let e=!1,t=i=>{e||this.params.output.error$.next({id:i==="timeout"?"HlsJsTimeout":"HlsJsLoadError",category:z.ErrorCategory.NETWORK,message:"Failed to load Hls.js",thrown:i}),e=!0},r=window.setTimeout(()=>t("timeout"),this.params.tuning.dynamicImportTimeout);(0,jv.default)(import("hls.js").then(i=>{e||(ot.Hls=i.default,ot.Events=i.default.Events,this.init())},t),()=>{window.clearTimeout(r),e=!0})}init(){(0,z.assertNonNullable)(ot.Hls,"hls.js not loaded"),this.hls=new ot.Hls({fragLoadingMaxRetry:5,levelLoadingMaxRetry:2,manifestLoadingMaxRetry:2,fragLoadingMaxRetryTimeout:16e3,manifestLoadingMaxRetryTimeout:2e3,levelLoadingMaxRetryTimeout:2e3}),this.subscribe(),this.videoState.setState("stopped")}subscribe(){(0,z.assertNonNullable)(ot.Events,"hls.js not loaded");let{desiredState:e,output:t}=this.params,r=l=>{t.error$.next({id:"HlsJsProvider",category:z.ErrorCategory.WTF,message:"HlsJsProvider internal logic error",thrown:l})},i=De(this.video),s=(l,d)=>this.subscription.add(l.subscribe(d,r));s(i.timeUpdate$,t.position$),s(i.durationChange$,t.duration$),s(i.ended$,t.endedEvent$),s(i.looped$,t.loopedEvent$),s(i.error$,t.error$),s(i.isBuffering$,t.isBuffering$),s(i.currentBuffer$,t.currentBuffer$),s(i.loadStart$,t.firstBytesEvent$),s(i.loadedMetadata$,t.loadedMetadataEvent$),s(i.playing$,t.firstFrameEvent$),s(i.canplay$,t.canplay$),s(i.seeked$,t.seekedEvent$),s(i.inPiP$,t.inPiP$),s(i.inFullscreen$,t.inFullscreen$),this.subscription.add(mt(this.video,e.isLooped,r)),this.subscription.add(Ce(this.video,e.volume,i.volumeState$,r)),this.subscription.add(i.volumeState$.subscribe(this.params.output.volume$)),this.subscription.add(Ye(this.video,e.playbackRate,i.playbackRateState$,r)),s(Ke(this.video),t.elementVisible$),s(this.videoState.stateChangeEnded$.pipe((0,z.map)(l=>l.to)),this.params.output.playbackState$),this.subscription.add(ni(this.hls,ot.Events.ERROR).subscribe(l=>{var d;l.fatal&&t.error$.next({id:["HlsJsFatal",l.type,l.details].join("_"),category:z.ErrorCategory.WTF,message:`HlsJs fatal ${l.type} ${l.details}, ${(d=l.err)==null?void 0:d.message} ${l.reason}`,thrown:l.error})})),this.subscription.add(i.playing$.subscribe(()=>{this.videoState.setState("playing"),k(e.playbackState,"playing")},r)).add(i.pause$.subscribe(()=>{this.videoState.setState("paused"),k(e.playbackState,"paused")},r)).add(i.canplay$.subscribe(()=>{var l;((l=this.videoState.getTransition())==null?void 0:l.to)==="ready"&&this.videoState.setState("ready"),this.videoState.getState()==="playing"&&this.playIfAllowed()},r)),s(ni(this.hls,ot.Events.MANIFEST_PARSED).pipe((0,z.map)(({levels:l})=>l.reduce((d,c)=>{var T,x;let p=c.name||c.height.toString(10),{width:h,height:m}=c,g=(x=zt((T=c.attrs.QUALITY)!=null?T:""))!=null?x:(0,z.videoSizeToQuality)({width:h,height:m});if(!g)return d;let v=c.attrs["FRAME-RATE"]?parseFloat(c.attrs["FRAME-RATE"]):void 0,I={id:p.toString(),quality:g,bitrate:c.bitrate/1e3,size:{width:h,height:m},fps:v};return this.trackLevels.set(p,{track:I,level:c}),d.push(I),d},[]))),t.availableVideoTracks$),s(ni(this.hls,ot.Events.MANIFEST_PARSED),l=>{if(l.subtitleTracks.length>0){let d=[];for(let c of l.subtitleTracks){let p=c.name,h=c.attrs.URI||"",m=c.lang;d.push({id:p,url:h,language:m,type:"internal"})}e.internalTextTracks.startTransitionTo(d)}}),s(ni(this.hls,ot.Events.LEVEL_LOADING).pipe((0,z.map)(({url:l})=>Se(l))),t.hostname$),s(ni(this.hls,ot.Events.FRAG_CHANGED),l=>{var p,h,m,g;let{video:d,audio:c}=l.frag.elementaryStreams;t.currentVideoSegmentLength$.next((((p=d==null?void 0:d.endPTS)!=null?p:0)-((h=d==null?void 0:d.startPTS)!=null?h:0))*1e3),t.currentAudioSegmentLength$.next((((m=c==null?void 0:c.endPTS)!=null?m:0)-((g=c==null?void 0:c.startPTS)!=null?g:0))*1e3)}),this.subscription.add(Yt(e.autoVideoTrackSwitching,()=>this.hls.autoLevelEnabled,l=>{this.hls.nextLevel=l?-1:this.hls.currentLevel,this.hls.loadLevel=l?-1:this.hls.loadLevel},{onError:r}));let n=l=>{var d;return(d=Array.from(this.trackLevels.values()).find(({level:c})=>c===l))==null?void 0:d.track},o=ni(this.hls,ot.Events.LEVEL_SWITCHED).pipe((0,z.map)(({level:l})=>n(this.hls.levels[l])));o.pipe((0,z.filter)(z.isNonNullable)).subscribe(t.currentVideoTrack$,r),this.subscription.add(Yt(e.videoTrack,()=>n(this.hls.levels[this.hls.currentLevel]),l=>{var m;if((0,z.isNullable)(l))return;let d=(m=this.trackLevels.get(l.id))==null?void 0:m.level;if(!d)return;let c=this.hls.levels.indexOf(d),p=this.hls.currentLevel,h=this.hls.levels[p];!h||d.bitrate>h.bitrate?this.hls.nextLevel=c:(this.hls.loadLevel=c,this.hls.loadLevel=c)},{changed$:o,onError:r})),s(i.progress$,()=>{this.params.dependencies.throughputEstimator.addRawThroughput(this.hls.bandwidthEstimate/1e3)}),this.textTracksManager.connect(this.video,e,t);let u=(0,z.merge)(e.playbackState.stateChangeStarted$,e.videoTrack.stateChangeStarted$,e.seekState.stateChangeEnded$,this.videoState.stateChangeEnded$,(0,z.observableFrom)(["init"])).pipe((0,z.debounce)(0));this.subscription.add(u.subscribe(this.syncPlayback,r))}prepare(){this.videoState.startTransitionTo("ready"),this.hls.attachMedia(this.video),this.hls.loadSource(this.params.source.url)}playIfAllowed(){return O(this,null,function*(){this.videoState.startTransitionTo("playing"),(yield Oe(this.video,()=>{this.params.output.soundProhibitedEvent$.next()}).catch(t=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:z.ErrorCategory.DOM,thrown:t})))||(this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused",!0))})}pause(){this.videoState.startTransitionTo("paused"),this.video.paused?this.videoState.setState("paused"):this.video.pause()}seek(e){this.params.output.willSeekEvent$.next(),this.video.currentTime=e/1e3}stop(){this.params.output.position$.next(0),this.params.output.duration$.next(1/0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.hls.stopLoad(),this.hls.detachMedia(),this.video.removeAttribute("src"),this.video.load(),this.videoState.setState("stopped"),k(this.params.desiredState.playbackState,"stopped",!0)}};var Gv="X-Playback-Duration",nl=a=>O(void 0,null,function*(){var i;let e=yield kt(a),t=yield e.text(),r=(i=/#EXT-X-VK-PLAYBACK-DURATION:(\d+)/m.exec(t))==null?void 0:i[1];return r?parseInt(r,10):e.headers.has(Gv)?parseInt(e.headers.get(Gv),10):void 0});var G=require("@vkontakte/videoplayer-shared/es2015");var ul=X($o(),1);var fn=require("@vkontakte/videoplayer-shared/es2015");var JR=a=>{let e=null;if(a.QUALITY&&(e=zt(a.QUALITY)),!e&&a.RESOLUTION){let[t,r]=a.RESOLUTION.split("x").map(i=>parseInt(i,10));e=(0,fn.videoSizeToQuality)({width:t,height:r})}return e!=null?e:null},XR=(a,e)=>{var s,n;let t=a.split(`
124
124
  `),r=[],i=[];for(let o=0;o<t.length;o++){let u=t[o],l=u.match(/^#EXT-X-STREAM-INF:(.+)/),d=u.match(/^#EXT-X-MEDIA:TYPE=SUBTITLES,(.+)/);if(!(!l&&!d)){if(l){let c=(0,ul.default)(l[1].split(",").map(T=>T.split("="))),p=(s=c.QUALITY)!=null?s:`stream-${c.BANDWIDTH}`,h=JR(c),m;c.BANDWIDTH&&(m=parseInt(c.BANDWIDTH,10)/1e3||void 0),!m&&c["AVERAGE-BANDWIDTH"]&&(m=parseInt(c["AVERAGE-BANDWIDTH"],10)/1e3||void 0);let g=c["FRAME-RATE"]?parseFloat(c["FRAME-RATE"]):void 0,v;if(c.RESOLUTION){let[T,x]=c.RESOLUTION.split("x").map(A=>parseInt(A,10));T&&x&&(v={width:T,height:x})}let I=new URL(t[++o],e).toString();h&&r.push({id:p,quality:h,url:I,bandwidth:m,size:v,fps:g})}if(d){let c=(0,ul.default)(d[1].split(",").map(g=>g.split("=")).map(([g,v])=>[g,v.replace(/^"|"$/g,"")])),p=(n=c.URI)==null?void 0:n.replace(/playlist$/,"subtitles.vtt"),h=c.LANGUAGE,m=c.NAME;p&&h&&i.push({type:"internal",id:h,label:m,language:h,url:p,isAuto:!1})}}}if(!r.length)throw new Error("Empty manifest");return{qualityManifests:r,textTracks:i}},ZR=a=>new Promise(e=>{setTimeout(()=>{e()},a)}),ol=0,Qv=(r,...i)=>O(void 0,[r,...i],function*(a,e=a,t){let n=yield(yield kt(a)).text();ol+=1;try{let{qualityManifests:o,textTracks:u}=XR(n,e);return{qualityManifests:o,textTracks:u}}catch(o){if(ol<=t.manifestRetryMaxCount)return yield ZR((0,fn.getExponentialDelay)(ol-1,{start:t.manifestRetryInterval,max:t.manifestRetryMaxInterval})),Qv(a,e,t)}return{qualityManifests:[],textTracks:[]}}),mn=Qv;var Ma=class{constructor(e){this.subscription=new G.Subscription;this.videoState=new j("stopped");this.textTracksManager=new ze;this.manifests$=new G.ValueSubject([]);this.liveOffset=new Pt;this.manifestStartTime$=new G.ValueSubject(void 0);this.syncPlayback=()=>{if(!this.manifests$.getValue().length)return;let t=this.videoState.getState(),r=this.params.desiredState.playbackState.getState(),i=this.params.desiredState.playbackState.getTransition(),s=this.params.desiredState.videoTrack.getTransition(),n=this.params.desiredState.autoVideoTrackSwitching.getTransition(),o=this.params.desiredState.autoVideoTrackLimits.getTransition();if(r==="stopped"){t!=="stopped"&&(this.videoState.startTransitionTo("stopped"),this.video.removeAttribute("src"),this.video.load(),this.params.output.position$.next(0),this.params.output.duration$.next(1/0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.videoState.setState("stopped"),k(this.params.desiredState.playbackState,"stopped",!0));return}if(this.videoState.getTransition())return;let l=this.params.desiredState.seekState.getState();if(t==="stopped"){this.videoState.startTransitionTo("ready"),this.prepare();return}if(s||n||o){let d=this.videoState.getState();this.videoState.setState("changing_manifest"),this.videoState.startTransitionTo(d),this.prepare(),o&&this.params.output.autoVideoTrackLimits$.next(o.to),l.state==="none"&&this.params.desiredState.seekState.setState({state:"requested",position:-this.liveOffset.getTotalOffset(),forcePrecise:!0});return}if((i==null?void 0:i.to)!=="paused"&&l.state==="requested"){this.videoState.startTransitionTo("ready"),this.seek(l.position-this.liveOffset.getTotalPausedTime()),this.prepare();return}switch(t){case"ready":r==="ready"?k(this.params.desiredState.playbackState,"ready"):r==="paused"?(this.videoState.setState("paused"),this.liveOffset.pause(),k(this.params.desiredState.playbackState,"paused")):r==="playing"&&(this.videoState.startTransitionTo("playing"),this.playIfAllowed());return;case"playing":r==="paused"?(this.videoState.startTransitionTo("paused"),this.liveOffset.pause(),this.video.paused?this.videoState.setState("paused"):this.video.pause()):(i==null?void 0:i.to)==="playing"&&k(this.params.desiredState.playbackState,"playing");return;case"paused":if(r==="playing")if(this.videoState.startTransitionTo("playing"),this.liveOffset.getTotalPausedTime()<this.params.config.maxPausedTime&&this.liveOffset.getTotalOffset()<this.maxSeekBackTime$.getValue())this.liveOffset.resume(),this.playIfAllowed(),this.params.output.position$.next(-this.liveOffset.getTotalOffset()/1e3);else{let d=this.liveOffset.getTotalOffset();d>=this.maxSeekBackTime$.getValue()&&(d=0,this.liveOffset.resetTo(d)),this.liveOffset.resume(),this.params.output.position$.next(-d/1e3),this.prepare()}else(i==null?void 0:i.to)==="paused"&&(k(this.params.desiredState.playbackState,"paused"),this.liveOffset.pause());return;case"changing_manifest":break;default:return(0,G.assertNever)(t)}};var t;this.params=e,this.video=Le(e.container,e.tuning),this.params.output.element$.next(this.video),this.masterManifest={id:"master",quality:G.VideoQuality.INVARIANT,url:this.params.source.url},mn(we(this.params.source.url),this.params.source.url,{manifestRetryInterval:this.params.tuning.manifestRetryInterval,manifestRetryMaxInterval:this.params.tuning.manifestRetryMaxInterval,manifestRetryMaxCount:this.params.tuning.manifestRetryMaxCount}).then(({qualityManifests:r})=>{r.length===0&&this.params.output.error$.next({id:"HlsLiveProviderInternal:empty_manifest",category:G.ErrorCategory.WTF,message:"HlsLiveProvider: there are no qualities in manifest"}),this.manifests$.next([this.masterManifest,...r])},r=>this.params.output.error$.next({id:"ExtractHlsQualities",category:G.ErrorCategory.NETWORK,message:"Error fetching manifest and extracting qualities",thrown:r})),this.params.output.isLive$.next(!0),this.params.output.canChangePlaybackSpeed$.next(!1),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.hostname$.next(Se(this.params.source.url)),this.params.output.availableTextTracks$.next([]),this.params.desiredState.internalTextTracks.setState([]),this.maxSeekBackTime$=new G.ValueSubject((t=e.source.maxSeekBackTime)!=null?t:1/0),this.subscribe()}selectManifest(){var u,l,d,c;let{autoVideoTrackSwitching:e,videoTrack:t}=this.params.desiredState,r=e.getState(),i=t.getTransition(),s=(c=(d=(u=i==null?void 0:i.to)==null?void 0:u.id)!=null?d:(l=t.getState())==null?void 0:l.id)!=null?c:"master",n=this.manifests$.getValue();if(!n.length)return;let o=r?"master":s;return r&&!i&&t.startTransitionTo(this.masterManifest),n.find(p=>p.id===o)}subscribe(){let{output:e,desiredState:t}=this.params,r=o=>{e.error$.next({id:"HlsLiveProvider",category:G.ErrorCategory.WTF,message:"HlsLiveProvider internal logic error",thrown:o})},i=De(this.video),s=(o,u)=>this.subscription.add(o.subscribe(u,r));s(i.ended$,e.endedEvent$),s(i.error$,e.error$),s(i.isBuffering$,e.isBuffering$),s(i.currentBuffer$,e.currentBuffer$),s(i.loadedMetadata$,e.firstBytesEvent$),s(i.loadedMetadata$,e.loadedMetadataEvent$),s(i.playing$,e.firstFrameEvent$),s(i.canplay$,e.canplay$),s(i.inPiP$,e.inPiP$),s(i.inFullscreen$,e.inFullscreen$),this.subscription.add(t.isLooped.stateChangeStarted$.subscribe(()=>t.isLooped.setState(!1),r)),this.subscription.add(Ce(this.video,t.volume,i.volumeState$,r)),this.subscription.add(i.volumeState$.subscribe(this.params.output.volume$,r)),this.subscription.add(Ye(this.video,t.playbackRate,i.playbackRateState$,r)),s(Ke(this.video),e.elementVisible$),this.textTracksManager.connect(this.video,t,e),this.subscription.add(i.playing$.subscribe(()=>{this.videoState.setState("playing"),k(t.playbackState,"playing")},r)).add(i.pause$.subscribe(()=>{this.videoState.setState("paused"),k(t.playbackState,"paused")},r)).add(i.canplay$.subscribe(()=>{var o;((o=this.videoState.getTransition())==null?void 0:o.to)==="ready"&&this.videoState.setState("ready"),this.videoState.getState()==="playing"&&this.playIfAllowed()},r)),this.subscription.add(this.maxSeekBackTime$.pipe((0,G.filterChanged)(),(0,G.map)(o=>-o/1e3)).subscribe(this.params.output.duration$,r)),this.subscription.add(i.loadedMetadata$.subscribe(()=>{let o=this.params.desiredState.seekState.getState(),u=this.videoState.getTransition(),l=this.params.desiredState.videoTrack.getTransition(),d=this.params.desiredState.autoVideoTrackSwitching.getTransition();if(l&&(0,G.isNonNullable)(l.to)){let c=l.to.id;this.params.desiredState.videoTrack.setState(l.to);let p=this.manifests$.getValue().find(h=>h.id===c);p&&(this.params.output.currentVideoTrack$.next(p),this.params.output.hostname$.next(Se(p.url)))}d&&this.params.desiredState.autoVideoTrackSwitching.setState(d.to),u&&u.from==="changing_manifest"&&this.videoState.setState(u.to),o&&o.state==="requested"&&this.seek(o.position)},r)),this.subscription.add(i.loadedData$.subscribe(()=>{var u,l,d;let o=(d=(l=(u=this.video)==null?void 0:u.getStartDate)==null?void 0:l.call(u))==null?void 0:d.getTime();this.manifestStartTime$.next(o||void 0)},r)),this.subscription.add((0,G.combine)({startTime:this.manifestStartTime$.pipe((0,G.filter)(G.isNonNullable)),currentTime:i.timeUpdate$}).subscribe(({startTime:o,currentTime:u})=>this.params.output.liveTime$.next(o+u*1e3),r)),this.subscription.add(this.manifests$.pipe((0,G.map)(o=>o.map(({id:u,quality:l,size:d,bandwidth:c,fps:p})=>({id:u,quality:l,size:d,fps:p,bitrate:c})))).subscribe(this.params.output.availableVideoTracks$,r));let n=(0,G.merge)(t.playbackState.stateChangeStarted$,t.seekState.stateChangeEnded$,t.videoTrack.stateChangeStarted$,t.autoVideoTrackSwitching.stateChangeStarted$,t.autoVideoTrackLimits.stateChangeStarted$,this.videoState.stateChangeEnded$,this.manifests$,(0,G.observableFrom)(["init"])).pipe((0,G.debounce)(0));this.subscription.add(n.subscribe(this.syncPlayback,r))}destroy(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.params.output.element$.next(void 0),Me(this.video)}prepare(){var o,u;let e=this.selectManifest();if((0,G.isNullable)(e))return;let t=this.params.desiredState.autoVideoTrackLimits.getTransition(),r=this.params.desiredState.autoVideoTrackLimits.getState(),i=new URL(e.url);if((t||r)&&e.id===this.masterManifest.id){let{max:l,min:d}=(u=(o=t==null?void 0:t.to)!=null?o:r)!=null?u:{};for(let[c,p]of[[l,"mq"],[d,"lq"]]){let h=String(parseFloat(c||""));p&&c&&i.searchParams.set(p,h)}}let s=this.params.format==="HLS_LIVE_CMAF"?2:0,n=we(i.toString(),this.liveOffset.getTotalOffset(),s);this.video.setAttribute("src",n),this.video.load(),nl(n).then(l=>{var d;if(!(0,G.isNullable)(l))this.maxSeekBackTime$.next(l);else{let c=(d=this.params.source.maxSeekBackTime)!=null?d:this.maxSeekBackTime$.getValue();if((0,G.isNullable)(c)||!isFinite(c))try{kt(n).then(p=>p.text()).then(p=>{var m;let h=(m=/#EXT-X-STREAM-INF[^\n]+\n(.+)/m.exec(p))==null?void 0:m[1];if(h){let g=new URL(h,n).toString();nl(g).then(v=>{(0,G.isNullable)(v)||this.maxSeekBackTime$.next(v)})}})}catch(p){}}})}playIfAllowed(){Oe(this.video,()=>{this.params.output.soundProhibitedEvent$.next()}).then(e=>{e||(this.videoState.setState("paused"),this.liveOffset.pause(),k(this.params.desiredState.playbackState,"paused",!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:G.ErrorCategory.DOM,thrown:e}))}seek(e){this.params.output.willSeekEvent$.next();let t=-e,r=t<this.maxSeekBackTime$.getValue()?t:0;this.liveOffset.resetTo(r),this.params.output.position$.next(-r/1e3),this.params.output.seekedEvent$.next()}};var ee=require("@vkontakte/videoplayer-shared/es2015");var Ca=class{constructor(e){this.subscription=new ee.Subscription;this.videoState=new j("stopped");this.textTracksManager=new ze;this.manifests$=new ee.ValueSubject([]);this.syncPlayback=()=>{if(!this.manifests$.getValue().length)return;let t=this.videoState.getState(),r=this.params.desiredState.playbackState.getState(),i=this.params.desiredState.playbackState.getTransition(),s=this.params.desiredState.videoTrack.getTransition(),n=this.params.desiredState.autoVideoTrackSwitching.getTransition(),o=this.params.desiredState.autoVideoTrackLimits.getTransition();if(r==="stopped"){t!=="stopped"&&(this.videoState.startTransitionTo("stopped"),this.video.removeAttribute("src"),this.video.load(),this.params.output.position$.next(0),this.params.output.duration$.next(1/0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.videoState.setState("stopped"),k(this.params.desiredState.playbackState,"stopped",!0));return}if(this.videoState.getTransition())return;let l=this.params.desiredState.seekState.getState();if(t==="stopped"){this.videoState.startTransitionTo("ready"),this.prepare();return}if(s||n||o){let d=this.videoState.getState();this.videoState.setState("changing_manifest"),this.videoState.startTransitionTo(d);let{currentTime:c}=this.video;this.prepare(),o&&this.params.output.autoVideoTrackLimits$.next(o.to),l.state==="none"&&this.params.desiredState.seekState.setState({state:"requested",position:c*1e3,forcePrecise:!0});return}switch((i==null?void 0:i.to)!=="paused"&&l.state==="requested"&&this.seek(l.position),t){case"ready":r==="ready"?k(this.params.desiredState.playbackState,"ready"):r==="paused"?(this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused")):r==="playing"&&(this.videoState.startTransitionTo("playing"),this.playIfAllowed());return;case"playing":r==="paused"?(this.videoState.startTransitionTo("paused"),this.video.paused?this.videoState.setState("paused"):this.video.pause()):(i==null?void 0:i.to)==="playing"&&k(this.params.desiredState.playbackState,"playing");return;case"paused":r==="playing"?(this.videoState.startTransitionTo("playing"),this.playIfAllowed()):(i==null?void 0:i.to)==="paused"&&k(this.params.desiredState.playbackState,"paused");return;case"changing_manifest":break;default:return(0,ee.assertNever)(t)}};this.params=e,this.video=Le(e.container,e.tuning),this.params.output.element$.next(this.video),this.masterManifest={id:"master",quality:ee.VideoQuality.INVARIANT,url:this.params.source.url},this.params.output.isLive$.next(!1),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.hostname$.next(Se(this.params.source.url)),this.params.output.autoVideoTrackLimitingAvailable$.next(!0),mn(we(this.params.source.url),this.params.source.url,{manifestRetryInterval:this.params.tuning.manifestRetryInterval,manifestRetryMaxInterval:this.params.tuning.manifestRetryMaxInterval,manifestRetryMaxCount:this.params.tuning.manifestRetryMaxCount}).then(({qualityManifests:t,textTracks:r})=>{this.manifests$.next([this.masterManifest,...t]),this.params.tuning.useNativeHLSTextTracks||this.params.desiredState.internalTextTracks.startTransitionTo(r)},t=>this.params.output.error$.next({id:"ExtractHlsQualities",category:ee.ErrorCategory.NETWORK,message:"Error fetching manifest and extracting qualities",thrown:t})),this.subscribe()}selectManifest(){var u,l,d,c;let{autoVideoTrackSwitching:e,videoTrack:t}=this.params.desiredState,r=e.getState(),i=t.getTransition(),s=(c=(d=(u=i==null?void 0:i.to)==null?void 0:u.id)!=null?d:(l=t.getState())==null?void 0:l.id)!=null?c:"master",n=this.manifests$.getValue();if(!n.length)return;let o=r?"master":s;return r&&!i&&t.startTransitionTo(this.masterManifest),n.find(p=>p.id===o)}subscribe(){let{output:e,desiredState:t}=this.params,r=o=>{e.error$.next({id:"HlsProvider",category:ee.ErrorCategory.WTF,message:"HlsProvider internal logic error",thrown:o})},i=De(this.video),s=(o,u)=>this.subscription.add(o.subscribe(u));if(s(i.timeUpdate$,e.position$),s(i.durationChange$,e.duration$),s(i.ended$,e.endedEvent$),s(i.looped$,e.loopedEvent$),s(i.error$,e.error$),s(i.isBuffering$,e.isBuffering$),s(i.currentBuffer$,e.currentBuffer$),s(i.loadedMetadata$,e.firstBytesEvent$),s(i.loadedMetadata$,e.loadedMetadataEvent$),s(i.playing$,e.firstFrameEvent$),s(i.canplay$,e.canplay$),s(i.seeked$,e.seekedEvent$),s(i.inPiP$,e.inPiP$),s(i.inFullscreen$,e.inFullscreen$),s(this.videoState.stateChangeEnded$.pipe((0,ee.map)(o=>o.to)),this.params.output.playbackState$),this.subscription.add(mt(this.video,t.isLooped,r)),this.subscription.add(Ce(this.video,t.volume,i.volumeState$,r)),this.subscription.add(i.volumeState$.subscribe(this.params.output.volume$,r)),this.subscription.add(Ye(this.video,t.playbackRate,i.playbackRateState$,r)),this.textTracksManager.connect(this.video,t,e),this.subscription.add(i.playing$.subscribe(()=>{this.videoState.setState("playing"),k(t.playbackState,"playing")},r)).add(i.pause$.subscribe(()=>{this.videoState.setState("paused"),k(t.playbackState,"paused")},r)).add(i.canplay$.subscribe(()=>{var o;((o=this.videoState.getTransition())==null?void 0:o.to)==="ready"&&this.videoState.setState("ready"),this.videoState.getState()==="playing"&&this.playIfAllowed()},r).add(i.loadedMetadata$.subscribe(()=>{var h;let o=this.params.desiredState.seekState.getState(),u=this.videoState.getTransition(),l=this.params.desiredState.videoTrack.getTransition(),d=this.params.desiredState.autoVideoTrackSwitching.getTransition();if(l&&(0,ee.isNonNullable)(l.to)){let m=l.to.id;this.params.desiredState.videoTrack.setState(l.to);let g=this.manifests$.getValue().find(v=>v.id===m);g&&(this.params.output.currentVideoTrack$.next(g),this.params.output.hostname$.next(Se(g.url)))}let c=this.params.desiredState.playbackRate.getState(),p=(h=this.params.output.element$.getValue())==null?void 0:h.playbackRate;if(c!==p){let m=this.params.output.element$.getValue();m&&(this.params.desiredState.playbackRate.setState(c),m.playbackRate=c)}d&&this.params.desiredState.autoVideoTrackSwitching.setState(d.to),u&&u.from==="changing_manifest"&&this.videoState.setState(u.to),o.state==="requested"&&this.seek(o.position)},r))),this.subscription.add(this.manifests$.pipe((0,ee.map)(o=>o.map(({id:u,quality:l,size:d,bandwidth:c,fps:p})=>({id:u,quality:l,size:d,fps:p,bitrate:c})))).subscribe(this.params.output.availableVideoTracks$,r)),!ee.clientChecker.isIOS||!this.params.tuning.useNativeHLSTextTracks){let{textTracks:o}=this.video;this.subscription.add((0,ee.merge)((0,ee.fromEvent)(o,"addtrack"),(0,ee.fromEvent)(o,"removetrack"),(0,ee.fromEvent)(o,"change"),(0,ee.observableFrom)(["init"])).subscribe(()=>{for(let u=0;u<o.length;u++)o[u].mode="hidden"},r))}let n=(0,ee.merge)(t.playbackState.stateChangeStarted$,t.seekState.stateChangeEnded$,t.videoTrack.stateChangeStarted$,t.autoVideoTrackSwitching.stateChangeStarted$,t.autoVideoTrackLimits.stateChangeStarted$,this.videoState.stateChangeEnded$,this.manifests$,(0,ee.observableFrom)(["init"])).pipe((0,ee.debounce)(0));this.subscription.add(n.subscribe(this.syncPlayback,r))}destroy(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.params.output.element$.next(void 0),Me(this.video)}prepare(){var s,n;let e=this.selectManifest();if((0,ee.isNullable)(e))return;let t=this.params.desiredState.autoVideoTrackLimits.getTransition(),r=this.params.desiredState.autoVideoTrackLimits.getState(),i=new URL(e.url);if((t||r)&&e.id===this.masterManifest.id){let{max:o,min:u}=(n=(s=t==null?void 0:t.to)!=null?s:r)!=null?n:{};for(let[l,d]of[[o,"mq"],[u,"lq"]]){let c=String(parseFloat(l||""));d&&l&&i.searchParams.set(d,c)}}this.video.setAttribute("src",i.toString()),this.video.load()}playIfAllowed(){Oe(this.video,()=>{this.params.output.soundProhibitedEvent$.next()}).then(e=>{e||(this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused",!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:ee.ErrorCategory.DOM,thrown:e}))}seek(e){this.params.output.willSeekEvent$.next(),this.video.currentTime=e/1e3}};var Wv=X(Fr(),1),Da=X(Fi(),1);var se=require("@vkontakte/videoplayer-shared/es2015");var Oa=class{constructor(e){this.subscription=new se.Subscription;this.videoState=new j("stopped");this.trackUrls={};this.textTracksManager=new ze;this.syncPlayback=()=>{var u,l,d;let e=this.videoState.getState(),t=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition();if(t==="stopped"){e!=="stopped"&&(this.videoState.startTransitionTo("stopped"),this.video.removeAttribute("src"),this.video.load(),this.params.output.position$.next(0),this.params.output.duration$.next(1/0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.videoState.setState("stopped"),k(this.params.desiredState.playbackState,"stopped",!0));return}if(this.videoState.getTransition())return;let s=this.params.desiredState.autoVideoTrackLimits.getTransition(),n=this.params.desiredState.videoTrack.getTransition(),o=this.params.desiredState.seekState.getState();if(s&&e!=="ready"&&!n){this.handleQualityLimitTransition(s.to.max);return}if(e==="stopped"){this.videoState.startTransitionTo("ready"),this.prepare();return}if(n){let{currentTime:c}=this.video;this.prepare(),o.state==="none"&&this.params.desiredState.seekState.setState({state:"requested",position:c*1e3,forcePrecise:!0}),n.to&&((u=this.params.desiredState.autoVideoTrackLimits.getState())==null?void 0:u.max)!==((d=(l=this.trackUrls[n.to.id])==null?void 0:l.track)==null?void 0:d.quality)&&this.params.output.autoVideoTrackLimits$.next({max:void 0});return}switch((r==null?void 0:r.to)!=="paused"&&o.state==="requested"&&this.seek(o.position),e){case"ready":t==="ready"?k(this.params.desiredState.playbackState,"ready"):t==="paused"?(this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused")):t==="playing"&&(this.videoState.startTransitionTo("playing"),this.playIfAllowed());return;case"playing":t==="paused"?(this.videoState.startTransitionTo("paused"),this.video.paused?this.videoState.setState("paused"):this.video.pause()):(r==null?void 0:r.to)==="playing"&&k(this.params.desiredState.playbackState,"playing");return;case"paused":t==="playing"?(this.videoState.startTransitionTo("playing"),this.playIfAllowed()):(r==null?void 0:r.to)==="paused"&&k(this.params.desiredState.playbackState,"paused");return;default:return(0,se.assertNever)(e)}};this.params=e,this.video=Le(e.container,e.tuning),this.params.output.element$.next(this.video),(0,Wv.default)(this.params.source).reverse().forEach(([t,r],i)=>{let s=i.toString(10);this.trackUrls[s]={track:{quality:t,id:s},url:r}}),this.params.output.isLive$.next(!1),this.params.output.availableVideoTracks$.next((0,Da.default)(this.trackUrls).map(({track:t})=>t)),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.desiredState.autoVideoTrackSwitching.setState(!1),this.params.output.autoVideoTrackLimitingAvailable$.next(!0),this.subscribe()}subscribe(){let{output:e,desiredState:t}=this.params,r=o=>{e.error$.next({id:"MpegProvider",category:se.ErrorCategory.WTF,message:"MpegProvider internal logic error",thrown:o})},i=De(this.video),s=(o,u)=>this.subscription.add(o.subscribe(u,r));s(i.timeUpdate$,e.position$),s(i.durationChange$,e.duration$),s(i.ended$,e.endedEvent$),s(i.looped$,e.loopedEvent$),s(i.error$,e.error$),s(i.isBuffering$,e.isBuffering$),s(i.currentBuffer$,e.currentBuffer$),s(i.loadedMetadata$,e.firstBytesEvent$),s(i.loadedMetadata$,e.loadedMetadataEvent$),s(i.playing$,e.firstFrameEvent$),s(i.canplay$,e.canplay$),s(i.seeked$,e.seekedEvent$),s(i.inPiP$,e.inPiP$),s(i.inFullscreen$,e.inFullscreen$),s(this.videoState.stateChangeEnded$.pipe((0,se.map)(o=>o.to)),this.params.output.playbackState$),this.subscription.add(mt(this.video,t.isLooped,r)),this.subscription.add(Ce(this.video,t.volume,i.volumeState$,r)),this.subscription.add(i.volumeState$.subscribe(this.params.output.volume$,r)),this.subscription.add(Ye(this.video,t.playbackRate,i.playbackRateState$,r)),s(Ke(this.video),e.elementVisible$),this.subscription.add(i.playing$.subscribe(()=>{this.videoState.setState("playing"),k(t.playbackState,"playing")},r)).add(i.pause$.subscribe(()=>{this.videoState.setState("paused"),k(t.playbackState,"paused")},r)).add(i.canplay$.subscribe(()=>{var u,l;((u=this.videoState.getTransition())==null?void 0:u.to)==="ready"&&this.videoState.setState("ready");let o=this.params.desiredState.videoTrack.getTransition();if(o&&(0,se.isNonNullable)(o.to)){this.params.desiredState.videoTrack.setState(o.to),this.params.output.currentVideoTrack$.next(this.trackUrls[o.to.id].track);let d=this.params.desiredState.playbackRate.getState(),c=(l=this.params.output.element$.getValue())==null?void 0:l.playbackRate;if(d!==c){let p=this.params.output.element$.getValue();p&&(this.params.desiredState.playbackRate.setState(d),p.playbackRate=d)}}this.videoState.getState()==="playing"&&this.playIfAllowed()},r)),this.textTracksManager.connect(this.video,t,e);let n=(0,se.merge)(t.playbackState.stateChangeStarted$,t.videoTrack.stateChangeStarted$,t.seekState.stateChangeEnded$,t.autoVideoTrackLimits.stateChangeStarted$,this.videoState.stateChangeEnded$,(0,se.observableFrom)(["init"])).pipe((0,se.debounce)(0));this.subscription.add(n.subscribe(this.syncPlayback,r))}destroy(){this.subscription.unsubscribe(),this.textTracksManager.destroy(),this.trackUrls={},this.params.output.element$.next(void 0),Me(this.video)}prepare(){var r;let e=(r=this.params.desiredState.videoTrack.getState())==null?void 0:r.id;(0,se.assertNonNullable)(e,"MpegProvider: track is not selected");let{url:t}=this.trackUrls[e];(0,se.assertNonNullable)(t,`MpegProvider: No url for ${e}`),this.params.tuning.requestQuick&&(t=xa(t)),this.video.setAttribute("src",t),this.video.load(),this.params.output.hostname$.next(Se(t))}playIfAllowed(){Oe(this.video,()=>{this.params.output.soundProhibitedEvent$.next()}).then(e=>{e||(this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused",!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:se.ErrorCategory.DOM,thrown:e}))}seek(e){this.params.output.willSeekEvent$.next(),this.video.currentTime=e/1e3}handleQualityLimitTransition(e){var i,s,n,o;let t,r=e;if(e&&((i=this.params.output.currentVideoTrack$.getValue())==null?void 0:i.quality)!==e){let u=(s=(0,Da.default)(this.trackUrls).find(c=>!(0,se.isInvariantQuality)(c.track.quality)&&(0,se.isLowerOrEqual)(c.track.quality,e)))==null?void 0:s.track,l=(n=this.params.desiredState.videoTrack.getState())==null?void 0:n.id,d=(o=this.trackUrls[l!=null?l:"0"])==null?void 0:o.track;if(u&&d&&(0,se.isHigherOrEqual)(d.quality,u.quality)&&(t=u),!t){let c=(0,Da.default)(this.trackUrls).filter(h=>!(0,se.isInvariantQuality)(h.track.quality)&&(0,se.isHigher)(h.track.quality,e)),p=c.length;p&&(t=c[p-1].track)}t&&(r=t.quality)}else if(!e){let u=(0,Da.default)(this.trackUrls).map(l=>l.track);t=Jt(u,{container:{width:this.video.offsetWidth,height:this.video.offsetHeight},estimatedThroughput:this.params.dependencies.throughputEstimator.throughput$.getValue(),tuning:this.params.tuning.autoTrackSelection,forwardBufferHealth:0,abrLogger:this.params.dependencies.abrLogger})}t&&(this.params.output.currentVideoTrack$.next(t),this.params.desiredState.videoTrack.startTransitionTo(t)),this.params.output.autoVideoTrackLimits$.next({max:r})}};var le=require("@vkontakte/videoplayer-shared/es2015");var zv=require("@vkontakte/videoplayer-shared/es2015");var Yv=["stun:videostun.mycdn.me:80"],e$=1e3,t$=3,ll=()=>null,bn=class{constructor(e,t){this.ws=null;this.peerConnection=null;this.serverUrl="";this.streamKey="";this.stream=null;this.signalingType="JOIN";this.retryCount=0;this.externalStartCallback=ll;this.externalStopCallback=ll;this.externalErrorCallback=ll;this.options=this.normalizeOptions(t);let r=e.split("/");this.serverUrl=r.slice(0,r.length-1).join("/"),this.streamKey=r[r.length-1]}onStart(e){try{this.externalStartCallback=e}catch(t){this.handleSystemError(t)}}onStop(e){try{this.externalStopCallback=e}catch(t){this.handleSystemError(t)}}onError(e){try{this.externalErrorCallback=e}catch(t){this.handleSystemError(t)}}connect(){this.connectWS()}disconnect(){try{this.externalStopCallback(),this.closeConnections()}catch(e){this.handleSystemError(e)}}connectWS(){this.ws||(this.ws=new WebSocket(this.serverUrl),this.ws.onopen=this.onSocketOpen.bind(this),this.ws.onmessage=this.onSocketMessage.bind(this),this.ws.onclose=this.onSocketClose.bind(this),this.ws.onerror=this.onSocketError.bind(this))}onSocketOpen(){this.handleLogin()}onSocketClose(e){try{if(!this.ws)return;this.ws=null,e.code>1e3?(this.retryCount++,this.retryCount>this.options.maxRetryNumber?this.handleNetworkError():this.scheduleRetry()):this.externalStopCallback()}catch(t){this.handleRTCError(t)}}onSocketError(e){try{this.externalErrorCallback(new Error(e.toString()))}catch(t){this.handleRTCError(t)}}onSocketMessage(e){try{let t=this.parseMessage(e.data);switch(t.type){case"JOIN":case"CALL_JOIN":this.handleJoinMessage(t);break;case"UPDATE":this.handleUpdateMessage(t);break;case"STATUS":this.handleStatusMessage(t);break}}catch(t){this.handleRTCError(t)}}handleJoinMessage(e){switch(e.inviteType){case"ANSWER":this.handleAnswer(e.sdp);break;case"CANDIDATE":this.handleCandidate(e.candidate);break}}handleStatusMessage(e){switch(e.status){case"UNPUBLISHED":this.handleUnpublished();break}}handleUpdateMessage(e){return O(this,null,function*(){try{let t=yield this.createOffer();this.peerConnection&&(yield this.peerConnection.setLocalDescription(t)),this.handleAnswer(e.sdp)}catch(t){this.handleRTCError(t)}})}handleLogin(){return O(this,null,function*(){try{let e={iceServers:[{urls:Yv}]};this.peerConnection=new RTCPeerConnection(e),this.peerConnection.ontrack=this.onPeerConnectionStream.bind(this),this.peerConnection.onicecandidate=this.onPeerConnectionIceCandidate.bind(this),this.peerConnection.oniceconnectionstatechange=this.onPeerConnectionIceConnectionStateChange.bind(this);let t=yield this.createOffer();yield this.peerConnection.setLocalDescription(t),this.send({type:this.signalingType,inviteType:"OFFER",streamKey:this.streamKey,sdp:t.sdp,callSupport:!1})}catch(e){this.handleRTCError(e)}})}handleAnswer(e){return O(this,null,function*(){try{this.peerConnection&&(yield this.peerConnection.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:e})))}catch(t){this.handleRTCError(t)}})}handleCandidate(e){return O(this,null,function*(){if(e)try{this.peerConnection&&(yield this.peerConnection.addIceCandidate(e))}catch(t){this.handleRTCError(t)}})}handleUnpublished(){try{this.closeConnections(),this.externalStopCallback()}catch(e){this.handleRTCError(e)}}handleSystemError(e){this.options.errorChanel&&this.options.errorChanel.next({id:"webrtc-provider-error",category:zv.ErrorCategory.WTF,message:e.message})}onPeerConnectionStream(e){return O(this,null,function*(){let t=e.streams[0];this.stream&&this.stream.id===t.id||(this.stream=t,this.externalStartCallback(this.stream))})}onPeerConnectionIceCandidate(e){e.candidate&&this.send({type:this.signalingType,inviteType:"CANDIDATE",candidate:e.candidate})}onPeerConnectionIceConnectionStateChange(){if(this.peerConnection){let e=this.peerConnection.iceConnectionState;["failed","closed"].indexOf(e)>-1&&(this.retryCount++,this.retryCount>this.options.maxRetryNumber?this.handleNetworkError():(this.closeConnections(),this.scheduleRetry()))}}createOffer(){return O(this,null,function*(){let e={offerToReceiveAudio:!0,offerToReceiveVideo:!0,voiceActivityDetection:!1};if(!this.peerConnection)throw new Error("Can not create offer - no peer connection instance ");let t=yield this.peerConnection.createOffer(e),r=t.sdp||"";if(!/^a=rtpmap:\d+ H264\/\d+$/m.test(r))throw new Error("No h264 codec support error");return t})}handleRTCError(e){try{this.externalErrorCallback(e||new Error("RTC connection error"))}catch(t){this.handleSystemError(t)}}handleNetworkError(){try{this.externalErrorCallback(new Error("Network error"))}catch(e){this.handleSystemError(e)}}send(e){this.ws&&this.ws.send(JSON.stringify(e))}parseMessage(e){try{return JSON.parse(e)}catch(t){throw new Error("Can not parse socket message")}}closeConnections(){let e=this.ws;e&&(this.ws=null,e.close(1e3)),this.removePeerConnection()}removePeerConnection(){let e=this.peerConnection;e&&(this.peerConnection=null,e.close(),e.ontrack=null,e.onicecandidate=null,e.oniceconnectionstatechange=null,e=null)}scheduleRetry(){this.retryTimeout=setTimeout(this.connectWS.bind(this),e$)}normalizeOptions(e={}){let t={stunServerList:Yv,maxRetryNumber:t$,errorChanel:null};return e.stunServerList&&(t.stunServerList=e.stunServerList),e.maxRetryNumber&&e.maxRetryNumber>0&&(t.maxRetryNumber=e.maxRetryNumber),t}};var Ba=class{constructor(e){this.videoState=new j("stopped");this.maxSeekBackTime$=new le.ValueSubject(0);this.syncPlayback=()=>{let e=this.videoState.getState(),t=this.params.desiredState.playbackState.getState(),r=this.params.desiredState.playbackState.getTransition();if(t==="stopped"){e!=="stopped"&&(this.videoState.startTransitionTo("stopped"),this.video.pause(),this.video.srcObject=null,this.params.output.position$.next(0),this.params.output.duration$.next(0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.videoState.setState("stopped"),k(this.params.desiredState.playbackState,"stopped",!0));return}if(this.videoState.getTransition())return;let s=this.params.desiredState.videoTrack.getTransition();if(e==="stopped"){this.videoState.startTransitionTo("ready"),this.prepare();return}if(s){this.prepare();return}switch(e){case"ready":t==="paused"?(this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused")):t==="playing"&&(this.videoState.startTransitionTo("playing"),this.playIfAllowed());return;case"playing":t==="paused"?(this.videoState.startTransitionTo("paused"),this.video.paused?this.videoState.setState("paused"):this.video.pause()):(r==null?void 0:r.to)==="playing"&&k(this.params.desiredState.playbackState,"playing");return;case"paused":t==="playing"?(this.videoState.startTransitionTo("playing"),this.playIfAllowed()):(r==null?void 0:r.to)==="paused"&&k(this.params.desiredState.playbackState,"paused");return;default:return(0,le.assertNever)(e)}};this.subscription=new le.Subscription,this.params=e,this.log=this.params.dependencies.logger.createComponentLog("WebRTCLiveProvider"),this.video=Le(e.container,e.tuning),this.liveStreamClient=new bn(this.params.source.url,{maxRetryNumber:this.params.tuning.webrtc.connectionRetryMaxNumber,errorChanel:this.params.output.error$}),this.liveStreamClient.onStart(this.onLiveStreamStart.bind(this)),this.liveStreamClient.onStop(this.onLiveStreamStop.bind(this)),this.liveStreamClient.onError(this.onLiveStreamError.bind(this)),this.params.output.availableTextTracks$.next([]),this.params.desiredState.internalTextTracks.setState([]),this.subscribe()}destroy(){this.subscription.unsubscribe(),this.liveStreamClient.disconnect(),this.params.output.element$.next(void 0),Me(this.video)}subscribe(){let{output:e,desiredState:t}=this.params,r=n=>{e.error$.next({id:"WebRTCLiveProvider",category:le.ErrorCategory.WTF,message:"WebRTCLiveProvider internal logic error",thrown:n})};(0,le.merge)(this.videoState.stateChangeStarted$.pipe((0,le.map)(n=>({transition:n,type:"start"}))),this.videoState.stateChangeEnded$.pipe((0,le.map)(n=>({transition:n,type:"end"})))).subscribe(({transition:n,type:o})=>{this.log({message:`[videoState change] ${o}: ${JSON.stringify(n)}`})});let i=De(this.video),s=(n,o)=>this.subscription.add(n.subscribe(o,r));s(i.timeUpdate$,e.liveTime$),s(i.ended$,e.endedEvent$),s(i.looped$,e.loopedEvent$),s(i.error$,e.error$),s(i.isBuffering$,e.isBuffering$),s(i.currentBuffer$,e.currentBuffer$),s(Ke(this.video),this.params.output.elementVisible$),this.subscription.add(i.durationChange$.subscribe(n=>{e.duration$.next(n===1/0?0:n)})).add(i.canplay$.subscribe(()=>{var n;((n=this.videoState.getTransition())==null?void 0:n.to)==="ready"&&this.videoState.setState("ready")},r)).add(i.pause$.subscribe(()=>{this.videoState.setState("paused")},r)).add(i.playing$.subscribe(()=>{this.videoState.setState("playing")},r)).add(i.error$.subscribe(e.error$)).add(this.maxSeekBackTime$.subscribe(this.params.output.duration$)).add(Ce(this.video,t.volume,i.volumeState$,r)).add(i.volumeState$.subscribe(e.volume$,r)).add(this.videoState.stateChangeEnded$.subscribe(n=>{switch(n.to){case"stopped":e.position$.next(0),e.duration$.next(0),t.playbackState.setState("stopped");break;case"ready":break;case"paused":t.playbackState.setState("paused");break;case"playing":t.playbackState.setState("playing");break;default:return(0,le.assertNever)(n.to)}},r)).add((0,le.merge)(t.playbackState.stateChangeStarted$,this.videoState.stateChangeEnded$,(0,le.observableFrom)(["init"])).pipe((0,le.debounce)(0)).subscribe(this.syncPlayback.bind(this),r)),this.subscription.add(t.isLooped.stateChangeStarted$.subscribe(()=>t.isLooped.setState(!1),r)),this.subscription.add(t.autoVideoTrackSwitching.stateChangeStarted$.subscribe(()=>t.autoVideoTrackSwitching.setState(!1),r))}onLiveStreamStart(e){this.params.output.element$.next(this.video),this.params.output.duration$.next(0),this.params.output.position$.next(0),this.params.output.isLive$.next(!0),this.params.output.canChangePlaybackSpeed$.next(!1),this.params.output.hostname$.next(Se(this.params.source.url)),this.params.output.autoVideoTrackLimitingAvailable$.next(!1),this.params.output.availableVideoTracks$.next([]),this.params.output.availableAudioTracks$.next([]),this.params.output.isAudioAvailable$.next(!0),this.params.output.currentVideoTrack$.next({id:"webrtc",quality:le.VideoQuality.INVARIANT}),this.video.srcObject=e,k(this.params.desiredState.playbackState,"playing")}onLiveStreamStop(){this.videoState.startTransitionTo("stopped"),this.syncPlayback(),this.params.output.position$.next(0),this.params.output.duration$.next(0),this.params.output.currentBuffer$.next(void 0),this.params.output.hostname$.next(void 0),this.params.output.endedEvent$.next()}onLiveStreamError(e){this.onLiveStreamStop(),this.params.output.error$.next({id:"WebRTC stream runtime error",category:le.ErrorCategory.EXTERNAL_API,message:e.message,thrown:e})}playIfAllowed(){Oe(this.video,()=>{this.params.output.soundProhibitedEvent$.next()}).then(e=>{e||(this.videoState.setState("paused"),k(this.params.desiredState.playbackState,"paused",!0))},e=>this.params.output.error$.next({id:"ForcePlay",message:"play() failed even with workarounds",category:le.ErrorCategory.DOM,thrown:e}))}prepare(){this.liveStreamClient.connect()}};var Va=class{constructor(e){this.iterator=e[Symbol.iterator](),this.next()}next(){this.current=this.iterator.next()}getValue(){if(this.current.done)throw new Error("Iterable is completed");return this.current.value}isCompleted(){return!!this.current.done}};var y=require("@vkontakte/videoplayer-shared/es2015");var Ct=require("@vkontakte/videoplayer-shared/es2015"),Kv=a=>new Ct.Observable(e=>{let t=new Ct.Subscription,r=a.desiredPlaybackState$.stateChangeStarted$.pipe((0,Ct.map)(({from:l,to:d})=>`${l}-${d}`)),i=a.desiredPlaybackState$.stateChangeEnded$,s=a.providerChanged$.pipe((0,Ct.map)(({type:l})=>l!==void 0)),n=new Ct.Subject,o=0,u="unknown";return t.add(r.subscribe(l=>{o&&window.clearTimeout(o),u=l,o=window.setTimeout(()=>n.next(l),a.maxTransitionInterval)})),t.add(i.subscribe(()=>{window.clearTimeout(o),u="unknown",o=0})),t.add(s.subscribe(l=>{o&&(window.clearTimeout(o),o=0,l&&(o=window.setTimeout(()=>n.next(u),a.maxTransitionInterval)))})),t.add(n.subscribe(e)),()=>{window.clearTimeout(o),t.unsubscribe()}});var Ze=require("@vkontakte/videoplayer-shared/es2015");function Jv(){return new(window.AudioContext||window.webkitAudioContext)}var Xv=require("@vkontakte/videoplayer-shared/es2015");var _a=class _a{constructor(e,t,r,i){this.providerOutput=e;this.provider$=t;this.volumeMultiplierError$=r;this.volumeMultiplier=i;this.destroyController=new He;this.subscriptions=new Ze.Subscription;this.audioContext=null;this.gainNode=null;this.mediaElementSource=null;this.subscriptions.add(this.provider$.pipe((0,Ze.filter)(s=>!!s.type),(0,Ze.once)()).subscribe(({type:s})=>this.subscribe(s)))}subscribe(e){Xv.clientChecker.isSafari&&e!=="MPEG"||this.subscriptions.add((0,Ze.combine)({video:this.providerOutput.element$,playbackState:this.providerOutput.playbackState$,volume:this.providerOutput.volume$}).pipe((0,Ze.filter)(({playbackState:t,video:r,volume:{muted:i,volume:s}})=>t==="playing"&&!!r&&!i&&!!s),(0,Ze.once)()).subscribe(({video:t})=>{this.initAudioContextOnce(t).then(r=>{r||this.destroy()}).catch(r=>{this.handleError(r),this.destroy()})}))}static isSupported(){return"AudioContext"in window&&"GainNode"in window&&"MediaElementAudioSourceNode"in window}initAudioContextOnce(e){return O(this,null,function*(){let{volumeMultiplier:t}=this,r=Jv();this.audioContext=r;let i=r.createGain();if(this.gainNode=i,i.gain.value=t,i.connect(r.destination),r.state==="suspended"&&(yield r.resume(),this.destroyController.signal.aborted))return!1;let s=r.createMediaElementSource(e);return this.mediaElementSource=s,s.connect(i),!0})}cleanup(){this.mediaElementSource&&(this.mediaElementSource.disconnect(),this.mediaElementSource=null),this.gainNode&&(this.gainNode.disconnect(),this.gainNode=null),this.audioContext&&(this.audioContext.state!=="closed"&&this.audioContext.close(),this.audioContext=null)}destroy(){this.destroyController.abort(),this.subscriptions.unsubscribe(),this.cleanup()}handleError(e){var t;this.volumeMultiplierError$.next({id:_a.errorId,category:Ze.ErrorCategory.VIDEO_PIPELINE,message:(t=e==null?void 0:e.message)!=null?t:`${_a.errorId} exception`,thrown:e})}};_a.errorId="VolumeMultiplierManager";var oi=_a;var r$={chunkDuration:5e3,maxParallelRequests:5},Na=class{constructor(e){this.current$=new y.ValueSubject({type:void 0});this.providerError$=new y.Subject;this.noAvailableProvidersError$=new y.Subject;this.volumeMultiplierError$=new y.Subject;this.providerOutput={position$:new y.ValueSubject(0),duration$:new y.ValueSubject(1/0),volume$:new y.ValueSubject({muted:!1,volume:1}),availableVideoStreams$:new y.ValueSubject([]),currentVideoStream$:new y.ValueSubject(void 0),availableVideoTracks$:new y.ValueSubject([]),currentVideoTrack$:new y.ValueSubject(void 0),availableAudioStreams$:new y.ValueSubject([]),currentAudioStream$:new y.ValueSubject(void 0),availableAudioTracks$:new y.ValueSubject([]),currentVideoSegmentLength$:new y.ValueSubject(0),currentAudioSegmentLength$:new y.ValueSubject(0),isAudioAvailable$:new y.ValueSubject(!0),autoVideoTrackLimitingAvailable$:new y.ValueSubject(!1),autoVideoTrackLimits$:new y.ValueSubject(void 0),currentBuffer$:new y.ValueSubject(void 0),isBuffering$:new y.ValueSubject(!0),error$:new y.Subject,warning$:new y.Subject,willSeekEvent$:new y.Subject,soundProhibitedEvent$:new y.Subject,seekedEvent$:new y.Subject,loopedEvent$:new y.Subject,endedEvent$:new y.Subject,firstBytesEvent$:new y.Subject,loadedMetadataEvent$:new y.Subject,firstFrameEvent$:new y.Subject,canplay$:new y.Subject,isLive$:new y.ValueSubject(void 0),isLowLatency$:new y.ValueSubject(!1),canChangePlaybackSpeed$:new y.ValueSubject(!0),liveTime$:new y.ValueSubject(void 0),liveBufferTime$:new y.ValueSubject(void 0),liveLatency$:new y.ValueSubject(void 0),availableTextTracks$:new y.ValueSubject([]),currentTextTrack$:new y.ValueSubject(void 0),hostname$:new y.ValueSubject(void 0),httpConnectionType$:new y.ValueSubject(void 0),httpConnectionReused$:new y.ValueSubject(void 0),inPiP$:new y.ValueSubject(!1),inFullscreen$:new y.ValueSubject(!1),element$:new y.ValueSubject(void 0),elementVisible$:new y.ValueSubject(!0),availableSources$:new y.ValueSubject(void 0),is3DVideo$:new y.ValueSubject(!1),playbackState$:new y.ValueSubject("")};this.subscription=new y.Subscription;this.volumeMultiplierManager=null;this.params=e,this.log=this.params.dependencies.logger.createComponentLog("ProviderContainer"),this.tracer=e.dependencies.tracer.createComponentTracer(this.constructor.name);let t=ig([...sg(this.params.tuning),...ag(this.params.tuning)],this.params.tuning).filter(l=>(0,y.isNonNullable)(e.sources[l])),{forceFormat:r,formatsToAvoid:i}=this.params.tuning,s=[];r?s=[r]:i.length?s=[...t.filter(l=>!(0,cl.default)(i,l)),...t.filter(l=>(0,cl.default)(i,l))]:s=t,this.log({message:`Selected formats: ${s.join(" > ")}`}),this.tracer.log("Selected formats",(0,y.flattenObject)(s)),this.screenFormatsIterator=new Va(s);let n=[...Du(!0),...Du(!1)];this.chromecastFormatsIterator=new Va(n.filter(l=>(0,y.isNonNullable)(e.sources[l]))),this.providerOutput.availableSources$.next(e.sources);let{volumeMultiplier:o=1,tuning:{useVolumeMultiplier:u}}=this.params;u&&o!==1&&oi.isSupported()&&(this.volumeMultiplierManager=new oi(this.providerOutput,this.current$,this.volumeMultiplierError$,o))}init(){this.subscription.add(this.initProviderErrorHandling()),this.subscription.add(this.params.dependencies.chromecastInitializer.connection$.subscribe(()=>{this.reinitProvider()}))}destroy(){var e;this.destroyProvider(),this.current$.next({type:void 0}),this.subscription.unsubscribe(),(e=this.volumeMultiplierManager)==null||e.destroy(),this.volumeMultiplierManager=null,this.tracer.end()}initProvider(){let e=this.chooseDestination(),t=this.chooseFormat(e);if((0,y.isNullable)(t)){this.handleNoFormatsError(e);return}let r;try{r=this.createProvider(e,t)}catch(i){this.providerError$.next({id:"ProviderNotConstructed",category:y.ErrorCategory.WTF,message:"Failed to create provider",thrown:i})}r?this.current$.next({type:t,provider:r,destination:e}):this.current$.next({type:void 0})}reinitProvider(){this.tracer.log("reinitProvider"),this.destroyProvider(),this.initProvider()}switchToNextProvider(e){this.tracer.log("switchToNextProvider",{destination:e}),this.destroyProvider(),this.failoverIndex=void 0,this.skipFormat(e),this.initProvider()}destroyProvider(){let e=this.current$.getValue().provider;if(!e)return;this.log({message:"destroyProvider"}),this.tracer.log("destroyProvider");let t=this.providerOutput.position$.getValue()*1e3,r=this.params.desiredState.seekState.getState(),i=r.state!=="none";if(this.params.desiredState.seekState.setState({state:"requested",position:i?r.position:t,forcePrecise:i?r.forcePrecise:!1}),e.scene3D){let n=e.scene3D.getCameraRotation();this.params.desiredState.cameraOrientation.setState({x:n.x,y:n.y})}e.destroy();let s=this.providerOutput.isBuffering$;s.getValue()||s.next(!0)}createProvider(e,t){switch(this.log({message:`createProvider: ${e}:${t}`}),this.tracer.log("createProvider",{destination:e,format:t}),e){case"SCREEN":return this.createScreenProvider(t);case"CHROMECAST":return this.createChromecastProvider(t);default:return(0,y.assertNever)(e)}}createScreenProvider(e){let{sources:t,container:r,desiredState:i}=this.params,s=this.providerOutput,n={container:r,source:null,desiredState:i,output:s,dependencies:this.params.dependencies,tuning:this.params.tuning};switch(e){case"DASH_SEP":case"DASH_WEBM":case"DASH_WEBM_AV1":case"DASH_ONDEMAND":case"DASH_STREAMS":{let o=this.applyFailoverHost(t[e]),u=this.applyFailoverHost(t.HLS_ONDEMAND||t.HLS);return(0,y.assertNonNullable)(o),new Ra(H(R({},n),{source:o,sourceHls:u}))}case"DASH_LIVE_CMAF":{let o=this.applyFailoverHost(t[e]);return(0,y.assertNonNullable)(o),new $a(H(R({},n),{source:o}))}case"HLS":case"HLS_ONDEMAND":{let o=this.applyFailoverHost(t[e]);return(0,y.assertNonNullable)(o),ei||!this.params.tuning.useHlsJs?new Ca(H(R({},n),{source:o})):new La(H(R({},n),{source:o}))}case"HLS_LIVE":case"HLS_LIVE_CMAF":{let o=this.applyFailoverHost(t[e]);return(0,y.assertNonNullable)(o),new Ma(H(R({},n),{source:o,config:{maxPausedTime:this.params.tuning.live.maxPausedTime},format:e}))}case"MPEG":{let o=this.applyFailoverHost(t[e]);return(0,y.assertNonNullable)(o),new Oa(H(R({},n),{source:o}))}case"DASH_LIVE":{let o=this.applyFailoverHost(t[e]);return(0,y.assertNonNullable)(o),new Tb(H(R({},n),{source:o,config:H(R({},r$),{maxPausedTime:this.params.tuning.live.maxPausedTime})}))}case"WEB_RTC_LIVE":{let o=this.applyFailoverHost(t[e]);return(0,y.assertNonNullable)(o),new Ba({container:r,source:o,desiredState:i,output:s,dependencies:this.params.dependencies,tuning:this.params.tuning})}case"DASH":case"DASH_LIVE_WEBM":throw new Error(`${e} is no longer supported`);default:return(0,y.assertNever)(e)}}createChromecastProvider(e){let{sources:t,container:r,desiredState:i,meta:s}=this.params,n=this.providerOutput,o=this.params.dependencies.chromecastInitializer.connection$.getValue();return(0,y.assertNonNullable)(o),new Ni({connection:o,meta:s,container:r,source:t,format:e,desiredState:i,output:n,dependencies:this.params.dependencies,tuning:this.params.tuning})}chooseDestination(){return this.params.dependencies.chromecastInitializer.connection$.getValue()?"CHROMECAST":"SCREEN"}chooseFormat(e){switch(e){case"SCREEN":return this.screenFormatsIterator.isCompleted()?void 0:this.screenFormatsIterator.getValue();case"CHROMECAST":return this.chromecastFormatsIterator.isCompleted()?void 0:this.chromecastFormatsIterator.getValue();default:return(0,y.assertNever)(e)}}skipFormat(e){switch(e){case"SCREEN":return this.screenFormatsIterator.next();case"CHROMECAST":return this.chromecastFormatsIterator.next();default:return(0,y.assertNever)(e)}}handleNoFormatsError(e){switch(e){case"SCREEN":this.noAvailableProvidersError$.next(this.params.tuning.forceFormat),this.current$.next({type:void 0});return;case"CHROMECAST":this.params.dependencies.chromecastInitializer.disconnect();return;default:return(0,y.assertNever)(e)}}applyFailoverHost(e){if(this.failoverIndex===void 0)return e;let t=this.params.failoverHosts[this.failoverIndex];if(!t)return e;let r=i=>{let s=new URL(i);return s.host=t,s.toString()};if(e===void 0)return e;if("type"in e){if(e.type==="raw")return e;if(e.type==="url")return H(R({},e),{url:r(e.url)})}return(0,eS.default)((0,Zv.default)(e).map(([i,s])=>[i,r(s)]))}initProviderErrorHandling(){let e=new y.Subscription,t=!1,r=0;return e.add((0,y.merge)(this.providerOutput.error$.pipe((0,y.filter)(i=>!this.params.tuning.ignoreAudioRendererError||!i.message||!/AUDIO_RENDERER_ERROR/ig.test(i.message))),Kv({desiredPlaybackState$:this.params.desiredState.playbackState,maxTransitionInterval:this.params.tuning.maxPlaybackTransitionInterval,position$:this.providerOutput.position$,providerChanged$:this.current$}).pipe((0,y.map)(i=>({id:`ProviderHangup:${i}`,category:y.ErrorCategory.WTF,message:`A ${i} transition failed to complete within reasonable time`})))).subscribe(this.providerError$)),e.add(this.current$.subscribe(()=>{t=!1;let i=this.params.desiredState.playbackState.transitionEnded$.pipe((0,y.filter)(({to:s})=>s==="playing"),(0,y.once)()).subscribe(()=>t=!0);e.add(i)})),e.add(this.providerError$.subscribe(i=>{let s=this.current$.getValue().destination,n={error:i,currentDestination:s};if(s==="CHROMECAST")this.destroyProvider(),this.params.dependencies.chromecastInitializer.stopMedia().then(()=>this.switchToNextProvider("SCREEN"),()=>this.params.dependencies.chromecastInitializer.disconnect());else{let o=i.category===y.ErrorCategory.NETWORK,u=i.category===y.ErrorCategory.FATAL,l=this.params.failoverHosts.length>0&&(this.failoverIndex===void 0||this.failoverIndex<this.params.failoverHosts.length-1),d=r<this.params.tuning.providerErrorLimit&&!u,c=l&&!u&&(o&&t||!d);n=H(R({},n),{isNetworkError:o,isFatalError:u,haveFailoverHost:l,tryFailover:c,canReinitProvider:d}),d?(r++,this.reinitProvider()):c?(this.failoverIndex=this.failoverIndex===void 0?0:this.failoverIndex+1,this.reinitProvider()):this.switchToNextProvider(s!=null?s:"SCREEN")}this.tracer.error("providerError",(0,y.flattenObject)(n))})),e}};var N=require("@vkontakte/videoplayer-shared/es2015");var i$=5e3,tS="one_video_throughput",rS="one_video_rtt",Dt=window.navigator.connection,iS=()=>{let a=Dt==null?void 0:Dt.downlink;if((0,N.isNonNullable)(a)&&a!==10)return a*1e3},aS=()=>{let a=Dt==null?void 0:Dt.rtt;if((0,N.isNonNullable)(a)&&a!==3e3)return a},sS=(a,e,t)=>{let r=t*8,i=r/a;return r/(i+e)},dl=class a{constructor(e){this.subscription=new N.Subscription;this.concurrentDownloads=new Set;var i,s;this.tuningConfig=e;let t=a.load(tS)||(e.useBrowserEstimation?iS():void 0)||i$,r=(s=(i=a.load(rS))!=null?i:e.useBrowserEstimation?aS():void 0)!=null?s:0;if(this.throughput$=new N.ValueSubject(t),this.rtt$=new N.ValueSubject(r),this.rttAdjustedThroughput$=new N.ValueSubject(sS(t,r,e.rttPenaltyRequestSize)),this.throughput=yr.getSmoothedValue(t,-1,e),this.rtt=yr.getSmoothedValue(r,1,e),e.useBrowserEstimation){let n=()=>{let u=iS();u&&this.throughput.next(u);let l=aS();(0,N.isNonNullable)(l)&&this.rtt.next(l)};Dt&&"onchange"in Dt&&this.subscription.add((0,N.fromEvent)(Dt,"change").subscribe(n)),n()}this.subscription.add(this.throughput.smoothed$.subscribe(n=>{N.safeStorage.set(tS,n.toFixed(0))})),this.subscription.add(this.rtt.smoothed$.subscribe(n=>{N.safeStorage.set(rS,n.toFixed(0))})),this.subscription.add(this.throughput.debounced$.subscribe(this.throughput$)),this.subscription.add(this.rtt.debounced$.subscribe(this.rtt$)),this.subscription.add((0,N.combine)({throughput:this.throughput.smoothed$,rtt:this.rtt.smoothed$}).pipe((0,N.map)(({throughput:n,rtt:o})=>sS(n,o,e.rttPenaltyRequestSize)),(0,N.filter)(n=>{let o=this.rttAdjustedThroughput$.getValue()||0;return Math.abs(n-o)/o>=e.changeThreshold})).subscribe(this.rttAdjustedThroughput$))}destroy(){this.concurrentDownloads.clear(),this.subscription.unsubscribe()}trackXHR(e){let t=0,r=(0,N.now)(),i=new N.Subscription;switch(this.subscription.add(i),this.concurrentDownloads.add(e),e.readyState){case 4:break;case 3:case 2:i.add((0,N.fromEvent)(e,"progress").pipe((0,N.once)()).subscribe(s=>{t=s.loaded,r=(0,N.now)()}));break;case 1:case 0:i.add((0,N.fromEvent)(e,"loadstart").subscribe(()=>{t=0,r=(0,N.now)()}));break}i.add((0,N.fromEvent)(e,"loadend").subscribe(s=>{if(e.status===200){let n=s.loaded,o=(0,N.now)(),u=n-t,l=o-r;this.addRawSpeed(u,l,1)}this.concurrentDownloads.delete(e),i.unsubscribe()}))}trackStream(e,t=!1){let r=e.getReader();if(!r){e.cancel("Could not get reader");return}let i=0,s=(0,N.now)(),n=0,o=(0,N.now)(),u=d=>{this.concurrentDownloads.delete(e),r.releaseLock(),e.cancel(`Throughput Estimator error: ${d}`).catch(()=>{})},l=p=>O(this,[p],function*({done:d,value:c}){if(d)!t&&this.addRawSpeed(i,(0,N.now)()-s,1),this.concurrentDownloads.delete(e);else if(c){if(t){let h=(0,N.now)();if(h-o>this.tuningConfig.lowLatency.continuesByteSequenceInterval||h-s>this.tuningConfig.lowLatency.maxLastEvaluationTimeout){let g=o-s;g&&this.addRawSpeed(n,g,1,t),n=c.byteLength,s=(0,N.now)()}else n+=c.byteLength;o=(0,N.now)()}else i+=c.byteLength,n+=c.byteLength,n>=this.tuningConfig.streamMinSampleSize&&(0,N.now)()-o>=this.tuningConfig.streamMinSampleTime&&(this.addRawSpeed(n,(0,N.now)()-o,this.concurrentDownloads.size),n=0,o=(0,N.now)());yield r==null?void 0:r.read().then(l,u)}});this.concurrentDownloads.add(e),r==null||r.read().then(l,u)}addRawSpeed(e,t,r=1,i=!1){if(a.sanityCheck(e,t,i)){let s=e*8/t;this.throughput.next(s*r)}}addRawThroughput(e){this.throughput.next(e)}addRawRtt(e){this.rtt.next(e)}static sanityCheck(e,t,r=!1){let i=e*8/t;return!(!i||!isFinite(i)||i>1e6||i<30||r&&e<1e4||!r&&e<10*1024||!r&&t<=20)}static load(e){var r;let t=N.safeStorage.get(e);if((0,N.isNonNullable)(t))return(r=parseInt(t,10))!=null?r:void 0}},nS=dl;var Fa=require("@vkontakte/videoplayer-shared/es2015");var oS={configName:["core"],throughputEstimator:{type:"EmaAndMa",emaAlphaSlow:.2,emaAlphaFast:.7,emaAlpha:.45,basisTrendChangeCount:10,changeThreshold:.05,useBrowserEstimation:!0,rttPenaltyRequestSize:1*1024*1024,streamMinSampleSize:10*1024,streamMinSampleTime:300,deviationDepth:20,deviationFactor:.5,lowLatency:{continuesByteSequenceInterval:50,maxLastEvaluationTimeout:300}},autoTrackSelection:{bitrateFactorAtEmptyBuffer:2.8,bitrateAudioFactorAtEmptyBuffer:10,bitrateFactorAtFullBuffer:2,bitrateAudioFactorAtFullBuffer:7,minVideoAudioRatio:5,minAvailableThroughputAudioRatio:5,usePixelRatio:!0,pixelRatioMultiplier:void 0,pixelRatioLogBase:3,pixelRatioLogCoefficients:[1,0,1],limitByContainer:!0,containerSizeFactor:1.3,lazyQualitySwitch:!0,minBufferToSwitchUp:.4,considerPlaybackRate:!1,trackCooldownIncreaseQuality:3e3,trackCooldownDecreaseQuality:3e3,backgroundVideoQualityLimit:Fa.VideoQuality.Q_4320P,activeVideoAreaThreshold:.1},droppedFramesChecker:{enabled:!1,percentLimit:.1,checkTime:1e3,countLimit:3,tickCountAfterQualityChange:5,qualityUpWaitingTime:5e3,minQualityBanLimit:Fa.VideoQuality.Q_480P},dash:{forwardBufferTarget:6e4,forwardBufferTargetAuto:6e4,forwardBufferTargetManual:5*6e4,forwardBufferTargetPreload:5e3,maxSegmentDurationLeftToSelectNextSegment:3e3,minSafeBufferThreshold:.5,bufferPruningSafeZone:1e3,segmentRequestSize:1*1024*1024,representationSwitchForwardBufferGap:3e3,crashOnStallTimeout:25e3,crashOnStallTWithoutDataTimeout:5e3,enableSubSegmentBufferFeeding:!0,bufferEmptinessTolerance:100,useFetchPriorityHints:!0,qualityLimitsOnStall:{stallDurationBeforeQualityDecrease:0,stallDurationNoDataBeforeQualityDecrease:0,stallCountBeforeQualityDecrease:0,resetQualityRestrictionTimeout:1e4},enableBaseUrlSupport:!0,maxSegmentRetryCount:5},dashCmafLive:{maxActiveLiveOffset:1e4,normalizedTargetMinBufferSize:6e4,normalizedLiveMinBufferSize:5e3,normalizedActualBufferOffset:1e4,offsetCalculationError:3e3,lowLatency:{maxTargetOffset:3e3,maxTargetOffsetDeviation:250,playbackCatchupSpeedup:.05,isActiveOnDefault:!1,bufferEstimator:{emaAlpha:.45,changeThreshold:.05,deviationDepth:20,deviationFactor:.5,extremumInterval:5}}},live:{minBuffer:3e3,minBufferSegments:3,lowLatencyMinBuffer:1e3,lowLatencyMinBufferSegments:1,isLiveCatchUpMode:!1,lowLatencyActiveLiveDelay:3e3,activeLiveDelay:5e3,maxPausedTime:5e3},downloadBackoff:{bufferThreshold:100,start:100,factor:2,max:3*1e3,random:.1},enableWakeLock:!0,enableTelemetryAtStart:!1,forceFormat:void 0,formatsToAvoid:[],disableChromecast:!1,chromecastReceiverId:"07A4434E",useWebmBigRequest:!1,webmCodec:"vp9",androidPreferredFormat:"dash",preferCMAF:!1,preferWebRTC:!1,preferMultiStream:!1,preferHDR:!1,bigRequestMinInitSize:50*1024,bigRequestMinDataSize:1*1024*1024,stripRangeHeader:!0,flushShortLoopedBuffers:!0,insufficientBufferRuleMargin:1e4,dashSeekInSegmentDurationThreshold:3*60*1e3,dashSeekInSegmentAlwaysSeekDelta:1e4,endGapTolerance:300,stallIgnoreThreshold:33,gapWatchdogInterval:50,requestQuick:!1,useHlsJs:!0,useNativeHLSTextTracks:!1,useManagedMediaSource:!0,useNewSwitchTo:!1,useSafariEndlessRequestBugfix:!0,isAudioDisabled:!1,autoplayOnlyInActiveTab:!0,dynamicImportTimeout:5e3,maxPlaybackTransitionInterval:2e4,providerErrorLimit:3,manifestRetryInterval:300,manifestRetryMaxInterval:1e4,manifestRetryMaxCount:10,audioVideoSyncRate:20,webrtc:{connectionRetryMaxNumber:3},spherical:{enabled:!1,fov:{x:135,y:76},rotationSpeed:45,maxYawAngle:175,rotationSpeedCorrection:10,degreeToPixelCorrection:5,speedFadeTime:2e3,speedFadeThreshold:50},useVolumeMultiplier:!1,ignoreAudioRendererError:!1,useEnableSubtitlesParam:!1,useOldMSEDetection:!1,exposeInternalsToGlobal:!1},uS=a=>{var e;return H(R({},(0,Fa.fillWithDefault)(a,oS)),{configName:[...(e=a.configName)!=null?e:[],...oS.configName]})};var f=require("@vkontakte/videoplayer-shared/es2015");var Ot=require("@vkontakte/videoplayer-shared/es2015"),pl=({seekState:a,position$:e})=>(0,Ot.merge)(a.stateChangeEnded$.pipe((0,Ot.map)(({to:t})=>{var r;return t.state==="none"?void 0:((r=t.position)!=null?r:NaN)/1e3}),(0,Ot.filter)(Ot.isNonNullable)),e.pipe((0,Ot.filter)(()=>a.getState().state==="none")));var lS=require("@vkontakte/videoplayer-shared/es2015"),cS=a=>{let e=typeof a.container=="string"?document.getElementById(a.container):a.container;return(0,lS.assertNonNullable)(e,`Wrong container or containerId {${a.container}}`),e};var gn=require("@vkontakte/videoplayer-shared/es2015"),dS=(a,e,t,r)=>{a!==void 0&&e.getState()===void 0&&e.getPrevState()===void 0&&(t==null?void 0:t.getValue().length)===0?t.pipe((0,gn.filter)(i=>i.length>0),(0,gn.once)()).subscribe(i=>{i.find(r)&&e.startTransitionTo(a)}):(a===void 0||t!=null&&t.getValue().find(r))&&e.startTransitionTo(a)};var qa=class{constructor(e={configName:[]},t=f.Tracer.createRootTracer(!1)){this.subscription=new f.Subscription;this.logger=new f.Logger;this.abrLogger=this.logger.createComponentLog("ABR");this.internalsExposure=null;this.isPlaybackStarted=!1;this.hasLiveOffsetByPaused=new f.ValueSubject(!1);this.hasLiveOffsetByPausedTimer=0;this.wasSetStartedQuality=!1;this.desiredState={playbackState:new j("stopped"),seekState:new j({state:"none"}),volume:new j({volume:1,muted:!1}),videoTrack:new j(void 0),videoStream:new j(void 0),audioStream:new j(void 0),autoVideoTrackSwitching:new j(!0),autoVideoTrackLimits:new j({}),isLooped:new j(!1),isLowLatency:new j(!1),playbackRate:new j(1),externalTextTracks:new j([]),internalTextTracks:new j([]),currentTextTrack:new j(void 0),textTrackCuesSettings:new j({}),cameraOrientation:new j({x:0,y:0})};this.info={playbackState$:new f.ValueSubject("stopped"),position$:new f.ValueSubject(0),duration$:new f.ValueSubject(1/0),muted$:new f.ValueSubject(!1),volume$:new f.ValueSubject(1),availableVideoStreams$:new f.ValueSubject([]),currentVideoStream$:new f.ValueSubject(void 0),availableQualities$:new f.ValueSubject([]),availableQualitiesFps$:new f.ValueSubject({}),currentQuality$:new f.ValueSubject(void 0),isAutoQualityEnabled$:new f.ValueSubject(!0),autoQualityLimitingAvailable$:new f.ValueSubject(!1),autoQualityLimits$:new f.ValueSubject({}),availableAudioStreams$:new f.ValueSubject([]),currentAudioStream$:new f.ValueSubject(void 0),availableAudioTracks$:new f.ValueSubject([]),isAudioAvailable$:new f.ValueSubject(!0),currentPlaybackRate$:new f.ValueSubject(1),currentBuffer$:new f.ValueSubject({start:0,end:0}),isBuffering$:new f.ValueSubject(!0),isStalled$:new f.ValueSubject(!1),isEnded$:new f.ValueSubject(!1),isLooped$:new f.ValueSubject(!1),isLive$:new f.ValueSubject(void 0),canChangePlaybackSpeed$:new f.ValueSubject(void 0),atLiveEdge$:new f.ValueSubject(void 0),atLiveDurationEdge$:new f.ValueSubject(void 0),liveTime$:new f.ValueSubject(void 0),liveBufferTime$:new f.ValueSubject(void 0),liveLatency$:new f.ValueSubject(void 0),currentFormat$:new f.ValueSubject(void 0),availableTextTracks$:new f.ValueSubject([]),currentTextTrack$:new f.ValueSubject(void 0),throughputEstimation$:new f.ValueSubject(void 0),rttEstimation$:new f.ValueSubject(void 0),videoBitrate$:new f.ValueSubject(void 0),hostname$:new f.ValueSubject(void 0),httpConnectionType$:new f.ValueSubject(void 0),httpConnectionReused$:new f.ValueSubject(void 0),surface$:new f.ValueSubject("none"),chromecastState$:new f.ValueSubject("NOT_AVAILABLE"),chromecastDeviceName$:new f.ValueSubject(void 0),intrinsicVideoSize$:new f.ValueSubject(void 0),availableSources$:new f.ValueSubject(void 0),is3DVideo$:new f.ValueSubject(!1),currentVideoSegmentLength$:new f.ValueSubject(0),currentAudioSegmentLength$:new f.ValueSubject(0)};this.events={inited$:new f.Subject,ready$:new f.Subject,started$:new f.Subject,playing$:new f.Subject,paused$:new f.Subject,stopped$:new f.Subject,willStart$:new f.Subject,willResume$:new f.Subject,willPause$:new f.Subject,willStop$:new f.Subject,willDestruct$:new f.Subject,watchCoverageRecord$:new f.Subject,watchCoverageLive$:new f.Subject,managedError$:new f.Subject,fatalError$:new f.Subject,ended$:new f.Subject,looped$:new f.Subject,seeked$:new f.Subject,willSeek$:new f.Subject,autoplaySoundProhibited$:new f.Subject,firstBytes$:new f.Subject,loadedMetadata$:new f.Subject,firstFrame$:new f.Subject,canplay$:new f.Subject,log$:new f.Subject};this.experimental={element$:new f.ValueSubject(void 0),tuningConfigName$:new f.ValueSubject([]),enableDebugTelemetry$:new f.ValueSubject(!1),dumpTelemetry:nb};if(this.initLogs(),this.tuning=uS(e),this.tracer=t,this.experimental.tuningConfigName$.next(this.tuning.configName),this.chromecastInitializer=new us({receiverApplicationId:e.chromecastReceiverId,isDisabled:e.disableChromecast,dependencies:{logger:this.logger}}),this.throughputEstimator=new nS(this.tuning.throughputEstimator),e.exposeInternalsToGlobal&&(this.internalsExposure=new f.InternalsExposure("CORE"),this.internalsExposure.expose({player:this})),this.initChromecastSubscription(),this.initDesiredStateSubscriptions(),Proxy&&Reflect)return new Proxy(this,{get:(r,i,s)=>{let n=Reflect.get(r,i,s);return typeof n!="function"?n:(...o)=>{try{return n.apply(r,o)}catch(u){let l=o.map(p=>JSON.stringify(p,(h,m)=>{let g=typeof m;return(0,pS.default)(["number","string","boolean"],g)?m:m===null?null:`<${g}>`})),d=`Player.${String(i)}`,c=`Exception calling ${d} (${l.join(", ")})`;throw this.events.fatalError$.next({id:d,category:f.ErrorCategory.WTF,message:c,thrown:u}),u}}}})}initVideo(e){var s,n,o,u;this.config=e;let i=e,{container:t}=i,r=Yl(i,["container"]);return this.tracer.log("initVideo",(0,f.flattenObject)(r)),this.domContainer=cS(e),this.chromecastInitializer.contentId=(s=e.meta)==null?void 0:s.videoId,this.providerContainer=new Na({sources:e.sources,meta:(n=e.meta)!=null?n:{},failoverHosts:(o=e.failoverHosts)!=null?o:[],container:this.domContainer,desiredState:this.desiredState,dependencies:{throughputEstimator:this.throughputEstimator,chromecastInitializer:this.chromecastInitializer,tracer:this.tracer,logger:this.logger,abrLogger:this.abrLogger},tuning:this.tuning,volumeMultiplier:e.volumeMultiplier}),this.initProviderContainerSubscription(this.providerContainer),this.initStartingVideoTrack(this.providerContainer),this.initTracerSubscription(),this.providerContainer.init(),this.setLiveLowLatency(this.tuning.dashCmafLive.lowLatency.isActiveOnDefault),this.setMuted(this.tuning.isAudioDisabled),this.initDebugTelemetry(),this.initWakeLock(),(u=this.internalsExposure)==null||u.expose({config:e,logger:this.logger,tuning:this.tuning}),this}destroy(){var e,t;this.tracer.log("destroy"),window.clearTimeout(this.hasLiveOffsetByPausedTimer),this.events.willDestruct$.next(),this.stop(),(e=this.providerContainer)==null||e.destroy(),this.throughputEstimator.destroy(),this.chromecastInitializer.destroy(),this.subscription.unsubscribe(),this.tracer.end(),(t=this.internalsExposure)==null||t.destroy()}prepare(){let e=this.desiredState.playbackState;return this.tracer.log("prepare",{currentPlayBackState:e.getState()}),e.getState()==="stopped"&&e.startTransitionTo("ready"),this}play(){let e=()=>{let t=this.desiredState.playbackState;this.tracer.log("play",{currentPlayBackState:t.getState()}),t.getState()!=="playing"&&t.startTransitionTo("playing")};return document.hidden&&this.tuning.autoplayOnlyInActiveTab&&!Qi()?(this.tracer.log("request play from hidden tab"),(0,f.fromEvent)(document,"visibilitychange").pipe((0,f.once)()).subscribe(e)):e(),this}pause(){let e=this.desiredState.playbackState;return this.tracer.log("pause",{currentPlayBackState:e.getState()}),e.getState()!=="paused"&&e.startTransitionTo("paused"),this}stop(){let e=this.desiredState.playbackState;return this.tracer.log("stop",{currentPlayBackState:e.getState()}),e.getState()!=="stopped"&&e.startTransitionTo("stopped"),this}seekTime(e,t=!0){let r=this.info.duration$.getValue(),i=this.info.isLive$.getValue(),s=e;return e>=r&&!i&&(s=r-.1),this.tracer.log("seekTime",{duration:r,isLive:i,time:e,calculatedTime:s,forcePrecise:t}),this.events.willSeek$.next({from:this.getExactTime(),to:s}),this.desiredState.seekState.setState({state:"requested",position:s*1e3,forcePrecise:t}),this}seekPercent(e){let t=this.info.duration$.getValue();return this.tracer.log("seekPercent",{percent:e,duration:t}),isFinite(t)&&this.seekTime(Math.abs(t)*e,!1),this}setVolume(e){let t=this.tuning.isAudioDisabled||this.desiredState.volume.getState().muted;return this.tracer.log("setVolume",{volume:e,isAudioDisabled:this.tuning.isAudioDisabled,isDesiredStateMuted:this.desiredState.volume.getState().muted,chromecastState:this.chromecastInitializer.castState$.getValue(),muted:t}),this.chromecastInitializer.castState$.getValue()==="CONNECTED"?this.chromecastInitializer.setVolume(e):this.desiredState.volume.startTransitionTo({volume:e,muted:t}),this}setMuted(e){let t=this.tuning.isAudioDisabled||e;return this.tracer.log("setMuted",{isMuted:e,isAudioDisabled:this.tuning.isAudioDisabled,desiredStateVolume:this.desiredState.volume.getState().volume,chromecastState:this.chromecastInitializer.castState$.getValue(),muted:t}),this.chromecastInitializer.castState$.getValue()==="CONNECTED"?this.chromecastInitializer.setMuted(t):this.desiredState.volume.startTransitionTo({volume:this.desiredState.volume.getState().volume,muted:t}),this}setVideoStream(e){return this.desiredState.videoStream.startTransitionTo(e),this}setAudioStream(e){return this.desiredState.audioStream.startTransitionTo(e),this}setQuality(e){(0,f.assertNonNullable)(this.providerContainer);let t=this.providerContainer.providerOutput.availableVideoTracks$.getValue();return this.tracer.log("setQuality",{isDelayed:t.length===0,quality:e}),this.desiredState.videoTrack.getState()===void 0&&this.desiredState.videoTrack.getPrevState()===void 0&&t.length===0?this.wasSetStartedQuality?this.providerContainer.providerOutput.availableVideoTracks$.pipe((0,f.filter)(r=>r.length>0),(0,f.once)()).subscribe(r=>{this.setVideoTrackIdByQuality(r,e)}):this.explicitInitialQuality=e:t.length>0&&this.setVideoTrackIdByQuality(t,e),this}setAutoQuality(e){return this.tracer.log("setAutoQuality",{enable:e}),this.desiredState.autoVideoTrackSwitching.startTransitionTo(e),this}setAutoQualityLimits(e){return this.tracer.log("setAutoQualityLimits",(0,f.flattenObject)(e)),this.desiredState.autoVideoTrackLimits.startTransitionTo(e),this}setPlaybackRate(e){var r;(0,f.assertNonNullable)(this.providerContainer);let t=(r=this.providerContainer)==null?void 0:r.providerOutput.element$.getValue();return this.tracer.log("setPlaybackRate",{playbackRate:e,isVideoElementAvailable:!!t}),t&&(this.desiredState.playbackRate.setState(e),t.playbackRate=e),this}setExternalTextTracks(e){return e.length&&this.tracer.log("setExternalTextTracks",(0,f.flattenObject)(e)),this.desiredState.externalTextTracks.startTransitionTo(e.map(t=>R({type:"external"},t))),this}selectTextTrack(e){var t;return dS(e,this.desiredState.currentTextTrack,(t=this.providerContainer)==null?void 0:t.providerOutput.availableTextTracks$,r=>r.id===e),this.tracer.log("selectTextTrack",{textTrackId:e}),this}setTextTrackCueSettings(e){return this.tracer.log("setTextTrackCueSettings",R({},e)),this.desiredState.textTrackCuesSettings.startTransitionTo(e),this}setLiveLowLatency(e){let t=this.info.isLive$.getValue(),r=this.desiredState.isLowLatency.getState();return!t||r===e?this:(this.tracer.log("live switch to low latency "+e),this.desiredState.isLowLatency.setState(e),this.seekTime(0))}setLooped(e){return this.tracer.log("setLooped",{isLooped:e}),this.desiredState.isLooped.startTransitionTo(e),this}toggleChromecast(){this.tracer.log("toggleChromecast"),this.chromecastInitializer.toggleConnection()}startCameraManualRotation(e,t){let r=this.getScene3D();return this.tracer.log("startCameraManualRotation",{isScene3DAvailable:!!r,mx:e,my:t}),r&&r.startCameraManualRotation(e,t),this}stopCameraManualRotation(e=!1){let t=this.getScene3D();return this.tracer.log("stopCameraManualRotation",{isScene3DAvailable:!!t,immediate:e}),t&&t.stopCameraManualRotation(e),this}moveCameraFocusPX(e,t){let r=this.getScene3D();if(this.tracer.log("moveCameraFocusPX",{isScene3DAvailable:!!r,dxpx:e,dypx:t}),r){let i=r.getCameraRotation(),s=r.pixelToDegree({x:e,y:t});this.desiredState.cameraOrientation.setState({x:i.x+s.x,y:i.y+s.y})}return this}holdCamera(){let e=this.getScene3D();return e&&e.holdCamera(),this}releaseCamera(){let e=this.getScene3D();return e&&e.releaseCamera(),this}getExactTime(){if(!this.providerContainer)return 0;let e=this.providerContainer.providerOutput.element$.getValue();if((0,f.isNullable)(e))return this.info.position$.getValue();let t=this.desiredState.seekState.getState(),r=t.state==="none"?void 0:t.position;return(0,f.isNonNullable)(r)?r/1e3:e.currentTime}getAllLogs(){return this.logger.getAllLogs()}getScene3D(){var t,r;let e=(t=this.providerContainer)==null?void 0:t.current$.getValue();if((r=e==null?void 0:e.provider)!=null&&r.scene3D)return e.provider.scene3D}setIntrinsicVideoSize(...e){let t={width:e.reduce((r,{width:i})=>r||i||0,0),height:e.reduce((r,{height:i})=>r||i||0,0)};t.width&&t.height&&this.info.intrinsicVideoSize$.next({width:t.width,height:t.height})}initDesiredStateSubscriptions(){this.subscription.add((0,f.merge)(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe((0,f.map)(e=>e.to)).subscribe(this.info.playbackState$)).add(this.desiredState.isLooped.stateChangeEnded$.pipe((0,f.map)(e=>e.to)).subscribe(this.info.isLooped$)).add(this.desiredState.playbackRate.stateChangeEnded$.pipe((0,f.map)(e=>e.to)).subscribe(this.info.currentPlaybackRate$)).add(this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe((0,f.map)(e=>e.to)).subscribe(this.info.isAutoQualityEnabled$)).add(this.desiredState.autoVideoTrackLimits.stateChangeEnded$.pipe((0,f.map)(e=>e.to)).subscribe(this.info.autoQualityLimits$)),this.subscription.add(this.desiredState.playbackState.stateChangeStarted$.pipe((0,f.filter)(({from:e})=>e==="stopped"),(0,f.once)()).subscribe(()=>{this.initedAt=(0,f.now)(),this.events.inited$.next()})).add(this.desiredState.playbackState.stateChangeEnded$.subscribe(e=>{switch(e.to){case"ready":this.events.ready$.next();break;case"playing":this.isPlaybackStarted||this.events.started$.next(),this.isPlaybackStarted=!0,this.events.playing$.next();break;case"paused":this.events.paused$.next();break;case"stopped":this.events.stopped$.next()}})).add(this.desiredState.playbackState.stateChangeStarted$.subscribe(e=>{switch(e.to){case"paused":this.events.willPause$.next();break;case"playing":this.isPlaybackStarted?this.events.willResume$.next():this.events.willStart$.next();break;case"stopped":this.events.willStop$.next();break;default:}}))}initProviderContainerSubscription(e){this.subscription.add(e.providerOutput.willSeekEvent$.subscribe(()=>{let n=this.desiredState.seekState.getState();this.tracer.log("willSeekEvent",(0,f.flattenObject)(n)),n.state==="requested"?this.desiredState.seekState.setState(H(R({},n),{state:"applying"})):this.events.managedError$.next({id:`WillSeekIn${n.state}`,category:f.ErrorCategory.WTF,message:"Received unexpeceted willSeek$"})})).add(e.providerOutput.soundProhibitedEvent$.pipe((0,f.once)()).subscribe(this.events.autoplaySoundProhibited$)).add(e.providerOutput.seekedEvent$.subscribe(()=>{let n=this.desiredState.seekState.getState();this.tracer.log("seekedEvent",(0,f.flattenObject)(n)),n.state==="applying"&&(this.desiredState.seekState.setState({state:"none"}),this.events.seeked$.next())})).add(e.current$.pipe((0,f.map)(n=>n.type)).subscribe(this.info.currentFormat$)).add(e.current$.pipe((0,f.map)(n=>n.destination),(0,f.filterChanged)()).subscribe(()=>this.isPlaybackStarted=!1)).add(e.providerOutput.availableVideoStreams$.subscribe(this.info.availableVideoStreams$)).add((0,f.combine)({availableVideoTracks:e.providerOutput.availableVideoTracks$,currentVideoStream:e.providerOutput.currentVideoStream$}).pipe((0,f.map)(({availableVideoTracks:n,currentVideoStream:o})=>n.filter(u=>o?o.id===u.streamId:!0).map(({quality:u})=>u).sort((u,l)=>(0,f.isInvariantQuality)(u)?1:(0,f.isInvariantQuality)(l)?-1:(0,f.isHigher)(l,u)?1:-1))).subscribe(this.info.availableQualities$)).add(e.providerOutput.availableVideoTracks$.subscribe(n=>{let o={};for(let u of n)u.fps&&(o[u.quality]=u.fps);this.info.availableQualitiesFps$.next(o)})).add(e.providerOutput.availableAudioStreams$.subscribe(this.info.availableAudioStreams$)).add(e.providerOutput.currentVideoStream$.subscribe(this.info.currentVideoStream$)).add(e.providerOutput.currentAudioStream$.subscribe(this.info.currentAudioStream$)).add(e.providerOutput.availableAudioTracks$.subscribe(this.info.availableAudioTracks$)).add(e.providerOutput.isAudioAvailable$.pipe((0,f.filterChanged)()).subscribe(this.info.isAudioAvailable$)).add(e.providerOutput.currentVideoTrack$.subscribe(n=>{this.info.currentQuality$.next(n==null?void 0:n.quality),this.info.videoBitrate$.next(n==null?void 0:n.bitrate)})).add(e.providerOutput.currentVideoSegmentLength$.pipe((0,f.filterChanged)((n,o)=>Math.round(n)===Math.round(o))).subscribe(this.info.currentVideoSegmentLength$)).add(e.providerOutput.currentAudioSegmentLength$.pipe((0,f.filterChanged)((n,o)=>Math.round(n)===Math.round(o))).subscribe(this.info.currentAudioSegmentLength$)).add(e.providerOutput.hostname$.pipe((0,f.filterChanged)()).subscribe(this.info.hostname$)).add(e.providerOutput.httpConnectionType$.pipe((0,f.filterChanged)()).subscribe(this.info.httpConnectionType$)).add(e.providerOutput.httpConnectionReused$.pipe((0,f.filterChanged)()).subscribe(this.info.httpConnectionReused$)).add(e.providerOutput.currentTextTrack$.subscribe(this.info.currentTextTrack$)).add(e.providerOutput.availableTextTracks$.subscribe(this.info.availableTextTracks$)).add(e.providerOutput.autoVideoTrackLimitingAvailable$.subscribe(this.info.autoQualityLimitingAvailable$)).add(e.providerOutput.autoVideoTrackLimits$.subscribe(n=>{this.desiredState.autoVideoTrackLimits.setState(n!=null?n:{})})).add(e.providerOutput.currentBuffer$.pipe((0,f.map)(n=>n?{start:n.from,end:n.to}:{start:0,end:0})).subscribe(this.info.currentBuffer$)).add(e.providerOutput.duration$.subscribe(this.info.duration$)).add(e.providerOutput.isBuffering$.subscribe(this.info.isBuffering$)).add(e.providerOutput.isLive$.subscribe(this.info.isLive$)).add(e.providerOutput.canChangePlaybackSpeed$.subscribe(this.info.canChangePlaybackSpeed$)).add(e.providerOutput.liveTime$.subscribe(this.info.liveTime$)).add(e.providerOutput.liveBufferTime$.subscribe(this.info.liveBufferTime$)).add(e.providerOutput.liveLatency$.subscribe(this.info.liveLatency$)).add((0,f.combine)({hasLiveOffsetByPaused:(0,f.merge)(this.desiredState.playbackState.stateChangeStarted$,this.desiredState.playbackState.forceChanged$).pipe((0,f.map)(n=>n.to),(0,f.filterChanged)(),(0,f.map)(n=>n==="paused")),isLowLatency:e.providerOutput.isLowLatency$}).subscribe(({hasLiveOffsetByPaused:n,isLowLatency:o})=>{if(window.clearTimeout(this.hasLiveOffsetByPausedTimer),n){this.hasLiveOffsetByPausedTimer=window.setTimeout(()=>{this.hasLiveOffsetByPaused.next(!0)},this.getActiveLiveDelay(o));return}this.hasLiveOffsetByPaused.next(!1)})).add((0,f.combine)({atLiveEdge:(0,f.combine)({isLive:e.providerOutput.isLive$,isLowLatency:e.providerOutput.isLowLatency$,position:pl({seekState:this.desiredState.seekState,position$:e.providerOutput.position$})}).pipe((0,f.map)(({isLive:n,position:o,isLowLatency:u})=>{let l=this.getActiveLiveDelay(u);return n&&Math.abs(o)<l/1e3}),(0,f.filterChanged)(),(0,f.tap)(n=>n&&this.setPlaybackRate(1))),hasPausedTimeoutCase:this.hasLiveOffsetByPaused}).pipe((0,f.map)(({atLiveEdge:n,hasPausedTimeoutCase:o})=>n&&!o)).subscribe(this.info.atLiveEdge$)).add((0,f.combine)({isLive:e.providerOutput.isLive$,position:e.providerOutput.position$,duration:e.providerOutput.duration$}).pipe((0,f.map)(({isLive:n,position:o,duration:u})=>n&&(Math.abs(u)-Math.abs(o))*1e3<this.tuning.live.activeLiveDelay),(0,f.filterChanged)(),(0,f.tap)(n=>n&&this.setPlaybackRate(1))).subscribe(this.info.atLiveDurationEdge$)).add(e.providerOutput.volume$.pipe((0,f.map)(n=>n.muted),(0,f.filterChanged)()).subscribe(this.info.muted$)).add(e.providerOutput.volume$.pipe((0,f.map)(n=>n.volume),(0,f.filterChanged)()).subscribe(this.info.volume$)).add(pl({seekState:this.desiredState.seekState,position$:e.providerOutput.position$}).subscribe(this.info.position$)).add((0,f.merge)(e.providerOutput.endedEvent$.pipe((0,f.mapTo)(!0)),e.providerOutput.seekedEvent$.pipe((0,f.mapTo)(!1))).pipe((0,f.filterChanged)()).subscribe(this.info.isEnded$)).add(e.providerOutput.endedEvent$.subscribe(this.events.ended$)).add(e.providerOutput.loopedEvent$.subscribe(this.events.looped$)).add(e.providerError$.subscribe(this.events.managedError$)).add(e.volumeMultiplierError$.subscribe(this.events.managedError$)).add(e.noAvailableProvidersError$.pipe((0,f.map)(n=>({id:n?`No${n}`:"NoProviders",category:f.ErrorCategory.VIDEO_PIPELINE,message:n?`${n} was forced but failed or not available`:"No suitable providers or all providers failed"}))).subscribe(this.events.fatalError$)).add(e.providerOutput.element$.subscribe(this.experimental.element$)).add(e.providerOutput.firstBytesEvent$.pipe((0,f.once)(),(0,f.map)(n=>n!=null?n:(0,f.now)()-this.initedAt)).subscribe(this.events.firstBytes$)).add(e.providerOutput.loadedMetadataEvent$.subscribe(this.events.loadedMetadata$)).add(e.providerOutput.firstFrameEvent$.pipe((0,f.once)(),(0,f.map)(()=>(0,f.now)()-this.initedAt)).subscribe(this.events.firstFrame$)).add(e.providerOutput.canplay$.pipe((0,f.once)(),(0,f.map)(()=>(0,f.now)()-this.initedAt)).subscribe(this.events.canplay$)).add(this.throughputEstimator.throughput$.subscribe(this.info.throughputEstimation$)).add(this.throughputEstimator.rtt$.subscribe(this.info.rttEstimation$)).add(e.providerOutput.availableSources$.subscribe(this.info.availableSources$));let t=new f.ValueSubject(!1);this.subscription.add(e.providerOutput.seekedEvent$.subscribe(()=>t.next(!1))).add(e.providerOutput.willSeekEvent$.subscribe(()=>t.next(!0)));let r=new f.ValueSubject(!0);this.subscription.add(e.current$.subscribe(()=>r.next(!0))).add(this.desiredState.playbackState.stateChangeEnded$.pipe((0,f.filter)(({to:n})=>n==="playing"),(0,f.once)()).subscribe(()=>r.next(!1)));let i=0,s=(0,f.merge)(e.providerOutput.isBuffering$,t,r).pipe((0,f.map)(()=>{let n=e.providerOutput.isBuffering$.getValue(),o=t.getValue()||r.getValue();return n&&!o}),(0,f.filterChanged)());this.subscription.add(s.subscribe(n=>{n?i=window.setTimeout(()=>this.info.isStalled$.next(!0),this.tuning.stallIgnoreThreshold):(window.clearTimeout(i),this.info.isStalled$.next(!1))})),this.subscription.add((0,f.merge)(e.providerOutput.canplay$,e.providerOutput.firstFrameEvent$,e.providerOutput.firstBytesEvent$).subscribe(()=>{let n=e.providerOutput.element$.getValue();this.setIntrinsicVideoSize({width:n==null?void 0:n.videoWidth,height:n==null?void 0:n.videoHeight})})).add(e.providerOutput.currentVideoTrack$.subscribe(n=>{var u,l;let o=e.providerOutput.element$.getValue();this.setIntrinsicVideoSize({width:(u=n==null?void 0:n.size)==null?void 0:u.width,height:(l=n==null?void 0:n.size)==null?void 0:l.height},{width:o==null?void 0:o.videoWidth,height:o==null?void 0:o.videoHeight})})).add(e.providerOutput.is3DVideo$.subscribe(this.info.is3DVideo$)),this.subscription.add((0,f.merge)(e.providerOutput.inPiP$,e.providerOutput.inFullscreen$,e.providerOutput.element$,e.providerOutput.elementVisible$,this.chromecastInitializer.castState$).subscribe(()=>{let n=e.providerOutput.inPiP$.getValue(),o=e.providerOutput.inFullscreen$.getValue(),u=e.providerOutput.element$.getValue(),l=e.providerOutput.elementVisible$.getValue(),d=this.chromecastInitializer.castState$.getValue(),c;d==="CONNECTED"?c="second_screen":u?l?n?c="pip":o?c="fullscreen":c="inline":c="invisible":c="none",this.info.surface$.getValue()!==c&&this.info.surface$.next(c)}))}initChromecastSubscription(){this.subscription.add(this.chromecastInitializer.castState$.subscribe(this.info.chromecastState$)),this.subscription.add(this.chromecastInitializer.connection$.pipe((0,f.map)(e=>e==null?void 0:e.castDevice.friendlyName)).subscribe(this.info.chromecastDeviceName$)),this.subscription.add(this.chromecastInitializer.errorEvent$.subscribe(this.events.managedError$))}initStartingVideoTrack(e){let t=new f.Subscription;this.subscription.add(t),this.subscription.add(e.current$.pipe((0,f.filterChanged)((r,i)=>r.provider===i.provider)).subscribe(()=>{t.unsubscribe(),t.add(e.providerOutput.availableVideoTracks$.pipe((0,f.filter)(r=>r.length>0),(0,f.once)()).subscribe(r=>{this.setStartingVideoTrack(r)}))}))}setStartingVideoTrack(e){var i,s;let t;this.wasSetStartedQuality=!0;let r=(s=this.explicitInitialQuality)!=null?s:(i=this.desiredState.videoTrack.getState())==null?void 0:i.quality;r&&(t=e.find(({quality:n})=>n===r),t||this.setAutoQuality(!0)),t||(t=Jt(e,{container:this.domContainer.getBoundingClientRect(),estimatedThroughput:this.throughputEstimator.throughput$.getValue(),tuning:this.tuning.autoTrackSelection,limits:this.desiredState.autoVideoTrackLimits.getState(),playbackRate:this.info.currentPlaybackRate$.getValue(),forwardBufferHealth:0,abrLogger:this.abrLogger})),this.desiredState.videoTrack.startTransitionTo(t),this.info.currentQuality$.next(t.quality),this.info.videoBitrate$.next(t.bitrate)}initLogs(){this.subscription.add((0,f.merge)(this.desiredState.videoTrack.stateChangeStarted$.pipe((0,f.map)(e=>({transition:e,entity:"quality",type:"start"}))),this.desiredState.videoTrack.stateChangeEnded$.pipe((0,f.map)(e=>({transition:e,entity:"quality",type:"end"}))),this.desiredState.autoVideoTrackSwitching.stateChangeStarted$.pipe((0,f.map)(e=>({transition:e,entity:"autoQualityEnabled",type:"start"}))),this.desiredState.autoVideoTrackSwitching.stateChangeEnded$.pipe((0,f.map)(e=>({transition:e,entity:"autoQualityEnabled",type:"end"}))),this.desiredState.seekState.stateChangeStarted$.pipe((0,f.map)(e=>({transition:e,entity:"seekState",type:"start"}))),this.desiredState.seekState.stateChangeEnded$.pipe((0,f.map)(e=>({transition:e,entity:"seekState",type:"end"}))),this.desiredState.playbackState.stateChangeStarted$.pipe((0,f.map)(e=>({transition:e,entity:"playbackState",type:"start"}))),this.desiredState.playbackState.stateChangeEnded$.pipe((0,f.map)(e=>({transition:e,entity:"playbackState",type:"end"})))).pipe((0,f.map)(e=>({component:"desiredState",message:`[${e.entity} change] ${e.type}: ${JSON.stringify(e.transition)}`}))).subscribe(this.logger.log)),this.subscription.add(this.logger.log$.subscribe(this.events.log$))}initDebugTelemetry(){var t;let e=(t=this.providerContainer)==null?void 0:t.providerOutput;(0,f.assertNonNullable)(this.providerContainer),(0,f.assertNonNullable)(e),sb(),this.experimental.enableDebugTelemetry$.next(this.tuning.enableTelemetryAtStart),[this.experimental.enableDebugTelemetry$.subscribe(r=>ab(r)),this.providerContainer.current$.subscribe(({type:r})=>qi("provider",r)),e.duration$.subscribe(r=>qi("duration",r)),e.availableVideoTracks$.pipe((0,f.filter)(r=>!!r.length),(0,f.once)()).subscribe(r=>qi("tracks",r)),this.events.fatalError$.subscribe(new $e("fatalError")),this.events.managedError$.subscribe(new $e("managedError")),e.position$.subscribe(new $e("position")),e.currentVideoTrack$.pipe((0,f.map)(r=>r==null?void 0:r.quality)).subscribe(new $e("quality")),this.info.currentBuffer$.subscribe(new $e("buffer")),e.isBuffering$.subscribe(new $e("isBuffering"))].forEach(r=>this.subscription.add(r)),qi("codecs",rg())}initTracerSubscription(){let e=(0,f.getTraceSubscriptionMethod)(this.tracer.log.bind(this.tracer)),t=(0,f.getTraceSubscriptionMethod)(this.tracer.error.bind(this.tracer));this.subscription.add(this.info.playbackState$.subscribe(e("playbackState"))).add(this.info.isLooped$.subscribe(e("isLooped"))).add(this.info.currentPlaybackRate$.pipe((0,f.filterChanged)()).subscribe(e("currentPlaybackRate"))).add(this.info.isAutoQualityEnabled$.subscribe(e("isAutoQualityEnabled"))).add(this.info.autoQualityLimits$.subscribe(e("autoQualityLimits"))).add(this.info.currentFormat$.subscribe(e("currentFormat"))).add(this.info.availableQualities$.subscribe(e("availableQualities"))).add(this.info.availableQualitiesFps$.subscribe(e("availableQualitiesFps"))).add(this.info.availableAudioTracks$.subscribe(e("availableAudioTracks"))).add(this.info.isAudioAvailable$.subscribe(e("isAudioAvailable"))).add((0,f.combine)({currentQuality:this.info.currentQuality$,videoBitrate:this.info.videoBitrate$}).pipe((0,f.filter)(({currentQuality:r,videoBitrate:i})=>!!r&&!!i),(0,f.filterChanged)((r,i)=>r.currentQuality===i.currentQuality)).subscribe(e("currentVideoTrack"))).add(this.info.currentVideoSegmentLength$.pipe((0,f.filter)(r=>r>0),(0,f.filterChanged)()).subscribe(e("currentVideoSegmentLength"))).add(this.info.currentAudioSegmentLength$.pipe((0,f.filter)(r=>r>0),(0,f.filterChanged)()).subscribe(e("currentAudioSegmentLength"))).add(this.info.hostname$.subscribe(e("hostname"))).add(this.info.currentTextTrack$.subscribe(e("currentTextTrack"))).add(this.info.availableTextTracks$.subscribe(e("availableTextTracks"))).add(this.info.autoQualityLimitingAvailable$.subscribe(e("autoQualityLimitingAvailable"))).add((0,f.combine)({currentBuffer:this.info.currentBuffer$.pipe((0,f.filter)(r=>r.end>0),(0,f.filterChanged)((r,i)=>r.end===i.end&&r.start===i.start)),position:this.info.position$.pipe((0,f.filterChanged)())}).pipe((0,f.throttle)(1e3)).subscribe(e("currentBufferAndPosition"))).add(this.info.duration$.pipe((0,f.filterChanged)()).subscribe(e("duration"))).add(this.info.isBuffering$.subscribe(e("isBuffering"))).add(this.info.isLive$.pipe((0,f.filterChanged)()).subscribe(e("isLive"))).add(this.info.canChangePlaybackSpeed$.pipe((0,f.filterChanged)()).subscribe(e("canChangePlaybackSpeed"))).add((0,f.combine)({liveTime:this.info.liveTime$,liveBufferTime:this.info.liveBufferTime$,position:this.info.position$}).pipe((0,f.filter)(({liveTime:r,liveBufferTime:i})=>!!r&&!!i),(0,f.throttle)(1e3)).subscribe(e("liveBufferAndPosition"))).add(this.info.atLiveEdge$.pipe((0,f.filterChanged)(),(0,f.filter)(r=>r===!0)).subscribe(e("atLiveEdge"))).add(this.info.atLiveDurationEdge$.pipe((0,f.filterChanged)(),(0,f.filter)(r=>r===!0)).subscribe(e("atLiveDurationEdge"))).add(this.info.muted$.pipe((0,f.filterChanged)()).subscribe(e("muted"))).add(this.info.volume$.pipe((0,f.filterChanged)()).subscribe(e("volume"))).add(this.info.isEnded$.pipe((0,f.filterChanged)(),(0,f.filter)(r=>r===!0)).subscribe(e("isEnded"))).add(this.info.availableSources$.subscribe(e("availableSources"))).add((0,f.combine)({throughputEstimation:this.info.throughputEstimation$,rtt:this.info.rttEstimation$}).pipe((0,f.filter)(({throughputEstimation:r,rtt:i})=>!!r&&!!i),(0,f.throttle)(3e3)).subscribe(e("throughputEstimation"))).add(this.info.isStalled$.subscribe(e("isStalled"))).add(this.info.is3DVideo$.pipe((0,f.filterChanged)(),(0,f.filter)(r=>r===!0)).subscribe(e("is3DVideo"))).add(this.info.surface$.subscribe(e("surface"))).add(this.events.ended$.subscribe(e("ended"))).add(this.events.looped$.subscribe(e("looped"))).add(this.events.managedError$.subscribe(t("managedError"))).add(this.events.fatalError$.subscribe(t("fatalError"))).add(this.events.firstBytes$.subscribe(e("firstBytes"))).add(this.events.firstFrame$.subscribe(e("firstFrame"))).add(this.events.canplay$.subscribe(e("canplay")))}initWakeLock(){if(!window.navigator.wakeLock||!this.tuning.enableWakeLock)return;let e,t=()=>{e==null||e.release(),e=void 0},r=()=>O(this,null,function*(){t(),e=yield window.navigator.wakeLock.request("screen").catch(i=>{i instanceof DOMException&&i.name==="NotAllowedError"||this.events.managedError$.next({id:"WakeLock",category:f.ErrorCategory.DOM,message:String(i)})})});this.subscription.add((0,f.merge)((0,f.fromEvent)(document,"visibilitychange"),(0,f.fromEvent)(document,"fullscreenchange"),this.desiredState.playbackState.stateChangeEnded$).subscribe(()=>{let i=document.visibilityState==="visible",s=this.desiredState.playbackState.getState()==="playing",n=!!e&&!(e!=null&&e.released);i&&s?n||r():t()})).add(this.events.willDestruct$.subscribe(t))}setVideoTrackIdByQuality(e,t){let r=e.find(i=>i.quality===t);this.tracer.log("setVideoTrackIdByQuality",(0,f.flattenObject)({quality:t,availableTracks:(0,f.flattenObject)(e),track:(0,f.flattenObject)(r),isAutoQuality:!r})),r?this.desiredState.videoTrack.startTransitionTo(r):this.setAutoQuality(!0)}getActiveLiveDelay(e=!1){return e?this.tuning.live.lowLatencyActiveLiveDelay:this.tuning.live.activeLiveDelay}};var St=require("@vkontakte/videoplayer-shared/es2015"),a$=`@vkontakte/videoplayer-core@${Pn}`;