@vkontakte/videoplayer-interactive 1.0.36-dev.5119b35a.0 → 1.0.36-dev.62c89fb9.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/esnext.cjs.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.36-dev.5119b35a.0
3
- * Tue, 29 Apr 2025 12:25:21 GMT
2
+ * @vkontakte/videoplayer-interactive v1.0.36-dev.62c89fb9.0
3
+ * Wed, 07 May 2025 06:34:17 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-36/doc/
5
5
  */
6
- "use strict";var Fs=Object.create;var et=Object.defineProperty;var Vs=Object.getOwnPropertyDescriptor;var Ns=Object.getOwnPropertyNames;var $s=Object.getPrototypeOf,js=Object.prototype.hasOwnProperty;var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),_s=(r,e)=>{for(var t in e)et(r,t,{get:e[t],enumerable:!0})},ai=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ns(e))!js.call(r,n)&&n!==t&&et(r,n,{get:()=>e[n],enumerable:!(i=Vs(e,n))||i.enumerable});return r};var W=(r,e,t)=>(t=r!=null?Fs($s(r)):{},ai(e||!r||!r.__esModule?et(t,"default",{value:r,enumerable:!0}):t,r)),Bs=r=>ai(et({},"__esModule",{value:!0}),r);var X=p((Jt,gi)=>{"use strict";var Re=function(r){return r&&r.Math===Math&&r};gi.exports=Re(typeof globalThis=="object"&&globalThis)||Re(typeof window=="object"&&window)||Re(typeof self=="object"&&self)||Re(typeof global=="object"&&global)||Re(typeof Jt=="object"&&Jt)||function(){return this}()||Function("return this")()});var B=p((Oh,Ci)=>{"use strict";Ci.exports=function(r){try{return!!r()}catch{return!0}}});var ke=p((Ph,Ei)=>{"use strict";var Hs=B();Ei.exports=!Hs(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var wi=p((Mh,Ai)=>{"use strict";var Us=ke(),xi=Function.prototype,Ti=xi.apply,Ii=xi.call;Ai.exports=typeof Reflect=="object"&&Reflect.apply||(Us?Ii.bind(Ti):function(){return Ii.apply(Ti,arguments)})});var H=p((Lh,ki)=>{"use strict";var Si=ke(),Ri=Function.prototype,er=Ri.call,Gs=Si&&Ri.bind.bind(er,er);ki.exports=Si?Gs:function(r){return function(){return er.apply(r,arguments)}}});var Oe=p((Fh,Pi)=>{"use strict";var Oi=H(),zs=Oi({}.toString),Ws=Oi("".slice);Pi.exports=function(r){return Ws(zs(r),8,-1)}});var tr=p((Vh,Mi)=>{"use strict";var Ks=Oe(),Xs=H();Mi.exports=function(r){if(Ks(r)==="Function")return Xs(r)}});var q=p((Nh,Li)=>{"use strict";var rr=typeof document=="object"&&document.all;Li.exports=typeof rr>"u"&&rr!==void 0?function(r){return typeof r=="function"||r===rr}:function(r){return typeof r=="function"}});var se=p(($h,Fi)=>{"use strict";var Qs=B();Fi.exports=!Qs(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ht=p((jh,Vi)=>{"use strict";var Ys=ke(),ut=Function.prototype.call;Vi.exports=Ys?ut.bind(ut):function(){return ut.apply(ut,arguments)}});var ir=p(ji=>{"use strict";var Ni={}.propertyIsEnumerable,$i=Object.getOwnPropertyDescriptor,Zs=$i&&!Ni.call({1:2},1);ji.f=Zs?function(e){var t=$i(this,e);return!!t&&t.enumerable}:Ni});var nr=p((Bh,_i)=>{"use strict";_i.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var qi=p((qh,Bi)=>{"use strict";var Js=H(),el=B(),tl=Oe(),or=Object,rl=Js("".split);Bi.exports=el(function(){return!or("z").propertyIsEnumerable(0)})?function(r){return tl(r)==="String"?rl(r,""):or(r)}:or});var ar=p((Dh,Di)=>{"use strict";Di.exports=function(r){return r==null}});var sr=p((Hh,Hi)=>{"use strict";var il=ar(),nl=TypeError;Hi.exports=function(r){if(il(r))throw new nl("Can't call method on "+r);return r}});var Pe=p((Uh,Ui)=>{"use strict";var ol=qi(),al=sr();Ui.exports=function(r){return ol(al(r))}});var ve=p((Gh,Gi)=>{"use strict";var sl=q();Gi.exports=function(r){return typeof r=="object"?r!==null:sl(r)}});var dt=p((zh,zi)=>{"use strict";zi.exports={}});var mt=p((Wh,Ki)=>{"use strict";var lr=dt(),cr=X(),ll=q(),Wi=function(r){return ll(r)?r:void 0};Ki.exports=function(r,e){return arguments.length<2?Wi(lr[r])||Wi(cr[r]):lr[r]&&lr[r][e]||cr[r]&&cr[r][e]}});var Qi=p((Kh,Xi)=>{"use strict";var cl=H();Xi.exports=cl({}.isPrototypeOf)});var en=p((Xh,Ji)=>{"use strict";var pl=X(),Yi=pl.navigator,Zi=Yi&&Yi.userAgent;Ji.exports=Zi?String(Zi):""});var ln=p((Qh,sn)=>{"use strict";var an=X(),pr=en(),tn=an.process,rn=an.Deno,nn=tn&&tn.versions||rn&&rn.version,on=nn&&nn.v8,U,ft;on&&(U=on.split("."),ft=U[0]>0&&U[0]<4?1:+(U[0]+U[1]));!ft&&pr&&(U=pr.match(/Edge\/(\d+)/),(!U||U[1]>=74)&&(U=pr.match(/Chrome\/(\d+)/),U&&(ft=+U[1])));sn.exports=ft});var ur=p((Yh,pn)=>{"use strict";var cn=ln(),ul=B(),hl=X(),dl=hl.String;pn.exports=!!Object.getOwnPropertySymbols&&!ul(function(){var r=Symbol("symbol detection");return!dl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&cn&&cn<41})});var hr=p((Zh,un)=>{"use strict";var ml=ur();un.exports=ml&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var dr=p((Jh,hn)=>{"use strict";var fl=mt(),vl=q(),bl=Qi(),yl=hr(),gl=Object;hn.exports=yl?function(r){return typeof r=="symbol"}:function(r){var e=fl("Symbol");return vl(e)&&bl(e.prototype,gl(r))}});var mn=p((ed,dn)=>{"use strict";var Cl=String;dn.exports=function(r){try{return Cl(r)}catch{return"Object"}}});var mr=p((td,fn)=>{"use strict";var El=q(),Tl=mn(),Il=TypeError;fn.exports=function(r){if(El(r))return r;throw new Il(Tl(r)+" is not a function")}});var bn=p((rd,vn)=>{"use strict";var xl=mr(),Al=ar();vn.exports=function(r,e){var t=r[e];return Al(t)?void 0:xl(t)}});var gn=p((id,yn)=>{"use strict";var fr=ht(),vr=q(),br=ve(),wl=TypeError;yn.exports=function(r,e){var t,i;if(e==="string"&&vr(t=r.toString)&&!br(i=fr(t,r))||vr(t=r.valueOf)&&!br(i=fr(t,r))||e!=="string"&&vr(t=r.toString)&&!br(i=fr(t,r)))return i;throw new wl("Can't convert object to primitive value")}});var En=p((nd,Cn)=>{"use strict";Cn.exports=!0});var xn=p((od,In)=>{"use strict";var Tn=X(),Sl=Object.defineProperty;In.exports=function(r,e){try{Sl(Tn,r,{value:e,configurable:!0,writable:!0})}catch{Tn[r]=e}return e}});var vt=p((ad,Sn)=>{"use strict";var Rl=En(),kl=X(),Ol=xn(),An="__core-js_shared__",wn=Sn.exports=kl[An]||Ol(An,{});(wn.versions||(wn.versions=[])).push({version:"3.38.0",mode:Rl?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var yr=p((sd,kn)=>{"use strict";var Rn=vt();kn.exports=function(r,e){return Rn[r]||(Rn[r]=e||{})}});var Me=p((ld,On)=>{"use strict";var Pl=sr(),Ml=Object;On.exports=function(r){return Ml(Pl(r))}});var be=p((cd,Pn)=>{"use strict";var Ll=H(),Fl=Me(),Vl=Ll({}.hasOwnProperty);Pn.exports=Object.hasOwn||function(e,t){return Vl(Fl(e),t)}});var gr=p((pd,Mn)=>{"use strict";var Nl=H(),$l=0,jl=Math.random(),_l=Nl(1 .toString);Mn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+_l(++$l+jl,36)}});var Le=p((ud,Fn)=>{"use strict";var Bl=X(),ql=yr(),Ln=be(),Dl=gr(),Hl=ur(),Ul=hr(),ye=Bl.Symbol,Cr=ql("wks"),Gl=Ul?ye.for||ye:ye&&ye.withoutSetter||Dl;Fn.exports=function(r){return Ln(Cr,r)||(Cr[r]=Hl&&Ln(ye,r)?ye[r]:Gl("Symbol."+r)),Cr[r]}});var jn=p((hd,$n)=>{"use strict";var zl=ht(),Vn=ve(),Nn=dr(),Wl=bn(),Kl=gn(),Xl=Le(),Ql=TypeError,Yl=Xl("toPrimitive");$n.exports=function(r,e){if(!Vn(r)||Nn(r))return r;var t=Wl(r,Yl),i;if(t){if(e===void 0&&(e="default"),i=zl(t,r,e),!Vn(i)||Nn(i))return i;throw new Ql("Can't convert object to primitive value")}return e===void 0&&(e="number"),Kl(r,e)}});var Er=p((dd,_n)=>{"use strict";var Zl=jn(),Jl=dr();_n.exports=function(r){var e=Zl(r,"string");return Jl(e)?e:e+""}});var Dn=p((md,qn)=>{"use strict";var ec=X(),Bn=ve(),Tr=ec.document,tc=Bn(Tr)&&Bn(Tr.createElement);qn.exports=function(r){return tc?Tr.createElement(r):{}}});var Ir=p((fd,Hn)=>{"use strict";var rc=se(),ic=B(),nc=Dn();Hn.exports=!rc&&!ic(function(){return Object.defineProperty(nc("div"),"a",{get:function(){return 7}}).a!==7})});var zn=p(Gn=>{"use strict";var oc=se(),ac=ht(),sc=ir(),lc=nr(),cc=Pe(),pc=Er(),uc=be(),hc=Ir(),Un=Object.getOwnPropertyDescriptor;Gn.f=oc?Un:function(e,t){if(e=cc(e),t=pc(t),hc)try{return Un(e,t)}catch{}if(uc(e,t))return lc(!ac(sc.f,e,t),e[t])}});var Kn=p((bd,Wn)=>{"use strict";var dc=B(),mc=q(),fc=/#|\.prototype\./,Fe=function(r,e){var t=bc[vc(r)];return t===gc?!0:t===yc?!1:mc(e)?dc(e):!!e},vc=Fe.normalize=function(r){return String(r).replace(fc,".").toLowerCase()},bc=Fe.data={},yc=Fe.NATIVE="N",gc=Fe.POLYFILL="P";Wn.exports=Fe});var xr=p((yd,Qn)=>{"use strict";var Xn=tr(),Cc=mr(),Ec=ke(),Tc=Xn(Xn.bind);Qn.exports=function(r,e){return Cc(r),e===void 0?r:Ec?Tc(r,e):function(){return r.apply(e,arguments)}}});var Zn=p((gd,Yn)=>{"use strict";var Ic=se(),xc=B();Yn.exports=Ic&&xc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var eo=p((Cd,Jn)=>{"use strict";var Ac=ve(),wc=String,Sc=TypeError;Jn.exports=function(r){if(Ac(r))return r;throw new Sc(wc(r)+" is not an object")}});var io=p(ro=>{"use strict";var Rc=se(),kc=Ir(),Oc=Zn(),bt=eo(),to=Er(),Pc=TypeError,Ar=Object.defineProperty,Mc=Object.getOwnPropertyDescriptor,wr="enumerable",Sr="configurable",Rr="writable";ro.f=Rc?Oc?function(e,t,i){if(bt(e),t=to(t),bt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Rr in i&&!i[Rr]){var n=Mc(e,t);n&&n[Rr]&&(e[t]=i.value,i={configurable:Sr in i?i[Sr]:n[Sr],enumerable:wr in i?i[wr]:n[wr],writable:!1})}return Ar(e,t,i)}:Ar:function(e,t,i){if(bt(e),t=to(t),bt(i),kc)try{return Ar(e,t,i)}catch{}if("get"in i||"set"in i)throw new Pc("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var oo=p((Td,no)=>{"use strict";var Lc=se(),Fc=io(),Vc=nr();no.exports=Lc?function(r,e,t){return Fc.f(r,e,Vc(1,t))}:function(r,e,t){return r[e]=t,r}});var Ne=p((Id,so)=>{"use strict";var Ve=X(),Nc=wi(),$c=tr(),jc=q(),_c=zn().f,Bc=Kn(),ge=dt(),qc=xr(),Ce=oo(),ao=be();vt();var Dc=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 Nc(r,this,arguments)};return e.prototype=r.prototype,e};so.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,l=i?Ve:n?Ve[t]:Ve[t]&&Ve[t].prototype,a=i?ge:ge[t]||Ce(ge,t,{})[t],s=a.prototype,c,d,m,v,b,k,w,g,u;for(v in e)c=Bc(i?v:t+(n?".":"#")+v,r.forced),d=!c&&l&&ao(l,v),k=a[v],d&&(r.dontCallGetSet?(u=_c(l,v),w=u&&u.value):w=l[v]),b=d&&w?w:e[v],!(!c&&!o&&typeof k==typeof b)&&(r.bind&&d?g=qc(b,Ve):r.wrap&&d?g=Dc(b):o&&jc(b)?g=$c(b):g=b,(r.sham||b&&b.sham||k&&k.sham)&&Ce(g,"sham",!0),Ce(a,v,g),o&&(m=t+"Prototype",ao(ge,m)||Ce(ge,m,{}),Ce(ge[m],v,b),r.real&&s&&(c||!s[v])&&Ce(s,v,b)))}});var co=p((xd,lo)=>{"use strict";var Hc=Math.ceil,Uc=Math.floor;lo.exports=Math.trunc||function(e){var t=+e;return(t>0?Uc:Hc)(t)}});var $e=p((Ad,po)=>{"use strict";var Gc=co();po.exports=function(r){var e=+r;return e!==e||e===0?0:Gc(e)}});var ho=p((wd,uo)=>{"use strict";var zc=$e(),Wc=Math.max,Kc=Math.min;uo.exports=function(r,e){var t=zc(r);return t<0?Wc(t+e,0):Kc(t,e)}});var fo=p((Sd,mo)=>{"use strict";var Xc=$e(),Qc=Math.min;mo.exports=function(r){var e=Xc(r);return e>0?Qc(e,9007199254740991):0}});var je=p((Rd,vo)=>{"use strict";var Yc=fo();vo.exports=function(r){return Yc(r.length)}});var kr=p((kd,yo)=>{"use strict";var Zc=Pe(),Jc=ho(),ep=je(),bo=function(r){return function(e,t,i){var n=Zc(e),o=ep(n);if(o===0)return!r&&-1;var l=Jc(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}};yo.exports={includes:bo(!0),indexOf:bo(!1)}});var yt=p((Od,go)=>{"use strict";go.exports=function(){}});var Co=p(()=>{"use strict";var tp=Ne(),rp=kr().includes,ip=B(),np=yt(),op=ip(function(){return!Array(1).includes()});tp({target:"Array",proto:!0,forced:op},{includes:function(e){return rp(this,e,arguments.length>1?arguments[1]:void 0)}});np("includes")});var gt=p((Ld,Eo)=>{"use strict";var ap=mt();Eo.exports=ap});var Io=p((Fd,To)=>{"use strict";Co();var sp=gt();To.exports=sp("Array","includes")});var Ao=p((Vd,xo)=>{"use strict";var lp=Io();xo.exports=lp});var Ct=p((Nd,wo)=>{"use strict";var cp=Ao();wo.exports=cp});var Fo=p(()=>{"use strict";var bp=Ne(),yp=Me(),gp=je(),Cp=$e(),Ep=yt();bp({target:"Array",proto:!0},{at:function(e){var t=yp(this),i=gp(t),n=Cp(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});Ep("at")});var No=p((Ym,Vo)=>{"use strict";Fo();var Tp=gt();Vo.exports=Tp("Array","at")});var jo=p((Zm,$o)=>{"use strict";var Ip=No();$o.exports=Ip});var _r=p((Jm,_o)=>{"use strict";var xp=jo();_o.exports=xp});var Xo=p((Bf,Ko)=>{"use strict";var Pp=yr(),Mp=gr(),Wo=Pp("keys");Ko.exports=function(r){return Wo[r]||(Wo[r]=Mp(r))}});var Yo=p((qf,Qo)=>{"use strict";var Lp=B();Qo.exports=!Lp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var ea=p((Df,Jo)=>{"use strict";var Fp=be(),Vp=q(),Np=Me(),$p=Xo(),jp=Yo(),Zo=$p("IE_PROTO"),Ur=Object,_p=Ur.prototype;Jo.exports=jp?Ur.getPrototypeOf:function(r){var e=Np(r);if(Fp(e,Zo))return e[Zo];var t=e.constructor;return Vp(t)&&e instanceof t?t.prototype:e instanceof Ur?_p:null}});var ra=p((Hf,ta)=>{"use strict";ta.exports={}});var oa=p((Uf,na)=>{"use strict";var Bp=H(),Gr=be(),qp=Pe(),Dp=kr().indexOf,Hp=ra(),ia=Bp([].push);na.exports=function(r,e){var t=qp(r),i=0,n=[],o;for(o in t)!Gr(Hp,o)&&Gr(t,o)&&ia(n,o);for(;e.length>i;)Gr(t,o=e[i++])&&(~Dp(n,o)||ia(n,o));return n}});var sa=p((Gf,aa)=>{"use strict";aa.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var ca=p((zf,la)=>{"use strict";var Up=oa(),Gp=sa();la.exports=Object.keys||function(e){return Up(e,Gp)}});var fa=p((Wf,ma)=>{"use strict";var ua=se(),zp=B(),ha=H(),Wp=ea(),Kp=ca(),Xp=Pe(),Qp=ir().f,da=ha(Qp),Yp=ha([].push),Zp=ua&&zp(function(){var r=Object.create(null);return r[2]=2,!da(r,2)}),pa=function(r){return function(e){for(var t=Xp(e),i=Kp(t),n=Zp&&Wp(t)===null,o=i.length,l=0,a=[],s;o>l;)s=i[l++],(!ua||(n?s in t:da(t,s)))&&Yp(a,r?[s,t[s]]:t[s]);return a}};ma.exports={entries:pa(!0),values:pa(!1)}});var va=p(()=>{"use strict";var Jp=Ne(),eu=fa().values;Jp({target:"Object",stat:!0},{values:function(e){return eu(e)}})});var ya=p((Qf,ba)=>{"use strict";va();var tu=dt();ba.exports=tu.Object.values});var Ca=p((Yf,ga)=>{"use strict";var ru=ya();ga.exports=ru});var $t=p((Zf,Ea)=>{"use strict";var iu=Ca();Ea.exports=iu});var Qr=p((gv,ka)=>{"use strict";var ou=Oe();ka.exports=Array.isArray||function(e){return ou(e)==="Array"}});var Pa=p((Cv,Oa)=>{"use strict";var au=TypeError,su=9007199254740991;Oa.exports=function(r){if(r>su)throw au("Maximum allowed index exceeded");return r}});var Fa=p((Ev,La)=>{"use strict";var lu=Qr(),cu=je(),pu=Pa(),uu=xr(),Ma=function(r,e,t,i,n,o,l,a){for(var s=n,c=0,d=l?uu(l,a):!1,m,v;c<i;)c in t&&(m=d?d(t[c],c,e):t[c],o>0&&lu(m)?(v=cu(m),s=Ma(r,e,m,v,s,o-1)-1):(pu(s+1),r[s]=m),s++),c++;return s};La.exports=Ma});var $a=p((Tv,Na)=>{"use strict";var hu=Le(),du=hu("toStringTag"),Va={};Va[du]="z";Na.exports=String(Va)==="[object z]"});var _a=p((Iv,ja)=>{"use strict";var mu=$a(),fu=q(),_t=Oe(),vu=Le(),bu=vu("toStringTag"),yu=Object,gu=_t(function(){return arguments}())==="Arguments",Cu=function(r,e){try{return r[e]}catch{}};ja.exports=mu?_t:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=Cu(e=yu(r),bu))=="string"?t:gu?_t(e):(i=_t(e))==="Object"&&fu(e.callee)?"Arguments":i}});var qa=p((xv,Ba)=>{"use strict";var Eu=H(),Tu=q(),Yr=vt(),Iu=Eu(Function.toString);Tu(Yr.inspectSource)||(Yr.inspectSource=function(r){return Iu(r)});Ba.exports=Yr.inspectSource});var Wa=p((Av,za)=>{"use strict";var xu=H(),Au=B(),Da=q(),wu=_a(),Su=mt(),Ru=qa(),Ha=function(){},Ua=Su("Reflect","construct"),Zr=/^\s*(?:class|function)\b/,ku=xu(Zr.exec),Ou=!Zr.test(Ha),Qe=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(wu(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Ou||!!ku(Zr,Ru(e))}catch{return!0}};Ga.sham=!0;za.exports=!Ua||Au(function(){var r;return Qe(Qe.call)||!Qe(Object)||!Qe(function(){r=!0})||r})?Ga:Qe});var Ya=p((wv,Qa)=>{"use strict";var Ka=Qr(),Pu=Wa(),Mu=ve(),Lu=Le(),Fu=Lu("species"),Xa=Array;Qa.exports=function(r){var e;return Ka(r)&&(e=r.constructor,Pu(e)&&(e===Xa||Ka(e.prototype))?e=void 0:Mu(e)&&(e=e[Fu],e===null&&(e=void 0))),e===void 0?Xa:e}});var Ja=p((Sv,Za)=>{"use strict";var Vu=Ya();Za.exports=function(r,e){return new(Vu(r))(e===0?0:e)}});var es=p(()=>{"use strict";var Nu=Ne(),$u=Fa(),ju=Me(),_u=je(),Bu=$e(),qu=Ja();Nu({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=ju(this),i=_u(t),n=qu(t,0);return n.length=$u(n,t,t,i,0,e===void 0?1:Bu(e)),n}})});var ts=p(()=>{"use strict";var Du=yt();Du("flat")});var is=p((Mv,rs)=>{"use strict";es();ts();var Hu=gt();rs.exports=Hu("Array","flat")});var os=p((Lv,ns)=>{"use strict";var Uu=is();ns.exports=Uu});var ss=p((Fv,as)=>{"use strict";var Gu=os();as.exports=Gu});var th={};_s(th,{ContainerTypes:()=>y.ContainerTypes,ControlTypes:()=>y.ControlTypes,CustomError:()=>L,EVENT_NAMES:()=>A,EventActionTypes:()=>y.EventActionTypes,EventTypes:()=>y.EventTypes,Interactives:()=>Ze,ManifestController:()=>pe,SDKInfo:()=>eh,chapterIdsToVKVideoIds:()=>qt,compareVersions:()=>Vt,containerTypes:()=>hp,controlTypes:()=>dp,eventActionTypes:()=>fp,eventTypes:()=>mp,getChapterIdByVkVideoId:()=>As,getVKVideoIdByMedia:()=>ti,getVideoRawIdByMedia:()=>Is,graphEventTypes:()=>Ie,hasEndTemplate:()=>Be,interactivesEventTypes:()=>P,isAreaControl:()=>up,isButtonControl:()=>pp,isLastChapter:()=>G,isOneTextCtrlContainer:()=>ce,isSupportedManifest:()=>y.isSupportedManifest,isTextControl:()=>_e,isVKVariantItem:()=>xs,isValidManifest:()=>Or,migrateManifestToLatestVersion:()=>y.migrateManifestToLatestVersion,utils:()=>Ms,vkVideoIdsToChapterIds:()=>ri});module.exports=Bs(th);var si="1.0.36-dev.5119b35a.0";var qe=require("@vkontakte/videoplayer-shared");var Gt=class{constructor(e){this.layout=e}},tt=class extends Gt{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))`}};var ci=require("@vkontakte/videoplayer-shared");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 rt({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 de=class{constructor(e,t){this.error$=new ci.Subject;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){rt({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]},[])||[]}};var Y=require("@vkontakte/videoplayer-shared");var ee=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,te=r=>ee(r,"Object"),it=r=>ee(r,"String"),nt=r=>ee(r,"Array"),ot=r=>ee(r,"Number"),pi=r=>ee(r,"Function"),ui=r=>ee(r,"Boolean"),Kt=r=>ot(r)&&!isNaN(r);var oe=r=>te(r)&&Object.keys(r).length===0,Xt=r=>nt(r)&&!r.length;var Ae=(r,e)=>it(r)&&(e?r.trim():r).length;function we(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 hi="interactive",O={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},di=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(di||{}),mi=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(mi||{}),fi=(i=>(i.start="left",i.end="right",i.center="center",i))(fi||{}),at=({target:r,props:e})=>{r.style.alignItems=(e?.gravityVertical&&di[e.gravityVertical])??"center",r.style.justifyContent=(e?.gravityHorizontal&&mi[e.gravityHorizontal])??"center",r.style.textAlign=(e?.alignment&&fi[e.alignment])??"center"},st=({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},lt=({target:r,props:e,fallback:t})=>{r.style.backgroundColor=we(e?.background?.color??t.backgroundColor,e?.background?.alpha??t.backgroundAlpha)},Se=({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=we(n?t.borderColor:e?.shape?.border?.color??t.borderColor,n?t.borderAlpha:e?.shape?.border?.alpha??t.borderAlpha),r.style.borderRadius=l},vi=({target:r,isDark:e,baseDimension:t,fallback:i})=>{let l=we(i.shadowColorLight,i.shadowColorAlpha),a=we(i.shadowColorDark,i.shadowColorAlpha),s=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${s} ${c} ${e?a:l}`;r.style.boxShadow=d},me=({target:r,layoutParams:e,fallback:t})=>{let i=e.angle??t.angle;i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};var Q=require("@vkontakte/videoplayer-shared");function ct(r){for(;r>Math.PI;)r-=2*Math.PI;for(;r<=-Math.PI;)r+=2*Math.PI;return r}function bi(r){return r*180/Math.PI}var Qt="interactive-control-tap",fe={common:Qt,animation:`${Qt}-animation`,visible:`${Qt}-visible`};var qs=60,pt=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=qs,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=Ds(s,c,ct(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(fe.visible,fe.animation)};this.onAnimationEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.element.classList.remove(fe.visible,fe.animation)};let o=document.createElement("div");o.classList.add(fe.common),this.controlRotateAngleRad=e,this.element=o,this.clickCancelCondition=t,this.circleDiameterPx=i,this.useDimensionsBasedSize=n}};function Ds(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var Yt="int",ae=(i=>(i.AREA=`${Yt}_area`,i.TEXT=`${Yt}_text`,i.BUTTON=`${Yt}_bttn`,i))(ae||{});function Zt(r){return"features"in r}var K="interactive-control",R={common:K,selected:`${K}-selected`,wrapper:`${K}-wrapper`,disabled:`${K}-disabled`,button:`${K}-button`,area:`${K}-area`,text:`${K}-text`,blinkAnim:`${K}-blink-anim`,blinkAnimButton:`${K}-blink-anim-button`,blinkAnimArea:`${K}-blink-anim-area`},yi=40;var Ro=W(Ct(),1);var y=require("@interactiveplatform/movika-manifest");var So={metadata:"Object",chapters:"Array"},Or=r=>{if(!te(r))return!1;for(let e in So)if(!r[e]||!ee(r[e],So[e]))return!1;return(0,y.isSupportedManifest)(r.metadata.version)},_e=r=>r.type===y.ControlTypes.Text,pp=r=>r.type===y.ControlTypes.Button,up=r=>r.type===y.ControlTypes.Area,hp={Choice:"Choice",TextInput:"TextInput"},dp={Button:"Button",Area:"Area",Text:"Text"},mp={onClick:"onClick",onSuspense:"onSuspense"},fp={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Et=r=>nt(r)&&!Xt(r),G=r=>r.order==="end",Be=r=>nt(r.containers)&&!Xt(r.containers)&&G(r),ko=(r,e)=>{let t=r*1e3;return Et(e.controls)&&t<(e.startTime??0)},Pr=(r,e)=>{let t=r*1e3;return Et(e.controls)&&t>=(e.startTime??0)&&t<=(e.endTime??1/0)};var le=(r=[])=>r.some(e=>e.action.type==="expect"),Mr=(r=[])=>r.find(e=>e.action.type==="expect"),vp=r=>r?.length===1,ce=r=>vp(r)&&_e(r[0]);function Oo(r=[],e=1/0,t=[]){return r.filter(({container:i})=>!(0,Ro.default)(t,i.container.id)&&le(i.container.events)&&i.container.endTime===e&&!i.isRemoved&&!i.willRemoved)}function Tt({gameControllers:r=[],subjectName:e,subjectId:t,execFn:i}){for(let n of r)if(e==="container"&&n.container.container.id===t){i(n),Oo(r,n.container.container.endTime,[n.container.container.id]).forEach(l=>{i(l)});break}}function Po(r){for(let e of r.events)if(e.action.type==="openURI")return!0;return!1}var Mo=(r,e)=>{let t=w=>e.find(({container:u})=>u.container.id===w)?.container.isRemoved,i=le(r.events)&&!t(r.id),n=(w,g=!1,u=!1)=>{let h=u?"every":"some";return w.controls[h](f=>{let E=g?w.endTime===r.endTime:!0;return f.events?.[h](T=>T.action?.type===y.EventActionTypes.openURI)&&E})},o=w=>w.some(({container:g})=>n(g.container,!0,!1)&&!g.isRemoved),l=w=>w.every(({container:g})=>g.isRemoved||g.willRemoved?!0:n(g.container,!0,!0)),a=Oo(e,r.endTime,[r.id]).length,s=w=>w.controls.some(g=>g.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,k=s(r);return{isExpectTime:c,hasOtherExpect:a>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:v,isExpectEventForCurrentContainer:b,hasShouldOpenNowEvent:k}};var re=class r{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new Q.Subscription;this.error$=new Q.Subject;this.isInteracted=!1;this.isRemoved=!1;this.onControlSelect=()=>{this.container?.isManifestContainerDisabled()||Po(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((0,Q.fromEvent)(t,"transitionend").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n))).add((0,Q.fromEvent)(t,"transitioncancel").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n)));return}this.removeListeners(),t.remove(),this.isRemoved=!0}}onError(e="",t){rt({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??O.angle;this.controlTap=new pt({controlRotateAngleRad:t,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?yi:void 0}),this.subscriptions.add((0,Q.fromEvent)(e,"click").subscribe(this.controlTap.onElementClick,i=>this.onError("Control click tap animation error",i))).add((0,Q.fromEvent)(this.controlTap.element,"animationend").subscribe(this.controlTap.onAnimationEnd,i=>this.onError("Tap animationend error",i))),this.container.element.append(this.controlTap.element)}}createContainerElement(e){let t=document.createElement("div");t.classList.add(R.wrapper),e.setControlLayout(t,this.control.layoutParams);let i=(this.control.layoutParams.innerSizesDependOn??O.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&&Zt(this.options)&&this.options.features[e]}isTouch(){return this.options&&Zt(this.options)&&this.options.isTouch}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add((0,Q.fromEvent)(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),n=>this.onError("Error happened on control interaction",n)));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var Lr="interactive-blink-anim-reference",V={common:Lr,animation:`${Lr}-animation`,disabled:`${Lr}-disabled`},It=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(V.common,V.animation),this._element=e}restart(){this._element&&(this._element.classList.add(V.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(V.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var Fr="interactive-container",N={common:Fr,hidden:`${Fr}-hidden`,disabled:`${Fr}-disabled`};var xt=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Vr(r,e)},Vr=class extends re{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(R.common,R.area),i.setAttribute("data-testid",ae.AREA),lt({target:i,props:this.control.props,fallback:{...O,backgroundColor:"transparent"}}),me({target:i,layoutParams:this.control.layoutParams,fallback:O}),this.addControlTap(i),this.subscriptions.add((0,Y.fromEvent)(this.container.element,"click").pipe((0,Y.once)()).subscribe(this.onControlSelect,n=>this.onError("Control click handler error",n))),this.container.element.append(i),e.append(this.container.element),this.controlElement=i,this.updateShadowStyles(),this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,Y.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(N.disabled))return;let t=e.parentElement;if(t){let i=t.querySelector(`.${V.common}`);i&&this.syncBlinkAnimation(i)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,Y.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(N.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,Y.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(R.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(R.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){if(!(!this.container||!this.controlElement))if(ui(e)){let t=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";vi({target:this.controlElement,props:this.control.props,fallback:O,isDark:e,baseDimension:t}),Se({target:this.controlElement,props:this.control.props,fallback:{...O,borderColor:e?O.shadowColorDark:O.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${this.control.props?.shape?.roundCorners??O.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else Se({target:this.controlElement,props:this.control.props,fallback:{...O,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(R.blinkAnim,e),this.controlElement?.classList.toggle(R.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${R.blinkAnimArea}`)||this.controlElement.classList.contains(R.selected)||this.controlElement.classList.contains(V.disabled)||(this.controlElement.classList.add(V.disabled),this.subscriptions.add((0,Y.fromEvent)(e,"animationiteration").pipe((0,Y.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(V.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${R.blinkAnimArea}`)||this.controlElement.classList.contains(R.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}};var J=require("@vkontakte/videoplayer-shared");var At=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 Z="interactive-control-fill-animation",$={common:Z,fillerWrapper:`${Z}-filler-wrapper`,filler:`${Z}-filler`,fillHeight:`${Z}-fill-height`,fillWidth:`${Z}-fill-width`,fromTop:`${Z}-from-top`,fromBottom:`${Z}-from-bottom`,fromLeft:`${Z}-from-left`,fromRight:`${Z}-from-right`};var wt=class r{constructor(e){this.widthExpansionCoef=0;let t=document.createElement("div");t.classList.add($.common);let i=document.createElement("div");i.classList.add($.fillerWrapper);let n=document.createElement("div");n.classList.add($.filler),i.append(n),t.append(i);let o=ct(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($.fillHeight,a?$.fromTop:$.fromBottom),i.classList.add($.fillHeight,a?$.fromTop:$.fromBottom)):(n.classList.add($.fillWidth,c?$.fromLeft:$.fromRight),i.classList.add($.fillWidth)),e.debug&&console.log(`[interactive ${r.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:d,rotateAngleRad:o,rotateAngelDeg:bi(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 St=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new Nr(r,e)},Nr=class extends re{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(R.common,R.button),i.setAttribute("data-testid",ae.BUTTON),me({target:i,layoutParams:this.control.layoutParams,fallback:O}),lt({target:i,props:this.control.props,fallback:O}),Se({target:i,props:this.control.props,fallback:O,dependsOn:this.container.dimensions}),at({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=At(this.control.type.trim().toLowerCase()),o=n.firstElementChild??n;st({target:o,props:this.control.props,fallback:O,dependsOn:this.container.dimensions}),this.addControlTap(i),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled("controlsFillAnimation")&&(this.controlFillAnimation=new wt({startTime:this.startTime,endTime:this.endTime,rotateAngle:this.control.layoutParams.angle??O.angle,borderRadius:i.style.borderRadius})),this.subscriptions.add((0,J.fromEvent)(i,"click").pipe((0,J.once)()).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((0,J.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(N.disabled))return;let t=e.parentElement;if(t){let i=t.querySelector(`.${V.common}`);i&&this.syncBlinkAnimation(i)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,J.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(N.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,J.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(R.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(R.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(R.blinkAnim,e),this.controlElement?.classList.toggle(R.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${R.blinkAnimButton}`)||this.controlElement.classList.contains(R.selected)||this.controlElement.classList.contains(V.disabled)||(this.controlElement.classList.add(V.disabled),this.subscriptions.add((0,J.fromEvent)(e,"animationiteration").pipe((0,J.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(V.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${R.blinkAnimButton}`)||this.controlElement.classList.contains(R.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}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 Lo=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new $r(r,e)},$r=class extends re{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(R.common,R.text),i.setAttribute("data-testid",ae.TEXT),me({target:i,layoutParams:this.control.layoutParams,fallback:O}),at({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=At(this.control.type.trim().toLowerCase()),o=n.firstElementChild??n;st({target:o,props:this.control.props,fallback:O,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 Rt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new jr(r,e,t)},jr=class r extends de{constructor(t,i,n){super(t,n);this.containerElement=null;this.subscriptions=new qe.Subscription;this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&this.removeView()};this.rootElement=i,this.layout=new tt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",St),this.addControlFactory("text",Lo),this.addControlFactory("area",xt)}createView({eventCallback:t,videoDurationMs:i}){let n=document.createElement("div");return n.classList.add(N.common,N.disabled),requestAnimationFrame(()=>{n.classList.remove(N.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(N.hidden)}show(){let t=this.getElement();t&&t.classList.remove(N.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(N.disabled),this.controls.forEach(i=>i.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(N.disabled),this.controls.forEach(i=>i.disable()),this.isDisabled=!0)}removeView(t=!1,i=!1){let n=this.getElement();if(n){if(t){if(this.willRemoved)return;this.willRemoved=!0,i&&n.classList.add("interactive-container-before-remove-delay"),n.classList.add("interactive-container-before-remove"),this.subscriptions.add((0,qe.fromEvent)(n,"transitionend").subscribe(this.onTransitionEnd,l=>this.onError(`${r.name} remove view transition error`,l))).add((0,qe.fromEvent)(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 Os=W(_r(),1),C=require("@vkontakte/videoplayer-shared"),xe=require("@vkontakte/videoplayer-statistics");var Ho=require("@vkontakte/videoplayer-shared");function De(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var Bo="video_interactive",qo="videoint";var Do=250,He=class{constructor(e){this.handleZoomChange=De(e=>{this.lastZoomInfo=e},Do);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,!ot(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=Ap(e),this.resizeObserver=new ResizeObserver(De(this.onResize,Do)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){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(0,Ho.loadVKLangPack)(this.lang,Bo,qo)}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 Ap(r){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",r.append(e),e}var Ue=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 kt=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 Ot=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{pi(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var zo=require("@vkontakte/videoplayer-shared");var Pt=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,t){return wp(...this.loaders[e])(t)}};function wp(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function Ge(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function Mt({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:Ge(e,Mt.name,"Could not find media"),actions:r}}}}return{...i,errors:Ge(e,Mt.name,"Could not find chapter"),actions:r}}var Lt=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}},Ee=class extends Lt{constructor(){super(),this.listeners||Lt.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)}},ze=class{constructor(){Object.defineProperty(this,"signal",{value:new Ee,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&&(ze.prototype[Symbol.toStringTag]="AbortController",Ee.prototype[Symbol.toStringTag]="AbortSignal");function Ft(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 Br(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Ft({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,k)=>{d.addEventListener("abort",()=>k(m),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([v,l(s,c)])}return l(s,c)},Request:o}}var We=Ft({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Uo=We?Br({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,qr=We?Uo.fetch:window.fetch,xf=We?Uo.Request:window.Request,Af=We?ze:window.AbortController,wf=We?Ee:window.AbortSignal;var Vt=(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 Sp=async r=>{try{let e={},t;if(it(r)){t=new URL(r).href;let n=await qr(t);if(!n.ok)return{};e=await n.json()}else if(te(r))e=r;else return{};if(!Or(e))return{};let i=e.metadata.media;if(it(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=await qr(n);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch{return Op(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch{return{}}};async function Go(r){let{manifest:e,manifestURL:t}=await Sp(r);if(!e)throw new Error("Failed on fetch");let i=(0,y.migrateManifestToLatestVersion)(e);return i.media=Rp(i.media,t),delete i.metadata.media,i}function Nt(r,e){if(e)return r.find(t=>t.id===e)}function Dr(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 Hr(r,e){return r.videos.find(t=>t.id===e)}function Rp(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=kp(n,e);return{...i,url:o||n}})}))}}function kp(r="",e){try{return new URL(r,e).href}catch{return""}}function Op(r){return Vt(r,"3.2.0")>=0}var pe=class extends Pt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new zo.ValueSubject(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){this.release();let i=await this.exec("manifestLoaders",{actions:{addErrorMessage:Ge},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await Go(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",Mt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Dr,getChapter:Nt,getMedia:Hr,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ge},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=Nt(this.manifest.chapters,t);if(i){let n=Hr(this.manifest.media,i.videoId),o=Dr(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=Nt(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?G(this.chapter):!1}};var xa=W($t(),1),Aa=require("@vkontakte/videoplayer-core"),ie=require("@vkontakte/videoplayer-shared");var Ta=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 Ia=W($t(),1);function zr(){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,Ia.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 Te=W(Ct(),1);function Wr(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,Te.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"mpeg":(n||(0,Te.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"hls":(n||(0,Te.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:o.url}});break;case"dash":(n||(0,Te.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 Ke=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,Te.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var nu=2;function Kr(r){let e=zr(),t=new ie.Subscription,i={},n=null,o=!1,l,a=new ie.ValueSubject(null);r&&s(r);function s(g){n=g}function c(g,u,h){if(!n)throw Error("need to set interactive controller");if(!n.options)return;let E=(e.map.get(g)??{})[u];if(E){i={chapterId:h,listId:g,itemId:u,...E};let T=i.player;i.subscription.add(T.info.currentQuality$.subscribe(I=>{let S=T.info.position$.getValue(),j=T.info.isAutoQualityEnabled$.getValue();if(!(!I||!S||j))for(let x of e.map)(0,xa.default)(x[1]).forEach(({player:M})=>{Ke(M,I)})})).add(T.events.started$.subscribe(()=>{d(u)})),E.container.remove(),n.setPlayer(E.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(g){if(!n)throw Error("need to set interactive controller");if(oe(i)||g!==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:g},manifestVideo:u}){if(oe(i)||!n)return;let h=i.player.info.muted$.getValue(),f=i.player.info.currentQuality$.getValue(),E=i.player.info.isAutoQualityEnabled$.getValue(),T=i.player.info.volume$.getValue(),I=i.player.info.currentPlaybackRate$.getValue(),S=!E,j=!1;for(let x of e.map)if(x[0]===u.id&&!n.state.isReplay$.getValue()){let M=Object.keys(x[1]);for(let F of M)F===i.itemId?(M.length<nu||(j=!0),e.removePlayer(x[0],F)):(j=!0,c(x[0],F,g),S?Ke(i.player,f):i.player.setAutoQuality(!0),i.player.setVolume(T),i.player.setMuted(h),i.player.setPlaybackRate(I))}else e.removePlayer(x[0]);j||(await v({media:u,chapterId:g,setAsActive:!0,playbackRate:I}),S?Ke(i.player,f):i.player.setAutoQuality(!0),i.player.setVolume(T),i.player.setMuted(h))}async function v({media:g,chapterId:u,prefetch:h=!0,setAsActive:f=!0,autoplay:E=!1,preferredExt:T,title:I,playbackRate:S}){let j=Math.random().toString(),x=document.createElement("div");l.append(x);let M;if(n?.options?.vkVideoLoader){let Je=Ta(g);Je.length&&(M=await n.options.vkVideoLoader(...Je))}let F=n?.options?.coreConfig||void 0,z={...F,configName:[...F?.configName??[],"interactive"]},ne={container:x,...M?.videos?.[0]||{sources:Wr(g,T).sources},title:I,failoverHosts:M?.failoverHosts||[]},_=new Aa.Player(z,ie.Tracer.createRootTracer());_.initVideo(ne);let ue=null;if(M?.videos&&n?.options.createOneStat){let Je=M.videos[0],Ut=n.options.createOneStat(Je),oi=new ie.Subscription;Ut&&(oi.add(Ut.attachTo(_)),ue={oneStat:Ut,statSubscription:oi})}let ni=new ie.Subscription,Ls=i?.player?.info.isAutoQualityEnabled$.getValue();ni.add(_.events.canplay$.subscribe(function(){Ls||Ke(_,i.player.info.currentQuality$.getValue()),S&&_.setPlaybackRate(S)}));let he=e.createPlayer({listId:g.id,itemId:j,player:_,container:x,sources:Wr(g,T).sources,config:ne,subscription:ni,statistics:ue});return f&&c(g.id,he.itemId,u),E&&he.player.play(),h&&!E&&he.player.prepare(),{player:he.player,config:he.config,statistics:he.statistics}}function b(){k(),n=null,l.remove()}function k(){t.unsubscribe(),e.removeAll(),i={},o=!1}async function w(){if(!n)throw Error("need to set interactive controller");k(),l=document.createElement("div");let{media:g,chapter:u}=n.getCurrentChapter();g&&u?(t.add(n.events.chapterChanged$.subscribe(m)),await v({media:g,chapterId:u.id,title:u.label})):console.error("not found")}return{...e,init:w,setInteractiveController:s,createPlayer:v,removeAll:b,getActivePlayer:function(){return i},activePlayerChanged:a}}var A={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Ie={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},P={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Sa=require("@vkontakte/videoplayer-shared");function Xr(r){return function(...t){return r(...t.reverse())}}function Xe(r,...e){return(...t)=>te(e[0])&&te(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var jt=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:k}){this.hide=()=>{setTimeout(()=>{this.gameState!==4&&(le(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,k=this.interactiveTimeOpenUri&&d;if((!this.interactiveTimeOpenUri||b)&&(this.isSelectedControlEvent=!0),o!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||b)){if(this.interactiveTimeOpenUri){let w=!s&&!m&&d;w&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:w})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&c&&this.gameState!==5){if(k){let g=((u,h,f,E)=>!u&&!h&&f||u&&!h&&f&&!E||u&&!h&&f&&E)(a,s,m,this.isSelectedContainerEvent);this.fakeRemoveView(g)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!a||!s||!v)&&(this.selectBranches.stopExpect(),l())}},isEOV:()=>this.gameState===4},i=Xe(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(ko(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Pr(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=Pr(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(A.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Sa.Subscription,this.player=e,this.interactiveEvents=o,this.getContainerEventState=s,this.isPermanentText=c&&ce(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=k,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(A.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(A.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{e?this.container.disable?.():this.container.enable?.()})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime??1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime??1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),i=this.interactiveTimeOpenUri?e||t:le(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(A.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,this.onRemove?.()}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}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=>!_e(o));if(Et(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=W(Ct(),1),Jr=W($t(),1),ps=W(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(Kt(a)){let d=r[a]??null;if(d&&s&&Ae(s,!0)){let m={},v=d[s];return v&&(m={...m,...v}),m=oe(m)?null:m,m&&Ae(c,!0)?m[c]??null:m}return d}return null}function o({timestamp:a,priority:s,initiator:c}){if(Kt(a))if(r[a]){if(s&&Ae(s,!0))if(r[a][s]){if(c&&Ae(c,!0))if(r[a][s][c]){if(delete r[a][s][c],!oe(r[a][s]))return!0}else return!1;if(delete r[a][s],!oe(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 zu=[y.EventActionTypes.expect,y.EventActionTypes.setNextBranch],Wu=1/0;function us(r,e){let t=r,i,n=Ku(e),o=ls(),l,a=()=>{b(),u()},s=h=>{o.add.call(void 0,h),k()},c=(h=[])=>{for(let f of h)if(f.action(),(0,cs.default)(zu,f.actionType))break},d=(h=1/0)=>{let f=Bt(o.get({timestamp:h,priority:"control"})??{}),E=Bt(o.get({timestamp:h,priority:"container"})??{}),T=Bt(o.get({timestamp:h,priority:"chapter"})??{});return[...f,...E,...T]},m=h=>{n.isReady(h)&&c(d(h))},v=()=>{c([...Bt(o.get({timestamp:1/0,priority:"chapter"})??{})])},b=()=>{i&&(l?.unsubscribe(),i=void 0)},k=()=>{i||(i=()=>setTimeout(()=>{m(1/0)}),l=t.events.ended$.subscribe(i))},w=h=>{b(),t=h},g=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),o.remove(h)},u=()=>{n.release(),o.removeAll()};return{setPlayer:w,add:s,remove:g,exec:m,execEndOfVideo:v,listen:k,unlisten:b,release:a,containersEventsCallState:n,getPreparedToExecActions:d}}function Ku(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??Wu,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,Jr.default)(s);return r?c.some(m=>m):!c.some(m=>!m)},release:()=>e.clear()}}function Bt(r){return(0,ps.default)((0,Jr.default)(r)).sort(e=>e.actionType===y.EventActionTypes.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 Xu=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=De(a=>{let{fns:s=[]}=r();i(a);for(let c of s)c()},Xu);function l(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e?.()},release:l}}var Qu=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=Qu(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",ei=(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:E,branches:T=[],onEvent:I,isEOV:S=()=>!1,isDisabled:j=()=>!1})=>{let x=ei(u,S()),M={timestamp:1/0,priority:"control",initiator:f,actionType:x.type},F=j(),z=r.emit.bind(r,A.interactives,{subjectId:f,subjectType:h,subjectName:"control",type:F?P.actionChoiceCanceled:P.actionChoice,actionType:u.type,payload:{invokeImmediately:x.args.shouldOpenNow,containerId:E,...x.args}}),ne=()=>{e.interactiveActionChoice$.next({subjectId:f,subjectType:h,subjectName:"control",type:F?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:x.args.shouldOpenNow,containerId:E,...x.args}})};if(F){z(),ne();return}switch(x.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let _=T.find(ue=>ue.id===x.args.branchId);if(!_)return;I(x.args.isDetachContainer,b.bind(null,{subjectId:f,subjectName:"control"})),z(),ne(),x.args.shouldOpenNow?w({subjectId:f,subjectName:"control",subjectType:h,action:x,payload:{chapterId:_.chapterId,autoSelect:!1}}):i.add({...M,action:w.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:x,payload:{chapterId:_.chapterId,autoSelect:!1}})});return}case y.EventActionTypes.continuePlayback.trim().toLowerCase():{I(x.args.isDetachContainer,b.bind(null,{subjectId:f,subjectName:"control"})),z(),ne(),x.args.shouldOpenNow?k({subjectId:f,subjectName:"control",subjectType:h,action:u}):i.add({...M,action:k.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:u})});return}case y.EventActionTypes.openURI.trim().toLowerCase():{I(x.args.isDetachContainer,b.bind(null,{subjectId:f,subjectName:"control"})),z(),ne(),x.args.shouldOpenNow?g({subjectId:f,subjectName:"control",subjectType:h,action:x,payload:{URI:u.args.uri}}):i.add({...M,action:g.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:x,payload:{URI:u.args.uri}})});return}default:{let _="Unexpected control event",ue=new L(1,1,{message:_});d(ue,_);return}}},a=({action:u,container:{id:h,endTime:f},branches:E=[],isEOV:T=!1,autoSelected:I=!1})=>{let S=ei(u,T),j={timestamp:!S.args.shouldOpenNow||T?1/0:f??1/0,priority:"container",initiator:h,actionType:S.type},x=r.emit.bind(r,A.interactives,{subjectId:h,subjectName:"container",type:P.actionChoice,actionType:S.type,payload:{invokeImmediately:S.args.shouldOpenNow,...S.args}}),M=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:S.type,payload:{invokeImmediately:S.args.shouldOpenNow,...S.args}})};switch(S.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let F=E.find(z=>z.id===S.args.branchId);if(!F)return;x(),M(),i.add({...j,action:w.bind(null,{subjectId:h,subjectName:"container",action:S,payload:{chapterId:F.chapterId,autoSelect:I}})});return}case y.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case y.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case y.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case y.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case y.EventActionTypes.continuePlayback.trim().toLowerCase():{x(),M(),i.add({...j,action:k.bind(null,{subjectId:h,subjectName:"container",action:S})});return}case y.EventActionTypes.openURI.trim().toLowerCase():{x(),M(),i.add({...j,action:g.bind(null,{subjectId:h,subjectName:"container",action:S,payload:{URI:u.args.uri}})});return}default:{let F="Unexpected container event",z=new L(1,1,{message:F});d(z,F);return}}};function s({container:u,branches:h,isEOV:f=!1}){let E=Mr(u.events);if(E){let T=ei(E.action,f);r.emit(A.interactives,{subjectId:u.id,subjectName:"container",type:P.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),i.add({timestamp:f?1/0:u.endTime??1/0,priority:"container",initiator:u.id,actionType:y.EventActionTypes.expect,action:v.bind(null,{subjectId:u.id,subjectName:"container"})}),n.isExpect=!0}else for(let T of u.events??[])a({action:T.action,container:u,branches:h,isEOV:f})}let c=({chapterId:u,action:h,branches:f=[]})=>{let E=r.emit.bind(r,A.interactives,{subjectId:u,subjectName:"chapter",type:P.actionChoice,actionType:h.type,payload:h.args}),T=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let I=f.find(S=>S.id===h.args.branchId);return I?.chapterId?(E(),T(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let I=ys(f);return I?.chapterId?(E(),T(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setRandomBranch.trim().toLowerCase():{let I=gs(f);return I?.chapterId?(E(),T(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let I=bs(f);return I?.chapterId?(E(),T(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let I=vs(f);return I?.chapterId?(E(),T(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.continuePlayback.trim().toLowerCase():return E(),T(),k.bind(null,{subjectId:u,subjectName:"chapter",action:h});case y.EventActionTypes.openURI.trim().toLowerCase():return E(),T(),g.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let I="Unexpected chapter event",S=new L(1,1,{message:I});d(S,I);return}}};function d(u,h){console.error(h),e.error$.next(u),r.emit(A.errors,u)}function m(u){let h=Mr(u.events);if(h){if(G(u))return;r.emit(A.interactives,{subjectId:u.id,subjectName:"chapter",type:P.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:y.EventActionTypes.expect,action:v.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else u.events?.forEach(f=>{let E=c({chapterId:u.id,action:f.action,branches:u.branches});E&&i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:f.action.type,action:E})})}let v=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(A.interactives,{subjectId:u,subjectName:h,type:P.actionExecution,actionType:y.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:y.EventActionTypes.expect})},b=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(A.interactives,{subjectId:u,subjectName:h,type:P.actionExecution,actionType:Es}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:Es})},k=({subjectId:u,subjectName:h,subjectType:f,action:E})=>{r.emit(A.interactives,{subjectId:u,subjectName:h,subjectType:f,type:P.actionExecution,actionType:E.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:E.type})},w=({subjectId:u,subjectName:h,subjectType:f,action:E,payload:T})=>{T.behaviour="change-chapter",r.emit(A.interactives,{subjectId:u,subjectName:h,subjectType:f,type:P.actionExecution,actionType:E.type,payload:T}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:E.type,payload:T})},g=({subjectId:u,subjectName:h,subjectType:f,action:E,payload:T})=>{if(!T.URI)return;let I=window.open(T.URI,"_blank","noopener,noreferrer");I&&(I.opener=null),r.emit(A.interactives,{subjectId:u,subjectName:h,subjectType:f,type:P.actionExecution,actionType:E.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:E.type})};return{onControlEvent:l,onContainerEvent:a,onChapterEvent:c,onExpectEvent:v,expectEventHandler:b,setManifestChapterEvents:m,setManifestContainerEvents:s,stopExpect:o,state:n}};var ii=W(_r(),1),D=require("@vkontakte/videoplayer-shared");var qt=(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]=ti(o)}return t[i]}).filter(Boolean)},Is=r=>{for(let e of r.variants)if(xs(e)&&e.payload)return e.payload.id},xs=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),ti=r=>{let e=Is(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},As=(r,e)=>{for(let t of r.media.videos)if(e===ti(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},ri=(r,e)=>r.reduce((t,i)=>{let n=As(e,i);return n?[...t,n]:t},[]);var Ye=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new D.ValueSubject([]),hasPrevChapter$:new D.ValueSubject(!1),prevChapter$:new D.ValueSubject(null),isInitialChapter$:new D.ValueSubject(!1),isGoBackLimited$:new D.ValueSubject(!1)};this.#r=null;this.#a=!1;this.#e=null;this.#p=null;this.events={inited$:new D.Subject,destroyed$:new D.Subject,error$:new D.Subject};this.#i=null;this.#n=null;this.#t=null;this.#s=new D.Subscription;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,ii.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=qt(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(A.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(A.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(A.errors,o)}let i=ri(t,e);this.state.history$.next(i)}getInitialChapterId(){let e=this.state.history$.getValue();return(0,ii.default)(e,-1)||this.#o.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return qt([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(A.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var Dt=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 Ht=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
+ "use strict";var Ta=Object.create;var Je=Object.defineProperty;var Sa=Object.getOwnPropertyDescriptor;var wa=Object.getOwnPropertyNames;var Aa=Object.getPrototypeOf,Ra=Object.prototype.hasOwnProperty;var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ka=(r,e)=>{for(var t in e)Je(r,t,{get:e[t],enumerable:!0})},Zr=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of wa(e))!Ra.call(r,i)&&i!==t&&Je(r,i,{get:()=>e[i],enumerable:!(n=Sa(e,i))||n.enumerable});return r};var D=(r,e,t)=>(t=r!=null?Ta(Aa(r)):{},Zr(e||!r||!r.__esModule?Je(t,"default",{value:r,enumerable:!0}):t,r)),Oa=r=>Zr(Je({},"__esModule",{value:!0}),r);var K=p((Xt,un)=>{"use strict";var Ae=function(r){return r&&r.Math===Math&&r};un.exports=Ae(typeof globalThis=="object"&&globalThis)||Ae(typeof window=="object"&&window)||Ae(typeof self=="object"&&self)||Ae(typeof global=="object"&&global)||Ae(typeof Xt=="object"&&Xt)||function(){return this}()||Function("return this")()});var _=p((od,hn)=>{"use strict";hn.exports=function(r){try{return!!r()}catch{return!0}}});var Re=p((sd,dn)=>{"use strict";var Pa=_();dn.exports=!Pa(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var bn=p((ad,yn)=>{"use strict";var Va=Re(),vn=Function.prototype,mn=vn.apply,fn=vn.call;yn.exports=typeof Reflect=="object"&&Reflect.apply||(Va?fn.bind(mn):function(){return fn.apply(mn,arguments)})});var H=p((ld,En)=>{"use strict";var Cn=Re(),gn=Function.prototype,Yt=gn.call,Ma=Cn&&gn.bind.bind(Yt,Yt);En.exports=Cn?Ma:function(r){return function(){return Yt.apply(r,arguments)}}});var ke=p((cd,xn)=>{"use strict";var In=H(),Na=In({}.toString),La=In("".slice);xn.exports=function(r){return La(Na(r),8,-1)}});var Zt=p((pd,Tn)=>{"use strict";var ja=ke(),$a=H();Tn.exports=function(r){if(ja(r)==="Function")return $a(r)}});var B=p((ud,Sn)=>{"use strict";var Jt=typeof document=="object"&&document.all;Sn.exports=typeof Jt>"u"&&Jt!==void 0?function(r){return typeof r=="function"||r===Jt}:function(r){return typeof r=="function"}});var ie=p((hd,wn)=>{"use strict";var Fa=_();wn.exports=!Fa(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var mt=p((dd,An)=>{"use strict";var _a=Re(),dt=Function.prototype.call;An.exports=_a?dt.bind(dt):function(){return dt.apply(dt,arguments)}});var er=p(On=>{"use strict";var Rn={}.propertyIsEnumerable,kn=Object.getOwnPropertyDescriptor,Ba=kn&&!Rn.call({1:2},1);On.f=Ba?function(e){var t=kn(this,e);return!!t&&t.enumerable}:Rn});var tr=p((fd,Pn)=>{"use strict";Pn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Mn=p((vd,Vn)=>{"use strict";var qa=H(),Da=_(),Ha=ke(),rr=Object,Ua=qa("".split);Vn.exports=Da(function(){return!rr("z").propertyIsEnumerable(0)})?function(r){return Ha(r)==="String"?Ua(r,""):rr(r)}:rr});var nr=p((yd,Nn)=>{"use strict";Nn.exports=function(r){return r==null}});var ir=p((bd,Ln)=>{"use strict";var Ga=nr(),za=TypeError;Ln.exports=function(r){if(Ga(r))throw new za("Can't call method on "+r);return r}});var Oe=p((Cd,jn)=>{"use strict";var Wa=Mn(),Ka=ir();jn.exports=function(r){return Wa(Ka(r))}});var de=p((gd,$n)=>{"use strict";var Qa=B();$n.exports=function(r){return typeof r=="object"?r!==null:Qa(r)}});var ft=p((Ed,Fn)=>{"use strict";Fn.exports={}});var vt=p((Id,Bn)=>{"use strict";var or=ft(),sr=K(),Xa=B(),_n=function(r){return Xa(r)?r:void 0};Bn.exports=function(r,e){return arguments.length<2?_n(or[r])||_n(sr[r]):or[r]&&or[r][e]||sr[r]&&sr[r][e]}});var Dn=p((xd,qn)=>{"use strict";var Ya=H();qn.exports=Ya({}.isPrototypeOf)});var zn=p((Td,Gn)=>{"use strict";var Za=K(),Hn=Za.navigator,Un=Hn&&Hn.userAgent;Gn.exports=Un?String(Un):""});var Jn=p((Sd,Zn)=>{"use strict";var Yn=K(),ar=zn(),Wn=Yn.process,Kn=Yn.Deno,Qn=Wn&&Wn.versions||Kn&&Kn.version,Xn=Qn&&Qn.v8,U,yt;Xn&&(U=Xn.split("."),yt=U[0]>0&&U[0]<4?1:+(U[0]+U[1]));!yt&&ar&&(U=ar.match(/Edge\/(\d+)/),(!U||U[1]>=74)&&(U=ar.match(/Chrome\/(\d+)/),U&&(yt=+U[1])));Zn.exports=yt});var lr=p((wd,ti)=>{"use strict";var ei=Jn(),Ja=_(),el=K(),tl=el.String;ti.exports=!!Object.getOwnPropertySymbols&&!Ja(function(){var r=Symbol("symbol detection");return!tl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&ei&&ei<41})});var cr=p((Ad,ri)=>{"use strict";var rl=lr();ri.exports=rl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var pr=p((Rd,ni)=>{"use strict";var nl=vt(),il=B(),ol=Dn(),sl=cr(),al=Object;ni.exports=sl?function(r){return typeof r=="symbol"}:function(r){var e=nl("Symbol");return il(e)&&ol(e.prototype,al(r))}});var oi=p((kd,ii)=>{"use strict";var ll=String;ii.exports=function(r){try{return ll(r)}catch{return"Object"}}});var ur=p((Od,si)=>{"use strict";var cl=B(),pl=oi(),ul=TypeError;si.exports=function(r){if(cl(r))return r;throw new ul(pl(r)+" is not a function")}});var li=p((Pd,ai)=>{"use strict";var hl=ur(),dl=nr();ai.exports=function(r,e){var t=r[e];return dl(t)?void 0:hl(t)}});var pi=p((Vd,ci)=>{"use strict";var hr=mt(),dr=B(),mr=de(),ml=TypeError;ci.exports=function(r,e){var t,n;if(e==="string"&&dr(t=r.toString)&&!mr(n=hr(t,r))||dr(t=r.valueOf)&&!mr(n=hr(t,r))||e!=="string"&&dr(t=r.toString)&&!mr(n=hr(t,r)))return n;throw new ml("Can't convert object to primitive value")}});var hi=p((Md,ui)=>{"use strict";ui.exports=!0});var fi=p((Nd,mi)=>{"use strict";var di=K(),fl=Object.defineProperty;mi.exports=function(r,e){try{fl(di,r,{value:e,configurable:!0,writable:!0})}catch{di[r]=e}return e}});var bt=p((Ld,bi)=>{"use strict";var vl=hi(),yl=K(),bl=fi(),vi="__core-js_shared__",yi=bi.exports=yl[vi]||bl(vi,{});(yi.versions||(yi.versions=[])).push({version:"3.38.0",mode:vl?"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 fr=p((jd,gi)=>{"use strict";var Ci=bt();gi.exports=function(r,e){return Ci[r]||(Ci[r]=e||{})}});var Pe=p(($d,Ei)=>{"use strict";var Cl=ir(),gl=Object;Ei.exports=function(r){return gl(Cl(r))}});var me=p((Fd,Ii)=>{"use strict";var El=H(),Il=Pe(),xl=El({}.hasOwnProperty);Ii.exports=Object.hasOwn||function(e,t){return xl(Il(e),t)}});var vr=p((_d,xi)=>{"use strict";var Tl=H(),Sl=0,wl=Math.random(),Al=Tl(1 .toString);xi.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Al(++Sl+wl,36)}});var Ve=p((Bd,Si)=>{"use strict";var Rl=K(),kl=fr(),Ti=me(),Ol=vr(),Pl=lr(),Vl=cr(),fe=Rl.Symbol,yr=kl("wks"),Ml=Vl?fe.for||fe:fe&&fe.withoutSetter||Ol;Si.exports=function(r){return Ti(yr,r)||(yr[r]=Pl&&Ti(fe,r)?fe[r]:Ml("Symbol."+r)),yr[r]}});var ki=p((qd,Ri)=>{"use strict";var Nl=mt(),wi=de(),Ai=pr(),Ll=li(),jl=pi(),$l=Ve(),Fl=TypeError,_l=$l("toPrimitive");Ri.exports=function(r,e){if(!wi(r)||Ai(r))return r;var t=Ll(r,_l),n;if(t){if(e===void 0&&(e="default"),n=Nl(t,r,e),!wi(n)||Ai(n))return n;throw new Fl("Can't convert object to primitive value")}return e===void 0&&(e="number"),jl(r,e)}});var br=p((Dd,Oi)=>{"use strict";var Bl=ki(),ql=pr();Oi.exports=function(r){var e=Bl(r,"string");return ql(e)?e:e+""}});var Mi=p((Hd,Vi)=>{"use strict";var Dl=K(),Pi=de(),Cr=Dl.document,Hl=Pi(Cr)&&Pi(Cr.createElement);Vi.exports=function(r){return Hl?Cr.createElement(r):{}}});var gr=p((Ud,Ni)=>{"use strict";var Ul=ie(),Gl=_(),zl=Mi();Ni.exports=!Ul&&!Gl(function(){return Object.defineProperty(zl("div"),"a",{get:function(){return 7}}).a!==7})});var $i=p(ji=>{"use strict";var Wl=ie(),Kl=mt(),Ql=er(),Xl=tr(),Yl=Oe(),Zl=br(),Jl=me(),ec=gr(),Li=Object.getOwnPropertyDescriptor;ji.f=Wl?Li:function(e,t){if(e=Yl(e),t=Zl(t),ec)try{return Li(e,t)}catch{}if(Jl(e,t))return Xl(!Kl(Ql.f,e,t),e[t])}});var _i=p((zd,Fi)=>{"use strict";var tc=_(),rc=B(),nc=/#|\.prototype\./,Me=function(r,e){var t=oc[ic(r)];return t===ac?!0:t===sc?!1:rc(e)?tc(e):!!e},ic=Me.normalize=function(r){return String(r).replace(nc,".").toLowerCase()},oc=Me.data={},sc=Me.NATIVE="N",ac=Me.POLYFILL="P";Fi.exports=Me});var Er=p((Wd,qi)=>{"use strict";var Bi=Zt(),lc=ur(),cc=Re(),pc=Bi(Bi.bind);qi.exports=function(r,e){return lc(r),e===void 0?r:cc?pc(r,e):function(){return r.apply(e,arguments)}}});var Hi=p((Kd,Di)=>{"use strict";var uc=ie(),hc=_();Di.exports=uc&&hc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Gi=p((Qd,Ui)=>{"use strict";var dc=de(),mc=String,fc=TypeError;Ui.exports=function(r){if(dc(r))return r;throw new fc(mc(r)+" is not an object")}});var Ki=p(Wi=>{"use strict";var vc=ie(),yc=gr(),bc=Hi(),Ct=Gi(),zi=br(),Cc=TypeError,Ir=Object.defineProperty,gc=Object.getOwnPropertyDescriptor,xr="enumerable",Tr="configurable",Sr="writable";Wi.f=vc?bc?function(e,t,n){if(Ct(e),t=zi(t),Ct(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Sr in n&&!n[Sr]){var i=gc(e,t);i&&i[Sr]&&(e[t]=n.value,n={configurable:Tr in n?n[Tr]:i[Tr],enumerable:xr in n?n[xr]:i[xr],writable:!1})}return Ir(e,t,n)}:Ir:function(e,t,n){if(Ct(e),t=zi(t),Ct(n),yc)try{return Ir(e,t,n)}catch{}if("get"in n||"set"in n)throw new Cc("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var Xi=p((Yd,Qi)=>{"use strict";var Ec=ie(),Ic=Ki(),xc=tr();Qi.exports=Ec?function(r,e,t){return Ic.f(r,e,xc(1,t))}:function(r,e,t){return r[e]=t,r}});var Le=p((Zd,Zi)=>{"use strict";var Ne=K(),Tc=bn(),Sc=Zt(),wc=B(),Ac=$i().f,Rc=_i(),ve=ft(),kc=Er(),ye=Xi(),Yi=me();bt();var Oc=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 Tc(r,this,arguments)};return e.prototype=r.prototype,e};Zi.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,o=r.proto,l=n?Ne:i?Ne[t]:Ne[t]&&Ne[t].prototype,s=n?ve:ve[t]||ye(ve,t,{})[t],a=s.prototype,c,d,f,v,y,k,w,C,u;for(v in e)c=Rc(n?v:t+(i?".":"#")+v,r.forced),d=!c&&l&&Yi(l,v),k=s[v],d&&(r.dontCallGetSet?(u=Ac(l,v),w=u&&u.value):w=l[v]),y=d&&w?w:e[v],!(!c&&!o&&typeof k==typeof y)&&(r.bind&&d?C=kc(y,Ne):r.wrap&&d?C=Oc(y):o&&wc(y)?C=Sc(y):C=y,(r.sham||y&&y.sham||k&&k.sham)&&ye(C,"sham",!0),ye(s,v,C),o&&(f=t+"Prototype",Yi(ve,f)||ye(ve,f,{}),ye(ve[f],v,y),r.real&&a&&(c||!a[v])&&ye(a,v,y)))}});var eo=p((Jd,Ji)=>{"use strict";var Pc=Math.ceil,Vc=Math.floor;Ji.exports=Math.trunc||function(e){var t=+e;return(t>0?Vc:Pc)(t)}});var je=p((em,to)=>{"use strict";var Mc=eo();to.exports=function(r){var e=+r;return e!==e||e===0?0:Mc(e)}});var no=p((tm,ro)=>{"use strict";var Nc=je(),Lc=Math.min;ro.exports=function(r){var e=Nc(r);return e>0?Lc(e,9007199254740991):0}});var $e=p((rm,io)=>{"use strict";var jc=no();io.exports=function(r){return jc(r.length)}});var gt=p((nm,oo)=>{"use strict";oo.exports=function(){}});var so=p(()=>{"use strict";var $c=Le(),Fc=Pe(),_c=$e(),Bc=je(),qc=gt();$c({target:"Array",proto:!0},{at:function(e){var t=Fc(this),n=_c(t),i=Bc(e),o=i>=0?i:n+i;return o<0||o>=n?void 0:t[o]}});qc("at")});var Et=p((sm,ao)=>{"use strict";var Dc=vt();ao.exports=Dc});var co=p((am,lo)=>{"use strict";so();var Hc=Et();lo.exports=Hc("Array","at")});var uo=p((lm,po)=>{"use strict";var Uc=co();po.exports=Uc});var wr=p((cm,ho)=>{"use strict";var Gc=uo();ho.exports=Gc});var Io=p((Qm,Eo)=>{"use strict";var ip=je(),op=Math.max,sp=Math.min;Eo.exports=function(r,e){var t=ip(r);return t<0?op(t+e,0):sp(t,e)}});var Mr=p((Xm,To)=>{"use strict";var ap=Oe(),lp=Io(),cp=$e(),xo=function(r){return function(e,t,n){var i=ap(e),o=cp(i);if(o===0)return!r&&-1;var l=lp(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 pp=Le(),up=Mr().includes,hp=_(),dp=gt(),mp=hp(function(){return!Array(1).includes()});pp({target:"Array",proto:!0,forced:mp},{includes:function(e){return up(this,e,arguments.length>1?arguments[1]:void 0)}});dp("includes")});var Ao=p((Jm,wo)=>{"use strict";So();var fp=Et();wo.exports=fp("Array","includes")});var ko=p((ef,Ro)=>{"use strict";var vp=Ao();Ro.exports=vp});var Ge=p((tf,Oo)=>{"use strict";var yp=ko();Oo.exports=yp});var Fo=p((hf,$o)=>{"use strict";var Cp=fr(),gp=vr(),jo=Cp("keys");$o.exports=function(r){return jo[r]||(jo[r]=gp(r))}});var Bo=p((df,_o)=>{"use strict";var Ep=_();_o.exports=!Ep(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Ho=p((mf,Do)=>{"use strict";var Ip=me(),xp=B(),Tp=Pe(),Sp=Fo(),wp=Bo(),qo=Sp("IE_PROTO"),jr=Object,Ap=jr.prototype;Do.exports=wp?jr.getPrototypeOf:function(r){var e=Tp(r);if(Ip(e,qo))return e[qo];var t=e.constructor;return xp(t)&&e instanceof t?t.prototype:e instanceof jr?Ap:null}});var Go=p((ff,Uo)=>{"use strict";Uo.exports={}});var Ko=p((vf,Wo)=>{"use strict";var Rp=H(),$r=me(),kp=Oe(),Op=Mr().indexOf,Pp=Go(),zo=Rp([].push);Wo.exports=function(r,e){var t=kp(r),n=0,i=[],o;for(o in t)!$r(Pp,o)&&$r(t,o)&&zo(i,o);for(;e.length>n;)$r(t,o=e[n++])&&(~Op(i,o)||zo(i,o));return i}});var Xo=p((yf,Qo)=>{"use strict";Qo.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Zo=p((bf,Yo)=>{"use strict";var Vp=Ko(),Mp=Xo();Yo.exports=Object.keys||function(e){return Vp(e,Mp)}});var is=p((Cf,ns)=>{"use strict";var es=ie(),Np=_(),ts=H(),Lp=Ho(),jp=Zo(),$p=Oe(),Fp=er().f,rs=ts(Fp),_p=ts([].push),Bp=es&&Np(function(){var r=Object.create(null);return r[2]=2,!rs(r,2)}),Jo=function(r){return function(e){for(var t=$p(e),n=jp(t),i=Bp&&Lp(t)===null,o=n.length,l=0,s=[],a;o>l;)a=n[l++],(!es||(i?a in t:rs(t,a)))&&_p(s,r?[a,t[a]]:t[a]);return s}};ns.exports={entries:Jo(!0),values:Jo(!1)}});var os=p(()=>{"use strict";var qp=Le(),Dp=is().values;qp({target:"Object",stat:!0},{values:function(e){return Dp(e)}})});var as=p((If,ss)=>{"use strict";os();var Hp=ft();ss.exports=Hp.Object.values});var cs=p((xf,ls)=>{"use strict";var Up=as();ls.exports=Up});var Vt=p((Tf,ps)=>{"use strict";var Gp=cs();ps.exports=Gp});var Dr=p((Gf,Cs)=>{"use strict";var Wp=ke();Cs.exports=Array.isArray||function(e){return Wp(e)==="Array"}});var Es=p((zf,gs)=>{"use strict";var Kp=TypeError,Qp=9007199254740991;gs.exports=function(r){if(r>Qp)throw Kp("Maximum allowed index exceeded");return r}});var Ts=p((Wf,xs)=>{"use strict";var Xp=Dr(),Yp=$e(),Zp=Es(),Jp=Er(),Is=function(r,e,t,n,i,o,l,s){for(var a=i,c=0,d=l?Jp(l,s):!1,f,v;c<n;)c in t&&(f=d?d(t[c],c,e):t[c],o>0&&Xp(f)?(v=Yp(f),a=Is(r,e,f,v,a,o-1)-1):(Zp(a+1),r[a]=f),a++),c++;return a};xs.exports=Is});var As=p((Kf,ws)=>{"use strict";var eu=Ve(),tu=eu("toStringTag"),Ss={};Ss[tu]="z";ws.exports=String(Ss)==="[object z]"});var ks=p((Qf,Rs)=>{"use strict";var ru=As(),nu=B(),Nt=ke(),iu=Ve(),ou=iu("toStringTag"),su=Object,au=Nt(function(){return arguments}())==="Arguments",lu=function(r,e){try{return r[e]}catch{}};Rs.exports=ru?Nt:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=lu(e=su(r),ou))=="string"?t:au?Nt(e):(n=Nt(e))==="Object"&&nu(e.callee)?"Arguments":n}});var Ps=p((Xf,Os)=>{"use strict";var cu=H(),pu=B(),Hr=bt(),uu=cu(Function.toString);pu(Hr.inspectSource)||(Hr.inspectSource=function(r){return uu(r)});Os.exports=Hr.inspectSource});var $s=p((Yf,js)=>{"use strict";var hu=H(),du=_(),Vs=B(),mu=ks(),fu=vt(),vu=Ps(),Ms=function(){},Ns=fu("Reflect","construct"),Ur=/^\s*(?:class|function)\b/,yu=hu(Ur.exec),bu=!Ur.test(Ms),Qe=function(e){if(!Vs(e))return!1;try{return Ns(Ms,[],e),!0}catch{return!1}},Ls=function(e){if(!Vs(e))return!1;switch(mu(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return bu||!!yu(Ur,vu(e))}catch{return!0}};Ls.sham=!0;js.exports=!Ns||du(function(){var r;return Qe(Qe.call)||!Qe(Object)||!Qe(function(){r=!0})||r})?Ls:Qe});var qs=p((Zf,Bs)=>{"use strict";var Fs=Dr(),Cu=$s(),gu=de(),Eu=Ve(),Iu=Eu("species"),_s=Array;Bs.exports=function(r){var e;return Fs(r)&&(e=r.constructor,Cu(e)&&(e===_s||Fs(e.prototype))?e=void 0:gu(e)&&(e=e[Iu],e===null&&(e=void 0))),e===void 0?_s:e}});var Hs=p((Jf,Ds)=>{"use strict";var xu=qs();Ds.exports=function(r,e){return new(xu(r))(e===0?0:e)}});var Us=p(()=>{"use strict";var Tu=Le(),Su=Ts(),wu=Pe(),Au=$e(),Ru=je(),ku=Hs();Tu({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=wu(this),n=Au(t),i=ku(t,0);return i.length=Su(i,t,t,n,0,e===void 0?1:Ru(e)),i}})});var Gs=p(()=>{"use strict";var Ou=gt();Ou("flat")});var Ws=p((iv,zs)=>{"use strict";Us();Gs();var Pu=Et();zs.exports=Pu("Array","flat")});var Qs=p((ov,Ks)=>{"use strict";var Vu=Ws();Ks.exports=Vu});var Ys=p((sv,Xs)=>{"use strict";var Mu=Qs();Xs.exports=Mu});var Hu={};ka(Hu,{ContainerTypes:()=>b.ContainerTypes,ControlTypes:()=>b.ControlTypes,CustomError:()=>O,EVENT_NAMES:()=>S,EventActionTypes:()=>b.EventActionTypes,EventTypes:()=>b.EventTypes,Interactives:()=>Ye,ManifestController:()=>ae,SDKInfo:()=>Du,chapterIdsToVKVideoIds:()=>jt,compareVersions:()=>Rt,containerTypes:()=>Qc,controlTypes:()=>Xc,eventActionTypes:()=>Rr,eventTypes:()=>Yc,getChapterIdByVkVideoId:()=>fa,getVKVideoIdByMedia:()=>Wr,getVideoRawIdByMedia:()=>da,graphEventTypes:()=>ge,hasEndTemplate:()=>ze,interactivesEventTypes:()=>P,isAreaControl:()=>Kc,isButtonControl:()=>Wc,isLastChapter:()=>G,isOneTextCtrlContainer:()=>se,isSupportedManifest:()=>b.isSupportedManifest,isTextControl:()=>qe,isVKVariantItem:()=>ma,isValidManifest:()=>Ar,migrateManifestToLatestVersion:()=>b.migrateManifestToLatestVersion,utils:()=>Ia,vkVideoIdsToChapterIds:()=>Kr});module.exports=Oa(Hu);var Jr="1.0.36-dev.62c89fb9.0";var ut=require("@vkontakte/videoplayer-shared");var Bt=class{constructor(e){this.layout=e}},et=class extends Bt{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 en(r){return"features"in r}var pe=class{constructor(e,t){this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&en(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]},[])||[]}};var re=require("@vkontakte/videoplayer-shared");function Ie(r,e=1){let t="0",n="0",i="0";return r.length===4?(t="0x"+r[1]+r[1],n="0x"+r[2]+r[2],i="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],n="0x"+r[3]+r[4],i="0x"+r[5]+r[6]),`rgba(${+t},${+n},${+i},${e})`}var tn="interactive",V={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},rn=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(rn||{}),nn=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(nn||{}),on=(n=>(n.start="left",n.end="right",n.center="center",n))(on||{}),tt=({target:r,props:e})=>{r.style.alignItems=(e?.gravityVertical&&rn[e.gravityVertical])??"center",r.style.justifyContent=(e?.gravityHorizontal&&nn[e.gravityHorizontal])??"center",r.style.textAlign=(e?.alignment&&on[e.alignment])??"center"},rt=({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},nt=({target:r,props:e,fallback:t})=>{r.style.backgroundColor=Ie(e?.background?.color??t.backgroundColor,e?.background?.alpha??t.backgroundAlpha)},xe=({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=Ie(i?t.borderColor:e?.shape?.border?.color??t.borderColor,i?t.borderAlpha:e?.shape?.border?.alpha??t.borderAlpha),r.style.borderRadius=l},sn=({target:r,isDark:e,baseDimension:t,fallback:n})=>{let l=Ie(n.shadowColorLight,n.shadowColorAlpha),s=Ie(n.shadowColorDark,n.shadowColorAlpha),a=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${a} ${c} ${e?s:l}`;r.style.boxShadow=d},ue=({target:r,layoutParams:e,fallback:t})=>{let n=e.angle??t.angle;n=n&&n*-1,r.style.transform=`rotate(${n}rad)`};var he=require("@vkontakte/videoplayer-shared");var qt="int",ee=(n=>(n.AREA=`${qt}_area`,n.TEXT=`${qt}_text`,n.BUTTON=`${qt}_bttn`,n))(ee||{});function an(r){return"features"in r}var W="interactive-control",R={common:W,selected:`${W}-selected`,wrapper:`${W}-wrapper`,disabled:`${W}-disabled`,button:`${W}-button`,area:`${W}-area`,text:`${W}-text`,blinkAnim:`${W}-blink-anim`,blinkAnimButton:`${W}-blink-anim-button`,blinkAnimArea:`${W}-blink-anim-area`};var O=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var Q=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new he.Subscription;this.error$=new he.Subject}createContainerElement(e){let t=document.createElement("div");t.classList.add(R.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=(this.control.layoutParams.innerSizesDependOn??V.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:n}}createClickListener(e){return t=>{t.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&an(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add((0,he.fromEvent)(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),i=>{let o=new O(1,1,{message:"Error happened on control interaction",error:i});this.error$.next(o)}));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var X=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Y=r=>X(r,"Object"),it=r=>X(r,"String"),ot=r=>X(r,"Array"),st=r=>X(r,"Number"),ln=r=>X(r,"Function"),cn=r=>X(r,"Boolean"),Dt=r=>st(r)&&!isNaN(r);var te=r=>Y(r)&&Object.keys(r).length===0,Ht=r=>ot(r)&&!r.length;var we=(r,e)=>it(r)&&(e?r.trim():r).length;var Ut="interactive-blink-anim-reference",L={common:Ut,animation:`${Ut}-animation`,disabled:`${Ut}-disabled`},at=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(L.common,L.animation),this._element=e}restart(){this._element&&(this._element.classList.add(L.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(L.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var Gt="interactive-container",j={common:Gt,hidden:`${Gt}-hidden`,disabled:`${Gt}-disabled`};var lt=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new zt(r,e)},zt=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(R.common,R.area),n.setAttribute("data-testid",ee.AREA),nt({target:n,props:this.control.props,fallback:{...V,backgroundColor:"transparent"}}),ue({target:n,layoutParams:this.control.layoutParams,fallback:V}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.updateShadowStyles(),this.registerEvents()}registerEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,re.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(j.disabled))return;let t=e.parentElement;if(t){let n=t.querySelector(`.${L.common}`);n&&this.syncBlinkAnimation(n)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,re.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(j.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,re.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(R.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(R.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){if(!(!this.container||!this.controlElement))if(cn(e)){let t=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";sn({target:this.controlElement,props:this.control.props,fallback:V,isDark:e,baseDimension:t}),xe({target:this.controlElement,props:this.control.props,fallback:{...V,borderColor:e?V.shadowColorDark:V.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${this.control.props?.shape?.roundCorners??V.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else xe({target:this.controlElement,props:this.control.props,fallback:{...V,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(R.blinkAnim,e),this.controlElement?.classList.toggle(R.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${R.blinkAnimArea}`)||this.controlElement.classList.contains(R.selected)||this.controlElement.classList.contains(L.disabled)||(this.controlElement.classList.add(L.disabled),this.subscriptions.add((0,re.fromEvent)(e,"animationiteration").pipe((0,re.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(L.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${R.blinkAnimArea}`)||this.controlElement.classList.contains(R.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}onError(e="",t){let n=new O(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}onProgress(){}onResize(){}};var ne=require("@vkontakte/videoplayer-shared");var ct=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,n),t.append(e);let i={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,i),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var pt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new Wt(r,e)},Wt=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(R.common,R.button),n.setAttribute("data-testid",ee.BUTTON),ue({target:n,layoutParams:this.control.layoutParams,fallback:V}),nt({target:n,props:this.control.props,fallback:V}),xe({target:n,props:this.control.props,fallback:V,dependsOn:this.container.dimensions}),tt({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=ct(this.control.type.trim().toLowerCase()),o=i.firstElementChild??i;rt({target:o,props:this.control.props,fallback:V,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.registerEvents()}registerEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,ne.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(j.disabled))return;let t=e.parentElement;if(t){let n=t.querySelector(`.${L.common}`);n&&this.syncBlinkAnimation(n)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,ne.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(j.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,ne.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(R.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(R.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(R.blinkAnim,e),this.controlElement?.classList.toggle(R.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${R.blinkAnimButton}`)||this.controlElement.classList.contains(R.selected)||this.controlElement.classList.contains(L.disabled)||(this.controlElement.classList.add(L.disabled),this.subscriptions.add((0,ne.fromEvent)(e,"animationiteration").pipe((0,ne.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(L.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${R.blinkAnimButton}`)||this.controlElement.classList.contains(R.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}onError(e="",t){let n=new O(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}onProgress(){}onResize(){}updateShadowStyles(){}};var pn=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new Kt(r,e)},Kt=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(R.common,R.text),n.setAttribute("data-testid",ee.TEXT),ue({target:n,layoutParams:this.control.layoutParams,fallback:V}),tt({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=ct(this.control.type.trim().toLowerCase()),o=i.firstElementChild??i;rt({target:o,props:this.control.props,fallback:V,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}onError(){}};var ht=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new Qt(r,e,t)},Qt=class extends pe{constructor(t,n,i){super(t,i);this.containerElement=null;this.controlSubscriptions=new ut.Subscription;this.error$=new ut.Subject;this.rootElement=n,this.layout=new et(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",pt),this.addControlFactory("text",pn),this.addControlFactory("area",lt)}createView({eventCallback:t}){let n=document.createElement("div");return n.classList.add(j.common,j.disabled),requestAnimationFrame(()=>{n.classList.remove(j.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(i=>{i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),i.setEvents(t),this.controlSubscriptions.add(i.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let t=this.getElement();t&&t.classList.add(j.hidden)}show(){let t=this.getElement();t&&t.classList.remove(j.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(j.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(j.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(this.controlSubscriptions.unsubscribe(),this.controls.forEach(n=>n.removeListeners()),t.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,n){n&&this.controls.forEach(i=>{i.onProgress(t)})}onResize(t){t&&this.controls.forEach(n=>{n.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(n=>n.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(n=>n.toggleBlinkAnimation(t))}};var ga=D(wr(),1),g=require("@vkontakte/videoplayer-shared"),Ee=require("@vkontakte/videoplayer-statistics");var yo=require("@vkontakte/videoplayer-shared");function Fe(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var mo="video_interactive",fo="videoint";var vo=250,_e=class{constructor(e){this.handleZoomChange=Fe(e=>{this.lastZoomInfo=e},vo);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,!st(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=zc(e),this.resizeObserver=new ResizeObserver(Fe(this.onResize,vo)),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(0,yo.loadVKLangPack)(this.lang,mo,fo)}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 zc(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 Be=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,n=!1,i=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let l=o.startTime-e;if(l<=i&&(o.endTime&&i<=o.endTime||o.endTime===null)){n=!0;break}i<l&&(t=t===-1?l:Math.min(t,l))}return!n&&t!==-1?t:null}}};var b=require("@interactiveplatform/movika-manifest");var bo={metadata:"Object",chapters:"Array"},Ar=r=>{if(!Y(r))return!1;for(let e in bo)if(!r[e]||!X(r[e],bo[e]))return!1;return(0,b.isSupportedManifest)(r.metadata.version)},qe=r=>r.type===b.ControlTypes.Text,Wc=r=>r.type===b.ControlTypes.Button,Kc=r=>r.type===b.ControlTypes.Area,Qc={Choice:"Choice",TextInput:"TextInput"},Xc={Button:"Button",Area:"Area",Text:"Text"},Yc={onClick:"onClick",onSuspense:"onSuspense"},Rr={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var It=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 xt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{ln(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(n=>n!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var Lo=require("@vkontakte/videoplayer-shared");var Tt=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,t){return Zc(...this.loaders[e])(t)}};function Zc(...r){return async function(t){let n=[...r];for(;n.length>0;)t=await n.shift()(t);return t}}function De(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function St({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:De(e,St.name,"Could not find media"),actions:r}}}}return{...n,errors:De(e,St.name,"Could not find chapter"),actions:r}}var wt=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}},be=class extends wt{constructor(){super(),this.listeners||wt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},He=class{constructor(){Object.defineProperty(this,"signal",{value:new be,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&&(He.prototype[Symbol.toStringTag]="AbortController",be.prototype[Symbol.toStringTag]="AbortSignal");function At(r){return r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof r.Request=="function"&&!r.Request.prototype.hasOwnProperty("signal")||!r.AbortController}function kr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=r;if(!At({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,k)=>{d.addEventListener("abort",()=>k(f),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([v,l(a,c)])}return l(a,c)},Request:o}}var Jc=()=>"fetch"in window,Ue=Jc()&&At({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Co=Ue?kr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Or=Ue?Co.fetch:window.fetch,_m=Ue?Co.Request:window.Request,Bm=Ue?He:window.AbortController,qm=Ue?be:window.AbortSignal;var Rt=(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 ep=async r=>{try{let e={},t;if(it(r)){t=new URL(r).href;let i=await Or(t);if(!i.ok)return{};e=await i.json()}else if(Y(r))e=r;else return{};if(!Ar(e))return{};let n=e.metadata.media;if(it(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let o=await Or(i);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch{return np(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch{return{}}};async function go(r){let{manifest:e,manifestURL:t}=await ep(r);if(!e)throw new Error("Failed on fetch");let n=(0,b.migrateManifestToLatestVersion)(e);return n.media=tp(n.media,t),delete n.metadata.media,n}function kt(r,e){if(e)return r.find(t=>t.id===e)}function Pr(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 Vr(r,e){return r.videos.find(t=>t.id===e)}function tp(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(n=>{let i="url"in n?n.url:"",o=rp(i,e);return{...n,url:o||i}})}))}}function rp(r="",e){try{return new URL(r,e).href}catch{return""}}function np(r){return Rt(r,"3.2.0")>=0}var Po=D(Ge(),1);var Ot=r=>ot(r)&&!Ht(r),G=r=>r.order==="end",ze=r=>ot(r.containers)&&!Ht(r.containers)&&G(r),Vo=(r,e)=>{let t=r*1e3;return Ot(e.controls)&&t<(e.startTime??0)},Nr=(r,e)=>{let t=r*1e3;return Ot(e.controls)&&t>=(e.startTime??0)&&t<=(e.endTime??1/0)};var oe=(r=[])=>r.some(e=>e.action.type==="expect"),Lr=(r=[])=>r.find(e=>e.action.type==="expect"),bp=r=>r?.length===1,se=r=>bp(r)&&qe(r[0]);function Mo(r=[],e=1/0,t=[]){return r.filter(({container:n})=>!(0,Po.default)(t,n.container.id)&&oe(n.container.events)&&n.container.endTime===e&&!n.isRemoved)}function Pt({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=w=>e.find(({container:u})=>u.container.id===w)?.container.isRemoved,n=oe(r.events)&&!t(r.id),i=(w,C=!1,u=!1)=>{let h=u?"every":"some";return w.controls[h](m=>{let I=C?w.endTime===r.endTime:!0;return m.events?.[h](E=>E.action?.type===Rr.openURI)&&I})},o=w=>w.some(({container:C})=>i(C.container,!0,!1)&&!C.isRemoved),l=w=>w.every(({container:C})=>C.isRemoved?!0:i(C.container,!0,!0)),s=Mo(e,r.endTime,[r.id]).length,a=w=>w.controls.some(C=>C.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,k=a(r);return{isExpectTime:c,hasOtherExpect:s>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:f,isAllOpenURIEventsValid:v,isExpectEventForCurrentContainer:y,hasShouldOpenNowEvent:k}};var ae=class extends Tt{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Lo.ValueSubject(null);this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){this.release();let n=await this.exec("manifestLoaders",{actions:{addErrorMessage:De},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",St({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Pr,getChapter:kt,getMedia:Vr,getByBranches:this.getByBranches.bind(this),addErrorMessage:De},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=kt(this.manifest.chapters,t);if(n){let i=Vr(this.manifest.media,n.videoId),o=Pr(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=kt(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?G(this.chapter):!1}};var ds=D(Vt(),1),ms=require("@vkontakte/videoplayer-core"),Z=require("@vkontakte/videoplayer-shared");var us=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 hs=D(Vt(),1);function Fr(){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,hs.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 Ce=D(Ge(),1);function _r(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,Ce.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"mpeg":(i||(0,Ce.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"hls":(i||(0,Ce.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:o.url}});break;case"dash":(i||(0,Ce.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 We=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,Ce.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var zp=2;function Br(r){let e=Fr(),t=new Z.Subscription,n={},i=null,o=!1,l,s=new Z.ValueSubject(null);r&&a(r);function a(C){i=C}function c(C,u,h){if(!i)throw Error("need to set interactive controller");if(!i.options)return;let I=(e.map.get(C)??{})[u];if(I){n={chapterId:h,listId:C,itemId:u,...I};let E=n.player;n.subscription.add(E.info.currentQuality$.subscribe(x=>{let A=E.info.position$.getValue(),$=E.info.isAutoQualityEnabled$.getValue();if(!(!x||!A||$))for(let T of e.map)(0,ds.default)(T[1]).forEach(({player:M})=>{We(M,x)})})).add(E.events.started$.subscribe(()=>{d(u)})),I.container.remove(),i.setPlayer(I.player),o||(i.init(),o=!0),s.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}async function d(C){if(!i)throw Error("need to set interactive controller");if(te(n)||C!==n.itemId)return;let 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:C},manifestVideo:u}){if(te(n)||!i)return;let h=n.player.info.muted$.getValue(),m=n.player.info.currentQuality$.getValue(),I=n.player.info.isAutoQualityEnabled$.getValue(),E=n.player.info.volume$.getValue(),x=n.player.info.currentPlaybackRate$.getValue(),A=!I,$=!1;for(let T of e.map)if(T[0]===u.id&&!i.state.isReplay$.getValue()){let M=Object.keys(T[1]);for(let N of M)N===n.itemId?(M.length<zp||($=!0),e.removePlayer(T[0],N)):($=!0,c(T[0],N,C),A?We(n.player,m):n.player.setAutoQuality(!0),n.player.setVolume(E),n.player.setMuted(h),n.player.setPlaybackRate(x))}else e.removePlayer(T[0]);$||(await v({media:u,chapterId:C,setAsActive:!0,playbackRate:x}),A?We(n.player,m):n.player.setAutoQuality(!0),n.player.setVolume(E),n.player.setMuted(h))}async function v({media:C,chapterId:u,prefetch:h=!0,setAsActive:m=!0,autoplay:I=!1,preferredExt:E,title:x,playbackRate:A}){let $=Math.random().toString(),T=document.createElement("div");l.append(T);let M;if(i?.options?.vkVideoLoader){let Ze=us(C);Ze.length&&(M=await i.options.vkVideoLoader(...Ze))}let N=i?.options?.coreConfig||void 0,z={...N,configName:[...N?.configName??[],"interactive"]},J={container:T,...M?.videos?.[0]||{sources:_r(C,E).sources},title:x,failoverHosts:M?.failoverHosts||[]},F=new ms.Player(z,Z.Tracer.createRootTracer());F.initVideo(J);let le=null;if(M?.videos&&i?.options.createOneStat){let Ze=M.videos[0],_t=i.options.createOneStat(Ze),Yr=new Z.Subscription;_t&&(Yr.add(_t.attachTo(F)),le={oneStat:_t,statSubscription:Yr})}let Xr=new Z.Subscription,xa=n?.player?.info.isAutoQualityEnabled$.getValue();Xr.add(F.events.canplay$.subscribe(function(){xa||We(F,n.player.info.currentQuality$.getValue()),A&&F.setPlaybackRate(A)}));let ce=e.createPlayer({listId:C.id,itemId:$,player:F,container:T,sources:_r(C,E).sources,config:J,subscription:Xr,statistics:le});return m&&c(C.id,ce.itemId,u),I&&ce.player.play(),h&&!I&&ce.player.prepare(),{player:ce.player,config:ce.config,statistics:ce.statistics}}function y(){k(),i=null,l.remove()}function k(){t.unsubscribe(),e.removeAll(),n={},o=!1}async function w(){if(!i)throw Error("need to set interactive controller");k(),l=document.createElement("div");let{media:C,chapter:u}=i.getCurrentChapter();C&&u?(t.add(i.events.chapterChanged$.subscribe(f)),await v({media:C,chapterId:u.id,title:u.label})):console.error("not found")}return{...e,init:w,setInteractiveController:a,createPlayer:v,removeAll:y,getActivePlayer:function(){return n},activePlayerChanged:s}}var S={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},ge={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},P={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var vs=D(Ge(),1),ys=require("@vkontakte/videoplayer-shared");function qr(r){return function(...t){return r(...t.reverse())}}function Ke(r,...e){return(...t)=>Y(e[0])&&Y(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var Mt=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&&(oe(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 k=!s&&!d&&c;k&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:k})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&a&&this.gameState!==5){if(y){let w=((C,u,h,m)=>!C&&!u&&h||C&&!u&&h&&!m||C&&!u&&h&&m)(l,s,d,this.isSelectedContainerEvent);this.fakeRemoveView(w)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!l||!s||!f)&&(this.selectBranches.stopExpect(),o())}},isEOV:()=>this.gameState===4},n=Ke(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,vs.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(Nr(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=Nr(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(S.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new ys.Subscription,this.player=e,this.interactiveEvents=o,this.getContainerEventState=a,this.isPermanentText=c&&se(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(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{e?this.container.disable?.():this.container.enable?.()})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime??1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime??1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||t:oe(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(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,this.onRemove?.()}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}destroy(){this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:this.container.container.endTime??1/0,id:this.container.container.id})}};var bs=(r=[])=>r.reduce((e,t,n)=>{let i=(t?.controls??[]).filter(o=>!qe(o));if(Ot(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 Js=D(Ge(),1),Gr=D(Vt(),1),ea=D(Ys(),1);function Zs(){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(Dt(s)){let d=r[s]??null;if(d&&a&&we(a,!0)){let f={},v=d[a];return v&&(f={...f,...v}),f=te(f)?null:f,f&&we(c,!0)?f[c]??null:f}return d}return null}function o({timestamp:s,priority:a,initiator:c}){if(Dt(s))if(r[s]){if(a&&we(a,!0))if(r[s][a]){if(c&&we(c,!0))if(r[s][a][c]){if(delete r[s][a][c],!te(r[s][a]))return!0}else return!1;if(delete r[s][a],!te(r[s]))return!0}else return!1;return delete r[s]}else return!1;return!1}function l({timestamp:s,priority:a,initiator:c,...d}){r[s]?.[a]?.[c]?r[s][a][c].push({...d}):r[s]?.[a]?r[s][a]={...r[s][a],[c]:[{...d}]}:r[s]?r[s]={...r[s],[a]:{[c]:[{...d}]}}:r[s]={[a]:{[c]:[{...d}]}}}return{map:r,remove:o,add:l,removeAll:e,get:i,getLte:t,getGte:n}}var Nu=[b.EventActionTypes.expect,b.EventActionTypes.setNextBranch],Lu=1/0;function ta(r,e){let t=r,n,i=ju(e),o=Zs(),l,s=()=>{y(),u()},a=h=>{o.add.call(void 0,h),k()},c=(h=[])=>{for(let m of h)if(m.action(),(0,Js.default)(Nu,m.actionType))break},d=(h=1/0)=>{let m=Lt(o.get({timestamp:h,priority:"control"})??{}),I=Lt(o.get({timestamp:h,priority:"container"})??{}),E=Lt(o.get({timestamp:h,priority:"chapter"})??{});return[...m,...I,...E]},f=h=>{i.isReady(h)&&c(d(h))},v=()=>{c([...Lt(o.get({timestamp:1/0,priority:"chapter"})??{})])},y=()=>{n&&(l?.unsubscribe(),n=void 0)},k=()=>{n||(n=()=>setTimeout(()=>{f(1/0)}),l=t.events.ended$.subscribe(n))},w=h=>{y(),t=h},C=h=>{h.priority==="container"&&i.resetCalled(h.timestamp),o.remove(h)},u=()=>{i.release(),o.removeAll()};return{setPlayer:w,add:a,remove:C,exec:f,execEndOfVideo:v,listen:k,unlisten:y,release:s,containersEventsCallState:i,getPreparedToExecActions:d}}function ju(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??Lu,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,Gr.default)(a);return r?c.some(f=>f):!c.some(f=>!f)},release:()=>e.clear()}}function Lt(r){return(0,ea.default)((0,Gr.default)(r)).sort(e=>e.actionType===b.EventActionTypes.expect?-1:1)}var ra={videoContentHeight:0,videoContentWidth:0},na=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return ra;let{clientHeight:n,clientWidth:i}=r.experimental.element$.getValue()||{};if(!(n&&i))return ra;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 $u=250;function ia(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}=na(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=Fe(s=>{let{fns:a=[]}=r();n(s);for(let c of a)c()},$u);function l(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e?.()},release:l}}var Fu=r=>Math.floor(Math.random()*r),sa=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},aa=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 la=r=>{let e=r.length,t=Fu(e);return r[t]},oa=1,ca=r=>{let e=0;for(let n=0;n<r.length;++n)e+=r[n].weight??oa;let t=Math.random()*e;e=0;for(let n=0;n<r.length-1;++n)if(e+=r[n].weight??oa,e>=t)return r[n];return r[r.length-1]};var pa={shouldOpenNow:!0,isDetachContainer:!0},ua="after-expect",zr=(r,e=!1)=>({...r,args:e?{...r.args,...pa}:{...pa,...r.args}}),ha=({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:I,branches:E=[],onEvent:x,isEOV:A=()=>!1,isDisabled:$=()=>!1})=>{let T=zr(u,A()),M={timestamp:1/0,priority:"control",initiator:m,actionType:T.type},N=$(),z=r.emit.bind(r,S.interactives,{subjectId:m,subjectType:h,subjectName:"control",type:N?P.actionChoiceCanceled:P.actionChoice,actionType:u.type,payload:{invokeImmediately:T.args.shouldOpenNow,containerId:I,...T.args}}),J=()=>{e.interactiveActionChoice$.next({subjectId:m,subjectType:h,subjectName:"control",type:N?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:T.args.shouldOpenNow,containerId:I,...T.args}})};if(N){z(),J();return}switch(T.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let F=E.find(le=>le.id===T.args.branchId);if(!F)return;x(T.args.isDetachContainer,y.bind(null,{subjectId:m,subjectName:"control"})),z(),J(),T.args.shouldOpenNow?w({subjectId:m,subjectName:"control",subjectType:h,action:T,payload:{chapterId:F.chapterId,autoSelect:!1}}):n.add({...M,action:w.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:T,payload:{chapterId:F.chapterId,autoSelect:!1}})});return}case b.EventActionTypes.continuePlayback.trim().toLowerCase():{x(T.args.isDetachContainer,y.bind(null,{subjectId:m,subjectName:"control"})),z(),J(),T.args.shouldOpenNow?k({subjectId:m,subjectName:"control",subjectType:h,action:u}):n.add({...M,action:k.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:u})});return}case b.EventActionTypes.openURI.trim().toLowerCase():{x(T.args.isDetachContainer,y.bind(null,{subjectId:m,subjectName:"control"})),z(),J(),T.args.shouldOpenNow?C({subjectId:m,subjectName:"control",subjectType:h,action:T,payload:{URI:u.args.uri}}):n.add({...M,action:C.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:T,payload:{URI:u.args.uri}})});return}default:{let F="Unexpected control event",le=new O(1,1,{message:F});d(le,F);return}}},s=({action:u,container:{id:h,endTime:m},branches:I=[],isEOV:E=!1,autoSelected:x=!1})=>{let A=zr(u,E),$={timestamp:!A.args.shouldOpenNow||E?1/0:m??1/0,priority:"container",initiator:h,actionType:A.type},T=r.emit.bind(r,S.interactives,{subjectId:h,subjectName:"container",type:P.actionChoice,actionType:A.type,payload:{invokeImmediately:A.args.shouldOpenNow,...A.args}}),M=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:A.type,payload:{invokeImmediately:A.args.shouldOpenNow,...A.args}})};switch(A.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let N=I.find(z=>z.id===A.args.branchId);if(!N)return;T(),M(),n.add({...$,action:w.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{chapterId:N.chapterId,autoSelect:x}})});return}case b.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case b.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case b.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case b.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case b.EventActionTypes.continuePlayback.trim().toLowerCase():{T(),M(),n.add({...$,action:k.bind(null,{subjectId:h,subjectName:"container",action:A})});return}case b.EventActionTypes.openURI.trim().toLowerCase():{T(),M(),n.add({...$,action:C.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{URI:u.args.uri}})});return}default:{let N="Unexpected container event",z=new O(1,1,{message:N});d(z,N);return}}};function a({container:u,branches:h,isEOV:m=!1}){let I=Lr(u.events);if(I){let E=zr(I.action,m);r.emit(S.interactives,{subjectId:u.id,subjectName:"container",type:P.actionChoice,actionType:E.type,payload:{invokeImmediately:E.args.shouldOpenNow,...E.args}}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:E.type,payload:{invokeImmediately:E.args.shouldOpenNow,...E.args}}),n.add({timestamp:m?1/0:u.endTime??1/0,priority:"container",initiator:u.id,actionType:b.EventActionTypes.expect,action:v.bind(null,{subjectId:u.id,subjectName:"container"})}),i.isExpect=!0}else for(let E of u.events??[])s({action:E.action,container:u,branches:h,isEOV:m})}let c=({chapterId:u,action:h,branches:m=[]})=>{let I=r.emit.bind(r,S.interactives,{subjectId:u,subjectName:"chapter",type:P.actionChoice,actionType:h.type,payload:h.args}),E=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let x=m.find(A=>A.id===h.args.branchId);return x?.chapterId?(I(),E(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let x=la(m);return x?.chapterId?(I(),E(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setRandomBranch.trim().toLowerCase():{let x=ca(m);return x?.chapterId?(I(),E(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let x=aa(m);return x?.chapterId?(I(),E(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let x=sa(m);return x?.chapterId?(I(),E(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.continuePlayback.trim().toLowerCase():return I(),E(),k.bind(null,{subjectId:u,subjectName:"chapter",action:h});case b.EventActionTypes.openURI.trim().toLowerCase():return I(),E(),C.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let x="Unexpected chapter event",A=new O(1,1,{message:x});d(A,x);return}}};function d(u,h){console.error(h),e.error$.next(u),r.emit(S.errors,u)}function f(u){let h=Lr(u.events);if(h){if(G(u))return;r.emit(S.interactives,{subjectId:u.id,subjectName:"chapter",type:P.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:b.EventActionTypes.expect,action:v.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else u.events?.forEach(m=>{let I=c({chapterId:u.id,action:m.action,branches:u.branches});I&&n.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:m.action.type,action:I})})}let v=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(S.interactives,{subjectId:u,subjectName:h,type:P.actionExecution,actionType:b.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:b.EventActionTypes.expect})},y=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(S.interactives,{subjectId:u,subjectName:h,type:P.actionExecution,actionType:ua}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:ua})},k=({subjectId:u,subjectName:h,subjectType:m,action:I})=>{r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:m,type:P.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:I.type})},w=({subjectId:u,subjectName:h,subjectType:m,action:I,payload:E})=>{E.behaviour="change-chapter",r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:m,type:P.actionExecution,actionType:I.type,payload:E}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:I.type,payload:E})},C=({subjectId:u,subjectName:h,subjectType:m,action:I,payload:E})=>{if(!E.URI)return;let x=window.open(E.URI,"_blank","noopener,noreferrer");x&&(x.opener=null),r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:m,type:P.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:I.type})};return{onControlEvent:l,onContainerEvent:s,onChapterEvent:c,onExpectEvent:v,expectEventHandler:y,setManifestChapterEvents:f,setManifestContainerEvents:a,stopExpect:o,state:i}};var Qr=D(wr(),1),q=require("@vkontakte/videoplayer-shared");var jt=(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]=Wr(o)}return t[n]}).filter(Boolean)},da=r=>{for(let e of r.variants)if(ma(e)&&e.payload)return e.payload.id},ma=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),Wr=r=>{let e=da(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},fa=(r,e)=>{for(let t of r.media.videos)if(e===Wr(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},Kr=(r,e)=>r.reduce((t,n)=>{let i=fa(e,n);return i?[...t,i]:t},[]);var Xe=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:o}){this.state={history$:new q.ValueSubject([]),hasPrevChapter$:new q.ValueSubject(!1),prevChapter$:new q.ValueSubject(null),isInitialChapter$:new q.ValueSubject(!1),isGoBackLimited$:new q.ValueSubject(!1)};this.#r=null;this.#s=!1;this.#e=null;this.#p=null;this.events={inited$:new q.Subject,destroyed$:new q.Subject,error$:new q.Subject};this.#n=null;this.#i=null;this.#t=null;this.#a=new q.Subscription;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,Qr.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=jt(o,n);if(this.#p=l,this.state.history$.next(o),!(!t||!this.#r||!this.#n))try{await this.#r.save(this.#n,l)}catch{let a=new O(1,5,"Unable to save interactive history");this.events.error$.next(a),this.#t?.emit(S.errors,a)}}async goBack(){if(!this.state||!this.#i){let n=new O(1,5,"Unable to save interactive history");return this.events.error$.next(n),this.#t?.emit(S.errors,n)}this.#l=!0;let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await this.#i.setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){if(!this.#e||!this.#n)return;let e=this.#e,t=[this.getInitialVideoId()];if(this.#r)try{let i=await this.#r.get(this.#n);i.length&&(t=i)}catch{let o=new O(1,5,"Error while trying to fetch data");this.events.error$.next(o),this.#t?.emit(S.errors,o)}let n=Kr(t,e);this.state.history$.next(n)}getInitialChapterId(){let e=this.state.history$.getValue();return(0,Qr.default)(e,-1)||this.#o.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return jt([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(S.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var $t=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 Ft=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 @@
11
11
  height: var(--interactive-height);
12
12
  background-color: var(--black);
13
13
  visibility: hidden;
14
- `,this.lastFrameCanvas=new Dt,this.endOffsetMs=t,this._callbacks={onError:i},this.lastFrameCanvas.rootElement.style.cssText=`
14
+ `,this.lastFrameCanvas=new $t,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 ws(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var Ss=`/* 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 va(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var ya=`/* interactive-container */
20
20
  .interactive-container {
21
21
  opacity: 1;
22
22
  visibility: visible;
@@ -31,16 +31,6 @@
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 @@
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 @@
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 @@
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 @@
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 Rs=r=>{let e=document.createElement("style");e.textContent=Ss,r.prepend(e)};var Ps=require("@vkontakte/videoplayer-core");var ks=Object.freeze({lang:C.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},isTouch:!1,animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1,controlsTapPlace:!1,controlsFillAnimation:!1,controlsHideAnimation:!1}});function Ju(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var Ze=class{constructor(e){this.playerSubscriptions=new C.Subscription;this.subscriptions=new C.Subscription;this.globalEventEmitter=new kt;this.animation=new Ot;this.seekToInteractiveController=new Ue;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Ju();this.factories=new Map([["choice",Rt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new C.Subscription;this.graph=null;this.lastFrame=null;this.blinkAnimationRef=null;this.appState=0;this.state={prevChapter$:new C.ValueSubject(null),isInitialChapter$:new C.ValueSubject(!1),isFirstChapter$:new C.ValueSubject(!0),isEndChapter$:new C.ValueSubject(!1),isInteractiveExpectation$:new C.ValueSubject(!1),isReplay$:new C.ValueSubject(!1),calledByInteractive$:new C.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new C.ValueSubject(!1),disabledControls$:new C.ValueSubject(!1),interactiveRanges$:new C.ValueSubject([]),isInteractiveTime$:new C.ValueSubject(!1),statistics$:new C.ValueSubject(null),isSeekable$:new C.ValueSubject(!1)};this.events={noInteraction$:new C.Subject,graphVisibilityChanged$:new C.Subject,watchAgainIsClicked$:new C.Subject,chapterChanged$:new C.Subject,playerChanged$:new C.Subject,error$:new C.Subject,eachTick$:new C.Subject,manifestChanged$:new C.Subject,interactiveRangeEnded$:new C.Subject,interactiveContainerRemoved$:new C.Subject,interactiveContainerFakeRemoved$:new C.Subject,interactiveActionExecution$:new C.Subject,interactiveActionChoice$:new C.Subject,interactiveVisibilityChanged$:new C.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(A.errors,e)};this.clearHistoryIfEnded=()=>{let e=this.player?.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:i}=this.getCurrentChapter();e&&i&&G(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(A.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={...ks,...e,config:{...ks.config,...e.config}},this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new It,this.blinkAnimationRef.create();let n=this.blinkAnimationRef.element;n&&this.rootElement.append(n)}this._options.parentElement.append(this.rootElement),this.historyController=new Ye({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 Ht({parentElement:this._options.parentElement,onError:n=>{let o=new L(1,6,n);this.emitErrorEvent(o)}})),Rs(this._options.parentElement),this.subscriptions.add((0,C.fromEvent)(this.rootElement,"mousedown").subscribe(n=>n.stopPropagation())).add((0,C.fromEvent)(this.rootElement,"mouseup").subscribe(n=>n.stopPropagation())),this.manifestController=new pe(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 He({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:n=>{this.setChapter({chapterId:n}),this.globalEventEmitter.emit(A.graph,{type:Ie.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=Kr(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(A.interactives,{type:P.rangeEnded,payload:n,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:n}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe((0,C.once)()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,C.combine)({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=>!ce(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 jt({player:this.player,container:l,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>Mo(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&&G(i)&&Be(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,Os.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)};Tt({...e,gameControllers:this.gameControllers,execFn:Xe(Xr(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?Tt({...e,gameControllers:this.gameControllers,execFn:Xe(Xr(t),!1)}):Tt({...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(A.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&&Ps.clientChecker.browser.isSafari&&await ws(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(A.chapterChanged,{chapter:o,media:l,graph:a}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new C.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?xe.InteractiveInterfaceClick.GRAPH_SHOW:xe.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(xe.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(xe.InteractiveInterfaceClick.NEXT_BUTTON),n==="Area"&&e.next(xe.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new C.Observable(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(A.graph,{type:Ie.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===y.EventActionTypes.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&&le(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,y.isSupportedManifest)(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){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 Ms={Container:de,createChoiceContainer:Rt,createAreaControl:xt,createButtonControl:St,classnamesPrefix:hi};var eh={version:si};
149
+ `;var ba=r=>{let e=document.createElement("style");e.textContent=ya,r.prepend(e)};var Ea=require("@vkontakte/videoplayer-core");var Ca=Object.freeze({lang:g.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1}});function qu(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var Ye=class{constructor(e){this.playerSubscriptions=new g.Subscription;this.subscriptions=new g.Subscription;this.globalEventEmitter=new It;this.animation=new xt;this.seekToInteractiveController=new Be;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=qu();this.factories=new Map([["choice",ht]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new g.Subscription;this.graph=null;this.lastFrame=null;this.blinkAnimationRef=null;this.appState=0;this.state={prevChapter$:new g.ValueSubject(null),isInitialChapter$:new g.ValueSubject(!1),isFirstChapter$:new g.ValueSubject(!0),isEndChapter$:new g.ValueSubject(!1),isInteractiveExpectation$:new g.ValueSubject(!1),isReplay$:new g.ValueSubject(!1),calledByInteractive$:new g.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new g.ValueSubject(!1),disabledControls$:new g.ValueSubject(!1),interactiveRanges$:new g.ValueSubject([]),isInteractiveTime$:new g.ValueSubject(!1),statistics$:new g.ValueSubject(null),isSeekable$:new g.ValueSubject(!1)};this.events={noInteraction$:new g.Subject,graphVisibilityChanged$:new g.Subject,watchAgainIsClicked$:new g.Subject,chapterChanged$:new g.Subject,playerChanged$:new g.Subject,error$:new g.Subject,eachTick$:new g.Subject,manifestChanged$:new g.Subject,interactiveRangeEnded$:new g.Subject,interactiveContainerRemoved$:new g.Subject,interactiveContainerFakeRemoved$:new g.Subject,interactiveActionExecution$:new g.Subject,interactiveActionChoice$:new g.Subject,interactiveVisibilityChanged$:new g.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(S.errors,e)};this.clearHistoryIfEnded=()=>{let e=this.player?.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&G(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(S.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={...Ca,...e,config:{...Ca.config,...e.config}},this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new at,this.blinkAnimationRef.create();let i=this.blinkAnimationRef.element;i&&this.rootElement.append(i)}this._options.parentElement.append(this.rootElement),this.historyController=new Xe({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 Ft({parentElement:this._options.parentElement,onError:i=>{let o=new O(1,6,i);this.emitErrorEvent(o)}})),ba(this._options.parentElement),this.subscriptions.add((0,g.fromEvent)(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add((0,g.fromEvent)(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new ae(this._options.loaders,i=>{let o=new O(1,3,i);this.emitErrorEvent(o)});let n=[];this._options.lastFrame&&n.push(()=>{this.lastFrame?.updateCanvasDimensions(!0)}),n.push(()=>{let i=this.state.isInteractiveTime$.getValue();for(let o of this.gameControllers)o.onResize(i)}),this.resizeManager=ia(()=>({player:this.player,parentElement:this._options.parentElement,fns:n})),this._options.graph&&(this.graph=new _e({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(S.graph,{type:ge.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let o=new O(1,2,{message:i});this.emitErrorEvent(o)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),e.payload?.behaviour==="change-chapter"){let{chapterId:t}=e.payload;this.setChapter({chapterId:t}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(e.payload?.behaviour==="change-manifest"){let{manifestURL:t}=e.payload;t&&this.setManifest(t)}e.actionType==="expect"?(this.state.isInteractiveExpectation$.next(!0),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType==="after-expect"&&(this.state.isInteractiveExpectation$.next(!1),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}))})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:n})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in n&&n.invokeImmediately||this.destroyGameControllers(!1)}))}async initSeamless(){this.seamlessController=Br(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(S.interactives,{type:P.rangeEnded,payload:i,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:i}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe((0,g.once)()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,g.combine)({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=>!se(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 Mt({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&&G(n)&&ze(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,ga.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)};Pt({...e,gameControllers:this.gameControllers,execFn:Ke(qr(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?Pt({...e,gameControllers:this.gameControllers,execFn:Ke(qr(t),!1)}):Pt({...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(S.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=ta(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=ha({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&Ea.clientChecker.browser.isSafari&&await va(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(S.chapterChanged,{chapter:o,media:l,graph:s}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new g.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?Ee.InteractiveInterfaceClick.GRAPH_SHOW:Ee.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Ee.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(Ee.InteractiveInterfaceClick.NEXT_BUTTON),i==="Area"&&e.next(Ee.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new g.Observable(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(S.graph,{type:ge.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===b.EventActionTypes.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&oe(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,b.isSupportedManifest)(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){return bs(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 Ia={Container:pe,createChoiceContainer:ht,createAreaControl:lt,createButtonControl:pt,classnamesPrefix:tn};var Du={version:Jr};