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