@vkontakte/videoplayer-interactive 1.0.55 → 1.0.56-dev.d24d1c13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es2018.cjs.js DELETED
@@ -1,285 +0,0 @@
1
- /**
2
- * @vkontakte/videoplayer-interactive v1.0.55
3
- * Tue, 16 Dec 2025 09:27:22 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-55/doc/
5
- */
6
- "use strict";var El=Object.create;var mt=Object.defineProperty;var Tl=Object.getOwnPropertyDescriptor;var Il=Object.getOwnPropertyNames;var xl=Object.getPrototypeOf,Al=Object.prototype.hasOwnProperty;var Oi=r=>{throw TypeError(r)};var u=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),wl=(r,e)=>{for(var t in e)mt(r,t,{get:e[t],enumerable:!0})},ki=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Il(e))!Al.call(r,n)&&n!==t&&mt(r,n,{get:()=>e[n],enumerable:!(i=Tl(e,n))||i.enumerable});return r};var z=(r,e,t)=>(t=r!=null?El(xl(r)):{},ki(e||!r||!r.__esModule?mt(t,"default",{value:r,enumerable:!0}):t,r)),Sl=r=>ki(mt({},"__esModule",{value:!0}),r);var Pi=(r,e,t)=>e.has(r)||Oi("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)?Oi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),F=(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){F(r,e,n,t)},get _(){return R(r,e,i)}});var J=u((fr,Ui)=>{"use strict";var He=function(r){return r&&r.Math===Math&&r};Ui.exports=He(typeof globalThis=="object"&&globalThis)||He(typeof window=="object"&&window)||He(typeof self=="object"&&self)||He(typeof global=="object"&&global)||He(typeof fr=="object"&&fr)||function(){return this}()||Function("return this")()});var H=u((xd,Gi)=>{"use strict";Gi.exports=function(r){try{return!!r()}catch(e){return!0}}});var Ue=u((Ad,Wi)=>{"use strict";var kl=H();Wi.exports=!kl(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Yi=u((wd,Xi)=>{"use strict";var Pl=Ue(),Qi=Function.prototype,zi=Qi.apply,Ki=Qi.call;Xi.exports=typeof Reflect=="object"&&Reflect.apply||(Pl?Ki.bind(zi):function(){return Ki.apply(zi,arguments)})});var K=u((Sd,en)=>{"use strict";var Zi=Ue(),Ji=Function.prototype,vr=Ji.call,Vl=Zi&&Ji.bind.bind(vr,vr);en.exports=Zi?Vl:function(r){return function(){return vr.apply(r,arguments)}}});var Ge=u((Rd,rn)=>{"use strict";var tn=K(),Ml=tn({}.toString),_l=tn("".slice);rn.exports=function(r){return _l(Ml(r),8,-1)}});var br=u((Od,nn)=>{"use strict";var Ll=Ge(),Fl=K();nn.exports=function(r){if(Ll(r)==="Function")return Fl(r)}});var U=u((kd,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((Pd,sn)=>{"use strict";var Nl=H();sn.exports=!Nl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var At=u((Vd,an)=>{"use strict";var $l=Ue(),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,jl=cn&&!ln.call({1:2},1);un.f=jl?function(e){var t=cn(this,e);return!!t&&t.enumerable}:ln});var Cr=u((_d,pn)=>{"use strict";pn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var dn=u((Ld,hn)=>{"use strict";var Bl=K(),ql=H(),Dl=Ge(),Er=Object,Hl=Bl("".split);hn.exports=ql(function(){return!Er("z").propertyIsEnumerable(0)})?function(r){return Dl(r)==="String"?Hl(r,""):Er(r)}:Er});var Tr=u((Fd,mn)=>{"use strict";mn.exports=function(r){return r==null}});var Ir=u((Nd,fn)=>{"use strict";var Ul=Tr(),Gl=TypeError;fn.exports=function(r){if(Ul(r))throw new Gl("Can't call method on "+r);return r}});var We=u(($d,vn)=>{"use strict";var Wl=dn(),zl=Ir();vn.exports=function(r){return Wl(zl(r))}});var Re=u((jd,bn)=>{"use strict";var Kl=U();bn.exports=function(r){return typeof r=="object"?r!==null:Kl(r)}});var ze=u((Bd,yn)=>{"use strict";yn.exports={}});var wt=u((qd,Cn)=>{"use strict";var xr=ze(),Ar=J(),Ql=U(),gn=function(r){return Ql(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((Dd,En)=>{"use strict";var Xl=K();En.exports=Xl({}.isPrototypeOf)});var wn=u((Hd,An)=>{"use strict";var Yl=J(),In=Yl.navigator,xn=In&&In.userAgent;An.exports=xn?String(xn):""});var Mn=u((Ud,Vn)=>{"use strict";var Pn=J(),wr=wn(),Sn=Pn.process,Rn=Pn.Deno,On=Sn&&Sn.versions||Rn&&Rn.version,kn=On&&On.v8,Q,St;kn&&(Q=kn.split("."),St=Q[0]>0&&Q[0]<4?1:+(Q[0]+Q[1]));!St&&wr&&(Q=wr.match(/Edge\/(\d+)/),(!Q||Q[1]>=74)&&(Q=wr.match(/Chrome\/(\d+)/),Q&&(St=+Q[1])));Vn.exports=St});var Sr=u((Gd,Ln)=>{"use strict";var _n=Mn(),Zl=H(),Jl=J(),ec=Jl.String;Ln.exports=!!Object.getOwnPropertySymbols&&!Zl(function(){var r=Symbol("symbol detection");return!ec(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&_n&&_n<41})});var Rr=u((Wd,Fn)=>{"use strict";var tc=Sr();Fn.exports=tc&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Or=u((zd,Nn)=>{"use strict";var rc=wt(),ic=U(),nc=Tn(),oc=Rr(),sc=Object;Nn.exports=oc?function(r){return typeof r=="symbol"}:function(r){var e=rc("Symbol");return ic(e)&&nc(e.prototype,sc(r))}});var jn=u((Kd,$n)=>{"use strict";var ac=String;$n.exports=function(r){try{return ac(r)}catch(e){return"Object"}}});var kr=u((Qd,Bn)=>{"use strict";var lc=U(),cc=jn(),uc=TypeError;Bn.exports=function(r){if(lc(r))return r;throw new uc(cc(r)+" is not a function")}});var Dn=u((Xd,qn)=>{"use strict";var pc=kr(),hc=Tr();qn.exports=function(r,e){var t=r[e];return hc(t)?void 0:pc(t)}});var Un=u((Yd,Hn)=>{"use strict";var Pr=At(),Vr=U(),Mr=Re(),dc=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 dc("Can't convert object to primitive value")}});var Wn=u((Zd,Gn)=>{"use strict";Gn.exports=!0});var Qn=u((Jd,Kn)=>{"use strict";var zn=J(),mc=Object.defineProperty;Kn.exports=function(r,e){try{mc(zn,r,{value:e,configurable:!0,writable:!0})}catch(t){zn[r]=e}return e}});var Rt=u((em,Zn)=>{"use strict";var fc=Wn(),vc=J(),bc=Qn(),Xn="__core-js_shared__",Yn=Zn.exports=vc[Xn]||bc(Xn,{});(Yn.versions||(Yn.versions=[])).push({version:"3.43.0",mode:fc?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var _r=u((tm,eo)=>{"use strict";var Jn=Rt();eo.exports=function(r,e){return Jn[r]||(Jn[r]=e||{})}});var Ke=u((rm,to)=>{"use strict";var yc=Ir(),gc=Object;to.exports=function(r){return gc(yc(r))}});var Oe=u((im,ro)=>{"use strict";var Cc=K(),Ec=Ke(),Tc=Cc({}.hasOwnProperty);ro.exports=Object.hasOwn||function(e,t){return Tc(Ec(e),t)}});var Lr=u((nm,io)=>{"use strict";var Ic=K(),xc=0,Ac=Math.random(),wc=Ic(1.1.toString);io.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+wc(++xc+Ac,36)}});var Qe=u((om,oo)=>{"use strict";var Sc=J(),Rc=_r(),no=Oe(),Oc=Lr(),kc=Sr(),Pc=Rr(),ke=Sc.Symbol,Fr=Rc("wks"),Vc=Pc?ke.for||ke:ke&&ke.withoutSetter||Oc;oo.exports=function(r){return no(Fr,r)||(Fr[r]=kc&&no(ke,r)?ke[r]:Vc("Symbol."+r)),Fr[r]}});var co=u((sm,lo)=>{"use strict";var Mc=At(),so=Re(),ao=Or(),_c=Dn(),Lc=Un(),Fc=Qe(),Nc=TypeError,$c=Fc("toPrimitive");lo.exports=function(r,e){if(!so(r)||ao(r))return r;var t=_c(r,$c),i;if(t){if(e===void 0&&(e="default"),i=Mc(t,r,e),!so(i)||ao(i))return i;throw new Nc("Can't convert object to primitive value")}return e===void 0&&(e="number"),Lc(r,e)}});var Nr=u((am,uo)=>{"use strict";var jc=co(),Bc=Or();uo.exports=function(r){var e=jc(r,"string");return Bc(e)?e:e+""}});var mo=u((lm,ho)=>{"use strict";var qc=J(),po=Re(),$r=qc.document,Dc=po($r)&&po($r.createElement);ho.exports=function(r){return Dc?$r.createElement(r):{}}});var jr=u((cm,fo)=>{"use strict";var Hc=fe(),Uc=H(),Gc=mo();fo.exports=!Hc&&!Uc(function(){return Object.defineProperty(Gc("div"),"a",{get:function(){return 7}}).a!==7})});var yo=u(bo=>{"use strict";var Wc=fe(),zc=At(),Kc=gr(),Qc=Cr(),Xc=We(),Yc=Nr(),Zc=Oe(),Jc=jr(),vo=Object.getOwnPropertyDescriptor;bo.f=Wc?vo:function(e,t){if(e=Xc(e),t=Yc(t),Jc)try{return vo(e,t)}catch(i){}if(Zc(e,t))return Qc(!zc(Kc.f,e,t),e[t])}});var Co=u((pm,go)=>{"use strict";var eu=H(),tu=U(),ru=/#|\.prototype\./,Xe=function(r,e){var t=nu[iu(r)];return t===su?!0:t===ou?!1:tu(e)?eu(e):!!e},iu=Xe.normalize=function(r){return String(r).replace(ru,".").toLowerCase()},nu=Xe.data={},ou=Xe.NATIVE="N",su=Xe.POLYFILL="P";go.exports=Xe});var Br=u((hm,To)=>{"use strict";var Eo=br(),au=kr(),lu=Ue(),cu=Eo(Eo.bind);To.exports=function(r,e){return au(r),e===void 0?r:lu?cu(r,e):function(){return r.apply(e,arguments)}}});var xo=u((dm,Io)=>{"use strict";var uu=fe(),pu=H();Io.exports=uu&&pu(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var wo=u((mm,Ao)=>{"use strict";var hu=Re(),du=String,mu=TypeError;Ao.exports=function(r){if(hu(r))return r;throw new mu(du(r)+" is not an object")}});var Oo=u(Ro=>{"use strict";var fu=fe(),vu=jr(),bu=xo(),Ot=wo(),So=Nr(),yu=TypeError,qr=Object.defineProperty,gu=Object.getOwnPropertyDescriptor,Dr="enumerable",Hr="configurable",Ur="writable";Ro.f=fu?bu?function(e,t,i){if(Ot(e),t=So(t),Ot(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Ur in i&&!i[Ur]){var n=gu(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(Ot(e),t=So(t),Ot(i),vu)try{return qr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new yu("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Po=u((vm,ko)=>{"use strict";var Cu=fe(),Eu=Oo(),Tu=Cr();ko.exports=Cu?function(r,e,t){return Eu.f(r,e,Tu(1,t))}:function(r,e,t){return r[e]=t,r}});var Me=u((bm,Mo)=>{"use strict";var Ye=J(),Iu=Yi(),xu=br(),Au=U(),wu=yo().f,Su=Co(),Pe=ze(),Ru=Br(),Ve=Po(),Vo=Oe();Rt();var Ou=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 Iu(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?Ye:n?Ye[t]:Ye[t]&&Ye[t].prototype,s=i?Pe:Pe[t]||Ve(Pe,t,{})[t],l=s.prototype,c,d,f,v,y,E,T,m,p;for(v in e)c=Su(i?v:t+(n?".":"#")+v,r.forced),d=!c&&a&&Vo(a,v),E=s[v],d&&(r.dontCallGetSet?(p=wu(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=Ru(y,Ye):r.wrap&&d?m=Ou(y):o&&Au(y)?m=xu(y):m=y,(r.sham||y&&y.sham||E&&E.sham)&&Ve(m,"sham",!0),Ve(s,v,m),o&&(f=t+"Prototype",Vo(Pe,f)||Ve(Pe,f,{}),Ve(Pe[f],v,y),r.real&&l&&(c||!l[v])&&Ve(l,v,y)))}});var Lo=u((ym,_o)=>{"use strict";var ku=Math.ceil,Pu=Math.floor;_o.exports=Math.trunc||function(e){var t=+e;return(t>0?Pu:ku)(t)}});var Ze=u((gm,Fo)=>{"use strict";var Vu=Lo();Fo.exports=function(r){var e=+r;return e!==e||e===0?0:Vu(e)}});var $o=u((Cm,No)=>{"use strict";var Mu=Ze(),_u=Math.max,Lu=Math.min;No.exports=function(r,e){var t=Mu(r);return t<0?_u(t+e,0):Lu(t,e)}});var Bo=u((Em,jo)=>{"use strict";var Fu=Ze(),Nu=Math.min;jo.exports=function(r){var e=Fu(r);return e>0?Nu(e,9007199254740991):0}});var Je=u((Tm,qo)=>{"use strict";var $u=Bo();qo.exports=function(r){return $u(r.length)}});var Gr=u((Im,Ho)=>{"use strict";var ju=We(),Bu=$o(),qu=Je(),Do=function(r){return function(e,t,i){var n=ju(e),o=qu(n);if(o===0)return!r&&-1;var a=Bu(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 kt=u((xm,Uo)=>{"use strict";Uo.exports=function(){}});var Go=u(()=>{"use strict";var Du=Me(),Hu=Gr().includes,Uu=H(),Gu=kt(),Wu=Uu(function(){return!Array(1).includes()});Du({target:"Array",proto:!0,forced:Wu},{includes:function(e){return Hu(this,e,arguments.length>1?arguments[1]:void 0)}});Gu("includes")});var Pt=u((Sm,Wo)=>{"use strict";var zu=wt();Wo.exports=zu});var Ko=u((Rm,zo)=>{"use strict";Go();var Ku=Pt();zo.exports=Ku("Array","includes")});var Xo=u((Om,Qo)=>{"use strict";var Qu=Ko();Qo.exports=Qu});var Vt=u((km,Yo)=>{"use strict";var Xu=Xo();Yo.exports=Xu});var hs=u(()=>{"use strict";var ap=Me(),lp=Ke(),cp=Je(),up=Ze(),pp=kt();ap({target:"Array",proto:!0},{at:function(e){var t=lp(this),i=cp(t),n=up(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});pp("at")});var ms=u((zf,ds)=>{"use strict";hs();var hp=Pt();ds.exports=hp("Array","at")});var vs=u((Kf,fs)=>{"use strict";var dp=ms();fs.exports=dp});var ri=u((Qf,bs)=>{"use strict";var mp=vs();bs.exports=mp});var xs=u((pv,Is)=>{"use strict";var vp=_r(),bp=Lr(),Ts=vp("keys");Is.exports=function(r){return Ts[r]||(Ts[r]=bp(r))}});var ws=u((hv,As)=>{"use strict";var yp=H();As.exports=!yp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Os=u((dv,Rs)=>{"use strict";var gp=Oe(),Cp=U(),Ep=Ke(),Tp=xs(),Ip=ws(),Ss=Tp("IE_PROTO"),ii=Object,xp=ii.prototype;Rs.exports=Ip?ii.getPrototypeOf:function(r){var e=Ep(r);if(gp(e,Ss))return e[Ss];var t=e.constructor;return Cp(t)&&e instanceof t?t.prototype:e instanceof ii?xp:null}});var Ps=u((mv,ks)=>{"use strict";ks.exports={}});var _s=u((fv,Ms)=>{"use strict";var Ap=K(),ni=Oe(),wp=We(),Sp=Gr().indexOf,Rp=Ps(),Vs=Ap([].push);Ms.exports=function(r,e){var t=wp(r),i=0,n=[],o;for(o in t)!ni(Rp,o)&&ni(t,o)&&Vs(n,o);for(;e.length>i;)ni(t,o=e[i++])&&(~Sp(n,o)||Vs(n,o));return n}});var Fs=u((vv,Ls)=>{"use strict";Ls.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var $s=u((bv,Ns)=>{"use strict";var Op=_s(),kp=Fs();Ns.exports=Object.keys||function(e){return Op(e,kp)}});var oi=u((yv,Hs)=>{"use strict";var Bs=fe(),Pp=H(),qs=K(),Vp=Os(),Mp=$s(),_p=We(),Lp=gr().f,Ds=qs(Lp),Fp=qs([].push),Np=Bs&&Pp(function(){var r=Object.create(null);return r[2]=2,!Ds(r,2)}),js=function(r){return function(e){for(var t=_p(e),i=Mp(t),n=Np&&Vp(t)===null,o=i.length,a=0,s=[],l;o>a;)l=i[a++],(!Bs||(n?l in t:Ds(t,l)))&&Fp(s,r?[l,t[l]]:t[l]);return s}};Hs.exports={entries:js(!0),values:js(!1)}});var Us=u(()=>{"use strict";var $p=Me(),jp=oi().entries;$p({target:"Object",stat:!0},{entries:function(e){return jp(e)}})});var Ws=u((Ev,Gs)=>{"use strict";Us();var Bp=ze();Gs.exports=Bp.Object.entries});var Ks=u((Tv,zs)=>{"use strict";var qp=Ws();zs.exports=qp});var Xs=u((Iv,Qs)=>{"use strict";var Dp=Ks();Qs.exports=Dp});var ia=u(()=>{"use strict";var Qp=Me(),Xp=oi().values;Qp({target:"Object",stat:!0},{values:function(e){return Xp(e)}})});var oa=u((tb,na)=>{"use strict";ia();var Yp=ze();na.exports=Yp.Object.values});var aa=u((rb,sa)=>{"use strict";var Zp=oa();sa.exports=Zp});var Zt=u((ib,la)=>{"use strict";var Jp=aa();la.exports=Jp});var mi=u((xb,va)=>{"use strict";var th=Ge();va.exports=Array.isArray||function(e){return th(e)==="Array"}});var ya=u((Ab,ba)=>{"use strict";var rh=TypeError,ih=9007199254740991;ba.exports=function(r){if(r>ih)throw rh("Maximum allowed index exceeded");return r}});var Ea=u((wb,Ca)=>{"use strict";var nh=mi(),oh=Je(),sh=ya(),ah=Br(),ga=function(r,e,t,i,n,o,a,s){for(var l=n,c=0,d=a?ah(a,s):!1,f,v;c<i;)c in t&&(f=d?d(t[c],c,e):t[c],o>0&&nh(f)?(v=oh(f),l=ga(r,e,f,v,l,o-1)-1):(sh(l+1),r[l]=f),l++),c++;return l};Ca.exports=ga});var xa=u((Sb,Ia)=>{"use strict";var lh=Qe(),ch=lh("toStringTag"),Ta={};Ta[ch]="z";Ia.exports=String(Ta)==="[object z]"});var wa=u((Rb,Aa)=>{"use strict";var uh=xa(),ph=U(),er=Ge(),hh=Qe(),dh=hh("toStringTag"),mh=Object,fh=er(function(){return arguments}())==="Arguments",vh=function(r,e){try{return r[e]}catch(t){}};Aa.exports=uh?er:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=vh(e=mh(r),dh))=="string"?t:fh?er(e):(i=er(e))==="Object"&&ph(e.callee)?"Arguments":i}});var Ra=u((Ob,Sa)=>{"use strict";var bh=K(),yh=U(),fi=Rt(),gh=bh(Function.toString);yh(fi.inspectSource)||(fi.inspectSource=function(r){return gh(r)});Sa.exports=fi.inspectSource});var _a=u((kb,Ma)=>{"use strict";var Ch=K(),Eh=H(),Oa=U(),Th=wa(),Ih=wt(),xh=Ra(),ka=function(){},Pa=Ih("Reflect","construct"),vi=/^\s*(?:class|function)\b/,Ah=Ch(vi.exec),wh=!vi.test(ka),ut=function(e){if(!Oa(e))return!1;try{return Pa(ka,[],e),!0}catch(t){return!1}},Va=function(e){if(!Oa(e))return!1;switch(Th(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return wh||!!Ah(vi,xh(e))}catch(t){return!0}};Va.sham=!0;Ma.exports=!Pa||Eh(function(){var r;return ut(ut.call)||!ut(Object)||!ut(function(){r=!0})||r})?Va:ut});var $a=u((Pb,Na)=>{"use strict";var La=mi(),Sh=_a(),Rh=Re(),Oh=Qe(),kh=Oh("species"),Fa=Array;Na.exports=function(r){var e;return La(r)&&(e=r.constructor,Sh(e)&&(e===Fa||La(e.prototype))?e=void 0:Rh(e)&&(e=e[kh],e===null&&(e=void 0))),e===void 0?Fa:e}});var Ba=u((Vb,ja)=>{"use strict";var Ph=$a();ja.exports=function(r,e){return new(Ph(r))(e===0?0:e)}});var qa=u(()=>{"use strict";var Vh=Me(),Mh=Ea(),_h=Ke(),Lh=Je(),Fh=Ze(),Nh=Ba();Vh({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=_h(this),i=Lh(t),n=Nh(t,0);return n.length=Mh(n,t,t,i,0,e===void 0?1:Fh(e)),n}})});var Da=u(()=>{"use strict";var $h=kt();$h("flat")});var Ua=u((Nb,Ha)=>{"use strict";qa();Da();var jh=Pt();Ha.exports=jh("Array","flat")});var Wa=u(($b,Ga)=>{"use strict";var Bh=Ua();Ga.exports=Bh});var Ka=u((jb,za)=>{"use strict";var qh=Wa();za.exports=qh});var Yh={};wl(Yh,{ContainerTypes:()=>C.ContainerTypes,ControlTypes:()=>C.ControlTypes,CustomError:()=>N,EVENT_NAMES:()=>O,EventActionTypes:()=>C.EventActionTypes,EventTypes:()=>C.EventTypes,Interactives:()=>ht,ManifestController:()=>ge,SDKInfo:()=>Xh,chapterIdsToVKVideoIds:()=>rr,compareVersions:()=>Xt,containerTypes:()=>Ju,controlTypes:()=>ep,eventActionTypes:()=>rp,eventTypes:()=>tp,getChapterIdByVkVideoId:()=>hl,getVKVideoIdByMedia:()=>gi,getVideoRawIdByMedia:()=>ul,graphEventTypes:()=>Fe,hasEndTemplate:()=>tt,interactivesEventTypes:()=>_,isAreaControl:()=>Zu,isButtonControl:()=>Yu,isLastChapter:()=>X,isOneTextCtrlContainer:()=>be,isSupportedManifest:()=>C.isSupportedManifest,isTextControl:()=>et,isVKVariantItem:()=>pl,isValidManifest:()=>Wr,migrateManifestToLatestVersion:()=>C.migrateManifestToLatestVersion,utils:()=>gl,vkVideoIdsToChapterIds:()=>Ci});module.exports=Sl(Yh);var Mi="1.0.55";var rt=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 Li=require("@vkontakte/videoplayer-shared/es2018");function _i(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 Ae=class{constructor(e,t,i){this.error$=new Li.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&&_i(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"),Fi=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 Be=(r,e)=>bt(r)&&(e?r.trim():r).length;function qe(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=qe((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)},De=({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=qe(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=qe(i.shadowColorLight,i.shadowColorAlpha),s=qe(i.shadowColorDark,i.shadowColorAlpha),l=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${l} ${c} ${e?s:a}`;r.style.boxShadow=d},we=({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 Rl=60,It=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=Rl,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=Ol(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 Ol(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)},et=r=>r.type===C.ControlTypes.Text,Yu=r=>r.type===C.ControlTypes.Button,Zu=r=>r.type===C.ControlTypes.Area,Ju={Choice:"Choice",TextInput:"TextInput"},ep={Button:"Button",Area:"Area",Text:"Text"},tp={onClick:"onClick",onSuspense:"onSuspense"},rp={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",tt=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"),ip=r=>(r==null?void 0:r.length)===1,be=r=>ip(r)&&et(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 _t({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 w;let x=m?T.endTime===r.endTime:!0;return((w=b.events)==null?void 0:w[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`},Lt=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 Ft=(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"}}),we({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}),De({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 De({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,np=0,op=[np,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 sp(r){for(let e of op)if(r===e)return e}function cs(r){if(sp(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),we({target:i,layoutParams:this.control.layoutParams,fallback:M}),Tt({target:i,props:this.control.props,fallback:M}),De({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),we({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 Ae{constructor(t,i,n,o){super(t,n,o);this.containerElement=null;this.subscriptions=new rt.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",Ft)}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.setCssVarsManager(this.cssVarsManager),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,rt.fromEvent)(n,"transitionend").subscribe(this.onTransitionEnd,a=>this.onError(`${r.name} remove view transition error`,a))).add((0,rt.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 bl=z(ri(),1),A=require("@vkontakte/videoplayer-shared/es2018"),je=require("@vkontakte/videoplayer-statistics/es2018");var Es=require("@vkontakte/videoplayer-shared/es2018");function it(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var ys="video_interactive",gs="videoint";var Cs=250,nt=class{constructor(e){this.handleZoomChange=it(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=fp(e),this.resizeObserver=new ResizeObserver(it(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 fp(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 ot=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)=>{Fi(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 ra=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 Hp(...this.loaders[e])(t)}};function Hp(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function st(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:st(e,zt.name,"Could not find media"),actions:r}}}}return{...i,errors:st(e,zt.name,"Could not find chapter"),actions:r}}var{NativeAbortSignal:wv,NativeAbortController:Sv}=function(r){return{NativeAbortSignal:r.AbortSignal,NativeAbortController:r.AbortController}}(typeof self!="undefined"?self:global);function Zs(r){let e;try{e=new Event("abort")}catch(t){typeof document!="undefined"?document.createEvent?(e=document.createEvent("Event"),e.initEvent("abort",!1,!1)):(e=document.createEventObject(),e.type="abort"):e={type:"abort",bubbles:!1,cancelable:!1}}return e.reason=r,e}function Js(r){if(r===void 0)if(typeof document=="undefined")r=new Error("This operation was aborted"),r.name="AbortError";else try{r=new DOMException("signal is aborted without reason"),Object.defineProperty(r,"name",{value:"AbortError"})}catch(e){r=new Error("This operation was aborted"),r.name="AbortError"}return r}var 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}},_e=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)}throwIfAborted(){let{aborted:e,reason:t="Aborted"}=this;if(e)throw t}static timeout(e){let t=new ye;return setTimeout(()=>t.abort(new DOMException(`This signal is timeout in ${e}ms`,"TimeoutError")),e),t.signal}static any(e){let t=new ye;function i(){t.abort(this.reason),n()}function n(){for(let o of e)o.removeEventListener("abort",i)}for(let o of e)if(o.aborted){t.abort(o.reason);break}else o.addEventListener("abort",i);return t.signal}},ye=class{constructor(){Object.defineProperty(this,"signal",{value:new _e,writable:!0,configurable:!0})}abort(e){let t=Js(e),i=Zs(t);this.signal.reason=t,this.signal.dispatchEvent(i)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(ye.prototype[Symbol.toStringTag]="AbortController",_e.prototype[Symbol.toStringTag]="AbortSignal");function 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 Up=()=>"fetch"in window,at=Up()&&Qt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),ea=at?si({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,ai=at?ea.fetch:window.fetch,Nv=at?ea.Request:window.Request,$v=at?ye:window.AbortController,jv=at?_e: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 Gp=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 Kp(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function ta(r){let{manifest:e,manifestURL:t}=await Gp(r);if(!e)throw new Error("Failed on fetch");let i=(0,C.migrateManifestToLatestVersion)(e);return i.media=Wp(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 Wp(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=zp(n,e);return{...i,url:o||n}})}))}}function zp(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Kp(r){return Xt(r,"3.2.0")>=0}var ge=class extends Wt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new ra.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:st},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await ta((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:st},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 pa=z(Zt(),1),ha=require("@vkontakte/videoplayer-core/es2018"),pe=require("@vkontakte/videoplayer-shared/es2018");var ca=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 ua=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,ua.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 eh=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 w;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let x=((w=e.map.get(m))!=null?w:{})[p];if(x){i={chapterId:h,listId:m,itemId:p,...x};let g=i.player;i.subscription.add(g.info.currentQuality$.subscribe(I=>{let L=g.info.position$.getValue(),S=g.info.isAutoQualityEnabled$.getValue();if(!(!I||!L||S))for(let k of e.map)(0,pa.default)(k[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(),w=i.player.info.volume$.getValue(),g=i.player.info.currentPlaybackRate$.getValue(),I=!x,L=!1;for(let S of e.map)if(S[0]===p.id&&!n.state.isReplay$.getValue()){let k=Object.keys(S[1]);for(let V of k)V===i.itemId?(k.length<eh||(L=!0),e.removePlayer(S[0],V)):(L=!0,c(S[0],V,m),I?lt(i.player,b):i.player.setAutoQuality(!0),i.player.setVolume(w),i.player.setMuted(h),i.player.setPlaybackRate(g))}else e.removePlayer(S[0]);L||(await v({media:p,chapterId:m,setAsActive:!0,playbackRate:g}),I?lt(i.player,b):i.player.setAutoQuality(!0),i.player.setVolume(w),i.player.setMuted(h))}async function v({media:m,chapterId:p,prefetch:h=!0,setAsActive:b=!0,autoplay:x=!1,preferredExt:w,title:g,playbackRate:I}){var Ii,xi,Ai,wi,Si;let L=Math.random().toString(),S=document.createElement("div");a.append(S);let k;if((Ii=n==null?void 0:n.options)!=null&&Ii.vkVideoLoader){let dt=ca(m);dt.length&&(k=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:S,...((wi=k==null?void 0:k.videos)==null?void 0:wi[0])||{sources:pi(m,w).sources},title:g,failoverHosts:(k==null?void 0:k.failoverHosts)||[]},q=new ha.Player(Y,pe.TracerFactory.createRootTracer());q.initVideo(he);let Ie=null;if(k!=null&&k.videos&&(n!=null&&n.options.createOneStat)){let dt=k.videos[0],sr=n.options.createOneStat(dt),Ri=new pe.Subscription;sr&&(Ri.add(sr.attachTo(q)),Ie={oneStat:sr,statSubscription:Ri})}let Ti=new pe.Subscription,Cl=(Si=i==null?void 0:i.player)==null?void 0:Si.info.isAutoQualityEnabled$.getValue();Ti.add(q.events.canplay$.subscribe(function(){Cl||lt(q,i.player.info.currentQuality$.getValue()),I&&q.setPlaybackRate(I)}));let xe=e.createPlayer({listId:m.id,itemId:L,player:q,container:S,sources:pi(m,w).sources,config:he,subscription:Ti,statistics:Ie});return b&&c(m.id,xe.itemId,p),x&&xe.player.play(),h&&!x&&xe.player.prepare(),{player:xe.player,config:xe.config,statistics:xe.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 O={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"},_={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var ma=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 w=!E&&!p&&m;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,L,S,k)=>!I&&!L&&S||I&&!L&&S&&!k||I&&!L&&S&&k)(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(),t=e instanceof HTMLVideoElement;if(this.features.enableAvPlayerSupport&&(t||(t=e instanceof HTMLObjectElement&&(e==null?void 0:e.getAttribute("type"))==="application/avplayer")),!(t?e==null?void 0:e.readyState:void 0)||this.isRemovedOrDestroyed()&&!this.isPermanentText)return;let n=this.player.getExactTime();if(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(O.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new ma.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(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.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(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.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 fa=(r=[])=>r.reduce((e,t,i)=>{var o,a,s;let n=((o=t==null?void 0:t.controls)!=null?o:[]).filter(l=>!et(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 Xa=z(Vt(),1),bi=z(Zt(),1),Ya=z(Ka(),1);function Qa(){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&&Be(l,!0)){let v={},y=f[l];if(y&&(v={...v,...y}),v=de(v)?null:v,v&&Be(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&&Be(l,!0))if(r[s][l]){if(c&&Be(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 Dh=[C.EventActionTypes.expect,C.EventActionTypes.setNextBranch],Hh=1/0;function Za(r,e){let t=r,i,n=Uh(e),o=Qa(),a,s=()=>{y(),p()},l=h=>{o.add.call(void 0,h),E()},c=(h=[])=>{for(let b of h)if(b.action(),(0,Xa.default)(Dh,b.actionType))break},d=(h=1/0)=>{var g,I,L;let b=tr((g=o.get({timestamp:h,priority:"control"}))!=null?g:{}),x=tr((I=o.get({timestamp:h,priority:"container"}))!=null?I:{}),w=tr((L=o.get({timestamp:h,priority:"chapter"}))!=null?L:{});return[...b,...x,...w]},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 Uh(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:Hh,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,Ya.default)((0,bi.default)(r)).sort(e=>e.actionType===C.EventActionTypes.expect?-1:1)}var Ja={videoContentHeight:0,videoContentWidth:0},el=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Ja;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return Ja;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 Gh=250;function tl(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}=el(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=it(s=>{let{fns:l=[]}=r();i(s);for(let c of l)c()},Gh);function a(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:a}}var Wh=r=>Math.floor(Math.random()*r),il=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},nl=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 ol=r=>{let e=r.length,t=Wh(e);return r[t]},rl=1,sl=r=>{var i,n;let e=0;for(let o=0;o<r.length;++o)e+=(i=r[o].weight)!=null?i:rl;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(n=r[o].weight)!=null?n:rl,e>=t)return r[o];return r[r.length-1]};var al={shouldOpenNow:!0,isDetachContainer:!0},ll="after-expect",yi=(r,e=!1)=>({...r,args:e?{...r.args,...al}:{...al,...r.args}}),cl=({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:w=[],onEvent:g,isEOV:I=()=>!1,isDisabled:L=()=>!1})=>{let S=yi(p,I()),k={timestamp:1/0,priority:"control",initiator:b,actionType:S.type},V=L(),Y=r.emit.bind(r,O.interactives,{subjectId:b,subjectType:h,subjectName:"control",type:V?_.actionChoiceCanceled:_.actionChoice,actionType:p.type,payload:{invokeImmediately:S.args.shouldOpenNow,containerId:x,...S.args}}),he=()=>{e.interactiveActionChoice$.next({subjectId:b,subjectType:h,subjectName:"control",type:V?"action-choice-canceled":"action-choice",actionType:p.type,payload:{invokeImmediately:S.args.shouldOpenNow,containerId:x,...S.args}})};if(V){Y(),he();return}switch(S.type.trim().toLowerCase()){case C.EventActionTypes.setNextBranch.trim().toLowerCase():{let q=w.find(Ie=>Ie.id===S.args.branchId);if(!q)return;g(S.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),Y(),he(),S.args.shouldOpenNow?T({subjectId:b,subjectName:"control",subjectType:h,action:S,payload:{chapterId:q.chapterId,autoSelect:!1}}):i.add({...k,action:T.bind(null,{subjectId:b,subjectName:"control",subjectType:h,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"})),Y(),he(),S.args.shouldOpenNow?E({subjectId:b,subjectName:"control",subjectType:h,action:p}):i.add({...k,action:E.bind(null,{subjectId:b,subjectName:"control",subjectType:h,action:p})});return}case C.EventActionTypes.openURI.trim().toLowerCase():{g(S.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),Y(),he(),S.args.shouldOpenNow?m({subjectId:b,subjectName:"control",subjectType:h,action:S,payload:{URI:p.args.uri}}):i.add({...k,action:m.bind(null,{subjectId:b,subjectName:"control",subjectType:h,action:S,payload:{URI:p.args.uri}})});return}default:{let q="Unexpected control event",Ie=new N(1,1,{message:q});d(Ie,q);return}}},s=({action:p,container:{id:h,endTime:b},branches:x=[],isEOV:w=!1,autoSelected:g=!1})=>{let I=yi(p,w),L={timestamp:!I.args.shouldOpenNow||w?1/0:b!=null?b:1/0,priority:"container",initiator:h,actionType:I.type},S=r.emit.bind(r,O.interactives,{subjectId:h,subjectName:"container",type:_.actionChoice,actionType:I.type,payload:{invokeImmediately:I.args.shouldOpenNow,...I.args}}),k=()=>{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;S(),k(),i.add({...L,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():{S(),k(),i.add({...L,action:E.bind(null,{subjectId:h,subjectName:"container",action:I})});return}case C.EventActionTypes.openURI.trim().toLowerCase():{S(),k(),i.add({...L,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 w,g;let x=Kr(p.events);if(x){let I=yi(x.action,b);r.emit(O.interactives,{subjectId:p.id,subjectName:"container",type:_.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:(w=p.endTime)!=null?w: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,O.interactives,{subjectId:p,subjectName:"chapter",type:_.actionChoice,actionType:h.type,payload:h.args}),w=()=>{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(),w(),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=ol(b);return g!=null&&g.chapterId?(x(),w(),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=sl(b);return g!=null&&g.chapterId?(x(),w(),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=nl(b);return g!=null&&g.chapterId?(x(),w(),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=il(b);return g!=null&&g.chapterId?(x(),w(),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(),w(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h});case C.EventActionTypes.openURI.trim().toLowerCase():return x(),w(),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(O.errors,p)}function f(p){var b;let h=Kr(p.events);if(h){if(X(p))return;r.emit(O.interactives,{subjectId:p.id,subjectName:"chapter",type:_.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 w=c({chapterId:p.id,action:x.action,branches:p.branches});w&&i.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:x.action.type,action:w})})}let v=({subjectId:p,subjectName:h})=>{t.pause(),r.emit(O.interactives,{subjectId:p,subjectName:h,type:_.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(O.interactives,{subjectId:p,subjectName:h,type:_.actionExecution,actionType:ll}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:ll})},E=({subjectId:p,subjectName:h,subjectType:b,action:x})=>{r.emit(O.interactives,{subjectId:p,subjectName:h,subjectType:b,type:_.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:w})=>{w.behaviour="change-chapter",r.emit(O.interactives,{subjectId:p,subjectName:h,subjectType:b,type:_.actionExecution,actionType:x.type,payload:w}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:b,type:"action-execution",actionType:x.type,payload:w})},m=({subjectId:p,subjectName:h,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(O.interactives,{subjectId:p,subjectName:h,subjectType:b,type:_.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)},ul=r=>{for(let e of r.variants)if(pl(e)&&e.payload)return e.payload.id},pl=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),gi=r=>{let e=ul(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},hl=(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=hl(e,i);return n?[...t,n]:t},[]);var oe,Ce,Ee,G,ir,se,ae,te,Te,Ne,$e,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,Ce);D(this,Ee,!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,Te,new W.Subscription);D(this,Ne,!1);D(this,$e,0);var a;F(this,se,t),F(this,te,e),F(this,ae,i),F(this,oe,n),F(this,Ce,o),this.state.history$&&R(this,Te)&&((a=R(this,Te))==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,$e)===R(this,Ce).maxLength-1)})))}async setManifest(e){if(!R(this,ae)||!R(this,te))return;F(this,G,e),await this.getProjectHistory();let t=this.getInitialChapterId();await R(this,ae).setChapter({chapterId:t,pushToHistory:!1}),R(this,Ee)||(F(this,Ee,!0),this.events.inited$.next({initChapterId:t}))}get inited(){return R(this,Ee)}async updateHistory(e,t=!0){var s;if(!R(this,G))return;R(this,Ne)?(F(this,Ne,!1),Vi(this,$e)._++):F(this,$e,0);let i=R(this,G),n=e.length-R(this,Ce).maxLength,o=n>0?e.slice(n):e,a=rr(o,i);if(F(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(O.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(O.errors,n)}F(this,Ne,!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(O.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,Ce).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;F(this,se,null),F(this,oe,null),F(this,ae,null),(e=R(this,Te))==null||e.unsubscribe(),F(this,Te,null),F(this,Ee,!1),(t=R(this,te))==null||t.emit(O.historyDestroyed),this.events.destroyed$.next(),F(this,te,null)}};oe=new WeakMap,Ce=new WeakMap,Ee=new WeakMap,G=new WeakMap,ir=new WeakMap,se=new WeakMap,ae=new WeakMap,te=new WeakMap,Te=new WeakMap,Ne=new WeakMap,$e=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
- position: absolute;
8
- top: 0;
9
- left: 0;
10
- width: var(--interactive-width);
11
- height: var(--interactive-height);
12
- background-color: var(--black);
13
- visibility: hidden;
14
- `,this.lastFrameCanvas=new nr,this.endOffsetMs=t,this._callbacks={onError:i},this.lastFrameCanvas.rootElement.style.cssText=`
15
- position: absolute;
16
- top: 50%;
17
- left: 50%;
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 dl(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var ml=`/* interactive-container */
20
- .interactive-container {
21
- opacity: 1;
22
- visibility: visible;
23
- transition: opacity var(--interactive-transition-1);
24
- }
25
-
26
- .interactive-container-disabled {
27
- opacity: 0.5;
28
- }
29
-
30
- .interactive-container-hidden {
31
- visibility: hidden;
32
- }
33
-
34
- .interactive-container.interactive-container-before-remove.interactive-container-before-remove-delay {
35
- transition-delay: var(--interactive-remove-delay);
36
- }
37
-
38
- .interactive-container.interactive-container-before-remove {
39
- transition: opacity var(--interactive-transition-1);
40
- opacity: 0;
41
- pointer-events: none;
42
- }
43
-
44
- /* blink-anim */
45
- .interactive-control-blink-anim {
46
- animation-duration: 2001ms;
47
- animation-iteration-count: infinite;
48
- animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
49
- }
50
-
51
- .interactive-control-blink-anim-button {
52
- animation-name: interactive-blinking-button;
53
- }
54
-
55
- .interactive-control-blink-anim-area {
56
- animation-name: interactive-blinking-area;
57
- }
58
-
59
- @keyframes interactive-blinking-area {
60
- 0%, 100% {
61
- opacity: 1;
62
- }
63
- 50% {
64
- opacity: var(--interactive-area-hover-opacity);
65
- }
66
- }
67
-
68
- @keyframes interactive-blinking-button {
69
- 0%, 100% {
70
- opacity: 1;
71
- }
72
- 50% {
73
- opacity: var(--interactive-button-hover-opacity);
74
- }
75
- }
76
-
77
- /* blink-anim-reference */
78
- .interactive-blink-anim-reference {
79
- position: absolute;
80
- height: 0;
81
- width: 0;
82
- top: 0;
83
- left: 0;
84
- pointer-events: none;
85
- }
86
-
87
- .interactive-blink-anim-reference-animation {
88
- animation-duration: 2001ms;
89
- animation-iteration-count: infinite;
90
- animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
91
- animation-name: interactive-blinking-button;
92
- }
93
-
94
- .interactive-blink-anim-reference-disabled {
95
- animation: none;
96
- }
97
-
98
- /* control tap */
99
- .interactive-control-tap {
100
- position: absolute;
101
- aspect-ratio: 1;
102
- background-color: var(--interactive-bg-color-1);
103
- border: 1px solid var(--interactive-color-1);
104
- border-radius: 50%;
105
- transition: opacity var(--interactive-transition-1);
106
- opacity: 0;
107
- pointer-events: none;
108
- z-index: 1;
109
- }
110
-
111
- .interactive-control-tap-animation {
112
- animation-duration: 300ms;
113
- animation-iteration-count: 1;
114
- animation-timing-function: ease;
115
- animation-name: interactive-control-tap-bounce;
116
- }
117
-
118
- @keyframes interactive-control-tap-bounce {
119
- 0%, 100% {
120
- transform: scale(1);
121
- }
122
- 50% {
123
- transform: scale(0.3);
124
- }
125
- }
126
-
127
- .interactive-container:not(.interactive-container-disabled) .interactive-control-tap-visible {
128
- opacity: 1;
129
- }
130
-
131
- /* interactive-chapter */
132
- .interactive-chapter {
133
- position: absolute;
134
- top: 0;
135
- left: 0;
136
- font-family: inherit;
137
-
138
- --interactive-transition-1: 100ms ease-in-out;
139
- --interactive-transition-2: 400ms cubic-bezier(0.4, 0, 0.2, 1);
140
- --interactive-color-1: #fff;
141
- --interactive-bg-color-1: rgba(255, 255, 255, 0.08);
142
- --interactive-button-hover-opacity: 0.8;
143
- --interactive-area-hover-opacity: 0;
144
- --interactive-remove-delay: 300ms;
145
- }
146
-
147
- /* interactive-control */
148
- .interactive-control-wrapper-selected {
149
- pointer-events: none;
150
- }
151
-
152
- .interactive-control {
153
- display: flex;
154
- width: 100%;
155
- height: 100%;
156
- font-family: inherit;
157
-
158
- position: relative;
159
- isolation: isolate;
160
- opacity: 1;
161
-
162
- box-shadow: none;
163
- border: none;
164
- }
165
-
166
- .interactive-control.interactive-control-disabled {
167
- cursor: default;
168
- }
169
-
170
- .interactive-control-button,
171
- .interactive-control-area {
172
- cursor: pointer;
173
- }
174
-
175
- .interactive-control-button {
176
- transition: opacity var(--interactive-transition-2);
177
- }
178
-
179
- .interactive-control-area {
180
- transition: border-color var(--interactive-transition-1), box-shadow var(--interactive-transition-1), opacity var(--interactive-transition-2);
181
- }
182
-
183
- .interactive-control-wrapper-selected > .interactive-control-button {
184
- transition: opacity var(--interactive-transition-1);
185
- opacity: 0.5;
186
- }
187
-
188
- .interactive-control-wrapper-selected > .interactive-control-area {
189
- transition: opacity var(--interactive-transition-1);
190
- opacity: 0;
191
- }
192
-
193
-
194
- .interactive-control.interactive-control-before-remove {
195
- transition: opacity var(--interactive-transition-1);
196
- opacity: 0;
197
- pointer-events: none;
198
- }
199
-
200
- .interactive-container.interactive-container-disabled .interactive-control-button,
201
- .interactive-container.interactive-container-disabled .interactive-control-area {
202
- animation: none;
203
- }
204
-
205
- .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-button:not(.interactive-control-blink-anim):hover,
206
- .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-button:not(.interactive-control-blink-anim):focus-visible {
207
- opacity: var(--interactive-button-hover-opacity);
208
- animation: none;
209
- }
210
-
211
- .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-area:not(.interactive-control-blink-anim):hover,
212
- .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-area:not(.interactive-control-blink-anim):focus-visible {
213
- opacity: var(--interactive-area-hover-opacity);
214
- animation: none;
215
- }
216
-
217
- /* fill animation */
218
- .interactive-control-fill-animation {
219
- position: absolute;
220
- overflow: hidden;
221
- z-index: -1;
222
- pointer-events: none;
223
- }
224
-
225
- .interactive-control-fill-animation-filler-wrapper {
226
- position: absolute;
227
- width: 100%;
228
- height: 100%;
229
- transform-origin: center;
230
- }
231
-
232
- .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-fill-width {
233
- top: 0;
234
- }
235
-
236
- .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-fill-height {
237
- left: 0;
238
- }
239
-
240
- .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-right {
241
- right: 0;
242
- }
243
-
244
- .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-left {
245
- left: 0;
246
- }
247
-
248
- .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-top {
249
- top: 0;
250
- }
251
-
252
- .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-bottom {
253
- bottom: 0;
254
- }
255
-
256
- .interactive-control-fill-animation-filler {
257
- width: 100%;
258
- height: 100%;
259
- background-color: rgba(173, 211, 255, 0.32);
260
- }
261
-
262
- .interactive-control-fill-animation-filler.interactive-control-fill-animation-fill-width {
263
- transform: scaleX(0);
264
- }
265
-
266
- .interactive-control-fill-animation-filler.interactive-control-fill-animation-fill-height {
267
- transform: scaleY(0);
268
- }
269
-
270
- .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-right {
271
- transform-origin: right;
272
- }
273
-
274
- .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-left {
275
- transform-origin: left;
276
- }
277
-
278
- .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-top {
279
- transform-origin: top;
280
- }
281
-
282
- .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-bottom {
283
- transform-origin: bottom;
284
- }
285
- `;var fl=r=>{let e=document.createElement("style");e.textContent=ml,r.prepend(e)};var yl=require("@vkontakte/videoplayer-core/es2018");var vl=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},enableAvPlayerSupport:!1});function Qh(){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 ot;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Qh();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(O.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(O.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={...vl,...e,config:{...vl.config,...e.config}},(n=this._options.animationsFeatureToggles)==null?void 0:n.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new Lt,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)}})),fl(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 ge(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=tl(()=>({player:this.player,cssVarsManager:this.cssVarsManager,parentElement:this._options.parentElement,fns:i})),this._options.graph&&(this.graph=new nt({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:s=>{this.setChapter({chapterId:s}),this.globalEventEmitter.emit(O.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),(e.actionType==="setNextBranch"||!this._options.endChapterHistoryFix)&&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(O.interactives,{type:_.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,enableAvPlayerSupport:this._options.enableAvPlayerSupport}});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)&&tt(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,bl.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._options.endChapterHistoryFix&&this.state.lastChapterChangeWasInitiatedByInteractive$.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)};_t({...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?_t({...e,gameControllers:this.gameControllers,execFn:ct(di(t),!1)}):_t({...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(O.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=Za(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=cl({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&&yl.clientChecker.browser.isSafari&&await dl(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(O.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?je.InteractiveInterfaceClick.GRAPH_SHOW:je.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(je.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(je.InteractiveInterfaceClick.NEXT_BUTTON),n==="Area"&&e.next(je.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(O.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 fa((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 gl={Container:Ae,createChoiceContainer:Dt,createAreaControl:Ft,createButtonControl:qt,classnamesPrefix:$i};var Xh={version:Mi};