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