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