@vkontakte/videoplayer-interactive 1.0.56-dev.31e6196f.0 → 1.0.56-dev.d24d1c13.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 +3 -3
- package/es2015.esm.js +3 -3
- package/es2018.cjs +3 -3
- package/es2018.esm.js +3 -3
- package/es2024.cjs +3 -3
- package/es2024.esm.js +3 -3
- package/esnext.cjs +3 -3
- package/esnext.esm.js +3 -3
- package/evergreen.esm.js +3 -3
- package/package.json +4 -4
package/es2015.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.56-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.56-dev.d24d1c13.0
|
|
3
|
+
* Tue, 30 Dec 2025 12:36:00 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-56/doc/
|
|
5
5
|
*/
|
|
6
|
-
var kl=Object.create;var pr=Object.defineProperty,Pl=Object.defineProperties,Vl=Object.getOwnPropertyDescriptor,Ml=Object.getOwnPropertyDescriptors,_l=Object.getOwnPropertyNames,ft=Object.getOwnPropertySymbols,Ll=Object.getPrototypeOf,hr=Object.prototype.hasOwnProperty,ji=Object.prototype.propertyIsEnumerable;var Bi=r=>{throw TypeError(r)};var $i=(r,e,t)=>e in r?pr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,f=(r,e)=>{for(var t in e||(e={}))hr.call(e,t)&&$i(r,t,e[t]);if(ft)for(var t of ft(e))ji.call(e,t)&&$i(r,t,e[t]);return r},A=(r,e)=>Pl(r,Ml(e));var ee=(r,e)=>{var t={};for(var i in r)hr.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&ft)for(var i of ft(r))e.indexOf(i)<0&&ji.call(r,i)&&(t[i]=r[i]);return t};var u=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Fl=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _l(e))!hr.call(r,n)&&n!==t&&pr(r,n,{get:()=>e[n],enumerable:!(i=Vl(e,n))||i.enumerable});return r};var te=(r,e,t)=>(t=r!=null?kl(Ll(r)):{},Fl(e||!r||!r.__esModule?pr(t,"default",{value:r,enumerable:!0}):t,r));var qi=(r,e,t)=>e.has(r)||Bi("Cannot "+t);var w=(r,e,t)=>(qi(r,e,"read from private field"),t?t.call(r):e.get(r)),W=(r,e,t)=>e.has(r)?Bi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),N=(r,e,t,i)=>(qi(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var Di=(r,e,t,i)=>({set _(n){N(r,e,n,t)},get _(){return w(r,e,i)}});var R=(r,e,t)=>new Promise((i,n)=>{var o=a=>{try{s(t.next(a))}catch(c){n(c)}},l=a=>{try{s(t.throw(a))}catch(c){n(c)}},s=a=>a.done?i(a.value):Promise.resolve(a.value).then(o,l);s((t=t.apply(r,e)).next())});var ie=u((Er,Ji)=>{"use strict";var De=function(r){return r&&r.Math===Math&&r};Ji.exports=De(typeof globalThis=="object"&&globalThis)||De(typeof window=="object"&&window)||De(typeof self=="object"&&self)||De(typeof global=="object"&&global)||De(typeof Er=="object"&&Er)||function(){return this}()||Function("return this")()});var z=u((Gd,en)=>{"use strict";en.exports=function(r){try{return!!r()}catch(e){return!0}}});var He=u((Wd,tn)=>{"use strict";var Bl=z();tn.exports=!Bl(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var an=u((zd,sn)=>{"use strict";var ql=He(),on=Function.prototype,rn=on.apply,nn=on.call;sn.exports=typeof Reflect=="object"&&Reflect.apply||(ql?nn.bind(rn):function(){return nn.apply(rn,arguments)})});var Y=u((Kd,un)=>{"use strict";var ln=He(),cn=Function.prototype,Tr=cn.call,Dl=ln&&cn.bind.bind(Tr,Tr);un.exports=ln?Dl:function(r){return function(){return Tr.apply(r,arguments)}}});var Ue=u((Qd,hn)=>{"use strict";var pn=Y(),Hl=pn({}.toString),Ul=pn("".slice);hn.exports=function(r){return Ul(Hl(r),8,-1)}});var Ir=u((Xd,dn)=>{"use strict";var Gl=Ue(),Wl=Y();dn.exports=function(r){if(Gl(r)==="Function")return Wl(r)}});var K=u((Yd,mn)=>{"use strict";var xr=typeof document=="object"&&document.all;mn.exports=typeof xr=="undefined"&&xr!==void 0?function(r){return typeof r=="function"||r===xr}:function(r){return typeof r=="function"}});var ve=u((Zd,fn)=>{"use strict";var zl=z();fn.exports=!zl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var St=u((Jd,vn)=>{"use strict";var Kl=He(),At=Function.prototype.call;vn.exports=Kl?At.bind(At):function(){return At.apply(At,arguments)}});var Ar=u(gn=>{"use strict";var bn={}.propertyIsEnumerable,yn=Object.getOwnPropertyDescriptor,Ql=yn&&!bn.call({1:2},1);gn.f=Ql?function(e){var t=yn(this,e);return!!t&&t.enumerable}:bn});var Sr=u((tm,Cn)=>{"use strict";Cn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Tn=u((rm,En)=>{"use strict";var Xl=Y(),Yl=z(),Zl=Ue(),wr=Object,Jl=Xl("".split);En.exports=Yl(function(){return!wr("z").propertyIsEnumerable(0)})?function(r){return Zl(r)==="String"?Jl(r,""):wr(r)}:wr});var Rr=u((im,In)=>{"use strict";In.exports=function(r){return r==null}});var Or=u((nm,xn)=>{"use strict";var ec=Rr(),tc=TypeError;xn.exports=function(r){if(ec(r))throw new tc("Can't call method on "+r);return r}});var Ge=u((om,An)=>{"use strict";var rc=Tn(),ic=Or();An.exports=function(r){return rc(ic(r))}});var we=u((sm,Sn)=>{"use strict";var nc=K();Sn.exports=function(r){return typeof r=="object"?r!==null:nc(r)}});var We=u((am,wn)=>{"use strict";wn.exports={}});var wt=u((lm,On)=>{"use strict";var kr=We(),Pr=ie(),oc=K(),Rn=function(r){return oc(r)?r:void 0};On.exports=function(r,e){return arguments.length<2?Rn(kr[r])||Rn(Pr[r]):kr[r]&&kr[r][e]||Pr[r]&&Pr[r][e]}});var Pn=u((cm,kn)=>{"use strict";var sc=Y();kn.exports=sc({}.isPrototypeOf)});var Ln=u((um,_n)=>{"use strict";var ac=ie(),Vn=ac.navigator,Mn=Vn&&Vn.userAgent;_n.exports=Mn?String(Mn):""});var Dn=u((pm,qn)=>{"use strict";var Bn=ie(),Vr=Ln(),Fn=Bn.process,Nn=Bn.Deno,$n=Fn&&Fn.versions||Nn&&Nn.version,jn=$n&&$n.v8,Z,Rt;jn&&(Z=jn.split("."),Rt=Z[0]>0&&Z[0]<4?1:+(Z[0]+Z[1]));!Rt&&Vr&&(Z=Vr.match(/Edge\/(\d+)/),(!Z||Z[1]>=74)&&(Z=Vr.match(/Chrome\/(\d+)/),Z&&(Rt=+Z[1])));qn.exports=Rt});var Mr=u((hm,Un)=>{"use strict";var Hn=Dn(),lc=z(),cc=ie(),uc=cc.String;Un.exports=!!Object.getOwnPropertySymbols&&!lc(function(){var r=Symbol("symbol detection");return!uc(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Hn&&Hn<41})});var _r=u((dm,Gn)=>{"use strict";var pc=Mr();Gn.exports=pc&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Lr=u((mm,Wn)=>{"use strict";var hc=wt(),dc=K(),mc=Pn(),fc=_r(),vc=Object;Wn.exports=fc?function(r){return typeof r=="symbol"}:function(r){var e=hc("Symbol");return dc(e)&&mc(e.prototype,vc(r))}});var Kn=u((fm,zn)=>{"use strict";var bc=String;zn.exports=function(r){try{return bc(r)}catch(e){return"Object"}}});var Fr=u((vm,Qn)=>{"use strict";var yc=K(),gc=Kn(),Cc=TypeError;Qn.exports=function(r){if(yc(r))return r;throw new Cc(gc(r)+" is not a function")}});var Yn=u((bm,Xn)=>{"use strict";var Ec=Fr(),Tc=Rr();Xn.exports=function(r,e){var t=r[e];return Tc(t)?void 0:Ec(t)}});var Jn=u((ym,Zn)=>{"use strict";var Nr=St(),$r=K(),jr=we(),Ic=TypeError;Zn.exports=function(r,e){var t,i;if(e==="string"&&$r(t=r.toString)&&!jr(i=Nr(t,r))||$r(t=r.valueOf)&&!jr(i=Nr(t,r))||e!=="string"&&$r(t=r.toString)&&!jr(i=Nr(t,r)))return i;throw new Ic("Can't convert object to primitive value")}});var to=u((gm,eo)=>{"use strict";eo.exports=!0});var no=u((Cm,io)=>{"use strict";var ro=ie(),xc=Object.defineProperty;io.exports=function(r,e){try{xc(ro,r,{value:e,configurable:!0,writable:!0})}catch(t){ro[r]=e}return e}});var Ot=u((Em,ao)=>{"use strict";var Ac=to(),Sc=ie(),wc=no(),oo="__core-js_shared__",so=ao.exports=Sc[oo]||wc(oo,{});(so.versions||(so.versions=[])).push({version:"3.43.0",mode:Ac?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Br=u((Tm,co)=>{"use strict";var lo=Ot();co.exports=function(r,e){return lo[r]||(lo[r]=e||{})}});var ze=u((Im,uo)=>{"use strict";var Rc=Or(),Oc=Object;uo.exports=function(r){return Oc(Rc(r))}});var Re=u((xm,po)=>{"use strict";var kc=Y(),Pc=ze(),Vc=kc({}.hasOwnProperty);po.exports=Object.hasOwn||function(e,t){return Vc(Pc(e),t)}});var qr=u((Am,ho)=>{"use strict";var Mc=Y(),_c=0,Lc=Math.random(),Fc=Mc(1.1.toString);ho.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Fc(++_c+Lc,36)}});var Ke=u((Sm,fo)=>{"use strict";var Nc=ie(),$c=Br(),mo=Re(),jc=qr(),Bc=Mr(),qc=_r(),Oe=Nc.Symbol,Dr=$c("wks"),Dc=qc?Oe.for||Oe:Oe&&Oe.withoutSetter||jc;fo.exports=function(r){return mo(Dr,r)||(Dr[r]=Bc&&mo(Oe,r)?Oe[r]:Dc("Symbol."+r)),Dr[r]}});var go=u((wm,yo)=>{"use strict";var Hc=St(),vo=we(),bo=Lr(),Uc=Yn(),Gc=Jn(),Wc=Ke(),zc=TypeError,Kc=Wc("toPrimitive");yo.exports=function(r,e){if(!vo(r)||bo(r))return r;var t=Uc(r,Kc),i;if(t){if(e===void 0&&(e="default"),i=Hc(t,r,e),!vo(i)||bo(i))return i;throw new zc("Can't convert object to primitive value")}return e===void 0&&(e="number"),Gc(r,e)}});var Hr=u((Rm,Co)=>{"use strict";var Qc=go(),Xc=Lr();Co.exports=function(r){var e=Qc(r,"string");return Xc(e)?e:e+""}});var Io=u((Om,To)=>{"use strict";var Yc=ie(),Eo=we(),Ur=Yc.document,Zc=Eo(Ur)&&Eo(Ur.createElement);To.exports=function(r){return Zc?Ur.createElement(r):{}}});var Gr=u((km,xo)=>{"use strict";var Jc=ve(),eu=z(),tu=Io();xo.exports=!Jc&&!eu(function(){return Object.defineProperty(tu("div"),"a",{get:function(){return 7}}).a!==7})});var wo=u(So=>{"use strict";var ru=ve(),iu=St(),nu=Ar(),ou=Sr(),su=Ge(),au=Hr(),lu=Re(),cu=Gr(),Ao=Object.getOwnPropertyDescriptor;So.f=ru?Ao:function(e,t){if(e=su(e),t=au(t),cu)try{return Ao(e,t)}catch(i){}if(lu(e,t))return ou(!iu(nu.f,e,t),e[t])}});var Oo=u((Vm,Ro)=>{"use strict";var uu=z(),pu=K(),hu=/#|\.prototype\./,Qe=function(r,e){var t=mu[du(r)];return t===vu?!0:t===fu?!1:pu(e)?uu(e):!!e},du=Qe.normalize=function(r){return String(r).replace(hu,".").toLowerCase()},mu=Qe.data={},fu=Qe.NATIVE="N",vu=Qe.POLYFILL="P";Ro.exports=Qe});var Wr=u((Mm,Po)=>{"use strict";var ko=Ir(),bu=Fr(),yu=He(),gu=ko(ko.bind);Po.exports=function(r,e){return bu(r),e===void 0?r:yu?gu(r,e):function(){return r.apply(e,arguments)}}});var Mo=u((_m,Vo)=>{"use strict";var Cu=ve(),Eu=z();Vo.exports=Cu&&Eu(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Lo=u((Lm,_o)=>{"use strict";var Tu=we(),Iu=String,xu=TypeError;_o.exports=function(r){if(Tu(r))return r;throw new xu(Iu(r)+" is not an object")}});var $o=u(No=>{"use strict";var Au=ve(),Su=Gr(),wu=Mo(),kt=Lo(),Fo=Hr(),Ru=TypeError,zr=Object.defineProperty,Ou=Object.getOwnPropertyDescriptor,Kr="enumerable",Qr="configurable",Xr="writable";No.f=Au?wu?function(e,t,i){if(kt(e),t=Fo(t),kt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Xr in i&&!i[Xr]){var n=Ou(e,t);n&&n[Xr]&&(e[t]=i.value,i={configurable:Qr in i?i[Qr]:n[Qr],enumerable:Kr in i?i[Kr]:n[Kr],writable:!1})}return zr(e,t,i)}:zr:function(e,t,i){if(kt(e),t=Fo(t),kt(i),Su)try{return zr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new Ru("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Bo=u((Nm,jo)=>{"use strict";var ku=ve(),Pu=$o(),Vu=Sr();jo.exports=ku?function(r,e,t){return Pu.f(r,e,Vu(1,t))}:function(r,e,t){return r[e]=t,r}});var Ve=u(($m,Do)=>{"use strict";var Xe=ie(),Mu=an(),_u=Ir(),Lu=K(),Fu=wo().f,Nu=Oo(),ke=We(),$u=Wr(),Pe=Bo(),qo=Re();Ot();var ju=function(r){var e=function(t,i,n){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,i)}return new r(t,i,n)}return Mu(r,this,arguments)};return e.prototype=r.prototype,e};Do.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,l=i?Xe:n?Xe[t]:Xe[t]&&Xe[t].prototype,s=i?ke:ke[t]||Pe(ke,t,{})[t],a=s.prototype,c,d,v,b,g,E,T,m,p;for(b in e)c=Nu(i?b:t+(n?".":"#")+b,r.forced),d=!c&&l&&qo(l,b),E=s[b],d&&(r.dontCallGetSet?(p=Fu(l,b),T=p&&p.value):T=l[b]),g=d&&T?T:e[b],!(!c&&!o&&typeof E==typeof g)&&(r.bind&&d?m=$u(g,Xe):r.wrap&&d?m=ju(g):o&&Lu(g)?m=_u(g):m=g,(r.sham||g&&g.sham||E&&E.sham)&&Pe(m,"sham",!0),Pe(s,b,m),o&&(v=t+"Prototype",qo(ke,v)||Pe(ke,v,{}),Pe(ke[v],b,g),r.real&&a&&(c||!a[b])&&Pe(a,b,g)))}});var Uo=u((jm,Ho)=>{"use strict";var Bu=Math.ceil,qu=Math.floor;Ho.exports=Math.trunc||function(e){var t=+e;return(t>0?qu:Bu)(t)}});var Ye=u((Bm,Go)=>{"use strict";var Du=Uo();Go.exports=function(r){var e=+r;return e!==e||e===0?0:Du(e)}});var zo=u((qm,Wo)=>{"use strict";var Hu=Ye(),Uu=Math.max,Gu=Math.min;Wo.exports=function(r,e){var t=Hu(r);return t<0?Uu(t+e,0):Gu(t,e)}});var Qo=u((Dm,Ko)=>{"use strict";var Wu=Ye(),zu=Math.min;Ko.exports=function(r){var e=Wu(r);return e>0?zu(e,9007199254740991):0}});var Ze=u((Hm,Xo)=>{"use strict";var Ku=Qo();Xo.exports=function(r){return Ku(r.length)}});var Yr=u((Um,Zo)=>{"use strict";var Qu=Ge(),Xu=zo(),Yu=Ze(),Yo=function(r){return function(e,t,i){var n=Qu(e),o=Yu(n);if(o===0)return!r&&-1;var l=Xu(i,o),s;if(r&&t!==t){for(;o>l;)if(s=n[l++],s!==s)return!0}else for(;o>l;l++)if((r||l in n)&&n[l]===t)return r||l||0;return!r&&-1}};Zo.exports={includes:Yo(!0),indexOf:Yo(!1)}});var Pt=u((Gm,Jo)=>{"use strict";Jo.exports=function(){}});var es=u(()=>{"use strict";var Zu=Ve(),Ju=Yr().includes,ep=z(),tp=Pt(),rp=ep(function(){return!Array(1).includes()});Zu({target:"Array",proto:!0,forced:rp},{includes:function(e){return Ju(this,e,arguments.length>1?arguments[1]:void 0)}});tp("includes")});var Vt=u((Km,ts)=>{"use strict";var ip=wt();ts.exports=ip});var is=u((Qm,rs)=>{"use strict";es();var np=Vt();rs.exports=np("Array","includes")});var os=u((Xm,ns)=>{"use strict";var op=is();ns.exports=op});var Mt=u((Ym,ss)=>{"use strict";var sp=os();ss.exports=sp});var Ss=u(()=>{"use strict";var mp=Ve(),fp=ze(),vp=Ze(),bp=Ye(),yp=Pt();mp({target:"Array",proto:!0},{at:function(e){var t=fp(this),i=vp(t),n=bp(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});yp("at")});var Rs=u((Pv,ws)=>{"use strict";Ss();var gp=Vt();ws.exports=gp("Array","at")});var ks=u((Vv,Os)=>{"use strict";var Cp=Rs();Os.exports=Cp});var ai=u((Mv,Ps)=>{"use strict";var Ep=ks();Ps.exports=Ep});var Ns=u((Yv,Fs)=>{"use strict";var xp=Br(),Ap=qr(),Ls=xp("keys");Fs.exports=function(r){return Ls[r]||(Ls[r]=Ap(r))}});var js=u((Zv,$s)=>{"use strict";var Sp=z();$s.exports=!Sp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Ds=u((Jv,qs)=>{"use strict";var wp=Re(),Rp=K(),Op=ze(),kp=Ns(),Pp=js(),Bs=kp("IE_PROTO"),li=Object,Vp=li.prototype;qs.exports=Pp?li.getPrototypeOf:function(r){var e=Op(r);if(wp(e,Bs))return e[Bs];var t=e.constructor;return Rp(t)&&e instanceof t?t.prototype:e instanceof li?Vp:null}});var Us=u((eb,Hs)=>{"use strict";Hs.exports={}});var zs=u((tb,Ws)=>{"use strict";var Mp=Y(),ci=Re(),_p=Ge(),Lp=Yr().indexOf,Fp=Us(),Gs=Mp([].push);Ws.exports=function(r,e){var t=_p(r),i=0,n=[],o;for(o in t)!ci(Fp,o)&&ci(t,o)&&Gs(n,o);for(;e.length>i;)ci(t,o=e[i++])&&(~Lp(n,o)||Gs(n,o));return n}});var Qs=u((rb,Ks)=>{"use strict";Ks.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Ys=u((ib,Xs)=>{"use strict";var Np=zs(),$p=Qs();Xs.exports=Object.keys||function(e){return Np(e,$p)}});var ui=u((nb,ra)=>{"use strict";var Js=ve(),jp=z(),ea=Y(),Bp=Ds(),qp=Ys(),Dp=Ge(),Hp=Ar().f,ta=ea(Hp),Up=ea([].push),Gp=Js&&jp(function(){var r=Object.create(null);return r[2]=2,!ta(r,2)}),Zs=function(r){return function(e){for(var t=Dp(e),i=qp(t),n=Gp&&Bp(t)===null,o=i.length,l=0,s=[],a;o>l;)a=i[l++],(!Js||(n?a in t:ta(t,a)))&&Up(s,r?[a,t[a]]:t[a]);return s}};ra.exports={entries:Zs(!0),values:Zs(!1)}});var ia=u(()=>{"use strict";var Wp=Ve(),zp=ui().entries;Wp({target:"Object",stat:!0},{entries:function(e){return zp(e)}})});var oa=u((ab,na)=>{"use strict";ia();var Kp=We();na.exports=Kp.Object.entries});var aa=u((lb,sa)=>{"use strict";var Qp=oa();sa.exports=Qp});var ca=u((cb,la)=>{"use strict";var Xp=aa();la.exports=Xp});var fa=u(()=>{"use strict";var nh=Ve(),oh=ui().values;nh({target:"Object",stat:!0},{values:function(e){return oh(e)}})});var ba=u((Kb,va)=>{"use strict";fa();var sh=We();va.exports=sh.Object.values});var ga=u((Qb,ya)=>{"use strict";var ah=ba();ya.exports=ah});var rr=u((Xb,Ca)=>{"use strict";var lh=ga();Ca.exports=lh});var Ei=u((xy,Sa)=>{"use strict";var mh=Ue();Sa.exports=Array.isArray||function(e){return mh(e)==="Array"}});var Ra=u((Ay,wa)=>{"use strict";var fh=TypeError,vh=9007199254740991;wa.exports=function(r){if(r>vh)throw fh("Maximum allowed index exceeded");return r}});var Pa=u((Sy,ka)=>{"use strict";var bh=Ei(),yh=Ze(),gh=Ra(),Ch=Wr(),Oa=function(r,e,t,i,n,o,l,s){for(var a=n,c=0,d=l?Ch(l,s):!1,v,b;c<i;)c in t&&(v=d?d(t[c],c,e):t[c],o>0&&bh(v)?(b=yh(v),a=Oa(r,e,v,b,a,o-1)-1):(gh(a+1),r[a]=v),a++),c++;return a};ka.exports=Oa});var _a=u((wy,Ma)=>{"use strict";var Eh=Ke(),Th=Eh("toStringTag"),Va={};Va[Th]="z";Ma.exports=String(Va)==="[object z]"});var Fa=u((Ry,La)=>{"use strict";var Ih=_a(),xh=K(),nr=Ue(),Ah=Ke(),Sh=Ah("toStringTag"),wh=Object,Rh=nr(function(){return arguments}())==="Arguments",Oh=function(r,e){try{return r[e]}catch(t){}};La.exports=Ih?nr:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=Oh(e=wh(r),Sh))=="string"?t:Rh?nr(e):(i=nr(e))==="Object"&&xh(e.callee)?"Arguments":i}});var $a=u((Oy,Na)=>{"use strict";var kh=Y(),Ph=K(),Ti=Ot(),Vh=kh(Function.toString);Ph(Ti.inspectSource)||(Ti.inspectSource=function(r){return Vh(r)});Na.exports=Ti.inspectSource});var Ua=u((ky,Ha)=>{"use strict";var Mh=Y(),_h=z(),ja=K(),Lh=Fa(),Fh=wt(),Nh=$a(),Ba=function(){},qa=Fh("Reflect","construct"),Ii=/^\s*(?:class|function)\b/,$h=Mh(Ii.exec),jh=!Ii.test(Ba),ut=function(e){if(!ja(e))return!1;try{return qa(Ba,[],e),!0}catch(t){return!1}},Da=function(e){if(!ja(e))return!1;switch(Lh(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return jh||!!$h(Ii,Nh(e))}catch(t){return!0}};Da.sham=!0;Ha.exports=!qa||_h(function(){var r;return ut(ut.call)||!ut(Object)||!ut(function(){r=!0})||r})?Da:ut});var Ka=u((Py,za)=>{"use strict";var Ga=Ei(),Bh=Ua(),qh=we(),Dh=Ke(),Hh=Dh("species"),Wa=Array;za.exports=function(r){var e;return Ga(r)&&(e=r.constructor,Bh(e)&&(e===Wa||Ga(e.prototype))?e=void 0:qh(e)&&(e=e[Hh],e===null&&(e=void 0))),e===void 0?Wa:e}});var Xa=u((Vy,Qa)=>{"use strict";var Uh=Ka();Qa.exports=function(r,e){return new(Uh(r))(e===0?0:e)}});var Ya=u(()=>{"use strict";var Gh=Ve(),Wh=Pa(),zh=ze(),Kh=Ze(),Qh=Ye(),Xh=Xa();Gh({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=zh(this),i=Kh(t),n=Xh(t,0);return n.length=Wh(n,t,t,i,0,e===void 0?1:Qh(e)),n}})});var Za=u(()=>{"use strict";var Yh=Pt();Yh("flat")});var el=u((Ny,Ja)=>{"use strict";Ya();Za();var Zh=Vt();Ja.exports=Zh("Array","flat")});var rl=u(($y,tl)=>{"use strict";var Jh=el();tl.exports=Jh});var nl=u((jy,il)=>{"use strict";var ed=rl();il.exports=ed});var Hi="1.0.56-dev.31e6196f.0";import{fromEvent as As,Subscription as dp}from"@vkontakte/videoplayer-shared/es2015";var dr=class{constructor(e,t){this.layout=e;this.cssVarsManager=t}},vt=class extends dr{constructor(t,i){super(t,i);this.cssVarsManager=i;this.cssVarsManager=i}setContainerLayout(t){t.style.position="relative"}setControlLayout(t,i){let n=this.cssVarsManager.getPropValue("--interactive-content-width"),o=this.cssVarsManager.getPropValue("--interactive-content-height"),l=this.cssVarsManager.getPropValue("--interactive-width"),s=this.cssVarsManager.getPropValue("--interactive-height"),a=2e-4;t.style.position="absolute",t.style.width=`calc(${n} * (${i.width} + ${a}))`,t.style.height=`calc(${o} * ${i.height})`,t.style.left=`calc(${n} * ${i.x} + ((${l} - ${n}) / 2))`,t.style.top=`calc(${o} * ${i.y} + ((${s} - ${o}) / 2))`}};import{Subject as Nl}from"@vkontakte/videoplayer-shared/es2015";function Ui(r){return"features"in r}var B=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};function bt({emitter$:r,error:e,subjectId:t,message:i="",severity:n=1,category:o=1}){let l=new B(n,o,{message:i,error:e,details:{id:t}});r.next(l)}var xe=class{constructor(e,t,i){this.error$=new Nl;this.container=e,this.options=i,this.factories=new Map,this.controls=[],this.setControls(),this.cssVarsManager=t}featureIsEnabled(e){return this.options&&this.options.features&&Ui(this.options)&&this.options.features[e]}onError(e="",t){bt({emitter$:this.error$,error:t,message:e,subjectId:this.container.id})}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){var e;return((e=this.container.controls)==null?void 0:e.reduce((t,i)=>{let n=i.type.trim().toLowerCase(),o=this.factories.get(n);if(o){let l=o(i,this.options);if(l)return[...t,l]}return[...t]},[]))||[]}};import{fromEvent as et,once as fs}from"@vkontakte/videoplayer-shared/es2015";var pe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,he=r=>pe(r,"Object"),yt=r=>pe(r,"String"),gt=r=>pe(r,"Array"),Ct=r=>pe(r,"Number"),Gi=r=>pe(r,"Function"),Wi=r=>pe(r,"Boolean"),vr=r=>Ct(r)&&!isNaN(r);var me=r=>he(r)&&Object.keys(r).length===0,br=r=>gt(r)&&!r.length;var je=(r,e)=>yt(r)&&(e?r.trim():r).length;function Be(r,e=1){let t="0",i="0",n="0";return r.length===4?(t="0x"+r[1]+r[1],i="0x"+r[2]+r[2],n="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],i="0x"+r[3]+r[4],n="0x"+r[5]+r[6]),`rgba(${+t},${+i},${+n},${e})`}var zi="interactive",L={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},Ki=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(Ki||{}),Qi=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(Qi||{}),Xi=(i=>(i.start="left",i.end="right",i.center="center",i))(Xi||{}),Et=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&Ki[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&Qi[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&Xi[e.alignment])!=null?n:"center"},Tt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,o,l,s,a,c;r.style.color=(o=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?o:t.textColor,r.style.fontSize=`calc(${i.height} * ${(s=(l=e==null?void 0:e.text)==null?void 0:l.size)!=null?s:t.textSize})`,r.textContent=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},It=({target:r,props:e,fallback:t})=>{var i,n,o,l;r.style.backgroundColor=Be((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(l=(o=e==null?void 0:e.background)==null?void 0:o.alpha)!=null?l:t.backgroundAlpha)},qe=({target:r,props:e,fallback:t,dependsOn:i,useRawValues:n=!1})=>{var s,a,c,d,v,b,g,E,T,m,p;let o=n?t.borderWidthRawValue:`calc(${i.height} * ${(c=(a=(s=e==null?void 0:e.shape)==null?void 0:s.border)==null?void 0:a.width)!=null?c:t.borderWidth})`,l=n?t.roundCornersRawValue:`calc(${i.height} * ${(v=(d=e==null?void 0:e.shape)==null?void 0:d.roundCorners)!=null?v:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Be(n?t.borderColor:(E=(g=(b=e==null?void 0:e.shape)==null?void 0:b.border)==null?void 0:g.color)!=null?E:t.borderColor,n?t.borderAlpha:(p=(m=(T=e==null?void 0:e.shape)==null?void 0:T.border)==null?void 0:m.alpha)!=null?p:t.borderAlpha),r.style.borderRadius=l},Yi=({target:r,isDark:e,baseDimension:t,fallback:i})=>{let l=Be(i.shadowColorLight,i.shadowColorAlpha),s=Be(i.shadowColorDark,i.shadowColorAlpha),a=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${a} ${c} ${e?s:l}`;r.style.boxShadow=d},Ae=({target:r,layoutParams:e,fallback:t})=>{var n;let i=(n=e.angle)!=null?n:t.angle;i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};import{fromEvent as Je,Subject as lp,Subscription as cp}from"@vkontakte/videoplayer-shared/es2015";var yr="interactive-control-tap",Se={common:yr,animation:`${yr}-animation`,visible:`${yr}-visible`};var $l=60,xt=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=$l,useDimensionsBasedSize:n=!1}){this.onElementClick=e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let i=t.getBoundingClientRect(),n={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},o=Math.min(n.width,n.height),l=i.left+i.width/2,s=i.top+i.height/2,a=e.clientX-l,c=e.clientY-s,d=jl(a,c,this.controlRotateAngleRad);this.element.style.width=o+"px",this.element.style.left=d.x+i.width/2-o/2+"px",this.element.style.top=d.y+i.height/2-o/2+"px",this.element.classList.add(Se.visible,Se.animation)};this.onAnimationEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.element.classList.remove(Se.visible,Se.animation)};let o=document.createElement("div");o.classList.add(Se.common),this.controlRotateAngleRad=e,this.element=o,this.clickCancelCondition=t,this.circleDiameterPx=i,this.useDimensionsBasedSize=n}};function jl(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var gr="int",fe=(i=>(i.AREA=`${gr}_area`,i.TEXT=`${gr}_text`,i.BUTTON=`${gr}_bttn`,i))(fe||{});function Cr(r){return"features"in r}var re="interactive-control",V={common:re,selected:`${re}-selected`,wrapper:`${re}-wrapper`,disabled:`${re}-disabled`,button:`${re}-button`,area:`${re}-area`,text:`${re}-text`,blinkAnim:`${re}-blink-anim`,blinkAnimButton:`${re}-blink-anim-button`,blinkAnimArea:`${re}-blink-anim-area`},Zi=40;var us=te(Mt(),1);import{isSupportedManifest as Lt,ContainerTypes as pf,ControlTypes as Ft,EventActionTypes as P,EventTypes as hf,migrateManifestToLatestVersion as cs,compareVersions as df}from"@interactiveplatform/movika-manifest";var as={metadata:"Object",chapters:"Array"},ls=r=>{if(!he(r))return!1;for(let e in as)if(!r[e]||!pe(r[e],as[e]))return!1;return Lt(r.metadata.version)},_t=r=>r.type===Ft.Text,tf=r=>r.type===Ft.Button,rf=r=>r.type===Ft.Area,nf={Choice:"Choice",TextInput:"TextInput"},of={Button:"Button",Area:"Area",Text:"Text"},sf={onClick:"onClick",onSuspense:"onSuspense"},af={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Nt=r=>gt(r)&&!br(r),ne=r=>r.order==="end",$t=r=>gt(r.containers)&&!br(r.containers)&&ne(r),ps=(r,e)=>{var i;let t=r*1e3;return Nt(e.controls)&&t<((i=e.startTime)!=null?i:0)},Zr=(r,e)=>{var i,n;let t=r*1e3;return Nt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var be=(r=[])=>r.some(e=>e.action.type==="expect"),Jr=(r=[])=>r.find(e=>e.action.type==="expect"),ap=r=>(r==null?void 0:r.length)===1,Me=r=>ap(r)&&_t(r[0]);function hs(r=[],e=1/0,t=[]){return r.filter(({container:i})=>!(0,us.default)(t,i.container.id)&&be(i.container.events)&&i.container.endTime===e&&!i.isRemoved&&!i.willRemoved)}function jt({gameControllers:r=[],subjectName:e,subjectId:t,execFn:i}){for(let n of r)if(e==="container"&&n.container.container.id===t){i(n),hs(r,n.container.container.endTime,[n.container.container.id]).forEach(l=>{i(l)});break}}function ds(r){for(let e of r.events)if(e.action.type==="openURI")return!0;return!1}var ms=(r,e)=>{let t=T=>{let m=e.find(({container:p})=>p.container.id===T);return m==null?void 0:m.container.isRemoved},i=be(r.events)&&!t(r.id),n=(T,m=!1,p=!1)=>{let h=p?"every":"some";return T.controls[h](y=>{var S;let I=m?T.endTime===r.endTime:!0;return((S=y.events)==null?void 0:S[h](C=>{var x;return((x=C.action)==null?void 0:x.type)===P.openURI}))&&I})},o=T=>T.some(({container:m})=>n(m.container,!0,!1)&&!m.isRemoved),l=T=>T.every(({container:m})=>m.isRemoved||m.willRemoved?!0:n(m.container,!0,!0)),s=hs(e,r.endTime,[r.id]).length,a=T=>T.controls.some(m=>{var p;return(p=m.events)==null?void 0:p.some(h=>{var y,I;return(I=(y=h.action)==null?void 0:y.args)==null?void 0:I.shouldOpenNow})}),c=i||s>0,d=o(e),v=n(r),b=l(e),g=i?!1:s>0,E=a(r);return{isExpectTime:c,hasOtherExpect:s>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:v,isAllOpenURIEventsValid:b,isExpectEventForCurrentContainer:g,hasShouldOpenNowEvent:E}};var de=class r{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new cp;this.error$=new lp;this.isInteracted=!1;this.isRemoved=!1;this.cssVarsManager=null;this.onControlSelect=()=>{var e,t,i;(e=this.container)!=null&&e.isManifestContainerDisabled()||ds(this.control)||(i=(t=this.container)==null?void 0:t.element)==null||i.classList.add("interactive-control-wrapper-selected")};this.onTransitionEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}}setCssVarsManager(e){this.cssVarsManager=e}removeView(e=!1){let t=this.getElement();if(t){if(e){if(t.classList.contains("interactive-control-before-remove"))return;t.classList.add("interactive-control-before-remove"),this.subscriptions.add(Je(t,"transitionend").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n))).add(Je(t,"transitioncancel").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n)));return}this.removeListeners(),t.remove(),this.isRemoved=!0}}onError(e="",t){bt({emitter$:this.error$,error:t,message:e,subjectId:this.control.id})}addControlTap(e){var t;if(this.featureIsEnabled("controlsTapPlace")&&this.container){let i=(t=this.control.layoutParams.angle)!=null?t:L.angle;this.controlTap=new xt({controlRotateAngleRad:i,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?Zi:void 0}),this.subscriptions.add(Je(e,"click").subscribe(this.controlTap.onElementClick,n=>this.onError("Control click tap animation error",n))).add(Je(this.controlTap.element,"animationend").subscribe(this.controlTap.onAnimationEnd,n=>this.onError("Tap animationend error",n))),this.container.element.append(this.controlTap.element)}}createContainerElement(e){var o,l,s,a,c;let t=document.createElement("div");t.classList.add(V.wrapper),e.setControlLayout(t,this.control.layoutParams);let i=((o=this.control.layoutParams.innerSizesDependOn)!=null?o:L.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:(s=(l=this.cssVarsManager)==null?void 0:l.getPropValue("--interactive-content-height"))!=null?s:0,width:(c=(a=this.cssVarsManager)==null?void 0:a.getPropValue("--interactive-content-width"))!=null?c:0},n=()=>{var d,v;return(v=(d=e.isContainerDisabled)==null?void 0:d.call(e))!=null?v:!1};this.container={element:t,dimensions:i,isManifestContainerDisabled:n}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted=!0,e()}}featureIsEnabled(e){return this.options&&Cr(this.options)&&this.options.features[e]}isTouch(){return this.options&&Cr(this.options)&&this.options.isTouch}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add(Je(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),n=>this.onError("Error happened on control interaction",n)));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var ei="interactive-blink-anim-reference",q={common:ei,animation:`${ei}-animation`,disabled:`${ei}-disabled`},Bt=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(q.common,q.animation),this._element=e}restart(){this._element&&(this._element.classList.add(q.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(q.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var ti="interactive-container",D={common:ti,hidden:`${ti}-hidden`,disabled:`${ti}-disabled`};var qt=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new ri(r,e)},ri=class extends de{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(V.common,V.area),i.setAttribute("data-testid",fe.AREA),It({target:i,props:this.control.props,fallback:A(f({},L),{backgroundColor:"transparent"})}),Ae({target:i,layoutParams:this.control.layoutParams,fallback:L}),this.addControlTap(i),this.subscriptions.add(et(this.container.element,"click").pipe(fs()).subscribe(this.onControlSelect,n=>this.onError("Control click handler error",n))),this.container.element.append(i),e.append(this.container.element),this.controlElement=i,this.updateShadowStyles(),this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(et(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(D.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${q.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(et(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(D.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(et(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(V.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(V.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){var t,i,n;if(!(!this.container||!this.controlElement))if(Wi(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";Yi({target:this.controlElement,props:this.control.props,fallback:L,isDark:e,baseDimension:o}),qe({target:this.controlElement,props:this.control.props,fallback:A(f({},L),{borderColor:e?L.shadowColorDark:L.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${(n=(i=(t=this.control.props)==null?void 0:t.shape)==null?void 0:i.roundCorners)!=null?n:L.roundCorners})`}),dependsOn:this.container.dimensions,useRawValues:!0})}else qe({target:this.controlElement,props:this.control.props,fallback:A(f({},L),{borderAlpha:0}),dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(V.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(V.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${V.blinkAnimArea}`)||this.controlElement.classList.contains(V.selected)||this.controlElement.classList.contains(q.disabled)||(this.controlElement.classList.add(q.disabled),this.subscriptions.add(et(e,"animationiteration").pipe(fs()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(q.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${V.blinkAnimArea}`)||this.controlElement.classList.contains(V.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}};import{fromEvent as tt,once as Is}from"@vkontakte/videoplayer-shared/es2015";var Dt=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),i={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,i),t.append(e);let n={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,n),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var Ht=Math.PI,ii=2*Ht,Ut=Ht/2,vs=3*Ut,up=0,pp=[up,Ut,Ht,vs];function bs(r){return r===Ut}function ys(r){return r===Ht}function gs(r){return r===vs}function Cs(r){return(r%ii+ii)%ii}function hp(r){for(let e of pp)if(r===e)return e}function Es(r){if(hp(r))return null;let t=Math.floor(r/Ut)+1;return[1,2,3,4][t-1]}function Ts(r){return r*180/Math.PI}var ae="interactive-control-fill-animation",H={common:ae,fillerWrapper:`${ae}-filler-wrapper`,filler:`${ae}-filler`,fillHeight:`${ae}-fill-height`,fillWidth:`${ae}-fill-width`,fromTop:`${ae}-from-top`,fromBottom:`${ae}-from-bottom`,fromLeft:`${ae}-from-left`,fromRight:`${ae}-from-right`};var Gt=class r{constructor(e){this.widthExpansionCoef=0;var m;let t=document.createElement("div");t.classList.add(H.common);let i=document.createElement("div");i.classList.add(H.fillerWrapper);let n=document.createElement("div");n.classList.add(H.filler),i.append(n),t.append(i);let o=Cs(e.rotateAngle),l=Es(o),s=l!==null,c=l===2||!s&&ys(o)||l===3,d=!s&&bs(o),v=!s&&gs(o),b=!c&&!d&&!v,g=d||v,E=s&&!g,T=E?o:0;t.style.borderRadius=e.borderRadius,i.style.transform=`skew(${T*-1}rad)`,g?(n.classList.add(H.fillHeight,d?H.fromTop:H.fromBottom),i.classList.add(H.fillHeight,d?H.fromTop:H.fromBottom)):(n.classList.add(H.fillWidth,b?H.fromLeft:H.fromRight),i.classList.add(H.fillWidth)),e.debug&&console.log(`[interactive ${r.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:g,rotateAngleRad:o,rotateAngelDeg:Ts(o),rotateAngleRaw:e.rotateAngle,fromRight:c,fromTop:d,fromBottom:v,fromLeft:b}),this.useSkew=E,this.fromLeft=b,this.rotateAngle=o,this.fillAnimationElement=t,this.fillAnimationFillerElement=n,this.fillAnimationFillerWrapperElement=i,this.startTime=e.startTime,this.endTime=e.endTime,this.shouldFillHeight=g,this.isDebug=(m=e.debug)!=null?m:!1}updateDimension(e){this.fillAnimationElement.style.top=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.left=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.width=`${e.width}px`,this.fillAnimationElement.style.height=`${e.height}px`;let t=this.calcWidthExpansionCoef({rotateAngle:this.rotateAngle,isSkewed:this.useSkew,initWidth:e.width,initHeight:e.height});!this.shouldFillHeight&&(this.fillAnimationFillerWrapperElement.style.width=100*t+100+"%",this.fillAnimationFillerWrapperElement.style[`${this.fromLeft?"left":"right"}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((o=>o<this.startTime||o>this.endTime)(e))return;let i=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/i,0),1);this.shouldFillHeight?this.fillAnimationFillerElement.style.transform=`scaleY(${n})`:this.fillAnimationFillerElement.style.transform=`scaleX(${n})`}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:i,initHeight:n}){return t?(i+n*Math.abs(Math.tan(e)))/i-1:0}};var Wt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new ni(r,e)},ni=class extends de{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var l,s,a,c,d,v;if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(V.common,V.button),i.setAttribute("data-testid",fe.BUTTON),Ae({target:i,layoutParams:this.control.layoutParams,fallback:L}),It({target:i,props:this.control.props,fallback:L}),qe({target:i,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),Et({target:i,props:A(f({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let n=Dt(this.control.type.trim().toLowerCase()),o=(l=n.firstElementChild)!=null?l:n;Tt({target:o,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),this.addControlTap(i),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled("controlsFillAnimation")&&(this.controlFillAnimation=new Gt({startTime:this.startTime,endTime:this.endTime,rotateAngle:(s=this.control.layoutParams.angle)!=null?s:L.angle,borderRadius:i.style.borderRadius})),this.subscriptions.add(tt(i,"click").pipe(Is()).subscribe(this.onControlSelect,b=>this.onError("Control click handler error",b))),i.append(n,(c=(a=this.controlFillAnimation)==null?void 0:a.fillAnimationElement)!=null?c:""),this.container.element.append((v=(d=this.controlTap)==null?void 0:d.element)!=null?v:"",i),e.append(this.container.element),this.controlElement=i,this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(tt(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(D.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${q.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(tt(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(D.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(tt(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(V.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(V.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(V.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(V.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${V.blinkAnimButton}`)||this.controlElement.classList.contains(V.selected)||this.controlElement.classList.contains(q.disabled)||(this.controlElement.classList.add(q.disabled),this.subscriptions.add(tt(e,"animationiteration").pipe(Is()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(q.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${V.blinkAnimButton}`)||this.controlElement.classList.contains(V.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}updateFillAnimationDimensions(){if(!this.container||!this.controlElement||!this.controlFillAnimation)return;let e=getComputedStyle(this.controlElement),t={width:parseFloat(e.width),height:parseFloat(e.height),borderWidth:parseFloat(e.borderWidth)||0};this.controlFillAnimation.updateDimension(t)}setShowTimeRange(e,t){this.startTime=e,this.endTime=t}onProgress(e){var t;(t=this.controlFillAnimation)==null||t.updateAnimation(e)}onResize(){this.updateFillAnimationDimensions()}updateShadowStyles(){}};var xs=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new oi(r,e)},oi=class extends de{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var l;if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("div");i.classList.add(V.common,V.text),i.setAttribute("data-testid",fe.TEXT),Ae({target:i,layoutParams:this.control.layoutParams,fallback:L}),Et({target:i,props:A(f({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let n=Dt(this.control.type.trim().toLowerCase()),o=(l=n.firstElementChild)!=null?l:n;Tt({target:o,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}setShowTimeRange(){}updateFillAnimationDimensions(){}};var zt=(r,e,t,i)=>{if(r.type.trim().toLowerCase()==="choice")return new si(r,e,t,i)},si=class r extends xe{constructor(t,i,n,o){super(t,n,o);this.containerElement=null;this.subscriptions=new dp;this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&this.removeView()};this.rootElement=i,this.layout=new vt(this.container.layout,n),this.cssVarsManager=n,this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Wt),this.addControlFactory("text",xs),this.addControlFactory("area",qt)}createView({eventCallback:t,videoDurationMs:i}){let n=document.createElement("div");return n.classList.add(D.common,D.disabled),n.setAttribute("data-subjectId",this.container.id),requestAnimationFrame(()=>{n.classList.remove(D.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(o=>{var l;o.setShowTimeRange(this.container.startTime,(l=this.container.endTime)!=null?l:i),o.setCssVarsManager(this.cssVarsManager),o.createView({parentElement:n,callbacks:{setControlLayout:(s,a)=>this.layout.setControlLayout(s,a),isContainerDisabled:()=>this.isDisabled}}),o.setEvents(t),this.subscriptions.add(o.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.willRemoved=!1,this.containerElement=n,this.updateControlsFillAnimationDimensions(),n}updateControlsFillAnimationDimensions(){for(let t of this.controls)t.updateFillAnimationDimensions()}hide(){let t=this.getElement();t&&t.classList.add(D.hidden)}show(){let t=this.getElement();t&&t.classList.remove(D.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(D.disabled),this.controls.forEach(i=>i.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(D.disabled),this.controls.forEach(i=>i.disable()),this.isDisabled=!0)}removeView(t=!1,i=!1){let n=this.getElement();if(n){if(t){if(this.willRemoved)return;this.willRemoved=!0,i&&n.classList.add("interactive-container-before-remove-delay"),n.classList.add("interactive-container-before-remove"),this.subscriptions.add(As(n,"transitionend").subscribe(this.onTransitionEnd,l=>this.onError(`${r.name} remove view transition error`,l))).add(As(n,"transitioncancel").subscribe(this.onTransitionEnd,l=>this.onError(`${r.name} remove view transition error`,l)));return}this.subscriptions.unsubscribe(),this.removeAllControls(),n.remove(),this.isRemoved=!0,this.willRemoved=!1,this.containerElement=null}}removeAllControls(t=!1){this.controls.forEach(i=>i.removeView(t))}removeNonInteractedControls(t=!1){this.controls.forEach(i=>{i.isInteracted||i.removeView(t)})}isInteracted(){return this.controls.some(t=>t.isInteracted)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,i){i&&this.controls.forEach(n=>{n.onProgress(t)})}onResize(t){t&&this.controls.forEach(i=>{i.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(i=>i.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(i=>i.toggleBlinkAnimation(t))}};var Rl=te(ai(),1);import{combine as hd,InterfaceLanguage as dd,Observable as Al,once as md,Subject as U,Subscription as Oi,ValueSubject as G,fromEvent as Sl}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as dt}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as Tp}from"@vkontakte/videoplayer-shared/es2015";function rt(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var Vs="video_interactive",Ms="videoint";var _s=250,it=class{constructor(e){this.handleZoomChange=rt(e=>{this.lastZoomInfo=e},_s);this.onResize=e=>{var i;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((i=this.ngEditor)==null||i.zoomTo(t,void 0,{isFromCenter:!0})),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,i,n;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Chapter id is not found");return}this.visitedChapterIds.add(e.id),(i=this.ngEditor)==null||i.selectChapter(e.id),(n=this.ngEditor)==null||n.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var i;if(this.isReady=!1,!Ct(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:i,lang:n,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,this.onError=i,this.lang=n!=null?n:"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Ip(e),this.resizeObserver=new ResizeObserver(rt(this.onResize,_s)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}show(){return R(this,null,function*(){var e;this.manifest&&(this.ngEditor||(yield this.initNgEditor()),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)})}initNgEditor(){return R(this,null,function*(){var i;if(!this.manifest)return;let e;try{e=yield Tp(this.lang,Vs,Ms)}catch(n){(i=this.onError)==null||i.call(this,"Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",l=>{var s=l,{name:n}=s,o=ee(s,["name"]);var a;n==="openPreview"&&"chapterId"in o&&((a=this.onOpenPreviewClick)==null||a.call(this,o.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0})}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Ip(r){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",r.append(e),e}var nt=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,i=!1,n=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let l=o.startTime-e;if(l<=n&&(o.endTime&&n<=o.endTime||o.endTime===null)){i=!0;break}n<l&&(t=t===-1?l:Math.min(t,l))}return!i&&t!==-1?t:null}}};var Kt=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let i=()=>{t(),this.off(e,i)};return this.listeners[e].push(i),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let i=this.listeners[e]||[];for(let n=i.length;n>0;n--)if(i[n]===t){i.splice(n,1);break}return this}emit(e,...t){let i=this.listeners[e];return i?(i.forEach(n=>{n(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var Qt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Gi(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var ua=te(ca(),1);var Xt=class r{constructor(e){this.rootElement=e;this.rootElementProps={};this.isCssVarsSupported=r.checkCssVarsSupport(e)}static checkCssVarsSupport(e){let t="--test-key",i="test";e.style.setProperty(t,i);let n=e.style.getPropertyValue(t)===i;return n&&e.style.removeProperty(t),n}getPropValue(e){var t;return this.isCssVarsSupported?`var(${e})`:(t=this.rootElementProps[e])!=null?t:""}setup(e){if(this.rootElementProps=f(f({},this.rootElementProps),e),this.isCssVarsSupported)for(let[t,i]of(0,ua.default)(e))this.rootElement.style.setProperty(t,i)}cleanup(){for(let e in this.rootElementProps)this.rootElement.style.removeProperty(e);this.rootElementProps={}}setProp(e,t){this.rootElementProps[e]=t,this.isCssVarsSupported&&this.rootElement.style.setProperty(e,t)}};import{ValueSubject as ih}from"@vkontakte/videoplayer-shared/es2015";var Yt=class{constructor(e){var t,i;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(i=e==null?void 0:e.manifestLoaders)!=null?i:[]}}exec(e,t){return R(this,null,function*(){return Yp(...this.loaders[e])(t)})}};function Yp(...r){return function(t){return R(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function ot(r,e,t){return r?A(f({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Zt(n){var o=n,{actions:r,errors:e,chapterId:t}=o,i=ee(o,["actions","errors","chapterId"]);if(t){let l=r.getManifest();if(l){let s=r.getChapter(l.chapters,t);if(s){let a=r.getMedia(l.media,s.videoId),c=r.getGraph(l.graph,s.id);return a?A(f({},i),{actions:r,errors:e,result:{chapter:s,media:a,graph:c}}):A(f({},i),{errors:ot(e,Zt.name,"Could not find media"),actions:r})}}}return A(f({},i),{errors:ot(e,Zt.name,"Could not find chapter"),actions:r})}var{NativeAbortSignal:mb,NativeAbortController:fb}=function(r){return{NativeAbortSignal:r.AbortSignal,NativeAbortController:r.AbortController}}(typeof self!="undefined"?self:global);function pa(r){let e;try{e=new Event("abort")}catch(t){typeof document!="undefined"?document.createEvent?(e=document.createEvent("Event"),e.initEvent("abort",!1,!1)):(e=document.createEventObject(),e.type="abort"):e={type:"abort",bubbles:!1,cancelable:!1}}return e.reason=r,e}function ha(r){if(r===void 0)if(typeof document=="undefined")r=new Error("This operation was aborted"),r.name="AbortError";else try{r=new DOMException("signal is aborted without reason"),Object.defineProperty(r,"name",{value:"AbortError"})}catch(e){r=new Error("This operation was aborted"),r.name="AbortError"}return r}var Jt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let n=0,o=i.length;n<o;n++)if(i[n].callback===t){i.splice(n,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let i=this.listeners[e.type].slice();for(let n=0,o=i.length;n<o;n++){let l=i[n];try{l.callback.call(this,e)}catch(s){Promise.resolve().then(()=>{throw s})}l.options&&l.options.once&&this.removeEventListener(e.type,l.callback)}return!e.defaultPrevented}},_e=class extends Jt{constructor(){super(),this.listeners||Jt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}throwIfAborted(){let{aborted:e,reason:t="Aborted"}=this;if(e)throw t}static timeout(e){let t=new ye;return setTimeout(()=>t.abort(new DOMException(`This signal is timeout in ${e}ms`,"TimeoutError")),e),t.signal}static any(e){let t=new ye;function i(){t.abort(this.reason),n()}function n(){for(let o of e)o.removeEventListener("abort",i)}for(let o of e)if(o.aborted){t.abort(o.reason);break}else o.addEventListener("abort",i);return t.signal}},ye=class{constructor(){Object.defineProperty(this,"signal",{value:new _e,writable:!0,configurable:!0})}abort(e){let t=ha(e),i=pa(t);this.signal.reason=t,this.signal.dispatchEvent(i)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(ye.prototype[Symbol.toStringTag]="AbortController",_e.prototype[Symbol.toStringTag]="AbortSignal");function er(r){return r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof r.Request=="function"&&!r.Request.prototype.hasOwnProperty("signal")||!r.AbortController}function pi(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!er({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||n)&&(o=function(c,d){let v;d&&d.signal&&(v=d.signal,delete d.signal);let b=new t(c,d);return v&&Object.defineProperty(b,"signal",{writable:!1,enumerable:!1,configurable:!0,value:v}),b},o.prototype=t.prototype);let l=e;return{fetch:(a,c)=>{let d=o&&o.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(d){let v;try{v=new DOMException("Aborted","AbortError")}catch(g){v=new Error("Aborted"),v.name="AbortError"}if(d.aborted)return Promise.reject(v);let b=new Promise((g,E)=>{d.addEventListener("abort",()=>E(v),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([b,l(a,c)])}return l(a,c)},Request:o}}var Q=typeof globalThis=="object"&&globalThis||typeof window=="object"&&window;var Zp=()=>"fetch"in Q,st=Zp()&&er({fetch:Q.fetch,Request:Q.Request,AbortController:Q.AbortController}),da=st?pi({fetch:Q.fetch,Request:Q.Request,AbortController:Q.AbortController}):void 0,hi=st?da.fetch:Q.fetch,wb=st?da.Request:Q.Request,Rb=st?ye:Q.AbortController,Ob=st?_e:Q.AbortSignal;var di=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let o=0;o<Math.max(t.length,i.length)&&!n;o++)t[o]>i[o]?n=1:t[o]<i[o]?n=-1:n=0;return n};var Jp=r=>R(null,null,function*(){try{let e={},t;if(yt(r)){t=new URL(r).href;let n=yield hi(t);if(!n.ok)return{};e=yield n.json()}else if(he(r))e=r;else return{};if(!ls(e))return{};let i=e.metadata.media;if(yt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=yield hi(n);if(!o.ok)throw new Error;e.metadata.media=yield o.json()}catch(n){return rh(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function ma(r){return R(this,null,function*(){let{manifest:e,manifestURL:t}=yield Jp(r);if(!e)throw new Error("Failed on fetch");let i=cs(e);return i.media=eh(i.media,t),delete i.metadata.media,i})}function tr(r,e){if(e)return r.find(t=>t.id===e)}function mi(r,e){var t,i;return(t=r.edit)!=null&&t.chapters?r.edit.chapters.find(n=>n.id===e):(i=r.view)!=null&&i.chapters?r.view.chapters.find(n=>n.id===e):void 0}function fi(r,e){return r.videos.find(t=>t.id===e)}function eh(r,e){return A(f({},r),{videos:r.videos.map(t=>A(f({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=th(n,e);return A(f({},i),{url:o||n})})}))})}function th(r="",e){try{return new URL(r,e).href}catch(t){return""}}function rh(r){return di(r,"3.2.0")>=0}var Le=class extends Yt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new ih(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(t){return R(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:ot},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield ma((n=i.result)!=null?n:t),this})}setInitial(){return R(this,null,function*(){return this.setNext()})}setNext(){return R(this,arguments,function*(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=yield this.exec("chapterLoaders",Zt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:mi,getChapter:tr,getMedia:fi,getByBranches:this.getByBranches.bind(this),addErrorMessage:ot},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),n.result&&(this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph),this})}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){var i;return this.getByChapterId((i=this.manifest)==null?void 0:i.metadata.initChapterId)||null}getByChapterId(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t||!this.manifest)return null;let n=tr(this.manifest.chapters,t);if(n){let o=fi(this.manifest.media,n.videoId),l=mi(this.manifest.graph,n.id);if(o)return{chapter:n,media:o,graph:l}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,o,l;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let s=tr(((l=this.manifest)==null?void 0:l.chapters)||[],t);return this.getByBranches(s==null?void 0:s.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let o=this.getByChapterId(n.chapterId);return o&&i.push(o),i},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,i;return((t=this.chapter)==null?void 0:t.id)===((i=this.manifest)==null?void 0:i.metadata.initChapterId)}isEndChapter(){return this.chapter?ne(this.chapter):!1}};var Ia=te(rr(),1);import{Player as ch}from"@vkontakte/videoplayer-core/es2015";import{Subscription as yi,TracerFactory as uh,ValueSubject as ph}from"@vkontakte/videoplayer-shared/es2015";var Ea=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&e.payload){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var Ta=te(rr(),1);function vi(){let r=new Map;function e(a){var c=a,{listId:o=Math.random().toString(),itemId:l=Math.random().toString()}=c,s=ee(c,["listId","itemId"]);let d=r.get(o),v=f({},s);return d?d[l]=v:r.set(o,{[l]:v}),f({listId:o,itemId:l},s)}function t(o){var l,s;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(l=o.statistics)==null||l.oneStat.destroy(),(s=o.statistics)==null||s.statSubscription.unsubscribe()}function i(o,l){let s=r.get(o);if(!s)throw Error("Can't remove. Not find.");if(l){let a=s[l];a&&t(a),delete s[l],Object.keys(s).length||r.delete(o)}else{for(let a of(0,Ta.default)(s))t(a);r.delete(o)}}function n(){for(let o of r)i(o[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var Fe=te(Mt(),1);function bi(r,e=[]){var o,l,s;let t={},i,n=!e.length;for(let a of r.variants)if(!i&&"cover"in a&&(i=a.cover),"url"in a)switch(a.type.toLowerCase()){case"mp4":(n||(0,Fe.default)(e,"mp4"))&&(t.MPEG=A(f({},t.MPEG),{[(o=a.standard)!=null?o:"Invariant quality"]:a.url}));break;case"mpeg":(n||(0,Fe.default)(e,"mpeg"))&&(t.MPEG=A(f({},t.MPEG),{[(l=a.standard)!=null?l:"Invariant quality"]:a.url}));break;case"hls":(n||(0,Fe.default)(e,"hls"))&&(t=A(f({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(n||(0,Fe.default)(e,"dash"))&&(t=A(f({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(s=r.title)!=null?s:""}}var at=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,Fe.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var hh=2;function gi(r){let e=vi(),t=new yi,i={},n=null,o=!1,l,s=new ph(null);r&&a(r);function a(m){n=m}function c(m,p,h){var S;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let I=((S=e.map.get(m))!=null?S:{})[p];if(I){i=f({chapterId:h,listId:m,itemId:p},I);let C=i.player;i.subscription.add(C.info.currentQuality$.subscribe(x=>{let j=C.info.position$.getValue(),O=C.info.isAutoQualityEnabled$.getValue();if(!(!x||!j||O))for(let _ of e.map)(0,Ia.default)(_[1]).forEach(({player:M})=>{at(M,x)})})).add(C.events.started$.subscribe(()=>{d(p)})),I.container.remove(),n.setPlayer(I.player),o||(n.init(),o=!0),s.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}function d(m){return R(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(me(i)||m!==i.itemId)return;let p=n.getChapterBranches(),h=new Set;for(let y of p)h.has(y.media.id)||(yield b({media:y.media,chapterId:y.chapter.id,setAsActive:!1,title:y.chapter.label}),h.add(y.media.id))})}function v(h){return R(this,arguments,function*({chapter:{id:m},manifestVideo:p}){if(me(i)||!n)return;let y=i.player.info.muted$.getValue(),I=i.player.info.currentQuality$.getValue(),S=i.player.info.isAutoQualityEnabled$.getValue(),C=i.player.info.volume$.getValue(),x=i.player.info.currentPlaybackRate$.getValue(),j=!S,O=!1;for(let _ of e.map)if(_[0]===p.id&&!n.state.isReplay$.getValue()){let M=Object.keys(_[1]);for(let $ of M)$===i.itemId?(M.length<hh||(O=!0),e.removePlayer(_[0],$)):(O=!0,c(_[0],$,m),j?at(i.player,I):i.player.setAutoQuality(!0),i.player.setVolume(C),i.player.setMuted(y),i.player.setPlaybackRate(x))}else e.removePlayer(_[0]);O||(yield b({media:p,chapterId:m,setAsActive:!0,playbackRate:x}),j?at(i.player,I):i.player.setAutoQuality(!0),i.player.setVolume(C),i.player.setMuted(y))})}function b(j){return R(this,arguments,function*({media:m,chapterId:p,prefetch:h=!0,setAsActive:y=!0,autoplay:I=!1,preferredExt:S,title:C,playbackRate:x}){var Vi,Mi,_i,Li,Fi;let O=Math.random().toString(),_=document.createElement("div");l.append(_);let M;if((Vi=n==null?void 0:n.options)!=null&&Vi.vkVideoLoader){let mt=Ea(m);mt.length&&(M=yield n.options.vkVideoLoader(...mt))}let $=((Mi=n==null?void 0:n.options)==null?void 0:Mi.coreConfig)||void 0,Te=A(f({},$),{configName:[...(_i=$==null?void 0:$.configName)!=null?_i:[],"interactive"]}),se=A(f({container:_},((Li=M==null?void 0:M.videos)==null?void 0:Li[0])||{sources:bi(m,S).sources}),{title:C,failoverHosts:(M==null?void 0:M.failoverHosts)||[]}),J=new ch(Te,uh.createRootTracer());J.initVideo(se);let ki=null;if(M!=null&&M.videos&&(n!=null&&n.options.createOneStat)){let mt=M.videos[0],ur=n.options.createOneStat(mt),Ni=new yi;ur&&(Ni.add(ur.attachTo(J)),ki={oneStat:ur,statSubscription:Ni})}let Pi=new yi,Ol=(Fi=i==null?void 0:i.player)==null?void 0:Fi.info.isAutoQualityEnabled$.getValue();Pi.add(J.events.canplay$.subscribe(function(){Ol||at(J,i.player.info.currentQuality$.getValue()),x&&J.setPlaybackRate(x)}));let Ie=e.createPlayer({listId:m.id,itemId:O,player:J,container:_,sources:bi(m,S).sources,config:se,subscription:Pi,statistics:ki});return y&&c(m.id,Ie.itemId,p),I&&Ie.player.play(),h&&!I&&Ie.player.prepare(),{player:Ie.player,config:Ie.config,statistics:Ie.statistics}})}function g(){E(),n=null,l.remove()}function E(){t.unsubscribe(),e.removeAll(),i={},o=!1}function T(){return R(this,null,function*(){if(!n)throw Error("need to set interactive controller");E(),l=document.createElement("div");let{media:m,chapter:p}=n.getCurrentChapter();m&&p?(t.add(n.events.chapterChanged$.subscribe(v)),yield b({media:m,chapterId:p.id,title:p.label})):console.error("not found")})}return A(f({},e),{init:T,setInteractiveController:a,createPlayer:b,removeAll:g,getActivePlayer:function(){return i},activePlayerChanged:s})}var k={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},lt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},F={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};import{Subscription as dh}from"@vkontakte/videoplayer-shared/es2015";function Ci(r){return function(...t){return r(...t.reverse())}}function ct(r,...e){return(...t)=>he(e[0])&&he(t[0])?r(f(f({},e[0]),t[0])):r(...e,...t)}var ir=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:l,globalEventEmitter:s,getContainerEventState:a,permanentTextControls:c,interactiveTimeOpenUri:d,disabledControls$:v,onRemove:b,onError:g,disableTextControlContainerVisibilityEvents:E=!1,features:T}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(be(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,i,n,o,l,s;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:a}=this.getContainerEventState();if((i=(t=this.container).show)==null||i.call(t),this.interactiveTimeOpenUri&&a||this.disableTextControlContainerVisibilityEvents)return;this.emitContainerVisibilityEvent(!0,!1)}else{let a={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(v,b)=>{let{isExpectTime:g,hasOtherExpect:E,hasOpenURIEvent:T,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:p,hasShouldOpenNowEvent:h}=this.getContainerEventState(),y=this.interactiveTimeOpenUri&&!m,I=this.interactiveTimeOpenUri&&m;if((!this.interactiveTimeOpenUri||y)&&(this.isSelectedControlEvent=!0),v!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||y)){if(this.interactiveTimeOpenUri){let S=!E&&!p&&m;S&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:S})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&T&&this.gameState!==5){if(I){let C=((x,j,O,_)=>!x&&!j&&O||x&&!j&&O&&!_||x&&!j&&O&&_)(g,E,p,this.isSelectedContainerEvent);this.fakeRemoveView(C)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!g||!E||!h)&&(this.selectBranches.stopExpect(),b())}},isEOV:()=>this.gameState===4},c=ct(this.selectBranches.onControlEvent,a),d=((o=(n=this.player)==null?void 0:n.info.duration$.getValue())!=null?o:1/0)*1e3;this.container.createView({eventCallback:c,videoDurationMs:d}),this.disableTextControlContainerVisibilityEvents||this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((s=(l=this.container).disable)==null||s.call(l))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var a,c,d;let e=this.player.experimental.element$.getValue(),t=e instanceof HTMLVideoElement;if(this.features.enableAvPlayerSupport&&(t||(t=e instanceof HTMLObjectElement&&(e==null?void 0:e.getAttribute("type"))==="application/avplayer")),!(t?e==null?void 0:e.readyState:void 0)||this.isRemovedOrDestroyed()&&!this.isPermanentText)return;let n=this.player.getExactTime();if(ps(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Zr(n,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let v=this.gameState;this.gameState=3,v===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:v}=this.getContainerEventState(),b=this.selectBranches.state.isExpect,g=this.interactiveTimeOpenUri&&v;if(g&&!b){let E=this.container.getElement();E&&(E.style.visibility!=="hidden"&&((c=(a=this.container).hide)==null||c.call(a)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!g&&this.removeView()}let o=Zr(n,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(d=this.container.container.endTime)!=null?d:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:n,isInteractiveTime:o};this.container.onProgress(n*1e3,o),this.globalEventEmitter.emit(k.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new dh,this.player=e,this.interactiveEvents=o,this.getContainerEventState=a;let m=Me(t.container.controls);this.isPermanentText=c&&m,this.disableTextControlContainerVisibilityEvents=E&&m,this.interactiveTimeOpenUri=d,this.disabledControls$=v,this.onRemove=b,this.globalEventEmitter=s,this.gameState=0,this.globalEvents=l,this.onError=g,this.features=T,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:F.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:F.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{var t,i,n,o;e?(i=(t=this.container).disable)==null||i.call(t):(o=(n=this.container).enable)==null||o.call(n)})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){var i,n;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(i=this.container.container.endTime)!=null?i:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((n=this.container.container.endTime)!=null?n:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),i=this.interactiveTimeOpenUri?e||t:be(this.container.container.events)||e;(this.isSelectedControlEvent||!i)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(e=this.features.controlsHideAnimation){var t;if(e){if(this.isRemovedOrDestroyed())return;this.container.removeNonInteractedControls(!0),this.container.removeView(!0,!0)}else this.container.removeView();this.globalEventEmitter.emit(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:F.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,(t=this.onRemove)==null||t.call(this)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}isInteracted(){return this.container.isInteracted()}isRemovedOrDestroyed(e=!0){let t=e?this.container.willRemoved:!1;return this.gameState===5||t||this.gameState===6}destroy(e=!1){var t;this.reset(),this.removeView(e),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(t=this.container.container.endTime)!=null?t:1/0,id:this.container.container.id})}};var Aa=(r=[])=>r.reduce((e,t,i)=>{var o,l,s;let n=((o=t==null?void 0:t.controls)!=null?o:[]).filter(a=>!_t(a));if(Nt(n)){let a=[(l=t.startTime)!=null?l:0,(s=t.endTime)!=null?s:1/0],c={id:t.id,isRemoved:!1};if(!i)e.push({subjects:[c],range:a});else{let d=[],v=-1/0,b=1/0,g=[],E=[];for(let T=0;T<e.length;T++){let m=e[T];if(E.push(...m.subjects),m.range[0]<b&&(b=m.range[0]),m.range[1]>v&&(v=m.range[1]),a[0]>=m.range[0]&&a[1]<=m.range[1])return e[T].subjects.push(c),e;a[0]<m.range[0]&&a[1]>m.range[0]&&(d.push(T),g=g.concat(m.subjects)),a[0]>=m.range[0]&&a[0]<=m.range[1]&&(d.push(T),g=g.concat(m.subjects),a[0]=m.range[0]),a[1]>=m.range[0]&&a[1]<=m.range[1]&&(d.push(T),g=g.concat(m.subjects),a[1]=m.range[1])}if(E.push(c),a[0]<=b&&a[1]>=v)return[{subjects:E,range:a}];d.length&&d.reverse().forEach(T=>{e.splice(T,1)}),e.push({subjects:g.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var sl=te(Mt(),1),xi=te(rr(),1),al=te(nl(),1);function ol(){let r={};function e(){for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]}function t(s){let a={};for(let c in r)+c<=s&&(a[c]=r[c]);return a}function i(s){let a={};for(let c in r)+c>=s&&(a[c]=r[c]);return a}function n({timestamp:s,priority:a,initiator:c}){var d;if(vr(s)){let v=(d=r[s])!=null?d:null;if(v&&a&&je(a,!0)){let b={},g=v[a];if(g&&(b=f(f({},b),g)),b=me(b)?null:b,b&&je(c,!0)){let E=b[c];return E!=null?E:null}return b}return v}return null}function o({timestamp:s,priority:a,initiator:c}){if(vr(s))if(r[s]){if(a&&je(a,!0))if(r[s][a]){if(c&&je(c,!0))if(r[s][a][c]){if(delete r[s][a][c],!me(r[s][a]))return!0}else return!1;if(delete r[s][a],!me(r[s]))return!0}else return!1;return delete r[s]}else return!1;return!1}function l(v){var b=v,{timestamp:s,priority:a,initiator:c}=b,d=ee(b,["timestamp","priority","initiator"]);var g,E,T;(E=(g=r[s])==null?void 0:g[a])!=null&&E[c]?r[s][a][c].push(f({},d)):(T=r[s])!=null&&T[a]?r[s][a]=A(f({},r[s][a]),{[c]:[f({},d)]}):r[s]?r[s]=A(f({},r[s]),{[a]:{[c]:[f({},d)]}}):r[s]={[a]:{[c]:[f({},d)]}}}return{map:r,remove:o,add:l,removeAll:e,get:n,getLte:t,getGte:i}}var td=[P.expect,P.setNextBranch],rd=1/0;function ll(r,e){let t=r,i,n=id(e),o=ol(),l,s=()=>{g(),p()},a=h=>{o.add.call(void 0,h),E()},c=(h=[])=>{for(let y of h)if(y.action(),(0,sl.default)(td,y.actionType))break},d=(h=1/0)=>{var C,x,j;let y=or((C=o.get({timestamp:h,priority:"control"}))!=null?C:{}),I=or((x=o.get({timestamp:h,priority:"container"}))!=null?x:{}),S=or((j=o.get({timestamp:h,priority:"chapter"}))!=null?j:{});return[...y,...I,...S]},v=h=>{n.isReady(h)&&c(d(h))},b=()=>{var h;c([...or((h=o.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},g=()=>{i&&(l==null||l.unsubscribe(),i=void 0)},E=()=>{i||(i=()=>setTimeout(()=>{v(1/0)}),l=t.events.ended$.subscribe(i))},T=h=>{g(),t=h},m=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),o.remove(h)},p=()=>{n.release(),o.removeAll()};return{setPlayer:T,add:a,remove:m,exec:v,execEndOfVideo:b,listen:E,unlisten:g,release:s,containersEventsCallState:n,getPreparedToExecActions:d}}function id(r){let e=new Map;return{setCalled:({timestamp:s,id:a})=>{let c=e.get(s);c&&c[a]!==void 0&&(c[a]=!0)},setData:(s=[])=>{var a;for(let c of s){let d=(a=c.endTime)!=null?a:rd,v=e.get(d);e.set(d,A(f({},v),{[c.id]:!1}))}},resetCalled:s=>{let a=e.get(s);if(a)for(let c in a)a[c]=!1},isReady:s=>{let a=e.get(s);if(!a)return!0;let c=(0,xi.default)(a);return r?c.some(v=>v):!c.some(v=>!v)},release:()=>e.clear()}}function or(r){return(0,al.default)((0,xi.default)(r)).sort(e=>e.actionType===P.expect?-1:1)}var cl={videoContentHeight:0,videoContentWidth:0},ul=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return cl;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return cl;let o=e/t,l=i/n,s,a;return l>o?(a=n,s=n*o):l<o?(a=i/o,s=i):(a=n,s=i),{videoContentWidth:a,videoContentHeight:s}};var nd=250;function pl(r){let e,t=new ResizeObserver(s=>{o(s),e=o.bind(null,s)});function i(s){let{parentElement:a,player:c,cssVarsManager:d}=r();if(!a||!c)return;let{videoContentWidth:v,videoContentHeight:b}=ul(c);d.setup({"--interactive-content-width":`${v}px`,"--interactive-content-height":`${b}px`,"--interactive-width":`${s[0].contentRect.width}px`,"--interactive-height":`${s[0].contentRect.height}px`})}function n(){let{parentElement:s}=r();s.removeAttribute("style")}let o=rt(s=>{let{fns:a=[]}=r();i(s);for(let c of a)c()},nd);function l(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:l}}var od=r=>Math.floor(Math.random()*r),dl=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let o=r[e],l=(n=o.weight)!=null?n:1;l<t&&(t=l,i=o)}return i},ml=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let o=r[e],l=(n=o.weight)!=null?n:0;l>t&&(t=l,i=o)}return i};var fl=r=>{let e=r.length,t=od(e);return r[t]},hl=1,vl=r=>{var i,n;let e=0;for(let o=0;o<r.length;++o)e+=(i=r[o].weight)!=null?i:hl;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(n=r[o].weight)!=null?n:hl,e>=t)return r[o];return r[r.length-1]};var bl={shouldOpenNow:!0,isDetachContainer:!0},yl="after-expect",Ai=(r,e=!1)=>A(f({},r),{args:e?f(f({},r.args),bl):f(f({},bl),r.args)}),gl=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:p,controlType:h,controlId:y,containerId:I,branches:S=[],onEvent:C,isEOV:x=()=>!1,isDisabled:j=()=>!1})=>{let O=Ai(p,x()),_={timestamp:1/0,priority:"control",initiator:y,actionType:O.type},M=j(),$=r.emit.bind(r,k.interactives,{subjectId:y,subjectType:h,subjectName:"control",type:M?F.actionChoiceCanceled:F.actionChoice,actionType:p.type,payload:f({invokeImmediately:O.args.shouldOpenNow,containerId:I},O.args)}),Te=()=>{e.interactiveActionChoice$.next({subjectId:y,subjectType:h,subjectName:"control",type:M?"action-choice-canceled":"action-choice",actionType:p.type,payload:f({invokeImmediately:O.args.shouldOpenNow,containerId:I},O.args)})};if(M){$(),Te();return}switch(O.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let se=S.find(J=>J.id===O.args.branchId);if(!se)return;C(O.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),$(),Te(),O.args.shouldOpenNow?T({subjectId:y,subjectName:"control",subjectType:h,action:O,payload:{chapterId:se.chapterId,autoSelect:!1}}):i.add(A(f({},_),{action:T.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:O,payload:{chapterId:se.chapterId,autoSelect:!1}})}));return}case P.continuePlayback.trim().toLowerCase():{C(O.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),$(),Te(),O.args.shouldOpenNow?E({subjectId:y,subjectName:"control",subjectType:h,action:p}):i.add(A(f({},_),{action:E.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:p})}));return}case P.openURI.trim().toLowerCase():{C(O.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),$(),Te(),O.args.shouldOpenNow?m({subjectId:y,subjectName:"control",subjectType:h,action:O,payload:{URI:p.args.uri}}):i.add(A(f({},_),{action:m.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:O,payload:{URI:p.args.uri}})}));return}default:{let se="Unexpected control event",J=new B(1,1,{message:se});d(J,se);return}}},s=({action:p,container:{id:h,endTime:y},branches:I=[],isEOV:S=!1,autoSelected:C=!1})=>{let x=Ai(p,S),j={timestamp:!x.args.shouldOpenNow||S?1/0:y!=null?y:1/0,priority:"container",initiator:h,actionType:x.type},O=r.emit.bind(r,k.interactives,{subjectId:h,subjectName:"container",type:F.actionChoice,actionType:x.type,payload:f({invokeImmediately:x.args.shouldOpenNow},x.args)}),_=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:x.type,payload:f({invokeImmediately:x.args.shouldOpenNow},x.args)})};switch(x.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let M=I.find($=>$.id===x.args.branchId);if(!M)return;O(),_(),i.add(A(f({},j),{action:T.bind(null,{subjectId:h,subjectName:"container",action:x,payload:{chapterId:M.chapterId,autoSelect:C}})}));return}case P.setMaxWeightBranch.trim().toLowerCase():return;case P.setMinWeightBranch.trim().toLowerCase():return;case P.setRandomBranch.trim().toLowerCase():return;case P.setWeightlessRandomBranch.trim().toLowerCase():return;case P.continuePlayback.trim().toLowerCase():{O(),_(),i.add(A(f({},j),{action:E.bind(null,{subjectId:h,subjectName:"container",action:x})}));return}case P.openURI.trim().toLowerCase():{O(),_(),i.add(A(f({},j),{action:m.bind(null,{subjectId:h,subjectName:"container",action:x,payload:{URI:p.args.uri}})}));return}default:{let M="Unexpected container event",$=new B(1,1,{message:M});d($,M);return}}};function a({container:p,branches:h,isEOV:y=!1}){var S,C;let I=Jr(p.events);if(I){let x=Ai(I.action,y);r.emit(k.interactives,{subjectId:p.id,subjectName:"container",type:F.actionChoice,actionType:x.type,payload:f({invokeImmediately:x.args.shouldOpenNow},x.args)}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"container",type:"action-choice",actionType:x.type,payload:f({invokeImmediately:x.args.shouldOpenNow},x.args)}),i.add({timestamp:y?1/0:(S=p.endTime)!=null?S:1/0,priority:"container",initiator:p.id,actionType:P.expect,action:b.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let x of(C=p.events)!=null?C:[])s({action:x.action,container:p,branches:h,isEOV:y})}let c=({chapterId:p,action:h,branches:y=[]})=>{let I=r.emit.bind(r,k.interactives,{subjectId:p,subjectName:"chapter",type:F.actionChoice,actionType:h.type,payload:h.args}),S=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let C=y.find(x=>x.id===h.args.branchId);return C!=null&&C.chapterId?(I(),S(),T.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setWeightlessRandomBranch.trim().toLowerCase():{let C=fl(y);return C!=null&&C.chapterId?(I(),S(),T.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setRandomBranch.trim().toLowerCase():{let C=vl(y);return C!=null&&C.chapterId?(I(),S(),T.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setMaxWeightBranch.trim().toLowerCase():{let C=ml(y);return C!=null&&C.chapterId?(I(),S(),T.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setMinWeightBranch.trim().toLowerCase():{let C=dl(y);return C!=null&&C.chapterId?(I(),S(),T.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.continuePlayback.trim().toLowerCase():return I(),S(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h});case P.openURI.trim().toLowerCase():return I(),S(),m.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let C="Unexpected chapter event",x=new B(1,1,{message:C});d(x,C);return}}};function d(p,h){console.error(h),e.error$.next(p),r.emit(k.errors,p)}function v(p){var y;let h=Jr(p.events);if(h){if(ne(p))return;r.emit(k.interactives,{subjectId:p.id,subjectName:"chapter",type:F.actionChoice,actionType:h.action.type,payload:h.action.args}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"chapter",type:"action-choice",actionType:h.action.type,payload:h.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:P.expect,action:b.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(y=p.events)==null||y.forEach(I=>{let S=c({chapterId:p.id,action:I.action,branches:p.branches});S&&i.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:I.action.type,action:S})})}let b=({subjectId:p,subjectName:h})=>{t.pause(),r.emit(k.interactives,{subjectId:p,subjectName:h,type:F.actionExecution,actionType:P.expect}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:P.expect})},g=({subjectId:p,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(k.interactives,{subjectId:p,subjectName:h,type:F.actionExecution,actionType:yl}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:yl})},E=({subjectId:p,subjectName:h,subjectType:y,action:I})=>{r.emit(k.interactives,{subjectId:p,subjectName:h,subjectType:y,type:F.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:y,type:"action-execution",actionType:I.type})},T=({subjectId:p,subjectName:h,subjectType:y,action:I,payload:S})=>{S.behaviour="change-chapter",r.emit(k.interactives,{subjectId:p,subjectName:h,subjectType:y,type:F.actionExecution,actionType:I.type,payload:S}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:y,type:"action-execution",actionType:I.type,payload:S})},m=({subjectId:p,subjectName:h,subjectType:y,action:I,payload:S})=>{if(!S.URI)return;let C=window.open(S.URI,"_blank","noopener,noreferrer");C&&(C.opener=null),r.emit(k.interactives,{subjectId:p,subjectName:h,subjectType:y,type:F.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:y,type:"action-execution",actionType:I.type})};return{onControlEvent:l,onContainerEvent:s,onChapterEvent:c,onExpectEvent:b,expectEventHandler:g,setManifestChapterEvents:v,setManifestContainerEvents:a,stopExpect:o,state:n}};var Ri=te(ai(),1);import{Subscription as ud,Subject as wi,ValueSubject as pt}from"@vkontakte/videoplayer-shared/es2015";var Si=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(l=>l.id===i);if(!n)return null;let o=e.media.videos.find(l=>n.videoId===l.id);if(!o)return null;t[i]=Cl(o)}return t[i]}).filter(Boolean)},ad=r=>{for(let e of r.variants)if(ld(e)&&e.payload)return e.payload.id},ld=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),Cl=r=>{let e=ad(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},cd=(r,e)=>{for(let t of r.media.videos)if(e===Cl(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},El=(r,e)=>r.reduce((t,i)=>{let n=cd(e,i);return n?[...t,n]:t},[]);var le,ge,Ce,X,sr,ce,ue,oe,Ee,Ne,$e,ht=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new pt([]),hasPrevChapter$:new pt(!1),prevChapter$:new pt(null),isInitialChapter$:new pt(!1),isGoBackLimited$:new pt(!1)};W(this,le,null);W(this,ge);W(this,Ce,!1);W(this,X,null);W(this,sr,null);this.events={inited$:new wi,destroyed$:new wi,error$:new wi};W(this,ce,null);W(this,ue,null);W(this,oe,null);W(this,Ee,new ud);W(this,Ne,!1);W(this,$e,0);var l;N(this,ce,t),N(this,oe,e),N(this,ue,i),N(this,le,n),N(this,ge,o),this.state.history$&&w(this,Ee)&&((l=w(this,Ee))==null||l.add(this.state.history$.subscribe(s=>{var a,c;this.state.prevChapter$.next((0,Ri.default)(s,-2)||null),this.state.hasPrevChapter$.next(s.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(a=w(this,X))==null?void 0:a.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(w(this,$e)===w(this,ge).maxLength-1)})))}setManifest(e){return R(this,null,function*(){if(!w(this,ue)||!w(this,oe))return;N(this,X,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield w(this,ue).setChapter({chapterId:t,pushToHistory:!1}),w(this,Ce)||(N(this,Ce,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return w(this,Ce)}updateHistory(e,t=!0){return R(this,null,function*(){var s;if(!w(this,X))return;w(this,Ne)?(N(this,Ne,!1),Di(this,$e)._++):N(this,$e,0);let i=w(this,X),n=e.length-w(this,ge).maxLength,o=n>0?e.slice(n):e,l=Si(o,i);if(N(this,sr,l),this.state.history$.next(o),!(!t||!w(this,le)||!w(this,ce)))try{yield w(this,le).save(w(this,ce),l)}catch(a){let c=new B(1,5,"Unable to save interactive history");this.events.error$.next(c),(s=w(this,oe))==null||s.emit(k.errors,c)}})}goBack(){return R(this,null,function*(){var i;if(!this.state||!w(this,ue)){let n=new B(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=w(this,oe))==null?void 0:i.emit(k.errors,n)}N(this,Ne,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield w(this,ue).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return R(this,null,function*(){var n;if(!w(this,X)||!w(this,ce))return;let e=w(this,X),t=[this.getInitialVideoId()];if(w(this,le))try{let o=yield w(this,le).get(w(this,ce));o.length&&(t=o)}catch(o){let l=new B(1,5,"Error while trying to fetch data");this.events.error$.next(l),(n=w(this,oe))==null||n.emit(k.errors,l)}let i=El(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,Ri.default)(e,-1)||w(this,ge).initChapterId||((t=w(this,X))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(w(this,X)){let e=this.getInitialChapterId();return Si([e],w(this,X)).pop()}return null}destroy(){var e,t;N(this,ce,null),N(this,le,null),N(this,ue,null),(e=w(this,Ee))==null||e.unsubscribe(),N(this,Ee,null),N(this,Ce,!1),(t=w(this,oe))==null||t.emit(k.historyDestroyed),this.events.destroyed$.next(),N(this,oe,null)}};le=new WeakMap,ge=new WeakMap,Ce=new WeakMap,X=new WeakMap,sr=new WeakMap,ce=new WeakMap,ue=new WeakMap,oe=new WeakMap,Ee=new WeakMap,Ne=new WeakMap,$e=new WeakMap;var ar=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var n;let e=(n=this.rootElement.getContext("2d"))==null?void 0:n.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,i=t.length;for(let o=3;o<i;o+=40)if(t[o]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(e,t=!1){return R(this,null,function*(){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i})}save(){return R(this,null,function*(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,yield t.decode(),t})}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var lr=class{constructor({parentElement:e,endOffsetMs:t=250,onError:i}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,i=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(i)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
6
|
+
var kl=Object.create;var pr=Object.defineProperty,Pl=Object.defineProperties,Vl=Object.getOwnPropertyDescriptor,Ml=Object.getOwnPropertyDescriptors,_l=Object.getOwnPropertyNames,ft=Object.getOwnPropertySymbols,Ll=Object.getPrototypeOf,hr=Object.prototype.hasOwnProperty,ji=Object.prototype.propertyIsEnumerable;var Bi=r=>{throw TypeError(r)};var $i=(r,e,t)=>e in r?pr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,f=(r,e)=>{for(var t in e||(e={}))hr.call(e,t)&&$i(r,t,e[t]);if(ft)for(var t of ft(e))ji.call(e,t)&&$i(r,t,e[t]);return r},A=(r,e)=>Pl(r,Ml(e));var ee=(r,e)=>{var t={};for(var i in r)hr.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&ft)for(var i of ft(r))e.indexOf(i)<0&&ji.call(r,i)&&(t[i]=r[i]);return t};var u=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Fl=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _l(e))!hr.call(r,n)&&n!==t&&pr(r,n,{get:()=>e[n],enumerable:!(i=Vl(e,n))||i.enumerable});return r};var te=(r,e,t)=>(t=r!=null?kl(Ll(r)):{},Fl(e||!r||!r.__esModule?pr(t,"default",{value:r,enumerable:!0}):t,r));var qi=(r,e,t)=>e.has(r)||Bi("Cannot "+t);var w=(r,e,t)=>(qi(r,e,"read from private field"),t?t.call(r):e.get(r)),W=(r,e,t)=>e.has(r)?Bi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),N=(r,e,t,i)=>(qi(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var Di=(r,e,t,i)=>({set _(n){N(r,e,n,t)},get _(){return w(r,e,i)}});var R=(r,e,t)=>new Promise((i,n)=>{var o=a=>{try{s(t.next(a))}catch(c){n(c)}},l=a=>{try{s(t.throw(a))}catch(c){n(c)}},s=a=>a.done?i(a.value):Promise.resolve(a.value).then(o,l);s((t=t.apply(r,e)).next())});var ie=u((Er,Ji)=>{"use strict";var De=function(r){return r&&r.Math===Math&&r};Ji.exports=De(typeof globalThis=="object"&&globalThis)||De(typeof window=="object"&&window)||De(typeof self=="object"&&self)||De(typeof global=="object"&&global)||De(typeof Er=="object"&&Er)||function(){return this}()||Function("return this")()});var z=u((Gd,en)=>{"use strict";en.exports=function(r){try{return!!r()}catch(e){return!0}}});var He=u((Wd,tn)=>{"use strict";var Bl=z();tn.exports=!Bl(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var an=u((zd,sn)=>{"use strict";var ql=He(),on=Function.prototype,rn=on.apply,nn=on.call;sn.exports=typeof Reflect=="object"&&Reflect.apply||(ql?nn.bind(rn):function(){return nn.apply(rn,arguments)})});var Y=u((Kd,un)=>{"use strict";var ln=He(),cn=Function.prototype,Tr=cn.call,Dl=ln&&cn.bind.bind(Tr,Tr);un.exports=ln?Dl:function(r){return function(){return Tr.apply(r,arguments)}}});var Ue=u((Qd,hn)=>{"use strict";var pn=Y(),Hl=pn({}.toString),Ul=pn("".slice);hn.exports=function(r){return Ul(Hl(r),8,-1)}});var Ir=u((Xd,dn)=>{"use strict";var Gl=Ue(),Wl=Y();dn.exports=function(r){if(Gl(r)==="Function")return Wl(r)}});var K=u((Yd,mn)=>{"use strict";var xr=typeof document=="object"&&document.all;mn.exports=typeof xr=="undefined"&&xr!==void 0?function(r){return typeof r=="function"||r===xr}:function(r){return typeof r=="function"}});var ve=u((Zd,fn)=>{"use strict";var zl=z();fn.exports=!zl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var St=u((Jd,vn)=>{"use strict";var Kl=He(),At=Function.prototype.call;vn.exports=Kl?At.bind(At):function(){return At.apply(At,arguments)}});var Ar=u(gn=>{"use strict";var bn={}.propertyIsEnumerable,yn=Object.getOwnPropertyDescriptor,Ql=yn&&!bn.call({1:2},1);gn.f=Ql?function(e){var t=yn(this,e);return!!t&&t.enumerable}:bn});var Sr=u((tm,Cn)=>{"use strict";Cn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Tn=u((rm,En)=>{"use strict";var Xl=Y(),Yl=z(),Zl=Ue(),wr=Object,Jl=Xl("".split);En.exports=Yl(function(){return!wr("z").propertyIsEnumerable(0)})?function(r){return Zl(r)==="String"?Jl(r,""):wr(r)}:wr});var Rr=u((im,In)=>{"use strict";In.exports=function(r){return r==null}});var Or=u((nm,xn)=>{"use strict";var ec=Rr(),tc=TypeError;xn.exports=function(r){if(ec(r))throw new tc("Can't call method on "+r);return r}});var Ge=u((om,An)=>{"use strict";var rc=Tn(),ic=Or();An.exports=function(r){return rc(ic(r))}});var we=u((sm,Sn)=>{"use strict";var nc=K();Sn.exports=function(r){return typeof r=="object"?r!==null:nc(r)}});var We=u((am,wn)=>{"use strict";wn.exports={}});var wt=u((lm,On)=>{"use strict";var kr=We(),Pr=ie(),oc=K(),Rn=function(r){return oc(r)?r:void 0};On.exports=function(r,e){return arguments.length<2?Rn(kr[r])||Rn(Pr[r]):kr[r]&&kr[r][e]||Pr[r]&&Pr[r][e]}});var Pn=u((cm,kn)=>{"use strict";var sc=Y();kn.exports=sc({}.isPrototypeOf)});var Ln=u((um,_n)=>{"use strict";var ac=ie(),Vn=ac.navigator,Mn=Vn&&Vn.userAgent;_n.exports=Mn?String(Mn):""});var Dn=u((pm,qn)=>{"use strict";var Bn=ie(),Vr=Ln(),Fn=Bn.process,Nn=Bn.Deno,$n=Fn&&Fn.versions||Nn&&Nn.version,jn=$n&&$n.v8,Z,Rt;jn&&(Z=jn.split("."),Rt=Z[0]>0&&Z[0]<4?1:+(Z[0]+Z[1]));!Rt&&Vr&&(Z=Vr.match(/Edge\/(\d+)/),(!Z||Z[1]>=74)&&(Z=Vr.match(/Chrome\/(\d+)/),Z&&(Rt=+Z[1])));qn.exports=Rt});var Mr=u((hm,Un)=>{"use strict";var Hn=Dn(),lc=z(),cc=ie(),uc=cc.String;Un.exports=!!Object.getOwnPropertySymbols&&!lc(function(){var r=Symbol("symbol detection");return!uc(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Hn&&Hn<41})});var _r=u((dm,Gn)=>{"use strict";var pc=Mr();Gn.exports=pc&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Lr=u((mm,Wn)=>{"use strict";var hc=wt(),dc=K(),mc=Pn(),fc=_r(),vc=Object;Wn.exports=fc?function(r){return typeof r=="symbol"}:function(r){var e=hc("Symbol");return dc(e)&&mc(e.prototype,vc(r))}});var Kn=u((fm,zn)=>{"use strict";var bc=String;zn.exports=function(r){try{return bc(r)}catch(e){return"Object"}}});var Fr=u((vm,Qn)=>{"use strict";var yc=K(),gc=Kn(),Cc=TypeError;Qn.exports=function(r){if(yc(r))return r;throw new Cc(gc(r)+" is not a function")}});var Yn=u((bm,Xn)=>{"use strict";var Ec=Fr(),Tc=Rr();Xn.exports=function(r,e){var t=r[e];return Tc(t)?void 0:Ec(t)}});var Jn=u((ym,Zn)=>{"use strict";var Nr=St(),$r=K(),jr=we(),Ic=TypeError;Zn.exports=function(r,e){var t,i;if(e==="string"&&$r(t=r.toString)&&!jr(i=Nr(t,r))||$r(t=r.valueOf)&&!jr(i=Nr(t,r))||e!=="string"&&$r(t=r.toString)&&!jr(i=Nr(t,r)))return i;throw new Ic("Can't convert object to primitive value")}});var to=u((gm,eo)=>{"use strict";eo.exports=!0});var no=u((Cm,io)=>{"use strict";var ro=ie(),xc=Object.defineProperty;io.exports=function(r,e){try{xc(ro,r,{value:e,configurable:!0,writable:!0})}catch(t){ro[r]=e}return e}});var Ot=u((Em,ao)=>{"use strict";var Ac=to(),Sc=ie(),wc=no(),oo="__core-js_shared__",so=ao.exports=Sc[oo]||wc(oo,{});(so.versions||(so.versions=[])).push({version:"3.43.0",mode:Ac?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Br=u((Tm,co)=>{"use strict";var lo=Ot();co.exports=function(r,e){return lo[r]||(lo[r]=e||{})}});var ze=u((Im,uo)=>{"use strict";var Rc=Or(),Oc=Object;uo.exports=function(r){return Oc(Rc(r))}});var Re=u((xm,po)=>{"use strict";var kc=Y(),Pc=ze(),Vc=kc({}.hasOwnProperty);po.exports=Object.hasOwn||function(e,t){return Vc(Pc(e),t)}});var qr=u((Am,ho)=>{"use strict";var Mc=Y(),_c=0,Lc=Math.random(),Fc=Mc(1.1.toString);ho.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Fc(++_c+Lc,36)}});var Ke=u((Sm,fo)=>{"use strict";var Nc=ie(),$c=Br(),mo=Re(),jc=qr(),Bc=Mr(),qc=_r(),Oe=Nc.Symbol,Dr=$c("wks"),Dc=qc?Oe.for||Oe:Oe&&Oe.withoutSetter||jc;fo.exports=function(r){return mo(Dr,r)||(Dr[r]=Bc&&mo(Oe,r)?Oe[r]:Dc("Symbol."+r)),Dr[r]}});var go=u((wm,yo)=>{"use strict";var Hc=St(),vo=we(),bo=Lr(),Uc=Yn(),Gc=Jn(),Wc=Ke(),zc=TypeError,Kc=Wc("toPrimitive");yo.exports=function(r,e){if(!vo(r)||bo(r))return r;var t=Uc(r,Kc),i;if(t){if(e===void 0&&(e="default"),i=Hc(t,r,e),!vo(i)||bo(i))return i;throw new zc("Can't convert object to primitive value")}return e===void 0&&(e="number"),Gc(r,e)}});var Hr=u((Rm,Co)=>{"use strict";var Qc=go(),Xc=Lr();Co.exports=function(r){var e=Qc(r,"string");return Xc(e)?e:e+""}});var Io=u((Om,To)=>{"use strict";var Yc=ie(),Eo=we(),Ur=Yc.document,Zc=Eo(Ur)&&Eo(Ur.createElement);To.exports=function(r){return Zc?Ur.createElement(r):{}}});var Gr=u((km,xo)=>{"use strict";var Jc=ve(),eu=z(),tu=Io();xo.exports=!Jc&&!eu(function(){return Object.defineProperty(tu("div"),"a",{get:function(){return 7}}).a!==7})});var wo=u(So=>{"use strict";var ru=ve(),iu=St(),nu=Ar(),ou=Sr(),su=Ge(),au=Hr(),lu=Re(),cu=Gr(),Ao=Object.getOwnPropertyDescriptor;So.f=ru?Ao:function(e,t){if(e=su(e),t=au(t),cu)try{return Ao(e,t)}catch(i){}if(lu(e,t))return ou(!iu(nu.f,e,t),e[t])}});var Oo=u((Vm,Ro)=>{"use strict";var uu=z(),pu=K(),hu=/#|\.prototype\./,Qe=function(r,e){var t=mu[du(r)];return t===vu?!0:t===fu?!1:pu(e)?uu(e):!!e},du=Qe.normalize=function(r){return String(r).replace(hu,".").toLowerCase()},mu=Qe.data={},fu=Qe.NATIVE="N",vu=Qe.POLYFILL="P";Ro.exports=Qe});var Wr=u((Mm,Po)=>{"use strict";var ko=Ir(),bu=Fr(),yu=He(),gu=ko(ko.bind);Po.exports=function(r,e){return bu(r),e===void 0?r:yu?gu(r,e):function(){return r.apply(e,arguments)}}});var Mo=u((_m,Vo)=>{"use strict";var Cu=ve(),Eu=z();Vo.exports=Cu&&Eu(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Lo=u((Lm,_o)=>{"use strict";var Tu=we(),Iu=String,xu=TypeError;_o.exports=function(r){if(Tu(r))return r;throw new xu(Iu(r)+" is not an object")}});var $o=u(No=>{"use strict";var Au=ve(),Su=Gr(),wu=Mo(),kt=Lo(),Fo=Hr(),Ru=TypeError,zr=Object.defineProperty,Ou=Object.getOwnPropertyDescriptor,Kr="enumerable",Qr="configurable",Xr="writable";No.f=Au?wu?function(e,t,i){if(kt(e),t=Fo(t),kt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Xr in i&&!i[Xr]){var n=Ou(e,t);n&&n[Xr]&&(e[t]=i.value,i={configurable:Qr in i?i[Qr]:n[Qr],enumerable:Kr in i?i[Kr]:n[Kr],writable:!1})}return zr(e,t,i)}:zr:function(e,t,i){if(kt(e),t=Fo(t),kt(i),Su)try{return zr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new Ru("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Bo=u((Nm,jo)=>{"use strict";var ku=ve(),Pu=$o(),Vu=Sr();jo.exports=ku?function(r,e,t){return Pu.f(r,e,Vu(1,t))}:function(r,e,t){return r[e]=t,r}});var Ve=u(($m,Do)=>{"use strict";var Xe=ie(),Mu=an(),_u=Ir(),Lu=K(),Fu=wo().f,Nu=Oo(),ke=We(),$u=Wr(),Pe=Bo(),qo=Re();Ot();var ju=function(r){var e=function(t,i,n){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,i)}return new r(t,i,n)}return Mu(r,this,arguments)};return e.prototype=r.prototype,e};Do.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,l=i?Xe:n?Xe[t]:Xe[t]&&Xe[t].prototype,s=i?ke:ke[t]||Pe(ke,t,{})[t],a=s.prototype,c,d,v,b,g,E,T,m,p;for(b in e)c=Nu(i?b:t+(n?".":"#")+b,r.forced),d=!c&&l&&qo(l,b),E=s[b],d&&(r.dontCallGetSet?(p=Fu(l,b),T=p&&p.value):T=l[b]),g=d&&T?T:e[b],!(!c&&!o&&typeof E==typeof g)&&(r.bind&&d?m=$u(g,Xe):r.wrap&&d?m=ju(g):o&&Lu(g)?m=_u(g):m=g,(r.sham||g&&g.sham||E&&E.sham)&&Pe(m,"sham",!0),Pe(s,b,m),o&&(v=t+"Prototype",qo(ke,v)||Pe(ke,v,{}),Pe(ke[v],b,g),r.real&&a&&(c||!a[b])&&Pe(a,b,g)))}});var Uo=u((jm,Ho)=>{"use strict";var Bu=Math.ceil,qu=Math.floor;Ho.exports=Math.trunc||function(e){var t=+e;return(t>0?qu:Bu)(t)}});var Ye=u((Bm,Go)=>{"use strict";var Du=Uo();Go.exports=function(r){var e=+r;return e!==e||e===0?0:Du(e)}});var zo=u((qm,Wo)=>{"use strict";var Hu=Ye(),Uu=Math.max,Gu=Math.min;Wo.exports=function(r,e){var t=Hu(r);return t<0?Uu(t+e,0):Gu(t,e)}});var Qo=u((Dm,Ko)=>{"use strict";var Wu=Ye(),zu=Math.min;Ko.exports=function(r){var e=Wu(r);return e>0?zu(e,9007199254740991):0}});var Ze=u((Hm,Xo)=>{"use strict";var Ku=Qo();Xo.exports=function(r){return Ku(r.length)}});var Yr=u((Um,Zo)=>{"use strict";var Qu=Ge(),Xu=zo(),Yu=Ze(),Yo=function(r){return function(e,t,i){var n=Qu(e),o=Yu(n);if(o===0)return!r&&-1;var l=Xu(i,o),s;if(r&&t!==t){for(;o>l;)if(s=n[l++],s!==s)return!0}else for(;o>l;l++)if((r||l in n)&&n[l]===t)return r||l||0;return!r&&-1}};Zo.exports={includes:Yo(!0),indexOf:Yo(!1)}});var Pt=u((Gm,Jo)=>{"use strict";Jo.exports=function(){}});var es=u(()=>{"use strict";var Zu=Ve(),Ju=Yr().includes,ep=z(),tp=Pt(),rp=ep(function(){return!Array(1).includes()});Zu({target:"Array",proto:!0,forced:rp},{includes:function(e){return Ju(this,e,arguments.length>1?arguments[1]:void 0)}});tp("includes")});var Vt=u((Km,ts)=>{"use strict";var ip=wt();ts.exports=ip});var is=u((Qm,rs)=>{"use strict";es();var np=Vt();rs.exports=np("Array","includes")});var os=u((Xm,ns)=>{"use strict";var op=is();ns.exports=op});var Mt=u((Ym,ss)=>{"use strict";var sp=os();ss.exports=sp});var Ss=u(()=>{"use strict";var mp=Ve(),fp=ze(),vp=Ze(),bp=Ye(),yp=Pt();mp({target:"Array",proto:!0},{at:function(e){var t=fp(this),i=vp(t),n=bp(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});yp("at")});var Rs=u((Pv,ws)=>{"use strict";Ss();var gp=Vt();ws.exports=gp("Array","at")});var ks=u((Vv,Os)=>{"use strict";var Cp=Rs();Os.exports=Cp});var ai=u((Mv,Ps)=>{"use strict";var Ep=ks();Ps.exports=Ep});var Ns=u((Yv,Fs)=>{"use strict";var xp=Br(),Ap=qr(),Ls=xp("keys");Fs.exports=function(r){return Ls[r]||(Ls[r]=Ap(r))}});var js=u((Zv,$s)=>{"use strict";var Sp=z();$s.exports=!Sp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Ds=u((Jv,qs)=>{"use strict";var wp=Re(),Rp=K(),Op=ze(),kp=Ns(),Pp=js(),Bs=kp("IE_PROTO"),li=Object,Vp=li.prototype;qs.exports=Pp?li.getPrototypeOf:function(r){var e=Op(r);if(wp(e,Bs))return e[Bs];var t=e.constructor;return Rp(t)&&e instanceof t?t.prototype:e instanceof li?Vp:null}});var Us=u((eb,Hs)=>{"use strict";Hs.exports={}});var zs=u((tb,Ws)=>{"use strict";var Mp=Y(),ci=Re(),_p=Ge(),Lp=Yr().indexOf,Fp=Us(),Gs=Mp([].push);Ws.exports=function(r,e){var t=_p(r),i=0,n=[],o;for(o in t)!ci(Fp,o)&&ci(t,o)&&Gs(n,o);for(;e.length>i;)ci(t,o=e[i++])&&(~Lp(n,o)||Gs(n,o));return n}});var Qs=u((rb,Ks)=>{"use strict";Ks.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Ys=u((ib,Xs)=>{"use strict";var Np=zs(),$p=Qs();Xs.exports=Object.keys||function(e){return Np(e,$p)}});var ui=u((nb,ra)=>{"use strict";var Js=ve(),jp=z(),ea=Y(),Bp=Ds(),qp=Ys(),Dp=Ge(),Hp=Ar().f,ta=ea(Hp),Up=ea([].push),Gp=Js&&jp(function(){var r=Object.create(null);return r[2]=2,!ta(r,2)}),Zs=function(r){return function(e){for(var t=Dp(e),i=qp(t),n=Gp&&Bp(t)===null,o=i.length,l=0,s=[],a;o>l;)a=i[l++],(!Js||(n?a in t:ta(t,a)))&&Up(s,r?[a,t[a]]:t[a]);return s}};ra.exports={entries:Zs(!0),values:Zs(!1)}});var ia=u(()=>{"use strict";var Wp=Ve(),zp=ui().entries;Wp({target:"Object",stat:!0},{entries:function(e){return zp(e)}})});var oa=u((ab,na)=>{"use strict";ia();var Kp=We();na.exports=Kp.Object.entries});var aa=u((lb,sa)=>{"use strict";var Qp=oa();sa.exports=Qp});var ca=u((cb,la)=>{"use strict";var Xp=aa();la.exports=Xp});var fa=u(()=>{"use strict";var nh=Ve(),oh=ui().values;nh({target:"Object",stat:!0},{values:function(e){return oh(e)}})});var ba=u((Kb,va)=>{"use strict";fa();var sh=We();va.exports=sh.Object.values});var ga=u((Qb,ya)=>{"use strict";var ah=ba();ya.exports=ah});var rr=u((Xb,Ca)=>{"use strict";var lh=ga();Ca.exports=lh});var Ei=u((xy,Sa)=>{"use strict";var mh=Ue();Sa.exports=Array.isArray||function(e){return mh(e)==="Array"}});var Ra=u((Ay,wa)=>{"use strict";var fh=TypeError,vh=9007199254740991;wa.exports=function(r){if(r>vh)throw fh("Maximum allowed index exceeded");return r}});var Pa=u((Sy,ka)=>{"use strict";var bh=Ei(),yh=Ze(),gh=Ra(),Ch=Wr(),Oa=function(r,e,t,i,n,o,l,s){for(var a=n,c=0,d=l?Ch(l,s):!1,v,b;c<i;)c in t&&(v=d?d(t[c],c,e):t[c],o>0&&bh(v)?(b=yh(v),a=Oa(r,e,v,b,a,o-1)-1):(gh(a+1),r[a]=v),a++),c++;return a};ka.exports=Oa});var _a=u((wy,Ma)=>{"use strict";var Eh=Ke(),Th=Eh("toStringTag"),Va={};Va[Th]="z";Ma.exports=String(Va)==="[object z]"});var Fa=u((Ry,La)=>{"use strict";var Ih=_a(),xh=K(),nr=Ue(),Ah=Ke(),Sh=Ah("toStringTag"),wh=Object,Rh=nr(function(){return arguments}())==="Arguments",Oh=function(r,e){try{return r[e]}catch(t){}};La.exports=Ih?nr:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=Oh(e=wh(r),Sh))=="string"?t:Rh?nr(e):(i=nr(e))==="Object"&&xh(e.callee)?"Arguments":i}});var $a=u((Oy,Na)=>{"use strict";var kh=Y(),Ph=K(),Ti=Ot(),Vh=kh(Function.toString);Ph(Ti.inspectSource)||(Ti.inspectSource=function(r){return Vh(r)});Na.exports=Ti.inspectSource});var Ua=u((ky,Ha)=>{"use strict";var Mh=Y(),_h=z(),ja=K(),Lh=Fa(),Fh=wt(),Nh=$a(),Ba=function(){},qa=Fh("Reflect","construct"),Ii=/^\s*(?:class|function)\b/,$h=Mh(Ii.exec),jh=!Ii.test(Ba),ut=function(e){if(!ja(e))return!1;try{return qa(Ba,[],e),!0}catch(t){return!1}},Da=function(e){if(!ja(e))return!1;switch(Lh(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return jh||!!$h(Ii,Nh(e))}catch(t){return!0}};Da.sham=!0;Ha.exports=!qa||_h(function(){var r;return ut(ut.call)||!ut(Object)||!ut(function(){r=!0})||r})?Da:ut});var Ka=u((Py,za)=>{"use strict";var Ga=Ei(),Bh=Ua(),qh=we(),Dh=Ke(),Hh=Dh("species"),Wa=Array;za.exports=function(r){var e;return Ga(r)&&(e=r.constructor,Bh(e)&&(e===Wa||Ga(e.prototype))?e=void 0:qh(e)&&(e=e[Hh],e===null&&(e=void 0))),e===void 0?Wa:e}});var Xa=u((Vy,Qa)=>{"use strict";var Uh=Ka();Qa.exports=function(r,e){return new(Uh(r))(e===0?0:e)}});var Ya=u(()=>{"use strict";var Gh=Ve(),Wh=Pa(),zh=ze(),Kh=Ze(),Qh=Ye(),Xh=Xa();Gh({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=zh(this),i=Kh(t),n=Xh(t,0);return n.length=Wh(n,t,t,i,0,e===void 0?1:Qh(e)),n}})});var Za=u(()=>{"use strict";var Yh=Pt();Yh("flat")});var el=u((Ny,Ja)=>{"use strict";Ya();Za();var Zh=Vt();Ja.exports=Zh("Array","flat")});var rl=u(($y,tl)=>{"use strict";var Jh=el();tl.exports=Jh});var nl=u((jy,il)=>{"use strict";var ed=rl();il.exports=ed});var Hi="1.0.56-dev.d24d1c13.0";import{fromEvent as As,Subscription as dp}from"@vkontakte/videoplayer-shared/es2015";var dr=class{constructor(e,t){this.layout=e;this.cssVarsManager=t}},vt=class extends dr{constructor(t,i){super(t,i);this.cssVarsManager=i;this.cssVarsManager=i}setContainerLayout(t){t.style.position="relative"}setControlLayout(t,i){let n=this.cssVarsManager.getPropValue("--interactive-content-width"),o=this.cssVarsManager.getPropValue("--interactive-content-height"),l=this.cssVarsManager.getPropValue("--interactive-width"),s=this.cssVarsManager.getPropValue("--interactive-height"),a=2e-4;t.style.position="absolute",t.style.width=`calc(${n} * (${i.width} + ${a}))`,t.style.height=`calc(${o} * ${i.height})`,t.style.left=`calc(${n} * ${i.x} + ((${l} - ${n}) / 2))`,t.style.top=`calc(${o} * ${i.y} + ((${s} - ${o}) / 2))`}};import{Subject as Nl}from"@vkontakte/videoplayer-shared/es2015";function Ui(r){return"features"in r}var B=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};function bt({emitter$:r,error:e,subjectId:t,message:i="",severity:n=1,category:o=1}){let l=new B(n,o,{message:i,error:e,details:{id:t}});r.next(l)}var xe=class{constructor(e,t,i){this.error$=new Nl;this.container=e,this.options=i,this.factories=new Map,this.controls=[],this.setControls(),this.cssVarsManager=t}featureIsEnabled(e){return this.options&&this.options.features&&Ui(this.options)&&this.options.features[e]}onError(e="",t){bt({emitter$:this.error$,error:t,message:e,subjectId:this.container.id})}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){var e;return((e=this.container.controls)==null?void 0:e.reduce((t,i)=>{let n=i.type.trim().toLowerCase(),o=this.factories.get(n);if(o){let l=o(i,this.options);if(l)return[...t,l]}return[...t]},[]))||[]}};import{fromEvent as et,once as fs}from"@vkontakte/videoplayer-shared/es2015";var pe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,he=r=>pe(r,"Object"),yt=r=>pe(r,"String"),gt=r=>pe(r,"Array"),Ct=r=>pe(r,"Number"),Gi=r=>pe(r,"Function"),Wi=r=>pe(r,"Boolean"),vr=r=>Ct(r)&&!isNaN(r);var me=r=>he(r)&&Object.keys(r).length===0,br=r=>gt(r)&&!r.length;var je=(r,e)=>yt(r)&&(e?r.trim():r).length;function Be(r,e=1){let t="0",i="0",n="0";return r.length===4?(t="0x"+r[1]+r[1],i="0x"+r[2]+r[2],n="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],i="0x"+r[3]+r[4],n="0x"+r[5]+r[6]),`rgba(${+t},${+i},${+n},${e})`}var zi="interactive",L={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},Ki=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(Ki||{}),Qi=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(Qi||{}),Xi=(i=>(i.start="left",i.end="right",i.center="center",i))(Xi||{}),Et=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&Ki[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&Qi[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&Xi[e.alignment])!=null?n:"center"},Tt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,o,l,s,a,c;r.style.color=(o=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?o:t.textColor,r.style.fontSize=`calc(${i.height} * ${(s=(l=e==null?void 0:e.text)==null?void 0:l.size)!=null?s:t.textSize})`,r.textContent=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},It=({target:r,props:e,fallback:t})=>{var i,n,o,l;r.style.backgroundColor=Be((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(l=(o=e==null?void 0:e.background)==null?void 0:o.alpha)!=null?l:t.backgroundAlpha)},qe=({target:r,props:e,fallback:t,dependsOn:i,useRawValues:n=!1})=>{var s,a,c,d,v,b,g,E,T,m,p;let o=n?t.borderWidthRawValue:`calc(${i.height} * ${(c=(a=(s=e==null?void 0:e.shape)==null?void 0:s.border)==null?void 0:a.width)!=null?c:t.borderWidth})`,l=n?t.roundCornersRawValue:`calc(${i.height} * ${(v=(d=e==null?void 0:e.shape)==null?void 0:d.roundCorners)!=null?v:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Be(n?t.borderColor:(E=(g=(b=e==null?void 0:e.shape)==null?void 0:b.border)==null?void 0:g.color)!=null?E:t.borderColor,n?t.borderAlpha:(p=(m=(T=e==null?void 0:e.shape)==null?void 0:T.border)==null?void 0:m.alpha)!=null?p:t.borderAlpha),r.style.borderRadius=l},Yi=({target:r,isDark:e,baseDimension:t,fallback:i})=>{let l=Be(i.shadowColorLight,i.shadowColorAlpha),s=Be(i.shadowColorDark,i.shadowColorAlpha),a=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${a} ${c} ${e?s:l}`;r.style.boxShadow=d},Ae=({target:r,layoutParams:e,fallback:t})=>{var n;let i=(n=e.angle)!=null?n:t.angle;i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};import{fromEvent as Je,Subject as lp,Subscription as cp}from"@vkontakte/videoplayer-shared/es2015";var yr="interactive-control-tap",Se={common:yr,animation:`${yr}-animation`,visible:`${yr}-visible`};var $l=60,xt=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=$l,useDimensionsBasedSize:n=!1}){this.onElementClick=e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let i=t.getBoundingClientRect(),n={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},o=Math.min(n.width,n.height),l=i.left+i.width/2,s=i.top+i.height/2,a=e.clientX-l,c=e.clientY-s,d=jl(a,c,this.controlRotateAngleRad);this.element.style.width=o+"px",this.element.style.left=d.x+i.width/2-o/2+"px",this.element.style.top=d.y+i.height/2-o/2+"px",this.element.classList.add(Se.visible,Se.animation)};this.onAnimationEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.element.classList.remove(Se.visible,Se.animation)};let o=document.createElement("div");o.classList.add(Se.common),this.controlRotateAngleRad=e,this.element=o,this.clickCancelCondition=t,this.circleDiameterPx=i,this.useDimensionsBasedSize=n}};function jl(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var gr="int",fe=(i=>(i.AREA=`${gr}_area`,i.TEXT=`${gr}_text`,i.BUTTON=`${gr}_bttn`,i))(fe||{});function Cr(r){return"features"in r}var re="interactive-control",V={common:re,selected:`${re}-selected`,wrapper:`${re}-wrapper`,disabled:`${re}-disabled`,button:`${re}-button`,area:`${re}-area`,text:`${re}-text`,blinkAnim:`${re}-blink-anim`,blinkAnimButton:`${re}-blink-anim-button`,blinkAnimArea:`${re}-blink-anim-area`},Zi=40;var us=te(Mt(),1);import{isSupportedManifest as Lt,ContainerTypes as pf,ControlTypes as Ft,EventActionTypes as P,EventTypes as hf,migrateManifestToLatestVersion as cs,compareVersions as df}from"@interactiveplatform/movika-manifest";var as={metadata:"Object",chapters:"Array"},ls=r=>{if(!he(r))return!1;for(let e in as)if(!r[e]||!pe(r[e],as[e]))return!1;return Lt(r.metadata.version)},_t=r=>r.type===Ft.Text,tf=r=>r.type===Ft.Button,rf=r=>r.type===Ft.Area,nf={Choice:"Choice",TextInput:"TextInput"},of={Button:"Button",Area:"Area",Text:"Text"},sf={onClick:"onClick",onSuspense:"onSuspense"},af={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Nt=r=>gt(r)&&!br(r),ne=r=>r.order==="end",$t=r=>gt(r.containers)&&!br(r.containers)&&ne(r),ps=(r,e)=>{var i;let t=r*1e3;return Nt(e.controls)&&t<((i=e.startTime)!=null?i:0)},Zr=(r,e)=>{var i,n;let t=r*1e3;return Nt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var be=(r=[])=>r.some(e=>e.action.type==="expect"),Jr=(r=[])=>r.find(e=>e.action.type==="expect"),ap=r=>(r==null?void 0:r.length)===1,Me=r=>ap(r)&&_t(r[0]);function hs(r=[],e=1/0,t=[]){return r.filter(({container:i})=>!(0,us.default)(t,i.container.id)&&be(i.container.events)&&i.container.endTime===e&&!i.isRemoved&&!i.willRemoved)}function jt({gameControllers:r=[],subjectName:e,subjectId:t,execFn:i}){for(let n of r)if(e==="container"&&n.container.container.id===t){i(n),hs(r,n.container.container.endTime,[n.container.container.id]).forEach(l=>{i(l)});break}}function ds(r){for(let e of r.events)if(e.action.type==="openURI")return!0;return!1}var ms=(r,e)=>{let t=T=>{let m=e.find(({container:p})=>p.container.id===T);return m==null?void 0:m.container.isRemoved},i=be(r.events)&&!t(r.id),n=(T,m=!1,p=!1)=>{let h=p?"every":"some";return T.controls[h](y=>{var S;let I=m?T.endTime===r.endTime:!0;return((S=y.events)==null?void 0:S[h](C=>{var x;return((x=C.action)==null?void 0:x.type)===P.openURI}))&&I})},o=T=>T.some(({container:m})=>n(m.container,!0,!1)&&!m.isRemoved),l=T=>T.every(({container:m})=>m.isRemoved||m.willRemoved?!0:n(m.container,!0,!0)),s=hs(e,r.endTime,[r.id]).length,a=T=>T.controls.some(m=>{var p;return(p=m.events)==null?void 0:p.some(h=>{var y,I;return(I=(y=h.action)==null?void 0:y.args)==null?void 0:I.shouldOpenNow})}),c=i||s>0,d=o(e),v=n(r),b=l(e),g=i?!1:s>0,E=a(r);return{isExpectTime:c,hasOtherExpect:s>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:v,isAllOpenURIEventsValid:b,isExpectEventForCurrentContainer:g,hasShouldOpenNowEvent:E}};var de=class r{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new cp;this.error$=new lp;this.isInteracted=!1;this.isRemoved=!1;this.cssVarsManager=null;this.onControlSelect=()=>{var e,t,i;(e=this.container)!=null&&e.isManifestContainerDisabled()||ds(this.control)||(i=(t=this.container)==null?void 0:t.element)==null||i.classList.add("interactive-control-wrapper-selected")};this.onTransitionEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}}setCssVarsManager(e){this.cssVarsManager=e}removeView(e=!1){let t=this.getElement();if(t){if(e){if(t.classList.contains("interactive-control-before-remove"))return;t.classList.add("interactive-control-before-remove"),this.subscriptions.add(Je(t,"transitionend").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n))).add(Je(t,"transitioncancel").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n)));return}this.removeListeners(),t.remove(),this.isRemoved=!0}}onError(e="",t){bt({emitter$:this.error$,error:t,message:e,subjectId:this.control.id})}addControlTap(e){var t;if(this.featureIsEnabled("controlsTapPlace")&&this.container){let i=(t=this.control.layoutParams.angle)!=null?t:L.angle;this.controlTap=new xt({controlRotateAngleRad:i,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?Zi:void 0}),this.subscriptions.add(Je(e,"click").subscribe(this.controlTap.onElementClick,n=>this.onError("Control click tap animation error",n))).add(Je(this.controlTap.element,"animationend").subscribe(this.controlTap.onAnimationEnd,n=>this.onError("Tap animationend error",n))),this.container.element.append(this.controlTap.element)}}createContainerElement(e){var o,l,s,a,c;let t=document.createElement("div");t.classList.add(V.wrapper),e.setControlLayout(t,this.control.layoutParams);let i=((o=this.control.layoutParams.innerSizesDependOn)!=null?o:L.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:(s=(l=this.cssVarsManager)==null?void 0:l.getPropValue("--interactive-content-height"))!=null?s:0,width:(c=(a=this.cssVarsManager)==null?void 0:a.getPropValue("--interactive-content-width"))!=null?c:0},n=()=>{var d,v;return(v=(d=e.isContainerDisabled)==null?void 0:d.call(e))!=null?v:!1};this.container={element:t,dimensions:i,isManifestContainerDisabled:n}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted=!0,e()}}featureIsEnabled(e){return this.options&&Cr(this.options)&&this.options.features[e]}isTouch(){return this.options&&Cr(this.options)&&this.options.isTouch}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add(Je(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),n=>this.onError("Error happened on control interaction",n)));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var ei="interactive-blink-anim-reference",q={common:ei,animation:`${ei}-animation`,disabled:`${ei}-disabled`},Bt=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(q.common,q.animation),this._element=e}restart(){this._element&&(this._element.classList.add(q.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(q.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var ti="interactive-container",D={common:ti,hidden:`${ti}-hidden`,disabled:`${ti}-disabled`};var qt=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new ri(r,e)},ri=class extends de{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(V.common,V.area),i.setAttribute("data-testid",fe.AREA),It({target:i,props:this.control.props,fallback:A(f({},L),{backgroundColor:"transparent"})}),Ae({target:i,layoutParams:this.control.layoutParams,fallback:L}),this.addControlTap(i),this.subscriptions.add(et(this.container.element,"click").pipe(fs()).subscribe(this.onControlSelect,n=>this.onError("Control click handler error",n))),this.container.element.append(i),e.append(this.container.element),this.controlElement=i,this.updateShadowStyles(),this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(et(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(D.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${q.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(et(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(D.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(et(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(V.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(V.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){var t,i,n;if(!(!this.container||!this.controlElement))if(Wi(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";Yi({target:this.controlElement,props:this.control.props,fallback:L,isDark:e,baseDimension:o}),qe({target:this.controlElement,props:this.control.props,fallback:A(f({},L),{borderColor:e?L.shadowColorDark:L.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${(n=(i=(t=this.control.props)==null?void 0:t.shape)==null?void 0:i.roundCorners)!=null?n:L.roundCorners})`}),dependsOn:this.container.dimensions,useRawValues:!0})}else qe({target:this.controlElement,props:this.control.props,fallback:A(f({},L),{borderAlpha:0}),dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(V.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(V.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${V.blinkAnimArea}`)||this.controlElement.classList.contains(V.selected)||this.controlElement.classList.contains(q.disabled)||(this.controlElement.classList.add(q.disabled),this.subscriptions.add(et(e,"animationiteration").pipe(fs()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(q.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${V.blinkAnimArea}`)||this.controlElement.classList.contains(V.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}};import{fromEvent as tt,once as Is}from"@vkontakte/videoplayer-shared/es2015";var Dt=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),i={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,i),t.append(e);let n={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,n),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var Ht=Math.PI,ii=2*Ht,Ut=Ht/2,vs=3*Ut,up=0,pp=[up,Ut,Ht,vs];function bs(r){return r===Ut}function ys(r){return r===Ht}function gs(r){return r===vs}function Cs(r){return(r%ii+ii)%ii}function hp(r){for(let e of pp)if(r===e)return e}function Es(r){if(hp(r))return null;let t=Math.floor(r/Ut)+1;return[1,2,3,4][t-1]}function Ts(r){return r*180/Math.PI}var ae="interactive-control-fill-animation",H={common:ae,fillerWrapper:`${ae}-filler-wrapper`,filler:`${ae}-filler`,fillHeight:`${ae}-fill-height`,fillWidth:`${ae}-fill-width`,fromTop:`${ae}-from-top`,fromBottom:`${ae}-from-bottom`,fromLeft:`${ae}-from-left`,fromRight:`${ae}-from-right`};var Gt=class r{constructor(e){this.widthExpansionCoef=0;var m;let t=document.createElement("div");t.classList.add(H.common);let i=document.createElement("div");i.classList.add(H.fillerWrapper);let n=document.createElement("div");n.classList.add(H.filler),i.append(n),t.append(i);let o=Cs(e.rotateAngle),l=Es(o),s=l!==null,c=l===2||!s&&ys(o)||l===3,d=!s&&bs(o),v=!s&&gs(o),b=!c&&!d&&!v,g=d||v,E=s&&!g,T=E?o:0;t.style.borderRadius=e.borderRadius,i.style.transform=`skew(${T*-1}rad)`,g?(n.classList.add(H.fillHeight,d?H.fromTop:H.fromBottom),i.classList.add(H.fillHeight,d?H.fromTop:H.fromBottom)):(n.classList.add(H.fillWidth,b?H.fromLeft:H.fromRight),i.classList.add(H.fillWidth)),e.debug&&console.log(`[interactive ${r.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:g,rotateAngleRad:o,rotateAngelDeg:Ts(o),rotateAngleRaw:e.rotateAngle,fromRight:c,fromTop:d,fromBottom:v,fromLeft:b}),this.useSkew=E,this.fromLeft=b,this.rotateAngle=o,this.fillAnimationElement=t,this.fillAnimationFillerElement=n,this.fillAnimationFillerWrapperElement=i,this.startTime=e.startTime,this.endTime=e.endTime,this.shouldFillHeight=g,this.isDebug=(m=e.debug)!=null?m:!1}updateDimension(e){this.fillAnimationElement.style.top=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.left=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.width=`${e.width}px`,this.fillAnimationElement.style.height=`${e.height}px`;let t=this.calcWidthExpansionCoef({rotateAngle:this.rotateAngle,isSkewed:this.useSkew,initWidth:e.width,initHeight:e.height});!this.shouldFillHeight&&(this.fillAnimationFillerWrapperElement.style.width=100*t+100+"%",this.fillAnimationFillerWrapperElement.style[`${this.fromLeft?"left":"right"}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((o=>o<this.startTime||o>this.endTime)(e))return;let i=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/i,0),1);this.shouldFillHeight?this.fillAnimationFillerElement.style.transform=`scaleY(${n})`:this.fillAnimationFillerElement.style.transform=`scaleX(${n})`}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:i,initHeight:n}){return t?(i+n*Math.abs(Math.tan(e)))/i-1:0}};var Wt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new ni(r,e)},ni=class extends de{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var l,s,a,c,d,v;if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(V.common,V.button),i.setAttribute("data-testid",fe.BUTTON),Ae({target:i,layoutParams:this.control.layoutParams,fallback:L}),It({target:i,props:this.control.props,fallback:L}),qe({target:i,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),Et({target:i,props:A(f({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let n=Dt(this.control.type.trim().toLowerCase()),o=(l=n.firstElementChild)!=null?l:n;Tt({target:o,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),this.addControlTap(i),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled("controlsFillAnimation")&&(this.controlFillAnimation=new Gt({startTime:this.startTime,endTime:this.endTime,rotateAngle:(s=this.control.layoutParams.angle)!=null?s:L.angle,borderRadius:i.style.borderRadius})),this.subscriptions.add(tt(i,"click").pipe(Is()).subscribe(this.onControlSelect,b=>this.onError("Control click handler error",b))),i.append(n,(c=(a=this.controlFillAnimation)==null?void 0:a.fillAnimationElement)!=null?c:""),this.container.element.append((v=(d=this.controlTap)==null?void 0:d.element)!=null?v:"",i),e.append(this.container.element),this.controlElement=i,this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(tt(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(D.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${q.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(tt(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(D.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(tt(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(V.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(V.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(V.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(V.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${V.blinkAnimButton}`)||this.controlElement.classList.contains(V.selected)||this.controlElement.classList.contains(q.disabled)||(this.controlElement.classList.add(q.disabled),this.subscriptions.add(tt(e,"animationiteration").pipe(Is()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(q.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${V.blinkAnimButton}`)||this.controlElement.classList.contains(V.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}updateFillAnimationDimensions(){if(!this.container||!this.controlElement||!this.controlFillAnimation)return;let e=getComputedStyle(this.controlElement),t={width:parseFloat(e.width),height:parseFloat(e.height),borderWidth:parseFloat(e.borderWidth)||0};this.controlFillAnimation.updateDimension(t)}setShowTimeRange(e,t){this.startTime=e,this.endTime=t}onProgress(e){var t;(t=this.controlFillAnimation)==null||t.updateAnimation(e)}onResize(){this.updateFillAnimationDimensions()}updateShadowStyles(){}};var xs=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new oi(r,e)},oi=class extends de{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var l;if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("div");i.classList.add(V.common,V.text),i.setAttribute("data-testid",fe.TEXT),Ae({target:i,layoutParams:this.control.layoutParams,fallback:L}),Et({target:i,props:A(f({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let n=Dt(this.control.type.trim().toLowerCase()),o=(l=n.firstElementChild)!=null?l:n;Tt({target:o,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}setShowTimeRange(){}updateFillAnimationDimensions(){}};var zt=(r,e,t,i)=>{if(r.type.trim().toLowerCase()==="choice")return new si(r,e,t,i)},si=class r extends xe{constructor(t,i,n,o){super(t,n,o);this.containerElement=null;this.subscriptions=new dp;this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&this.removeView()};this.rootElement=i,this.layout=new vt(this.container.layout,n),this.cssVarsManager=n,this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Wt),this.addControlFactory("text",xs),this.addControlFactory("area",qt)}createView({eventCallback:t,videoDurationMs:i}){let n=document.createElement("div");return n.classList.add(D.common,D.disabled),n.setAttribute("data-subjectId",this.container.id),requestAnimationFrame(()=>{n.classList.remove(D.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(o=>{var l;o.setShowTimeRange(this.container.startTime,(l=this.container.endTime)!=null?l:i),o.setCssVarsManager(this.cssVarsManager),o.createView({parentElement:n,callbacks:{setControlLayout:(s,a)=>this.layout.setControlLayout(s,a),isContainerDisabled:()=>this.isDisabled}}),o.setEvents(t),this.subscriptions.add(o.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.willRemoved=!1,this.containerElement=n,this.updateControlsFillAnimationDimensions(),n}updateControlsFillAnimationDimensions(){for(let t of this.controls)t.updateFillAnimationDimensions()}hide(){let t=this.getElement();t&&t.classList.add(D.hidden)}show(){let t=this.getElement();t&&t.classList.remove(D.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(D.disabled),this.controls.forEach(i=>i.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(D.disabled),this.controls.forEach(i=>i.disable()),this.isDisabled=!0)}removeView(t=!1,i=!1){let n=this.getElement();if(n){if(t){if(this.willRemoved)return;this.willRemoved=!0,i&&n.classList.add("interactive-container-before-remove-delay"),n.classList.add("interactive-container-before-remove"),this.subscriptions.add(As(n,"transitionend").subscribe(this.onTransitionEnd,l=>this.onError(`${r.name} remove view transition error`,l))).add(As(n,"transitioncancel").subscribe(this.onTransitionEnd,l=>this.onError(`${r.name} remove view transition error`,l)));return}this.subscriptions.unsubscribe(),this.removeAllControls(),n.remove(),this.isRemoved=!0,this.willRemoved=!1,this.containerElement=null}}removeAllControls(t=!1){this.controls.forEach(i=>i.removeView(t))}removeNonInteractedControls(t=!1){this.controls.forEach(i=>{i.isInteracted||i.removeView(t)})}isInteracted(){return this.controls.some(t=>t.isInteracted)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,i){i&&this.controls.forEach(n=>{n.onProgress(t)})}onResize(t){t&&this.controls.forEach(i=>{i.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(i=>i.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(i=>i.toggleBlinkAnimation(t))}};var Rl=te(ai(),1);import{combine as hd,InterfaceLanguage as dd,Observable as Al,once as md,Subject as U,Subscription as Oi,ValueSubject as G,fromEvent as Sl}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as dt}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as Tp}from"@vkontakte/videoplayer-shared/es2015";function rt(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var Vs="video_interactive",Ms="videoint";var _s=250,it=class{constructor(e){this.handleZoomChange=rt(e=>{this.lastZoomInfo=e},_s);this.onResize=e=>{var i;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((i=this.ngEditor)==null||i.zoomTo(t,void 0,{isFromCenter:!0})),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,i,n;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Chapter id is not found");return}this.visitedChapterIds.add(e.id),(i=this.ngEditor)==null||i.selectChapter(e.id),(n=this.ngEditor)==null||n.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var i;if(this.isReady=!1,!Ct(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:i,lang:n,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,this.onError=i,this.lang=n!=null?n:"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Ip(e),this.resizeObserver=new ResizeObserver(rt(this.onResize,_s)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}show(){return R(this,null,function*(){var e;this.manifest&&(this.ngEditor||(yield this.initNgEditor()),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)})}initNgEditor(){return R(this,null,function*(){var i;if(!this.manifest)return;let e;try{e=yield Tp(this.lang,Vs,Ms)}catch(n){(i=this.onError)==null||i.call(this,"Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",l=>{var s=l,{name:n}=s,o=ee(s,["name"]);var a;n==="openPreview"&&"chapterId"in o&&((a=this.onOpenPreviewClick)==null||a.call(this,o.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0})}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Ip(r){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",r.append(e),e}var nt=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,i=!1,n=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let l=o.startTime-e;if(l<=n&&(o.endTime&&n<=o.endTime||o.endTime===null)){i=!0;break}n<l&&(t=t===-1?l:Math.min(t,l))}return!i&&t!==-1?t:null}}};var Kt=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let i=()=>{t(),this.off(e,i)};return this.listeners[e].push(i),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let i=this.listeners[e]||[];for(let n=i.length;n>0;n--)if(i[n]===t){i.splice(n,1);break}return this}emit(e,...t){let i=this.listeners[e];return i?(i.forEach(n=>{n(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var Qt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Gi(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var ua=te(ca(),1);var Xt=class r{constructor(e){this.rootElement=e;this.rootElementProps={};this.isCssVarsSupported=r.checkCssVarsSupport(e)}static checkCssVarsSupport(e){let t="--test-key",i="test";e.style.setProperty(t,i);let n=e.style.getPropertyValue(t)===i;return n&&e.style.removeProperty(t),n}getPropValue(e){var t;return this.isCssVarsSupported?`var(${e})`:(t=this.rootElementProps[e])!=null?t:""}setup(e){if(this.rootElementProps=f(f({},this.rootElementProps),e),this.isCssVarsSupported)for(let[t,i]of(0,ua.default)(e))this.rootElement.style.setProperty(t,i)}cleanup(){for(let e in this.rootElementProps)this.rootElement.style.removeProperty(e);this.rootElementProps={}}setProp(e,t){this.rootElementProps[e]=t,this.isCssVarsSupported&&this.rootElement.style.setProperty(e,t)}};import{ValueSubject as ih}from"@vkontakte/videoplayer-shared/es2015";var Yt=class{constructor(e){var t,i;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(i=e==null?void 0:e.manifestLoaders)!=null?i:[]}}exec(e,t){return R(this,null,function*(){return Yp(...this.loaders[e])(t)})}};function Yp(...r){return function(t){return R(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function ot(r,e,t){return r?A(f({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Zt(n){var o=n,{actions:r,errors:e,chapterId:t}=o,i=ee(o,["actions","errors","chapterId"]);if(t){let l=r.getManifest();if(l){let s=r.getChapter(l.chapters,t);if(s){let a=r.getMedia(l.media,s.videoId),c=r.getGraph(l.graph,s.id);return a?A(f({},i),{actions:r,errors:e,result:{chapter:s,media:a,graph:c}}):A(f({},i),{errors:ot(e,Zt.name,"Could not find media"),actions:r})}}}return A(f({},i),{errors:ot(e,Zt.name,"Could not find chapter"),actions:r})}var{NativeAbortSignal:mb,NativeAbortController:fb}=function(r){return{NativeAbortSignal:r.AbortSignal,NativeAbortController:r.AbortController}}(typeof self!="undefined"?self:global);function pa(r){let e;try{e=new Event("abort")}catch(t){typeof document!="undefined"?document.createEvent?(e=document.createEvent("Event"),e.initEvent("abort",!1,!1)):(e=document.createEventObject(),e.type="abort"):e={type:"abort",bubbles:!1,cancelable:!1}}return e.reason=r,e}function ha(r){if(r===void 0)if(typeof document=="undefined")r=new Error("This operation was aborted"),r.name="AbortError";else try{r=new DOMException("signal is aborted without reason"),Object.defineProperty(r,"name",{value:"AbortError"})}catch(e){r=new Error("This operation was aborted"),r.name="AbortError"}return r}var Jt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let n=0,o=i.length;n<o;n++)if(i[n].callback===t){i.splice(n,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let i=this.listeners[e.type].slice();for(let n=0,o=i.length;n<o;n++){let l=i[n];try{l.callback.call(this,e)}catch(s){Promise.resolve().then(()=>{throw s})}l.options&&l.options.once&&this.removeEventListener(e.type,l.callback)}return!e.defaultPrevented}},_e=class extends Jt{constructor(){super(),this.listeners||Jt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}throwIfAborted(){let{aborted:e,reason:t="Aborted"}=this;if(e)throw t}static timeout(e){let t=new ye;return setTimeout(()=>t.abort(new DOMException(`This signal is timeout in ${e}ms`,"TimeoutError")),e),t.signal}static any(e){let t=new ye;function i(){t.abort(this.reason),n()}function n(){for(let o of e)o.removeEventListener("abort",i)}for(let o of e)if(o.aborted){t.abort(o.reason);break}else o.addEventListener("abort",i);return t.signal}},ye=class{constructor(){Object.defineProperty(this,"signal",{value:new _e,writable:!0,configurable:!0})}abort(e){let t=ha(e),i=pa(t);this.signal.reason=t,this.signal.dispatchEvent(i)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(ye.prototype[Symbol.toStringTag]="AbortController",_e.prototype[Symbol.toStringTag]="AbortSignal");function er(r){return r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof r.Request=="function"&&!r.Request.prototype.hasOwnProperty("signal")||!r.AbortController}function pi(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!er({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||n)&&(o=function(c,d){let v;d&&d.signal&&(v=d.signal,delete d.signal);let b=new t(c,d);return v&&Object.defineProperty(b,"signal",{writable:!1,enumerable:!1,configurable:!0,value:v}),b},o.prototype=t.prototype);let l=e;return{fetch:(a,c)=>{let d=o&&o.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(d){let v;try{v=new DOMException("Aborted","AbortError")}catch(g){v=new Error("Aborted"),v.name="AbortError"}if(d.aborted)return Promise.reject(v);let b=new Promise((g,E)=>{d.addEventListener("abort",()=>E(v),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([b,l(a,c)])}return l(a,c)},Request:o}}var Q=typeof globalThis=="object"&&globalThis||typeof window=="object"&&window;var Zp=()=>"fetch"in Q,st=Zp()&&er({fetch:Q.fetch,Request:Q.Request,AbortController:Q.AbortController}),da=st?pi({fetch:Q.fetch,Request:Q.Request,AbortController:Q.AbortController}):void 0,hi=st?da.fetch:Q.fetch,wb=st?da.Request:Q.Request,Rb=st?ye:Q.AbortController,Ob=st?_e:Q.AbortSignal;var di=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let o=0;o<Math.max(t.length,i.length)&&!n;o++)t[o]>i[o]?n=1:t[o]<i[o]?n=-1:n=0;return n};var Jp=r=>R(null,null,function*(){try{let e={},t;if(yt(r)){t=new URL(r).href;let n=yield hi(t);if(!n.ok)return{};e=yield n.json()}else if(he(r))e=r;else return{};if(!ls(e))return{};let i=e.metadata.media;if(yt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=yield hi(n);if(!o.ok)throw new Error;e.metadata.media=yield o.json()}catch(n){return rh(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function ma(r){return R(this,null,function*(){let{manifest:e,manifestURL:t}=yield Jp(r);if(!e)throw new Error("Failed on fetch");let i=cs(e);return i.media=eh(i.media,t),delete i.metadata.media,i})}function tr(r,e){if(e)return r.find(t=>t.id===e)}function mi(r,e){var t,i;return(t=r.edit)!=null&&t.chapters?r.edit.chapters.find(n=>n.id===e):(i=r.view)!=null&&i.chapters?r.view.chapters.find(n=>n.id===e):void 0}function fi(r,e){return r.videos.find(t=>t.id===e)}function eh(r,e){return A(f({},r),{videos:r.videos.map(t=>A(f({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=th(n,e);return A(f({},i),{url:o||n})})}))})}function th(r="",e){try{return new URL(r,e).href}catch(t){return""}}function rh(r){return di(r,"3.2.0")>=0}var Le=class extends Yt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new ih(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(t){return R(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:ot},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield ma((n=i.result)!=null?n:t),this})}setInitial(){return R(this,null,function*(){return this.setNext()})}setNext(){return R(this,arguments,function*(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=yield this.exec("chapterLoaders",Zt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:mi,getChapter:tr,getMedia:fi,getByBranches:this.getByBranches.bind(this),addErrorMessage:ot},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),n.result&&(this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph),this})}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){var i;return this.getByChapterId((i=this.manifest)==null?void 0:i.metadata.initChapterId)||null}getByChapterId(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t||!this.manifest)return null;let n=tr(this.manifest.chapters,t);if(n){let o=fi(this.manifest.media,n.videoId),l=mi(this.manifest.graph,n.id);if(o)return{chapter:n,media:o,graph:l}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,o,l;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let s=tr(((l=this.manifest)==null?void 0:l.chapters)||[],t);return this.getByBranches(s==null?void 0:s.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let o=this.getByChapterId(n.chapterId);return o&&i.push(o),i},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,i;return((t=this.chapter)==null?void 0:t.id)===((i=this.manifest)==null?void 0:i.metadata.initChapterId)}isEndChapter(){return this.chapter?ne(this.chapter):!1}};var Ia=te(rr(),1);import{Player as ch}from"@vkontakte/videoplayer-core/es2015";import{Subscription as yi,TracerFactory as uh,ValueSubject as ph}from"@vkontakte/videoplayer-shared/es2015";var Ea=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&e.payload){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var Ta=te(rr(),1);function vi(){let r=new Map;function e(a){var c=a,{listId:o=Math.random().toString(),itemId:l=Math.random().toString()}=c,s=ee(c,["listId","itemId"]);let d=r.get(o),v=f({},s);return d?d[l]=v:r.set(o,{[l]:v}),f({listId:o,itemId:l},s)}function t(o){var l,s;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(l=o.statistics)==null||l.oneStat.destroy(),(s=o.statistics)==null||s.statSubscription.unsubscribe()}function i(o,l){let s=r.get(o);if(!s)throw Error("Can't remove. Not find.");if(l){let a=s[l];a&&t(a),delete s[l],Object.keys(s).length||r.delete(o)}else{for(let a of(0,Ta.default)(s))t(a);r.delete(o)}}function n(){for(let o of r)i(o[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var Fe=te(Mt(),1);function bi(r,e=[]){var o,l,s;let t={},i,n=!e.length;for(let a of r.variants)if(!i&&"cover"in a&&(i=a.cover),"url"in a)switch(a.type.toLowerCase()){case"mp4":(n||(0,Fe.default)(e,"mp4"))&&(t.MPEG=A(f({},t.MPEG),{[(o=a.standard)!=null?o:"Invariant quality"]:a.url}));break;case"mpeg":(n||(0,Fe.default)(e,"mpeg"))&&(t.MPEG=A(f({},t.MPEG),{[(l=a.standard)!=null?l:"Invariant quality"]:a.url}));break;case"hls":(n||(0,Fe.default)(e,"hls"))&&(t=A(f({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(n||(0,Fe.default)(e,"dash"))&&(t=A(f({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(s=r.title)!=null?s:""}}var at=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,Fe.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var hh=2;function gi(r){let e=vi(),t=new yi,i={},n=null,o=!1,l,s=new ph(null);r&&a(r);function a(m){n=m}function c(m,p,h){var S;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let I=((S=e.map.get(m))!=null?S:{})[p];if(I){i=f({chapterId:h,listId:m,itemId:p},I);let C=i.player;i.subscription.add(C.info.currentQuality$.subscribe(x=>{let j=C.info.position$.getValue(),O=C.info.isAutoQualityEnabled$.getValue();if(!(!x||!j||O))for(let _ of e.map)(0,Ia.default)(_[1]).forEach(({player:M})=>{at(M,x)})})).add(C.events.started$.subscribe(()=>{d(p)})),I.container.remove(),n.setPlayer(I.player),o||(n.init(),o=!0),s.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}function d(m){return R(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(me(i)||m!==i.itemId)return;let p=n.getChapterBranches(),h=new Set;for(let y of p)h.has(y.media.id)||(yield b({media:y.media,chapterId:y.chapter.id,setAsActive:!1,title:y.chapter.label}),h.add(y.media.id))})}function v(h){return R(this,arguments,function*({chapter:{id:m},manifestVideo:p}){if(me(i)||!n)return;let y=i.player.info.muted$.getValue(),I=i.player.info.currentQuality$.getValue(),S=i.player.info.isAutoQualityEnabled$.getValue(),C=i.player.info.volume$.getValue(),x=i.player.info.currentPlaybackRate$.getValue(),j=!S,O=!1;for(let _ of e.map)if(_[0]===p.id&&!n.state.isReplay$.getValue()){let M=Object.keys(_[1]);for(let $ of M)$===i.itemId?(M.length<hh||(O=!0),e.removePlayer(_[0],$)):(O=!0,c(_[0],$,m),j?at(i.player,I):i.player.setAutoQuality(!0),i.player.setVolume(C),i.player.setMuted(y),i.player.setPlaybackRate(x))}else e.removePlayer(_[0]);O||(yield b({media:p,chapterId:m,setAsActive:!0,playbackRate:x}),j?at(i.player,I):i.player.setAutoQuality(!0),i.player.setVolume(C),i.player.setMuted(y))})}function b(j){return R(this,arguments,function*({media:m,chapterId:p,prefetch:h=!0,setAsActive:y=!0,autoplay:I=!1,preferredExt:S,title:C,playbackRate:x}){var Vi,Mi,_i,Li,Fi;let O=Math.random().toString(),_=document.createElement("div");l.append(_);let M;if((Vi=n==null?void 0:n.options)!=null&&Vi.vkVideoLoader){let mt=Ea(m);mt.length&&(M=yield n.options.vkVideoLoader(...mt))}let $=((Mi=n==null?void 0:n.options)==null?void 0:Mi.coreConfig)||void 0,Te=A(f({},$),{configName:[...(_i=$==null?void 0:$.configName)!=null?_i:[],"interactive"]}),se=A(f({container:_},((Li=M==null?void 0:M.videos)==null?void 0:Li[0])||{sources:bi(m,S).sources}),{title:C,failoverHosts:(M==null?void 0:M.failoverHosts)||[]}),J=new ch(Te,uh.createRootTracer());J.initVideo(se);let ki=null;if(M!=null&&M.videos&&(n!=null&&n.options.createOneStat)){let mt=M.videos[0],ur=n.options.createOneStat(mt),Ni=new yi;ur&&(Ni.add(ur.attachTo(J)),ki={oneStat:ur,statSubscription:Ni})}let Pi=new yi,Ol=(Fi=i==null?void 0:i.player)==null?void 0:Fi.info.isAutoQualityEnabled$.getValue();Pi.add(J.events.canplay$.subscribe(function(){Ol||at(J,i.player.info.currentQuality$.getValue()),x&&J.setPlaybackRate(x)}));let Ie=e.createPlayer({listId:m.id,itemId:O,player:J,container:_,sources:bi(m,S).sources,config:se,subscription:Pi,statistics:ki});return y&&c(m.id,Ie.itemId,p),I&&Ie.player.play(),h&&!I&&Ie.player.prepare(),{player:Ie.player,config:Ie.config,statistics:Ie.statistics}})}function g(){E(),n=null,l.remove()}function E(){t.unsubscribe(),e.removeAll(),i={},o=!1}function T(){return R(this,null,function*(){if(!n)throw Error("need to set interactive controller");E(),l=document.createElement("div");let{media:m,chapter:p}=n.getCurrentChapter();m&&p?(t.add(n.events.chapterChanged$.subscribe(v)),yield b({media:m,chapterId:p.id,title:p.label})):console.error("not found")})}return A(f({},e),{init:T,setInteractiveController:a,createPlayer:b,removeAll:g,getActivePlayer:function(){return i},activePlayerChanged:s})}var k={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},lt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},F={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};import{Subscription as dh}from"@vkontakte/videoplayer-shared/es2015";function Ci(r){return function(...t){return r(...t.reverse())}}function ct(r,...e){return(...t)=>he(e[0])&&he(t[0])?r(f(f({},e[0]),t[0])):r(...e,...t)}var ir=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:l,globalEventEmitter:s,getContainerEventState:a,permanentTextControls:c,interactiveTimeOpenUri:d,disabledControls$:v,onRemove:b,onError:g,disableTextControlContainerVisibilityEvents:E=!1,features:T}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(be(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,i,n,o,l,s;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:a}=this.getContainerEventState();if((i=(t=this.container).show)==null||i.call(t),this.interactiveTimeOpenUri&&a||this.disableTextControlContainerVisibilityEvents)return;this.emitContainerVisibilityEvent(!0,!1)}else{let a={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(v,b)=>{let{isExpectTime:g,hasOtherExpect:E,hasOpenURIEvent:T,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:p,hasShouldOpenNowEvent:h}=this.getContainerEventState(),y=this.interactiveTimeOpenUri&&!m,I=this.interactiveTimeOpenUri&&m;if((!this.interactiveTimeOpenUri||y)&&(this.isSelectedControlEvent=!0),v!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||y)){if(this.interactiveTimeOpenUri){let S=!E&&!p&&m;S&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:S})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&T&&this.gameState!==5){if(I){let C=((x,j,O,_)=>!x&&!j&&O||x&&!j&&O&&!_||x&&!j&&O&&_)(g,E,p,this.isSelectedContainerEvent);this.fakeRemoveView(C)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!g||!E||!h)&&(this.selectBranches.stopExpect(),b())}},isEOV:()=>this.gameState===4},c=ct(this.selectBranches.onControlEvent,a),d=((o=(n=this.player)==null?void 0:n.info.duration$.getValue())!=null?o:1/0)*1e3;this.container.createView({eventCallback:c,videoDurationMs:d}),this.disableTextControlContainerVisibilityEvents||this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((s=(l=this.container).disable)==null||s.call(l))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var a,c,d;let e=this.player.experimental.element$.getValue(),t=e instanceof HTMLVideoElement;if(this.features.enableAvPlayerSupport&&(t||(t=e instanceof HTMLObjectElement&&(e==null?void 0:e.getAttribute("type"))==="application/avplayer")),!(t?e==null?void 0:e.readyState:void 0)||this.isRemovedOrDestroyed()&&!this.isPermanentText)return;let n=this.player.getExactTime();if(ps(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Zr(n,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let v=this.gameState;this.gameState=3,v===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:v}=this.getContainerEventState(),b=this.selectBranches.state.isExpect,g=this.interactiveTimeOpenUri&&v;if(g&&!b){let E=this.container.getElement();E&&(E.style.visibility!=="hidden"&&((c=(a=this.container).hide)==null||c.call(a)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!g&&this.removeView()}let o=Zr(n,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(d=this.container.container.endTime)!=null?d:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:n,isInteractiveTime:o};this.container.onProgress(n*1e3,o),this.globalEventEmitter.emit(k.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new dh,this.player=e,this.interactiveEvents=o,this.getContainerEventState=a;let m=Me(t.container.controls);this.isPermanentText=c&&m,this.disableTextControlContainerVisibilityEvents=E&&m,this.interactiveTimeOpenUri=d,this.disabledControls$=v,this.onRemove=b,this.globalEventEmitter=s,this.gameState=0,this.globalEvents=l,this.onError=g,this.features=T,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:F.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:F.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{var t,i,n,o;e?(i=(t=this.container).disable)==null||i.call(t):(o=(n=this.container).enable)==null||o.call(n)})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){var i,n;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(i=this.container.container.endTime)!=null?i:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((n=this.container.container.endTime)!=null?n:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),i=this.interactiveTimeOpenUri?e||t:be(this.container.container.events)||e;(this.isSelectedControlEvent||!i)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(e=this.features.controlsHideAnimation){var t;if(e){if(this.isRemovedOrDestroyed())return;this.container.removeNonInteractedControls(!0),this.container.removeView(!0,!0)}else this.container.removeView();this.globalEventEmitter.emit(k.interactives,{subjectId:this.container.container.id,subjectName:"container",type:F.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,(t=this.onRemove)==null||t.call(this)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}isInteracted(){return this.container.isInteracted()}isRemovedOrDestroyed(e=!0){let t=e?this.container.willRemoved:!1;return this.gameState===5||t||this.gameState===6}destroy(e=!1){var t;this.reset(),this.removeView(e),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(t=this.container.container.endTime)!=null?t:1/0,id:this.container.container.id})}};var Aa=(r=[])=>r.reduce((e,t,i)=>{var o,l,s;let n=((o=t==null?void 0:t.controls)!=null?o:[]).filter(a=>!_t(a));if(Nt(n)){let a=[(l=t.startTime)!=null?l:0,(s=t.endTime)!=null?s:1/0],c={id:t.id,isRemoved:!1};if(!i)e.push({subjects:[c],range:a});else{let d=[],v=-1/0,b=1/0,g=[],E=[];for(let T=0;T<e.length;T++){let m=e[T];if(E.push(...m.subjects),m.range[0]<b&&(b=m.range[0]),m.range[1]>v&&(v=m.range[1]),a[0]>=m.range[0]&&a[1]<=m.range[1])return e[T].subjects.push(c),e;a[0]<m.range[0]&&a[1]>m.range[0]&&(d.push(T),g=g.concat(m.subjects)),a[0]>=m.range[0]&&a[0]<=m.range[1]&&(d.push(T),g=g.concat(m.subjects),a[0]=m.range[0]),a[1]>=m.range[0]&&a[1]<=m.range[1]&&(d.push(T),g=g.concat(m.subjects),a[1]=m.range[1])}if(E.push(c),a[0]<=b&&a[1]>=v)return[{subjects:E,range:a}];d.length&&d.reverse().forEach(T=>{e.splice(T,1)}),e.push({subjects:g.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var sl=te(Mt(),1),xi=te(rr(),1),al=te(nl(),1);function ol(){let r={};function e(){for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]}function t(s){let a={};for(let c in r)+c<=s&&(a[c]=r[c]);return a}function i(s){let a={};for(let c in r)+c>=s&&(a[c]=r[c]);return a}function n({timestamp:s,priority:a,initiator:c}){var d;if(vr(s)){let v=(d=r[s])!=null?d:null;if(v&&a&&je(a,!0)){let b={},g=v[a];if(g&&(b=f(f({},b),g)),b=me(b)?null:b,b&&je(c,!0)){let E=b[c];return E!=null?E:null}return b}return v}return null}function o({timestamp:s,priority:a,initiator:c}){if(vr(s))if(r[s]){if(a&&je(a,!0))if(r[s][a]){if(c&&je(c,!0))if(r[s][a][c]){if(delete r[s][a][c],!me(r[s][a]))return!0}else return!1;if(delete r[s][a],!me(r[s]))return!0}else return!1;return delete r[s]}else return!1;return!1}function l(v){var b=v,{timestamp:s,priority:a,initiator:c}=b,d=ee(b,["timestamp","priority","initiator"]);var g,E,T;(E=(g=r[s])==null?void 0:g[a])!=null&&E[c]?r[s][a][c].push(f({},d)):(T=r[s])!=null&&T[a]?r[s][a]=A(f({},r[s][a]),{[c]:[f({},d)]}):r[s]?r[s]=A(f({},r[s]),{[a]:{[c]:[f({},d)]}}):r[s]={[a]:{[c]:[f({},d)]}}}return{map:r,remove:o,add:l,removeAll:e,get:n,getLte:t,getGte:i}}var td=[P.expect,P.setNextBranch],rd=1/0;function ll(r,e){let t=r,i,n=id(e),o=ol(),l,s=()=>{g(),p()},a=h=>{o.add.call(void 0,h),E()},c=(h=[])=>{for(let y of h)if(y.action(),(0,sl.default)(td,y.actionType))break},d=(h=1/0)=>{var C,x,j;let y=or((C=o.get({timestamp:h,priority:"control"}))!=null?C:{}),I=or((x=o.get({timestamp:h,priority:"container"}))!=null?x:{}),S=or((j=o.get({timestamp:h,priority:"chapter"}))!=null?j:{});return[...y,...I,...S]},v=h=>{n.isReady(h)&&c(d(h))},b=()=>{var h;c([...or((h=o.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},g=()=>{i&&(l==null||l.unsubscribe(),i=void 0)},E=()=>{i||(i=()=>setTimeout(()=>{v(1/0)}),l=t.events.ended$.subscribe(i))},T=h=>{g(),t=h},m=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),o.remove(h)},p=()=>{n.release(),o.removeAll()};return{setPlayer:T,add:a,remove:m,exec:v,execEndOfVideo:b,listen:E,unlisten:g,release:s,containersEventsCallState:n,getPreparedToExecActions:d}}function id(r){let e=new Map;return{setCalled:({timestamp:s,id:a})=>{let c=e.get(s);c&&c[a]!==void 0&&(c[a]=!0)},setData:(s=[])=>{var a;for(let c of s){let d=(a=c.endTime)!=null?a:rd,v=e.get(d);e.set(d,A(f({},v),{[c.id]:!1}))}},resetCalled:s=>{let a=e.get(s);if(a)for(let c in a)a[c]=!1},isReady:s=>{let a=e.get(s);if(!a)return!0;let c=(0,xi.default)(a);return r?c.some(v=>v):!c.some(v=>!v)},release:()=>e.clear()}}function or(r){return(0,al.default)((0,xi.default)(r)).sort(e=>e.actionType===P.expect?-1:1)}var cl={videoContentHeight:0,videoContentWidth:0},ul=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return cl;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return cl;let o=e/t,l=i/n,s,a;return l>o?(a=n,s=n*o):l<o?(a=i/o,s=i):(a=n,s=i),{videoContentWidth:a,videoContentHeight:s}};var nd=250;function pl(r){let e,t=new ResizeObserver(s=>{o(s),e=o.bind(null,s)});function i(s){let{parentElement:a,player:c,cssVarsManager:d}=r();if(!a||!c)return;let{videoContentWidth:v,videoContentHeight:b}=ul(c);d.setup({"--interactive-content-width":`${v}px`,"--interactive-content-height":`${b}px`,"--interactive-width":`${s[0].contentRect.width}px`,"--interactive-height":`${s[0].contentRect.height}px`})}function n(){let{parentElement:s}=r();s.removeAttribute("style")}let o=rt(s=>{let{fns:a=[]}=r();i(s);for(let c of a)c()},nd);function l(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:l}}var od=r=>Math.floor(Math.random()*r),dl=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let o=r[e],l=(n=o.weight)!=null?n:1;l<t&&(t=l,i=o)}return i},ml=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let o=r[e],l=(n=o.weight)!=null?n:0;l>t&&(t=l,i=o)}return i};var fl=r=>{let e=r.length,t=od(e);return r[t]},hl=1,vl=r=>{var i,n;let e=0;for(let o=0;o<r.length;++o)e+=(i=r[o].weight)!=null?i:hl;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(n=r[o].weight)!=null?n:hl,e>=t)return r[o];return r[r.length-1]};var bl={shouldOpenNow:!0,isDetachContainer:!0},yl="after-expect",Ai=(r,e=!1)=>A(f({},r),{args:e?f(f({},r.args),bl):f(f({},bl),r.args)}),gl=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:p,controlType:h,controlId:y,containerId:I,branches:S=[],onEvent:C,isEOV:x=()=>!1,isDisabled:j=()=>!1})=>{let O=Ai(p,x()),_={timestamp:1/0,priority:"control",initiator:y,actionType:O.type},M=j(),$=r.emit.bind(r,k.interactives,{subjectId:y,subjectType:h,subjectName:"control",type:M?F.actionChoiceCanceled:F.actionChoice,actionType:p.type,payload:f({invokeImmediately:O.args.shouldOpenNow,containerId:I},O.args)}),Te=()=>{e.interactiveActionChoice$.next({subjectId:y,subjectType:h,subjectName:"control",type:M?"action-choice-canceled":"action-choice",actionType:p.type,payload:f({invokeImmediately:O.args.shouldOpenNow,containerId:I},O.args)})};if(M){$(),Te();return}switch(O.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let se=S.find(J=>J.id===O.args.branchId);if(!se)return;C(O.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),$(),Te(),O.args.shouldOpenNow?T({subjectId:y,subjectName:"control",subjectType:h,action:O,payload:{chapterId:se.chapterId,autoSelect:!1}}):i.add(A(f({},_),{action:T.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:O,payload:{chapterId:se.chapterId,autoSelect:!1}})}));return}case P.continuePlayback.trim().toLowerCase():{C(O.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),$(),Te(),O.args.shouldOpenNow?E({subjectId:y,subjectName:"control",subjectType:h,action:p}):i.add(A(f({},_),{action:E.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:p})}));return}case P.openURI.trim().toLowerCase():{C(O.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),$(),Te(),O.args.shouldOpenNow?m({subjectId:y,subjectName:"control",subjectType:h,action:O,payload:{URI:p.args.uri}}):i.add(A(f({},_),{action:m.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:O,payload:{URI:p.args.uri}})}));return}default:{let se="Unexpected control event",J=new B(1,1,{message:se});d(J,se);return}}},s=({action:p,container:{id:h,endTime:y},branches:I=[],isEOV:S=!1,autoSelected:C=!1})=>{let x=Ai(p,S),j={timestamp:!x.args.shouldOpenNow||S?1/0:y!=null?y:1/0,priority:"container",initiator:h,actionType:x.type},O=r.emit.bind(r,k.interactives,{subjectId:h,subjectName:"container",type:F.actionChoice,actionType:x.type,payload:f({invokeImmediately:x.args.shouldOpenNow},x.args)}),_=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:x.type,payload:f({invokeImmediately:x.args.shouldOpenNow},x.args)})};switch(x.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let M=I.find($=>$.id===x.args.branchId);if(!M)return;O(),_(),i.add(A(f({},j),{action:T.bind(null,{subjectId:h,subjectName:"container",action:x,payload:{chapterId:M.chapterId,autoSelect:C}})}));return}case P.setMaxWeightBranch.trim().toLowerCase():return;case P.setMinWeightBranch.trim().toLowerCase():return;case P.setRandomBranch.trim().toLowerCase():return;case P.setWeightlessRandomBranch.trim().toLowerCase():return;case P.continuePlayback.trim().toLowerCase():{O(),_(),i.add(A(f({},j),{action:E.bind(null,{subjectId:h,subjectName:"container",action:x})}));return}case P.openURI.trim().toLowerCase():{O(),_(),i.add(A(f({},j),{action:m.bind(null,{subjectId:h,subjectName:"container",action:x,payload:{URI:p.args.uri}})}));return}default:{let M="Unexpected container event",$=new B(1,1,{message:M});d($,M);return}}};function a({container:p,branches:h,isEOV:y=!1}){var S,C;let I=Jr(p.events);if(I){let x=Ai(I.action,y);r.emit(k.interactives,{subjectId:p.id,subjectName:"container",type:F.actionChoice,actionType:x.type,payload:f({invokeImmediately:x.args.shouldOpenNow},x.args)}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"container",type:"action-choice",actionType:x.type,payload:f({invokeImmediately:x.args.shouldOpenNow},x.args)}),i.add({timestamp:y?1/0:(S=p.endTime)!=null?S:1/0,priority:"container",initiator:p.id,actionType:P.expect,action:b.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let x of(C=p.events)!=null?C:[])s({action:x.action,container:p,branches:h,isEOV:y})}let c=({chapterId:p,action:h,branches:y=[]})=>{let I=r.emit.bind(r,k.interactives,{subjectId:p,subjectName:"chapter",type:F.actionChoice,actionType:h.type,payload:h.args}),S=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let C=y.find(x=>x.id===h.args.branchId);return C!=null&&C.chapterId?(I(),S(),T.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setWeightlessRandomBranch.trim().toLowerCase():{let C=fl(y);return C!=null&&C.chapterId?(I(),S(),T.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setRandomBranch.trim().toLowerCase():{let C=vl(y);return C!=null&&C.chapterId?(I(),S(),T.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setMaxWeightBranch.trim().toLowerCase():{let C=ml(y);return C!=null&&C.chapterId?(I(),S(),T.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setMinWeightBranch.trim().toLowerCase():{let C=dl(y);return C!=null&&C.chapterId?(I(),S(),T.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.continuePlayback.trim().toLowerCase():return I(),S(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h});case P.openURI.trim().toLowerCase():return I(),S(),m.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let C="Unexpected chapter event",x=new B(1,1,{message:C});d(x,C);return}}};function d(p,h){console.error(h),e.error$.next(p),r.emit(k.errors,p)}function v(p){var y;let h=Jr(p.events);if(h){if(ne(p))return;r.emit(k.interactives,{subjectId:p.id,subjectName:"chapter",type:F.actionChoice,actionType:h.action.type,payload:h.action.args}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"chapter",type:"action-choice",actionType:h.action.type,payload:h.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:P.expect,action:b.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(y=p.events)==null||y.forEach(I=>{let S=c({chapterId:p.id,action:I.action,branches:p.branches});S&&i.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:I.action.type,action:S})})}let b=({subjectId:p,subjectName:h})=>{t.pause(),r.emit(k.interactives,{subjectId:p,subjectName:h,type:F.actionExecution,actionType:P.expect}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:P.expect})},g=({subjectId:p,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(k.interactives,{subjectId:p,subjectName:h,type:F.actionExecution,actionType:yl}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:yl})},E=({subjectId:p,subjectName:h,subjectType:y,action:I})=>{r.emit(k.interactives,{subjectId:p,subjectName:h,subjectType:y,type:F.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:y,type:"action-execution",actionType:I.type})},T=({subjectId:p,subjectName:h,subjectType:y,action:I,payload:S})=>{S.behaviour="change-chapter",r.emit(k.interactives,{subjectId:p,subjectName:h,subjectType:y,type:F.actionExecution,actionType:I.type,payload:S}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:y,type:"action-execution",actionType:I.type,payload:S})},m=({subjectId:p,subjectName:h,subjectType:y,action:I,payload:S})=>{if(!S.URI)return;let C=window.open(S.URI,"_blank","noopener,noreferrer");C&&(C.opener=null),r.emit(k.interactives,{subjectId:p,subjectName:h,subjectType:y,type:F.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:y,type:"action-execution",actionType:I.type})};return{onControlEvent:l,onContainerEvent:s,onChapterEvent:c,onExpectEvent:b,expectEventHandler:g,setManifestChapterEvents:v,setManifestContainerEvents:a,stopExpect:o,state:n}};var Ri=te(ai(),1);import{Subscription as ud,Subject as wi,ValueSubject as pt}from"@vkontakte/videoplayer-shared/es2015";var Si=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(l=>l.id===i);if(!n)return null;let o=e.media.videos.find(l=>n.videoId===l.id);if(!o)return null;t[i]=Cl(o)}return t[i]}).filter(Boolean)},ad=r=>{for(let e of r.variants)if(ld(e)&&e.payload)return e.payload.id},ld=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),Cl=r=>{let e=ad(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},cd=(r,e)=>{for(let t of r.media.videos)if(e===Cl(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},El=(r,e)=>r.reduce((t,i)=>{let n=cd(e,i);return n?[...t,n]:t},[]);var le,ge,Ce,X,sr,ce,ue,oe,Ee,Ne,$e,ht=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new pt([]),hasPrevChapter$:new pt(!1),prevChapter$:new pt(null),isInitialChapter$:new pt(!1),isGoBackLimited$:new pt(!1)};W(this,le,null);W(this,ge);W(this,Ce,!1);W(this,X,null);W(this,sr,null);this.events={inited$:new wi,destroyed$:new wi,error$:new wi};W(this,ce,null);W(this,ue,null);W(this,oe,null);W(this,Ee,new ud);W(this,Ne,!1);W(this,$e,0);var l;N(this,ce,t),N(this,oe,e),N(this,ue,i),N(this,le,n),N(this,ge,o),this.state.history$&&w(this,Ee)&&((l=w(this,Ee))==null||l.add(this.state.history$.subscribe(s=>{var a,c;this.state.prevChapter$.next((0,Ri.default)(s,-2)||null),this.state.hasPrevChapter$.next(s.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(a=w(this,X))==null?void 0:a.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(w(this,$e)===w(this,ge).maxLength-1)})))}setManifest(e){return R(this,null,function*(){if(!w(this,ue)||!w(this,oe))return;N(this,X,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield w(this,ue).setChapter({chapterId:t,pushToHistory:!1}),w(this,Ce)||(N(this,Ce,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return w(this,Ce)}updateHistory(e,t=!0){return R(this,null,function*(){var s;if(!w(this,X))return;w(this,Ne)?(N(this,Ne,!1),Di(this,$e)._++):N(this,$e,0);let i=w(this,X),n=e.length-w(this,ge).maxLength,o=n>0?e.slice(n):e,l=Si(o,i);if(N(this,sr,l),this.state.history$.next(o),!(!t||!w(this,le)||!w(this,ce)))try{yield w(this,le).save(w(this,ce),l)}catch(a){let c=new B(1,5,"Unable to save interactive history");this.events.error$.next(c),(s=w(this,oe))==null||s.emit(k.errors,c)}})}goBack(){return R(this,null,function*(){var i;if(!this.state||!w(this,ue)){let n=new B(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=w(this,oe))==null?void 0:i.emit(k.errors,n)}N(this,Ne,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield w(this,ue).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return R(this,null,function*(){var n;if(!w(this,X)||!w(this,ce))return;let e=w(this,X),t=[this.getInitialVideoId()];if(w(this,le))try{let o=yield w(this,le).get(w(this,ce));o.length&&(t=o)}catch(o){let l=new B(1,5,"Error while trying to fetch data");this.events.error$.next(l),(n=w(this,oe))==null||n.emit(k.errors,l)}let i=El(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,Ri.default)(e,-1)||w(this,ge).initChapterId||((t=w(this,X))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(w(this,X)){let e=this.getInitialChapterId();return Si([e],w(this,X)).pop()}return null}destroy(){var e,t;N(this,ce,null),N(this,le,null),N(this,ue,null),(e=w(this,Ee))==null||e.unsubscribe(),N(this,Ee,null),N(this,Ce,!1),(t=w(this,oe))==null||t.emit(k.historyDestroyed),this.events.destroyed$.next(),N(this,oe,null)}};le=new WeakMap,ge=new WeakMap,Ce=new WeakMap,X=new WeakMap,sr=new WeakMap,ce=new WeakMap,ue=new WeakMap,oe=new WeakMap,Ee=new WeakMap,Ne=new WeakMap,$e=new WeakMap;var ar=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var n;let e=(n=this.rootElement.getContext("2d"))==null?void 0:n.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,i=t.length;for(let o=3;o<i;o+=40)if(t[o]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(e,t=!1){return R(this,null,function*(){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i})}save(){return R(this,null,function*(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,yield t.decode(),t})}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var lr=class{constructor({parentElement:e,endOffsetMs:t=250,onError:i}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,i=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(i)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
7
7
|
position: absolute;
|
|
8
8
|
top: 0;
|
|
9
9
|
left: 0;
|