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