@vkontakte/videoplayer-interactive 1.0.33-dev.8135f6ff.0 → 1.0.33-dev.e991e8d3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es2015.cjs.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.33-dev.8135f6ff.0
3
- * Wed, 05 Mar 2025 09:46:22 GMT
2
+ * @vkontakte/videoplayer-interactive v1.0.33-dev.e991e8d3.0
3
+ * Thu, 06 Mar 2025 08:10:57 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-33/doc/
5
5
  */
6
- "use strict";var qo=Object.create;var je=Object.defineProperty,Bo=Object.defineProperties,Do=Object.getOwnPropertyDescriptor,Ho=Object.getOwnPropertyDescriptors,Uo=Object.getOwnPropertyNames,ct=Object.getOwnPropertySymbols,Go=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty,mn=Object.prototype.propertyIsEnumerable;var fn=r=>{throw TypeError(r)};var dn=(r,e,t)=>e in r?je(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)&&dn(r,t,e[t]);if(ct)for(var t of ct(e))mn.call(e,t)&&dn(r,t,e[t]);return r},w=(r,e)=>Bo(r,Ho(e));var J=(r,e)=>{var t={};for(var n in r)Qt.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&ct)for(var n of ct(r))e.indexOf(n)<0&&mn.call(r,n)&&(t[n]=r[n]);return t};var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),zo=(r,e)=>{for(var t in e)je(r,t,{get:e[t],enumerable:!0})},vn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Uo(e))!Qt.call(r,i)&&i!==t&&je(r,i,{get:()=>e[i],enumerable:!(n=Do(e,i))||n.enumerable});return r};var ee=(r,e,t)=>(t=r!=null?qo(Go(r)):{},vn(e||!r||!r.__esModule?je(t,"default",{value:r,enumerable:!0}):t,r)),Wo=r=>vn(je({},"__esModule",{value:!0}),r);var yn=(r,e,t)=>e.has(r)||fn("Cannot "+t);var O=(r,e,t)=>(yn(r,e,"read from private field"),t?t.call(r):e.get(r)),H=(r,e,t)=>e.has(r)?fn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),_=(r,e,t,n)=>(yn(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 O(r,e,n)}});var V=(r,e,t)=>new Promise((n,i)=>{var s=a=>{try{c(t.next(a))}catch(l){i(l)}},o=a=>{try{c(t.throw(a))}catch(l){i(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,o);c((t=t.apply(r,e)).next())});var te=p((ir,An)=>{"use strict";var Le=function(r){return r&&r.Math===Math&&r};An.exports=Le(typeof globalThis=="object"&&globalThis)||Le(typeof window=="object"&&window)||Le(typeof self=="object"&&self)||Le(typeof global=="object"&&global)||Le(typeof ir=="object"&&ir)||function(){return this}()||Function("return this")()});var G=p((od,On)=>{"use strict";On.exports=function(r){try{return!!r()}catch(e){return!0}}});var $e=p((cd,Rn)=>{"use strict";var Ko=G();Rn.exports=!Ko(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Nn=p((ld,Mn)=>{"use strict";var Qo=$e(),Vn=Function.prototype,kn=Vn.apply,Pn=Vn.call;Mn.exports=typeof Reflect=="object"&&Reflect.apply||(Qo?Pn.bind(kn):function(){return Pn.apply(kn,arguments)})});var Q=p((ud,$n)=>{"use strict";var jn=$e(),Ln=Function.prototype,sr=Ln.call,Xo=jn&&Ln.bind.bind(sr,sr);$n.exports=jn?Xo:function(r){return function(){return sr.apply(r,arguments)}}});var _e=p((pd,Fn)=>{"use strict";var _n=Q(),Yo=_n({}.toString),Zo=_n("".slice);Fn.exports=function(r){return Zo(Yo(r),8,-1)}});var ar=p((hd,qn)=>{"use strict";var Jo=_e(),ec=Q();qn.exports=function(r){if(Jo(r)==="Function")return ec(r)}});var z=p((dd,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 ue=p((md,Dn)=>{"use strict";var tc=G();Dn.exports=!tc(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Ct=p((fd,Hn)=>{"use strict";var rc=$e(),bt=Function.prototype.call;Hn.exports=rc?bt.bind(bt):function(){return bt.apply(bt,arguments)}});var cr=p(zn=>{"use strict";var Un={}.propertyIsEnumerable,Gn=Object.getOwnPropertyDescriptor,nc=Gn&&!Un.call({1:2},1);zn.f=nc?function(e){var t=Gn(this,e);return!!t&&t.enumerable}:Un});var lr=p((yd,Wn)=>{"use strict";Wn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Qn=p((bd,Kn)=>{"use strict";var ic=Q(),sc=G(),ac=_e(),ur=Object,oc=ic("".split);Kn.exports=sc(function(){return!ur("z").propertyIsEnumerable(0)})?function(r){return ac(r)==="String"?oc(r,""):ur(r)}:ur});var pr=p((Cd,Xn)=>{"use strict";Xn.exports=function(r){return r==null}});var hr=p((gd,Yn)=>{"use strict";var cc=pr(),lc=TypeError;Yn.exports=function(r){if(cc(r))throw new lc("Can't call method on "+r);return r}});var Fe=p((Ed,Zn)=>{"use strict";var uc=Qn(),pc=hr();Zn.exports=function(r){return uc(pc(r))}});var Te=p((Id,Jn)=>{"use strict";var hc=z();Jn.exports=function(r){return typeof r=="object"?r!==null:hc(r)}});var gt=p((xd,ei)=>{"use strict";ei.exports={}});var Et=p((Td,ri)=>{"use strict";var dr=gt(),mr=te(),dc=z(),ti=function(r){return dc(r)?r:void 0};ri.exports=function(r,e){return arguments.length<2?ti(dr[r])||ti(mr[r]):dr[r]&&dr[r][e]||mr[r]&&mr[r][e]}});var ii=p((Sd,ni)=>{"use strict";var mc=Q();ni.exports=mc({}.isPrototypeOf)});var ci=p((wd,oi)=>{"use strict";var fc=te(),si=fc.navigator,ai=si&&si.userAgent;oi.exports=ai?String(ai):""});var fi=p((Ad,mi)=>{"use strict";var di=te(),fr=ci(),li=di.process,ui=di.Deno,pi=li&&li.versions||ui&&ui.version,hi=pi&&pi.v8,X,It;hi&&(X=hi.split("."),It=X[0]>0&&X[0]<4?1:+(X[0]+X[1]));!It&&fr&&(X=fr.match(/Edge\/(\d+)/),(!X||X[1]>=74)&&(X=fr.match(/Chrome\/(\d+)/),X&&(It=+X[1])));mi.exports=It});var vr=p((Od,yi)=>{"use strict";var vi=fi(),vc=G(),yc=te(),bc=yc.String;yi.exports=!!Object.getOwnPropertySymbols&&!vc(function(){var r=Symbol("symbol detection");return!bc(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&vi&&vi<41})});var yr=p((Rd,bi)=>{"use strict";var Cc=vr();bi.exports=Cc&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var br=p((kd,Ci)=>{"use strict";var gc=Et(),Ec=z(),Ic=ii(),xc=yr(),Tc=Object;Ci.exports=xc?function(r){return typeof r=="symbol"}:function(r){var e=gc("Symbol");return Ec(e)&&Ic(e.prototype,Tc(r))}});var Ei=p((Pd,gi)=>{"use strict";var Sc=String;gi.exports=function(r){try{return Sc(r)}catch(e){return"Object"}}});var Cr=p((Vd,Ii)=>{"use strict";var wc=z(),Ac=Ei(),Oc=TypeError;Ii.exports=function(r){if(wc(r))return r;throw new Oc(Ac(r)+" is not a function")}});var Ti=p((Md,xi)=>{"use strict";var Rc=Cr(),kc=pr();xi.exports=function(r,e){var t=r[e];return kc(t)?void 0:Rc(t)}});var wi=p((Nd,Si)=>{"use strict";var gr=Ct(),Er=z(),Ir=Te(),Pc=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 Pc("Can't convert object to primitive value")}});var Oi=p((jd,Ai)=>{"use strict";Ai.exports=!0});var Pi=p((Ld,ki)=>{"use strict";var Ri=te(),Vc=Object.defineProperty;ki.exports=function(r,e){try{Vc(Ri,r,{value:e,configurable:!0,writable:!0})}catch(t){Ri[r]=e}return e}});var xt=p(($d,Ni)=>{"use strict";var Mc=Oi(),Nc=te(),jc=Pi(),Vi="__core-js_shared__",Mi=Ni.exports=Nc[Vi]||jc(Vi,{});(Mi.versions||(Mi.versions=[])).push({version:"3.38.0",mode:Mc?"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=p((_d,Li)=>{"use strict";var ji=xt();Li.exports=function(r,e){return ji[r]||(ji[r]=e||{})}});var qe=p((Fd,$i)=>{"use strict";var Lc=hr(),$c=Object;$i.exports=function(r){return $c(Lc(r))}});var Se=p((qd,_i)=>{"use strict";var _c=Q(),Fc=qe(),qc=_c({}.hasOwnProperty);_i.exports=Object.hasOwn||function(e,t){return qc(Fc(e),t)}});var Tr=p((Bd,Fi)=>{"use strict";var Bc=Q(),Dc=0,Hc=Math.random(),Uc=Bc(1 .toString);Fi.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Uc(++Dc+Hc,36)}});var Be=p((Dd,Bi)=>{"use strict";var Gc=te(),zc=xr(),qi=Se(),Wc=Tr(),Kc=vr(),Qc=yr(),we=Gc.Symbol,Sr=zc("wks"),Xc=Qc?we.for||we:we&&we.withoutSetter||Wc;Bi.exports=function(r){return qi(Sr,r)||(Sr[r]=Kc&&qi(we,r)?we[r]:Xc("Symbol."+r)),Sr[r]}});var Gi=p((Hd,Ui)=>{"use strict";var Yc=Ct(),Di=Te(),Hi=br(),Zc=Ti(),Jc=wi(),el=Be(),tl=TypeError,rl=el("toPrimitive");Ui.exports=function(r,e){if(!Di(r)||Hi(r))return r;var t=Zc(r,rl),n;if(t){if(e===void 0&&(e="default"),n=Yc(t,r,e),!Di(n)||Hi(n))return n;throw new tl("Can't convert object to primitive value")}return e===void 0&&(e="number"),Jc(r,e)}});var wr=p((Ud,zi)=>{"use strict";var nl=Gi(),il=br();zi.exports=function(r){var e=nl(r,"string");return il(e)?e:e+""}});var Qi=p((Gd,Ki)=>{"use strict";var sl=te(),Wi=Te(),Ar=sl.document,al=Wi(Ar)&&Wi(Ar.createElement);Ki.exports=function(r){return al?Ar.createElement(r):{}}});var Or=p((zd,Xi)=>{"use strict";var ol=ue(),cl=G(),ll=Qi();Xi.exports=!ol&&!cl(function(){return Object.defineProperty(ll("div"),"a",{get:function(){return 7}}).a!==7})});var Ji=p(Zi=>{"use strict";var ul=ue(),pl=Ct(),hl=cr(),dl=lr(),ml=Fe(),fl=wr(),vl=Se(),yl=Or(),Yi=Object.getOwnPropertyDescriptor;Zi.f=ul?Yi:function(e,t){if(e=ml(e),t=fl(t),yl)try{return Yi(e,t)}catch(n){}if(vl(e,t))return dl(!pl(hl.f,e,t),e[t])}});var ts=p((Kd,es)=>{"use strict";var bl=G(),Cl=z(),gl=/#|\.prototype\./,De=function(r,e){var t=Il[El(r)];return t===Tl?!0:t===xl?!1:Cl(e)?bl(e):!!e},El=De.normalize=function(r){return String(r).replace(gl,".").toLowerCase()},Il=De.data={},xl=De.NATIVE="N",Tl=De.POLYFILL="P";es.exports=De});var Rr=p((Qd,ns)=>{"use strict";var rs=ar(),Sl=Cr(),wl=$e(),Al=rs(rs.bind);ns.exports=function(r,e){return Sl(r),e===void 0?r:wl?Al(r,e):function(){return r.apply(e,arguments)}}});var ss=p((Xd,is)=>{"use strict";var Ol=ue(),Rl=G();is.exports=Ol&&Rl(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var os=p((Yd,as)=>{"use strict";var kl=Te(),Pl=String,Vl=TypeError;as.exports=function(r){if(kl(r))return r;throw new Vl(Pl(r)+" is not an object")}});var us=p(ls=>{"use strict";var Ml=ue(),Nl=Or(),jl=ss(),Tt=os(),cs=wr(),Ll=TypeError,kr=Object.defineProperty,$l=Object.getOwnPropertyDescriptor,Pr="enumerable",Vr="configurable",Mr="writable";ls.f=Ml?jl?function(e,t,n){if(Tt(e),t=cs(t),Tt(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Mr in n&&!n[Mr]){var i=$l(e,t);i&&i[Mr]&&(e[t]=n.value,n={configurable:Vr in n?n[Vr]:i[Vr],enumerable:Pr in n?n[Pr]:i[Pr],writable:!1})}return kr(e,t,n)}:kr:function(e,t,n){if(Tt(e),t=cs(t),Tt(n),Nl)try{return kr(e,t,n)}catch(i){}if("get"in n||"set"in n)throw new Ll("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var hs=p((Jd,ps)=>{"use strict";var _l=ue(),Fl=us(),ql=lr();ps.exports=_l?function(r,e,t){return Fl.f(r,e,ql(1,t))}:function(r,e,t){return r[e]=t,r}});var Ue=p((em,ms)=>{"use strict";var He=te(),Bl=Nn(),Dl=ar(),Hl=z(),Ul=Ji().f,Gl=ts(),Ae=gt(),zl=Rr(),Oe=hs(),ds=Se();xt();var Wl=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 Bl(r,this,arguments)};return e.prototype=r.prototype,e};ms.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,s=r.proto,o=n?He:i?He[t]:He[t]&&He[t].prototype,c=n?Ae:Ae[t]||Oe(Ae,t,{})[t],a=c.prototype,l,f,y,b,g,A,E,v,k;for(b in e)l=Gl(n?b:t+(i?".":"#")+b,r.forced),f=!l&&o&&ds(o,b),A=c[b],f&&(r.dontCallGetSet?(k=Ul(o,b),E=k&&k.value):E=o[b]),g=f&&E?E:e[b],!(!l&&!s&&typeof A==typeof g)&&(r.bind&&f?v=zl(g,He):r.wrap&&f?v=Wl(g):s&&Hl(g)?v=Dl(g):v=g,(r.sham||g&&g.sham||A&&A.sham)&&Oe(v,"sham",!0),Oe(c,b,v),s&&(y=t+"Prototype",ds(Ae,y)||Oe(Ae,y,{}),Oe(Ae[y],b,g),r.real&&a&&(l||!a[b])&&Oe(a,b,g)))}});var vs=p((tm,fs)=>{"use strict";var Kl=Math.ceil,Ql=Math.floor;fs.exports=Math.trunc||function(e){var t=+e;return(t>0?Ql:Kl)(t)}});var Ge=p((rm,ys)=>{"use strict";var Xl=vs();ys.exports=function(r){var e=+r;return e!==e||e===0?0:Xl(e)}});var Cs=p((nm,bs)=>{"use strict";var Yl=Ge(),Zl=Math.min;bs.exports=function(r){var e=Yl(r);return e>0?Zl(e,9007199254740991):0}});var ze=p((im,gs)=>{"use strict";var Jl=Cs();gs.exports=function(r){return Jl(r.length)}});var St=p((sm,Es)=>{"use strict";Es.exports=function(){}});var Is=p(()=>{"use strict";var eu=Ue(),tu=qe(),ru=ze(),nu=Ge(),iu=St();eu({target:"Array",proto:!0},{at:function(e){var t=tu(this),n=ru(t),i=nu(e),s=i>=0?i:n+i;return s<0||s>=n?void 0:t[s]}});iu("at")});var wt=p((cm,xs)=>{"use strict";var su=Et();xs.exports=su});var Ss=p((lm,Ts)=>{"use strict";Is();var au=wt();Ts.exports=au("Array","at")});var As=p((um,ws)=>{"use strict";var ou=Ss();ws.exports=ou});var Nr=p((pm,Os)=>{"use strict";var cu=As();Os.exports=cu});var Hs=p((yf,Ds)=>{"use strict";var Eu=xr(),Iu=Tr(),Bs=Eu("keys");Ds.exports=function(r){return Bs[r]||(Bs[r]=Iu(r))}});var Gs=p((bf,Us)=>{"use strict";var xu=G();Us.exports=!xu(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Ks=p((Cf,Ws)=>{"use strict";var Tu=Se(),Su=z(),wu=qe(),Au=Hs(),Ou=Gs(),zs=Au("IE_PROTO"),Gr=Object,Ru=Gr.prototype;Ws.exports=Ou?Gr.getPrototypeOf:function(r){var e=wu(r);if(Tu(e,zs))return e[zs];var t=e.constructor;return Su(t)&&e instanceof t?t.prototype:e instanceof Gr?Ru:null}});var Xs=p((gf,Qs)=>{"use strict";var ku=Ge(),Pu=Math.max,Vu=Math.min;Qs.exports=function(r,e){var t=ku(r);return t<0?Pu(t+e,0):Vu(t,e)}});var zr=p((Ef,Zs)=>{"use strict";var Mu=Fe(),Nu=Xs(),ju=ze(),Ys=function(r){return function(e,t,n){var i=Mu(e),s=ju(i);if(s===0)return!r&&-1;var o=Nu(n,s),c;if(r&&t!==t){for(;s>o;)if(c=i[o++],c!==c)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=p((If,Js)=>{"use strict";Js.exports={}});var na=p((xf,ra)=>{"use strict";var Lu=Q(),Wr=Se(),$u=Fe(),_u=zr().indexOf,Fu=ea(),ta=Lu([].push);ra.exports=function(r,e){var t=$u(r),n=0,i=[],s;for(s in t)!Wr(Fu,s)&&Wr(t,s)&&ta(i,s);for(;e.length>n;)Wr(t,s=e[n++])&&(~_u(i,s)||ta(i,s));return i}});var sa=p((Tf,ia)=>{"use strict";ia.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var oa=p((Sf,aa)=>{"use strict";var qu=na(),Bu=sa();aa.exports=Object.keys||function(e){return qu(e,Bu)}});var da=p((wf,ha)=>{"use strict";var la=ue(),Du=G(),ua=Q(),Hu=Ks(),Uu=oa(),Gu=Fe(),zu=cr().f,pa=ua(zu),Wu=ua([].push),Ku=la&&Du(function(){var r=Object.create(null);return r[2]=2,!pa(r,2)}),ca=function(r){return function(e){for(var t=Gu(e),n=Uu(t),i=Ku&&Hu(t)===null,s=n.length,o=0,c=[],a;s>o;)a=n[o++],(!la||(i?a in t:pa(t,a)))&&Wu(c,r?[a,t[a]]:t[a]);return c}};ha.exports={entries:ca(!0),values:ca(!1)}});var ma=p(()=>{"use strict";var Qu=Ue(),Xu=da().values;Qu({target:"Object",stat:!0},{values:function(e){return Xu(e)}})});var va=p((Rf,fa)=>{"use strict";ma();var Yu=gt();fa.exports=Yu.Object.values});var ba=p((kf,ya)=>{"use strict";var Zu=va();ya.exports=Zu});var Ft=p((Pf,Ca)=>{"use strict";var Ju=ba();Ca.exports=Ju});var Ia=p(()=>{"use strict";var ep=Ue(),tp=zr().includes,rp=G(),np=St(),ip=rp(function(){return!Array(1).includes()});ep({target:"Array",proto:!0,forced:ip},{includes:function(e){return tp(this,e,arguments.length>1?arguments[1]:void 0)}});np("includes")});var Ta=p(($f,xa)=>{"use strict";Ia();var sp=wt();xa.exports=sp("Array","includes")});var wa=p((_f,Sa)=>{"use strict";var ap=Ta();Sa.exports=ap});var qt=p((Ff,Aa)=>{"use strict";var op=wa();Aa.exports=op});var Yr=p((rv,Na)=>{"use strict";var lp=_e();Na.exports=Array.isArray||function(e){return lp(e)==="Array"}});var La=p((nv,ja)=>{"use strict";var up=TypeError,pp=9007199254740991;ja.exports=function(r){if(r>pp)throw up("Maximum allowed index exceeded");return r}});var Fa=p((iv,_a)=>{"use strict";var hp=Yr(),dp=ze(),mp=La(),fp=Rr(),$a=function(r,e,t,n,i,s,o,c){for(var a=i,l=0,f=o?fp(o,c):!1,y,b;l<n;)l in t&&(y=f?f(t[l],l,e):t[l],s>0&&hp(y)?(b=dp(y),a=$a(r,e,y,b,a,s-1)-1):(mp(a+1),r[a]=y),a++),l++;return a};_a.exports=$a});var Da=p((sv,Ba)=>{"use strict";var vp=Be(),yp=vp("toStringTag"),qa={};qa[yp]="z";Ba.exports=String(qa)==="[object z]"});var Ua=p((av,Ha)=>{"use strict";var bp=Da(),Cp=z(),Dt=_e(),gp=Be(),Ep=gp("toStringTag"),Ip=Object,xp=Dt(function(){return arguments}())==="Arguments",Tp=function(r,e){try{return r[e]}catch(t){}};Ha.exports=bp?Dt:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=Tp(e=Ip(r),Ep))=="string"?t:xp?Dt(e):(n=Dt(e))==="Object"&&Cp(e.callee)?"Arguments":n}});var za=p((ov,Ga)=>{"use strict";var Sp=Q(),wp=z(),Zr=xt(),Ap=Sp(Function.toString);wp(Zr.inspectSource)||(Zr.inspectSource=function(r){return Ap(r)});Ga.exports=Zr.inspectSource});var Za=p((cv,Ya)=>{"use strict";var Op=Q(),Rp=G(),Wa=z(),kp=Ua(),Pp=Et(),Vp=za(),Ka=function(){},Qa=Pp("Reflect","construct"),Jr=/^\s*(?:class|function)\b/,Mp=Op(Jr.exec),Np=!Jr.test(Ka),it=function(e){if(!Wa(e))return!1;try{return Qa(Ka,[],e),!0}catch(t){return!1}},Xa=function(e){if(!Wa(e))return!1;switch(kp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Np||!!Mp(Jr,Vp(e))}catch(t){return!0}};Xa.sham=!0;Ya.exports=!Qa||Rp(function(){var r;return it(it.call)||!it(Object)||!it(function(){r=!0})||r})?Xa:it});var ro=p((lv,to)=>{"use strict";var Ja=Yr(),jp=Za(),Lp=Te(),$p=Be(),_p=$p("species"),eo=Array;to.exports=function(r){var e;return Ja(r)&&(e=r.constructor,jp(e)&&(e===eo||Ja(e.prototype))?e=void 0:Lp(e)&&(e=e[_p],e===null&&(e=void 0))),e===void 0?eo:e}});var io=p((uv,no)=>{"use strict";var Fp=ro();no.exports=function(r,e){return new(Fp(r))(e===0?0:e)}});var so=p(()=>{"use strict";var qp=Ue(),Bp=Fa(),Dp=qe(),Hp=ze(),Up=Ge(),Gp=io();qp({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Dp(this),n=Hp(t),i=Gp(t,0);return i.length=Bp(i,t,t,n,0,e===void 0?1:Up(e)),i}})});var ao=p(()=>{"use strict";var zp=St();zp("flat")});var co=p((fv,oo)=>{"use strict";so();ao();var Wp=wt();oo.exports=Wp("Array","flat")});var uo=p((vv,lo)=>{"use strict";var Kp=co();lo.exports=Kp});var ho=p((yv,po)=>{"use strict";var Qp=uo();po.exports=Qp});var ah={};zo(ah,{ContainerTypes:()=>I.ContainerTypes,ControlTypes:()=>I.ControlTypes,CustomError:()=>q,EVENT_NAMES:()=>M,EventActionTypes:()=>I.EventActionTypes,EventTypes:()=>I.EventTypes,Interactives:()=>at,ManifestController:()=>fe,SDKInfo:()=>sh,chapterIdsToVKVideoIds:()=>Ut,compareVersions:()=>Lt,containerTypes:()=>hu,controlTypes:()=>du,eventActionTypes:()=>_r,eventTypes:()=>mu,getChapterIdByVkVideoId:()=>Mo,getVKVideoIdByMedia:()=>rn,getVideoRawIdByMedia:()=>Po,graphEventTypes:()=>Pe,hasEndTemplate:()=>rt,interactivesEventTypes:()=>j,isAreaControl:()=>pu,isButtonControl:()=>uu,isLastChapter:()=>Y,isOneTextCtrlContainer:()=>me,isSupportedManifest:()=>I.isSupportedManifest,isTextControl:()=>Ze,isVKVariantItem:()=>Vo,isValidManifest:()=>$r,migrateManifestToLatestVersion:()=>I.migrateManifestToLatestVersion,utils:()=>_o,vkVideoIdsToChapterIds:()=>nn});module.exports=Wo(ah);var Cn="1.0.33-dev.8135f6ff.0";var Xt=class{constructor(e){this.layout=e}},lt=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 Ee=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",B={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||{}),ut=({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"},pt=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,s,o,c,a,l;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} * ${(c=(o=e==null?void 0:e.text)==null?void 0:o.size)!=null?c:t.textSize})`,r.textContent=(l=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?l:t.textContent},ht=({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)},dt=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,s,o,c,a,l,f,y,b,g,A;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((l=(a=(c=e==null?void 0:e.shape)==null?void 0:c.border)==null?void 0:a.color)!=null?l:t.borderColor,(b=(y=(f=e==null?void 0:e.shape)==null?void 0:f.border)==null?void 0:y.alpha)!=null?b:t.borderAlpha)}`,r.style.borderRadius=`calc(${n.height} * ${(A=(g=e==null?void 0:e.shape)==null?void 0:g.roundCorners)!=null?A:t.roundCorners})`},Ie=({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 xe="interactive-control",L={common:xe,wrapper:`${xe}-wrapper`,disabled:`${xe}-disabled`,button:`${xe}-button`,area:`${xe}-area`,text:`${xe}-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(L.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=((i=this.control.layoutParams.innerSizesDependOn)!=null?i:B.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 mt=(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(L.common,L.area),n.setAttribute("data-testid",le.AREA),ht({target:n,props:this.control.props,fallback:w(d({},B),{backgroundColor:"transparent"})}),dt({target:n,props:this.control.props,fallback:w(d({},B),{borderAlpha:0}),dependsOn:this.container.dimensions}),Ie({target:n,layoutParams:this.control.layoutParams,fallback:B}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(L.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(L.disabled)}getElement(){return this.controlElement}};var ft=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 vt=(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(L.common,L.button),n.setAttribute("data-testid",le.BUTTON),Ie({target:n,layoutParams:this.control.layoutParams,fallback:B}),ht({target:n,props:this.control.props,fallback:B}),dt({target:n,props:this.control.props,fallback:B,dependsOn:this.container.dimensions}),ut({target:n,props:w(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=ft(this.control.type.trim().toLowerCase()),s=(o=i.firstElementChild)!=null?o:i;pt({target:s,props:this.control.props,fallback:B,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(L.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(L.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(L.common,L.text),n.setAttribute("data-testid",le.TEXT),Ie({target:n,layoutParams:this.control.layoutParams,fallback:B}),ut({target:n,props:w(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=ft(this.control.type.trim().toLowerCase()),s=(o=i.firstElementChild)!=null?o:i;pt({target:s,props:this.control.props,fallback:B,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 yt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new nr(r,e,t)},nr=class extends Ee{constructor(t,n,i){super(t,i);this.containerElement=null;this.rootElement=n,this.layout=new lt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",vt),this.addControlFactory("text",wn),this.addControlFactory("area",mt)}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,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}};var $o=ee(Nr(),1),S=require("@vkontakte/videoplayer-shared/es2015"),Ne=require("@vkontakte/videoplayer-statistics/es2015");var Ms=require("@vkontakte/videoplayer-shared/es2015");function We(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var pe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Ke=r=>pe(r,"Object"),At=r=>pe(r,"String"),Ot=r=>pe(r,"Array"),Rt=r=>pe(r,"Number"),Rs=r=>pe(r,"Function");var jr=r=>Rt(r)&&!isNaN(r);var he=r=>Ke(r)&&Object.keys(r).length===0,Lr=r=>Ot(r)&&!r.length;var Qe=(r,e)=>At(r)&&(e?r.trim():r).length;var ks="video_interactive",Ps="videoint";var Vs=250,Xe=class{constructor(e){this.handleZoomChange=We(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,"Chapter 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,!Rt(e.graph.edit.chapters[0].x)){(n=this.onError)==null||n.call(this,"Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError: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=lu(e),this.resizeObserver=new ResizeObserver(We(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 V(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 V(this,null,function*(){var n;if(!this.manifest)return;let e;try{e=yield(0,Ms.loadVKLangPack)(this.lang,ks,Ps)}catch(i){(n=this.onError)==null||n.call(this,"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",o=>{var c=o,{name:i}=c,s=J(c,["name"]);var a;i==="openPreview"&&"chapterId"in s&&((a=this.onOpenPreviewClick)==null||a.call(this,s.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 lu(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 Ye=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}}};var I=require("@interactiveplatform/movika-manifest");var Ns={metadata:"Object",chapters:"Array"},$r=r=>{if(!Ke(r))return!1;for(let e in Ns)if(!r[e]||!pe(r[e],Ns[e]))return!1;return(0,I.isSupportedManifest)(r.metadata.version)},Ze=r=>r.type===I.ControlTypes.Text,uu=r=>r.type===I.ControlTypes.Button,pu=r=>r.type===I.ControlTypes.Area,hu={Choice:"Choice",TextInput:"TextInput"},du={Button:"Button",Area:"Area",Text:"Text"},mu={onClick:"onClick",onSuspense:"onSuspense"},_r={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var q=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var kt=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let 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=[]}};var qs=require("@vkontakte/videoplayer-shared/es2015");var Vt=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 V(this,null,function*(){return fu(...this.loaders[e])(t)})}};function fu(...r){return function(t){return V(this,null,function*(){let n=[...r];for(;n.length>0;)t=yield n.shift()(t);return t})}}function Je(r,e,t){return r?w(d({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Mt(i){var s=i,{actions:r,errors:e,chapterId:t}=s,n=J(s,["actions","errors","chapterId"]);if(t){let o=r.getManifest();if(o){let c=r.getChapter(o.chapters,t);if(c){let a=r.getMedia(o.media,c.videoId),l=r.getGraph(o.graph,c.id);return a?w(d({},n),{actions:r,errors:e,result:{chapter:c,media:a,graph:l}}):w(d({},n),{errors:Je(e,Mt.name,"Could not find media"),actions:r})}}}return w(d({},n),{errors:Je(e,Mt.name,"Could not find chapter"),actions:r})}var Nt=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(c){Promise.resolve().then(()=>{throw c})}o.options&&o.options.once&&this.removeEventListener(e.type,o.callback)}return!e.defaultPrevented}},Re=class extends Nt{constructor(){super(),this.listeners||Nt.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)}},et=class{constructor(){Object.defineProperty(this,"signal",{value:new Re,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&&(et.prototype[Symbol.toStringTag]="AbortController",Re.prototype[Symbol.toStringTag]="AbortSignal");function jt(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 Fr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=r;if(!jt({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(l,f){let y;f&&f.signal&&(y=f.signal,delete f.signal);let b=new t(l,f);return y&&Object.defineProperty(b,"signal",{writable:!1,enumerable:!1,configurable:!0,value:y}),b},s.prototype=t.prototype);let o=e;return{fetch:(a,l)=>{let f=s&&s.prototype.isPrototypeOf(a)?a.signal:l?l.signal:void 0;if(f){let y;try{y=new DOMException("Aborted","AbortError")}catch(g){y=new Error("Aborted"),y.name="AbortError"}if(f.aborted)return Promise.reject(y);let b=new Promise((g,A)=>{f.addEventListener("abort",()=>A(y),{once:!0})});return l&&l.signal&&delete l.signal,Promise.race([b,o(a,l)])}return o(a,l)},Request:s}}var tt=jt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),js=tt?Fr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,qr=tt?js.fetch:window.fetch,Km=tt?js.Request:window.Request,Qm=tt?et:window.AbortController,Xm=tt?Re:window.AbortSignal;var Lt=(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 vu=r=>V(void 0,null,function*(){try{let e={},t;if(At(r)){t=new URL(r).href;let i=yield qr(t);if(!i.ok)return{};e=yield i.json()}else if(Ke(r))e=r;else return{};if(!$r(e))return{};let n=e.metadata.media;if(At(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let s=yield qr(i);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(i){return Cu(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function Ls(r){return V(this,null,function*(){let{manifest:e,manifestURL:t}=yield vu(r);if(!e)throw new Error("Failed on fetch");let n=(0,I.migrateManifestToLatestVersion)(e);return n.media=yu(n.media,t),delete n.metadata.media,n})}function $t(r,e){if(e)return r.find(t=>t.id===e)}function Br(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 Dr(r,e){return r.videos.find(t=>t.id===e)}function yu(r,e){return w(d({},r),{videos:r.videos.map(t=>w(d({},t),{variants:t.variants.map(n=>{let i="url"in n?n.url:"",s=bu(i,e);return w(d({},n),{url:s||i})})}))})}function bu(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Cu(r){return Lt(r,"3.2.0")>=0}var _t=r=>Ot(r)&&!Lr(r),Y=r=>r.order==="end",rt=r=>Ot(r.containers)&&!Lr(r.containers)&&Y(r),$s=(r,e)=>{var n;let t=r*1e3;return _t(e.controls)&&t<((n=e.startTime)!=null?n:0)},Hr=(r,e)=>{var n,i;let t=r*1e3;return _t(e.controls)&&t>=((n=e.startTime)!=null?n:0)&&t<=((i=e.endTime)!=null?i:1/0)};var de=(r=[])=>r.some(e=>e.action.type==="expect"),Ur=(r=[])=>r.find(e=>e.action.type==="expect"),gu=r=>(r==null?void 0:r.length)===1,me=r=>gu(r)&&Ze(r[0]);function _s(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(d(d({},e[0]),t)):r(...e,...t)}var Fs=(r,e)=>{let t=E=>{let v=e.find(({container:k})=>k.container.id===E);return v==null?void 0:v.container.isRemoved},n=de(r.events)&&!t(r.id),i=(E,v=!1,k=!1)=>{let h=k?"every":"some";return E.controls[h](u=>{var x;let m=v?E.endTime===r.endTime:!0;return((x=u.events)==null?void 0:x[h](T=>{var C;return((C=T.action)==null?void 0:C.type)===_r.openURI}))&&m})},s=E=>E.some(({container:v})=>i(v.container,!0,!1)&&!v.isRemoved),o=E=>E.every(({container:v})=>v.isRemoved?!0:i(v.container,!0,!0)),c=e.filter(({container:E})=>E.container.id!==r.id&&de(E.container.events)&&E.container.endTime===r.endTime&&!E.isRemoved).length,a=E=>E.controls.some(v=>{var k;return(k=v.events)==null?void 0:k.some(h=>{var u,m;return(m=(u=h.action)==null?void 0:u.args)==null?void 0:m.shouldOpenNow})}),l=n||c>0,f=s(e),y=i(r),b=o(e),g=n?!1:c>0,A=a(r);return{isExpectTime:l,hasOtherExpect:c>0,hasOpenURIEvent:f,hasOpenURIEventInCurrentContainer:y,isAllOpenURIEventsValid:b,isExpectEventForCurrentContainer:g,hasShouldOpenNowEvent:A}};var fe=class extends Vt{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new qs.ValueSubject(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 V(this,null,function*(){var i;this.release();let n=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Je},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=yield Ls((i=n.result)!=null?i:t),this})}setInitial(){return V(this,null,function*(){return this.setNext()})}setNext(){return V(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",Mt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Br,getChapter:$t,getMedia:Dr,getByBranches:this.getByBranches.bind(this),addErrorMessage:Je},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=$t(this.manifest.chapters,t);if(i){let s=Dr(this.manifest.media,i.videoId),o=Br(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 c=$t(((o=this.manifest)==null?void 0:o.chapters)||[],t);return this.getByBranches(c==null?void 0:c.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?Y(this.chapter):!1}};var Oa=ee(Ft(),1),Ra=require("@vkontakte/videoplayer-core/es2015"),oe=require("@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=ee(Ft(),1);function Kr(){let r=new Map;function e(a){var l=a,{listId:s=Math.random().toString(),itemId:o=Math.random().toString()}=l,c=J(l,["listId","itemId"]);let f=r.get(s),y=d({},c);return f?f[o]=y:r.set(s,{[o]:y}),d({listId:s,itemId:o},c)}function t(s){var o,c;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(o=s.statistics)==null||o.oneStat.destroy(),(c=s.statistics)==null||c.statSubscription.unsubscribe()}function n(s,o){let c=r.get(s);if(!c)throw Error("Can't remove. Not find.");if(o){let a=c[o];a&&t(a),delete c[o],Object.keys(c).length||r.delete(s)}else{for(let a of(0,Ea.default)(c))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 ke=ee(qt(),1);function Qr(r,e=[]){var s,o,c;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,ke.default)(e,"mp4"))&&(t.MPEG=w(d({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"mpeg":(i||(0,ke.default)(e,"mpeg"))&&(t.MPEG=w(d({},t.MPEG),{[(o=a.standard)!=null?o:"Invariant quality"]:a.url}));break;case"hls":(i||(0,ke.default)(e,"hls"))&&(t=w(d({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(i||(0,ke.default)(e,"dash"))&&(t=w(d({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:n,title:(c=r.title)!=null?c:""}}var nt=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,ke.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var cp=2;function Xr(r){let e=Kr(),t=new oe.Subscription,n={},i=null,s=!1,o,c=new oe.ValueSubject(null);r&&a(r);function a(v){i=v}function l(v,k,h){var x;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let m=((x=e.map.get(v))!=null?x:{})[k];if(m){n=d({chapterId:h,listId:v,itemId:k},m);let T=n.player;n.subscription.add(T.info.currentQuality$.subscribe(C=>{let R=T.info.position$.getValue(),F=T.info.isAutoQualityEnabled$.getValue();if(!(!C||!R||F))for(let P of e.map)(0,Oa.default)(P[1]).forEach(({player:N})=>{nt(N,C)})})).add(T.events.started$.subscribe(()=>{f(k)})),m.container.remove(),i.setPlayer(m.player),s||(i.init(),s=!0),c.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}function f(v){return V(this,null,function*(){if(!i)throw Error("need to set interactive controller");if(he(n)||v!==n.itemId)return;let k=i.getChapterBranches(),h=new Set;for(let u of k)h.has(u.media.id)||(yield b({media:u.media,chapterId:u.chapter.id,setAsActive:!1,title:u.chapter.label}),h.add(u.media.id))})}function y(h){return V(this,arguments,function*({chapter:{id:v},manifestVideo:k}){if(he(n)||!i)return;let u=n.player.info.muted$.getValue(),m=n.player.info.currentQuality$.getValue(),x=n.player.info.isAutoQualityEnabled$.getValue(),T=n.player.info.volume$.getValue(),C=n.player.info.currentPlaybackRate$.getValue(),R=!x,F=!1;for(let P of e.map)if(P[0]===k.id&&!i.state.isReplay$.getValue()){let N=Object.keys(P[1]);for(let $ of N)$===n.itemId?(N.length<cp||(F=!0),e.removePlayer(P[0],$)):(F=!0,l(P[0],$,v),R?nt(n.player,m):n.player.setAutoQuality(!0),n.player.setVolume(T),n.player.setMuted(u),n.player.setPlaybackRate(C))}else e.removePlayer(P[0]);F||(yield b({media:k,chapterId:v,setAsActive:!0,playbackRate:C}),R?nt(n.player,m):n.player.setAutoQuality(!0),n.player.setVolume(T),n.player.setMuted(u))})}function b(R){return V(this,arguments,function*({media:v,chapterId:k,prefetch:h=!0,setAsActive:u=!0,autoplay:m=!1,preferredExt:x,title:T,playbackRate:C}){var on,cn,ln,un,pn;let F=Math.random().toString(),P=document.createElement("div");o.append(P);let N;if((on=i==null?void 0:i.options)!=null&&on.vkVideoLoader){let ot=ga(v);ot.length&&(N=yield i.options.vkVideoLoader(...ot))}let $=((cn=i==null?void 0:i.options)==null?void 0:cn.coreConfig)||void 0,Z=w(d({},$),{configName:[...(ln=$==null?void 0:$.configName)!=null?ln:[],"interactive"]}),ce=w(d({container:P},((un=N==null?void 0:N.videos)==null?void 0:un[0])||{sources:Qr(v,x).sources}),{title:T,failoverHosts:(N==null?void 0:N.failoverHosts)||[]}),D=new Ra.Player(Z,oe.Tracer.createRootTracer());D.initVideo(ce);let Ce=null;if(N!=null&&N.videos&&(i!=null&&i.options.createOneStat)){let ot=N.videos[0],Kt=i.options.createOneStat(ot),hn=new oe.Subscription;Kt&&(hn.add(Kt.attachTo(D)),Ce={oneStat:Kt,statSubscription:hn})}let an=new oe.Subscription,Fo=(pn=n==null?void 0:n.player)==null?void 0:pn.info.isAutoQualityEnabled$.getValue();an.add(D.events.canplay$.subscribe(function(){Fo||nt(D,n.player.info.currentQuality$.getValue()),C&&D.setPlaybackRate(C)}));let ge=e.createPlayer({listId:v.id,itemId:F,player:D,container:P,sources:Qr(v,x).sources,config:ce,subscription:an,statistics:Ce});return u&&l(v.id,ge.itemId,k),m&&ge.player.play(),h&&!m&&ge.player.prepare(),{player:ge.player,config:ge.config,statistics:ge.statistics}})}function g(){A(),i=null,o.remove()}function A(){t.unsubscribe(),e.removeAll(),n={},s=!1}function E(){return V(this,null,function*(){if(!i)throw Error("need to set interactive controller");A(),o=document.createElement("div");let{media:v,chapter:k}=i.getCurrentChapter();v&&k?(t.add(i.events.chapterChanged$.subscribe(y)),yield b({media:v,chapterId:k.id,title:k.label})):console.error("not found")})}return w(d({},e),{init:E,setInteractiveController:a,createPlayer:b,removeAll:g,getActivePlayer:function(){return n},activePlayerChanged:c})}var M={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Pe={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},j={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Pa=ee(qt(),1),Va=require("@vkontakte/videoplayer-shared/es2015");var Bt=class{constructor({player:e,container:t,branches:n,selectBranches:i,interactiveEvents:s,globalEvents:o,globalEventEmitter:c,getContainerEventState:a,permanentTextControls:l,interactiveTimeOpenUri:f,disabledControls$:y,onRemove:b}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(de(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()){let{hasOpenURIEventInCurrentContainer:o}=this.getContainerEventState();if((n=(t=this.container).show)==null||n.call(t),this.interactiveTimeOpenUri&&o)return;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,l)=>{let{isExpectTime:f,hasOtherExpect:y,hasOpenURIEvent:b,hasOpenURIEventInCurrentContainer:g,isAllOpenURIEventsValid:A,hasShouldOpenNowEvent:E}=this.getContainerEventState(),v=this.interactiveTimeOpenUri&&!g,k=this.interactiveTimeOpenUri&&g;if((!this.interactiveTimeOpenUri||v)&&(this.isSelectedControlEvent=!0),a!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||v)){if(this.interactiveTimeOpenUri){let h=!y&&!A&&g;h&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:h})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&b&&this.gameState!==5){if(k){let u=((m,x,T,C)=>!m&&!x&&T||m&&!x&&T&&!C||m&&!x&&T&&C)(f,y,A,this.isSelectedContainerEvent);this.fakeRemoveView(u)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!f||!y||!E)&&(this.selectBranches.stopExpect(),l())}},isEOV:()=>this.gameState===4},c=_s(this.selectBranches.onControlEvent,o);this.container.createView({eventCallback:c}),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 l,f,y;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(Hr(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let b=this.gameState;this.gameState=3,b===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:b}=this.getContainerEventState(),g=this.selectBranches.state.isExpect,A=this.interactiveTimeOpenUri&&b;if(A&&!g){let E=this.container.getElement();E&&(E.style.visibility!=="hidden"&&((f=(l=this.container).hide)==null||f.call(l)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!A&&this.removeView()}let o=Hr(s,this.container.container),c=this.container.container.startTime?[this.container.container.startTime,(y=this.container.container.endTime)!=null?y:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:c,currentTime:s,isInteractiveTime:o};this.globalEventEmitter.emit(M.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new Va.Subscription,this.player=e,this.interactiveEvents=s,this.getContainerEventState=a,this.isPermanentText=l&&me(t.container.controls),this.interactiveTimeOpenUri=f,this.disabledControls$=y,this.onRemove=b,this.globalEventEmitter=c,this.gameState=0,this.globalEvents=o,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(M.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(M.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,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 n,i;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(n=this.container.container.endTime)!=null?n:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((i=this.container.container.endTime)!=null?i:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||t:de(this.container.container.events)||e;(this.isSelectedControlEvent||!n)&&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(M.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)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}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 Ma=(r=[])=>r.reduce((e,t,n)=>{var s,o,c;let i=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!Ze(a));if(_t(i)){let a=[(o=t.startTime)!=null?o:0,(c=t.endTime)!=null?c:1/0],l={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[l],range:a});else{let f=[],y=-1/0,b=1/0,g=[],A=[];for(let E=0;E<e.length;E++){let v=e[E];if(A.push(...v.subjects),v.range[0]<b&&(b=v.range[0]),v.range[1]>y&&(y=v.range[1]),a[0]>=v.range[0]&&a[1]<=v.range[1])return e[E].subjects.push(l),e;a[0]<v.range[0]&&a[1]>v.range[0]&&(f.push(E),g=g.concat(v.subjects)),a[0]>=v.range[0]&&a[0]<=v.range[1]&&(f.push(E),g=g.concat(v.subjects),a[0]=v.range[0]),a[1]>=v.range[0]&&a[1]<=v.range[1]&&(f.push(E),g=g.concat(v.subjects),a[1]=v.range[1])}if(A.push(l),a[0]<=b&&a[1]>=y)return[{subjects:A,range:a}];f.length&&f.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:g.concat([l]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var fo=ee(qt(),1),en=ee(Ft(),1),vo=ee(ho(),1);function mo(){let r={};function e(){for(let c in r)Object.prototype.hasOwnProperty.call(r,c)&&delete r[c]}function t(c){let a={};for(let l in r)+l<=c&&(a[l]=r[l]);return a}function n(c){let a={};for(let l in r)+l>=c&&(a[l]=r[l]);return a}function i({timestamp:c,priority:a,initiator:l}){var f;if(jr(c)){let y=(f=r[c])!=null?f:null;if(y&&a&&Qe(a,!0)){let b={},g=y[a];if(g&&(b=d(d({},b),g)),b=he(b)?null:b,b&&Qe(l,!0)){let A=b[l];return A!=null?A:null}return b}return y}return null}function s({timestamp:c,priority:a,initiator:l}){if(jr(c))if(r[c]){if(a&&Qe(a,!0))if(r[c][a]){if(l&&Qe(l,!0))if(r[c][a][l]){if(delete r[c][a][l],!he(r[c][a]))return!0}else return!1;if(delete r[c][a],!he(r[c]))return!0}else return!1;return delete r[c]}else return!1;return!1}function o(y){var b=y,{timestamp:c,priority:a,initiator:l}=b,f=J(b,["timestamp","priority","initiator"]);var g,A,E;(A=(g=r[c])==null?void 0:g[a])!=null&&A[l]?r[c][a][l].push(d({},f)):(E=r[c])!=null&&E[a]?r[c][a]=w(d({},r[c][a]),{[l]:[d({},f)]}):r[c]?r[c]=w(d({},r[c]),{[a]:{[l]:[d({},f)]}}):r[c]={[a]:{[l]:[d({},f)]}}}return{map:r,remove:s,add:o,removeAll:e,get:i,getLte:t,getGte:n}}var Xp=[I.EventActionTypes.expect,I.EventActionTypes.setNextBranch],Yp=1/0;function yo(r,e){let t=r,n,i=Zp(e),s=mo(),o,c=()=>{g(),h()},a=u=>{s.add.call(void 0,u),E()},l=(u=[])=>{for(let m of u)if(m.action(),(0,fo.default)(Xp,m.actionType))break},f=(u=1/0)=>{var C,R,F;let m=Ht((C=s.get({timestamp:u,priority:"control"}))!=null?C:{}),x=Ht((R=s.get({timestamp:u,priority:"container"}))!=null?R:{}),T=Ht((F=s.get({timestamp:u,priority:"chapter"}))!=null?F:{});return[...m,...x,...T]},y=u=>{i.isReady(u)&&l(f(u))},b=()=>{var u;l([...Ht((u=s.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},g=()=>{n&&(o==null||o.unsubscribe(),n=void 0)},A=u=>{},E=()=>{n||(n=()=>setTimeout(()=>{y(1/0)}),o=t.events.ended$.subscribe(n))},v=u=>{g(),t=u},k=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),s.remove(u)},h=()=>{i.release(),s.removeAll()};return{setPlayer:v,add:a,remove:k,exec:y,execEndOfVideo:b,listen:E,unlisten:g,release:c,containersEventsCallState:i,getPreparedToExecActions:f}}function Zp(r){let e=new Map;return{setCalled:({timestamp:c,id:a})=>{let l=e.get(c);l&&l[a]!==void 0&&(l[a]=!0)},setData:(c=[])=>{var a;for(let l of c){let f=(a=l.endTime)!=null?a:Yp,y=e.get(f);e.set(f,w(d({},y),{[l.id]:!1}))}},resetCalled:c=>{let a=e.get(c);if(a)for(let l in a)a[l]=!1},isReady:c=>{let a=e.get(c);if(!a)return!0;let l=(0,en.default)(a);return r?l.some(y=>y):!l.some(y=>!y)},release:()=>e.clear()}}function Ht(r){return(0,vo.default)((0,en.default)(r)).sort(e=>e.actionType===I.EventActionTypes.expect?-1:1)}var bo={videoContentHeight:0,videoContentWidth:0},Co=(r,e)=>{let{height:t,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&n))return bo;let{clientHeight:i,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(i&&s))return bo;let o=t/n,c=i/s,a,l;return c>o?(l=s,a=s*o):c<o?(l=i/o,a=i):(l=s,a=i),{videoContentWidth:l,videoContentHeight:a}};var Jp=250;function go(r){let e=()=>{},t=new ResizeObserver(c=>{s(c),e=s.bind(null,c)});function n(c){let{parentElement:a,player:l}=r();if(a&&l){let{videoContentWidth:f,videoContentHeight:y}=Co(a,l);a.style.setProperty("--interactive-content-width",`${f}px`),a.style.setProperty("--interactive-content-height",`${y}px`),a.style.setProperty("--interactive-width",`${c[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${c[0].contentRect.height}px`)}}function i(){let{parentElement:c}=r();c.removeAttribute("style")}let s=We(c=>{let{fns:a=[]}=r();n(c);for(let l of a)l()},Jp);function o(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var eh=r=>Math.floor(Math.random()*r),Io=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},xo=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 To=r=>{let e=r.length,t=eh(e);return r[t]},Eo=1,So=r=>{var n,i;let e=0;for(let s=0;s<r.length;++s)e+=(n=r[s].weight)!=null?n:Eo;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(i=r[s].weight)!=null?i:Eo,e>=t)return r[s];return r[r.length-1]};var wo={shouldOpenNow:!0,isDetachContainer:!0},Ao="after-expect";var tn=(r,e=!1)=>w(d({},r),{args:e?d(d({},r.args),wo):d(d({},wo),r.args)}),ko=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},s=()=>{i.isExpect&&(i.isExpect=!1)},o=({action:h,controlType:u,controlId:m,containerId:x,branches:T=[],onEvent:C,isEOV:R=()=>!1,isDisabled:F=()=>!1})=>{let P=tn(h,R()),N={timestamp:1/0,priority:"control",initiator:m,actionType:P.type},$=F(),Z=r.emit.bind(r,M.interactives,{subjectId:m,subjectType:u,subjectName:"control",type:$?j.actionChoiceCanceled:j.actionChoice,actionType:h.type,payload:d({invokeImmediately:P.args.shouldOpenNow,containerId:x},P.args)}),ce=()=>{e.interactiveActionChoice$.next({subjectId:m,subjectType:u,subjectName:"control",type:$?"action-choice-canceled":"action-choice",actionType:h.type,payload:d({invokeImmediately:P.args.shouldOpenNow,containerId:x},P.args)})};if($){Z(),ce();return}switch(P.type.trim().toLowerCase()){case I.EventActionTypes.setNextBranch.trim().toLowerCase():{let D=T.find(Ce=>Ce.id===P.args.branchId);if(!D)return;C(P.args.isDetachContainer,g.bind(null,{subjectId:m,subjectName:"control"})),Z(),ce(),P.args.shouldOpenNow?E({subjectId:m,subjectName:"control",subjectType:u,action:P,payload:{chapterId:D.chapterId,autoSelect:!1}}):n.add(w(d({},N),{action:E.bind(null,{subjectId:m,subjectName:"control",subjectType:u,action:P,payload:{chapterId:D.chapterId,autoSelect:!1}})}));return}case I.EventActionTypes.continuePlayback.trim().toLowerCase():{C(P.args.isDetachContainer,g.bind(null,{subjectId:m,subjectName:"control"})),Z(),ce(),P.args.shouldOpenNow?A({subjectId:m,subjectName:"control",subjectType:u,action:h}):n.add(w(d({},N),{action:A.bind(null,{subjectId:m,subjectName:"control",subjectType:u,action:h})}));return}case I.EventActionTypes.openURI.trim().toLowerCase():{C(P.args.isDetachContainer,g.bind(null,{subjectId:m,subjectName:"control"})),Z(),ce(),P.args.shouldOpenNow?k({subjectId:m,subjectName:"control",subjectType:u,action:P,payload:{URI:h.args.uri}}):n.add(w(d({},N),{action:k.bind(null,{subjectId:m,subjectName:"control",subjectType:u,action:P,payload:{URI:h.args.uri}})}));return}default:{let D="Unexpected control event",Ce=new q(1,1,{message:D});f(Ce,D);return}}},c=({action:h,container:{id:u,endTime:m},branches:x=[],isEOV:T=!1,autoSelected:C=!1})=>{let R=tn(h,T),F={timestamp:!R.args.shouldOpenNow||T?1/0:m!=null?m:1/0,priority:"container",initiator:u,actionType:R.type},P=r.emit.bind(r,M.interactives,{subjectId:u,subjectName:"container",type:j.actionChoice,actionType:R.type,payload:d({invokeImmediately:R.args.shouldOpenNow},R.args)}),N=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"container",type:"action-choice",actionType:R.type,payload:d({invokeImmediately:R.args.shouldOpenNow},R.args)})};switch(R.type.trim().toLowerCase()){case I.EventActionTypes.setNextBranch.trim().toLowerCase():{let $=x.find(Z=>Z.id===R.args.branchId);if(!$)return;P(),N(),n.add(w(d({},F),{action:E.bind(null,{subjectId:u,subjectName:"container",action:R,payload:{chapterId:$.chapterId,autoSelect:C}})}));return}case I.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case I.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case I.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case I.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case I.EventActionTypes.continuePlayback.trim().toLowerCase():{P(),N(),n.add(w(d({},F),{action:A.bind(null,{subjectId:u,subjectName:"container",action:R})}));return}case I.EventActionTypes.openURI.trim().toLowerCase():{P(),N(),n.add(w(d({},F),{action:k.bind(null,{subjectId:u,subjectName:"container",action:R,payload:{URI:h.args.uri}})}));return}default:{let $="Unexpected container event",Z=new q(1,1,{message:$});f(Z,$);return}}};function a({container:h,branches:u,isEOV:m=!1}){var T,C;let x=Ur(h.events);if(x){let R=tn(x.action,m);r.emit(M.interactives,{subjectId:h.id,subjectName:"container",type:j.actionChoice,actionType:R.type,payload:d({invokeImmediately:R.args.shouldOpenNow},R.args)}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"container",type:"action-choice",actionType:R.type,payload:d({invokeImmediately:R.args.shouldOpenNow},R.args)}),n.add({timestamp:m?1/0:(T=h.endTime)!=null?T:1/0,priority:"container",initiator:h.id,actionType:I.EventActionTypes.expect,action:b.bind(null,{subjectId:h.id,subjectName:"container"})}),i.isExpect=!0}else for(let R of(C=h.events)!=null?C:[])c({action:R.action,container:h,branches:u,isEOV:m})}let l=({chapterId:h,action:u,branches:m=[]})=>{let x=r.emit.bind(r,M.interactives,{subjectId:h,subjectName:"chapter",type:j.actionChoice,actionType:u.type,payload:u.args}),T=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"chapter",type:"action-choice",actionType:u.type,payload:u.args})};switch(u.type.trim().toLowerCase()){case I.EventActionTypes.setNextBranch.trim().toLowerCase():{let C=m.find(R=>R.id===u.args.branchId);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let C=To(m);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.setRandomBranch.trim().toLowerCase():{let C=So(m);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let C=xo(m);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let C=Io(m);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.continuePlayback.trim().toLowerCase():return x(),T(),A.bind(null,{subjectId:h,subjectName:"chapter",action:u});case I.EventActionTypes.openURI.trim().toLowerCase():return x(),T(),k.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:{let C="Unexpected chapter event",R=new q(1,1,{message:C});f(R,C);return}}};function f(h,u){console.error(u),e.error$.next(h),r.emit(M.errors,h)}function y(h){var m;let u=Ur(h.events);if(u){if(Y(h))return;r.emit(M.interactives,{subjectId:h.id,subjectName:"chapter",type:j.actionChoice,actionType:u.action.type,payload:u.action.args}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"chapter",type:"action-choice",actionType:u.action.type,payload:u.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:I.EventActionTypes.expect,action:b.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else(m=h.events)==null||m.forEach(x=>{let T=l({chapterId:h.id,action:x.action,branches:h.branches});T&&n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:x.action.type,action:T})})}let b=({subjectId:h,subjectName:u})=>{t.pause(),r.emit(M.interactives,{subjectId:h,subjectName:u,type:j.actionExecution,actionType:I.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,type:"action-execution",actionType:I.EventActionTypes.expect})},g=({subjectId:h,subjectName:u})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(M.interactives,{subjectId:h,subjectName:u,type:j.actionExecution,actionType:Ao}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,type:"action-execution",actionType:Ao})},A=({subjectId:h,subjectName:u,subjectType:m,action:x})=>{r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:m,type:j.actionExecution,actionType:x.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:x.type})},E=({subjectId:h,subjectName:u,subjectType:m,action:x,payload:T})=>{T.behaviour="change-chapter",r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:m,type:j.actionExecution,actionType:x.type,payload:T}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:x.type,payload:T})},v=({subjectId:h,subjectName:u,subjectType:m,action:x,payload:T})=>{T.behaviour="change-manifest",r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:m,type:j.actionExecution,actionType:x.type,payload:T}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:x.type,payload:T})},k=({subjectId:h,subjectName:u,subjectType:m,action:x,payload:T})=>{if(!T.URI)return;let C=window.open(T.URI,"_blank","noopener,noreferrer");C&&(C.opener=null),r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:m,type:j.actionExecution,actionType:x.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:x.type})};return{onControlEvent:o,onContainerEvent:c,onChapterEvent:l,onExpectEvent:b,expectEventHandler:g,setManifestChapterEvents:y,setManifestContainerEvents:a,stopExpect:s,state:i}};var sn=ee(Nr(),1),K=require("@vkontakte/videoplayer-shared/es2015");var Ut=(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]=rn(s)}return t[n]}).filter(Boolean)},Po=r=>{for(let e of r.variants)if(Vo(e)&&e.payload)return e.payload.id},Vo=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),rn=r=>{let e=Po(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Mo=(r,e)=>{for(let t of r.media.videos)if(e===rn(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},nn=(r,e)=>r.reduce((t,n)=>{let i=Mo(e,n);return i?[...t,i]:t},[]);var ne,ve,ye,W,Gt,ie,se,re,be,Ve,Me,st=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:s}){this.state={history$:new K.ValueSubject([]),hasPrevChapter$:new K.ValueSubject(!1),prevChapter$:new K.ValueSubject(null),isInitialChapter$:new K.ValueSubject(!1),isGoBackLimited$:new K.ValueSubject(!1)};H(this,ne,null);H(this,ve);H(this,ye,!1);H(this,W,null);H(this,Gt,null);this.events={inited$:new K.Subject,destroyed$:new K.Subject,error$:new K.Subject};H(this,ie,null);H(this,se,null);H(this,re,null);H(this,be,new K.Subscription);H(this,Ve,!1);H(this,Me,0);var o;_(this,ie,t),_(this,re,e),_(this,se,n),_(this,ne,i),_(this,ve,s),this.state.history$&&O(this,be)&&((o=O(this,be))==null||o.add(this.state.history$.subscribe(c=>{var a,l;this.state.prevChapter$.next((0,sn.default)(c,-2)||null),this.state.hasPrevChapter$.next(c.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((l=(a=O(this,W))==null?void 0:a.metadata)==null?void 0:l.initChapterId)),this.state.isGoBackLimited$.next(O(this,Me)===O(this,ve).maxLength-1)})))}setManifest(e){return V(this,null,function*(){if(!O(this,se)||!O(this,re))return;_(this,W,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield O(this,se).setChapter({chapterId:t,pushToHistory:!1}),O(this,ye)||(_(this,ye,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return O(this,ye)}updateHistory(e,t=!0){return V(this,null,function*(){var c;if(!O(this,W))return;O(this,Ve)?(_(this,Ve,!1),bn(this,Me)._++):_(this,Me,0);let n=O(this,W),i=e.length-O(this,ve).maxLength,s=i>0?e.slice(i):e,o=Ut(s,n);if(_(this,Gt,o),this.state.history$.next(s),!(!t||!O(this,ne)||!O(this,ie)))try{yield O(this,ne).save(O(this,ie),o)}catch(a){let l=new q(1,5,"Unable to save interactive history");this.events.error$.next(l),(c=O(this,re))==null||c.emit(M.errors,l)}})}goBack(){return V(this,null,function*(){var n;if(!this.state||!O(this,se)){let i=new q(1,5,"Unable to save interactive history");return this.events.error$.next(i),(n=O(this,re))==null?void 0:n.emit(M.errors,i)}_(this,Ve,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield O(this,se).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return V(this,null,function*(){var i;if(!O(this,W)||!O(this,ie))return;let e=O(this,W),t=[this.getInitialVideoId()];if(O(this,ne))try{let s=yield O(this,ne).get(O(this,ie));s.length&&(t=s)}catch(s){let o=new q(1,5,"Error while trying to fetch data");this.events.error$.next(o),(i=O(this,re))==null||i.emit(M.errors,o)}let n=nn(t,e);this.state.history$.next(n)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,sn.default)(e,-1)||O(this,ve).initChapterId||((t=O(this,W))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(O(this,W)){let e=this.getInitialChapterId();return Ut([e],O(this,W)).pop()}return null}destroy(){var e,t;_(this,ie,null),_(this,ne,null),_(this,se,null),(e=O(this,be))==null||e.unsubscribe(),_(this,be,null),_(this,ye,!1),(t=O(this,re))==null||t.emit(M.historyDestroyed),this.events.destroyed$.next(),_(this,re,null)}};ne=new WeakMap,ve=new WeakMap,ye=new WeakMap,W=new WeakMap,Gt=new WeakMap,ie=new WeakMap,se=new WeakMap,re=new WeakMap,be=new WeakMap,Ve=new WeakMap,Me=new WeakMap;var zt=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 V(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 V(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 Wt=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=`
6
+ "use strict";var qo=Object.create;var Le=Object.defineProperty,Bo=Object.defineProperties,Do=Object.getOwnPropertyDescriptor,Ho=Object.getOwnPropertyDescriptors,Uo=Object.getOwnPropertyNames,ct=Object.getOwnPropertySymbols,Go=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty,mn=Object.prototype.propertyIsEnumerable;var fn=r=>{throw TypeError(r)};var dn=(r,e,t)=>e in r?Le(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)&&dn(r,t,e[t]);if(ct)for(var t of ct(e))mn.call(e,t)&&dn(r,t,e[t]);return r},w=(r,e)=>Bo(r,Ho(e));var J=(r,e)=>{var t={};for(var n in r)Qt.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&ct)for(var n of ct(r))e.indexOf(n)<0&&mn.call(r,n)&&(t[n]=r[n]);return t};var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),zo=(r,e)=>{for(var t in e)Le(r,t,{get:e[t],enumerable:!0})},vn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Uo(e))!Qt.call(r,i)&&i!==t&&Le(r,i,{get:()=>e[i],enumerable:!(n=Do(e,i))||n.enumerable});return r};var ee=(r,e,t)=>(t=r!=null?qo(Go(r)):{},vn(e||!r||!r.__esModule?Le(t,"default",{value:r,enumerable:!0}):t,r)),Wo=r=>vn(Le({},"__esModule",{value:!0}),r);var yn=(r,e,t)=>e.has(r)||fn("Cannot "+t);var O=(r,e,t)=>(yn(r,e,"read from private field"),t?t.call(r):e.get(r)),H=(r,e,t)=>e.has(r)?fn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),_=(r,e,t,n)=>(yn(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 O(r,e,n)}});var V=(r,e,t)=>new Promise((n,i)=>{var s=a=>{try{c(t.next(a))}catch(l){i(l)}},o=a=>{try{c(t.throw(a))}catch(l){i(l)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,o);c((t=t.apply(r,e)).next())});var te=p((ir,An)=>{"use strict";var je=function(r){return r&&r.Math===Math&&r};An.exports=je(typeof globalThis=="object"&&globalThis)||je(typeof window=="object"&&window)||je(typeof self=="object"&&self)||je(typeof global=="object"&&global)||je(typeof ir=="object"&&ir)||function(){return this}()||Function("return this")()});var G=p((od,On)=>{"use strict";On.exports=function(r){try{return!!r()}catch(e){return!0}}});var $e=p((cd,Rn)=>{"use strict";var Ko=G();Rn.exports=!Ko(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Nn=p((ld,Mn)=>{"use strict";var Qo=$e(),Vn=Function.prototype,kn=Vn.apply,Pn=Vn.call;Mn.exports=typeof Reflect=="object"&&Reflect.apply||(Qo?Pn.bind(kn):function(){return Pn.apply(kn,arguments)})});var Q=p((ud,$n)=>{"use strict";var Ln=$e(),jn=Function.prototype,sr=jn.call,Xo=Ln&&jn.bind.bind(sr,sr);$n.exports=Ln?Xo:function(r){return function(){return sr.apply(r,arguments)}}});var _e=p((pd,Fn)=>{"use strict";var _n=Q(),Yo=_n({}.toString),Zo=_n("".slice);Fn.exports=function(r){return Zo(Yo(r),8,-1)}});var ar=p((hd,qn)=>{"use strict";var Jo=_e(),ec=Q();qn.exports=function(r){if(Jo(r)==="Function")return ec(r)}});var z=p((dd,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 ue=p((md,Dn)=>{"use strict";var tc=G();Dn.exports=!tc(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Ct=p((fd,Hn)=>{"use strict";var rc=$e(),bt=Function.prototype.call;Hn.exports=rc?bt.bind(bt):function(){return bt.apply(bt,arguments)}});var cr=p(zn=>{"use strict";var Un={}.propertyIsEnumerable,Gn=Object.getOwnPropertyDescriptor,nc=Gn&&!Un.call({1:2},1);zn.f=nc?function(e){var t=Gn(this,e);return!!t&&t.enumerable}:Un});var lr=p((yd,Wn)=>{"use strict";Wn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Qn=p((bd,Kn)=>{"use strict";var ic=Q(),sc=G(),ac=_e(),ur=Object,oc=ic("".split);Kn.exports=sc(function(){return!ur("z").propertyIsEnumerable(0)})?function(r){return ac(r)==="String"?oc(r,""):ur(r)}:ur});var pr=p((Cd,Xn)=>{"use strict";Xn.exports=function(r){return r==null}});var hr=p((gd,Yn)=>{"use strict";var cc=pr(),lc=TypeError;Yn.exports=function(r){if(cc(r))throw new lc("Can't call method on "+r);return r}});var Fe=p((Ed,Zn)=>{"use strict";var uc=Qn(),pc=hr();Zn.exports=function(r){return uc(pc(r))}});var Te=p((Id,Jn)=>{"use strict";var hc=z();Jn.exports=function(r){return typeof r=="object"?r!==null:hc(r)}});var gt=p((xd,ei)=>{"use strict";ei.exports={}});var Et=p((Td,ri)=>{"use strict";var dr=gt(),mr=te(),dc=z(),ti=function(r){return dc(r)?r:void 0};ri.exports=function(r,e){return arguments.length<2?ti(dr[r])||ti(mr[r]):dr[r]&&dr[r][e]||mr[r]&&mr[r][e]}});var ii=p((Sd,ni)=>{"use strict";var mc=Q();ni.exports=mc({}.isPrototypeOf)});var ci=p((wd,oi)=>{"use strict";var fc=te(),si=fc.navigator,ai=si&&si.userAgent;oi.exports=ai?String(ai):""});var fi=p((Ad,mi)=>{"use strict";var di=te(),fr=ci(),li=di.process,ui=di.Deno,pi=li&&li.versions||ui&&ui.version,hi=pi&&pi.v8,X,It;hi&&(X=hi.split("."),It=X[0]>0&&X[0]<4?1:+(X[0]+X[1]));!It&&fr&&(X=fr.match(/Edge\/(\d+)/),(!X||X[1]>=74)&&(X=fr.match(/Chrome\/(\d+)/),X&&(It=+X[1])));mi.exports=It});var vr=p((Od,yi)=>{"use strict";var vi=fi(),vc=G(),yc=te(),bc=yc.String;yi.exports=!!Object.getOwnPropertySymbols&&!vc(function(){var r=Symbol("symbol detection");return!bc(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&vi&&vi<41})});var yr=p((Rd,bi)=>{"use strict";var Cc=vr();bi.exports=Cc&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var br=p((kd,Ci)=>{"use strict";var gc=Et(),Ec=z(),Ic=ii(),xc=yr(),Tc=Object;Ci.exports=xc?function(r){return typeof r=="symbol"}:function(r){var e=gc("Symbol");return Ec(e)&&Ic(e.prototype,Tc(r))}});var Ei=p((Pd,gi)=>{"use strict";var Sc=String;gi.exports=function(r){try{return Sc(r)}catch(e){return"Object"}}});var Cr=p((Vd,Ii)=>{"use strict";var wc=z(),Ac=Ei(),Oc=TypeError;Ii.exports=function(r){if(wc(r))return r;throw new Oc(Ac(r)+" is not a function")}});var Ti=p((Md,xi)=>{"use strict";var Rc=Cr(),kc=pr();xi.exports=function(r,e){var t=r[e];return kc(t)?void 0:Rc(t)}});var wi=p((Nd,Si)=>{"use strict";var gr=Ct(),Er=z(),Ir=Te(),Pc=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 Pc("Can't convert object to primitive value")}});var Oi=p((Ld,Ai)=>{"use strict";Ai.exports=!0});var Pi=p((jd,ki)=>{"use strict";var Ri=te(),Vc=Object.defineProperty;ki.exports=function(r,e){try{Vc(Ri,r,{value:e,configurable:!0,writable:!0})}catch(t){Ri[r]=e}return e}});var xt=p(($d,Ni)=>{"use strict";var Mc=Oi(),Nc=te(),Lc=Pi(),Vi="__core-js_shared__",Mi=Ni.exports=Nc[Vi]||Lc(Vi,{});(Mi.versions||(Mi.versions=[])).push({version:"3.38.0",mode:Mc?"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=p((_d,ji)=>{"use strict";var Li=xt();ji.exports=function(r,e){return Li[r]||(Li[r]=e||{})}});var qe=p((Fd,$i)=>{"use strict";var jc=hr(),$c=Object;$i.exports=function(r){return $c(jc(r))}});var Se=p((qd,_i)=>{"use strict";var _c=Q(),Fc=qe(),qc=_c({}.hasOwnProperty);_i.exports=Object.hasOwn||function(e,t){return qc(Fc(e),t)}});var Tr=p((Bd,Fi)=>{"use strict";var Bc=Q(),Dc=0,Hc=Math.random(),Uc=Bc(1 .toString);Fi.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Uc(++Dc+Hc,36)}});var Be=p((Dd,Bi)=>{"use strict";var Gc=te(),zc=xr(),qi=Se(),Wc=Tr(),Kc=vr(),Qc=yr(),we=Gc.Symbol,Sr=zc("wks"),Xc=Qc?we.for||we:we&&we.withoutSetter||Wc;Bi.exports=function(r){return qi(Sr,r)||(Sr[r]=Kc&&qi(we,r)?we[r]:Xc("Symbol."+r)),Sr[r]}});var Gi=p((Hd,Ui)=>{"use strict";var Yc=Ct(),Di=Te(),Hi=br(),Zc=Ti(),Jc=wi(),el=Be(),tl=TypeError,rl=el("toPrimitive");Ui.exports=function(r,e){if(!Di(r)||Hi(r))return r;var t=Zc(r,rl),n;if(t){if(e===void 0&&(e="default"),n=Yc(t,r,e),!Di(n)||Hi(n))return n;throw new tl("Can't convert object to primitive value")}return e===void 0&&(e="number"),Jc(r,e)}});var wr=p((Ud,zi)=>{"use strict";var nl=Gi(),il=br();zi.exports=function(r){var e=nl(r,"string");return il(e)?e:e+""}});var Qi=p((Gd,Ki)=>{"use strict";var sl=te(),Wi=Te(),Ar=sl.document,al=Wi(Ar)&&Wi(Ar.createElement);Ki.exports=function(r){return al?Ar.createElement(r):{}}});var Or=p((zd,Xi)=>{"use strict";var ol=ue(),cl=G(),ll=Qi();Xi.exports=!ol&&!cl(function(){return Object.defineProperty(ll("div"),"a",{get:function(){return 7}}).a!==7})});var Ji=p(Zi=>{"use strict";var ul=ue(),pl=Ct(),hl=cr(),dl=lr(),ml=Fe(),fl=wr(),vl=Se(),yl=Or(),Yi=Object.getOwnPropertyDescriptor;Zi.f=ul?Yi:function(e,t){if(e=ml(e),t=fl(t),yl)try{return Yi(e,t)}catch(n){}if(vl(e,t))return dl(!pl(hl.f,e,t),e[t])}});var ts=p((Kd,es)=>{"use strict";var bl=G(),Cl=z(),gl=/#|\.prototype\./,De=function(r,e){var t=Il[El(r)];return t===Tl?!0:t===xl?!1:Cl(e)?bl(e):!!e},El=De.normalize=function(r){return String(r).replace(gl,".").toLowerCase()},Il=De.data={},xl=De.NATIVE="N",Tl=De.POLYFILL="P";es.exports=De});var Rr=p((Qd,ns)=>{"use strict";var rs=ar(),Sl=Cr(),wl=$e(),Al=rs(rs.bind);ns.exports=function(r,e){return Sl(r),e===void 0?r:wl?Al(r,e):function(){return r.apply(e,arguments)}}});var ss=p((Xd,is)=>{"use strict";var Ol=ue(),Rl=G();is.exports=Ol&&Rl(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var os=p((Yd,as)=>{"use strict";var kl=Te(),Pl=String,Vl=TypeError;as.exports=function(r){if(kl(r))return r;throw new Vl(Pl(r)+" is not an object")}});var us=p(ls=>{"use strict";var Ml=ue(),Nl=Or(),Ll=ss(),Tt=os(),cs=wr(),jl=TypeError,kr=Object.defineProperty,$l=Object.getOwnPropertyDescriptor,Pr="enumerable",Vr="configurable",Mr="writable";ls.f=Ml?Ll?function(e,t,n){if(Tt(e),t=cs(t),Tt(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Mr in n&&!n[Mr]){var i=$l(e,t);i&&i[Mr]&&(e[t]=n.value,n={configurable:Vr in n?n[Vr]:i[Vr],enumerable:Pr in n?n[Pr]:i[Pr],writable:!1})}return kr(e,t,n)}:kr:function(e,t,n){if(Tt(e),t=cs(t),Tt(n),Nl)try{return kr(e,t,n)}catch(i){}if("get"in n||"set"in n)throw new jl("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var hs=p((Jd,ps)=>{"use strict";var _l=ue(),Fl=us(),ql=lr();ps.exports=_l?function(r,e,t){return Fl.f(r,e,ql(1,t))}:function(r,e,t){return r[e]=t,r}});var Ue=p((em,ms)=>{"use strict";var He=te(),Bl=Nn(),Dl=ar(),Hl=z(),Ul=Ji().f,Gl=ts(),Ae=gt(),zl=Rr(),Oe=hs(),ds=Se();xt();var Wl=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 Bl(r,this,arguments)};return e.prototype=r.prototype,e};ms.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,s=r.proto,o=n?He:i?He[t]:He[t]&&He[t].prototype,c=n?Ae:Ae[t]||Oe(Ae,t,{})[t],a=c.prototype,l,f,y,b,g,A,E,v,k;for(b in e)l=Gl(n?b:t+(i?".":"#")+b,r.forced),f=!l&&o&&ds(o,b),A=c[b],f&&(r.dontCallGetSet?(k=Ul(o,b),E=k&&k.value):E=o[b]),g=f&&E?E:e[b],!(!l&&!s&&typeof A==typeof g)&&(r.bind&&f?v=zl(g,He):r.wrap&&f?v=Wl(g):s&&Hl(g)?v=Dl(g):v=g,(r.sham||g&&g.sham||A&&A.sham)&&Oe(v,"sham",!0),Oe(c,b,v),s&&(y=t+"Prototype",ds(Ae,y)||Oe(Ae,y,{}),Oe(Ae[y],b,g),r.real&&a&&(l||!a[b])&&Oe(a,b,g)))}});var vs=p((tm,fs)=>{"use strict";var Kl=Math.ceil,Ql=Math.floor;fs.exports=Math.trunc||function(e){var t=+e;return(t>0?Ql:Kl)(t)}});var Ge=p((rm,ys)=>{"use strict";var Xl=vs();ys.exports=function(r){var e=+r;return e!==e||e===0?0:Xl(e)}});var Cs=p((nm,bs)=>{"use strict";var Yl=Ge(),Zl=Math.min;bs.exports=function(r){var e=Yl(r);return e>0?Zl(e,9007199254740991):0}});var ze=p((im,gs)=>{"use strict";var Jl=Cs();gs.exports=function(r){return Jl(r.length)}});var St=p((sm,Es)=>{"use strict";Es.exports=function(){}});var Is=p(()=>{"use strict";var eu=Ue(),tu=qe(),ru=ze(),nu=Ge(),iu=St();eu({target:"Array",proto:!0},{at:function(e){var t=tu(this),n=ru(t),i=nu(e),s=i>=0?i:n+i;return s<0||s>=n?void 0:t[s]}});iu("at")});var wt=p((cm,xs)=>{"use strict";var su=Et();xs.exports=su});var Ss=p((lm,Ts)=>{"use strict";Is();var au=wt();Ts.exports=au("Array","at")});var As=p((um,ws)=>{"use strict";var ou=Ss();ws.exports=ou});var Nr=p((pm,Os)=>{"use strict";var cu=As();Os.exports=cu});var Hs=p((yf,Ds)=>{"use strict";var Eu=xr(),Iu=Tr(),Bs=Eu("keys");Ds.exports=function(r){return Bs[r]||(Bs[r]=Iu(r))}});var Gs=p((bf,Us)=>{"use strict";var xu=G();Us.exports=!xu(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Ks=p((Cf,Ws)=>{"use strict";var Tu=Se(),Su=z(),wu=qe(),Au=Hs(),Ou=Gs(),zs=Au("IE_PROTO"),Gr=Object,Ru=Gr.prototype;Ws.exports=Ou?Gr.getPrototypeOf:function(r){var e=wu(r);if(Tu(e,zs))return e[zs];var t=e.constructor;return Su(t)&&e instanceof t?t.prototype:e instanceof Gr?Ru:null}});var Xs=p((gf,Qs)=>{"use strict";var ku=Ge(),Pu=Math.max,Vu=Math.min;Qs.exports=function(r,e){var t=ku(r);return t<0?Pu(t+e,0):Vu(t,e)}});var zr=p((Ef,Zs)=>{"use strict";var Mu=Fe(),Nu=Xs(),Lu=ze(),Ys=function(r){return function(e,t,n){var i=Mu(e),s=Lu(i);if(s===0)return!r&&-1;var o=Nu(n,s),c;if(r&&t!==t){for(;s>o;)if(c=i[o++],c!==c)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=p((If,Js)=>{"use strict";Js.exports={}});var na=p((xf,ra)=>{"use strict";var ju=Q(),Wr=Se(),$u=Fe(),_u=zr().indexOf,Fu=ea(),ta=ju([].push);ra.exports=function(r,e){var t=$u(r),n=0,i=[],s;for(s in t)!Wr(Fu,s)&&Wr(t,s)&&ta(i,s);for(;e.length>n;)Wr(t,s=e[n++])&&(~_u(i,s)||ta(i,s));return i}});var sa=p((Tf,ia)=>{"use strict";ia.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var oa=p((Sf,aa)=>{"use strict";var qu=na(),Bu=sa();aa.exports=Object.keys||function(e){return qu(e,Bu)}});var da=p((wf,ha)=>{"use strict";var la=ue(),Du=G(),ua=Q(),Hu=Ks(),Uu=oa(),Gu=Fe(),zu=cr().f,pa=ua(zu),Wu=ua([].push),Ku=la&&Du(function(){var r=Object.create(null);return r[2]=2,!pa(r,2)}),ca=function(r){return function(e){for(var t=Gu(e),n=Uu(t),i=Ku&&Hu(t)===null,s=n.length,o=0,c=[],a;s>o;)a=n[o++],(!la||(i?a in t:pa(t,a)))&&Wu(c,r?[a,t[a]]:t[a]);return c}};ha.exports={entries:ca(!0),values:ca(!1)}});var ma=p(()=>{"use strict";var Qu=Ue(),Xu=da().values;Qu({target:"Object",stat:!0},{values:function(e){return Xu(e)}})});var va=p((Rf,fa)=>{"use strict";ma();var Yu=gt();fa.exports=Yu.Object.values});var ba=p((kf,ya)=>{"use strict";var Zu=va();ya.exports=Zu});var Ft=p((Pf,Ca)=>{"use strict";var Ju=ba();Ca.exports=Ju});var Ia=p(()=>{"use strict";var ep=Ue(),tp=zr().includes,rp=G(),np=St(),ip=rp(function(){return!Array(1).includes()});ep({target:"Array",proto:!0,forced:ip},{includes:function(e){return tp(this,e,arguments.length>1?arguments[1]:void 0)}});np("includes")});var Ta=p(($f,xa)=>{"use strict";Ia();var sp=wt();xa.exports=sp("Array","includes")});var wa=p((_f,Sa)=>{"use strict";var ap=Ta();Sa.exports=ap});var qt=p((Ff,Aa)=>{"use strict";var op=wa();Aa.exports=op});var Yr=p((rv,Na)=>{"use strict";var lp=_e();Na.exports=Array.isArray||function(e){return lp(e)==="Array"}});var ja=p((nv,La)=>{"use strict";var up=TypeError,pp=9007199254740991;La.exports=function(r){if(r>pp)throw up("Maximum allowed index exceeded");return r}});var Fa=p((iv,_a)=>{"use strict";var hp=Yr(),dp=ze(),mp=ja(),fp=Rr(),$a=function(r,e,t,n,i,s,o,c){for(var a=i,l=0,f=o?fp(o,c):!1,y,b;l<n;)l in t&&(y=f?f(t[l],l,e):t[l],s>0&&hp(y)?(b=dp(y),a=$a(r,e,y,b,a,s-1)-1):(mp(a+1),r[a]=y),a++),l++;return a};_a.exports=$a});var Da=p((sv,Ba)=>{"use strict";var vp=Be(),yp=vp("toStringTag"),qa={};qa[yp]="z";Ba.exports=String(qa)==="[object z]"});var Ua=p((av,Ha)=>{"use strict";var bp=Da(),Cp=z(),Dt=_e(),gp=Be(),Ep=gp("toStringTag"),Ip=Object,xp=Dt(function(){return arguments}())==="Arguments",Tp=function(r,e){try{return r[e]}catch(t){}};Ha.exports=bp?Dt:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=Tp(e=Ip(r),Ep))=="string"?t:xp?Dt(e):(n=Dt(e))==="Object"&&Cp(e.callee)?"Arguments":n}});var za=p((ov,Ga)=>{"use strict";var Sp=Q(),wp=z(),Zr=xt(),Ap=Sp(Function.toString);wp(Zr.inspectSource)||(Zr.inspectSource=function(r){return Ap(r)});Ga.exports=Zr.inspectSource});var Za=p((cv,Ya)=>{"use strict";var Op=Q(),Rp=G(),Wa=z(),kp=Ua(),Pp=Et(),Vp=za(),Ka=function(){},Qa=Pp("Reflect","construct"),Jr=/^\s*(?:class|function)\b/,Mp=Op(Jr.exec),Np=!Jr.test(Ka),it=function(e){if(!Wa(e))return!1;try{return Qa(Ka,[],e),!0}catch(t){return!1}},Xa=function(e){if(!Wa(e))return!1;switch(kp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Np||!!Mp(Jr,Vp(e))}catch(t){return!0}};Xa.sham=!0;Ya.exports=!Qa||Rp(function(){var r;return it(it.call)||!it(Object)||!it(function(){r=!0})||r})?Xa:it});var ro=p((lv,to)=>{"use strict";var Ja=Yr(),Lp=Za(),jp=Te(),$p=Be(),_p=$p("species"),eo=Array;to.exports=function(r){var e;return Ja(r)&&(e=r.constructor,Lp(e)&&(e===eo||Ja(e.prototype))?e=void 0:jp(e)&&(e=e[_p],e===null&&(e=void 0))),e===void 0?eo:e}});var io=p((uv,no)=>{"use strict";var Fp=ro();no.exports=function(r,e){return new(Fp(r))(e===0?0:e)}});var so=p(()=>{"use strict";var qp=Ue(),Bp=Fa(),Dp=qe(),Hp=ze(),Up=Ge(),Gp=io();qp({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Dp(this),n=Hp(t),i=Gp(t,0);return i.length=Bp(i,t,t,n,0,e===void 0?1:Up(e)),i}})});var ao=p(()=>{"use strict";var zp=St();zp("flat")});var co=p((fv,oo)=>{"use strict";so();ao();var Wp=wt();oo.exports=Wp("Array","flat")});var uo=p((vv,lo)=>{"use strict";var Kp=co();lo.exports=Kp});var ho=p((yv,po)=>{"use strict";var Qp=uo();po.exports=Qp});var ah={};zo(ah,{ContainerTypes:()=>I.ContainerTypes,ControlTypes:()=>I.ControlTypes,CustomError:()=>q,EVENT_NAMES:()=>M,EventActionTypes:()=>I.EventActionTypes,EventTypes:()=>I.EventTypes,Interactives:()=>at,ManifestController:()=>fe,SDKInfo:()=>sh,chapterIdsToVKVideoIds:()=>Ut,compareVersions:()=>jt,containerTypes:()=>hu,controlTypes:()=>du,eventActionTypes:()=>_r,eventTypes:()=>mu,getChapterIdByVkVideoId:()=>Mo,getVKVideoIdByMedia:()=>rn,getVideoRawIdByMedia:()=>Po,graphEventTypes:()=>Pe,hasEndTemplate:()=>rt,interactivesEventTypes:()=>L,isAreaControl:()=>pu,isButtonControl:()=>uu,isLastChapter:()=>Y,isOneTextCtrlContainer:()=>me,isSupportedManifest:()=>I.isSupportedManifest,isTextControl:()=>Ze,isVKVariantItem:()=>Vo,isValidManifest:()=>$r,migrateManifestToLatestVersion:()=>I.migrateManifestToLatestVersion,utils:()=>_o,vkVideoIdsToChapterIds:()=>nn});module.exports=Wo(ah);var Cn="1.0.33-dev.e991e8d3.0";var Xt=class{constructor(e){this.layout=e}},lt=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 Ee=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",B={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||{}),ut=({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"},pt=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,s,o,c,a,l;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} * ${(c=(o=e==null?void 0:e.text)==null?void 0:o.size)!=null?c:t.textSize})`,r.textContent=(l=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?l:t.textContent},ht=({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)},dt=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,s,o,c,a,l,f,y,b,g,A;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((l=(a=(c=e==null?void 0:e.shape)==null?void 0:c.border)==null?void 0:a.color)!=null?l:t.borderColor,(b=(y=(f=e==null?void 0:e.shape)==null?void 0:f.border)==null?void 0:y.alpha)!=null?b:t.borderAlpha)}`,r.style.borderRadius=`calc(${n.height} * ${(A=(g=e==null?void 0:e.shape)==null?void 0:g.roundCorners)!=null?A:t.roundCorners})`},Ie=({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 xe="interactive-control",j={common:xe,wrapper:`${xe}-wrapper`,disabled:`${xe}-disabled`,button:`${xe}-button`,area:`${xe}-area`,text:`${xe}-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(j.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=((i=this.control.layoutParams.innerSizesDependOn)!=null?i:B.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 mt=(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(j.common,j.area),n.setAttribute("data-testid",le.AREA),ht({target:n,props:this.control.props,fallback:w(d({},B),{backgroundColor:"transparent"})}),dt({target:n,props:this.control.props,fallback:w(d({},B),{borderAlpha:0}),dependsOn:this.container.dimensions}),Ie({target:n,layoutParams:this.control.layoutParams,fallback:B}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(j.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(j.disabled)}getElement(){return this.controlElement}};var ft=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 vt=(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(j.common,j.button),n.setAttribute("data-testid",le.BUTTON),Ie({target:n,layoutParams:this.control.layoutParams,fallback:B}),ht({target:n,props:this.control.props,fallback:B}),dt({target:n,props:this.control.props,fallback:B,dependsOn:this.container.dimensions}),ut({target:n,props:w(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=ft(this.control.type.trim().toLowerCase()),s=(o=i.firstElementChild)!=null?o:i;pt({target:s,props:this.control.props,fallback:B,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(j.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(j.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(j.common,j.text),n.setAttribute("data-testid",le.TEXT),Ie({target:n,layoutParams:this.control.layoutParams,fallback:B}),ut({target:n,props:w(d({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let i=ft(this.control.type.trim().toLowerCase()),s=(o=i.firstElementChild)!=null?o:i;pt({target:s,props:this.control.props,fallback:B,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 yt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new nr(r,e,t)},nr=class extends Ee{constructor(t,n,i){super(t,i);this.containerElement=null;this.rootElement=n,this.layout=new lt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",vt),this.addControlFactory("text",wn),this.addControlFactory("area",mt)}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,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}};var $o=ee(Nr(),1),S=require("@vkontakte/videoplayer-shared/es2015"),Ne=require("@vkontakte/videoplayer-statistics/es2015");var Ms=require("@vkontakte/videoplayer-shared/es2015");function We(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var pe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Ke=r=>pe(r,"Object"),At=r=>pe(r,"String"),Ot=r=>pe(r,"Array"),Rt=r=>pe(r,"Number"),Rs=r=>pe(r,"Function");var Lr=r=>Rt(r)&&!isNaN(r);var he=r=>Ke(r)&&Object.keys(r).length===0,jr=r=>Ot(r)&&!r.length;var Qe=(r,e)=>At(r)&&(e?r.trim():r).length;var ks="video_interactive",Ps="videoint";var Vs=250,Xe=class{constructor(e){this.handleZoomChange=We(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,"Chapter 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,!Rt(e.graph.edit.chapters[0].x)){(n=this.onError)==null||n.call(this,"Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError: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=lu(e),this.resizeObserver=new ResizeObserver(We(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 V(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 V(this,null,function*(){var n;if(!this.manifest)return;let e;try{e=yield(0,Ms.loadVKLangPack)(this.lang,ks,Ps)}catch(i){(n=this.onError)==null||n.call(this,"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",o=>{var c=o,{name:i}=c,s=J(c,["name"]);var a;i==="openPreview"&&"chapterId"in s&&((a=this.onOpenPreviewClick)==null||a.call(this,s.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 lu(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 Ye=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}}};var I=require("@interactiveplatform/movika-manifest");var Ns={metadata:"Object",chapters:"Array"},$r=r=>{if(!Ke(r))return!1;for(let e in Ns)if(!r[e]||!pe(r[e],Ns[e]))return!1;return(0,I.isSupportedManifest)(r.metadata.version)},Ze=r=>r.type===I.ControlTypes.Text,uu=r=>r.type===I.ControlTypes.Button,pu=r=>r.type===I.ControlTypes.Area,hu={Choice:"Choice",TextInput:"TextInput"},du={Button:"Button",Area:"Area",Text:"Text"},mu={onClick:"onClick",onSuspense:"onSuspense"},_r={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var q=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var kt=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let 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=[]}};var qs=require("@vkontakte/videoplayer-shared/es2015");var Vt=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 V(this,null,function*(){return fu(...this.loaders[e])(t)})}};function fu(...r){return function(t){return V(this,null,function*(){let n=[...r];for(;n.length>0;)t=yield n.shift()(t);return t})}}function Je(r,e,t){return r?w(d({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Mt(i){var s=i,{actions:r,errors:e,chapterId:t}=s,n=J(s,["actions","errors","chapterId"]);if(t){let o=r.getManifest();if(o){let c=r.getChapter(o.chapters,t);if(c){let a=r.getMedia(o.media,c.videoId),l=r.getGraph(o.graph,c.id);return a?w(d({},n),{actions:r,errors:e,result:{chapter:c,media:a,graph:l}}):w(d({},n),{errors:Je(e,Mt.name,"Could not find media"),actions:r})}}}return w(d({},n),{errors:Je(e,Mt.name,"Could not find chapter"),actions:r})}var Nt=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(c){Promise.resolve().then(()=>{throw c})}o.options&&o.options.once&&this.removeEventListener(e.type,o.callback)}return!e.defaultPrevented}},Re=class extends Nt{constructor(){super(),this.listeners||Nt.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)}},et=class{constructor(){Object.defineProperty(this,"signal",{value:new Re,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&&(et.prototype[Symbol.toStringTag]="AbortController",Re.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 Fr(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(l,f){let y;f&&f.signal&&(y=f.signal,delete f.signal);let b=new t(l,f);return y&&Object.defineProperty(b,"signal",{writable:!1,enumerable:!1,configurable:!0,value:y}),b},s.prototype=t.prototype);let o=e;return{fetch:(a,l)=>{let f=s&&s.prototype.isPrototypeOf(a)?a.signal:l?l.signal:void 0;if(f){let y;try{y=new DOMException("Aborted","AbortError")}catch(g){y=new Error("Aborted"),y.name="AbortError"}if(f.aborted)return Promise.reject(y);let b=new Promise((g,A)=>{f.addEventListener("abort",()=>A(y),{once:!0})});return l&&l.signal&&delete l.signal,Promise.race([b,o(a,l)])}return o(a,l)},Request:s}}var tt=Lt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ls=tt?Fr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,qr=tt?Ls.fetch:window.fetch,Km=tt?Ls.Request:window.Request,Qm=tt?et:window.AbortController,Xm=tt?Re:window.AbortSignal;var jt=(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 vu=r=>V(void 0,null,function*(){try{let e={},t;if(At(r)){t=new URL(r).href;let i=yield qr(t);if(!i.ok)return{};e=yield i.json()}else if(Ke(r))e=r;else return{};if(!$r(e))return{};let n=e.metadata.media;if(At(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let s=yield qr(i);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(i){return Cu(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function js(r){return V(this,null,function*(){let{manifest:e,manifestURL:t}=yield vu(r);if(!e)throw new Error("Failed on fetch");let n=(0,I.migrateManifestToLatestVersion)(e);return n.media=yu(n.media,t),delete n.metadata.media,n})}function $t(r,e){if(e)return r.find(t=>t.id===e)}function Br(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 Dr(r,e){return r.videos.find(t=>t.id===e)}function yu(r,e){return w(d({},r),{videos:r.videos.map(t=>w(d({},t),{variants:t.variants.map(n=>{let i="url"in n?n.url:"",s=bu(i,e);return w(d({},n),{url:s||i})})}))})}function bu(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Cu(r){return jt(r,"3.2.0")>=0}var _t=r=>Ot(r)&&!jr(r),Y=r=>r.order==="end",rt=r=>Ot(r.containers)&&!jr(r.containers)&&Y(r),$s=(r,e)=>{var n;let t=r*1e3;return _t(e.controls)&&t<((n=e.startTime)!=null?n:0)},Hr=(r,e)=>{var n,i;let t=r*1e3;return _t(e.controls)&&t>=((n=e.startTime)!=null?n:0)&&t<=((i=e.endTime)!=null?i:1/0)};var de=(r=[])=>r.some(e=>e.action.type==="expect"),Ur=(r=[])=>r.find(e=>e.action.type==="expect"),gu=r=>(r==null?void 0:r.length)===1,me=r=>gu(r)&&Ze(r[0]);function _s(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(d(d({},e[0]),t)):r(...e,...t)}var Fs=(r,e)=>{let t=E=>{let v=e.find(({container:k})=>k.container.id===E);return v==null?void 0:v.container.isRemoved},n=de(r.events)&&!t(r.id),i=(E,v=!1,k=!1)=>{let h=k?"every":"some";return E.controls[h](u=>{var x;let m=v?E.endTime===r.endTime:!0;return((x=u.events)==null?void 0:x[h](T=>{var C;return((C=T.action)==null?void 0:C.type)===_r.openURI}))&&m})},s=E=>E.some(({container:v})=>i(v.container,!0,!1)&&!v.isRemoved),o=E=>E.every(({container:v})=>v.isRemoved?!0:i(v.container,!0,!0)),c=e.filter(({container:E})=>E.container.id!==r.id&&de(E.container.events)&&E.container.endTime===r.endTime&&!E.isRemoved).length,a=E=>E.controls.some(v=>{var k;return(k=v.events)==null?void 0:k.some(h=>{var u,m;return(m=(u=h.action)==null?void 0:u.args)==null?void 0:m.shouldOpenNow})}),l=n||c>0,f=s(e),y=i(r),b=o(e),g=n?!1:c>0,A=a(r);return{isExpectTime:l,hasOtherExpect:c>0,hasOpenURIEvent:f,hasOpenURIEventInCurrentContainer:y,isAllOpenURIEventsValid:b,isExpectEventForCurrentContainer:g,hasShouldOpenNowEvent:A}};var fe=class extends Vt{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new qs.ValueSubject(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 V(this,null,function*(){var i;this.release();let n=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Je},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=yield js((i=n.result)!=null?i:t),this})}setInitial(){return V(this,null,function*(){return this.setNext()})}setNext(){return V(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",Mt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Br,getChapter:$t,getMedia:Dr,getByBranches:this.getByBranches.bind(this),addErrorMessage:Je},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=$t(this.manifest.chapters,t);if(i){let s=Dr(this.manifest.media,i.videoId),o=Br(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 c=$t(((o=this.manifest)==null?void 0:o.chapters)||[],t);return this.getByBranches(c==null?void 0:c.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?Y(this.chapter):!1}};var Oa=ee(Ft(),1),Ra=require("@vkontakte/videoplayer-core/es2015"),oe=require("@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=ee(Ft(),1);function Kr(){let r=new Map;function e(a){var l=a,{listId:s=Math.random().toString(),itemId:o=Math.random().toString()}=l,c=J(l,["listId","itemId"]);let f=r.get(s),y=d({},c);return f?f[o]=y:r.set(s,{[o]:y}),d({listId:s,itemId:o},c)}function t(s){var o,c;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(o=s.statistics)==null||o.oneStat.destroy(),(c=s.statistics)==null||c.statSubscription.unsubscribe()}function n(s,o){let c=r.get(s);if(!c)throw Error("Can't remove. Not find.");if(o){let a=c[o];a&&t(a),delete c[o],Object.keys(c).length||r.delete(s)}else{for(let a of(0,Ea.default)(c))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 ke=ee(qt(),1);function Qr(r,e=[]){var s,o,c;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,ke.default)(e,"mp4"))&&(t.MPEG=w(d({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"mpeg":(i||(0,ke.default)(e,"mpeg"))&&(t.MPEG=w(d({},t.MPEG),{[(o=a.standard)!=null?o:"Invariant quality"]:a.url}));break;case"hls":(i||(0,ke.default)(e,"hls"))&&(t=w(d({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(i||(0,ke.default)(e,"dash"))&&(t=w(d({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:n,title:(c=r.title)!=null?c:""}}var nt=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,ke.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var cp=2;function Xr(r){let e=Kr(),t=new oe.Subscription,n={},i=null,s=!1,o,c=new oe.ValueSubject(null);r&&a(r);function a(v){i=v}function l(v,k,h){var x;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let m=((x=e.map.get(v))!=null?x:{})[k];if(m){n=d({chapterId:h,listId:v,itemId:k},m);let T=n.player;n.subscription.add(T.info.currentQuality$.subscribe(C=>{let R=T.info.position$.getValue(),F=T.info.isAutoQualityEnabled$.getValue();if(!(!C||!R||F))for(let P of e.map)(0,Oa.default)(P[1]).forEach(({player:N})=>{nt(N,C)})})).add(T.events.started$.subscribe(()=>{f(k)})),m.container.remove(),i.setPlayer(m.player),s||(i.init(),s=!0),c.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}function f(v){return V(this,null,function*(){if(!i)throw Error("need to set interactive controller");if(he(n)||v!==n.itemId)return;let k=i.getChapterBranches(),h=new Set;for(let u of k)h.has(u.media.id)||(yield b({media:u.media,chapterId:u.chapter.id,setAsActive:!1,title:u.chapter.label}),h.add(u.media.id))})}function y(h){return V(this,arguments,function*({chapter:{id:v},manifestVideo:k}){if(he(n)||!i)return;let u=n.player.info.muted$.getValue(),m=n.player.info.currentQuality$.getValue(),x=n.player.info.isAutoQualityEnabled$.getValue(),T=n.player.info.volume$.getValue(),C=n.player.info.currentPlaybackRate$.getValue(),R=!x,F=!1;for(let P of e.map)if(P[0]===k.id&&!i.state.isReplay$.getValue()){let N=Object.keys(P[1]);for(let $ of N)$===n.itemId?(N.length<cp||(F=!0),e.removePlayer(P[0],$)):(F=!0,l(P[0],$,v),R?nt(n.player,m):n.player.setAutoQuality(!0),n.player.setVolume(T),n.player.setMuted(u),n.player.setPlaybackRate(C))}else e.removePlayer(P[0]);F||(yield b({media:k,chapterId:v,setAsActive:!0,playbackRate:C}),R?nt(n.player,m):n.player.setAutoQuality(!0),n.player.setVolume(T),n.player.setMuted(u))})}function b(R){return V(this,arguments,function*({media:v,chapterId:k,prefetch:h=!0,setAsActive:u=!0,autoplay:m=!1,preferredExt:x,title:T,playbackRate:C}){var on,cn,ln,un,pn;let F=Math.random().toString(),P=document.createElement("div");o.append(P);let N;if((on=i==null?void 0:i.options)!=null&&on.vkVideoLoader){let ot=ga(v);ot.length&&(N=yield i.options.vkVideoLoader(...ot))}let $=((cn=i==null?void 0:i.options)==null?void 0:cn.coreConfig)||void 0,Z=w(d({},$),{configName:[...(ln=$==null?void 0:$.configName)!=null?ln:[],"interactive"]}),ce=w(d({container:P},((un=N==null?void 0:N.videos)==null?void 0:un[0])||{sources:Qr(v,x).sources}),{title:T,failoverHosts:(N==null?void 0:N.failoverHosts)||[]}),D=new Ra.Player(Z,oe.Tracer.createRootTracer());D.initVideo(ce);let Ce=null;if(N!=null&&N.videos&&(i!=null&&i.options.createOneStat)){let ot=N.videos[0],Kt=i.options.createOneStat(ot),hn=new oe.Subscription;Kt&&(hn.add(Kt.attachTo(D)),Ce={oneStat:Kt,statSubscription:hn})}let an=new oe.Subscription,Fo=(pn=n==null?void 0:n.player)==null?void 0:pn.info.isAutoQualityEnabled$.getValue();an.add(D.events.canplay$.subscribe(function(){Fo||nt(D,n.player.info.currentQuality$.getValue()),C&&D.setPlaybackRate(C)}));let ge=e.createPlayer({listId:v.id,itemId:F,player:D,container:P,sources:Qr(v,x).sources,config:ce,subscription:an,statistics:Ce});return u&&l(v.id,ge.itemId,k),m&&ge.player.play(),h&&!m&&ge.player.prepare(),{player:ge.player,config:ge.config,statistics:ge.statistics}})}function g(){A(),i=null,o.remove()}function A(){t.unsubscribe(),e.removeAll(),n={},s=!1}function E(){return V(this,null,function*(){if(!i)throw Error("need to set interactive controller");A(),o=document.createElement("div");let{media:v,chapter:k}=i.getCurrentChapter();v&&k?(t.add(i.events.chapterChanged$.subscribe(y)),yield b({media:v,chapterId:k.id,title:k.label})):console.error("not found")})}return w(d({},e),{init:E,setInteractiveController:a,createPlayer:b,removeAll:g,getActivePlayer:function(){return n},activePlayerChanged:c})}var M={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Pe={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=ee(qt(),1),Va=require("@vkontakte/videoplayer-shared/es2015");var Bt=class{constructor({player:e,container:t,branches:n,selectBranches:i,interactiveEvents:s,globalEvents:o,globalEventEmitter:c,getContainerEventState:a,permanentTextControls:l,interactiveTimeOpenUri:f,disabledControls$:y,onRemove:b}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(de(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()){let{hasOpenURIEventInCurrentContainer:o}=this.getContainerEventState();if((n=(t=this.container).show)==null||n.call(t),this.interactiveTimeOpenUri&&o)return;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,l)=>{let{isExpectTime:f,hasOtherExpect:y,hasOpenURIEvent:b,hasOpenURIEventInCurrentContainer:g,isAllOpenURIEventsValid:A,hasShouldOpenNowEvent:E}=this.getContainerEventState(),v=this.interactiveTimeOpenUri&&!g,k=this.interactiveTimeOpenUri&&g;if((!this.interactiveTimeOpenUri||v)&&(this.isSelectedControlEvent=!0),a!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||v)){if(this.interactiveTimeOpenUri){let h=!y&&!A&&g;h&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:h})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&b&&this.gameState!==5){if(k){let u=((m,x,T,C)=>!m&&!x&&T||m&&!x&&T&&!C||m&&!x&&T&&C)(f,y,A,this.isSelectedContainerEvent);this.fakeRemoveView(u)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!f||!y||!E)&&(this.selectBranches.stopExpect(),l())}},isEOV:()=>this.gameState===4},c=_s(this.selectBranches.onControlEvent,o);this.container.createView({eventCallback:c}),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 l,f,y;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(Hr(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let b=this.gameState;this.gameState=3,b===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:b}=this.getContainerEventState(),g=this.selectBranches.state.isExpect,A=this.interactiveTimeOpenUri&&b;if(A&&!g){let E=this.container.getElement();E&&(E.style.visibility!=="hidden"&&((f=(l=this.container).hide)==null||f.call(l)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!A&&this.removeView()}let o=Hr(s,this.container.container),c=this.container.container.startTime?[this.container.container.startTime,(y=this.container.container.endTime)!=null?y:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:c,currentTime:s,isInteractiveTime:o};this.globalEventEmitter.emit(M.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new Va.Subscription,this.player=e,this.interactiveEvents=s,this.getContainerEventState=a,this.isPermanentText=l&&me(t.container.controls),this.interactiveTimeOpenUri=f,this.disabledControls$=y,this.onRemove=b,this.globalEventEmitter=c,this.gameState=0,this.globalEvents=o,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(M.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(M.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 n,i;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(n=this.container.container.endTime)!=null?n:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((i=this.container.container.endTime)!=null?i:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||t:de(this.container.container.events)||e;(this.isSelectedControlEvent||!n)&&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(M.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)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}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 Ma=(r=[])=>r.reduce((e,t,n)=>{var s,o,c;let i=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!Ze(a));if(_t(i)){let a=[(o=t.startTime)!=null?o:0,(c=t.endTime)!=null?c:1/0],l={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[l],range:a});else{let f=[],y=-1/0,b=1/0,g=[],A=[];for(let E=0;E<e.length;E++){let v=e[E];if(A.push(...v.subjects),v.range[0]<b&&(b=v.range[0]),v.range[1]>y&&(y=v.range[1]),a[0]>=v.range[0]&&a[1]<=v.range[1])return e[E].subjects.push(l),e;a[0]<v.range[0]&&a[1]>v.range[0]&&(f.push(E),g=g.concat(v.subjects)),a[0]>=v.range[0]&&a[0]<=v.range[1]&&(f.push(E),g=g.concat(v.subjects),a[0]=v.range[0]),a[1]>=v.range[0]&&a[1]<=v.range[1]&&(f.push(E),g=g.concat(v.subjects),a[1]=v.range[1])}if(A.push(l),a[0]<=b&&a[1]>=y)return[{subjects:A,range:a}];f.length&&f.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:g.concat([l]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var fo=ee(qt(),1),en=ee(Ft(),1),vo=ee(ho(),1);function mo(){let r={};function e(){for(let c in r)Object.prototype.hasOwnProperty.call(r,c)&&delete r[c]}function t(c){let a={};for(let l in r)+l<=c&&(a[l]=r[l]);return a}function n(c){let a={};for(let l in r)+l>=c&&(a[l]=r[l]);return a}function i({timestamp:c,priority:a,initiator:l}){var f;if(Lr(c)){let y=(f=r[c])!=null?f:null;if(y&&a&&Qe(a,!0)){let b={},g=y[a];if(g&&(b=d(d({},b),g)),b=he(b)?null:b,b&&Qe(l,!0)){let A=b[l];return A!=null?A:null}return b}return y}return null}function s({timestamp:c,priority:a,initiator:l}){if(Lr(c))if(r[c]){if(a&&Qe(a,!0))if(r[c][a]){if(l&&Qe(l,!0))if(r[c][a][l]){if(delete r[c][a][l],!he(r[c][a]))return!0}else return!1;if(delete r[c][a],!he(r[c]))return!0}else return!1;return delete r[c]}else return!1;return!1}function o(y){var b=y,{timestamp:c,priority:a,initiator:l}=b,f=J(b,["timestamp","priority","initiator"]);var g,A,E;(A=(g=r[c])==null?void 0:g[a])!=null&&A[l]?r[c][a][l].push(d({},f)):(E=r[c])!=null&&E[a]?r[c][a]=w(d({},r[c][a]),{[l]:[d({},f)]}):r[c]?r[c]=w(d({},r[c]),{[a]:{[l]:[d({},f)]}}):r[c]={[a]:{[l]:[d({},f)]}}}return{map:r,remove:s,add:o,removeAll:e,get:i,getLte:t,getGte:n}}var Xp=[I.EventActionTypes.expect,I.EventActionTypes.setNextBranch],Yp=1/0;function yo(r,e){let t=r,n,i=Zp(e),s=mo(),o,c=()=>{g(),h()},a=u=>{s.add.call(void 0,u),E()},l=(u=[])=>{for(let m of u)if(m.action(),(0,fo.default)(Xp,m.actionType))break},f=(u=1/0)=>{var C,R,F;let m=Ht((C=s.get({timestamp:u,priority:"control"}))!=null?C:{}),x=Ht((R=s.get({timestamp:u,priority:"container"}))!=null?R:{}),T=Ht((F=s.get({timestamp:u,priority:"chapter"}))!=null?F:{});return[...m,...x,...T]},y=u=>{i.isReady(u)&&l(f(u))},b=()=>{var u;l([...Ht((u=s.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},g=()=>{n&&(o==null||o.unsubscribe(),n=void 0)},A=u=>{},E=()=>{n||(n=()=>setTimeout(()=>{y(1/0)}),o=t.events.ended$.subscribe(n))},v=u=>{g(),t=u},k=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),s.remove(u)},h=()=>{i.release(),s.removeAll()};return{setPlayer:v,add:a,remove:k,exec:y,execEndOfVideo:b,listen:E,unlisten:g,release:c,containersEventsCallState:i,getPreparedToExecActions:f}}function Zp(r){let e=new Map;return{setCalled:({timestamp:c,id:a})=>{let l=e.get(c);l&&l[a]!==void 0&&(l[a]=!0)},setData:(c=[])=>{var a;for(let l of c){let f=(a=l.endTime)!=null?a:Yp,y=e.get(f);e.set(f,w(d({},y),{[l.id]:!1}))}},resetCalled:c=>{let a=e.get(c);if(a)for(let l in a)a[l]=!1},isReady:c=>{let a=e.get(c);if(!a)return!0;let l=(0,en.default)(a);return r?l.some(y=>y):!l.some(y=>!y)},release:()=>e.clear()}}function Ht(r){return(0,vo.default)((0,en.default)(r)).sort(e=>e.actionType===I.EventActionTypes.expect?-1:1)}var bo={videoContentHeight:0,videoContentWidth:0},Co=(r,e)=>{let{height:t,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&n))return bo;let{clientHeight:i,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(i&&s))return bo;let o=t/n,c=i/s,a,l;return c>o?(l=s,a=s*o):c<o?(l=i/o,a=i):(l=s,a=i),{videoContentWidth:l,videoContentHeight:a}};var Jp=250;function go(r){let e=()=>{},t=new ResizeObserver(c=>{s(c),e=s.bind(null,c)});function n(c){let{parentElement:a,player:l}=r();if(a&&l){let{videoContentWidth:f,videoContentHeight:y}=Co(a,l);a.style.setProperty("--interactive-content-width",`${f}px`),a.style.setProperty("--interactive-content-height",`${y}px`),a.style.setProperty("--interactive-width",`${c[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${c[0].contentRect.height}px`)}}function i(){let{parentElement:c}=r();c.removeAttribute("style")}let s=We(c=>{let{fns:a=[]}=r();n(c);for(let l of a)l()},Jp);function o(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var eh=r=>Math.floor(Math.random()*r),Io=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},xo=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 To=r=>{let e=r.length,t=eh(e);return r[t]},Eo=1,So=r=>{var n,i;let e=0;for(let s=0;s<r.length;++s)e+=(n=r[s].weight)!=null?n:Eo;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(i=r[s].weight)!=null?i:Eo,e>=t)return r[s];return r[r.length-1]};var wo={shouldOpenNow:!0,isDetachContainer:!0},Ao="after-expect";var tn=(r,e=!1)=>w(d({},r),{args:e?d(d({},r.args),wo):d(d({},wo),r.args)}),ko=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},s=()=>{i.isExpect&&(i.isExpect=!1)},o=({action:h,controlType:u,controlId:m,containerId:x,branches:T=[],onEvent:C,isEOV:R=()=>!1,isDisabled:F=()=>!1})=>{let P=tn(h,R()),N={timestamp:1/0,priority:"control",initiator:m,actionType:P.type},$=F(),Z=r.emit.bind(r,M.interactives,{subjectId:m,subjectType:u,subjectName:"control",type:$?L.actionChoiceCanceled:L.actionChoice,actionType:h.type,payload:d({invokeImmediately:P.args.shouldOpenNow,containerId:x},P.args)}),ce=()=>{e.interactiveActionChoice$.next({subjectId:m,subjectType:u,subjectName:"control",type:$?"action-choice-canceled":"action-choice",actionType:h.type,payload:d({invokeImmediately:P.args.shouldOpenNow,containerId:x},P.args)})};if($){Z(),ce();return}switch(P.type.trim().toLowerCase()){case I.EventActionTypes.setNextBranch.trim().toLowerCase():{let D=T.find(Ce=>Ce.id===P.args.branchId);if(!D)return;C(P.args.isDetachContainer,g.bind(null,{subjectId:m,subjectName:"control"})),Z(),ce(),P.args.shouldOpenNow?E({subjectId:m,subjectName:"control",subjectType:u,action:P,payload:{chapterId:D.chapterId,autoSelect:!1}}):n.add(w(d({},N),{action:E.bind(null,{subjectId:m,subjectName:"control",subjectType:u,action:P,payload:{chapterId:D.chapterId,autoSelect:!1}})}));return}case I.EventActionTypes.continuePlayback.trim().toLowerCase():{C(P.args.isDetachContainer,g.bind(null,{subjectId:m,subjectName:"control"})),Z(),ce(),P.args.shouldOpenNow?A({subjectId:m,subjectName:"control",subjectType:u,action:h}):n.add(w(d({},N),{action:A.bind(null,{subjectId:m,subjectName:"control",subjectType:u,action:h})}));return}case I.EventActionTypes.openURI.trim().toLowerCase():{C(P.args.isDetachContainer,g.bind(null,{subjectId:m,subjectName:"control"})),Z(),ce(),P.args.shouldOpenNow?k({subjectId:m,subjectName:"control",subjectType:u,action:P,payload:{URI:h.args.uri}}):n.add(w(d({},N),{action:k.bind(null,{subjectId:m,subjectName:"control",subjectType:u,action:P,payload:{URI:h.args.uri}})}));return}default:{let D="Unexpected control event",Ce=new q(1,1,{message:D});f(Ce,D);return}}},c=({action:h,container:{id:u,endTime:m},branches:x=[],isEOV:T=!1,autoSelected:C=!1})=>{let R=tn(h,T),F={timestamp:!R.args.shouldOpenNow||T?1/0:m!=null?m:1/0,priority:"container",initiator:u,actionType:R.type},P=r.emit.bind(r,M.interactives,{subjectId:u,subjectName:"container",type:L.actionChoice,actionType:R.type,payload:d({invokeImmediately:R.args.shouldOpenNow},R.args)}),N=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"container",type:"action-choice",actionType:R.type,payload:d({invokeImmediately:R.args.shouldOpenNow},R.args)})};switch(R.type.trim().toLowerCase()){case I.EventActionTypes.setNextBranch.trim().toLowerCase():{let $=x.find(Z=>Z.id===R.args.branchId);if(!$)return;P(),N(),n.add(w(d({},F),{action:E.bind(null,{subjectId:u,subjectName:"container",action:R,payload:{chapterId:$.chapterId,autoSelect:C}})}));return}case I.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case I.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case I.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case I.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case I.EventActionTypes.continuePlayback.trim().toLowerCase():{P(),N(),n.add(w(d({},F),{action:A.bind(null,{subjectId:u,subjectName:"container",action:R})}));return}case I.EventActionTypes.openURI.trim().toLowerCase():{P(),N(),n.add(w(d({},F),{action:k.bind(null,{subjectId:u,subjectName:"container",action:R,payload:{URI:h.args.uri}})}));return}default:{let $="Unexpected container event",Z=new q(1,1,{message:$});f(Z,$);return}}};function a({container:h,branches:u,isEOV:m=!1}){var T,C;let x=Ur(h.events);if(x){let R=tn(x.action,m);r.emit(M.interactives,{subjectId:h.id,subjectName:"container",type:L.actionChoice,actionType:R.type,payload:d({invokeImmediately:R.args.shouldOpenNow},R.args)}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"container",type:"action-choice",actionType:R.type,payload:d({invokeImmediately:R.args.shouldOpenNow},R.args)}),n.add({timestamp:m?1/0:(T=h.endTime)!=null?T:1/0,priority:"container",initiator:h.id,actionType:I.EventActionTypes.expect,action:b.bind(null,{subjectId:h.id,subjectName:"container"})}),i.isExpect=!0}else for(let R of(C=h.events)!=null?C:[])c({action:R.action,container:h,branches:u,isEOV:m})}let l=({chapterId:h,action:u,branches:m=[]})=>{let x=r.emit.bind(r,M.interactives,{subjectId:h,subjectName:"chapter",type:L.actionChoice,actionType:u.type,payload:u.args}),T=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"chapter",type:"action-choice",actionType:u.type,payload:u.args})};switch(u.type.trim().toLowerCase()){case I.EventActionTypes.setNextBranch.trim().toLowerCase():{let C=m.find(R=>R.id===u.args.branchId);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let C=To(m);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.setRandomBranch.trim().toLowerCase():{let C=So(m);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let C=xo(m);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let C=Io(m);return C!=null&&C.chapterId?(x(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case I.EventActionTypes.continuePlayback.trim().toLowerCase():return x(),T(),A.bind(null,{subjectId:h,subjectName:"chapter",action:u});case I.EventActionTypes.openURI.trim().toLowerCase():return x(),T(),k.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:{let C="Unexpected chapter event",R=new q(1,1,{message:C});f(R,C);return}}};function f(h,u){console.error(u),e.error$.next(h),r.emit(M.errors,h)}function y(h){var m;let u=Ur(h.events);if(u){if(Y(h))return;r.emit(M.interactives,{subjectId:h.id,subjectName:"chapter",type:L.actionChoice,actionType:u.action.type,payload:u.action.args}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"chapter",type:"action-choice",actionType:u.action.type,payload:u.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:I.EventActionTypes.expect,action:b.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else(m=h.events)==null||m.forEach(x=>{let T=l({chapterId:h.id,action:x.action,branches:h.branches});T&&n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:x.action.type,action:T})})}let b=({subjectId:h,subjectName:u})=>{t.pause(),r.emit(M.interactives,{subjectId:h,subjectName:u,type:L.actionExecution,actionType:I.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,type:"action-execution",actionType:I.EventActionTypes.expect})},g=({subjectId:h,subjectName:u})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(M.interactives,{subjectId:h,subjectName:u,type:L.actionExecution,actionType:Ao}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,type:"action-execution",actionType:Ao})},A=({subjectId:h,subjectName:u,subjectType:m,action:x})=>{r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:m,type:L.actionExecution,actionType:x.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:x.type})},E=({subjectId:h,subjectName:u,subjectType:m,action:x,payload:T})=>{T.behaviour="change-chapter",r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:m,type:L.actionExecution,actionType:x.type,payload:T}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:x.type,payload:T})},v=({subjectId:h,subjectName:u,subjectType:m,action:x,payload:T})=>{T.behaviour="change-manifest",r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:m,type:L.actionExecution,actionType:x.type,payload:T}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:x.type,payload:T})},k=({subjectId:h,subjectName:u,subjectType:m,action:x,payload:T})=>{if(!T.URI)return;let C=window.open(T.URI,"_blank","noopener,noreferrer");C&&(C.opener=null),r.emit(M.interactives,{subjectId:h,subjectName:u,subjectType:m,type:L.actionExecution,actionType:x.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:m,type:"action-execution",actionType:x.type})};return{onControlEvent:o,onContainerEvent:c,onChapterEvent:l,onExpectEvent:b,expectEventHandler:g,setManifestChapterEvents:y,setManifestContainerEvents:a,stopExpect:s,state:i}};var sn=ee(Nr(),1),K=require("@vkontakte/videoplayer-shared/es2015");var Ut=(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]=rn(s)}return t[n]}).filter(Boolean)},Po=r=>{for(let e of r.variants)if(Vo(e)&&e.payload)return e.payload.id},Vo=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),rn=r=>{let e=Po(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Mo=(r,e)=>{for(let t of r.media.videos)if(e===rn(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},nn=(r,e)=>r.reduce((t,n)=>{let i=Mo(e,n);return i?[...t,i]:t},[]);var ne,ve,ye,W,Gt,ie,se,re,be,Ve,Me,st=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:s}){this.state={history$:new K.ValueSubject([]),hasPrevChapter$:new K.ValueSubject(!1),prevChapter$:new K.ValueSubject(null),isInitialChapter$:new K.ValueSubject(!1),isGoBackLimited$:new K.ValueSubject(!1)};H(this,ne,null);H(this,ve);H(this,ye,!1);H(this,W,null);H(this,Gt,null);this.events={inited$:new K.Subject,destroyed$:new K.Subject,error$:new K.Subject};H(this,ie,null);H(this,se,null);H(this,re,null);H(this,be,new K.Subscription);H(this,Ve,!1);H(this,Me,0);var o;_(this,ie,t),_(this,re,e),_(this,se,n),_(this,ne,i),_(this,ve,s),this.state.history$&&O(this,be)&&((o=O(this,be))==null||o.add(this.state.history$.subscribe(c=>{var a,l;this.state.prevChapter$.next((0,sn.default)(c,-2)||null),this.state.hasPrevChapter$.next(c.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((l=(a=O(this,W))==null?void 0:a.metadata)==null?void 0:l.initChapterId)),this.state.isGoBackLimited$.next(O(this,Me)===O(this,ve).maxLength-1)})))}setManifest(e){return V(this,null,function*(){if(!O(this,se)||!O(this,re))return;_(this,W,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield O(this,se).setChapter({chapterId:t,pushToHistory:!1}),O(this,ye)||(_(this,ye,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return O(this,ye)}updateHistory(e,t=!0){return V(this,null,function*(){var c;if(!O(this,W))return;O(this,Ve)?(_(this,Ve,!1),bn(this,Me)._++):_(this,Me,0);let n=O(this,W),i=e.length-O(this,ve).maxLength,s=i>0?e.slice(i):e,o=Ut(s,n);if(_(this,Gt,o),this.state.history$.next(s),!(!t||!O(this,ne)||!O(this,ie)))try{yield O(this,ne).save(O(this,ie),o)}catch(a){let l=new q(1,5,"Unable to save interactive history");this.events.error$.next(l),(c=O(this,re))==null||c.emit(M.errors,l)}})}goBack(){return V(this,null,function*(){var n;if(!this.state||!O(this,se)){let i=new q(1,5,"Unable to save interactive history");return this.events.error$.next(i),(n=O(this,re))==null?void 0:n.emit(M.errors,i)}_(this,Ve,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield O(this,se).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return V(this,null,function*(){var i;if(!O(this,W)||!O(this,ie))return;let e=O(this,W),t=[this.getInitialVideoId()];if(O(this,ne))try{let s=yield O(this,ne).get(O(this,ie));s.length&&(t=s)}catch(s){let o=new q(1,5,"Error while trying to fetch data");this.events.error$.next(o),(i=O(this,re))==null||i.emit(M.errors,o)}let n=nn(t,e);this.state.history$.next(n)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,sn.default)(e,-1)||O(this,ve).initChapterId||((t=O(this,W))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(O(this,W)){let e=this.getInitialChapterId();return Ut([e],O(this,W)).pop()}return null}destroy(){var e,t;_(this,ie,null),_(this,ne,null),_(this,se,null),(e=O(this,be))==null||e.unsubscribe(),_(this,be,null),_(this,ye,!1),(t=O(this,re))==null||t.emit(M.historyDestroyed),this.events.destroyed$.next(),_(this,re,null)}};ne=new WeakMap,ve=new WeakMap,ye=new WeakMap,W=new WeakMap,Gt=new WeakMap,ie=new WeakMap,se=new WeakMap,re=new WeakMap,be=new WeakMap,Ve=new WeakMap,Me=new WeakMap;var zt=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 V(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 V(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 Wt=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;
@@ -42,19 +42,19 @@
42
42
 
43
43
  ${rh}
44
44
 
45
- .${L.common} {
45
+ .${j.common} {
46
46
  display: flex;
47
47
  width: 100%;
48
48
  height: 100%;
49
49
  font-family: inherit;
50
50
  }
51
51
 
52
- .${L.disabled} {
52
+ .${j.disabled} {
53
53
  cursor: default;
54
54
  }
55
55
 
56
- .${L.button},
57
- .${L.area} {
56
+ .${j.button},
57
+ .${j.area} {
58
58
  cursor: pointer;
59
59
  }
60
- `,jo=r=>{let e=document.createElement("style");e.textContent=nh,r.prepend(e)};var Lo=Object.freeze({lang:S.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function ih(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var at=class{constructor(e){this.playerSubscriptions=new S.Subscription;this.subscriptions=new S.Subscription;this.globalEventEmitter=new kt;this.animation=new Pt;this.seekToInteractiveController=new Ye;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=ih();this.factories=new Map([["choice",yt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new S.Subscription;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new S.ValueSubject(null),isInitialChapter$:new S.ValueSubject(!1),isFirstChapter$:new S.ValueSubject(!0),isEndChapter$:new S.ValueSubject(!1),isInteractiveExpectation$:new S.ValueSubject(!1),isReplay$:new S.ValueSubject(!1),calledByInteractive$:new S.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new S.ValueSubject(!1),disabledControls$:new S.ValueSubject(!1),interactiveRanges$:new S.ValueSubject([]),isInteractiveTime$:new S.ValueSubject(!1),statistics$:new S.ValueSubject(null),isSeekable$:new S.ValueSubject(!1)};this.events={noInteraction$:new S.Subject,graphVisibilityChanged$:new S.Subject,watchAgainIsClicked$:new S.Subject,chapterChanged$:new S.Subject,playerChanged$:new S.Subject,error$:new S.Subject,eachTick$:new S.Subject,manifestChanged$:new S.Subject,interactiveRangeEnded$:new S.Subject,interactiveContainerRemoved$:new S.Subject,interactiveContainerFakeRemoved$:new S.Subject,interactiveActionExecution$:new S.Subject,interactiveActionChoice$:new S.Subject,interactiveVisibilityChanged$:new S.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(M.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&&Y(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let i=e,{statistics:t}=i,n=J(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(M.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=>w(d({},s),{subjects:s.subjects.filter(o=>o.id!==e)}));t.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var n;this._options=w(d(d({},Lo),e),{config:d(d({},Lo.config),e.config)}),this._options.parentElement.append(this.rootElement),this.historyController=new st({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 Wt({parentElement:this._options.parentElement,onError:i=>{let s=new q(1,6,i);this.emitErrorEvent(s)}})),jo(this._options.parentElement),this.subscriptions.add((0,S.fromEvent)(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add((0,S.fromEvent)(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new fe(this._options.loaders,i=>{let s=new q(1,3,i);this.emitErrorEvent(s)});let t=[];this._options.lastFrame&&t.push(()=>{var i;(i=this.lastFrame)==null||i.updateCanvasDimensions(!0)}),this.resizeManager=go(()=>({player:this.player,parentElement:this._options.parentElement,fns:t})),this._options.graph&&(this.graph=new Xe({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(M.graph,{type:Pe.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let s=new q(1,2,{message:i});this.emitErrorEvent(s)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(t=>V(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.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).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 V(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(M.interactives,{type:j.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((0,S.once)()).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((0,S.combine)({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 l=e*1e3;i=!!t.find(({range:[y,b],subjects:g})=>y<l&&l<b&&g.some(A=>!A.isRemoved)&&g.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let s=!!this.noInteractionTimeout,c=((a=this.player)==null?void 0:a.info.playbackState$.getValue())==="playing"||n;i&&!s&&c?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):s&&!c&&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=>!me(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 c=new Bt({player:this.player,container:o,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>Fs(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)}});this.animation.addFn(c.whilePlaying,!0),t.push(c)}}),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 c,a;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(c=n&&Y(n)&&rt(n))!=null?c:!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,$o.default)(o,-1)!==e&&this.historyController.updateHistory([...o,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,s=n.getValue().map(o=>{let c=o.subjects.some(l=>l.id===e),a=o.subjects.map(l=>t&&c||l.id===e?w(d({},l),{isRemoved:!0}):l);return w(d({},o),{subjects:a})});n.next(s)}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 V(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(M.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=yo(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=ko({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){return V(this,arguments,function*({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){var a,l;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&S.clientChecker.isSafari&&(yield No(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:c}=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),(l=this.lastFrame)==null||l.setCurrentChapter(s),this.events.chapterChanged$.next({chapter:s,manifestVideo:o}),this.globalEventEmitter.emit(M.chapterChanged,{chapter:s,media:o,graph:c}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new S.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?Ne.InteractiveInterfaceClick.GRAPH_SHOW:Ne.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Ne.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(Ne.InteractiveInterfaceClick.NEXT_BUTTON),i==="Area"&&e.next(Ne.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new S.Observable(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}toggleGraphView(e=!0){return V(this,null,function*(){this.graph&&(e?(yield this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(M.graph,{type:Pe.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===I.EventActionTypes.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&&de(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,I.isSupportedManifest)(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 Ma((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 _o={Container:Ee,createChoiceContainer:yt,createAreaControl:mt,createButtonControl:vt,classnamesPrefix:En};var sh={version:Cn};
60
+ `,Lo=r=>{let e=document.createElement("style");e.textContent=nh,r.prepend(e)};var jo=Object.freeze({lang:S.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function ih(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var at=class{constructor(e){this.playerSubscriptions=new S.Subscription;this.subscriptions=new S.Subscription;this.globalEventEmitter=new kt;this.animation=new Pt;this.seekToInteractiveController=new Ye;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=ih();this.factories=new Map([["choice",yt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new S.Subscription;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new S.ValueSubject(null),isInitialChapter$:new S.ValueSubject(!1),isFirstChapter$:new S.ValueSubject(!0),isEndChapter$:new S.ValueSubject(!1),isInteractiveExpectation$:new S.ValueSubject(!1),isReplay$:new S.ValueSubject(!1),calledByInteractive$:new S.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new S.ValueSubject(!1),disabledControls$:new S.ValueSubject(!1),interactiveRanges$:new S.ValueSubject([]),isInteractiveTime$:new S.ValueSubject(!1),statistics$:new S.ValueSubject(null),isSeekable$:new S.ValueSubject(!1)};this.events={noInteraction$:new S.Subject,graphVisibilityChanged$:new S.Subject,watchAgainIsClicked$:new S.Subject,chapterChanged$:new S.Subject,playerChanged$:new S.Subject,error$:new S.Subject,eachTick$:new S.Subject,manifestChanged$:new S.Subject,interactiveRangeEnded$:new S.Subject,interactiveContainerRemoved$:new S.Subject,interactiveContainerFakeRemoved$:new S.Subject,interactiveActionExecution$:new S.Subject,interactiveActionChoice$:new S.Subject,interactiveVisibilityChanged$:new S.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(M.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&&Y(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let i=e,{statistics:t}=i,n=J(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(M.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=>w(d({},s),{subjects:s.subjects.filter(o=>o.id!==e)}));t.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var n;this._options=w(d(d({},jo),e),{config:d(d({},jo.config),e.config)}),this._options.parentElement.append(this.rootElement),this.historyController=new st({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 Wt({parentElement:this._options.parentElement,onError:i=>{let s=new q(1,6,i);this.emitErrorEvent(s)}})),Lo(this._options.parentElement),this.subscriptions.add((0,S.fromEvent)(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add((0,S.fromEvent)(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new fe(this._options.loaders,i=>{let s=new q(1,3,i);this.emitErrorEvent(s)});let t=[];this._options.lastFrame&&t.push(()=>{var i;(i=this.lastFrame)==null||i.updateCanvasDimensions(!0)}),this.resizeManager=go(()=>({player:this.player,parentElement:this._options.parentElement,fns:t})),this._options.graph&&(this.graph=new Xe({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(M.graph,{type:Pe.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let s=new q(1,2,{message:i});this.emitErrorEvent(s)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(t=>V(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.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).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 V(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(M.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((0,S.once)()).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((0,S.combine)({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 l=e*1e3;i=!!t.find(({range:[y,b],subjects:g})=>y<l&&l<b&&g.some(A=>!A.isRemoved)&&g.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let s=!!this.noInteractionTimeout,c=((a=this.player)==null?void 0:a.info.playbackState$.getValue())==="playing"||n;i&&!s&&c?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):s&&!c&&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=>!me(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 c=new Bt({player:this.player,container:o,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>Fs(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)}});this.animation.addFn(c.whilePlaying,!0),t.push(c)}}),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 c,a;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(c=n&&Y(n)&&rt(n))!=null?c:!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,$o.default)(o,-1)!==e&&this.historyController.updateHistory([...o,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,s=n.getValue().map(o=>{let c=o.subjects.some(l=>l.id===e),a=o.subjects.map(l=>t&&c||l.id===e?w(d({},l),{isRemoved:!0}):l);return w(d({},o),{subjects:a})});n.next(s)}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 V(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(M.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=yo(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=ko({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){return V(this,arguments,function*({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){var a,l;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&S.clientChecker.isSafari&&(yield No(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:c}=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),(l=this.lastFrame)==null||l.setCurrentChapter(s),this.events.chapterChanged$.next({chapter:s,manifestVideo:o}),this.globalEventEmitter.emit(M.chapterChanged,{chapter:s,media:o,graph:c}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new S.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?Ne.InteractiveInterfaceClick.GRAPH_SHOW:Ne.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Ne.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(Ne.InteractiveInterfaceClick.NEXT_BUTTON),i==="Area"&&e.next(Ne.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new S.Observable(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}toggleGraphView(e=!0){return V(this,null,function*(){this.graph&&(e?(yield this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(M.graph,{type:Pe.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===I.EventActionTypes.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&&de(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,I.isSupportedManifest)(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 Ma((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 _o={Container:Ee,createChoiceContainer:yt,createAreaControl:mt,createButtonControl:vt,classnamesPrefix:En};var sh={version:Cn};