@vkontakte/videoplayer-interactive 1.0.36-dev.ca6258d6.0 → 1.0.36-dev.cf7ccf83.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es2024.cjs.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.36-dev.ca6258d6.0
3
- * Tue, 29 Apr 2025 09:02:16 GMT
2
+ * @vkontakte/videoplayer-interactive v1.0.36-dev.cf7ccf83.0
3
+ * Tue, 29 Apr 2025 11:04:39 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,_s=Object.prototype.hasOwnProperty;var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),js=(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))!_s.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 Ai=p((Mh,wi)=>{"use strict";var Us=ke(),xi=Function.prototype,Ti=xi.apply,Ii=xi.call;wi.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((_h,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(_i=>{"use strict";var Ni={}.propertyIsEnumerable,$i=Object.getOwnPropertyDescriptor,Zs=$i&&!Ni.call({1:2},1);_i.f=Zs?function(e){var t=$i(this,e);return!!t&&t.enumerable}:Ni});var nr=p((Bh,ji)=>{"use strict";ji.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(),wl=ar();vn.exports=function(r,e){var t=r[e];return wl(t)?void 0:xl(t)}});var gn=p((id,yn)=>{"use strict";var fr=ht(),vr=q(),br=ve(),Al=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 Al("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(),wn="__core-js_shared__",An=Sn.exports=kl[wn]||Ol(wn,{});(An.versions||(An.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,_l=Math.random(),jl=Nl(1 .toString);Mn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+jl(++$l+_l,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 _n=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,jn)=>{"use strict";var Zl=_n(),Jl=dr();jn.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 wc=ve(),Ac=String,Sc=TypeError;Jn.exports=function(r){if(wc(r))return r;throw new Sc(Ac(r)+" is not an object")}});var io=p(ro=>{"use strict";var Rc=se(),kc=Ir(),Oc=Zn(),bt=eo(),to=Er(),Pc=TypeError,wr=Object.defineProperty,Mc=Object.getOwnPropertyDescriptor,Ar="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:Ar in i?i[Ar]:n[Ar],writable:!1})}return wr(e,t,i)}:wr:function(e,t,i){if(bt(e),t=to(t),bt(i),kc)try{return wr(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=Ai(),$c=tr(),_c=q(),jc=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,A,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=jc(l,v),A=u&&u.value):A=l[v]),b=d&&A?A:e[v],!(!c&&!o&&typeof k==typeof b)&&(r.bind&&d?g=qc(b,Ve):r.wrap&&d?g=Dc(b):o&&_c(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((wd,po)=>{"use strict";var Gc=co();po.exports=function(r){var e=+r;return e!==e||e===0?0:Gc(e)}});var ho=p((Ad,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 _e=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=_e(),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 wo=p((Vd,xo)=>{"use strict";var lp=Io();xo.exports=lp});var Ct=p((Nd,Ao)=>{"use strict";var cp=wo();Ao.exports=cp});var Fo=p(()=>{"use strict";var bp=Ne(),yp=Me(),gp=_e(),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 _o=p((Zm,$o)=>{"use strict";var Ip=No();$o.exports=Ip});var jr=p((Jm,jo)=>{"use strict";var xp=_o();jo.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(),_p=Yo(),Zo=$p("IE_PROTO"),Ur=Object,jp=Ur.prototype;Jo.exports=_p?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?jp: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=_e(),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 ja=p((Iv,_a)=>{"use strict";var mu=$a(),fu=q(),jt=Oe(),vu=Le(),bu=vu("toStringTag"),yu=Object,gu=jt(function(){return arguments}())==="Arguments",Cu=function(r,e){try{return r[e]}catch{}};_a.exports=mu?jt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=Cu(e=yu(r),bu))=="string"?t:gu?jt(e):(i=jt(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((wv,za)=>{"use strict";var xu=H(),wu=B(),Da=q(),Au=ja(),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(Au(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||wu(function(){var r;return Qe(Qe.call)||!Qe(Object)||!Qe(function(){r=!0})||r})?Ga:Qe});var Ya=p((Av,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(),_u=Me(),ju=_e(),Bu=$e(),qu=Ja();Nu({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=_u(this),i=ju(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={};js(th,{ContainerTypes:()=>y.ContainerTypes,ControlTypes:()=>y.ControlTypes,CustomError:()=>L,EVENT_NAMES:()=>w,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:()=>ws,getVKVideoIdByMedia:()=>ti,getVideoRawIdByMedia:()=>Is,graphEventTypes:()=>Ie,hasEndTemplate:()=>Be,interactivesEventTypes:()=>P,isAreaControl:()=>up,isButtonControl:()=>pp,isLastChapter:()=>G,isOneTextCtrlContainer:()=>ce,isSupportedManifest:()=>y.isSupportedManifest,isTextControl:()=>je,isVKVariantItem:()=>xs,isValidManifest:()=>Or,migrateManifestToLatestVersion:()=>y.migrateManifestToLatestVersion,utils:()=>Ms,vkVideoIdsToChapterIds:()=>ri});module.exports=Bs(th);var si="1.0.36-dev.ca6258d6.0";var qe=require("@vkontakte/videoplayer-shared/es2024");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/es2024");function li(r){return"features"in r}var L=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};function 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/es2024");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 we=(r,e)=>it(r)&&(e?r.trim():r).length;function Ae(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=Ae(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=Ae(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=Ae(i.shadowColorLight,i.shadowColorAlpha),a=Ae(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/es2024");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)},je=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)&&je(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=A=>e.find(({container:u})=>u.container.id===A)?.container.isRemoved,i=le(r.events)&&!t(r.id),n=(A,g=!1,u=!1)=>{let h=u?"every":"some";return A.controls[h](f=>{let E=g?A.endTime===r.endTime:!0;return f.events?.[h](T=>T.action?.type===y.EventActionTypes.openURI)&&E})},o=A=>A.some(({container:g})=>n(g.container,!0,!1)&&!g.isRemoved),l=A=>A.every(({container:g})=>g.isRemoved||g.willRemoved?!0:n(g.container,!0,!0)),a=Oo(e,r.endTime,[r.id]).length,s=A=>A.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/es2024");var wt=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 At=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=wt(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 At({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=wt(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 _r(r,e,t)},_r=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(jr(),1),C=require("@vkontakte/videoplayer-shared/es2024"),xe=require("@vkontakte/videoplayer-statistics/es2024");var Ho=require("@vkontakte/videoplayer-shared/es2024");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=wp(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 wp(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/es2024");var Pt=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,t){return Ap(...this.loaders[e])(t)}};function Ap(...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,wf=We?ze:window.AbortController,Af=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),wa=require("@vkontakte/videoplayer-core/es2024"),ie=require("@vkontakte/videoplayer-shared/es2024");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(),_=T.info.isAutoQualityEnabled$.getValue();if(!(!I||!S||_))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,_=!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||(_=!0),e.removePlayer(x[0],F)):(_=!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]);_||(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 _=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||[]},j=new wa.Player(z,ie.Tracer.createRootTracer());j.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(j)),ue={oneStat:Ut,statSubscription:oi})}let ni=new ie.Subscription,Ls=i?.player?.info.isAutoQualityEnabled$.getValue();ni.add(j.events.canplay$.subscribe(function(){Ls||Ke(j,i.player.info.currentQuality$.getValue()),S&&j.setPlaybackRate(S)}));let he=e.createPlayer({listId:g.id,itemId:_,player:j,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 A(){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:A,setInteractiveController:s,createPlayer:v,removeAll:b,getActivePlayer:function(){return i},activePlayerChanged:a}}var w={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/es2024");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 _t=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 A=!s&&!m&&d;A&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:A})}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(w.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(w.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(w.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(w.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=>!je(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&&we(s,!0)){let m={},v=d[s];return v&&(m={...m,...v}),m=oe(m)?null:m,m&&we(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&&we(s,!0))if(r[a][s]){if(c&&we(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))},A=h=>{b(),t=h},g=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),o.remove(h)},u=()=>{n.release(),o.removeAll()};return{setPlayer:A,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:_=()=>!1})=>{let x=ei(u,S()),M={timestamp:1/0,priority:"control",initiator:f,actionType:x.type},F=_(),z=r.emit.bind(r,w.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 j=T.find(ue=>ue.id===x.args.branchId);if(!j)return;I(x.args.isDetachContainer,b.bind(null,{subjectId:f,subjectName:"control"})),z(),ne(),x.args.shouldOpenNow?A({subjectId:f,subjectName:"control",subjectType:h,action:x,payload:{chapterId:j.chapterId,autoSelect:!1}}):i.add({...M,action:A.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:x,payload:{chapterId:j.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 j="Unexpected control event",ue=new L(1,1,{message:j});d(ue,j);return}}},a=({action:u,container:{id:h,endTime:f},branches:E=[],isEOV:T=!1,autoSelected:I=!1})=>{let S=ei(u,T),_={timestamp:!S.args.shouldOpenNow||T?1/0:f??1/0,priority:"container",initiator:h,actionType:S.type},x=r.emit.bind(r,w.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({..._,action:A.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({..._,action:k.bind(null,{subjectId:h,subjectName:"container",action:S})});return}case y.EventActionTypes.openURI.trim().toLowerCase():{x(),M(),i.add({..._,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(w.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,w.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(),A.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(),A.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(),A.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(),A.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(),A.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(w.errors,u)}function m(u){let h=Mr(u.events);if(h){if(G(u))return;r.emit(w.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(w.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(w.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(w.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})},A=({subjectId:u,subjectName:h,subjectType:f,action:E,payload:T})=>{T.behaviour="change-chapter",r.emit(w.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(w.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(jr(),1),D=require("@vkontakte/videoplayer-shared/es2024");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},ws=(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=ws(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(w.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(w.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(w.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(w.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 Fs=Object.create;var et=Object.defineProperty;var Vs=Object.getOwnPropertyDescriptor;var Ns=Object.getOwnPropertyNames;var $s=Object.getPrototypeOf,_s=Object.prototype.hasOwnProperty;var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),js=(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))!_s.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((_h,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(_i=>{"use strict";var Ni={}.propertyIsEnumerable,$i=Object.getOwnPropertyDescriptor,Zs=$i&&!Ni.call({1:2},1);_i.f=Zs?function(e){var t=$i(this,e);return!!t&&t.enumerable}:Ni});var nr=p((Bh,ji)=>{"use strict";ji.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,_l=Math.random(),jl=Nl(1 .toString);Mn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+jl(++$l+_l,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 _n=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,jn)=>{"use strict";var Zl=_n(),Jl=dr();jn.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(),_c=q(),jc=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=jc(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&&_c(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 _e=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=_e(),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=_e(),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 _o=p((Zm,$o)=>{"use strict";var Ip=No();$o.exports=Ip});var jr=p((Jm,jo)=>{"use strict";var xp=_o();jo.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(),_p=Yo(),Zo=$p("IE_PROTO"),Ur=Object,jp=Ur.prototype;Jo.exports=_p?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?jp: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=_e(),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 ja=p((Iv,_a)=>{"use strict";var mu=$a(),fu=q(),jt=Oe(),vu=Le(),bu=vu("toStringTag"),yu=Object,gu=jt(function(){return arguments}())==="Arguments",Cu=function(r,e){try{return r[e]}catch{}};_a.exports=mu?jt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=Cu(e=yu(r),bu))=="string"?t:gu?jt(e):(i=jt(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=ja(),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(),_u=Me(),ju=_e(),Bu=$e(),qu=Ja();Nu({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=_u(this),i=ju(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={};js(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:()=>je,isVKVariantItem:()=>xs,isValidManifest:()=>Or,migrateManifestToLatestVersion:()=>y.migrateManifestToLatestVersion,utils:()=>Ms,vkVideoIdsToChapterIds:()=>ri});module.exports=Bs(th);var si="1.0.36-dev.cf7ccf83.0";var qe=require("@vkontakte/videoplayer-shared/es2024");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/es2024");function li(r){return"features"in r}var L=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};function 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/es2024");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/es2024");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)},je=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)&&je(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/es2024");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 _r(r,e,t)},_r=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(jr(),1),C=require("@vkontakte/videoplayer-shared/es2024"),xe=require("@vkontakte/videoplayer-statistics/es2024");var Ho=require("@vkontakte/videoplayer-shared/es2024");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/es2024");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/es2024"),ie=require("@vkontakte/videoplayer-shared/es2024");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(),_=T.info.isAutoQualityEnabled$.getValue();if(!(!I||!S||_))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,_=!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||(_=!0),e.removePlayer(x[0],F)):(_=!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]);_||(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 _=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||[]},j=new Aa.Player(z,ie.Tracer.createRootTracer());j.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(j)),ue={oneStat:Ut,statSubscription:oi})}let ni=new ie.Subscription,Ls=i?.player?.info.isAutoQualityEnabled$.getValue();ni.add(j.events.canplay$.subscribe(function(){Ls||Ke(j,i.player.info.currentQuality$.getValue()),S&&j.setPlaybackRate(S)}));let he=e.createPlayer({listId:g.id,itemId:_,player:j,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/es2024");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 _t=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=>!je(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:_=()=>!1})=>{let x=ei(u,S()),M={timestamp:1/0,priority:"control",initiator:f,actionType:x.type},F=_(),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 j=T.find(ue=>ue.id===x.args.branchId);if(!j)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:j.chapterId,autoSelect:!1}}):i.add({...M,action:w.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:x,payload:{chapterId:j.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 j="Unexpected control event",ue=new L(1,1,{message:j});d(ue,j);return}}},a=({action:u,container:{id:h,endTime:f},branches:E=[],isEOV:T=!1,autoSelected:I=!1})=>{let S=ei(u,T),_={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({..._,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({..._,action:k.bind(null,{subjectId:h,subjectName:"container",action:S})});return}case y.EventActionTypes.openURI.trim().toLowerCase():{x(),M(),i.add({..._,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(jr(),1),D=require("@vkontakte/videoplayer-shared/es2024");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=`
7
7
  position: absolute;
8
8
  top: 0;
9
9
  left: 0;
@@ -16,7 +16,7 @@
16
16
  top: 50%;
17
17
  left: 50%;
18
18
  transform: translate(-50%, -50%);
19
- `,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),i={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(i,e)}catch(n){this._onError(n)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>t.controls?.length&&e>=(t.startTime??0)&&e<=Math.min(t.endTime??1/0,this.currentVideoDurationMs-this.endOffsetMs))}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){this._callbacks?.onError?.(e)}};function As(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var 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),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 */
20
20
  .interactive-container {
21
21
  opacity: 1;
22
22
  visibility: visible;
@@ -163,7 +163,7 @@
163
163
  border: none;
164
164
  }
165
165
 
166
- .interactive-control-disabled {
166
+ .interactive-control.interactive-control-disabled {
167
167
  cursor: default;
168
168
  }
169
169
 
@@ -282,4 +282,4 @@
282
282
  .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-bottom {
283
283
  transform-origin: bottom;
284
284
  }
285
- `;var Rs=r=>{let e=document.createElement("style");e.textContent=Ss,r.prepend(e)};var Ps=require("@vkontakte/videoplayer-core/es2024");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}});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(w.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(w.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(w.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(w.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 _t({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(w.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 As(35);let n=!i&&this.state.isEndChapter$.getValue()&&this.getCurrentManifest()?.metadata.initChapterId===e;this.state.isReplay$.next(n);let{chapter:o,media:l,graph:a}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||n)&&this.state.isFirstChapter$.next(!0),!(!o||!l)&&(t&&this.pushChapterToHistory(o.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(o),this.lastFrame?.setCurrentChapter(o),this.events.chapterChanged$.next({chapter:o,manifestVideo:l}),this.globalEventEmitter.emit(w.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(w.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};
285
+ `;var Rs=r=>{let e=document.createElement("style");e.textContent=Ss,r.prepend(e)};var Ps=require("@vkontakte/videoplayer-core/es2024");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 _t({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};