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