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