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