@vkontakte/videoplayer-interactive 1.0.31-dev.a65d13ac.0 → 1.0.31-dev.a8108f50.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.esm.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.31-dev.a65d13ac.0
3
- * Wed, 12 Feb 2025 13:53:24 GMT
2
+ * @vkontakte/videoplayer-interactive v1.0.31-dev.a8108f50.0
3
+ * Mon, 17 Feb 2025 12:16:24 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-31/doc/
5
5
  */
6
- var Mo=Object.create;var Wt=Object.defineProperty,jo=Object.defineProperties,Lo=Object.getOwnPropertyDescriptor,$o=Object.getOwnPropertyDescriptors,No=Object.getOwnPropertyNames,rt=Object.getOwnPropertySymbols,_o=Object.getPrototypeOf,Kt=Object.prototype.hasOwnProperty,hi=Object.prototype.propertyIsEnumerable;var di=r=>{throw TypeError(r)};var pi=(r,e,t)=>e in r?Wt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e)=>{for(var t in e||(e={}))Kt.call(e,t)&&pi(r,t,e[t]);if(rt)for(var t of rt(e))hi.call(e,t)&&pi(r,t,e[t]);return r},E=(r,e)=>jo(r,$o(e));var X=(r,e)=>{var t={};for(var i in r)Kt.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&rt)for(var i of rt(r))e.indexOf(i)<0&&hi.call(r,i)&&(t[i]=r[i]);return t};var u=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Fo=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of No(e))!Kt.call(r,n)&&n!==t&&Wt(r,n,{get:()=>e[n],enumerable:!(i=Lo(e,n))||i.enumerable});return r};var te=(r,e,t)=>(t=r!=null?Mo(_o(r)):{},Fo(e||!r||!r.__esModule?Wt(t,"default",{value:r,enumerable:!0}):t,r));var fi=(r,e,t)=>e.has(r)||di("Cannot "+t);var T=(r,e,t)=>(fi(r,e,"read from private field"),t?t.call(r):e.get(r)),G=(r,e,t)=>e.has(r)?di("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),$=(r,e,t,i)=>(fi(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var mi=(r,e,t,i)=>({set _(n){$(r,e,n,t)},get _(){return T(r,e,i)}});var A=(r,e,t)=>new Promise((i,n)=>{var a=s=>{try{l(t.next(s))}catch(c){n(c)}},o=s=>{try{l(t.throw(s))}catch(c){n(c)}},l=s=>s.done?i(s.value):Promise.resolve(s.value).then(a,o);l((t=t.apply(r,e)).next())});var Z=u((rr,Ii)=>{"use strict";var Oe=function(r){return r&&r.Math===Math&&r};Ii.exports=Oe(typeof globalThis=="object"&&globalThis)||Oe(typeof window=="object"&&window)||Oe(typeof self=="object"&&self)||Oe(typeof global=="object"&&global)||Oe(typeof rr=="object"&&rr)||function(){return this}()||Function("return this")()});var U=u((Qh,xi)=>{"use strict";xi.exports=function(r){try{return!!r()}catch(e){return!0}}});var ke=u((Yh,Ti)=>{"use strict";var Bo=U();Ti.exports=!Bo(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Pi=u((Xh,Ri)=>{"use strict";var Do=ke(),Ai=Function.prototype,Si=Ai.apply,wi=Ai.call;Ri.exports=typeof Reflect=="object"&&Reflect.apply||(Do?wi.bind(Si):function(){return wi.apply(Si,arguments)})});var K=u((Zh,Vi)=>{"use strict";var Oi=ke(),ki=Function.prototype,ir=ki.call,Ho=Oi&&ki.bind.bind(ir,ir);Vi.exports=Oi?Ho:function(r){return function(){return ir.apply(r,arguments)}}});var Ve=u((Jh,ji)=>{"use strict";var Mi=K(),Go=Mi({}.toString),Uo=Mi("".slice);ji.exports=function(r){return Uo(Go(r),8,-1)}});var nr=u((ed,Li)=>{"use strict";var zo=Ve(),Wo=K();Li.exports=function(r){if(zo(r)==="Function")return Wo(r)}});var z=u((td,$i)=>{"use strict";var ar=typeof document=="object"&&document.all;$i.exports=typeof ar=="undefined"&&ar!==void 0?function(r){return typeof r=="function"||r===ar}:function(r){return typeof r=="function"}});var le=u((rd,Ni)=>{"use strict";var Ko=U();Ni.exports=!Ko(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ft=u((id,_i)=>{"use strict";var Qo=ke(),dt=Function.prototype.call;_i.exports=Qo?dt.bind(dt):function(){return dt.apply(dt,arguments)}});var sr=u(Bi=>{"use strict";var Fi={}.propertyIsEnumerable,qi=Object.getOwnPropertyDescriptor,Yo=qi&&!Fi.call({1:2},1);Bi.f=Yo?function(e){var t=qi(this,e);return!!t&&t.enumerable}:Fi});var or=u((ad,Di)=>{"use strict";Di.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Gi=u((sd,Hi)=>{"use strict";var Xo=K(),Zo=U(),Jo=Ve(),lr=Object,el=Xo("".split);Hi.exports=Zo(function(){return!lr("z").propertyIsEnumerable(0)})?function(r){return Jo(r)==="String"?el(r,""):lr(r)}:lr});var cr=u((od,Ui)=>{"use strict";Ui.exports=function(r){return r==null}});var ur=u((ld,zi)=>{"use strict";var tl=cr(),rl=TypeError;zi.exports=function(r){if(tl(r))throw new rl("Can't call method on "+r);return r}});var Me=u((cd,Wi)=>{"use strict";var il=Gi(),nl=ur();Wi.exports=function(r){return il(nl(r))}});var ge=u((ud,Ki)=>{"use strict";var al=z();Ki.exports=function(r){return typeof r=="object"?r!==null:al(r)}});var mt=u((pd,Qi)=>{"use strict";Qi.exports={}});var yt=u((hd,Xi)=>{"use strict";var pr=mt(),hr=Z(),sl=z(),Yi=function(r){return sl(r)?r:void 0};Xi.exports=function(r,e){return arguments.length<2?Yi(pr[r])||Yi(hr[r]):pr[r]&&pr[r][e]||hr[r]&&hr[r][e]}});var Ji=u((dd,Zi)=>{"use strict";var ol=K();Zi.exports=ol({}.isPrototypeOf)});var nn=u((fd,rn)=>{"use strict";var ll=Z(),en=ll.navigator,tn=en&&en.userAgent;rn.exports=tn?String(tn):""});var pn=u((md,un)=>{"use strict";var cn=Z(),dr=nn(),an=cn.process,sn=cn.Deno,on=an&&an.versions||sn&&sn.version,ln=on&&on.v8,Q,vt;ln&&(Q=ln.split("."),vt=Q[0]>0&&Q[0]<4?1:+(Q[0]+Q[1]));!vt&&dr&&(Q=dr.match(/Edge\/(\d+)/),(!Q||Q[1]>=74)&&(Q=dr.match(/Chrome\/(\d+)/),Q&&(vt=+Q[1])));un.exports=vt});var fr=u((yd,dn)=>{"use strict";var hn=pn(),cl=U(),ul=Z(),pl=ul.String;dn.exports=!!Object.getOwnPropertySymbols&&!cl(function(){var r=Symbol("symbol detection");return!pl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&hn&&hn<41})});var mr=u((vd,fn)=>{"use strict";var hl=fr();fn.exports=hl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var yr=u((bd,mn)=>{"use strict";var dl=yt(),fl=z(),ml=Ji(),yl=mr(),vl=Object;mn.exports=yl?function(r){return typeof r=="symbol"}:function(r){var e=dl("Symbol");return fl(e)&&ml(e.prototype,vl(r))}});var vn=u((gd,yn)=>{"use strict";var bl=String;yn.exports=function(r){try{return bl(r)}catch(e){return"Object"}}});var vr=u((Cd,bn)=>{"use strict";var gl=z(),Cl=vn(),El=TypeError;bn.exports=function(r){if(gl(r))return r;throw new El(Cl(r)+" is not a function")}});var Cn=u((Ed,gn)=>{"use strict";var Il=vr(),xl=cr();gn.exports=function(r,e){var t=r[e];return xl(t)?void 0:Il(t)}});var In=u((Id,En)=>{"use strict";var br=ft(),gr=z(),Cr=ge(),Tl=TypeError;En.exports=function(r,e){var t,i;if(e==="string"&&gr(t=r.toString)&&!Cr(i=br(t,r))||gr(t=r.valueOf)&&!Cr(i=br(t,r))||e!=="string"&&gr(t=r.toString)&&!Cr(i=br(t,r)))return i;throw new Tl("Can't convert object to primitive value")}});var Tn=u((xd,xn)=>{"use strict";xn.exports=!0});var An=u((Td,wn)=>{"use strict";var Sn=Z(),Sl=Object.defineProperty;wn.exports=function(r,e){try{Sl(Sn,r,{value:e,configurable:!0,writable:!0})}catch(t){Sn[r]=e}return e}});var bt=u((Sd,On)=>{"use strict";var wl=Tn(),Al=Z(),Rl=An(),Rn="__core-js_shared__",Pn=On.exports=Al[Rn]||Rl(Rn,{});(Pn.versions||(Pn.versions=[])).push({version:"3.38.0",mode:wl?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Er=u((wd,Vn)=>{"use strict";var kn=bt();Vn.exports=function(r,e){return kn[r]||(kn[r]=e||{})}});var je=u((Ad,Mn)=>{"use strict";var Pl=ur(),Ol=Object;Mn.exports=function(r){return Ol(Pl(r))}});var Ce=u((Rd,jn)=>{"use strict";var kl=K(),Vl=je(),Ml=kl({}.hasOwnProperty);jn.exports=Object.hasOwn||function(e,t){return Ml(Vl(e),t)}});var Ir=u((Pd,Ln)=>{"use strict";var jl=K(),Ll=0,$l=Math.random(),Nl=jl(1 .toString);Ln.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Nl(++Ll+$l,36)}});var Le=u((Od,Nn)=>{"use strict";var _l=Z(),Fl=Er(),$n=Ce(),ql=Ir(),Bl=fr(),Dl=mr(),Ee=_l.Symbol,xr=Fl("wks"),Hl=Dl?Ee.for||Ee:Ee&&Ee.withoutSetter||ql;Nn.exports=function(r){return $n(xr,r)||(xr[r]=Bl&&$n(Ee,r)?Ee[r]:Hl("Symbol."+r)),xr[r]}});var Bn=u((kd,qn)=>{"use strict";var Gl=ft(),_n=ge(),Fn=yr(),Ul=Cn(),zl=In(),Wl=Le(),Kl=TypeError,Ql=Wl("toPrimitive");qn.exports=function(r,e){if(!_n(r)||Fn(r))return r;var t=Ul(r,Ql),i;if(t){if(e===void 0&&(e="default"),i=Gl(t,r,e),!_n(i)||Fn(i))return i;throw new Kl("Can't convert object to primitive value")}return e===void 0&&(e="number"),zl(r,e)}});var Tr=u((Vd,Dn)=>{"use strict";var Yl=Bn(),Xl=yr();Dn.exports=function(r){var e=Yl(r,"string");return Xl(e)?e:e+""}});var Un=u((Md,Gn)=>{"use strict";var Zl=Z(),Hn=ge(),Sr=Zl.document,Jl=Hn(Sr)&&Hn(Sr.createElement);Gn.exports=function(r){return Jl?Sr.createElement(r):{}}});var wr=u((jd,zn)=>{"use strict";var ec=le(),tc=U(),rc=Un();zn.exports=!ec&&!tc(function(){return Object.defineProperty(rc("div"),"a",{get:function(){return 7}}).a!==7})});var Qn=u(Kn=>{"use strict";var ic=le(),nc=ft(),ac=sr(),sc=or(),oc=Me(),lc=Tr(),cc=Ce(),uc=wr(),Wn=Object.getOwnPropertyDescriptor;Kn.f=ic?Wn:function(e,t){if(e=oc(e),t=lc(t),uc)try{return Wn(e,t)}catch(i){}if(cc(e,t))return sc(!nc(ac.f,e,t),e[t])}});var Xn=u(($d,Yn)=>{"use strict";var pc=U(),hc=z(),dc=/#|\.prototype\./,$e=function(r,e){var t=mc[fc(r)];return t===vc?!0:t===yc?!1:hc(e)?pc(e):!!e},fc=$e.normalize=function(r){return String(r).replace(dc,".").toLowerCase()},mc=$e.data={},yc=$e.NATIVE="N",vc=$e.POLYFILL="P";Yn.exports=$e});var Ar=u((Nd,Jn)=>{"use strict";var Zn=nr(),bc=vr(),gc=ke(),Cc=Zn(Zn.bind);Jn.exports=function(r,e){return bc(r),e===void 0?r:gc?Cc(r,e):function(){return r.apply(e,arguments)}}});var ta=u((_d,ea)=>{"use strict";var Ec=le(),Ic=U();ea.exports=Ec&&Ic(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var ia=u((Fd,ra)=>{"use strict";var xc=ge(),Tc=String,Sc=TypeError;ra.exports=function(r){if(xc(r))return r;throw new Sc(Tc(r)+" is not an object")}});var sa=u(aa=>{"use strict";var wc=le(),Ac=wr(),Rc=ta(),gt=ia(),na=Tr(),Pc=TypeError,Rr=Object.defineProperty,Oc=Object.getOwnPropertyDescriptor,Pr="enumerable",Or="configurable",kr="writable";aa.f=wc?Rc?function(e,t,i){if(gt(e),t=na(t),gt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&kr in i&&!i[kr]){var n=Oc(e,t);n&&n[kr]&&(e[t]=i.value,i={configurable:Or in i?i[Or]:n[Or],enumerable:Pr in i?i[Pr]:n[Pr],writable:!1})}return Rr(e,t,i)}:Rr:function(e,t,i){if(gt(e),t=na(t),gt(i),Ac)try{return Rr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new Pc("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var la=u((Bd,oa)=>{"use strict";var kc=le(),Vc=sa(),Mc=or();oa.exports=kc?function(r,e,t){return Vc.f(r,e,Mc(1,t))}:function(r,e,t){return r[e]=t,r}});var _e=u((Dd,ua)=>{"use strict";var Ne=Z(),jc=Pi(),Lc=nr(),$c=z(),Nc=Qn().f,_c=Xn(),Ie=mt(),Fc=Ar(),xe=la(),ca=Ce();bt();var qc=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 jc(r,this,arguments)};return e.prototype=r.prototype,e};ua.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,a=r.proto,o=i?Ne:n?Ne[t]:Ne[t]&&Ne[t].prototype,l=i?Ie:Ie[t]||xe(Ie,t,{})[t],s=l.prototype,c,f,b,m,I,P,O,g,V;for(m in e)c=_c(i?m:t+(n?".":"#")+m,r.forced),f=!c&&o&&ca(o,m),P=l[m],f&&(r.dontCallGetSet?(V=Nc(o,m),O=V&&V.value):O=o[m]),I=f&&O?O:e[m],!(!c&&!a&&typeof P==typeof I)&&(r.bind&&f?g=Fc(I,Ne):r.wrap&&f?g=qc(I):a&&$c(I)?g=Lc(I):g=I,(r.sham||I&&I.sham||P&&P.sham)&&xe(g,"sham",!0),xe(l,m,g),a&&(b=t+"Prototype",ca(Ie,b)||xe(Ie,b,{}),xe(Ie[b],m,I),r.real&&s&&(c||!s[m])&&xe(s,m,I)))}});var ha=u((Hd,pa)=>{"use strict";var Bc=Math.ceil,Dc=Math.floor;pa.exports=Math.trunc||function(e){var t=+e;return(t>0?Dc:Bc)(t)}});var Fe=u((Gd,da)=>{"use strict";var Hc=ha();da.exports=function(r){var e=+r;return e!==e||e===0?0:Hc(e)}});var ma=u((Ud,fa)=>{"use strict";var Gc=Fe(),Uc=Math.min;fa.exports=function(r){var e=Gc(r);return e>0?Uc(e,9007199254740991):0}});var qe=u((zd,ya)=>{"use strict";var zc=ma();ya.exports=function(r){return zc(r.length)}});var Ct=u((Wd,va)=>{"use strict";va.exports=function(){}});var ba=u(()=>{"use strict";var Wc=_e(),Kc=je(),Qc=qe(),Yc=Fe(),Xc=Ct();Wc({target:"Array",proto:!0},{at:function(e){var t=Kc(this),i=Qc(t),n=Yc(e),a=n>=0?n:i+n;return a<0||a>=i?void 0:t[a]}});Xc("at")});var Et=u((Yd,ga)=>{"use strict";var Zc=yt();ga.exports=Zc});var Ea=u((Xd,Ca)=>{"use strict";ba();var Jc=Et();Ca.exports=Jc("Array","at")});var xa=u((Zd,Ia)=>{"use strict";var eu=Ea();Ia.exports=eu});var Vr=u((Jd,Ta)=>{"use strict";var tu=xa();Ta.exports=tu});var Fa=u((vm,_a)=>{"use strict";var pu=Er(),hu=Ir(),Na=pu("keys");_a.exports=function(r){return Na[r]||(Na[r]=hu(r))}});var Ba=u((bm,qa)=>{"use strict";var du=U();qa.exports=!du(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Ga=u((gm,Ha)=>{"use strict";var fu=Ce(),mu=z(),yu=je(),vu=Fa(),bu=Ba(),Da=vu("IE_PROTO"),Dr=Object,gu=Dr.prototype;Ha.exports=bu?Dr.getPrototypeOf:function(r){var e=yu(r);if(fu(e,Da))return e[Da];var t=e.constructor;return mu(t)&&e instanceof t?t.prototype:e instanceof Dr?gu:null}});var za=u((Cm,Ua)=>{"use strict";var Cu=Fe(),Eu=Math.max,Iu=Math.min;Ua.exports=function(r,e){var t=Cu(r);return t<0?Eu(t+e,0):Iu(t,e)}});var Hr=u((Em,Ka)=>{"use strict";var xu=Me(),Tu=za(),Su=qe(),Wa=function(r){return function(e,t,i){var n=xu(e),a=Su(n);if(a===0)return!r&&-1;var o=Tu(i,a),l;if(r&&t!==t){for(;a>o;)if(l=n[o++],l!==l)return!0}else for(;a>o;o++)if((r||o in n)&&n[o]===t)return r||o||0;return!r&&-1}};Ka.exports={includes:Wa(!0),indexOf:Wa(!1)}});var Ya=u((Im,Qa)=>{"use strict";Qa.exports={}});var Ja=u((xm,Za)=>{"use strict";var wu=K(),Gr=Ce(),Au=Me(),Ru=Hr().indexOf,Pu=Ya(),Xa=wu([].push);Za.exports=function(r,e){var t=Au(r),i=0,n=[],a;for(a in t)!Gr(Pu,a)&&Gr(t,a)&&Xa(n,a);for(;e.length>i;)Gr(t,a=e[i++])&&(~Ru(n,a)||Xa(n,a));return n}});var ts=u((Tm,es)=>{"use strict";es.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var is=u((Sm,rs)=>{"use strict";var Ou=Ja(),ku=ts();rs.exports=Object.keys||function(e){return Ou(e,ku)}});var cs=u((wm,ls)=>{"use strict";var as=le(),Vu=U(),ss=K(),Mu=Ga(),ju=is(),Lu=Me(),$u=sr().f,os=ss($u),Nu=ss([].push),_u=as&&Vu(function(){var r=Object.create(null);return r[2]=2,!os(r,2)}),ns=function(r){return function(e){for(var t=Lu(e),i=ju(t),n=_u&&Mu(t)===null,a=i.length,o=0,l=[],s;a>o;)s=i[o++],(!as||(n?s in t:os(t,s)))&&Nu(l,r?[s,t[s]]:t[s]);return l}};ls.exports={entries:ns(!0),values:ns(!1)}});var us=u(()=>{"use strict";var Fu=_e(),qu=cs().values;Fu({target:"Object",stat:!0},{values:function(e){return qu(e)}})});var hs=u((Pm,ps)=>{"use strict";us();var Bu=mt();ps.exports=Bu.Object.values});var fs=u((Om,ds)=>{"use strict";var Du=hs();ds.exports=Du});var Nt=u((km,ms)=>{"use strict";var Hu=fs();ms.exports=Hu});var bs=u(()=>{"use strict";var Gu=_e(),Uu=Hr().includes,zu=U(),Wu=Ct(),Ku=zu(function(){return!Array(1).includes()});Gu({target:"Array",proto:!0,forced:Ku},{includes:function(e){return Uu(this,e,arguments.length>1?arguments[1]:void 0)}});Wu("includes")});var Cs=u((Nm,gs)=>{"use strict";bs();var Qu=Et();gs.exports=Qu("Array","includes")});var Is=u((_m,Es)=>{"use strict";var Yu=Cs();Es.exports=Yu});var _t=u((Fm,xs)=>{"use strict";var Xu=Is();xs.exports=Xu});var Qr=u((ay,Rs)=>{"use strict";var ip=Ve();Rs.exports=Array.isArray||function(e){return ip(e)==="Array"}});var Os=u((sy,Ps)=>{"use strict";var np=TypeError,ap=9007199254740991;Ps.exports=function(r){if(r>ap)throw np("Maximum allowed index exceeded");return r}});var Ms=u((oy,Vs)=>{"use strict";var sp=Qr(),op=qe(),lp=Os(),cp=Ar(),ks=function(r,e,t,i,n,a,o,l){for(var s=n,c=0,f=o?cp(o,l):!1,b,m;c<i;)c in t&&(b=f?f(t[c],c,e):t[c],a>0&&sp(b)?(m=op(b),s=ks(r,e,b,m,s,a-1)-1):(lp(s+1),r[s]=b),s++),c++;return s};Vs.exports=ks});var $s=u((ly,Ls)=>{"use strict";var up=Le(),pp=up("toStringTag"),js={};js[pp]="z";Ls.exports=String(js)==="[object z]"});var _s=u((cy,Ns)=>{"use strict";var hp=$s(),dp=z(),qt=Ve(),fp=Le(),mp=fp("toStringTag"),yp=Object,vp=qt(function(){return arguments}())==="Arguments",bp=function(r,e){try{return r[e]}catch(t){}};Ns.exports=hp?qt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=bp(e=yp(r),mp))=="string"?t:vp?qt(e):(i=qt(e))==="Object"&&dp(e.callee)?"Arguments":i}});var qs=u((uy,Fs)=>{"use strict";var gp=K(),Cp=z(),Yr=bt(),Ep=gp(Function.toString);Cp(Yr.inspectSource)||(Yr.inspectSource=function(r){return Ep(r)});Fs.exports=Yr.inspectSource});var zs=u((py,Us)=>{"use strict";var Ip=K(),xp=U(),Bs=z(),Tp=_s(),Sp=yt(),wp=qs(),Ds=function(){},Hs=Sp("Reflect","construct"),Xr=/^\s*(?:class|function)\b/,Ap=Ip(Xr.exec),Rp=!Xr.test(Ds),Xe=function(e){if(!Bs(e))return!1;try{return Hs(Ds,[],e),!0}catch(t){return!1}},Gs=function(e){if(!Bs(e))return!1;switch(Tp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Rp||!!Ap(Xr,wp(e))}catch(t){return!0}};Gs.sham=!0;Us.exports=!Hs||xp(function(){var r;return Xe(Xe.call)||!Xe(Object)||!Xe(function(){r=!0})||r})?Gs:Xe});var Ys=u((hy,Qs)=>{"use strict";var Ws=Qr(),Pp=zs(),Op=ge(),kp=Le(),Vp=kp("species"),Ks=Array;Qs.exports=function(r){var e;return Ws(r)&&(e=r.constructor,Pp(e)&&(e===Ks||Ws(e.prototype))?e=void 0:Op(e)&&(e=e[Vp],e===null&&(e=void 0))),e===void 0?Ks:e}});var Zs=u((dy,Xs)=>{"use strict";var Mp=Ys();Xs.exports=function(r,e){return new(Mp(r))(e===0?0:e)}});var Js=u(()=>{"use strict";var jp=_e(),Lp=Ms(),$p=je(),Np=qe(),_p=Fe(),Fp=Zs();jp({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=$p(this),i=Np(t),n=Fp(t,0);return n.length=Lp(n,t,t,i,0,e===void 0?1:_p(e)),n}})});var eo=u(()=>{"use strict";var qp=Ct();qp("flat")});var ro=u((by,to)=>{"use strict";Js();eo();var Bp=Et();to.exports=Bp("Array","flat")});var no=u((gy,io)=>{"use strict";var Dp=ro();io.exports=Dp});var so=u((Cy,ao)=>{"use strict";var Hp=no();ao.exports=Hp});var yi="1.0.31-dev.a65d13ac.0";function Qt(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 B="interactive",qo="interactive-controls-container",it=()=>document.querySelector(`.${qo}`),vi=.4,_={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},bi=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(bi||{}),gi=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(gi||{}),Ci=(i=>(i.start="left",i.end="right",i.center="center",i))(Ci||{}),nt=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&bi[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&gi[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&Ci[e.alignment])!=null?n:"center"},at=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,a,o,l,s,c;r.style.color=(a=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?a:t.textColor,r.style.fontSize=`calc(${i.height} * ${(l=(o=e==null?void 0:e.text)==null?void 0:o.size)!=null?l:t.textSize})`,r.textContent=(c=(s=e==null?void 0:e.text)==null?void 0:s.value)!=null?c:t.textContent},st=({target:r,props:e,fallback:t})=>{var i,n,a,o;r.style.backgroundColor=Qt((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(o=(a=e==null?void 0:e.background)==null?void 0:a.alpha)!=null?o:t.backgroundAlpha)},ot=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,a,o,l,s,c,f,b,m,I,P;r.style.border=`calc(${i.height} * ${(o=(a=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:a.width)!=null?o:t.borderWidth}) solid ${Qt((c=(s=(l=e==null?void 0:e.shape)==null?void 0:l.border)==null?void 0:s.color)!=null?c:t.borderColor,(m=(b=(f=e==null?void 0:e.shape)==null?void 0:f.border)==null?void 0:b.alpha)!=null?m:t.borderAlpha)}`,r.style.borderRadius=`calc(${i.height} * ${(P=(I=e==null?void 0:e.shape)==null?void 0:I.roundCorners)!=null?P:t.roundCorners})`},ve=({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)`};var re=class{constructor(e){this.control=e;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){var n;let t=document.createElement("div");t.classList.add(`${B}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:_.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:i}}createClickListener(e){return t=>{t.stopPropagation(),e()}}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var n;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(n=this.container)==null||n.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){var e,t;(e=this.container)!=null&&e.element&&this.clickListener&&((t=this.container)==null||t.element.removeEventListener("click",this.clickListener))}};var Yt="int",oe=(i=>(i.AREA=`${Yt}_area`,i.TEXT=`${Yt}_text`,i.BUTTON=`${Yt}_bttn`,i))(oe||{});var lt=r=>{if(r.type.trim().toLowerCase()==="area")return new Xt(r)},Xt=class extends re{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${B}-${this.control.id}`),i.setAttribute("data-testid",oe.AREA),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",st({target:i,props:this.control.props,fallback:E(d({},_),{backgroundColor:"transparent"})}),ot({target:i,props:this.control.props,fallback:E(d({},_),{borderAlpha:0}),dependsOn:this.container.dimensions}),ve({target:i,layoutParams:this.control.layoutParams,fallback:_}),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var ct=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 ut=r=>{if(r.type.trim().toLowerCase()==="button")return new Zt(r)},Zt=class extends re{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){var o;if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${B}-${this.control.id}`),i.setAttribute("data-testid",oe.BUTTON),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",i.style.fontFamily="inherit",ve({target:i,layoutParams:this.control.layoutParams,fallback:_}),st({target:i,props:this.control.props,fallback:_}),ot({target:i,props:this.control.props,fallback:_,dependsOn:this.container.dimensions}),nt({target:i,props:E(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let n=ct(this.control.type.trim().toLowerCase()),a=(o=n.firstElementChild)!=null?o:n;at({target:a,props:this.control.props,fallback:_,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var Ei=r=>{if(r.type.trim().toLowerCase()==="text")return new Jt(r)},Jt=class extends re{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){var o;if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(`${B}-${this.control.id}`),i.setAttribute("data-testid",oe.TEXT),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.fontFamily="inherit",ve({target:i,layoutParams:this.control.layoutParams,fallback:_}),nt({target:i,props:E(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let n=ct(this.control.type.trim().toLowerCase()),a=(o=n.firstElementChild)!=null?o:n;at({target:a,props:this.control.props,fallback:_,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){}enable(){}getElement(){return this.controlElement}};var er=class{constructor(e){this.layout=e}},pt=class extends er{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var be=class{constructor(e){this.container=e,this.factories=new Map,this.controls=[],this.setControls()}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(),a=this.factories.get(n);if(a){let o=a(i);if(o)return[...t,o]}return[...t]},[]))||[]}};var ht=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new tr(r,e)},tr=class extends be{constructor(e,t){super(e),this.rootElement=t!=null?t:it(),this.layout=new pt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",ut),this.addControlFactory("text",Ei),this.addControlFactory("area",lt)}createView(e){let t=document.createElement("div");return t.classList.add(`${B}-${this.container.id}`),this.layout.setContainerLayout(t),this.controls.forEach(i=>{i.createView({parentElement:t,layoutCallback:this.layout.setControlLayout}),i.setEvents(e)}),this.rootElement.append(t),this.isRemoved=!1,t}hide(){let e=this.getElement();e&&(e.style.visibility="hidden")}show(){let e=this.getElement();e&&(e.style.visibility="visible")}enable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.enable()),e.style.opacity="1",this.isDisabled=!1)}disable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.disable()),e.style.opacity=`${vi}`,this.isDisabled=!0)}removeView(){var e;this.isRemoved||(this.controls.forEach(t=>t.removeListeners()),(e=this.getElement())==null||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${B}-${this.container.id}`)}};var ko=te(Vr(),1);import{clientChecker as eh,combine as th,InterfaceLanguage as rh,Observable as Ro,once as ih,Subject as D,Subscription as ii,ValueSubject as H,fromEvent as Po}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as et}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as ru}from"@vkontakte/videoplayer-shared/es2015";function Be(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var ce=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,De=r=>ce(r,"Object"),It=r=>ce(r,"String"),xt=r=>ce(r,"Array"),Tt=r=>ce(r,"Number"),Sa=r=>ce(r,"Function");var Mr=r=>Tt(r)&&!isNaN(r);var ue=r=>De(r)&&Object.keys(r).length===0,jr=r=>xt(r)&&!r.length;var He=(r,e)=>It(r)&&(e?r.trim():r).length;var wa="video_interactive",Aa="videoint";var Ra=250,Ge=class{constructor(e){this.handleZoomChange=Be(e=>{this.lastZoomInfo=e},Ra);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)),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,"Id is not found"),console.error("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,!Tt(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"Can't show graph"),console.error("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:a=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(a),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=iu(e),this.resizeObserver=new ResizeObserver(Be(this.onResize,Ra)),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 A(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 A(this,null,function*(){if(!this.manifest)return;let e;try{e=yield ru(this.lang,wa,Aa)}catch(i){console.log("Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",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",a=>{var o=a,{name:i}=o,n=X(o,["name"]);var l;i==="openPreview"&&"chapterId"in n&&((l=this.onOpenPreviewClick)==null||l.call(this,n.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 iu(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 Ue=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 a of this._containers){let o=a.startTime-e;if(o<=n&&(a.endTime&&n<=a.endTime||a.endTime===null)){i=!0;break}n<o&&(t=t===-1?o:Math.min(t,o))}return!i&&t!==-1?t:null}}};import{isSupportedManifest as wt,ContainerTypes as Af,ControlTypes as At,EventActionTypes as k,EventTypes as Rf,migrateManifestToLatestVersion as ka,compareVersions as Pf}from"@interactiveplatform/movika-manifest";var Pa={metadata:"Object",chapters:"Array"},Oa=r=>{if(!De(r))return!1;for(let e in Pa)if(!r[e]||!ce(r[e],Pa[e]))return!1;return wt(r.metadata.version)},St=r=>r.type===At.Text,bf=r=>r.type===At.Button,gf=r=>r.type===At.Area,Cf={Choice:"Choice",TextInput:"TextInput"},Ef={Button:"Button",Area:"Area",Text:"Text"},If={onClick:"onClick",onSuspense:"onSuspense"},xf={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var N=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var Rt=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 Pt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Sa(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=[]}};import{ValueSubject as uu}from"@vkontakte/videoplayer-shared/es2015";var Ot=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 A(this,null,function*(){return nu(...this.loaders[e])(t)})}};function nu(...r){return function(t){return A(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function ze(r,e,t){return r?E(d({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function kt(n){var a=n,{actions:r,errors:e,chapterId:t}=a,i=X(a,["actions","errors","chapterId"]);if(t){let o=r.getManifest();if(o){let l=r.getChapter(o.chapters,t);if(l){let s=r.getMedia(o.media,l.videoId),c=r.getGraph(o.graph,l.id);return s?E(d({},i),{actions:r,errors:e,result:{chapter:l,media:s,graph:c}}):E(d({},i),{errors:ze(e,kt.name,"Could not find media"),actions:r})}}}return E(d({},i),{errors:ze(e,kt.name,"Could not find chapter"),actions:r})}var Vt=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,a=i.length;n<a;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,a=i.length;n<a;n++){let o=i[n];try{o.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}o.options&&o.options.once&&this.removeEventListener(e.type,o.callback)}return!e.defaultPrevented}},Te=class extends Vt{constructor(){super(),this.listeners||Vt.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)}},We=class{constructor(){Object.defineProperty(this,"signal",{value:new Te,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(n){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let i=e;if(i===void 0)if(typeof document=="undefined")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch(n){i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(We.prototype[Symbol.toStringTag]="AbortController",Te.prototype[Symbol.toStringTag]="AbortSignal");function Mt(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 Lr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Mt({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:a};let a=t;(a&&!a.prototype.hasOwnProperty("signal")||n)&&(a=function(c,f){let b;f&&f.signal&&(b=f.signal,delete f.signal);let m=new t(c,f);return b&&Object.defineProperty(m,"signal",{writable:!1,enumerable:!1,configurable:!0,value:b}),m},a.prototype=t.prototype);let o=e;return{fetch:(s,c)=>{let f=a&&a.prototype.isPrototypeOf(s)?s.signal:c?c.signal:void 0;if(f){let b;try{b=new DOMException("Aborted","AbortError")}catch(I){b=new Error("Aborted"),b.name="AbortError"}if(f.aborted)return Promise.reject(b);let m=new Promise((I,P)=>{f.addEventListener("abort",()=>P(b),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([m,o(s,c)])}return o(s,c)},Request:a}}var Ke=Mt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Va=Ke?Lr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,$r=Ke?Va.fetch:window.fetch,Kf=Ke?Va.Request:window.Request,Qf=Ke?We:window.AbortController,Yf=Ke?Te:window.AbortSignal;var Nr=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let a=0;a<Math.max(t.length,i.length)&&!n;a++)t[a]>i[a]?n=1:t[a]<i[a]?n=-1:n=0;return n};var au=r=>A(void 0,null,function*(){try{let e={},t;if(It(r)){t=new URL(r).href;let n=yield $r(t);if(!n.ok)return{};e=yield n.json()}else if(De(r))e=r;else return{};if(!Oa(e))return{};let i=e.metadata.media;if(It(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let a=yield $r(n);if(!a.ok)throw new Error;e.metadata.media=yield a.json()}catch(n){return lu(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function Ma(r){return A(this,null,function*(){let{manifest:e,manifestURL:t}=yield au(r);if(!e)throw new Error("Failed on fetch");let i=ka(e);return i.media=su(i.media,t),delete i.metadata.media,i})}function jt(r,e){if(e)return r.find(t=>t.id===e)}function _r(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 Fr(r,e){return r.videos.find(t=>t.id===e)}function su(r,e){return E(d({},r),{videos:r.videos.map(t=>E(d({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",a=ou(n,e);return E(d({},i),{url:a||n})})}))})}function ou(r="",e){try{return new URL(r,e).href}catch(t){return""}}function lu(r){return Nr(r,"3.2.0")>=0}var Lt=r=>xt(r)&&!jr(r),J=r=>r.order==="end",$t=r=>xt(r.containers)&&!jr(r.containers)&&J(r),ja=(r,e)=>{var i;let t=r*1e3;return Lt(e.controls)&&t<((i=e.startTime)!=null?i:0)},qr=(r,e)=>{var i,n;let t=r*1e3;return Lt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var pe=(r=[])=>r.some(e=>e.action.type==="expect"),Br=(r=[])=>r.find(e=>e.action.type==="expect"),cu=r=>(r==null?void 0:r.length)===1,Se=r=>cu(r)&&St(r[0]);function La(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(d(d({},e[0]),t)):r(...e,...t)}var $a=(r,e)=>pe(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&pe(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var we=class extends Ot{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new uu(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 A(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:ze},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 A(this,null,function*(){return this.setNext()})}setNext(){return A(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",kt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:_r,getChapter:jt,getMedia:Fr,getByBranches:this.getByBranches.bind(this),addErrorMessage:ze},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=jt(this.manifest.chapters,t);if(n){let a=Fr(this.manifest.media,n.videoId),o=_r(this.manifest.graph,n.id);if(a)return{chapter:n,media:a,graph:o}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,a,o;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((a=this.chapter)==null?void 0:a.branches);{let l=jt(((o=this.manifest)==null?void 0:o.chapters)||[],t);return this.getByBranches(l==null?void 0:l.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let a=this.getByChapterId(n.chapterId);return a&&i.push(a),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?J(this.chapter):!1}};var Ts=te(Nt(),1);import{Player as Zu}from"@vkontakte/videoplayer-core/es2015";import{Subscription as Wr,Tracer as Ju,ValueSubject as ep}from"@vkontakte/videoplayer-shared/es2015";var ys=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 vs=te(Nt(),1);function Ur(){let r=new Map;function e(s){var c=s,{listId:a=Math.random().toString(),itemId:o=Math.random().toString()}=c,l=X(c,["listId","itemId"]);let f=r.get(a),b=d({},l);return f?f[o]=b:r.set(a,{[o]:b}),d({listId:a,itemId:o},l)}function t(a){var o,l;a.player.destroy(),a.container.remove(),a.subscription.unsubscribe(),(o=a.statistics)==null||o.oneStat.destroy(),(l=a.statistics)==null||l.statSubscription.unsubscribe()}function i(a,o){let l=r.get(a);if(!l)throw Error("Can't remove. Not find.");if(o){let s=l[o];s&&t(s),delete l[o],Object.keys(l).length||r.delete(a)}else{for(let s of(0,vs.default)(l))t(s);r.delete(a)}}function n(){for(let a of r)i(a[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var Ae=te(_t(),1);function zr(r,e=[]){var a,o,l;let t={},i,n=!e.length;for(let s of r.variants)if(!i&&"cover"in s&&(i=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(n||(0,Ae.default)(e,"mp4"))&&(t.MPEG=E(d({},t.MPEG),{[(a=s.standard)!=null?a:"Invariant quality"]:s.url}));break;case"mpeg":(n||(0,Ae.default)(e,"mpeg"))&&(t.MPEG=E(d({},t.MPEG),{[(o=s.standard)!=null?o:"Invariant quality"]:s.url}));break;case"hls":(n||(0,Ae.default)(e,"hls"))&&(t=E(d({},t),{HLS:{type:"url",url:s.url}}));break;case"dash":(n||(0,Ae.default)(e,"dash"))&&(t=E(d({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(l=r.title)!=null?l:""}}var Qe=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,Ae.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var tp=2;function Kr(r){let e=Ur(),t=new Wr,i={},n=null,a=!1,o,l=new ep(null);r&&s(r);function s(g){n=g}function c(g,V,p){var x;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let y=((x=e.map.get(g))!=null?x:{})[V];if(y){i=d({chapterId:p,listId:g,itemId:V},y);let C=i.player;i.subscription.add(C.info.currentQuality$.subscribe(v=>{let S=C.info.position$.getValue(),F=C.info.isAutoQualityEnabled$.getValue();if(!(!v||!S||F))for(let w of e.map)(0,Ts.default)(w[1]).forEach(({player:M})=>{Qe(M,v)})})).add(C.events.started$.subscribe(()=>{f(V)})),y.container.remove(),n.setPlayer(y.player),a||(n.init(),a=!0),l.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}function f(g){return A(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(ue(i)||g!==i.itemId)return;let V=n.getChapterBranches(),p=new Set;for(let h of V)p.has(h.media.id)||(yield m({media:h.media,chapterId:h.chapter.id,setAsActive:!1,title:h.chapter.label}),p.add(h.media.id))})}function b(p){return A(this,arguments,function*({chapter:{id:g},manifestVideo:V}){if(ue(i)||!n)return;let h=i.player.info.muted$.getValue(),y=i.player.info.currentQuality$.getValue(),x=i.player.info.isAutoQualityEnabled$.getValue(),C=i.player.info.volume$.getValue(),v=i.player.info.currentPlaybackRate$.getValue(),S=!x,F=!1;for(let w of e.map)if(w[0]===V.id&&!n.state.isReplay$.getValue()){let M=Object.keys(w[1]);for(let L of M)L===i.itemId?(M.length<tp||(F=!0),e.removePlayer(w[0],L)):(F=!0,c(w[0],L,g),S?Qe(i.player,y):i.player.setAutoQuality(!0),i.player.setVolume(C),i.player.setMuted(h),i.player.setPlaybackRate(v))}else e.removePlayer(w[0]);F||(yield m({media:V,chapterId:g,setAsActive:!0,playbackRate:v}),S?Qe(i.player,y):i.player.setAutoQuality(!0),i.player.setVolume(C),i.player.setMuted(h))})}function m(S){return A(this,arguments,function*({media:g,chapterId:V,prefetch:p=!0,setAsActive:h=!0,autoplay:y=!1,preferredExt:x,title:C,playbackRate:v}){var ai,si,oi,li,ci;let F=Math.random().toString(),w=document.createElement("div");o.append(w);let M;if((ai=n==null?void 0:n.options)!=null&&ai.vkVideoLoader){let tt=ys(g);tt.length&&(M=yield n.options.vkVideoLoader(...tt))}let L=((si=n==null?void 0:n.options)==null?void 0:si.coreConfig)||void 0,Y=E(d({},L),{configName:[...(oi=L==null?void 0:L.configName)!=null?oi:[],"interactive"]}),se=E(d({container:w},((li=M==null?void 0:M.videos)==null?void 0:li[0])||{sources:zr(g,x).sources}),{title:C,failoverHosts:(M==null?void 0:M.failoverHosts)||[]}),q=new Zu(Y,Ju.createRootTracer());q.initVideo(se);let me=null;if(M!=null&&M.videos&&(n!=null&&n.options.createOneStat)){let tt=M.videos[0],zt=n.options.createOneStat(tt),ui=new Wr;zt&&(ui.add(zt.attachTo(q)),me={oneStat:zt,statSubscription:ui})}let ni=new Wr,Vo=(ci=i==null?void 0:i.player)==null?void 0:ci.info.isAutoQualityEnabled$.getValue();ni.add(q.events.canplay$.subscribe(function(){Vo||Qe(q,i.player.info.currentQuality$.getValue()),v&&q.setPlaybackRate(v)}));let ye=e.createPlayer({listId:g.id,itemId:F,player:q,container:w,sources:zr(g,x).sources,config:se,subscription:ni,statistics:me});return h&&c(g.id,ye.itemId,V),y&&ye.player.play(),p&&!y&&ye.player.prepare(),{player:ye.player,config:ye.config,statistics:ye.statistics}})}function I(){P(),n=null,o.remove()}function P(){t.unsubscribe(),e.removeAll(),i={},a=!1}function O(){return A(this,null,function*(){if(!n)throw Error("need to set interactive controller");P(),o=document.createElement("div");let{media:g,chapter:V}=n.getCurrentChapter();g&&V?(t.add(n.events.chapterChanged$.subscribe(b)),yield m({media:g,chapterId:V.id,title:V.label})):console.error("not found")})}return E(d({},e),{init:O,setInteractiveController:s,createPlayer:m,removeAll:I,getActivePlayer:function(){return i},activePlayerChanged:l})}var R={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Ye={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},j={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var ws=te(_t(),1);import{Subscription as rp}from"@vkontakte/videoplayer-shared/es2015";var Ft=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:a,globalEvents:o,globalEventEmitter:l,ignoreContainerEvent:s,permanentTextControls:c,disabledControls$:f,onRemove:b}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(pe(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,a;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement())(i=(t=this.container).show)==null||i.call(t),this.emitContainerVisibilityEvent(!0,!1);else{let o={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(s,c)=>{this.isSelectedControlEvent=!0,s!==!1&&(this.removeView(),this.emitContainerVisibilityEvent(!1)),(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),c(),this.removeView(),this.emitContainerVisibilityEvent(!1))},isEOV:()=>this.gameState===4},l=La(this.selectBranches.onControlEvent,o);this.container.createView(l),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((a=(n=this.container).disable)==null||a.call(n))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var c;let e=this.player.experimental.element$.getValue(),i=e instanceof HTMLVideoElement?e.readyState:void 0,n=[6,5];if(!i||(0,ws.default)(n,this.gameState)&&!this.isPermanentText)return;let a=this.player.getExactTime();if(ja(a,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(qr(a,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let f=this.gameState;this.gameState=3,f===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let o=qr(a,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(c=this.container.container.endTime)!=null?c:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:a,isInteractiveTime:o};this.globalEventEmitter.emit(R.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new rp,this.player=e,this.interactiveEvents=a,this.ignoreContainerEvent=s,this.isPermanentText=c&&Se(t.container.controls),this.disabledControls$=f,this.onRemove=b,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=o,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(R.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.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(R.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.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,a;e?(i=(t=this.container).disable)==null||i.call(t):(a=(n=this.container).enable)==null||a.call(n)}))}selectContainerEvent(e=!1){var t,i;this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(t=this.container.container.endTime)!=null?t:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((i=this.container.container.endTime)!=null?i:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=pe(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(R.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var As=(r=[])=>r.reduce((e,t,i)=>{var a,o,l;let n=((a=t==null?void 0:t.controls)!=null?a:[]).filter(s=>!St(s));if(Lt(n)){let s=[(o=t.startTime)!=null?o:0,(l=t.endTime)!=null?l:1/0],c=t.id;if(!i)e.push({subjects:[c],range:s});else{let f=[],b=-1/0,m=1/0,I=[],P=[];for(let O=0;O<e.length;O++){let g=e[O];if(P.push(...g.subjects),g.range[0]<m&&(m=g.range[0]),g.range[1]>b&&(b=g.range[1]),s[0]>=g.range[0]&&s[1]<=g.range[1])return e[O].subjects.push(c),e;s[0]<g.range[0]&&s[1]>g.range[0]&&(f.push(O),I=I.concat(g.subjects)),s[0]>=g.range[0]&&s[0]<=g.range[1]&&(f.push(O),I=I.concat(g.subjects),s[0]=g.range[0]),s[1]>=g.range[0]&&s[1]<=g.range[1]&&(f.push(O),I=I.concat(g.subjects),s[1]=g.range[1])}if(P.push(c),s[0]<=m&&s[1]>=b)return[{subjects:P,range:s}];f.length&&f.reverse().forEach(O=>{e.splice(O,1)}),e.push({subjects:I.concat([c]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var lo=te(_t(),1),Zr=te(Nt(),1),co=te(so(),1);function oo(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let s={};for(let c in r)+c<=l&&(s[c]=r[c]);return s}function i(l){let s={};for(let c in r)+c>=l&&(s[c]=r[c]);return s}function n({timestamp:l,priority:s,initiator:c}){var f;if(Mr(l)){let b=(f=r[l])!=null?f:null;if(b&&s&&He(s,!0)){let m={},I=b[s];if(I&&(m=d(d({},m),I)),m=ue(m)?null:m,m&&He(c,!0)){let P=m[c];return P!=null?P:null}return m}return b}return null}function a({timestamp:l,priority:s,initiator:c}){if(Mr(l))if(r[l]){if(s&&He(s,!0))if(r[l][s]){if(c&&He(c,!0))if(r[l][s][c]){if(delete r[l][s][c],!ue(r[l][s]))return!0}else return!1;if(delete r[l][s],!ue(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function o(b){var m=b,{timestamp:l,priority:s,initiator:c}=m,f=X(m,["timestamp","priority","initiator"]);var I,P,O;(P=(I=r[l])==null?void 0:I[s])!=null&&P[c]?r[l][s][c].push(d({},f)):(O=r[l])!=null&&O[s]?r[l][s]=E(d({},r[l][s]),{[c]:[d({},f)]}):r[l]?r[l]=E(d({},r[l]),{[s]:{[c]:[d({},f)]}}):r[l]={[s]:{[c]:[d({},f)]}}}return{map:r,remove:a,add:o,removeAll:e,get:n,getLte:t,getGte:i}}var Gp=[k.expect,k.setNextBranch],Up=1/0;function uo(r){let e=r,t,i=zp(),n=oo(),a,o=()=>{m(),V()},l=p=>{n.add.call(void 0,p),P()},s=(p=[])=>{for(let h of p)if(h.action(),(0,lo.default)(Gp,h.actionType))break},c=(p=1/0)=>{var C,v,S;let h=Bt((C=n.get({timestamp:p,priority:"control"}))!=null?C:{}),y=Bt((v=n.get({timestamp:p,priority:"container"}))!=null?v:{}),x=Bt((S=n.get({timestamp:p,priority:"chapter"}))!=null?S:{});return[...h,...y,...x]},f=p=>{i.isReady(p)&&s(c(p))},b=()=>{var p;s([...Bt((p=n.get({timestamp:1/0,priority:"chapter"}))!=null?p:{})])},m=()=>{t&&(a==null||a.unsubscribe(),t=void 0)},I=p=>{},P=()=>{t||(t=()=>setTimeout(()=>{f(1/0)}),a=e.events.ended$.subscribe(t))},O=p=>{m(),e=p},g=p=>{p.priority==="container"&&i.resetCalled(p.timestamp),n.remove(p)},V=()=>{i.release(),n.removeAll()};return{setPlayer:O,add:l,remove:g,exec:f,execEndOfVideo:b,listen:P,unlisten:m,release:o,containersEventsCallState:i,getPreparedToExecActions:c}}function zp(){let r=new Map;return{setCalled:({timestamp:o,id:l})=>{let s=r.get(o);s&&s[l]!==void 0&&(s[l]=!0)},setData:(o=[])=>{var l;for(let s of o){let c=(l=s.endTime)!=null?l:Up,f=r.get(c);r.set(c,E(d({},f),{[s.id]:!1}))}},resetCalled:o=>{let l=r.get(o);if(l)for(let s in l)l[s]=!1},isReady:o=>{let l=r.get(o);return l?!(0,Zr.default)(l).some(s=>!s):!0},release:()=>r.clear()}}function Bt(r){return(0,co.default)((0,Zr.default)(r)).sort(e=>e.actionType===k.expect?-1:1)}var po={videoContentHeight:0,videoContentWidth:0},ho=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return po;let{clientHeight:n,clientWidth:a}=e.experimental.element$.getValue()||{};if(!(n&&a))return po;let o=t/i,l=n/a,s,c;return l>o?(c=a,s=a*o):l<o?(c=n/o,s=n):(c=a,s=n),{videoContentWidth:c,videoContentHeight:s}};var Wp=250;function fo(r){let e=()=>{},t=new ResizeObserver(l=>{a(l),e=a.bind(null,l)});function i(l){let{parentElement:s,player:c}=r();if(s&&c){let{videoContentWidth:f,videoContentHeight:b}=ho(s,c);s.style.setProperty("--interactive-content-width",`${f}px`),s.style.setProperty("--interactive-content-height",`${b}px`),s.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),s.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function n(){let{parentElement:l}=r();l.removeAttribute("style")}let a=Be(l=>{let{fns:s=[]}=r();i(l);for(let c of s)c()},Wp);function o(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var Kp=r=>Math.floor(Math.random()*r),yo=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let a=r[e],o=(n=a.weight)!=null?n:1;o<t&&(t=o,i=a)}return i},vo=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let a=r[e],o=(n=a.weight)!=null?n:0;o>t&&(t=o,i=a)}return i};var bo=r=>{let e=r.length,t=Kp(e);return r[t]},mo=1,go=r=>{var i,n;let e=0;for(let a=0;a<r.length;++a)e+=(i=r[a].weight)!=null?i:mo;let t=Math.random()*e;e=0;for(let a=0;a<r.length-1;++a)if(e+=(n=r[a].weight)!=null?n:mo,e>=t)return r[a];return r[r.length-1]};var Co={shouldOpenNow:!0,isDetachContainer:!0},Eo="after-expect";var Jr=(r,e=!1)=>E(d({},r),{args:e?d(d({},r.args),Co):d(d({},Co),r.args)}),To=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},a=()=>{n.isExpect&&(n.isExpect=!1)},o=({action:p,controlType:h,controlId:y,containerId:x,branches:C=[],onEvent:v,isEOV:S=()=>!1,isDisabled:F=()=>!1})=>{let w=Jr(p,S()),M={timestamp:1/0,priority:"control",initiator:y,actionType:w.type},L=F(),Y=r.emit.bind(r,R.interactives,{subjectId:y,subjectType:h,subjectName:"control",type:L?j.actionChoiceCanceled:j.actionChoice,actionType:p.type,payload:d({invokeImmediately:w.args.shouldOpenNow,containerId:x},w.args)}),se=()=>{e.interactiveActionChoice$.next({subjectId:y,subjectType:h,subjectName:"control",type:L?"action-choice-canceled":"action-choice",actionType:p.type,payload:d({invokeImmediately:w.args.shouldOpenNow,containerId:x},w.args)})};if(L){Y(),se();return}switch(w.type.trim().toLowerCase()){case k.setNextBranch.trim().toLowerCase():{let q=C.find(me=>me.id===w.args.branchId);if(!q)return;v(w.args.isDetachContainer,I.bind(null,{subjectId:y,subjectName:"control"})),Y(),se(),w.args.shouldOpenNow?O({subjectId:y,subjectName:"control",subjectType:h,action:w,payload:{chapterId:q.chapterId,autoSelect:!1}}):i.add(E(d({},M),{action:O.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:w,payload:{chapterId:q.chapterId,autoSelect:!1}})}));return}case k.continuePlayback.trim().toLowerCase():{v(w.args.isDetachContainer,I.bind(null,{subjectId:y,subjectName:"control"})),Y(),se(),w.args.shouldOpenNow?P({subjectId:y,subjectName:"control",subjectType:h,action:p}):i.add(E(d({},M),{action:P.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:p})}));return}case k.openURI.trim().toLowerCase():{v(w.args.isDetachContainer,I.bind(null,{subjectId:y,subjectName:"control"})),Y(),se(),w.args.shouldOpenNow?V({subjectId:y,subjectName:"control",subjectType:h,action:w,payload:{URI:p.args.uri}}):i.add(E(d({},M),{action:V.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:w,payload:{URI:p.args.uri}})}));return}default:{let q="Unexpected control event",me=new N(1,1,{message:q});f(me,q);return}}},l=({action:p,container:{id:h,endTime:y},branches:x=[],isEOV:C=!1,autoSelected:v=!1})=>{let S=Jr(p,C),F={timestamp:!S.args.shouldOpenNow||C?1/0:y!=null?y:1/0,priority:"container",initiator:h,actionType:S.type},w=r.emit.bind(r,R.interactives,{subjectId:h,subjectName:"container",type:j.actionChoice,actionType:S.type,payload:d({invokeImmediately:S.args.shouldOpenNow},S.args)}),M=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:S.type,payload:d({invokeImmediately:S.args.shouldOpenNow},S.args)})};switch(S.type.trim().toLowerCase()){case k.setNextBranch.trim().toLowerCase():{let L=x.find(Y=>Y.id===S.args.branchId);if(!L)return;w(),M(),i.add(E(d({},F),{action:O.bind(null,{subjectId:h,subjectName:"container",action:S,payload:{chapterId:L.chapterId,autoSelect:v}})}));return}case k.setMaxWeightBranch.trim().toLowerCase():return;case k.setMinWeightBranch.trim().toLowerCase():return;case k.setRandomBranch.trim().toLowerCase():return;case k.setWeightlessRandomBranch.trim().toLowerCase():return;case k.continuePlayback.trim().toLowerCase():{w(),M(),i.add(E(d({},F),{action:P.bind(null,{subjectId:h,subjectName:"container",action:S})}));return}case k.openURI.trim().toLowerCase():{w(),M(),i.add(E(d({},F),{action:V.bind(null,{subjectId:h,subjectName:"container",action:S,payload:{URI:p.args.uri}})}));return}default:{let L="Unexpected container event",Y=new N(1,1,{message:L});f(Y,L);return}}};function s({container:p,branches:h,isEOV:y=!1}){var C,v;let x=Br(p.events);if(x){let S=Jr(x.action,y);r.emit(R.interactives,{subjectId:p.id,subjectName:"container",type:j.actionChoice,actionType:S.type,payload:d({invokeImmediately:S.args.shouldOpenNow},S.args)}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"container",type:"action-choice",actionType:S.type,payload:d({invokeImmediately:S.args.shouldOpenNow},S.args)}),i.add({timestamp:y?1/0:(C=p.endTime)!=null?C:1/0,priority:"container",initiator:p.id,actionType:k.expect,action:m.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let S of(v=p.events)!=null?v:[])l({action:S.action,container:p,branches:h,isEOV:y})}let c=({chapterId:p,action:h,branches:y=[]})=>{let x=r.emit.bind(r,R.interactives,{subjectId:p,subjectName:"chapter",type:j.actionChoice,actionType:h.type,payload:h.args}),C=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case k.setNextBranch.trim().toLowerCase():{let v=y.find(S=>S.id===h.args.branchId);return v!=null&&v.chapterId?(x(),C(),O.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case k.setWeightlessRandomBranch.trim().toLowerCase():{let v=bo(y);return v!=null&&v.chapterId?(x(),C(),O.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case k.setRandomBranch.trim().toLowerCase():{let v=go(y);return v!=null&&v.chapterId?(x(),C(),O.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case k.setMaxWeightBranch.trim().toLowerCase():{let v=vo(y);return v!=null&&v.chapterId?(x(),C(),O.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case k.setMinWeightBranch.trim().toLowerCase():{let v=yo(y);return v!=null&&v.chapterId?(x(),C(),O.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case k.continuePlayback.trim().toLowerCase():return x(),C(),P.bind(null,{subjectId:p,subjectName:"chapter",action:h});case k.openURI.trim().toLowerCase():return x(),C(),V.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let v="Unexpected chapter event",S=new N(1,1,{message:v});f(S,v);return}}};function f(p,h){console.error(h),e.error$.next(p),r.emit(R.errors,p)}function b(p){var y;let h=Br(p.events);if(h){if(J(p))return;r.emit(R.interactives,{subjectId:p.id,subjectName:"chapter",type:j.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:k.expect,action:m.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(y=p.events)==null||y.forEach(x=>{let C=c({chapterId:p.id,action:x.action,branches:p.branches});C&&i.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:x.action.type,action:C})})}let m=({subjectId:p,subjectName:h})=>{t.pause(),r.emit(R.interactives,{subjectId:p,subjectName:h,type:j.actionExecution,actionType:k.expect}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:k.expect})},I=({subjectId:p,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(R.interactives,{subjectId:p,subjectName:h,type:j.actionExecution,actionType:Eo}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:Eo})},P=({subjectId:p,subjectName:h,subjectType:y,action:x})=>{r.emit(R.interactives,{subjectId:p,subjectName:h,subjectType:y,type:j.actionExecution,actionType:x.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:y,type:"action-execution",actionType:x.type})},O=({subjectId:p,subjectName:h,subjectType:y,action:x,payload:C})=>{C.behaviour="change-chapter",r.emit(R.interactives,{subjectId:p,subjectName:h,subjectType:y,type:j.actionExecution,actionType:x.type,payload:C}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:y,type:"action-execution",actionType:x.type,payload:C})},g=({subjectId:p,subjectName:h,subjectType:y,action:x,payload:C})=>{C.behaviour="change-manifest",r.emit(R.interactives,{subjectId:p,subjectName:h,subjectType:y,type:j.actionExecution,actionType:x.type,payload:C}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:y,type:"action-execution",actionType:x.type,payload:C})},V=({subjectId:p,subjectName:h,subjectType:y,action:x,payload:C})=>{if(!C.URI)return;let v=window.open(C.URI,"_blank","noopener,noreferrer");v&&(v.opener=null),r.emit(R.interactives,{subjectId:p,subjectName:h,subjectType:y,type:j.actionExecution,actionType:x.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:y,type:"action-execution",actionType:x.type})};return{onControlEvent:o,onContainerEvent:l,onChapterEvent:c,onExpectEvent:m,expectEventHandler:I,setManifestChapterEvents:b,setManifestContainerEvents:s,stopExpect:a,state:n}};var ri=te(Vr(),1);import{Subscription as Jp,Subject as ti,ValueSubject as Ze}from"@vkontakte/videoplayer-shared/es2015";var ei=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(o=>o.id===i);if(!n)return null;let a=e.media.videos.find(o=>n.videoId===o.id);if(!a)return null;t[i]=So(a)}return t[i]}).filter(Boolean)},Yp=r=>{for(let e of r.variants)if(Xp(e)&&e.payload)return e.payload.id},Xp=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),So=r=>{let e=Yp(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Zp=(r,e)=>{for(let t of r.media.videos)if(e===So(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},wo=(r,e)=>r.reduce((t,i)=>{let n=Zp(e,i);return n?[...t,n]:t},[]);var ie,he,de,W,Dt,ne,ae,ee,fe,Re,Pe,Je=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:a}){this.state={history$:new Ze([]),hasPrevChapter$:new Ze(!1),prevChapter$:new Ze(null),isInitialChapter$:new Ze(!1),isGoBackLimited$:new Ze(!1)};G(this,ie,null);G(this,he);G(this,de,!1);G(this,W,null);G(this,Dt,null);this.events={inited$:new ti,destroyed$:new ti,error$:new ti};G(this,ne,null);G(this,ae,null);G(this,ee,null);G(this,fe,new Jp);G(this,Re,!1);G(this,Pe,0);var o;$(this,ne,t),$(this,ee,e),$(this,ae,i),$(this,ie,n),$(this,he,a),this.state.history$&&T(this,fe)&&((o=T(this,fe))==null||o.add(this.state.history$.subscribe(l=>{var s,c;this.state.prevChapter$.next((0,ri.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(s=T(this,W))==null?void 0:s.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(T(this,Pe)===T(this,he).maxLength-1)})))}setManifest(e){return A(this,null,function*(){if(!T(this,ae)||!T(this,ee))return;$(this,W,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield T(this,ae).setChapter({chapterId:t,pushToHistory:!1}),T(this,de)||($(this,de,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return T(this,de)}updateHistory(e,t=!0){return A(this,null,function*(){var l;if(!T(this,W))return;T(this,Re)?($(this,Re,!1),mi(this,Pe)._++):$(this,Pe,0);let i=T(this,W),n=e.length-T(this,he).maxLength,a=n>0?e.slice(n):e,o=ei(a,i);if($(this,Dt,o),this.state.history$.next(a),!(!t||!T(this,ie)||!T(this,ne)))try{yield T(this,ie).save(T(this,ne),o)}catch(s){let c=new N(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=T(this,ee))==null||l.emit(R.errors,c)}})}goBack(){return A(this,null,function*(){var i;if(!this.state||!T(this,ae)){let n=new N(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=T(this,ee))==null?void 0:i.emit(R.errors,n)}$(this,Re,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield T(this,ae).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return A(this,null,function*(){var n;if(!T(this,W)||!T(this,ne))return;let e=T(this,W),t=[this.getInitialVideoId()];if(T(this,ie))try{let a=yield T(this,ie).get(T(this,ne));a.length&&(t=a)}catch(a){let o=new N(1,5,"Error while trying to fetch data");this.events.error$.next(o),(n=T(this,ee))==null||n.emit(R.errors,o)}let i=wo(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,ri.default)(e,-1)||T(this,he).initChapterId||((t=T(this,W))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(T(this,W)){let e=this.getInitialChapterId();return ei([e],T(this,W)).pop()}return null}destroy(){var e,t;$(this,ne,null),$(this,ie,null),$(this,ae,null),(e=T(this,fe))==null||e.unsubscribe(),$(this,fe,null),$(this,de,!1),(t=T(this,ee))==null||t.emit(R.historyDestroyed),this.events.destroyed$.next(),$(this,ee,null)}};ie=new WeakMap,he=new WeakMap,de=new WeakMap,W=new WeakMap,Dt=new WeakMap,ne=new WeakMap,ae=new WeakMap,ee=new WeakMap,fe=new WeakMap,Re=new WeakMap,Pe=new WeakMap;var Ht=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 a=3;a<i;a+=40)if(t[a]!==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 A(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 A(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 Gt=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 _o=Object.create;var Kt=Object.defineProperty,Fo=Object.defineProperties,qo=Object.getOwnPropertyDescriptor,Bo=Object.getOwnPropertyDescriptors,Do=Object.getOwnPropertyNames,it=Object.getOwnPropertySymbols,Ho=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty,mn=Object.prototype.propertyIsEnumerable;var yn=r=>{throw TypeError(r)};var fn=(r,e,t)=>e in r?Kt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,d=(r,e)=>{for(var t in e||(e={}))Qt.call(e,t)&&fn(r,t,e[t]);if(it)for(var t of it(e))mn.call(e,t)&&fn(r,t,e[t]);return r},E=(r,e)=>Fo(r,Bo(e));var Z=(r,e)=>{var t={};for(var n in r)Qt.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&it)for(var n of it(r))e.indexOf(n)<0&&mn.call(r,n)&&(t[n]=r[n]);return t};var u=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Go=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Do(e))!Qt.call(r,i)&&i!==t&&Kt(r,i,{get:()=>e[i],enumerable:!(n=qo(e,i))||n.enumerable});return r};var re=(r,e,t)=>(t=r!=null?_o(Ho(r)):{},Go(e||!r||!r.__esModule?Kt(t,"default",{value:r,enumerable:!0}):t,r));var vn=(r,e,t)=>e.has(r)||yn("Cannot "+t);var T=(r,e,t)=>(vn(r,e,"read from private field"),t?t.call(r):e.get(r)),G=(r,e,t)=>e.has(r)?yn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),$=(r,e,t,n)=>(vn(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var bn=(r,e,t,n)=>({set _(i){$(r,e,i,t)},get _(){return T(r,e,n)}});var A=(r,e,t)=>new Promise((n,i)=>{var s=a=>{try{l(t.next(a))}catch(c){i(c)}},o=a=>{try{l(t.throw(a))}catch(c){i(c)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,o);l((t=t.apply(r,e)).next())});var J=u((ir,An)=>{"use strict";var Ve=function(r){return r&&r.Math===Math&&r};An.exports=Ve(typeof globalThis=="object"&&globalThis)||Ve(typeof window=="object"&&window)||Ve(typeof self=="object"&&self)||Ve(typeof global=="object"&&global)||Ve(typeof ir=="object"&&ir)||function(){return this}()||Function("return this")()});var z=u((hd,On)=>{"use strict";On.exports=function(r){try{return!!r()}catch(e){return!0}}});var Me=u((dd,Rn)=>{"use strict";var Uo=z();Rn.exports=!Uo(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Ln=u((fd,Mn)=>{"use strict";var zo=Me(),Vn=Function.prototype,Pn=Vn.apply,kn=Vn.call;Mn.exports=typeof Reflect=="object"&&Reflect.apply||(zo?kn.bind(Pn):function(){return kn.apply(Pn,arguments)})});var Q=u((md,$n)=>{"use strict";var Nn=Me(),jn=Function.prototype,sr=jn.call,Wo=Nn&&jn.bind.bind(sr,sr);$n.exports=Nn?Wo:function(r){return function(){return sr.apply(r,arguments)}}});var Le=u((yd,Fn)=>{"use strict";var _n=Q(),Ko=_n({}.toString),Qo=_n("".slice);Fn.exports=function(r){return Qo(Ko(r),8,-1)}});var ar=u((vd,qn)=>{"use strict";var Xo=Le(),Yo=Q();qn.exports=function(r){if(Xo(r)==="Function")return Yo(r)}});var W=u((bd,Bn)=>{"use strict";var or=typeof document=="object"&&document.all;Bn.exports=typeof or=="undefined"&&or!==void 0?function(r){return typeof r=="function"||r===or}:function(r){return typeof r=="function"}});var ce=u((Cd,Dn)=>{"use strict";var Zo=z();Dn.exports=!Zo(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var mt=u((gd,Hn)=>{"use strict";var Jo=Me(),ft=Function.prototype.call;Hn.exports=Jo?ft.bind(ft):function(){return ft.apply(ft,arguments)}});var lr=u(zn=>{"use strict";var Gn={}.propertyIsEnumerable,Un=Object.getOwnPropertyDescriptor,el=Un&&!Gn.call({1:2},1);zn.f=el?function(e){var t=Un(this,e);return!!t&&t.enumerable}:Gn});var cr=u((Id,Wn)=>{"use strict";Wn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Qn=u((xd,Kn)=>{"use strict";var tl=Q(),rl=z(),nl=Le(),ur=Object,il=tl("".split);Kn.exports=rl(function(){return!ur("z").propertyIsEnumerable(0)})?function(r){return nl(r)==="String"?il(r,""):ur(r)}:ur});var pr=u((Td,Xn)=>{"use strict";Xn.exports=function(r){return r==null}});var hr=u((Sd,Yn)=>{"use strict";var sl=pr(),al=TypeError;Yn.exports=function(r){if(sl(r))throw new al("Can't call method on "+r);return r}});var Ne=u((wd,Zn)=>{"use strict";var ol=Qn(),ll=hr();Zn.exports=function(r){return ol(ll(r))}});var Ee=u((Ad,Jn)=>{"use strict";var cl=W();Jn.exports=function(r){return typeof r=="object"?r!==null:cl(r)}});var yt=u((Od,ei)=>{"use strict";ei.exports={}});var vt=u((Rd,ri)=>{"use strict";var dr=yt(),fr=J(),ul=W(),ti=function(r){return ul(r)?r:void 0};ri.exports=function(r,e){return arguments.length<2?ti(dr[r])||ti(fr[r]):dr[r]&&dr[r][e]||fr[r]&&fr[r][e]}});var ii=u((Pd,ni)=>{"use strict";var pl=Q();ni.exports=pl({}.isPrototypeOf)});var li=u((kd,oi)=>{"use strict";var hl=J(),si=hl.navigator,ai=si&&si.userAgent;oi.exports=ai?String(ai):""});var mi=u((Vd,fi)=>{"use strict";var di=J(),mr=li(),ci=di.process,ui=di.Deno,pi=ci&&ci.versions||ui&&ui.version,hi=pi&&pi.v8,X,bt;hi&&(X=hi.split("."),bt=X[0]>0&&X[0]<4?1:+(X[0]+X[1]));!bt&&mr&&(X=mr.match(/Edge\/(\d+)/),(!X||X[1]>=74)&&(X=mr.match(/Chrome\/(\d+)/),X&&(bt=+X[1])));fi.exports=bt});var yr=u((Md,vi)=>{"use strict";var yi=mi(),dl=z(),fl=J(),ml=fl.String;vi.exports=!!Object.getOwnPropertySymbols&&!dl(function(){var r=Symbol("symbol detection");return!ml(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&yi&&yi<41})});var vr=u((Ld,bi)=>{"use strict";var yl=yr();bi.exports=yl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var br=u((Nd,Ci)=>{"use strict";var vl=vt(),bl=W(),Cl=ii(),gl=vr(),El=Object;Ci.exports=gl?function(r){return typeof r=="symbol"}:function(r){var e=vl("Symbol");return bl(e)&&Cl(e.prototype,El(r))}});var Ei=u((jd,gi)=>{"use strict";var Il=String;gi.exports=function(r){try{return Il(r)}catch(e){return"Object"}}});var Cr=u(($d,Ii)=>{"use strict";var xl=W(),Tl=Ei(),Sl=TypeError;Ii.exports=function(r){if(xl(r))return r;throw new Sl(Tl(r)+" is not a function")}});var Ti=u((_d,xi)=>{"use strict";var wl=Cr(),Al=pr();xi.exports=function(r,e){var t=r[e];return Al(t)?void 0:wl(t)}});var wi=u((Fd,Si)=>{"use strict";var gr=mt(),Er=W(),Ir=Ee(),Ol=TypeError;Si.exports=function(r,e){var t,n;if(e==="string"&&Er(t=r.toString)&&!Ir(n=gr(t,r))||Er(t=r.valueOf)&&!Ir(n=gr(t,r))||e!=="string"&&Er(t=r.toString)&&!Ir(n=gr(t,r)))return n;throw new Ol("Can't convert object to primitive value")}});var Oi=u((qd,Ai)=>{"use strict";Ai.exports=!0});var ki=u((Bd,Pi)=>{"use strict";var Ri=J(),Rl=Object.defineProperty;Pi.exports=function(r,e){try{Rl(Ri,r,{value:e,configurable:!0,writable:!0})}catch(t){Ri[r]=e}return e}});var Ct=u((Dd,Li)=>{"use strict";var Pl=Oi(),kl=J(),Vl=ki(),Vi="__core-js_shared__",Mi=Li.exports=kl[Vi]||Vl(Vi,{});(Mi.versions||(Mi.versions=[])).push({version:"3.38.0",mode:Pl?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var xr=u((Hd,ji)=>{"use strict";var Ni=Ct();ji.exports=function(r,e){return Ni[r]||(Ni[r]=e||{})}});var je=u((Gd,$i)=>{"use strict";var Ml=hr(),Ll=Object;$i.exports=function(r){return Ll(Ml(r))}});var Ie=u((Ud,_i)=>{"use strict";var Nl=Q(),jl=je(),$l=Nl({}.hasOwnProperty);_i.exports=Object.hasOwn||function(e,t){return $l(jl(e),t)}});var Tr=u((zd,Fi)=>{"use strict";var _l=Q(),Fl=0,ql=Math.random(),Bl=_l(1 .toString);Fi.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Bl(++Fl+ql,36)}});var $e=u((Wd,Bi)=>{"use strict";var Dl=J(),Hl=xr(),qi=Ie(),Gl=Tr(),Ul=yr(),zl=vr(),xe=Dl.Symbol,Sr=Hl("wks"),Wl=zl?xe.for||xe:xe&&xe.withoutSetter||Gl;Bi.exports=function(r){return qi(Sr,r)||(Sr[r]=Ul&&qi(xe,r)?xe[r]:Wl("Symbol."+r)),Sr[r]}});var Ui=u((Kd,Gi)=>{"use strict";var Kl=mt(),Di=Ee(),Hi=br(),Ql=Ti(),Xl=wi(),Yl=$e(),Zl=TypeError,Jl=Yl("toPrimitive");Gi.exports=function(r,e){if(!Di(r)||Hi(r))return r;var t=Ql(r,Jl),n;if(t){if(e===void 0&&(e="default"),n=Kl(t,r,e),!Di(n)||Hi(n))return n;throw new Zl("Can't convert object to primitive value")}return e===void 0&&(e="number"),Xl(r,e)}});var wr=u((Qd,zi)=>{"use strict";var ec=Ui(),tc=br();zi.exports=function(r){var e=ec(r,"string");return tc(e)?e:e+""}});var Qi=u((Xd,Ki)=>{"use strict";var rc=J(),Wi=Ee(),Ar=rc.document,nc=Wi(Ar)&&Wi(Ar.createElement);Ki.exports=function(r){return nc?Ar.createElement(r):{}}});var Or=u((Yd,Xi)=>{"use strict";var ic=ce(),sc=z(),ac=Qi();Xi.exports=!ic&&!sc(function(){return Object.defineProperty(ac("div"),"a",{get:function(){return 7}}).a!==7})});var Ji=u(Zi=>{"use strict";var oc=ce(),lc=mt(),cc=lr(),uc=cr(),pc=Ne(),hc=wr(),dc=Ie(),fc=Or(),Yi=Object.getOwnPropertyDescriptor;Zi.f=oc?Yi:function(e,t){if(e=pc(e),t=hc(t),fc)try{return Yi(e,t)}catch(n){}if(dc(e,t))return uc(!lc(cc.f,e,t),e[t])}});var ts=u((Jd,es)=>{"use strict";var mc=z(),yc=W(),vc=/#|\.prototype\./,_e=function(r,e){var t=Cc[bc(r)];return t===Ec?!0:t===gc?!1:yc(e)?mc(e):!!e},bc=_e.normalize=function(r){return String(r).replace(vc,".").toLowerCase()},Cc=_e.data={},gc=_e.NATIVE="N",Ec=_e.POLYFILL="P";es.exports=_e});var Rr=u((ef,ns)=>{"use strict";var rs=ar(),Ic=Cr(),xc=Me(),Tc=rs(rs.bind);ns.exports=function(r,e){return Ic(r),e===void 0?r:xc?Tc(r,e):function(){return r.apply(e,arguments)}}});var ss=u((tf,is)=>{"use strict";var Sc=ce(),wc=z();is.exports=Sc&&wc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var os=u((rf,as)=>{"use strict";var Ac=Ee(),Oc=String,Rc=TypeError;as.exports=function(r){if(Ac(r))return r;throw new Rc(Oc(r)+" is not an object")}});var us=u(cs=>{"use strict";var Pc=ce(),kc=Or(),Vc=ss(),gt=os(),ls=wr(),Mc=TypeError,Pr=Object.defineProperty,Lc=Object.getOwnPropertyDescriptor,kr="enumerable",Vr="configurable",Mr="writable";cs.f=Pc?Vc?function(e,t,n){if(gt(e),t=ls(t),gt(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Mr in n&&!n[Mr]){var i=Lc(e,t);i&&i[Mr]&&(e[t]=n.value,n={configurable:Vr in n?n[Vr]:i[Vr],enumerable:kr in n?n[kr]:i[kr],writable:!1})}return Pr(e,t,n)}:Pr:function(e,t,n){if(gt(e),t=ls(t),gt(n),kc)try{return Pr(e,t,n)}catch(i){}if("get"in n||"set"in n)throw new Mc("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var hs=u((sf,ps)=>{"use strict";var Nc=ce(),jc=us(),$c=cr();ps.exports=Nc?function(r,e,t){return jc.f(r,e,$c(1,t))}:function(r,e,t){return r[e]=t,r}});var qe=u((af,fs)=>{"use strict";var Fe=J(),_c=Ln(),Fc=ar(),qc=W(),Bc=Ji().f,Dc=ts(),Te=yt(),Hc=Rr(),Se=hs(),ds=Ie();Ct();var Gc=function(r){var e=function(t,n,i){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,n)}return new r(t,n,i)}return _c(r,this,arguments)};return e.prototype=r.prototype,e};fs.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,s=r.proto,o=n?Fe:i?Fe[t]:Fe[t]&&Fe[t].prototype,l=n?Te:Te[t]||Se(Te,t,{})[t],a=l.prototype,c,f,b,m,I,R,P,C,V;for(m in e)c=Dc(n?m:t+(i?".":"#")+m,r.forced),f=!c&&o&&ds(o,m),R=l[m],f&&(r.dontCallGetSet?(V=Bc(o,m),P=V&&V.value):P=o[m]),I=f&&P?P:e[m],!(!c&&!s&&typeof R==typeof I)&&(r.bind&&f?C=Hc(I,Fe):r.wrap&&f?C=Gc(I):s&&qc(I)?C=Fc(I):C=I,(r.sham||I&&I.sham||R&&R.sham)&&Se(C,"sham",!0),Se(l,m,C),s&&(b=t+"Prototype",ds(Te,b)||Se(Te,b,{}),Se(Te[b],m,I),r.real&&a&&(c||!a[m])&&Se(a,m,I)))}});var ys=u((of,ms)=>{"use strict";var Uc=Math.ceil,zc=Math.floor;ms.exports=Math.trunc||function(e){var t=+e;return(t>0?zc:Uc)(t)}});var Be=u((lf,vs)=>{"use strict";var Wc=ys();vs.exports=function(r){var e=+r;return e!==e||e===0?0:Wc(e)}});var Cs=u((cf,bs)=>{"use strict";var Kc=Be(),Qc=Math.min;bs.exports=function(r){var e=Kc(r);return e>0?Qc(e,9007199254740991):0}});var De=u((uf,gs)=>{"use strict";var Xc=Cs();gs.exports=function(r){return Xc(r.length)}});var Et=u((pf,Es)=>{"use strict";Es.exports=function(){}});var Is=u(()=>{"use strict";var Yc=qe(),Zc=je(),Jc=De(),eu=Be(),tu=Et();Yc({target:"Array",proto:!0},{at:function(e){var t=Zc(this),n=Jc(t),i=eu(e),s=i>=0?i:n+i;return s<0||s>=n?void 0:t[s]}});tu("at")});var It=u((ff,xs)=>{"use strict";var ru=vt();xs.exports=ru});var Ss=u((mf,Ts)=>{"use strict";Is();var nu=It();Ts.exports=nu("Array","at")});var As=u((yf,ws)=>{"use strict";var iu=Ss();ws.exports=iu});var Lr=u((vf,Os)=>{"use strict";var su=As();Os.exports=su});var Hs=u((Lm,Ds)=>{"use strict";var mu=xr(),yu=Tr(),Bs=mu("keys");Ds.exports=function(r){return Bs[r]||(Bs[r]=yu(r))}});var Us=u((Nm,Gs)=>{"use strict";var vu=z();Gs.exports=!vu(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Ks=u((jm,Ws)=>{"use strict";var bu=Ie(),Cu=W(),gu=je(),Eu=Hs(),Iu=Us(),zs=Eu("IE_PROTO"),Gr=Object,xu=Gr.prototype;Ws.exports=Iu?Gr.getPrototypeOf:function(r){var e=gu(r);if(bu(e,zs))return e[zs];var t=e.constructor;return Cu(t)&&e instanceof t?t.prototype:e instanceof Gr?xu:null}});var Xs=u(($m,Qs)=>{"use strict";var Tu=Be(),Su=Math.max,wu=Math.min;Qs.exports=function(r,e){var t=Tu(r);return t<0?Su(t+e,0):wu(t,e)}});var Ur=u((_m,Zs)=>{"use strict";var Au=Ne(),Ou=Xs(),Ru=De(),Ys=function(r){return function(e,t,n){var i=Au(e),s=Ru(i);if(s===0)return!r&&-1;var o=Ou(n,s),l;if(r&&t!==t){for(;s>o;)if(l=i[o++],l!==l)return!0}else for(;s>o;o++)if((r||o in i)&&i[o]===t)return r||o||0;return!r&&-1}};Zs.exports={includes:Ys(!0),indexOf:Ys(!1)}});var ea=u((Fm,Js)=>{"use strict";Js.exports={}});var na=u((qm,ra)=>{"use strict";var Pu=Q(),zr=Ie(),ku=Ne(),Vu=Ur().indexOf,Mu=ea(),ta=Pu([].push);ra.exports=function(r,e){var t=ku(r),n=0,i=[],s;for(s in t)!zr(Mu,s)&&zr(t,s)&&ta(i,s);for(;e.length>n;)zr(t,s=e[n++])&&(~Vu(i,s)||ta(i,s));return i}});var sa=u((Bm,ia)=>{"use strict";ia.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var oa=u((Dm,aa)=>{"use strict";var Lu=na(),Nu=sa();aa.exports=Object.keys||function(e){return Lu(e,Nu)}});var da=u((Hm,ha)=>{"use strict";var ca=ce(),ju=z(),ua=Q(),$u=Ks(),_u=oa(),Fu=Ne(),qu=lr().f,pa=ua(qu),Bu=ua([].push),Du=ca&&ju(function(){var r=Object.create(null);return r[2]=2,!pa(r,2)}),la=function(r){return function(e){for(var t=Fu(e),n=_u(t),i=Du&&$u(t)===null,s=n.length,o=0,l=[],a;s>o;)a=n[o++],(!ca||(i?a in t:pa(t,a)))&&Bu(l,r?[a,t[a]]:t[a]);return l}};ha.exports={entries:la(!0),values:la(!1)}});var fa=u(()=>{"use strict";var Hu=qe(),Gu=da().values;Hu({target:"Object",stat:!0},{values:function(e){return Gu(e)}})});var ya=u((zm,ma)=>{"use strict";fa();var Uu=yt();ma.exports=Uu.Object.values});var ba=u((Wm,va)=>{"use strict";var zu=ya();va.exports=zu});var _t=u((Km,Ca)=>{"use strict";var Wu=ba();Ca.exports=Wu});var Ia=u(()=>{"use strict";var Ku=qe(),Qu=Ur().includes,Xu=z(),Yu=Et(),Zu=Xu(function(){return!Array(1).includes()});Ku({target:"Array",proto:!0,forced:Zu},{includes:function(e){return Qu(this,e,arguments.length>1?arguments[1]:void 0)}});Yu("includes")});var Ta=u((ey,xa)=>{"use strict";Ia();var Ju=It();xa.exports=Ju("Array","includes")});var wa=u((ty,Sa)=>{"use strict";var ep=Ta();Sa.exports=ep});var Ft=u((ry,Aa)=>{"use strict";var tp=wa();Aa.exports=tp});var Yr=u((Iy,Va)=>{"use strict";var op=Le();Va.exports=Array.isArray||function(e){return op(e)==="Array"}});var La=u((xy,Ma)=>{"use strict";var lp=TypeError,cp=9007199254740991;Ma.exports=function(r){if(r>cp)throw lp("Maximum allowed index exceeded");return r}});var $a=u((Ty,ja)=>{"use strict";var up=Yr(),pp=De(),hp=La(),dp=Rr(),Na=function(r,e,t,n,i,s,o,l){for(var a=i,c=0,f=o?dp(o,l):!1,b,m;c<n;)c in t&&(b=f?f(t[c],c,e):t[c],s>0&&up(b)?(m=pp(b),a=Na(r,e,b,m,a,s-1)-1):(hp(a+1),r[a]=b),a++),c++;return a};ja.exports=Na});var qa=u((Sy,Fa)=>{"use strict";var fp=$e(),mp=fp("toStringTag"),_a={};_a[mp]="z";Fa.exports=String(_a)==="[object z]"});var Da=u((wy,Ba)=>{"use strict";var yp=qa(),vp=W(),Bt=Le(),bp=$e(),Cp=bp("toStringTag"),gp=Object,Ep=Bt(function(){return arguments}())==="Arguments",Ip=function(r,e){try{return r[e]}catch(t){}};Ba.exports=yp?Bt:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=Ip(e=gp(r),Cp))=="string"?t:Ep?Bt(e):(n=Bt(e))==="Object"&&vp(e.callee)?"Arguments":n}});var Ga=u((Ay,Ha)=>{"use strict";var xp=Q(),Tp=W(),Zr=Ct(),Sp=xp(Function.toString);Tp(Zr.inspectSource)||(Zr.inspectSource=function(r){return Sp(r)});Ha.exports=Zr.inspectSource});var Xa=u((Oy,Qa)=>{"use strict";var wp=Q(),Ap=z(),Ua=W(),Op=Da(),Rp=vt(),Pp=Ga(),za=function(){},Wa=Rp("Reflect","construct"),Jr=/^\s*(?:class|function)\b/,kp=wp(Jr.exec),Vp=!Jr.test(za),Je=function(e){if(!Ua(e))return!1;try{return Wa(za,[],e),!0}catch(t){return!1}},Ka=function(e){if(!Ua(e))return!1;switch(Op(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Vp||!!kp(Jr,Pp(e))}catch(t){return!0}};Ka.sham=!0;Qa.exports=!Wa||Ap(function(){var r;return Je(Je.call)||!Je(Object)||!Je(function(){r=!0})||r})?Ka:Je});var eo=u((Ry,Ja)=>{"use strict";var Ya=Yr(),Mp=Xa(),Lp=Ee(),Np=$e(),jp=Np("species"),Za=Array;Ja.exports=function(r){var e;return Ya(r)&&(e=r.constructor,Mp(e)&&(e===Za||Ya(e.prototype))?e=void 0:Lp(e)&&(e=e[jp],e===null&&(e=void 0))),e===void 0?Za:e}});var ro=u((Py,to)=>{"use strict";var $p=eo();to.exports=function(r,e){return new($p(r))(e===0?0:e)}});var no=u(()=>{"use strict";var _p=qe(),Fp=$a(),qp=je(),Bp=De(),Dp=Be(),Hp=ro();_p({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=qp(this),n=Bp(t),i=Hp(t,0);return i.length=Fp(i,t,t,n,0,e===void 0?1:Dp(e)),i}})});var io=u(()=>{"use strict";var Gp=Et();Gp("flat")});var ao=u((Ny,so)=>{"use strict";no();io();var Up=It();so.exports=Up("Array","flat")});var lo=u((jy,oo)=>{"use strict";var zp=ao();oo.exports=zp});var uo=u(($y,co)=>{"use strict";var Wp=lo();co.exports=Wp});var Cn="1.0.31-dev.a8108f50.0";var Xt=class{constructor(e){this.layout=e}},st=class extends Xt{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};function gn(r){return"features"in r}var be=class{constructor(e,t){this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&gn(this.options)&&this.options.features[e]}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,n)=>{let i=n.type.trim().toLowerCase(),s=this.factories.get(i);if(s){let o=s(n,this.options);if(o)return[...t,o]}return[...t]},[]))||[]}};function Yt(r,e=1){let t="0",n="0",i="0";return r.length===4?(t="0x"+r[1]+r[1],n="0x"+r[2]+r[2],i="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],n="0x"+r[3]+r[4],i="0x"+r[5]+r[6]),`rgba(${+t},${+n},${+i},${e})`}var En="interactive",F={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},In=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(In||{}),xn=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(xn||{}),Tn=(n=>(n.start="left",n.end="right",n.center="center",n))(Tn||{}),at=({target:r,props:e})=>{var t,n,i;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&In[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(n=(e==null?void 0:e.gravityHorizontal)&&xn[e.gravityHorizontal])!=null?n:"center",r.style.textAlign=(i=(e==null?void 0:e.alignment)&&Tn[e.alignment])!=null?i:"center"},ot=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,s,o,l,a,c;r.style.color=(s=(i=e==null?void 0:e.text)==null?void 0:i.color)!=null?s:t.textColor,r.style.fontSize=`calc(${n.height} * ${(l=(o=e==null?void 0:e.text)==null?void 0:o.size)!=null?l:t.textSize})`,r.textContent=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},lt=({target:r,props:e,fallback:t})=>{var n,i,s,o;r.style.backgroundColor=Yt((i=(n=e==null?void 0:e.background)==null?void 0:n.color)!=null?i:t.backgroundColor,(o=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?o:t.backgroundAlpha)},ct=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,s,o,l,a,c,f,b,m,I,R;r.style.border=`calc(${n.height} * ${(o=(s=(i=e==null?void 0:e.shape)==null?void 0:i.border)==null?void 0:s.width)!=null?o:t.borderWidth}) solid ${Yt((c=(a=(l=e==null?void 0:e.shape)==null?void 0:l.border)==null?void 0:a.color)!=null?c:t.borderColor,(m=(b=(f=e==null?void 0:e.shape)==null?void 0:f.border)==null?void 0:b.alpha)!=null?m:t.borderAlpha)}`,r.style.borderRadius=`calc(${n.height} * ${(R=(I=e==null?void 0:e.shape)==null?void 0:I.roundCorners)!=null?R:t.roundCorners})`},Ce=({target:r,layoutParams:e,fallback:t})=>{var i;let n=(i=e.angle)!=null?i:t.angle;n=n&&n*-1,r.style.transform=`rotate(${n}rad)`};var Zt="int",le=(n=>(n.AREA=`${Zt}_area`,n.TEXT=`${Zt}_text`,n.BUTTON=`${Zt}_bttn`,n))(le||{});function Sn(r){return"features"in r}var ge="interactive-control",N={common:ge,wrapper:`${ge}-wrapper`,disabled:`${ge}-disabled`,button:`${ge}-button`,area:`${ge}-area`,text:`${ge}-text`};var ae=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){var i;let t=document.createElement("div");t.classList.add(N.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=((i=this.control.layoutParams.innerSizesDependOn)!=null?i:F.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:n}}createClickListener(e){return t=>{t.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&Sn(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var i;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(i=this.container)==null||i.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){var e,t;(e=this.container)!=null&&e.element&&this.clickListener&&((t=this.container)==null||t.element.removeEventListener("click",this.clickListener))}};var ut=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Jt(r,e)},Jt=class extends ae{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(N.common,N.area),n.setAttribute("data-testid",le.AREA),lt({target:n,props:this.control.props,fallback:E(d({},F),{backgroundColor:"transparent"})}),ct({target:n,props:this.control.props,fallback:E(d({},F),{borderAlpha:0}),dependsOn:this.container.dimensions}),Ce({target:n,layoutParams:this.control.layoutParams,fallback:F}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(N.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(N.disabled)}getElement(){return this.controlElement}};var pt=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,n),t.append(e);let i={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,i),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=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new er(r,e)},er=class extends ae{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var o;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(N.common,N.button),n.setAttribute("data-testid",le.BUTTON),Ce({target:n,layoutParams:this.control.layoutParams,fallback:F}),lt({target:n,props:this.control.props,fallback:F}),ct({target:n,props:this.control.props,fallback:F,dependsOn:this.container.dimensions}),at({target:n,props:E(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=pt(this.control.type.trim().toLowerCase()),s=(o=i.firstElementChild)!=null?o:i;ot({target:s,props:this.control.props,fallback:F,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(N.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(N.disabled)}getElement(){return this.controlElement}};var wn=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new tr(r,e)},tr=class extends ae{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var o;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(N.common,N.text),n.setAttribute("data-testid",le.TEXT),Ce({target:n,layoutParams:this.control.layoutParams,fallback:F}),at({target:n,props:E(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=pt(this.control.type.trim().toLowerCase()),s=(o=i.firstElementChild)!=null?o:i;ot({target:s,props:this.control.props,fallback:F,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){}enable(){}getElement(){return this.controlElement}};var rr="interactive-container",U={common:rr,hidden:`${rr}-hidden`,disabled:`${rr}-disabled`};var dt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new nr(r,e,t)},nr=class extends be{constructor(t,n,i){super(t,i);this.containerElement=null;this.rootElement=n,this.layout=new st(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",ht),this.addControlFactory("text",wn),this.addControlFactory("area",ut)}createView({eventCallback:t}){let n=document.createElement("div");return n.classList.add(U.common,U.disabled),requestAnimationFrame(()=>{n.classList.remove(U.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(i=>{i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),i.setEvents(t)}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let t=this.getElement();t&&t.classList.add(U.hidden)}show(){let t=this.getElement();t&&t.classList.remove(U.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(U.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(U.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(this.controls.forEach(n=>n.removeListeners()),t.remove(),this.isRemoved=!0)}getElement(){return this.containerElement}};var jo=re(Lr(),1);import{clientChecker as ah,combine as oh,InterfaceLanguage as lh,Observable as Mo,once as ch,Subject as D,Subscription as an,ValueSubject as H,fromEvent as Lo}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as rt}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as au}from"@vkontakte/videoplayer-shared/es2015";function He(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var ue=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Ge=r=>ue(r,"Object"),xt=r=>ue(r,"String"),Tt=r=>ue(r,"Array"),St=r=>ue(r,"Number"),Rs=r=>ue(r,"Function");var Nr=r=>St(r)&&!isNaN(r);var pe=r=>Ge(r)&&Object.keys(r).length===0,jr=r=>Tt(r)&&!r.length;var Ue=(r,e)=>xt(r)&&(e?r.trim():r).length;var Ps="video_interactive",ks="videoint";var Vs=250,ze=class{constructor(e){this.handleZoomChange=He(e=>{this.lastZoomInfo=e},Vs);this.onResize=e=>{var n;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((n=this.ngEditor)==null||n.zoomTo(t)),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,n,i;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(e.id),(n=this.ngEditor)==null||n.selectChapter(e.id),(i=this.ngEditor)==null||i.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var n;if(this.isReady=!1,!St(e.graph.edit.chapters[0].x)){(n=this.onError)==null||n.call(this,"Can't show graph"),console.error("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:n,lang:i,visitedChapters:s=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=t,this.onError=n,this.lang=i!=null?i:"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=ou(e),this.resizeObserver=new ResizeObserver(He(this.onResize,Vs)),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 A(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 A(this,null,function*(){if(!this.manifest)return;let e;try{e=yield au(this.lang,Ps,ks)}catch(n){console.log("Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",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",s=>{var o=s,{name:n}=o,i=Z(o,["name"]);var l;n==="openPreview"&&"chapterId"in i&&((l=this.onOpenPreviewClick)==null||l.call(this,i.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 ou(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 We=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,n=!1,i=Math.round(this._player.info.position$.getValue()*1e3);for(let s of this._containers){let o=s.startTime-e;if(o<=i&&(s.endTime&&i<=s.endTime||s.endTime===null)){n=!0;break}i<o&&(t=t===-1?o:Math.min(t,o))}return!n&&t!==-1?t:null}}};import{isSupportedManifest as At,ContainerTypes as Gf,ControlTypes as Ot,EventActionTypes as k,EventTypes as Uf,migrateManifestToLatestVersion as Ns,compareVersions as zf}from"@interactiveplatform/movika-manifest";var Ms={metadata:"Object",chapters:"Array"},Ls=r=>{if(!Ge(r))return!1;for(let e in Ms)if(!r[e]||!ue(r[e],Ms[e]))return!1;return At(r.metadata.version)},wt=r=>r.type===Ot.Text,Nf=r=>r.type===Ot.Button,jf=r=>r.type===Ot.Area,$f={Choice:"Choice",TextInput:"TextInput"},_f={Button:"Button",Area:"Area",Text:"Text"},Ff={onClick:"onClick",onSuspense:"onSuspense"},qf={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var _=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var Rt=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 n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let n=this.listeners[e]||[];for(let i=n.length;i>0;i--)if(n[i]===t){n.splice(i,1);break}return this}emit(e,...t){let n=this.listeners[e];return n?(n.forEach(i=>{i(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var Pt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Rs(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(n=>n!==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=[]}};import{ValueSubject as fu}from"@vkontakte/videoplayer-shared/es2015";var kt=class{constructor(e){var t,n;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(n=e==null?void 0:e.manifestLoaders)!=null?n:[]}}exec(e,t){return A(this,null,function*(){return lu(...this.loaders[e])(t)})}};function lu(...r){return function(t){return A(this,null,function*(){let n=[...r];for(;n.length>0;)t=yield n.shift()(t);return t})}}function Ke(r,e,t){return r?E(d({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Vt(i){var s=i,{actions:r,errors:e,chapterId:t}=s,n=Z(s,["actions","errors","chapterId"]);if(t){let o=r.getManifest();if(o){let l=r.getChapter(o.chapters,t);if(l){let a=r.getMedia(o.media,l.videoId),c=r.getGraph(o.graph,l.id);return a?E(d({},n),{actions:r,errors:e,result:{chapter:l,media:a,graph:c}}):E(d({},n),{errors:Ke(e,Vt.name,"Could not find media"),actions:r})}}}return E(d({},n),{errors:Ke(e,Vt.name,"Could not find chapter"),actions:r})}var Mt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){if(!(e in this.listeners))return;let n=this.listeners[e];for(let i=0,s=n.length;i<s;i++)if(n[i].callback===t){n.splice(i,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let n=this.listeners[e.type].slice();for(let i=0,s=n.length;i<s;i++){let o=n[i];try{o.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}o.options&&o.options.once&&this.removeEventListener(e.type,o.callback)}return!e.defaultPrevented}},we=class extends Mt{constructor(){super(),this.listeners||Mt.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)}},Qe=class{constructor(){Object.defineProperty(this,"signal",{value:new we,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(i){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let n=e;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(i){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(Qe.prototype[Symbol.toStringTag]="AbortController",we.prototype[Symbol.toStringTag]="AbortSignal");function Lt(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 $r(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=r;if(!Lt({fetch:e,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:e,Request:s};let s=t;(s&&!s.prototype.hasOwnProperty("signal")||i)&&(s=function(c,f){let b;f&&f.signal&&(b=f.signal,delete f.signal);let m=new t(c,f);return b&&Object.defineProperty(m,"signal",{writable:!1,enumerable:!1,configurable:!0,value:b}),m},s.prototype=t.prototype);let o=e;return{fetch:(a,c)=>{let f=s&&s.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(f){let b;try{b=new DOMException("Aborted","AbortError")}catch(I){b=new Error("Aborted"),b.name="AbortError"}if(f.aborted)return Promise.reject(b);let m=new Promise((I,R)=>{f.addEventListener("abort",()=>R(b),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([m,o(a,c)])}return o(a,c)},Request:s}}var Xe=Lt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),js=Xe?$r({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,_r=Xe?js.fetch:window.fetch,pm=Xe?js.Request:window.Request,hm=Xe?Qe:window.AbortController,dm=Xe?we:window.AbortSignal;var Fr=(r="",e="")=>{let t=r.split("."),n=e.split("."),i=0;for(let s=0;s<Math.max(t.length,n.length)&&!i;s++)t[s]>n[s]?i=1:t[s]<n[s]?i=-1:i=0;return i};var cu=r=>A(void 0,null,function*(){try{let e={},t;if(xt(r)){t=new URL(r).href;let i=yield _r(t);if(!i.ok)return{};e=yield i.json()}else if(Ge(r))e=r;else return{};if(!Ls(e))return{};let n=e.metadata.media;if(xt(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let s=yield _r(i);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(i){return hu(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function $s(r){return A(this,null,function*(){let{manifest:e,manifestURL:t}=yield cu(r);if(!e)throw new Error("Failed on fetch");let n=Ns(e);return n.media=uu(n.media,t),delete n.metadata.media,n})}function Nt(r,e){if(e)return r.find(t=>t.id===e)}function qr(r,e){var t,n;return(t=r.edit)!=null&&t.chapters?r.edit.chapters.find(i=>i.id===e):(n=r.view)!=null&&n.chapters?r.view.chapters.find(i=>i.id===e):void 0}function Br(r,e){return r.videos.find(t=>t.id===e)}function uu(r,e){return E(d({},r),{videos:r.videos.map(t=>E(d({},t),{variants:t.variants.map(n=>{let i="url"in n?n.url:"",s=pu(i,e);return E(d({},n),{url:s||i})})}))})}function pu(r="",e){try{return new URL(r,e).href}catch(t){return""}}function hu(r){return Fr(r,"3.2.0")>=0}var jt=r=>Tt(r)&&!jr(r),ee=r=>r.order==="end",$t=r=>Tt(r.containers)&&!jr(r.containers)&&ee(r),_s=(r,e)=>{var n;let t=r*1e3;return jt(e.controls)&&t<((n=e.startTime)!=null?n:0)},Dr=(r,e)=>{var n,i;let t=r*1e3;return jt(e.controls)&&t>=((n=e.startTime)!=null?n:0)&&t<=((i=e.endTime)!=null?i:1/0)};var he=(r=[])=>r.some(e=>e.action.type==="expect"),Hr=(r=[])=>r.find(e=>e.action.type==="expect"),du=r=>(r==null?void 0:r.length)===1,Ae=r=>du(r)&&wt(r[0]);function Fs(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(d(d({},e[0]),t)):r(...e,...t)}var qs=(r,e)=>he(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&he(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var Oe=class extends kt{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new fu(null);this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(t){return A(this,null,function*(){var i;this.release();let n=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Ke},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=yield $s((i=n.result)!=null?i:t),this})}setInitial(){return A(this,null,function*(){return this.setNext()})}setNext(){return A(this,arguments,function*(t=(n=>(n=this.manifest)==null?void 0:n.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let i=yield this.exec("chapterLoaders",Vt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:qr,getChapter:Nt,getMedia:Br,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ke},result:null,errors:null,chapterId:t}));return i.errors&&this.errorHandler(i.errors),i.result&&(this.chapter=i.result.chapter,this.media=i.result.media,this.graph=i.result.graph),this})}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){var n;return this.getByChapterId((n=this.manifest)==null?void 0:n.metadata.initChapterId)||null}getByChapterId(t=(n=>(n=this.manifest)==null?void 0:n.metadata.initChapterId)()){if(!t||!this.manifest)return null;let i=Nt(this.manifest.chapters,t);if(i){let s=Br(this.manifest.media,i.videoId),o=qr(this.manifest.graph,i.id);if(s)return{chapter:i,media:s,graph:o}}return null}getBranches(t=(n=>(n=this.chapter)==null?void 0:n.id)()){var i,s,o;if(t===((i=this.chapter)==null?void 0:i.id))return this.getByBranches((s=this.chapter)==null?void 0:s.branches);{let l=Nt(((o=this.manifest)==null?void 0:o.chapters)||[],t);return this.getByBranches(l==null?void 0:l.branches)}}getByBranches(t=[]){return t.reduce((n,i)=>{let s=this.getByChapterId(i.chapterId);return s&&n.push(s),n},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,n;return((t=this.chapter)==null?void 0:t.id)===((n=this.manifest)==null?void 0:n.metadata.initChapterId)}isEndChapter(){return this.chapter?ee(this.chapter):!1}};var Oa=re(_t(),1);import{Player as rp}from"@vkontakte/videoplayer-core/es2015";import{Subscription as Qr,Tracer as np,ValueSubject as ip}from"@vkontakte/videoplayer-shared/es2015";var ga=r=>{let e=r.variants.find(t=>{var n;return((n=t.payload)==null?void 0:n.type)==="vk"});if(e&&e.payload){let[t,n]=e.payload.id.split("_");return[t,n]}return[]};var Ea=re(_t(),1);function Wr(){let r=new Map;function e(a){var c=a,{listId:s=Math.random().toString(),itemId:o=Math.random().toString()}=c,l=Z(c,["listId","itemId"]);let f=r.get(s),b=d({},l);return f?f[o]=b:r.set(s,{[o]:b}),d({listId:s,itemId:o},l)}function t(s){var o,l;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(o=s.statistics)==null||o.oneStat.destroy(),(l=s.statistics)==null||l.statSubscription.unsubscribe()}function n(s,o){let l=r.get(s);if(!l)throw Error("Can't remove. Not find.");if(o){let a=l[o];a&&t(a),delete l[o],Object.keys(l).length||r.delete(s)}else{for(let a of(0,Ea.default)(l))t(a);r.delete(s)}}function i(){for(let s of r)n(s[0])}return{createPlayer:e,removePlayer:n,map:r,removeAll:i}}var Re=re(Ft(),1);function Kr(r,e=[]){var s,o,l;let t={},n,i=!e.length;for(let a of r.variants)if(!n&&"cover"in a&&(n=a.cover),"url"in a)switch(a.type.toLowerCase()){case"mp4":(i||(0,Re.default)(e,"mp4"))&&(t.MPEG=E(d({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"mpeg":(i||(0,Re.default)(e,"mpeg"))&&(t.MPEG=E(d({},t.MPEG),{[(o=a.standard)!=null?o:"Invariant quality"]:a.url}));break;case"hls":(i||(0,Re.default)(e,"hls"))&&(t=E(d({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(i||(0,Re.default)(e,"dash"))&&(t=E(d({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:n,title:(l=r.title)!=null?l:""}}var Ye=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,Re.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var sp=2;function Xr(r){let e=Wr(),t=new Qr,n={},i=null,s=!1,o,l=new ip(null);r&&a(r);function a(C){i=C}function c(C,V,p){var x;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let y=((x=e.map.get(C))!=null?x:{})[V];if(y){n=d({chapterId:p,listId:C,itemId:V},y);let g=n.player;n.subscription.add(g.info.currentQuality$.subscribe(v=>{let S=g.info.position$.getValue(),q=g.info.isAutoQualityEnabled$.getValue();if(!(!v||!S||q))for(let w of e.map)(0,Oa.default)(w[1]).forEach(({player:M})=>{Ye(M,v)})})).add(g.events.started$.subscribe(()=>{f(V)})),y.container.remove(),i.setPlayer(y.player),s||(i.init(),s=!0),l.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}function f(C){return A(this,null,function*(){if(!i)throw Error("need to set interactive controller");if(pe(n)||C!==n.itemId)return;let V=i.getChapterBranches(),p=new Set;for(let h of V)p.has(h.media.id)||(yield m({media:h.media,chapterId:h.chapter.id,setAsActive:!1,title:h.chapter.label}),p.add(h.media.id))})}function b(p){return A(this,arguments,function*({chapter:{id:C},manifestVideo:V}){if(pe(n)||!i)return;let h=n.player.info.muted$.getValue(),y=n.player.info.currentQuality$.getValue(),x=n.player.info.isAutoQualityEnabled$.getValue(),g=n.player.info.volume$.getValue(),v=n.player.info.currentPlaybackRate$.getValue(),S=!x,q=!1;for(let w of e.map)if(w[0]===V.id&&!i.state.isReplay$.getValue()){let M=Object.keys(w[1]);for(let j of M)j===n.itemId?(M.length<sp||(q=!0),e.removePlayer(w[0],j)):(q=!0,c(w[0],j,C),S?Ye(n.player,y):n.player.setAutoQuality(!0),n.player.setVolume(g),n.player.setMuted(h),n.player.setPlaybackRate(v))}else e.removePlayer(w[0]);q||(yield m({media:V,chapterId:C,setAsActive:!0,playbackRate:v}),S?Ye(n.player,y):n.player.setAutoQuality(!0),n.player.setVolume(g),n.player.setMuted(h))})}function m(S){return A(this,arguments,function*({media:C,chapterId:V,prefetch:p=!0,setAsActive:h=!0,autoplay:y=!1,preferredExt:x,title:g,playbackRate:v}){var ln,cn,un,pn,hn;let q=Math.random().toString(),w=document.createElement("div");o.append(w);let M;if((ln=i==null?void 0:i.options)!=null&&ln.vkVideoLoader){let nt=ga(C);nt.length&&(M=yield i.options.vkVideoLoader(...nt))}let j=((cn=i==null?void 0:i.options)==null?void 0:cn.coreConfig)||void 0,Y=E(d({},j),{configName:[...(un=j==null?void 0:j.configName)!=null?un:[],"interactive"]}),oe=E(d({container:w},((pn=M==null?void 0:M.videos)==null?void 0:pn[0])||{sources:Kr(C,x).sources}),{title:g,failoverHosts:(M==null?void 0:M.failoverHosts)||[]}),B=new rp(Y,np.createRootTracer());B.initVideo(oe);let ye=null;if(M!=null&&M.videos&&(i!=null&&i.options.createOneStat)){let nt=M.videos[0],Wt=i.options.createOneStat(nt),dn=new Qr;Wt&&(dn.add(Wt.attachTo(B)),ye={oneStat:Wt,statSubscription:dn})}let on=new Qr,$o=(hn=n==null?void 0:n.player)==null?void 0:hn.info.isAutoQualityEnabled$.getValue();on.add(B.events.canplay$.subscribe(function(){$o||Ye(B,n.player.info.currentQuality$.getValue()),v&&B.setPlaybackRate(v)}));let ve=e.createPlayer({listId:C.id,itemId:q,player:B,container:w,sources:Kr(C,x).sources,config:oe,subscription:on,statistics:ye});return h&&c(C.id,ve.itemId,V),y&&ve.player.play(),p&&!y&&ve.player.prepare(),{player:ve.player,config:ve.config,statistics:ve.statistics}})}function I(){R(),i=null,o.remove()}function R(){t.unsubscribe(),e.removeAll(),n={},s=!1}function P(){return A(this,null,function*(){if(!i)throw Error("need to set interactive controller");R(),o=document.createElement("div");let{media:C,chapter:V}=i.getCurrentChapter();C&&V?(t.add(i.events.chapterChanged$.subscribe(b)),yield m({media:C,chapterId:V.id,title:V.label})):console.error("not found")})}return E(d({},e),{init:P,setInteractiveController:a,createPlayer:m,removeAll:I,getActivePlayer:function(){return n},activePlayerChanged:l})}var O={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Ze={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},L={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Pa=re(Ft(),1);import{Subscription as ap}from"@vkontakte/videoplayer-shared/es2015";var qt=class{constructor({player:e,container:t,branches:n,selectBranches:i,interactiveEvents:s,globalEvents:o,globalEventEmitter:l,ignoreContainerEvent:a,permanentTextControls:c,disabledControls$:f,onRemove:b}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(he(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,n,i,s;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement())(n=(t=this.container).show)==null||n.call(t),this.emitContainerVisibilityEvent(!0,!1);else{let o={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(a,c)=>{this.isSelectedControlEvent=!0,a!==!1&&(this.removeView(),this.emitContainerVisibilityEvent(!1)),(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),c(),this.removeView(),this.emitContainerVisibilityEvent(!1))},isEOV:()=>this.gameState===4},l=Fs(this.selectBranches.onControlEvent,o);this.container.createView({eventCallback:l}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((s=(i=this.container).disable)==null||s.call(i))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var c;let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,i=[6,5];if(!n||(0,Pa.default)(i,this.gameState)&&!this.isPermanentText)return;let s=this.player.getExactTime();if(_s(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Dr(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let f=this.gameState;this.gameState=3,f===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let o=Dr(s,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(c=this.container.container.endTime)!=null?c:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:s,isInteractiveTime:o};this.globalEventEmitter.emit(O.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new ap,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=a,this.isPermanentText=c&&Ae(t.container.controls),this.disabledControls$=f,this.onRemove=b,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=o,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.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(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.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,n,i,s;e?(n=(t=this.container).disable)==null||n.call(t):(s=(i=this.container).enable)==null||s.call(i)}))}selectContainerEvent(e=!1){var t,n;this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(t=this.container.container.endTime)!=null?t:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||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 e=he(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:L.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var ka=(r=[])=>r.reduce((e,t,n)=>{var s,o,l;let i=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!wt(a));if(jt(i)){let a=[(o=t.startTime)!=null?o:0,(l=t.endTime)!=null?l:1/0],c=t.id;if(!n)e.push({subjects:[c],range:a});else{let f=[],b=-1/0,m=1/0,I=[],R=[];for(let P=0;P<e.length;P++){let C=e[P];if(R.push(...C.subjects),C.range[0]<m&&(m=C.range[0]),C.range[1]>b&&(b=C.range[1]),a[0]>=C.range[0]&&a[1]<=C.range[1])return e[P].subjects.push(c),e;a[0]<C.range[0]&&a[1]>C.range[0]&&(f.push(P),I=I.concat(C.subjects)),a[0]>=C.range[0]&&a[0]<=C.range[1]&&(f.push(P),I=I.concat(C.subjects),a[0]=C.range[0]),a[1]>=C.range[0]&&a[1]<=C.range[1]&&(f.push(P),I=I.concat(C.subjects),a[1]=C.range[1])}if(R.push(c),a[0]<=m&&a[1]>=b)return[{subjects:R,range:a}];f.length&&f.reverse().forEach(P=>{e.splice(P,1)}),e.push({subjects:I.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var ho=re(Ft(),1),en=re(_t(),1),fo=re(uo(),1);function po(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let a={};for(let c in r)+c<=l&&(a[c]=r[c]);return a}function n(l){let a={};for(let c in r)+c>=l&&(a[c]=r[c]);return a}function i({timestamp:l,priority:a,initiator:c}){var f;if(Nr(l)){let b=(f=r[l])!=null?f:null;if(b&&a&&Ue(a,!0)){let m={},I=b[a];if(I&&(m=d(d({},m),I)),m=pe(m)?null:m,m&&Ue(c,!0)){let R=m[c];return R!=null?R:null}return m}return b}return null}function s({timestamp:l,priority:a,initiator:c}){if(Nr(l))if(r[l]){if(a&&Ue(a,!0))if(r[l][a]){if(c&&Ue(c,!0))if(r[l][a][c]){if(delete r[l][a][c],!pe(r[l][a]))return!0}else return!1;if(delete r[l][a],!pe(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function o(b){var m=b,{timestamp:l,priority:a,initiator:c}=m,f=Z(m,["timestamp","priority","initiator"]);var I,R,P;(R=(I=r[l])==null?void 0:I[a])!=null&&R[c]?r[l][a][c].push(d({},f)):(P=r[l])!=null&&P[a]?r[l][a]=E(d({},r[l][a]),{[c]:[d({},f)]}):r[l]?r[l]=E(d({},r[l]),{[a]:{[c]:[d({},f)]}}):r[l]={[a]:{[c]:[d({},f)]}}}return{map:r,remove:s,add:o,removeAll:e,get:i,getLte:t,getGte:n}}var Kp=[k.expect,k.setNextBranch],Qp=1/0;function mo(r){let e=r,t,n=Xp(),i=po(),s,o=()=>{m(),V()},l=p=>{i.add.call(void 0,p),R()},a=(p=[])=>{for(let h of p)if(h.action(),(0,ho.default)(Kp,h.actionType))break},c=(p=1/0)=>{var g,v,S;let h=Dt((g=i.get({timestamp:p,priority:"control"}))!=null?g:{}),y=Dt((v=i.get({timestamp:p,priority:"container"}))!=null?v:{}),x=Dt((S=i.get({timestamp:p,priority:"chapter"}))!=null?S:{});return[...h,...y,...x]},f=p=>{n.isReady(p)&&a(c(p))},b=()=>{var p;a([...Dt((p=i.get({timestamp:1/0,priority:"chapter"}))!=null?p:{})])},m=()=>{t&&(s==null||s.unsubscribe(),t=void 0)},I=p=>{},R=()=>{t||(t=()=>setTimeout(()=>{f(1/0)}),s=e.events.ended$.subscribe(t))},P=p=>{m(),e=p},C=p=>{p.priority==="container"&&n.resetCalled(p.timestamp),i.remove(p)},V=()=>{n.release(),i.removeAll()};return{setPlayer:P,add:l,remove:C,exec:f,execEndOfVideo:b,listen:R,unlisten:m,release:o,containersEventsCallState:n,getPreparedToExecActions:c}}function Xp(){let r=new Map;return{setCalled:({timestamp:o,id:l})=>{let a=r.get(o);a&&a[l]!==void 0&&(a[l]=!0)},setData:(o=[])=>{var l;for(let a of o){let c=(l=a.endTime)!=null?l:Qp,f=r.get(c);r.set(c,E(d({},f),{[a.id]:!1}))}},resetCalled:o=>{let l=r.get(o);if(l)for(let a in l)l[a]=!1},isReady:o=>{let l=r.get(o);return l?!(0,en.default)(l).some(a=>!a):!0},release:()=>r.clear()}}function Dt(r){return(0,fo.default)((0,en.default)(r)).sort(e=>e.actionType===k.expect?-1:1)}var yo={videoContentHeight:0,videoContentWidth:0},vo=(r,e)=>{let{height:t,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&n))return yo;let{clientHeight:i,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(i&&s))return yo;let o=t/n,l=i/s,a,c;return l>o?(c=s,a=s*o):l<o?(c=i/o,a=i):(c=s,a=i),{videoContentWidth:c,videoContentHeight:a}};var Yp=250;function bo(r){let e=()=>{},t=new ResizeObserver(l=>{s(l),e=s.bind(null,l)});function n(l){let{parentElement:a,player:c}=r();if(a&&c){let{videoContentWidth:f,videoContentHeight:b}=vo(a,c);a.style.setProperty("--interactive-content-width",`${f}px`),a.style.setProperty("--interactive-content-height",`${b}px`),a.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function i(){let{parentElement:l}=r();l.removeAttribute("style")}let s=He(l=>{let{fns:a=[]}=r();n(l);for(let c of a)c()},Yp);function o(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var Zp=r=>Math.floor(Math.random()*r),go=r=>{var i;let e=r.length,t=1/0,n=null;for(;e--;){let s=r[e],o=(i=s.weight)!=null?i:1;o<t&&(t=o,n=s)}return n},Eo=r=>{var i;let e=r.length,t=-1/0,n=null;for(;e--;){let s=r[e],o=(i=s.weight)!=null?i:0;o>t&&(t=o,n=s)}return n};var Io=r=>{let e=r.length,t=Zp(e);return r[t]},Co=1,xo=r=>{var n,i;let e=0;for(let s=0;s<r.length;++s)e+=(n=r[s].weight)!=null?n:Co;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(i=r[s].weight)!=null?i:Co,e>=t)return r[s];return r[r.length-1]};var To={shouldOpenNow:!0,isDetachContainer:!0},So="after-expect";var tn=(r,e=!1)=>E(d({},r),{args:e?d(d({},r.args),To):d(d({},To),r.args)}),Oo=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},s=()=>{i.isExpect&&(i.isExpect=!1)},o=({action:p,controlType:h,controlId:y,containerId:x,branches:g=[],onEvent:v,isEOV:S=()=>!1,isDisabled:q=()=>!1})=>{let w=tn(p,S()),M={timestamp:1/0,priority:"control",initiator:y,actionType:w.type},j=q(),Y=r.emit.bind(r,O.interactives,{subjectId:y,subjectType:h,subjectName:"control",type:j?L.actionChoiceCanceled:L.actionChoice,actionType:p.type,payload:d({invokeImmediately:w.args.shouldOpenNow,containerId:x},w.args)}),oe=()=>{e.interactiveActionChoice$.next({subjectId:y,subjectType:h,subjectName:"control",type:j?"action-choice-canceled":"action-choice",actionType:p.type,payload:d({invokeImmediately:w.args.shouldOpenNow,containerId:x},w.args)})};if(j){Y(),oe();return}switch(w.type.trim().toLowerCase()){case k.setNextBranch.trim().toLowerCase():{let B=g.find(ye=>ye.id===w.args.branchId);if(!B)return;v(w.args.isDetachContainer,I.bind(null,{subjectId:y,subjectName:"control"})),Y(),oe(),w.args.shouldOpenNow?P({subjectId:y,subjectName:"control",subjectType:h,action:w,payload:{chapterId:B.chapterId,autoSelect:!1}}):n.add(E(d({},M),{action:P.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:w,payload:{chapterId:B.chapterId,autoSelect:!1}})}));return}case k.continuePlayback.trim().toLowerCase():{v(w.args.isDetachContainer,I.bind(null,{subjectId:y,subjectName:"control"})),Y(),oe(),w.args.shouldOpenNow?R({subjectId:y,subjectName:"control",subjectType:h,action:p}):n.add(E(d({},M),{action:R.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:p})}));return}case k.openURI.trim().toLowerCase():{v(w.args.isDetachContainer,I.bind(null,{subjectId:y,subjectName:"control"})),Y(),oe(),w.args.shouldOpenNow?V({subjectId:y,subjectName:"control",subjectType:h,action:w,payload:{URI:p.args.uri}}):n.add(E(d({},M),{action:V.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:w,payload:{URI:p.args.uri}})}));return}default:{let B="Unexpected control event",ye=new _(1,1,{message:B});f(ye,B);return}}},l=({action:p,container:{id:h,endTime:y},branches:x=[],isEOV:g=!1,autoSelected:v=!1})=>{let S=tn(p,g),q={timestamp:!S.args.shouldOpenNow||g?1/0:y!=null?y:1/0,priority:"container",initiator:h,actionType:S.type},w=r.emit.bind(r,O.interactives,{subjectId:h,subjectName:"container",type:L.actionChoice,actionType:S.type,payload:d({invokeImmediately:S.args.shouldOpenNow},S.args)}),M=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:S.type,payload:d({invokeImmediately:S.args.shouldOpenNow},S.args)})};switch(S.type.trim().toLowerCase()){case k.setNextBranch.trim().toLowerCase():{let j=x.find(Y=>Y.id===S.args.branchId);if(!j)return;w(),M(),n.add(E(d({},q),{action:P.bind(null,{subjectId:h,subjectName:"container",action:S,payload:{chapterId:j.chapterId,autoSelect:v}})}));return}case k.setMaxWeightBranch.trim().toLowerCase():return;case k.setMinWeightBranch.trim().toLowerCase():return;case k.setRandomBranch.trim().toLowerCase():return;case k.setWeightlessRandomBranch.trim().toLowerCase():return;case k.continuePlayback.trim().toLowerCase():{w(),M(),n.add(E(d({},q),{action:R.bind(null,{subjectId:h,subjectName:"container",action:S})}));return}case k.openURI.trim().toLowerCase():{w(),M(),n.add(E(d({},q),{action:V.bind(null,{subjectId:h,subjectName:"container",action:S,payload:{URI:p.args.uri}})}));return}default:{let j="Unexpected container event",Y=new _(1,1,{message:j});f(Y,j);return}}};function a({container:p,branches:h,isEOV:y=!1}){var g,v;let x=Hr(p.events);if(x){let S=tn(x.action,y);r.emit(O.interactives,{subjectId:p.id,subjectName:"container",type:L.actionChoice,actionType:S.type,payload:d({invokeImmediately:S.args.shouldOpenNow},S.args)}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"container",type:"action-choice",actionType:S.type,payload:d({invokeImmediately:S.args.shouldOpenNow},S.args)}),n.add({timestamp:y?1/0:(g=p.endTime)!=null?g:1/0,priority:"container",initiator:p.id,actionType:k.expect,action:m.bind(null,{subjectId:p.id,subjectName:"container"})}),i.isExpect=!0}else for(let S of(v=p.events)!=null?v:[])l({action:S.action,container:p,branches:h,isEOV:y})}let c=({chapterId:p,action:h,branches:y=[]})=>{let x=r.emit.bind(r,O.interactives,{subjectId:p,subjectName:"chapter",type:L.actionChoice,actionType:h.type,payload:h.args}),g=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case k.setNextBranch.trim().toLowerCase():{let v=y.find(S=>S.id===h.args.branchId);return v!=null&&v.chapterId?(x(),g(),P.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case k.setWeightlessRandomBranch.trim().toLowerCase():{let v=Io(y);return v!=null&&v.chapterId?(x(),g(),P.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case k.setRandomBranch.trim().toLowerCase():{let v=xo(y);return v!=null&&v.chapterId?(x(),g(),P.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case k.setMaxWeightBranch.trim().toLowerCase():{let v=Eo(y);return v!=null&&v.chapterId?(x(),g(),P.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case k.setMinWeightBranch.trim().toLowerCase():{let v=go(y);return v!=null&&v.chapterId?(x(),g(),P.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case k.continuePlayback.trim().toLowerCase():return x(),g(),R.bind(null,{subjectId:p,subjectName:"chapter",action:h});case k.openURI.trim().toLowerCase():return x(),g(),V.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let v="Unexpected chapter event",S=new _(1,1,{message:v});f(S,v);return}}};function f(p,h){console.error(h),e.error$.next(p),r.emit(O.errors,p)}function b(p){var y;let h=Hr(p.events);if(h){if(ee(p))return;r.emit(O.interactives,{subjectId:p.id,subjectName:"chapter",type:L.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}),n.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:k.expect,action:m.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(y=p.events)==null||y.forEach(x=>{let g=c({chapterId:p.id,action:x.action,branches:p.branches});g&&n.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:x.action.type,action:g})})}let m=({subjectId:p,subjectName:h})=>{t.pause(),r.emit(O.interactives,{subjectId:p,subjectName:h,type:L.actionExecution,actionType:k.expect}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:k.expect})},I=({subjectId:p,subjectName:h})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(O.interactives,{subjectId:p,subjectName:h,type:L.actionExecution,actionType:So}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:So})},R=({subjectId:p,subjectName:h,subjectType:y,action:x})=>{r.emit(O.interactives,{subjectId:p,subjectName:h,subjectType:y,type:L.actionExecution,actionType:x.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:y,type:"action-execution",actionType:x.type})},P=({subjectId:p,subjectName:h,subjectType:y,action:x,payload:g})=>{g.behaviour="change-chapter",r.emit(O.interactives,{subjectId:p,subjectName:h,subjectType:y,type:L.actionExecution,actionType:x.type,payload:g}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:y,type:"action-execution",actionType:x.type,payload:g})},C=({subjectId:p,subjectName:h,subjectType:y,action:x,payload:g})=>{g.behaviour="change-manifest",r.emit(O.interactives,{subjectId:p,subjectName:h,subjectType:y,type:L.actionExecution,actionType:x.type,payload:g}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:y,type:"action-execution",actionType:x.type,payload:g})},V=({subjectId:p,subjectName:h,subjectType:y,action:x,payload:g})=>{if(!g.URI)return;let v=window.open(g.URI,"_blank","noopener,noreferrer");v&&(v.opener=null),r.emit(O.interactives,{subjectId:p,subjectName:h,subjectType:y,type:L.actionExecution,actionType:x.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:y,type:"action-execution",actionType:x.type})};return{onControlEvent:o,onContainerEvent:l,onChapterEvent:c,onExpectEvent:m,expectEventHandler:I,setManifestChapterEvents:b,setManifestContainerEvents:a,stopExpect:s,state:i}};var sn=re(Lr(),1);import{Subscription as nh,Subject as nn,ValueSubject as et}from"@vkontakte/videoplayer-shared/es2015";var rn=(r,e)=>{let t={};return r.map(n=>{if(!t[n]){let i=e.chapters.find(o=>o.id===n);if(!i)return null;let s=e.media.videos.find(o=>i.videoId===o.id);if(!s)return null;t[n]=Ro(s)}return t[n]}).filter(Boolean)},eh=r=>{for(let e of r.variants)if(th(e)&&e.payload)return e.payload.id},th=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),Ro=r=>{let e=eh(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},rh=(r,e)=>{for(let t of r.media.videos)if(e===Ro(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},Po=(r,e)=>r.reduce((t,n)=>{let i=rh(e,n);return i?[...t,i]:t},[]);var ne,de,fe,K,Ht,ie,se,te,me,Pe,ke,tt=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:s}){this.state={history$:new et([]),hasPrevChapter$:new et(!1),prevChapter$:new et(null),isInitialChapter$:new et(!1),isGoBackLimited$:new et(!1)};G(this,ne,null);G(this,de);G(this,fe,!1);G(this,K,null);G(this,Ht,null);this.events={inited$:new nn,destroyed$:new nn,error$:new nn};G(this,ie,null);G(this,se,null);G(this,te,null);G(this,me,new nh);G(this,Pe,!1);G(this,ke,0);var o;$(this,ie,t),$(this,te,e),$(this,se,n),$(this,ne,i),$(this,de,s),this.state.history$&&T(this,me)&&((o=T(this,me))==null||o.add(this.state.history$.subscribe(l=>{var a,c;this.state.prevChapter$.next((0,sn.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(a=T(this,K))==null?void 0:a.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(T(this,ke)===T(this,de).maxLength-1)})))}setManifest(e){return A(this,null,function*(){if(!T(this,se)||!T(this,te))return;$(this,K,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield T(this,se).setChapter({chapterId:t,pushToHistory:!1}),T(this,fe)||($(this,fe,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return T(this,fe)}updateHistory(e,t=!0){return A(this,null,function*(){var l;if(!T(this,K))return;T(this,Pe)?($(this,Pe,!1),bn(this,ke)._++):$(this,ke,0);let n=T(this,K),i=e.length-T(this,de).maxLength,s=i>0?e.slice(i):e,o=rn(s,n);if($(this,Ht,o),this.state.history$.next(s),!(!t||!T(this,ne)||!T(this,ie)))try{yield T(this,ne).save(T(this,ie),o)}catch(a){let c=new _(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=T(this,te))==null||l.emit(O.errors,c)}})}goBack(){return A(this,null,function*(){var n;if(!this.state||!T(this,se)){let i=new _(1,5,"Unable to save interactive history");return this.events.error$.next(i),(n=T(this,te))==null?void 0:n.emit(O.errors,i)}$(this,Pe,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield T(this,se).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return A(this,null,function*(){var i;if(!T(this,K)||!T(this,ie))return;let e=T(this,K),t=[this.getInitialVideoId()];if(T(this,ne))try{let s=yield T(this,ne).get(T(this,ie));s.length&&(t=s)}catch(s){let o=new _(1,5,"Error while trying to fetch data");this.events.error$.next(o),(i=T(this,te))==null||i.emit(O.errors,o)}let n=Po(t,e);this.state.history$.next(n)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,sn.default)(e,-1)||T(this,de).initChapterId||((t=T(this,K))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(T(this,K)){let e=this.getInitialChapterId();return rn([e],T(this,K)).pop()}return null}destroy(){var e,t;$(this,ie,null),$(this,ne,null),$(this,se,null),(e=T(this,me))==null||e.unsubscribe(),$(this,me,null),$(this,fe,!1),(t=T(this,te))==null||t.emit(O.historyDestroyed),this.events.destroyed$.next(),$(this,te,null)}};ne=new WeakMap,de=new WeakMap,fe=new WeakMap,K=new WeakMap,Ht=new WeakMap,ie=new WeakMap,se=new WeakMap,te=new WeakMap,me=new WeakMap,Pe=new WeakMap,ke=new WeakMap;var Gt=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 i;let e=(i=this.rootElement.getContext("2d"))==null?void 0:i.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,n=t.length;for(let s=3;s<n;s+=40)if(t[s]!==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 A(this,null,function*(){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;t&&(i=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&i&&this.restore(i),this._prevSizeId=n})}save(){return A(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 Ut=class{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){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,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)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;
@@ -11,13 +11,50 @@ var Mo=Object.create;var Wt=Object.defineProperty,jo=Object.defineProperties,Lo=
11
11
  height: var(--interactive-height);
12
12
  background-color: var(--black);
13
13
  visibility: hidden;
14
- `,this.lastFrameCanvas=new Ht,this.endOffsetMs=t,this._callbacks={onError:i},this.lastFrameCanvas.rootElement.style.cssText=`
14
+ `,this.lastFrameCanvas=new Gt,this.endOffsetMs=t,this._callbacks={onError:n},this.lastFrameCanvas.rootElement.style.cssText=`
15
15
  position: absolute;
16
16
  top: 50%;
17
17
  left: 50%;
18
18
  transform: translate(-50%, -50%);
19
- `,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}updateCanvasDimensions(e=!1){return A(this,null,function*(){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),i={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(i,e)}catch(n){this._onError(n)}})}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var i,n,a;return((i=t.controls)==null?void 0:i.length)&&e>=((n=t.startTime)!=null?n:0)&&e<=Math.min((a=t.endTime)!=null?a:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,i;(i=(t=this._callbacks)==null?void 0:t.onError)==null||i.call(t,e)}};function Ao(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var Oo=Object.freeze({lang:rh.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function nh(){let r=document.createElement("div");return r.style.cssText=`
19
+ `,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}updateCanvasDimensions(e=!1){return A(this,null,function*(){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),n={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(i){this._onError(i)}})}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var n,i,s;return((n=t.controls)==null?void 0:n.length)&&e>=((i=t.startTime)!=null?i:0)&&e<=Math.min((s=t.endTime)!=null?s:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,n;(n=(t=this._callbacks)==null?void 0:t.onError)==null||n.call(t,e)}};function ko(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var ih=`
20
+ .${U.common} {
21
+ opacity: 1;
22
+ visibility: visible;
23
+ transition: opacity var(--transition-1);
24
+ }
25
+
26
+ .${U.disabled} {
27
+ opacity: 0.5;
28
+ }
29
+
30
+ .${U.hidden} {
31
+ visibility: hidden;
32
+ }
33
+ `,sh=`
34
+ .interactive-chapter {
20
35
  position: absolute;
21
36
  top: 0;
22
37
  left: 0;
23
- `,r}var Ut=class{constructor(e){this.playerSubscriptions=new ii;this.subscriptions=new ii;this.globalEventEmitter=new Rt;this.animation=new Pt;this.seekToInteractiveController=new Ue;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=nh();this.factories=new Map([["choice",ht]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new ii;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new H(null),isInitialChapter$:new H(!1),isFirstChapter$:new H(!0),isEndChapter$:new H(!1),isInteractiveExpectation$:new H(!1),isReplay$:new H(!1),calledByInteractive$:new H(!1),lastChapterChangeWasInitiatedByInteractive$:new H(!1),disabledControls$:new H(!1),interactiveRanges$:new H([]),isInteractiveTime$:new H(!1),statistics$:new H(null),isSeekable$:new H(!1)};this.events={noInteraction$:new D,graphVisibilityChanged$:new D,watchAgainIsClicked$:new D,chapterChanged$:new D,playerChanged$:new D,error$:new D,eachTick$:new D,manifestChanged$:new D,interactiveRangeEnded$:new D,interactiveContainerRemoved$:new D,interactiveActionExecution$:new D,interactiveActionChoice$:new D,interactiveVisibilityChanged$:new D};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(R.errors,e)};this.clearHistoryIfEnded=()=>{var n;let e=(n=this.player)==null?void 0:n.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:i}=this.getCurrentChapter();e&&i&&J(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let n=e,{statistics:t}=n,i=X(n,["statistics"]);if(t){let{statSubscription:a,oneStat:o}=t;a.add(o.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(i),this.globalEventEmitter.emit(R.playerChanged,i)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.removeControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(a=>E(d({},a),{subjects:a.subjects.filter(o=>o!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var t;this._options=E(d(d({},Oo),e),{config:d(d({},Oo.config),e.config)}),this._options.parentElement.append(this.rootElement),this.historyController=new Je({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(t=this._options.projectInfo)==null?void 0:t.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Gt({parentElement:this._options.parentElement,onError:i=>{let n=new N(1,6,i);this.emitErrorEvent(n)}})),this.subscriptions.add(Po(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add(Po(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new we(this._options.loaders,i=>{let n=new N(1,3,i);this.emitErrorEvent(n)}),this.resizeManager=fo(()=>{var i,n;return{player:this.player,parentElement:(i=this._options)==null?void 0:i.parentElement,fns:(n=this._options)!=null&&n.lastFrame?[()=>{var a;(a=this.lastFrame)==null||a.updateCanvasDimensions(!0)}]:[]}}),this._options.graph&&(this.graph=new Ge({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(R.graph,{type:Ye.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let n=new N(1,4,{message:i});this.emitErrorEvent(n)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(t=>A(this,[t],function*({videosInfo:e=[]}){this._options.initSeamless&&(yield this.initSeamless(),this.updateGraphVideosInfo(e))}))),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveActionExecution$.subscribe(e=>{var t,i;if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:n}=e.payload;this.setChapter({chapterId:n}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:n}=e.payload;n&&this.setManifest(n)}e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:i})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in i&&i.invokeImmediately||this.removeControllers(!1)}))}initSeamless(){return A(this,null,function*(){this.seamlessController=Kr(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),yield this.seamlessController.init()})}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:a})=>t>=a[1]);if(n){let a=n.range.join("-");this.endedRanges.has(a)||(this.endedRanges.add(a),this.globalEventEmitter.emit(R.interactives,{type:j.rangeEnded,payload:n,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:n}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(ih()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add(th({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:i})=>{var s;let n;if(i)n=!0;else{let c=e*1e3;n=!!t.find(({range:[b,m],subjects:I})=>b<c&&c<m&&I.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let a=!!this.noInteractionTimeout,l=((s=this.player)==null?void 0:s.info.playbackState$.getValue())==="playing"||i;n&&!a&&l?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):a&&!l&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,i;(t=this.lastFrame)==null||t.hide(),(i=this.lastFrame)==null||i.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,i;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.filterGameControllers(e),(i=this.interactiveEvents)==null||i.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(n=>n.container.container).filter(n=>!Se(n.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var n;this.player&&((n=this.lastFrame)==null||n.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}filterGameControllers(e){let t=[];return e.containers.forEach(i=>{let n=i.type.trim().toLowerCase(),a=this.factories.get(n),o=a==null?void 0:a(i,this.rootElement);if(o&&this.selectBranches&&this.interactiveEvents&&this.player){let l=new Ft({player:this.player,container:o,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,ignoreContainerEvent:()=>$a(i,this.gameControllers),permanentTextControls:this._options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(i.id)}});this.animation.addFn(l.whilePlaying,!0),t.push(l)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),i=!!this.seekToInteractiveController.getNextInteractiveTime();(i&&!t||!i&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){var l,s;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(l=i&&J(i)&&$t(i))!=null?l:!1,a=((s=this.manifestController.manifest)==null?void 0:s.metadata.initChapterId)===e,o=this.historyController.state.history$.getValue();if(a||n&&t){this.historyController.updateHistory([e]);return}(0,ko.default)(o,-1)!==e&&this.historyController.updateHistory([...o,e])}reset(){var e;this.appState===2&&(this.removeControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}setManifest(e){return A(this,null,function*(){this.reset(),this.isFirstChapterFetched=!1;let t=yield this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),yield this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(R.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest})}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=uo(this.player),this.selectBranches=To({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){return A(this,arguments,function*({chapterId:e,pushToHistory:t=!0,playPrev:i=!1}={}){var s,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),eh.isSafari&&(yield Ao(35));let n=!i&&this.state.isEndChapter$.getValue()&&((s=this.getCurrentManifest())==null?void 0:s.metadata.initChapterId)===e;this.state.isReplay$.next(n);let{chapter:a,media:o,graph:l}=yield e?this.manifestController.setNext(e):this.manifestController.setInitial();(!e||n)&&this.state.isFirstChapter$.next(!0),!(!a||!o)&&(t&&this.pushChapterToHistory(a.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(a),(c=this.lastFrame)==null||c.setCurrentChapter(a),this.events.chapterChanged$.next({chapter:a,manifestVideo:o}),this.globalEventEmitter.emit(R.chapterChanged,{chapter:a,media:o,graph:l}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new Ro(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?et.GRAPH_SHOW:et.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(et.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(et.NEXT_BUTTON),n==="Area"&&e.next(et.NEXT_AREA))}))}),nextMovie$:new Ro(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}toggleGraphView(e=!0){this.graph&&(e?(this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(R.graph,{type:Ye.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var i;return!(((i=this.interactiveEvents)==null?void 0:i.getPreparedToExecActions())||[]).some(n=>n.actionType===k.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(i=>{let n=i.container.container;return!i.container.isRemoved&&n.endTime===null&&pe(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&wt(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){var e;return As((e=this.manifestController.chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){var e,t,i,n,a;this.clearHistoryIfEnded(),this.removeControllers(),this.gameControllers=[],(e=this.graph)==null||e.destroy(),this.seamlessControllerSubs.unsubscribe(),(t=this.seamlessController)==null||t.removeAll(),(i=this.resizeManager)==null||i.release(),this.animation.release(),(n=this.interactiveEvents)==null||n.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),(a=this.lastFrame)==null||a.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var ah={Container:be,createChoiceContainer:ht,createAreaControl:lt,createButtonControl:ut,getRootEl:it,classnamesPrefix:B};var Lv={version:yi};export{Af as ContainerTypes,At as ControlTypes,N as CustomError,R as EVENT_NAMES,k as EventActionTypes,Rf as EventTypes,Ut as Interactives,we as ManifestController,Lv as SDKInfo,ei as chapterIdsToVKVideoIds,Nr as compareVersions,Cf as containerTypes,Ef as controlTypes,xf as eventActionTypes,If as eventTypes,Zp as getChapterIdByVkVideoId,So as getVKVideoIdByMedia,Yp as getVideoRawIdByMedia,Ye as graphEventTypes,$t as hasEndTemplate,j as interactivesEventTypes,gf as isAreaControl,bf as isButtonControl,J as isLastChapter,Se as isOneTextCtrlContainer,wt as isSupportedManifest,St as isTextControl,Xp as isVKVariantItem,Oa as isValidManifest,ka as migrateManifestToLatestVersion,ah as utils,wo as vkVideoIdsToChapterIds};
38
+ font-family: inherit;
39
+
40
+ --transition-1: 100ms ease-in-out;
41
+ }
42
+
43
+ ${ih}
44
+
45
+ .${N.common} {
46
+ display: flex;
47
+ width: 100%;
48
+ height: 100%;
49
+ font-family: inherit;
50
+ }
51
+
52
+ .${N.disabled} {
53
+ cursor: default;
54
+ }
55
+
56
+ .${N.button},
57
+ .${N.area} {
58
+ cursor: pointer;
59
+ }
60
+ `,Vo=r=>{let e=document.createElement("style");e.textContent=sh,r.prepend(e)};var No=Object.freeze({lang:lh.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function uh(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var zt=class{constructor(e){this.playerSubscriptions=new an;this.subscriptions=new an;this.globalEventEmitter=new Rt;this.animation=new Pt;this.seekToInteractiveController=new We;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=uh();this.factories=new Map([["choice",dt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new an;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new H(null),isInitialChapter$:new H(!1),isFirstChapter$:new H(!0),isEndChapter$:new H(!1),isInteractiveExpectation$:new H(!1),isReplay$:new H(!1),calledByInteractive$:new H(!1),lastChapterChangeWasInitiatedByInteractive$:new H(!1),disabledControls$:new H(!1),interactiveRanges$:new H([]),isInteractiveTime$:new H(!1),statistics$:new H(null),isSeekable$:new H(!1)};this.events={noInteraction$:new D,graphVisibilityChanged$:new D,watchAgainIsClicked$:new D,chapterChanged$:new D,playerChanged$:new D,error$:new D,eachTick$:new D,manifestChanged$:new D,interactiveRangeEnded$:new D,interactiveContainerRemoved$:new D,interactiveActionExecution$:new D,interactiveActionChoice$:new D,interactiveVisibilityChanged$:new D};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(O.errors,e)};this.clearHistoryIfEnded=()=>{var i;let e=(i=this.player)==null?void 0:i.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&ee(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let i=e,{statistics:t}=i,n=Z(i,["statistics"]);if(t){let{statSubscription:s,oneStat:o}=t;s.add(o.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(O.playerChanged,n)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.removeControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,i=t.getValue().map(s=>E(d({},s),{subjects:s.subjects.filter(o=>o!==e)}));t.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var n;this._options=E(d(d({},No),e),{config:d(d({},No.config),e.config)}),this._options.parentElement.append(this.rootElement),this.historyController=new tt({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(n=this._options.projectInfo)==null?void 0:n.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Ut({parentElement:this._options.parentElement,onError:i=>{let s=new _(1,6,i);this.emitErrorEvent(s)}})),Vo(this._options.parentElement),this.subscriptions.add(Lo(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add(Lo(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new Oe(this._options.loaders,i=>{let s=new _(1,3,i);this.emitErrorEvent(s)});let t=[];this._options.lastFrame&&t.push(()=>{var i;(i=this.lastFrame)==null||i.updateCanvasDimensions(!0)}),this.resizeManager=bo(()=>({player:this.player,parentElement:this._options.parentElement,fns:t})),this._options.graph&&(this.graph=new ze({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(O.graph,{type:Ze.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let s=new _(1,4,{message:i});this.emitErrorEvent(s)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(t=>A(this,[t],function*({videosInfo:e=[]}){this._options.initSeamless&&(yield this.initSeamless(),this.updateGraphVideosInfo(e))}))),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveActionExecution$.subscribe(e=>{var t,n;if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:i}=e.payload;this.setChapter({chapterId:i}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((n=e.payload)==null?void 0:n.behaviour)==="change-manifest"){let{manifestURL:i}=e.payload;i&&this.setManifest(i)}e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:n})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in n&&n.invokeImmediately||this.removeControllers(!1)}))}initSeamless(){return A(this,null,function*(){this.seamlessController=Xr(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),yield this.seamlessController.init()})}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,i=this.getInteractiveRanges().reverse().find(({range:s})=>t>=s[1]);if(i){let s=i.range.join("-");this.endedRanges.has(s)||(this.endedRanges.add(s),this.globalEventEmitter.emit(O.interactives,{type:L.rangeEnded,payload:i,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:i}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(ch()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add(oh({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:n})=>{var a;let i;if(n)i=!0;else{let c=e*1e3;i=!!t.find(({range:[b,m],subjects:I})=>b<c&&c<m&&I.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let s=!!this.noInteractionTimeout,l=((a=this.player)==null?void 0:a.info.playbackState$.getValue())==="playing"||n;i&&!s&&l?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):s&&!l&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,n;(t=this.lastFrame)==null||t.hide(),(n=this.lastFrame)==null||n.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,n;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.filterGameControllers(e),(n=this.interactiveEvents)==null||n.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(i=>i.container.container).filter(i=>!Ae(i.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var i;this.player&&((i=this.lastFrame)==null||i.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}filterGameControllers(e){let t=[];return e.containers.forEach(n=>{let i=n.type.trim().toLowerCase(),s=this.factories.get(i),o=s==null?void 0:s(n,this.rootElement);if(o&&this.selectBranches&&this.interactiveEvents&&this.player){let l=new qt({player:this.player,container:o,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,ignoreContainerEvent:()=>qs(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)}});this.animation.addFn(l.whilePlaying,!0),t.push(l)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),n=!!this.seekToInteractiveController.getNextInteractiveTime();(n&&!t||!n&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){var l,a;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(l=n&&ee(n)&&$t(n))!=null?l:!1,s=((a=this.manifestController.manifest)==null?void 0:a.metadata.initChapterId)===e,o=this.historyController.state.history$.getValue();if(s||i&&t){this.historyController.updateHistory([e]);return}(0,jo.default)(o,-1)!==e&&this.historyController.updateHistory([...o,e])}reset(){var e;this.appState===2&&(this.removeControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}setManifest(e){return A(this,null,function*(){this.reset(),this.isFirstChapterFetched=!1;let t=yield this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),yield this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(O.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest})}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=mo(this.player),this.selectBranches=Oo({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){return A(this,arguments,function*({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){var a,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&ah.isSafari&&(yield ko(35));let i=!n&&this.state.isEndChapter$.getValue()&&((a=this.getCurrentManifest())==null?void 0:a.metadata.initChapterId)===e;this.state.isReplay$.next(i);let{chapter:s,media:o,graph:l}=yield e?this.manifestController.setNext(e):this.manifestController.setInitial();(!e||i)&&this.state.isFirstChapter$.next(!0),!(!s||!o)&&(t&&this.pushChapterToHistory(s.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(s),(c=this.lastFrame)==null||c.setCurrentChapter(s),this.events.chapterChanged$.next({chapter:s,manifestVideo:o}),this.globalEventEmitter.emit(O.chapterChanged,{chapter:s,media:o,graph:l}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new Mo(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?rt.GRAPH_SHOW:rt.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(rt.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(rt.NEXT_BUTTON),i==="Area"&&e.next(rt.NEXT_AREA))}))}),nextMovie$:new Mo(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}toggleGraphView(e=!0){this.graph&&(e?(this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(O.graph,{type:Ze.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var n;return!(((n=this.interactiveEvents)==null?void 0:n.getPreparedToExecActions())||[]).some(i=>i.actionType===k.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&he(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&At(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){var e;return ka((e=this.manifestController.chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){var e,t,n,i,s;this.clearHistoryIfEnded(),this.removeControllers(),this.gameControllers=[],(e=this.graph)==null||e.destroy(),this.seamlessControllerSubs.unsubscribe(),(t=this.seamlessController)==null||t.removeAll(),(n=this.resizeManager)==null||n.release(),this.animation.release(),(i=this.interactiveEvents)==null||i.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),(s=this.lastFrame)==null||s.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var ph={Container:be,createChoiceContainer:dt,createAreaControl:ut,createButtonControl:ht,classnamesPrefix:En};var rb={version:Cn};export{Gf as ContainerTypes,Ot as ControlTypes,_ as CustomError,O as EVENT_NAMES,k as EventActionTypes,Uf as EventTypes,zt as Interactives,Oe as ManifestController,rb as SDKInfo,rn as chapterIdsToVKVideoIds,Fr as compareVersions,$f as containerTypes,_f as controlTypes,qf as eventActionTypes,Ff as eventTypes,rh as getChapterIdByVkVideoId,Ro as getVKVideoIdByMedia,eh as getVideoRawIdByMedia,Ze as graphEventTypes,$t as hasEndTemplate,L as interactivesEventTypes,jf as isAreaControl,Nf as isButtonControl,ee as isLastChapter,Ae as isOneTextCtrlContainer,At as isSupportedManifest,wt as isTextControl,th as isVKVariantItem,Ls as isValidManifest,Ns as migrateManifestToLatestVersion,ph as utils,Po as vkVideoIdsToChapterIds};