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