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