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