@vkontakte/videoplayer-interactive 1.0.34-dev.15990b7d.0 → 1.0.34-dev.3bb5d797.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/esnext.cjs.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.34-dev.15990b7d.0
3
- * Thu, 20 Mar 2025 09:05:59 GMT
2
+ * @vkontakte/videoplayer-interactive v1.0.34-dev.3bb5d797.0
3
+ * Wed, 26 Mar 2025 00:47:16 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-34/doc/
5
5
  */
6
- "use strict";var pa=Object.create;var Ue=Object.defineProperty;var ua=Object.getOwnPropertyDescriptor;var ha=Object.getOwnPropertyNames;var da=Object.getPrototypeOf,ma=Object.prototype.hasOwnProperty;var u=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),fa=(t,e)=>{for(var r in e)Ue(t,r,{get:e[r],enumerable:!0})},qr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ha(e))!ma.call(t,i)&&i!==r&&Ue(t,i,{get:()=>e[i],enumerable:!(n=ua(e,i))||n.enumerable});return t};var z=(t,e,r)=>(r=t!=null?pa(da(t)):{},qr(e||!t||!t.__esModule?Ue(r,"default",{value:t,enumerable:!0}):r,t)),va=t=>qr(Ue({},"__esModule",{value:!0}),t);var W=u((_t,Qr)=>{"use strict";var be=function(t){return t&&t.Math===Math&&t};Qr.exports=be(typeof globalThis=="object"&&globalThis)||be(typeof window=="object"&&window)||be(typeof self=="object"&&self)||be(typeof global=="object"&&global)||be(typeof _t=="object"&&_t)||function(){return this}()||Function("return this")()});var $=u((Ah,Xr)=>{"use strict";Xr.exports=function(t){try{return!!t()}catch{return!0}}});var Ce=u((Rh,Yr)=>{"use strict";var ya=$();Yr.exports=!ya(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")})});var rn=u((Oh,tn)=>{"use strict";var ba=Ce(),en=Function.prototype,Zr=en.apply,Jr=en.call;tn.exports=typeof Reflect=="object"&&Reflect.apply||(ba?Jr.bind(Zr):function(){return Jr.apply(Zr,arguments)})});var H=u((kh,on)=>{"use strict";var nn=Ce(),sn=Function.prototype,Ft=sn.call,Ca=nn&&sn.bind.bind(Ft,Ft);on.exports=nn?Ca:function(t){return function(){return Ft.apply(t,arguments)}}});var ge=u((Ph,cn)=>{"use strict";var an=H(),ga=an({}.toString),Ea=an("".slice);cn.exports=function(t){return Ea(ga(t),8,-1)}});var qt=u((Vh,ln)=>{"use strict";var Ia=ge(),Ta=H();ln.exports=function(t){if(Ia(t)==="Function")return Ta(t)}});var _=u((Mh,pn)=>{"use strict";var Bt=typeof document=="object"&&document.all;pn.exports=typeof Bt>"u"&&Bt!==void 0?function(t){return typeof t=="function"||t===Bt}:function(t){return typeof t=="function"}});var Z=u((Nh,un)=>{"use strict";var xa=$();un.exports=!xa(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var tt=u((Lh,hn)=>{"use strict";var Sa=Ce(),et=Function.prototype.call;hn.exports=Sa?et.bind(et):function(){return et.apply(et,arguments)}});var Dt=u(fn=>{"use strict";var dn={}.propertyIsEnumerable,mn=Object.getOwnPropertyDescriptor,wa=mn&&!dn.call({1:2},1);fn.f=wa?function(e){var r=mn(this,e);return!!r&&r.enumerable}:dn});var Ht=u(($h,vn)=>{"use strict";vn.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}});var bn=u((_h,yn)=>{"use strict";var Aa=H(),Ra=$(),Oa=ge(),Ut=Object,ka=Aa("".split);yn.exports=Ra(function(){return!Ut("z").propertyIsEnumerable(0)})?function(t){return Oa(t)==="String"?ka(t,""):Ut(t)}:Ut});var Gt=u((Fh,Cn)=>{"use strict";Cn.exports=function(t){return t==null}});var zt=u((qh,gn)=>{"use strict";var Pa=Gt(),Va=TypeError;gn.exports=function(t){if(Pa(t))throw new Va("Can't call method on "+t);return t}});var Ee=u((Bh,En)=>{"use strict";var Ma=bn(),Na=zt();En.exports=function(t){return Ma(Na(t))}});var le=u((Dh,In)=>{"use strict";var La=_();In.exports=function(t){return typeof t=="object"?t!==null:La(t)}});var rt=u((Hh,Tn)=>{"use strict";Tn.exports={}});var nt=u((Uh,Sn)=>{"use strict";var Wt=rt(),Kt=W(),ja=_(),xn=function(t){return ja(t)?t:void 0};Sn.exports=function(t,e){return arguments.length<2?xn(Wt[t])||xn(Kt[t]):Wt[t]&&Wt[t][e]||Kt[t]&&Kt[t][e]}});var An=u((Gh,wn)=>{"use strict";var $a=H();wn.exports=$a({}.isPrototypeOf)});var Pn=u((zh,kn)=>{"use strict";var _a=W(),Rn=_a.navigator,On=Rn&&Rn.userAgent;kn.exports=On?String(On):""});var _n=u((Wh,$n)=>{"use strict";var jn=W(),Qt=Pn(),Vn=jn.process,Mn=jn.Deno,Nn=Vn&&Vn.versions||Mn&&Mn.version,Ln=Nn&&Nn.v8,U,it;Ln&&(U=Ln.split("."),it=U[0]>0&&U[0]<4?1:+(U[0]+U[1]));!it&&Qt&&(U=Qt.match(/Edge\/(\d+)/),(!U||U[1]>=74)&&(U=Qt.match(/Chrome\/(\d+)/),U&&(it=+U[1])));$n.exports=it});var Xt=u((Kh,qn)=>{"use strict";var Fn=_n(),Fa=$(),qa=W(),Ba=qa.String;qn.exports=!!Object.getOwnPropertySymbols&&!Fa(function(){var t=Symbol("symbol detection");return!Ba(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&Fn&&Fn<41})});var Yt=u((Qh,Bn)=>{"use strict";var Da=Xt();Bn.exports=Da&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Zt=u((Xh,Dn)=>{"use strict";var Ha=nt(),Ua=_(),Ga=An(),za=Yt(),Wa=Object;Dn.exports=za?function(t){return typeof t=="symbol"}:function(t){var e=Ha("Symbol");return Ua(e)&&Ga(e.prototype,Wa(t))}});var Un=u((Yh,Hn)=>{"use strict";var Ka=String;Hn.exports=function(t){try{return Ka(t)}catch{return"Object"}}});var Jt=u((Zh,Gn)=>{"use strict";var Qa=_(),Xa=Un(),Ya=TypeError;Gn.exports=function(t){if(Qa(t))return t;throw new Ya(Xa(t)+" is not a function")}});var Wn=u((Jh,zn)=>{"use strict";var Za=Jt(),Ja=Gt();zn.exports=function(t,e){var r=t[e];return Ja(r)?void 0:Za(r)}});var Qn=u((ed,Kn)=>{"use strict";var er=tt(),tr=_(),rr=le(),ec=TypeError;Kn.exports=function(t,e){var r,n;if(e==="string"&&tr(r=t.toString)&&!rr(n=er(r,t))||tr(r=t.valueOf)&&!rr(n=er(r,t))||e!=="string"&&tr(r=t.toString)&&!rr(n=er(r,t)))return n;throw new ec("Can't convert object to primitive value")}});var Yn=u((td,Xn)=>{"use strict";Xn.exports=!0});var ei=u((rd,Jn)=>{"use strict";var Zn=W(),tc=Object.defineProperty;Jn.exports=function(t,e){try{tc(Zn,t,{value:e,configurable:!0,writable:!0})}catch{Zn[t]=e}return e}});var st=u((nd,ni)=>{"use strict";var rc=Yn(),nc=W(),ic=ei(),ti="__core-js_shared__",ri=ni.exports=nc[ti]||ic(ti,{});(ri.versions||(ri.versions=[])).push({version:"3.38.0",mode:rc?"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 nr=u((id,si)=>{"use strict";var ii=st();si.exports=function(t,e){return ii[t]||(ii[t]=e||{})}});var Ie=u((sd,oi)=>{"use strict";var sc=zt(),oc=Object;oi.exports=function(t){return oc(sc(t))}});var pe=u((od,ai)=>{"use strict";var ac=H(),cc=Ie(),lc=ac({}.hasOwnProperty);ai.exports=Object.hasOwn||function(e,r){return lc(cc(e),r)}});var ir=u((ad,ci)=>{"use strict";var pc=H(),uc=0,hc=Math.random(),dc=pc(1 .toString);ci.exports=function(t){return"Symbol("+(t===void 0?"":t)+")_"+dc(++uc+hc,36)}});var Te=u((cd,pi)=>{"use strict";var mc=W(),fc=nr(),li=pe(),vc=ir(),yc=Xt(),bc=Yt(),ue=mc.Symbol,sr=fc("wks"),Cc=bc?ue.for||ue:ue&&ue.withoutSetter||vc;pi.exports=function(t){return li(sr,t)||(sr[t]=yc&&li(ue,t)?ue[t]:Cc("Symbol."+t)),sr[t]}});var mi=u((ld,di)=>{"use strict";var gc=tt(),ui=le(),hi=Zt(),Ec=Wn(),Ic=Qn(),Tc=Te(),xc=TypeError,Sc=Tc("toPrimitive");di.exports=function(t,e){if(!ui(t)||hi(t))return t;var r=Ec(t,Sc),n;if(r){if(e===void 0&&(e="default"),n=gc(r,t,e),!ui(n)||hi(n))return n;throw new xc("Can't convert object to primitive value")}return e===void 0&&(e="number"),Ic(t,e)}});var or=u((pd,fi)=>{"use strict";var wc=mi(),Ac=Zt();fi.exports=function(t){var e=wc(t,"string");return Ac(e)?e:e+""}});var bi=u((ud,yi)=>{"use strict";var Rc=W(),vi=le(),ar=Rc.document,Oc=vi(ar)&&vi(ar.createElement);yi.exports=function(t){return Oc?ar.createElement(t):{}}});var cr=u((hd,Ci)=>{"use strict";var kc=Z(),Pc=$(),Vc=bi();Ci.exports=!kc&&!Pc(function(){return Object.defineProperty(Vc("div"),"a",{get:function(){return 7}}).a!==7})});var Ii=u(Ei=>{"use strict";var Mc=Z(),Nc=tt(),Lc=Dt(),jc=Ht(),$c=Ee(),_c=or(),Fc=pe(),qc=cr(),gi=Object.getOwnPropertyDescriptor;Ei.f=Mc?gi:function(e,r){if(e=$c(e),r=_c(r),qc)try{return gi(e,r)}catch{}if(Fc(e,r))return jc(!Nc(Lc.f,e,r),e[r])}});var xi=u((md,Ti)=>{"use strict";var Bc=$(),Dc=_(),Hc=/#|\.prototype\./,xe=function(t,e){var r=Gc[Uc(t)];return r===Wc?!0:r===zc?!1:Dc(e)?Bc(e):!!e},Uc=xe.normalize=function(t){return String(t).replace(Hc,".").toLowerCase()},Gc=xe.data={},zc=xe.NATIVE="N",Wc=xe.POLYFILL="P";Ti.exports=xe});var lr=u((fd,wi)=>{"use strict";var Si=qt(),Kc=Jt(),Qc=Ce(),Xc=Si(Si.bind);wi.exports=function(t,e){return Kc(t),e===void 0?t:Qc?Xc(t,e):function(){return t.apply(e,arguments)}}});var Ri=u((vd,Ai)=>{"use strict";var Yc=Z(),Zc=$();Ai.exports=Yc&&Zc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var ki=u((yd,Oi)=>{"use strict";var Jc=le(),el=String,tl=TypeError;Oi.exports=function(t){if(Jc(t))return t;throw new tl(el(t)+" is not an object")}});var Mi=u(Vi=>{"use strict";var rl=Z(),nl=cr(),il=Ri(),ot=ki(),Pi=or(),sl=TypeError,pr=Object.defineProperty,ol=Object.getOwnPropertyDescriptor,ur="enumerable",hr="configurable",dr="writable";Vi.f=rl?il?function(e,r,n){if(ot(e),r=Pi(r),ot(n),typeof e=="function"&&r==="prototype"&&"value"in n&&dr in n&&!n[dr]){var i=ol(e,r);i&&i[dr]&&(e[r]=n.value,n={configurable:hr in n?n[hr]:i[hr],enumerable:ur in n?n[ur]:i[ur],writable:!1})}return pr(e,r,n)}:pr:function(e,r,n){if(ot(e),r=Pi(r),ot(n),nl)try{return pr(e,r,n)}catch{}if("get"in n||"set"in n)throw new sl("Accessors not supported");return"value"in n&&(e[r]=n.value),e}});var Li=u((Cd,Ni)=>{"use strict";var al=Z(),cl=Mi(),ll=Ht();Ni.exports=al?function(t,e,r){return cl.f(t,e,ll(1,r))}:function(t,e,r){return t[e]=r,t}});var we=u((gd,$i)=>{"use strict";var Se=W(),pl=rn(),ul=qt(),hl=_(),dl=Ii().f,ml=xi(),he=rt(),fl=lr(),de=Li(),ji=pe();st();var vl=function(t){var e=function(r,n,i){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,n)}return new t(r,n,i)}return pl(t,this,arguments)};return e.prototype=t.prototype,e};$i.exports=function(t,e){var r=t.target,n=t.global,i=t.stat,s=t.proto,c=n?Se:i?Se[r]:Se[r]&&Se[r].prototype,o=n?he:he[r]||de(he,r,{})[r],a=o.prototype,l,d,m,f,b,k,T,E,x;for(f in e)l=ml(n?f:r+(i?".":"#")+f,t.forced),d=!l&&c&&ji(c,f),k=o[f],d&&(t.dontCallGetSet?(x=dl(c,f),T=x&&x.value):T=c[f]),b=d&&T?T:e[f],!(!l&&!s&&typeof k==typeof b)&&(t.bind&&d?E=fl(b,Se):t.wrap&&d?E=vl(b):s&&hl(b)?E=ul(b):E=b,(t.sham||b&&b.sham||k&&k.sham)&&de(E,"sham",!0),de(o,f,E),s&&(m=r+"Prototype",ji(he,m)||de(he,m,{}),de(he[m],f,b),t.real&&a&&(l||!a[f])&&de(a,f,b)))}});var Fi=u((Ed,_i)=>{"use strict";var yl=Math.ceil,bl=Math.floor;_i.exports=Math.trunc||function(e){var r=+e;return(r>0?bl:yl)(r)}});var Ae=u((Id,qi)=>{"use strict";var Cl=Fi();qi.exports=function(t){var e=+t;return e!==e||e===0?0:Cl(e)}});var Di=u((Td,Bi)=>{"use strict";var gl=Ae(),El=Math.min;Bi.exports=function(t){var e=gl(t);return e>0?El(e,9007199254740991):0}});var Re=u((xd,Hi)=>{"use strict";var Il=Di();Hi.exports=function(t){return Il(t.length)}});var at=u((Sd,Ui)=>{"use strict";Ui.exports=function(){}});var Gi=u(()=>{"use strict";var Tl=we(),xl=Ie(),Sl=Re(),wl=Ae(),Al=at();Tl({target:"Array",proto:!0},{at:function(e){var r=xl(this),n=Sl(r),i=wl(e),s=i>=0?i:n+i;return s<0||s>=n?void 0:r[s]}});Al("at")});var ct=u((Rd,zi)=>{"use strict";var Rl=nt();zi.exports=Rl});var Ki=u((Od,Wi)=>{"use strict";Gi();var Ol=ct();Wi.exports=Ol("Array","at")});var Xi=u((kd,Qi)=>{"use strict";var kl=Ki();Qi.exports=kl});var mr=u((Pd,Yi)=>{"use strict";var Pl=Xi();Yi.exports=Pl});var hs=u((Pm,us)=>{"use strict";var Ul=nr(),Gl=ir(),ps=Ul("keys");us.exports=function(t){return ps[t]||(ps[t]=Gl(t))}});var ms=u((Vm,ds)=>{"use strict";var zl=$();ds.exports=!zl(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})});var ys=u((Mm,vs)=>{"use strict";var Wl=pe(),Kl=_(),Ql=Ie(),Xl=hs(),Yl=ms(),fs=Xl("IE_PROTO"),Sr=Object,Zl=Sr.prototype;vs.exports=Yl?Sr.getPrototypeOf:function(t){var e=Ql(t);if(Wl(e,fs))return e[fs];var r=e.constructor;return Kl(r)&&e instanceof r?r.prototype:e instanceof Sr?Zl:null}});var Cs=u((Nm,bs)=>{"use strict";var Jl=Ae(),ep=Math.max,tp=Math.min;bs.exports=function(t,e){var r=Jl(t);return r<0?ep(r+e,0):tp(r,e)}});var wr=u((Lm,Es)=>{"use strict";var rp=Ee(),np=Cs(),ip=Re(),gs=function(t){return function(e,r,n){var i=rp(e),s=ip(i);if(s===0)return!t&&-1;var c=np(n,s),o;if(t&&r!==r){for(;s>c;)if(o=i[c++],o!==o)return!0}else for(;s>c;c++)if((t||c in i)&&i[c]===r)return t||c||0;return!t&&-1}};Es.exports={includes:gs(!0),indexOf:gs(!1)}});var Ts=u((jm,Is)=>{"use strict";Is.exports={}});var ws=u(($m,Ss)=>{"use strict";var sp=H(),Ar=pe(),op=Ee(),ap=wr().indexOf,cp=Ts(),xs=sp([].push);Ss.exports=function(t,e){var r=op(t),n=0,i=[],s;for(s in r)!Ar(cp,s)&&Ar(r,s)&&xs(i,s);for(;e.length>n;)Ar(r,s=e[n++])&&(~ap(i,s)||xs(i,s));return i}});var Rs=u((_m,As)=>{"use strict";As.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var ks=u((Fm,Os)=>{"use strict";var lp=ws(),pp=Rs();Os.exports=Object.keys||function(e){return lp(e,pp)}});var js=u((qm,Ls)=>{"use strict";var Vs=Z(),up=$(),Ms=H(),hp=ys(),dp=ks(),mp=Ee(),fp=Dt().f,Ns=Ms(fp),vp=Ms([].push),yp=Vs&&up(function(){var t=Object.create(null);return t[2]=2,!Ns(t,2)}),Ps=function(t){return function(e){for(var r=mp(e),n=dp(r),i=yp&&hp(r)===null,s=n.length,c=0,o=[],a;s>c;)a=n[c++],(!Vs||(i?a in r:Ns(r,a)))&&vp(o,t?[a,r[a]]:r[a]);return o}};Ls.exports={entries:Ps(!0),values:Ps(!1)}});var $s=u(()=>{"use strict";var bp=we(),Cp=js().values;bp({target:"Object",stat:!0},{values:function(e){return Cp(e)}})});var Fs=u((Hm,_s)=>{"use strict";$s();var gp=rt();_s.exports=gp.Object.values});var Bs=u((Um,qs)=>{"use strict";var Ep=Fs();qs.exports=Ep});var Et=u((Gm,Ds)=>{"use strict";var Ip=Bs();Ds.exports=Ip});var Gs=u(()=>{"use strict";var Tp=we(),xp=wr().includes,Sp=$(),wp=at(),Ap=Sp(function(){return!Array(1).includes()});Tp({target:"Array",proto:!0,forced:Ap},{includes:function(e){return xp(this,e,arguments.length>1?arguments[1]:void 0)}});wp("includes")});var Ws=u((Xm,zs)=>{"use strict";Gs();var Rp=ct();zs.exports=Rp("Array","includes")});var Qs=u((Ym,Ks)=>{"use strict";var Op=Ws();Ks.exports=Op});var It=u((Zm,Xs)=>{"use strict";var kp=Qs();Xs.exports=kp});var Pr=u((mf,no)=>{"use strict";var Vp=ge();no.exports=Array.isArray||function(e){return Vp(e)==="Array"}});var so=u((ff,io)=>{"use strict";var Mp=TypeError,Np=9007199254740991;io.exports=function(t){if(t>Np)throw Mp("Maximum allowed index exceeded");return t}});var co=u((vf,ao)=>{"use strict";var Lp=Pr(),jp=Re(),$p=so(),_p=lr(),oo=function(t,e,r,n,i,s,c,o){for(var a=i,l=0,d=c?_p(c,o):!1,m,f;l<n;)l in r&&(m=d?d(r[l],l,e):r[l],s>0&&Lp(m)?(f=jp(m),a=oo(t,e,m,f,a,s-1)-1):($p(a+1),t[a]=m),a++),l++;return a};ao.exports=oo});var uo=u((yf,po)=>{"use strict";var Fp=Te(),qp=Fp("toStringTag"),lo={};lo[qp]="z";po.exports=String(lo)==="[object z]"});var mo=u((bf,ho)=>{"use strict";var Bp=uo(),Dp=_(),xt=ge(),Hp=Te(),Up=Hp("toStringTag"),Gp=Object,zp=xt(function(){return arguments}())==="Arguments",Wp=function(t,e){try{return t[e]}catch{}};ho.exports=Bp?xt:function(t){var e,r,n;return t===void 0?"Undefined":t===null?"Null":typeof(r=Wp(e=Gp(t),Up))=="string"?r:zp?xt(e):(n=xt(e))==="Object"&&Dp(e.callee)?"Arguments":n}});var vo=u((Cf,fo)=>{"use strict";var Kp=H(),Qp=_(),Vr=st(),Xp=Kp(Function.toString);Qp(Vr.inspectSource)||(Vr.inspectSource=function(t){return Xp(t)});fo.exports=Vr.inspectSource});var Io=u((gf,Eo)=>{"use strict";var Yp=H(),Zp=$(),yo=_(),Jp=mo(),eu=nt(),tu=vo(),bo=function(){},Co=eu("Reflect","construct"),Mr=/^\s*(?:class|function)\b/,ru=Yp(Mr.exec),nu=!Mr.test(bo),qe=function(e){if(!yo(e))return!1;try{return Co(bo,[],e),!0}catch{return!1}},go=function(e){if(!yo(e))return!1;switch(Jp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return nu||!!ru(Mr,tu(e))}catch{return!0}};go.sham=!0;Eo.exports=!Co||Zp(function(){var t;return qe(qe.call)||!qe(Object)||!qe(function(){t=!0})||t})?go:qe});var wo=u((Ef,So)=>{"use strict";var To=Pr(),iu=Io(),su=le(),ou=Te(),au=ou("species"),xo=Array;So.exports=function(t){var e;return To(t)&&(e=t.constructor,iu(e)&&(e===xo||To(e.prototype))?e=void 0:su(e)&&(e=e[au],e===null&&(e=void 0))),e===void 0?xo:e}});var Ro=u((If,Ao)=>{"use strict";var cu=wo();Ao.exports=function(t,e){return new(cu(t))(e===0?0:e)}});var Oo=u(()=>{"use strict";var lu=we(),pu=co(),uu=Ie(),hu=Re(),du=Ae(),mu=Ro();lu({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,r=uu(this),n=hu(r),i=mu(r,0);return i.length=pu(i,r,r,n,0,e===void 0?1:du(e)),i}})});var ko=u(()=>{"use strict";var fu=at();fu("flat")});var Vo=u((Af,Po)=>{"use strict";Oo();ko();var vu=ct();Po.exports=vu("Array","flat")});var No=u((Rf,Mo)=>{"use strict";var yu=Vo();Mo.exports=yu});var jo=u((Of,Lo)=>{"use strict";var bu=No();Lo.exports=bu});var Ou={};fa(Ou,{ContainerTypes:()=>y.ContainerTypes,ControlTypes:()=>y.ControlTypes,CustomError:()=>M,EVENT_NAMES:()=>w,EventActionTypes:()=>y.EventActionTypes,EventTypes:()=>y.EventTypes,Interactives:()=>De,ManifestController:()=>ne,SDKInfo:()=>Ru,chapterIdsToVKVideoIds:()=>wt,compareVersions:()=>bt,containerTypes:()=>Ll,controlTypes:()=>jl,eventActionTypes:()=>br,eventTypes:()=>$l,getChapterIdByVkVideoId:()=>ra,getVKVideoIdByMedia:()=>jr,getVideoRawIdByMedia:()=>ea,graphEventTypes:()=>ve,hasEndTemplate:()=>_e,interactivesEventTypes:()=>O,isAreaControl:()=>Nl,isButtonControl:()=>Ml,isLastChapter:()=>G,isOneTextCtrlContainer:()=>re,isSupportedManifest:()=>y.isSupportedManifest,isTextControl:()=>Ne,isVKVariantItem:()=>ta,isValidManifest:()=>yr,migrateManifestToLatestVersion:()=>y.migrateManifestToLatestVersion,utils:()=>ca,vkVideoIdsToChapterIds:()=>$r});module.exports=va(Ou);var Br="1.0.34-dev.15990b7d.0";var kt=class{constructor(e){this.layout=e}},Ge=class extends kt{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,r){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${r.width})`,e.style.height=`calc(var(--interactive-content-height) * ${r.height})`,e.style.left=`calc(var(--interactive-content-width) * ${r.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${r.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};function Dr(t){return"features"in t}var oe=class{constructor(e,r){this.container=e,this.options=r,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&Dr(this.options)&&this.options.features[e]}addControlFactory(e,r){this.factories.set(e.trim().toLowerCase(),r),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){return this.container.controls?.reduce((e,r)=>{let n=r.type.trim().toLowerCase(),i=this.factories.get(n);if(i){let s=i(r,this.options);if(s)return[...e,s]}return[...e]},[])||[]}};function Pt(t,e=1){let r="0",n="0",i="0";return t.length===4?(r="0x"+t[1]+t[1],n="0x"+t[2]+t[2],i="0x"+t[3]+t[3]):t.length===7&&(r="0x"+t[1]+t[2],n="0x"+t[3]+t[4],i="0x"+t[5]+t[6]),`rgba(${+r},${+n},${+i},${e})`}var Hr="interactive",L={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},Ur=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(Ur||{}),Gr=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(Gr||{}),zr=(n=>(n.start="left",n.end="right",n.center="center",n))(zr||{}),ze=({target:t,props:e})=>{t.style.alignItems=(e?.gravityVertical&&Ur[e.gravityVertical])??"center",t.style.justifyContent=(e?.gravityHorizontal&&Gr[e.gravityHorizontal])??"center",t.style.textAlign=(e?.alignment&&zr[e.alignment])??"center"},We=({target:t,props:e,fallback:r,dependsOn:n})=>{t.style.color=e?.text?.color??r.textColor,t.style.fontSize=`calc(${n.height} * ${e?.text?.size??r.textSize})`,t.textContent=e?.text?.value??r.textContent},Ke=({target:t,props:e,fallback:r})=>{t.style.backgroundColor=Pt(e?.background?.color??r.backgroundColor,e?.background?.alpha??r.backgroundAlpha)},Qe=({target:t,props:e,fallback:r,dependsOn:n})=>{t.style.border=`calc(${n.height} * ${e?.shape?.border?.width??r.borderWidth}) solid ${Pt(e?.shape?.border?.color??r.borderColor,e?.shape?.border?.alpha??r.borderAlpha)}`,t.style.borderRadius=`calc(${n.height} * ${e?.shape?.roundCorners??r.roundCorners})`},ae=({target:t,layoutParams:e,fallback:r})=>{let n=e.angle??r.angle;n=n&&n*-1,t.style.transform=`rotate(${n}rad)`};var Vt="int",Y=(n=>(n.AREA=`${Vt}_area`,n.TEXT=`${Vt}_text`,n.BUTTON=`${Vt}_bttn`,n))(Y||{});function Wr(t){return"features"in t}var ce="interactive-control",P={common:ce,wrapper:`${ce}-wrapper`,disabled:`${ce}-disabled`,button:`${ce}-button`,area:`${ce}-area`,text:`${ce}-text`};var Q=class{constructor(e,r){this.control=e;this.options=r;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){let r=document.createElement("div");r.classList.add(P.wrapper),e.setControlLayout(r,this.control.layoutParams);let n=(this.control.layoutParams.innerSizesDependOn??L.innerSizesDependOn)==="self"?{height:r.style.height,width:r.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:r,dimensions:n}}createClickListener(e){return r=>{r.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&Wr(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(r=>{switch(r.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:r.action,controlId:this.control.id,controlType:this.control.type})),this.container?.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){this.container?.element&&this.clickListener&&this.container?.element.removeEventListener("click",this.clickListener)}};var Xe=(t,e)=>{if(t.type.trim().toLowerCase()==="area")return new Mt(t,e)},Mt=class extends Q{constructor(e,r){super(e,r)}createView({parentElement:e,callbacks:r}){if(super.createContainerElement(r),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(P.common,P.area),n.setAttribute("data-testid",Y.AREA),Ke({target:n,props:this.control.props,fallback:{...L,backgroundColor:"transparent"}}),Qe({target:n,props:this.control.props,fallback:{...L,borderAlpha:0},dependsOn:this.container.dimensions}),ae({target:n,layoutParams:this.control.layoutParams,fallback:L}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(P.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(P.disabled)}getElement(){return this.controlElement}onProgress(){}onResize(){}};var Ye=t=>{let e=document.createElement("span");switch(t){case"Button":case"button":{let r=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(r.style,n),r.append(e);let i={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,i),r}default:{let r={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,r),e}}};var Ze=(t,e)=>{if(t.type.trim().toLowerCase()==="button")return new Nt(t,e)},Nt=class extends Q{constructor(e,r){super(e,r)}createView({parentElement:e,callbacks:r}){if(super.createContainerElement(r),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(P.common,P.button),n.setAttribute("data-testid",Y.BUTTON),ae({target:n,layoutParams:this.control.layoutParams,fallback:L}),Ke({target:n,props:this.control.props,fallback:L}),Qe({target:n,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),ze({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=Ye(this.control.type.trim().toLowerCase()),s=i.firstElementChild??i;We({target:s,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(P.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(P.disabled)}getElement(){return this.controlElement}onProgress(){}onResize(){}};var Kr=(t,e)=>{if(t.type.trim().toLowerCase()==="text")return new Lt(t,e)},Lt=class extends Q{constructor(e,r){super(e,r)}createView({parentElement:e,callbacks:r}){if(super.createContainerElement(r),!this.container)return;let n=document.createElement("div");n.classList.add(P.common,P.text),n.setAttribute("data-testid",Y.TEXT),ae({target:n,layoutParams:this.control.layoutParams,fallback:L}),ze({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=Ye(this.control.type.trim().toLowerCase()),s=i.firstElementChild??i;We({target:s,props:this.control.props,fallback:L,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(){}};var jt="interactive-container",j={common:jt,hidden:`${jt}-hidden`,disabled:`${jt}-disabled`};var Je=(t,e,r)=>{if(t.type.trim().toLowerCase()==="choice")return new $t(t,e,r)},$t=class extends oe{constructor(r,n,i){super(r,i);this.containerElement=null;this.rootElement=n,this.layout=new Ge(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Ze),this.addControlFactory("text",Kr),this.addControlFactory("area",Xe)}createView({eventCallback:r}){let n=document.createElement("div");return n.classList.add(j.common,j.disabled),requestAnimationFrame(()=>{n.classList.remove(j.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(i=>{i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),i.setEvents(r)}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let r=this.getElement();r&&r.classList.add(j.hidden)}show(){let r=this.getElement();r&&r.classList.remove(j.hidden)}enable(){let r=this.getElement();r&&(r.classList.remove(j.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let r=this.getElement();r&&(r.classList.add(j.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let r=this.getElement();r&&(this.controls.forEach(n=>n.removeListeners()),r.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(r,n){n&&this.controls.forEach(i=>{i.onProgress(r)})}onResize(r){r&&this.controls.forEach(n=>{n.onResize()})}};var oa=z(mr(),1),g=require("@vkontakte/videoplayer-shared"),ye=require("@vkontakte/videoplayer-statistics");var rs=require("@vkontakte/videoplayer-shared");function Oe(t,e){let r;return(...n)=>{clearTimeout(r),r=setTimeout(()=>t(...n),e)}}var J=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,ke=t=>J(t,"Object"),lt=t=>J(t,"String"),pt=t=>J(t,"Array"),ut=t=>J(t,"Number"),Zi=t=>J(t,"Function");var fr=t=>ut(t)&&!isNaN(t);var ee=t=>ke(t)&&Object.keys(t).length===0,vr=t=>pt(t)&&!t.length;var Pe=(t,e)=>lt(t)&&(e?t.trim():t).length;var Ji="video_interactive",es="videoint";var ts=250,Ve=class{constructor(e){this.handleZoomChange=Oe(e=>{this.lastZoomInfo=e},ts);this.onResize=e=>{if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let r=this.getNextPoint();r&&this.ngEditor?.zoomTo(r,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,r=[])=>{if(this.isReady=!1,!ut(e.graph.edit.chapters[0].x)){this.onError?.("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(r),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(r)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:r,onError:n,lang:i,visitedChapters:s=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=r,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=Vl(e),this.resizeObserver=new ResizeObserver(Oe(this.onResize,ts)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor?.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor?.updateVideosInfo(e)}async show(){this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&this.ngEditor?.focusChapter(this.currentChapterId),this.isHidden=!1)}async initNgEditor(){if(!this.manifest)return;let e;try{e=await(0,rs.loadVKLangPack)(this.lang,Ji,es)}catch{this.onError?.("Unable to load graph language pack")}let{GraphEditor:r}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new r(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 Vl(t){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",t.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(r=>r.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let r=-1,n=!1,i=Math.round(this._player.info.position$.getValue()*1e3);for(let s of this._containers){let c=s.startTime-e;if(c<=i&&(s.endTime&&i<=s.endTime||s.endTime===null)){n=!0;break}i<c&&(r=r===-1?c:Math.min(r,c))}return!n&&r!==-1?r:null}}};var y=require("@interactiveplatform/movika-manifest");var ns={metadata:"Object",chapters:"Array"},yr=t=>{if(!ke(t))return!1;for(let e in ns)if(!t[e]||!J(t[e],ns[e]))return!1;return(0,y.isSupportedManifest)(t.metadata.version)},Ne=t=>t.type===y.ControlTypes.Text,Ml=t=>t.type===y.ControlTypes.Button,Nl=t=>t.type===y.ControlTypes.Area,Ll={Choice:"Choice",TextInput:"TextInput"},jl={Button:"Button",Area:"Area",Text:"Text"},$l={onClick:"onClick",onSuspense:"onSuspense"},br={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var M=class{constructor(e,r,...n){this.severity=e;this.category=r;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var ht=class{constructor(){this.listeners={}}addListener(e,r){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(r),this}on(e,r){return this.addListener(e,r)}once(e,r){this.listeners[e]=this.listeners[e]||[];let n=()=>{r(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,r){return this.removeListener(e,r)}reset(){this.listeners={}}removeListener(e,r){let n=this.listeners[e]||[];for(let i=n.length;i>0;i--)if(n[i]===r){n.splice(i,1);break}return this}emit(e,...r){let n=this.listeners[e];return n?(n.forEach(i=>{i(...r)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var dt=class{constructor(e){this.fns=[];this.addFn=(e,r=!1)=>{Zi(e)&&(this.fns.push(e),r&&this.updateFn())};this.removeFn=(e,r=!1)=>{this.fns=this.fns.filter(n=>n!==e),r&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var ls=require("@vkontakte/videoplayer-shared");var mt=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,r){return _l(...this.loaders[e])(r)}};function _l(...t){return async function(r){let n=[...t];for(;n.length>0;)r=await n.shift()(r);return r}}function Le(t,e,r){return t?{...t,[e]:t[e]?[r,...t[e]]:[r]}:{[e]:[r]}}function ft({actions:t,errors:e,chapterId:r,...n}){if(r){let i=t.getManifest();if(i){let s=t.getChapter(i.chapters,r);if(s){let c=t.getMedia(i.media,s.videoId),o=t.getGraph(i.graph,s.id);return c?{...n,actions:t,errors:e,result:{chapter:s,media:c,graph:o}}:{...n,errors:Le(e,ft.name,"Could not find media"),actions:t}}}}return{...n,errors:Le(e,ft.name,"Could not find chapter"),actions:t}}var vt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,r,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:r,options:n})}removeEventListener(e,r){if(!(e in this.listeners))return;let n=this.listeners[e];for(let i=0,s=n.length;i<s;i++)if(n[i].callback===r){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,s=n.length;i<s;i++){let c=n[i];try{c.callback.call(this,e)}catch(o){Promise.resolve().then(()=>{throw o})}c.options&&c.options.once&&this.removeEventListener(e.type,c.callback)}return!e.defaultPrevented}},me=class extends vt{constructor(){super(),this.listeners||vt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},je=class{constructor(){Object.defineProperty(this,"signal",{value:new me,writable:!0,configurable:!0})}abort(e){let r;try{r=new Event("abort")}catch{typeof document<"u"?document.createEvent?(r=document.createEvent("Event"),r.initEvent("abort",!1,!1)):(r=document.createEventObject(),r.type="abort"):r={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(r)}toString(){return"[object AbortController]"}};typeof Symbol<"u"&&Symbol.toStringTag&&(je.prototype[Symbol.toStringTag]="AbortController",me.prototype[Symbol.toStringTag]="AbortSignal");function yt(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof t.Request=="function"&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}function Cr(t){typeof t=="function"&&(t={fetch:t});let{fetch:e,Request:r=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=t;if(!yt({fetch:e,Request:r,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:e,Request:s};let s=r;(s&&!s.prototype.hasOwnProperty("signal")||i)&&(s=function(l,d){let m;d&&d.signal&&(m=d.signal,delete d.signal);let f=new r(l,d);return m&&Object.defineProperty(f,"signal",{writable:!1,enumerable:!1,configurable:!0,value:m}),f},s.prototype=r.prototype);let c=e;return{fetch:(a,l)=>{let d=s&&s.prototype.isPrototypeOf(a)?a.signal:l?l.signal:void 0;if(d){let m;try{m=new DOMException("Aborted","AbortError")}catch{m=new Error("Aborted"),m.name="AbortError"}if(d.aborted)return Promise.reject(m);let f=new Promise((b,k)=>{d.addEventListener("abort",()=>k(m),{once:!0})});return l&&l.signal&&delete l.signal,Promise.race([f,c(a,l)])}return c(a,l)},Request:s}}var $e=yt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),is=$e?Cr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,gr=$e?is.fetch:window.fetch,hm=$e?is.Request:window.Request,dm=$e?je:window.AbortController,mm=$e?me:window.AbortSignal;var bt=(t="",e="")=>{let r=t.split("."),n=e.split("."),i=0;for(let s=0;s<Math.max(r.length,n.length)&&!i;s++)r[s]>n[s]?i=1:r[s]<n[s]?i=-1:i=0;return i};var Fl=async t=>{try{let e={},r;if(lt(t)){r=new URL(t).href;let i=await gr(r);if(!i.ok)return{};e=await i.json()}else if(ke(t))e=t;else return{};if(!yr(e))return{};let n=e.metadata.media;if(lt(n)&&!("media"in e))try{let i;r?i=new URL(n,r).href:(i=new URL(n).href,r=i);let s=await gr(i);if(!s.ok)throw new Error;e.metadata.media=await s.json()}catch{return Dl(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:r}}catch{return{}}};async function ss(t){let{manifest:e,manifestURL:r}=await Fl(t);if(!e)throw new Error("Failed on fetch");let n=(0,y.migrateManifestToLatestVersion)(e);return n.media=ql(n.media,r),delete n.metadata.media,n}function Ct(t,e){if(e)return t.find(r=>r.id===e)}function Er(t,e){return t.edit?.chapters?t.edit.chapters.find(r=>r.id===e):t.view?.chapters?t.view.chapters.find(r=>r.id===e):void 0}function Ir(t,e){return t.videos.find(r=>r.id===e)}function ql(t,e){return{...t,videos:t.videos.map(r=>({...r,variants:r.variants.map(n=>{let i="url"in n?n.url:"",s=Bl(i,e);return{...n,url:s||i}})}))}}function Bl(t="",e){try{return new URL(t,e).href}catch{return""}}function Dl(t){return bt(t,"3.2.0")>=0}var gt=t=>pt(t)&&!vr(t),G=t=>t.order==="end",_e=t=>pt(t.containers)&&!vr(t.containers)&&G(t),os=(t,e)=>{let r=t*1e3;return gt(e.controls)&&r<(e.startTime??0)},Tr=(t,e)=>{let r=t*1e3;return gt(e.controls)&&r>=(e.startTime??0)&&r<=(e.endTime??1/0)};var te=(t=[])=>t.some(e=>e.action.type==="expect"),xr=(t=[])=>t.find(e=>e.action.type==="expect"),Hl=t=>t?.length===1,re=t=>Hl(t)&&Ne(t[0]);function as(t,...e){return r=>typeof e[0]=="object"&&typeof r=="object"?t({...e[0],...r}):t(...e,...r)}var cs=(t,e)=>{let r=T=>e.find(({container:x})=>x.container.id===T)?.container.isRemoved,n=te(t.events)&&!r(t.id),i=(T,E=!1,x=!1)=>{let h=x?"every":"some";return T.controls[h](p=>{let v=E?T.endTime===t.endTime:!0;return p.events?.[h](C=>C.action?.type===br.openURI)&&v})},s=T=>T.some(({container:E})=>i(E.container,!0,!1)&&!E.isRemoved),c=T=>T.every(({container:E})=>E.isRemoved?!0:i(E.container,!0,!0)),o=e.filter(({container:T})=>T.container.id!==t.id&&te(T.container.events)&&T.container.endTime===t.endTime&&!T.isRemoved).length,a=T=>T.controls.some(E=>E.events?.some(x=>x.action?.args?.shouldOpenNow)),l=n||o>0,d=s(e),m=i(t),f=c(e),b=n?!1:o>0,k=a(t);return{isExpectTime:l,hasOtherExpect:o>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:f,isExpectEventForCurrentContainer:b,hasShouldOpenNowEvent:k}};var ne=class extends mt{constructor(r,n){super(r);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new ls.ValueSubject(null);this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(r){this.release();let n=await this.exec("manifestLoaders",{actions:{addErrorMessage:Le},result:null,errors:null,source:r});return n.errors&&this.errorHandler(n.errors),this.manifest=await ss(n.result??r),this}async setInitial(){return this.setNext()}async setNext(r=this.manifest?.metadata.initChapterId){if(!r)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",ft({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Er,getChapter:Ct,getMedia:Ir,getByBranches:this.getByBranches.bind(this),addErrorMessage:Le},result:null,errors:null,chapterId:r}));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(r){this.onError(r),console.error("Something went wrong with loaders",{errors:r})}getInitial(){return this.getByChapterId(this.manifest?.metadata.initChapterId)||null}getByChapterId(r=this.manifest?.metadata.initChapterId){if(!r||!this.manifest)return null;let n=Ct(this.manifest.chapters,r);if(n){let i=Ir(this.manifest.media,n.videoId),s=Er(this.manifest.graph,n.id);if(i)return{chapter:n,media:i,graph:s}}return null}getBranches(r=this.chapter?.id){if(r===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let n=Ct(this.manifest?.chapters||[],r);return this.getByBranches(n?.branches)}}getByBranches(r=[]){return r.reduce((n,i)=>{let s=this.getByChapterId(i.chapterId);return s&&n.push(s),n},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter?.id===this.manifest?.metadata.initChapterId}isEndChapter(){return this.chapter?G(this.chapter):!1}};var Ys=z(Et(),1),Zs=require("@vkontakte/videoplayer-core"),X=require("@vkontakte/videoplayer-shared");var Hs=t=>{let e=t.variants.find(r=>r.payload?.type==="vk");if(e&&e.payload){let[r,n]=e.payload.id.split("_");return[r,n]}return[]};var Us=z(Et(),1);function Rr(){let t=new Map;function e({listId:s=Math.random().toString(),itemId:c=Math.random().toString(),...o}){let a=t.get(s),l={...o};return a?a[c]=l:t.set(s,{[c]:l}),{listId:s,itemId:c,...o}}function r(s){s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),s.statistics?.oneStat.destroy(),s.statistics?.statSubscription.unsubscribe()}function n(s,c){let o=t.get(s);if(!o)throw Error("Can't remove. Not find.");if(c){let a=o[c];a&&r(a),delete o[c],Object.keys(o).length||t.delete(s)}else{for(let a of(0,Us.default)(o))r(a);t.delete(s)}}function i(){for(let s of t)n(s[0])}return{createPlayer:e,removePlayer:n,map:t,removeAll:i}}var fe=z(It(),1);function Or(t,e=[]){let r={},n,i=!e.length;for(let s of t.variants)if(!n&&"cover"in s&&(n=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(i||(0,fe.default)(e,"mp4"))&&(r.MPEG={...r.MPEG,[s.standard??"Invariant quality"]:s.url});break;case"mpeg":(i||(0,fe.default)(e,"mpeg"))&&(r.MPEG={...r.MPEG,[s.standard??"Invariant quality"]:s.url});break;case"hls":(i||(0,fe.default)(e,"hls"))&&(r={...r,HLS:{type:"url",url:s.url}});break;case"dash":(i||(0,fe.default)(e,"dash"))&&(r={...r,DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}});break;default:break}return{sources:r,thumbUrl:n,title:t.title??""}}var Fe=(t,e)=>{let r=t.info.currentQuality$.getValue(),n=t.info.availableQualities$.getValue();r!==e&&(0,fe.default)(n,e)&&(t.setQuality(e),t.setAutoQuality(!1))};var Pp=2;function kr(t){let e=Rr(),r=new X.Subscription,n={},i=null,s=!1,c,o=new X.ValueSubject(null);t&&a(t);function a(E){i=E}function l(E,x,h){if(!i)throw Error("need to set interactive controller");if(!i.options)return;let v=(e.map.get(E)??{})[x];if(v){n={chapterId:h,listId:E,itemId:x,...v};let C=n.player;n.subscription.add(C.info.currentQuality$.subscribe(I=>{let S=C.info.position$.getValue(),R=C.info.isAutoQualityEnabled$.getValue();if(!(!I||!S||R))for(let V of e.map)(0,Ys.default)(V[1]).forEach(({player:A})=>{Fe(A,I)})})).add(C.events.started$.subscribe(()=>{d(x)})),v.container.remove(),i.setPlayer(v.player),s||(i.init(),s=!0),o.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}async function d(E){if(!i)throw Error("need to set interactive controller");if(ee(n)||E!==n.itemId)return;let x=i.getChapterBranches(),h=new Set;for(let p of x)h.has(p.media.id)||(await f({media:p.media,chapterId:p.chapter.id,setAsActive:!1,title:p.chapter.label}),h.add(p.media.id))}async function m({chapter:{id:E},manifestVideo:x}){if(ee(n)||!i)return;let h=n.player.info.muted$.getValue(),p=n.player.info.currentQuality$.getValue(),v=n.player.info.isAutoQualityEnabled$.getValue(),C=n.player.info.volume$.getValue(),I=n.player.info.currentPlaybackRate$.getValue(),S=!v,R=!1;for(let V of e.map)if(V[0]===x.id&&!i.state.isReplay$.getValue()){let A=Object.keys(V[1]);for(let N of A)N===n.itemId?(A.length<Pp||(R=!0),e.removePlayer(V[0],N)):(R=!0,l(V[0],N,E),S?Fe(n.player,p):n.player.setAutoQuality(!0),n.player.setVolume(C),n.player.setMuted(h),n.player.setPlaybackRate(I))}else e.removePlayer(V[0]);R||(await f({media:x,chapterId:E,setAsActive:!0,playbackRate:I}),S?Fe(n.player,p):n.player.setAutoQuality(!0),n.player.setVolume(C),n.player.setMuted(h))}async function f({media:E,chapterId:x,prefetch:h=!0,setAsActive:p=!0,autoplay:v=!1,preferredExt:C,title:I,playbackRate:S}){let R=Math.random().toString(),V=document.createElement("div");c.append(V);let A;if(i?.options?.vkVideoLoader){let He=Hs(E);He.length&&(A=await i.options.vkVideoLoader(...He))}let N=i?.options?.coreConfig||void 0,q={...N,configName:[...N?.configName??[],"interactive"]},B={container:V,...A?.videos?.[0]||{sources:Or(E,C).sources},title:I,failoverHosts:A?.failoverHosts||[]},D=new Zs.Player(q,X.Tracer.createRootTracer());D.initVideo(B);let K=null;if(A?.videos&&i?.options.createOneStat){let He=A.videos[0],Ot=i.options.createOneStat(He),Fr=new X.Subscription;Ot&&(Fr.add(Ot.attachTo(D)),K={oneStat:Ot,statSubscription:Fr})}let ie=new X.Subscription,la=n?.player?.info.isAutoQualityEnabled$.getValue();ie.add(D.events.canplay$.subscribe(function(){la||Fe(D,n.player.info.currentQuality$.getValue()),S&&D.setPlaybackRate(S)}));let se=e.createPlayer({listId:E.id,itemId:R,player:D,container:V,sources:Or(E,C).sources,config:B,subscription:ie,statistics:K});return p&&l(E.id,se.itemId,x),v&&se.player.play(),h&&!v&&se.player.prepare(),{player:se.player,config:se.config,statistics:se.statistics}}function b(){k(),i=null,c.remove()}function k(){r.unsubscribe(),e.removeAll(),n={},s=!1}async function T(){if(!i)throw Error("need to set interactive controller");k(),c=document.createElement("div");let{media:E,chapter:x}=i.getCurrentChapter();E&&x?(r.add(i.events.chapterChanged$.subscribe(m)),await f({media:E,chapterId:x.id,title:x.label})):console.error("not found")}return{...e,init:T,setInteractiveController:a,createPlayer:f,removeAll:b,getActivePlayer:function(){return n},activePlayerChanged:o}}var w={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},ve={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},O={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var eo=z(It(),1),to=require("@vkontakte/videoplayer-shared");var Tt=class{constructor({player:e,container:r,branches:n,selectBranches:i,interactiveEvents:s,globalEvents:c,globalEventEmitter:o,getContainerEventState:a,permanentTextControls:l,interactiveTimeOpenUri:d,disabledControls$:m,onRemove:f}){this.hide=()=>{setTimeout(()=>{this.gameState!==4&&(te(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:r}=this.getContainerEventState();if(this.container.show?.(),this.interactiveTimeOpenUri&&r)return;this.emitContainerVisibilityEvent(!0,!1)}else{let r={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(i,s)=>{let{isExpectTime:c,hasOtherExpect:o,hasOpenURIEvent:a,hasOpenURIEventInCurrentContainer:l,isAllOpenURIEventsValid:d,hasShouldOpenNowEvent:m}=this.getContainerEventState(),f=this.interactiveTimeOpenUri&&!l,b=this.interactiveTimeOpenUri&&l;if((!this.interactiveTimeOpenUri||f)&&(this.isSelectedControlEvent=!0),i!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||f)){if(this.interactiveTimeOpenUri){let k=!o&&!d&&l;k&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:k})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&a&&this.gameState!==5){if(b){let T=((E,x,h,p)=>!E&&!x&&h||E&&!x&&h&&!p||E&&!x&&h&&p)(c,o,d,this.isSelectedContainerEvent);this.fakeRemoveView(T)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!c||!o||!m)&&(this.selectBranches.stopExpect(),s())}},isEOV:()=>this.gameState===4},n=as(this.selectBranches.onControlEvent,r);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,eo.default)(i,this.gameState)&&!this.isPermanentText)return;let s=this.player.getExactTime();if(os(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Tr(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let l=this.gameState;this.gameState=3,l===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:l}=this.getContainerEventState(),d=this.selectBranches.state.isExpect,m=this.interactiveTimeOpenUri&&l;if(m&&!d){let f=this.container.getElement();f&&(f.style.visibility!=="hidden"&&this.container.hide?.(),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!m&&this.removeView()}let c=Tr(s,this.container.container),o=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:o,currentTime:s,isInteractiveTime:c};this.container.onProgress(s*1e3,c),this.globalEventEmitter.emit(w.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=r,this.branches=n,this.selectBranches=i,this.subscription=new to.Subscription,this.player=e,this.interactiveEvents=s,this.getContainerEventState=a,this.isPermanentText=l&&re(r.container.controls),this.interactiveTimeOpenUri=d,this.disabledControls$=m,this.onRemove=f,this.globalEventEmitter=o,this.gameState=0,this.globalEvents=c,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,r=!1){e?(this.globalEventEmitter.emit(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:O.visibility,visibility:e,isFirst:r}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:r})):(this.globalEventEmitter.emit(w.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?.()}))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:r}=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,!r&&!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:r}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||r:te(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(w.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()}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 ro=(t=[])=>t.reduce((e,r,n)=>{let i=(r?.controls??[]).filter(s=>!Ne(s));if(gt(i)){let s=[r.startTime??0,r.endTime??1/0],c={id:r.id,isRemoved:!1};if(!n)e.push({subjects:[c],range:s});else{let o=[],a=-1/0,l=1/0,d=[],m=[];for(let f=0;f<e.length;f++){let b=e[f];if(m.push(...b.subjects),b.range[0]<l&&(l=b.range[0]),b.range[1]>a&&(a=b.range[1]),s[0]>=b.range[0]&&s[1]<=b.range[1])return e[f].subjects.push(c),e;s[0]<b.range[0]&&s[1]>b.range[0]&&(o.push(f),d=d.concat(b.subjects)),s[0]>=b.range[0]&&s[0]<=b.range[1]&&(o.push(f),d=d.concat(b.subjects),s[0]=b.range[0]),s[1]>=b.range[0]&&s[1]<=b.range[1]&&(o.push(f),d=d.concat(b.subjects),s[1]=b.range[1])}if(m.push(c),s[0]<=l&&s[1]>=a)return[{subjects:m,range:s}];o.length&&o.reverse().forEach(f=>{e.splice(f,1)}),e.push({subjects:d.concat([c]),range:s})}}return e},[]).sort((e,r)=>e.range[0]-r.range[0]);var _o=z(It(),1),Nr=z(Et(),1),Fo=z(jo(),1);function $o(){let t={};function e(){for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&delete t[o]}function r(o){let a={};for(let l in t)+l<=o&&(a[l]=t[l]);return a}function n(o){let a={};for(let l in t)+l>=o&&(a[l]=t[l]);return a}function i({timestamp:o,priority:a,initiator:l}){if(fr(o)){let d=t[o]??null;if(d&&a&&Pe(a,!0)){let m={},f=d[a];return f&&(m={...m,...f}),m=ee(m)?null:m,m&&Pe(l,!0)?m[l]??null:m}return d}return null}function s({timestamp:o,priority:a,initiator:l}){if(fr(o))if(t[o]){if(a&&Pe(a,!0))if(t[o][a]){if(l&&Pe(l,!0))if(t[o][a][l]){if(delete t[o][a][l],!ee(t[o][a]))return!0}else return!1;if(delete t[o][a],!ee(t[o]))return!0}else return!1;return delete t[o]}else return!1;return!1}function c({timestamp:o,priority:a,initiator:l,...d}){t[o]?.[a]?.[l]?t[o][a][l].push({...d}):t[o]?.[a]?t[o][a]={...t[o][a],[l]:[{...d}]}:t[o]?t[o]={...t[o],[a]:{[l]:[{...d}]}}:t[o]={[a]:{[l]:[{...d}]}}}return{map:t,remove:s,add:c,removeAll:e,get:i,getLte:r,getGte:n}}var Cu=[y.EventActionTypes.expect,y.EventActionTypes.setNextBranch],gu=1/0;function qo(t,e){let r=t,n,i=Eu(e),s=$o(),c,o=()=>{b(),h()},a=p=>{s.add.call(void 0,p),T()},l=(p=[])=>{for(let v of p)if(v.action(),(0,_o.default)(Cu,v.actionType))break},d=(p=1/0)=>{let v=St(s.get({timestamp:p,priority:"control"})??{}),C=St(s.get({timestamp:p,priority:"container"})??{}),I=St(s.get({timestamp:p,priority:"chapter"})??{});return[...v,...C,...I]},m=p=>{i.isReady(p)&&l(d(p))},f=()=>{l([...St(s.get({timestamp:1/0,priority:"chapter"})??{})])},b=()=>{n&&(c?.unsubscribe(),n=void 0)},k=p=>{},T=()=>{n||(n=()=>setTimeout(()=>{m(1/0)}),c=r.events.ended$.subscribe(n))},E=p=>{b(),r=p},x=p=>{p.priority==="container"&&i.resetCalled(p.timestamp),s.remove(p)},h=()=>{i.release(),s.removeAll()};return{setPlayer:E,add:a,remove:x,exec:m,execEndOfVideo:f,listen:T,unlisten:b,release:o,containersEventsCallState:i,getPreparedToExecActions:d}}function Eu(t){let e=new Map;return{setCalled:({timestamp:o,id:a})=>{let l=e.get(o);l&&l[a]!==void 0&&(l[a]=!0)},setData:(o=[])=>{for(let a of o){let l=a.endTime??gu,d=e.get(l);e.set(l,{...d,[a.id]:!1})}},resetCalled:o=>{let a=e.get(o);if(a)for(let l in a)a[l]=!1},isReady:o=>{let a=e.get(o);if(!a)return!0;let l=(0,Nr.default)(a);return t?l.some(m=>m):!l.some(m=>!m)},release:()=>e.clear()}}function St(t){return(0,Fo.default)((0,Nr.default)(t)).sort(e=>e.actionType===y.EventActionTypes.expect?-1:1)}var Bo={videoContentHeight:0,videoContentWidth:0},Do=t=>{let{height:e,width:r}=t.info.intrinsicVideoSize$.getValue()||{};if(!(e&&r))return Bo;let{clientHeight:n,clientWidth:i}=t.experimental.element$.getValue()||{};if(!(n&&i))return Bo;let s=e/r,c=n/i,o,a;return c>s?(a=i,o=i*s):c<s?(a=n/s,o=n):(a=i,o=n),{videoContentWidth:a,videoContentHeight:o}};var Iu=250;function Ho(t){let e,r=new ResizeObserver(o=>{s(o),e=s.bind(null,o)});function n(o){let{parentElement:a,player:l}=t();if(a&&l){let{videoContentWidth:d,videoContentHeight:m}=Do(l);a.style.setProperty("--interactive-content-width",`${d}px`),a.style.setProperty("--interactive-content-height",`${m}px`),a.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function i(){let{parentElement:o}=t();o.removeAttribute("style")}let s=Oe(o=>{let{fns:a=[]}=t();n(o);for(let l of a)l()},Iu);function c(){e=void 0,r.disconnect(),i()}return{resizeObserver:r,calc:()=>{e?.()},release:c}}var Tu=t=>Math.floor(Math.random()*t),Go=t=>{let e=t.length,r=1/0,n=null;for(;e--;){let i=t[e],s=i.weight??1;s<r&&(r=s,n=i)}return n},zo=t=>{let e=t.length,r=-1/0,n=null;for(;e--;){let i=t[e],s=i.weight??0;s>r&&(r=s,n=i)}return n};var Wo=t=>{let e=t.length,r=Tu(e);return t[r]},Uo=1,Ko=t=>{let e=0;for(let n=0;n<t.length;++n)e+=t[n].weight??Uo;let r=Math.random()*e;e=0;for(let n=0;n<t.length-1;++n)if(e+=t[n].weight??Uo,e>=r)return t[n];return t[t.length-1]};var Qo={shouldOpenNow:!0,isDetachContainer:!0},Xo="after-expect";var Lr=(t,e=!1)=>({...t,args:e?{...t.args,...Qo}:{...Qo,...t.args}}),Jo=({globalEventEmitter:t,globalEvents:e,player:r,interactiveEvents:n})=>{let i={isExpect:!1},s=()=>{i.isExpect&&(i.isExpect=!1)},c=({action:h,controlType:p,controlId:v,containerId:C,branches:I=[],onEvent:S,isEOV:R=()=>!1,isDisabled:V=()=>!1})=>{let A=Lr(h,R()),N={timestamp:1/0,priority:"control",initiator:v,actionType:A.type},q=V(),B=t.emit.bind(t,w.interactives,{subjectId:v,subjectType:p,subjectName:"control",type:q?O.actionChoiceCanceled:O.actionChoice,actionType:h.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:C,...A.args}}),D=()=>{e.interactiveActionChoice$.next({subjectId:v,subjectType:p,subjectName:"control",type:q?"action-choice-canceled":"action-choice",actionType:h.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:C,...A.args}})};if(q){B(),D();return}switch(A.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let K=I.find(ie=>ie.id===A.args.branchId);if(!K)return;S(A.args.isDetachContainer,b.bind(null,{subjectId:v,subjectName:"control"})),B(),D(),A.args.shouldOpenNow?T({subjectId:v,subjectName:"control",subjectType:p,action:A,payload:{chapterId:K.chapterId,autoSelect:!1}}):n.add({...N,action:T.bind(null,{subjectId:v,subjectName:"control",subjectType:p,action:A,payload:{chapterId:K.chapterId,autoSelect:!1}})});return}case y.EventActionTypes.continuePlayback.trim().toLowerCase():{S(A.args.isDetachContainer,b.bind(null,{subjectId:v,subjectName:"control"})),B(),D(),A.args.shouldOpenNow?k({subjectId:v,subjectName:"control",subjectType:p,action:h}):n.add({...N,action:k.bind(null,{subjectId:v,subjectName:"control",subjectType:p,action:h})});return}case y.EventActionTypes.openURI.trim().toLowerCase():{S(A.args.isDetachContainer,b.bind(null,{subjectId:v,subjectName:"control"})),B(),D(),A.args.shouldOpenNow?x({subjectId:v,subjectName:"control",subjectType:p,action:A,payload:{URI:h.args.uri}}):n.add({...N,action:x.bind(null,{subjectId:v,subjectName:"control",subjectType:p,action:A,payload:{URI:h.args.uri}})});return}default:{let K="Unexpected control event",ie=new M(1,1,{message:K});d(ie,K);return}}},o=({action:h,container:{id:p,endTime:v},branches:C=[],isEOV:I=!1,autoSelected:S=!1})=>{let R=Lr(h,I),V={timestamp:!R.args.shouldOpenNow||I?1/0:v??1/0,priority:"container",initiator:p,actionType:R.type},A=t.emit.bind(t,w.interactives,{subjectId:p,subjectName:"container",type:O.actionChoice,actionType:R.type,payload:{invokeImmediately:R.args.shouldOpenNow,...R.args}}),N=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"container",type:"action-choice",actionType:R.type,payload:{invokeImmediately:R.args.shouldOpenNow,...R.args}})};switch(R.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let q=C.find(B=>B.id===R.args.branchId);if(!q)return;A(),N(),n.add({...V,action:T.bind(null,{subjectId:p,subjectName:"container",action:R,payload:{chapterId:q.chapterId,autoSelect:S}})});return}case y.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case y.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case y.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case y.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case y.EventActionTypes.continuePlayback.trim().toLowerCase():{A(),N(),n.add({...V,action:k.bind(null,{subjectId:p,subjectName:"container",action:R})});return}case y.EventActionTypes.openURI.trim().toLowerCase():{A(),N(),n.add({...V,action:x.bind(null,{subjectId:p,subjectName:"container",action:R,payload:{URI:h.args.uri}})});return}default:{let q="Unexpected container event",B=new M(1,1,{message:q});d(B,q);return}}};function a({container:h,branches:p,isEOV:v=!1}){let C=xr(h.events);if(C){let I=Lr(C.action,v);t.emit(w.interactives,{subjectId:h.id,subjectName:"container",type:O.actionChoice,actionType:I.type,payload:{invokeImmediately:I.args.shouldOpenNow,...I.args}}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"container",type:"action-choice",actionType:I.type,payload:{invokeImmediately:I.args.shouldOpenNow,...I.args}}),n.add({timestamp:v?1/0:h.endTime??1/0,priority:"container",initiator:h.id,actionType:y.EventActionTypes.expect,action:f.bind(null,{subjectId:h.id,subjectName:"container"})}),i.isExpect=!0}else for(let I of h.events??[])o({action:I.action,container:h,branches:p,isEOV:v})}let l=({chapterId:h,action:p,branches:v=[]})=>{let C=t.emit.bind(t,w.interactives,{subjectId:h,subjectName:"chapter",type:O.actionChoice,actionType:p.type,payload:p.args}),I=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"chapter",type:"action-choice",actionType:p.type,payload:p.args})};switch(p.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let S=v.find(R=>R.id===p.args.branchId);return S?.chapterId?(C(),I(),T.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:S.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let S=Wo(v);return S?.chapterId?(C(),I(),T.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:S.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setRandomBranch.trim().toLowerCase():{let S=Ko(v);return S?.chapterId?(C(),I(),T.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:S.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let S=zo(v);return S?.chapterId?(C(),I(),T.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:S.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let S=Go(v);return S?.chapterId?(C(),I(),T.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:S.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.continuePlayback.trim().toLowerCase():return C(),I(),k.bind(null,{subjectId:h,subjectName:"chapter",action:p});case y.EventActionTypes.openURI.trim().toLowerCase():return C(),I(),x.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{URI:p.args.uri}});default:{let S="Unexpected chapter event",R=new M(1,1,{message:S});d(R,S);return}}};function d(h,p){console.error(p),e.error$.next(h),t.emit(w.errors,h)}function m(h){let p=xr(h.events);if(p){if(G(h))return;t.emit(w.interactives,{subjectId:h.id,subjectName:"chapter",type:O.actionChoice,actionType:p.action.type,payload:p.action.args}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"chapter",type:"action-choice",actionType:p.action.type,payload:p.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:y.EventActionTypes.expect,action:f.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else h.events?.forEach(v=>{let C=l({chapterId:h.id,action:v.action,branches:h.branches});C&&n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:v.action.type,action:C})})}let f=({subjectId:h,subjectName:p})=>{r.pause(),t.emit(w.interactives,{subjectId:h,subjectName:p,type:O.actionExecution,actionType:y.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,type:"action-execution",actionType:y.EventActionTypes.expect})},b=({subjectId:h,subjectName:p})=>{r.info.isEnded$.getValue()?n.execEndOfVideo():r.play(),t.emit(w.interactives,{subjectId:h,subjectName:p,type:O.actionExecution,actionType:Xo}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,type:"action-execution",actionType:Xo})},k=({subjectId:h,subjectName:p,subjectType:v,action:C})=>{t.emit(w.interactives,{subjectId:h,subjectName:p,subjectType:v,type:O.actionExecution,actionType:C.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:C.type})},T=({subjectId:h,subjectName:p,subjectType:v,action:C,payload:I})=>{I.behaviour="change-chapter",t.emit(w.interactives,{subjectId:h,subjectName:p,subjectType:v,type:O.actionExecution,actionType:C.type,payload:I}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:C.type,payload:I})},E=({subjectId:h,subjectName:p,subjectType:v,action:C,payload:I})=>{I.behaviour="change-manifest",t.emit(w.interactives,{subjectId:h,subjectName:p,subjectType:v,type:O.actionExecution,actionType:C.type,payload:I}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:C.type,payload:I})},x=({subjectId:h,subjectName:p,subjectType:v,action:C,payload:I})=>{if(!I.URI)return;let S=window.open(I.URI,"_blank","noopener,noreferrer");S&&(S.opener=null),t.emit(w.interactives,{subjectId:h,subjectName:p,subjectType:v,type:O.actionExecution,actionType:C.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:C.type})};return{onControlEvent:c,onContainerEvent:o,onChapterEvent:l,onExpectEvent:f,expectEventHandler:b,setManifestChapterEvents:m,setManifestContainerEvents:a,stopExpect:s,state:i}};var _r=z(mr(),1),F=require("@vkontakte/videoplayer-shared");var wt=(t,e)=>{let r={};return t.map(n=>{if(!r[n]){let i=e.chapters.find(c=>c.id===n);if(!i)return null;let s=e.media.videos.find(c=>i.videoId===c.id);if(!s)return null;r[n]=jr(s)}return r[n]}).filter(Boolean)},ea=t=>{for(let e of t.variants)if(ta(e)&&e.payload)return e.payload.id},ta=t=>!!(t.type==="custom"&&t.payload&&t.payload.type==="vk"),jr=t=>{let e=ea(t);if(!e)return null;let r=e.split("_").pop();return r?parseInt(r,10):null},ra=(t,e)=>{for(let r of t.media.videos)if(e===jr(r)){for(let n of t.chapters)if(n.videoId===r.id)return n.id;return}},$r=(t,e)=>t.reduce((r,n)=>{let i=ra(e,n);return i?[...r,i]:r},[]);var Be=class{constructor({globalEventEmitter:e,videoId:r,interactiveController:n,historyApi:i,settings:s}){this.state={history$:new F.ValueSubject([]),hasPrevChapter$:new F.ValueSubject(!1),prevChapter$:new F.ValueSubject(null),isInitialChapter$:new F.ValueSubject(!1),isGoBackLimited$:new F.ValueSubject(!1)};this.#r=null;this.#o=!1;this.#e=null;this.#p=null;this.events={inited$:new F.Subject,destroyed$:new F.Subject,error$:new F.Subject};this.#n=null;this.#i=null;this.#t=null;this.#a=new F.Subscription;this.#c=!1;this.#l=0;this.#n=r,this.#t=e,this.#i=n,this.#r=i,this.#s=s,this.state.history$&&this.#a&&this.#a?.add(this.state.history$.subscribe(c=>{this.state.prevChapter$.next((0,_r.default)(c,-2)||null),this.state.hasPrevChapter$.next(c.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===this.#e?.metadata?.initChapterId),this.state.isGoBackLimited$.next(this.#l===this.#s.maxLength-1)}))}#r;#s;#o;#e;#p;#n;#i;#t;#a;#c;#l;async setManifest(e){if(!this.#i||!this.#t)return;this.#e=e,await this.getProjectHistory();let r=this.getInitialChapterId();await this.#i.setChapter({chapterId:r,pushToHistory:!1}),this.#o||(this.#o=!0,this.events.inited$.next({initChapterId:r}))}get inited(){return this.#o}async updateHistory(e,r=!0){if(!this.#e)return;this.#c?(this.#c=!1,this.#l++):this.#l=0;let n=this.#e,i=e.length-this.#s.maxLength,s=i>0?e.slice(i):e,c=wt(s,n);if(this.#p=c,this.state.history$.next(s),!(!r||!this.#r||!this.#n))try{await this.#r.save(this.#n,c)}catch{let a=new M(1,5,"Unable to save interactive history");this.events.error$.next(a),this.#t?.emit(w.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(w.errors,n)}this.#c=!0;let e=this.state.history$.getValue().slice(0,-1),r=e.pop();this.state.history$.next(e),await this.#i.setChapter({chapterId:r,playPrev:!0})}async getProjectHistory(){if(!this.#e||!this.#n)return;let e=this.#e,r=[this.getInitialVideoId()];if(this.#r)try{let i=await this.#r.get(this.#n);i.length&&(r=i)}catch{let s=new M(1,5,"Error while trying to fetch data");this.events.error$.next(s),this.#t?.emit(w.errors,s)}let n=$r(r,e);this.state.history$.next(n)}getInitialChapterId(){let e=this.state.history$.getValue();return(0,_r.default)(e,-1)||this.#s.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return wt([e],this.#e).pop()}return null}destroy(){this.#n=null,this.#r=null,this.#i=null,this.#a?.unsubscribe(),this.#a=null,this.#o=!1,this.#t?.emit(w.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var At=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 r=e.data,n=r.length;for(let i=3;i<n;i+=40)if(r[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,r=!1){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;r&&(i=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,r&&i&&this.restore(i),this._prevSizeId=n}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),r=new Image;return r.crossOrigin="anonymous",r.src=e,await r.decode(),r}restore(e){this.rootElement&&this.rootElement.getContext("2d")?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}};var Rt=class{constructor({parentElement:e,endOffsetMs:r=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let r=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(r);if(this.isContainerTime(r))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
+ "use strict";var pa=Object.create;var Ue=Object.defineProperty;var ua=Object.getOwnPropertyDescriptor;var ha=Object.getOwnPropertyNames;var da=Object.getPrototypeOf,ma=Object.prototype.hasOwnProperty;var u=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),fa=(t,e)=>{for(var r in e)Ue(t,r,{get:e[r],enumerable:!0})},qr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ha(e))!ma.call(t,i)&&i!==r&&Ue(t,i,{get:()=>e[i],enumerable:!(n=ua(e,i))||n.enumerable});return t};var z=(t,e,r)=>(r=t!=null?pa(da(t)):{},qr(e||!t||!t.__esModule?Ue(r,"default",{value:t,enumerable:!0}):r,t)),va=t=>qr(Ue({},"__esModule",{value:!0}),t);var W=u((_t,Qr)=>{"use strict";var be=function(t){return t&&t.Math===Math&&t};Qr.exports=be(typeof globalThis=="object"&&globalThis)||be(typeof window=="object"&&window)||be(typeof self=="object"&&self)||be(typeof global=="object"&&global)||be(typeof _t=="object"&&_t)||function(){return this}()||Function("return this")()});var $=u((Ah,Xr)=>{"use strict";Xr.exports=function(t){try{return!!t()}catch{return!0}}});var Ce=u((Rh,Yr)=>{"use strict";var ya=$();Yr.exports=!ya(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")})});var rn=u((Oh,tn)=>{"use strict";var ba=Ce(),en=Function.prototype,Zr=en.apply,Jr=en.call;tn.exports=typeof Reflect=="object"&&Reflect.apply||(ba?Jr.bind(Zr):function(){return Jr.apply(Zr,arguments)})});var H=u((Ph,on)=>{"use strict";var nn=Ce(),sn=Function.prototype,Ft=sn.call,Ca=nn&&sn.bind.bind(Ft,Ft);on.exports=nn?Ca:function(t){return function(){return Ft.apply(t,arguments)}}});var ge=u((kh,cn)=>{"use strict";var an=H(),ga=an({}.toString),Ea=an("".slice);cn.exports=function(t){return Ea(ga(t),8,-1)}});var qt=u((Vh,ln)=>{"use strict";var Ia=ge(),Ta=H();ln.exports=function(t){if(Ia(t)==="Function")return Ta(t)}});var _=u((Mh,pn)=>{"use strict";var Bt=typeof document=="object"&&document.all;pn.exports=typeof Bt>"u"&&Bt!==void 0?function(t){return typeof t=="function"||t===Bt}:function(t){return typeof t=="function"}});var Z=u((Nh,un)=>{"use strict";var xa=$();un.exports=!xa(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var tt=u((Lh,hn)=>{"use strict";var Sa=Ce(),et=Function.prototype.call;hn.exports=Sa?et.bind(et):function(){return et.apply(et,arguments)}});var Dt=u(fn=>{"use strict";var dn={}.propertyIsEnumerable,mn=Object.getOwnPropertyDescriptor,wa=mn&&!dn.call({1:2},1);fn.f=wa?function(e){var r=mn(this,e);return!!r&&r.enumerable}:dn});var Ht=u(($h,vn)=>{"use strict";vn.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}});var bn=u((_h,yn)=>{"use strict";var Aa=H(),Ra=$(),Oa=ge(),Ut=Object,Pa=Aa("".split);yn.exports=Ra(function(){return!Ut("z").propertyIsEnumerable(0)})?function(t){return Oa(t)==="String"?Pa(t,""):Ut(t)}:Ut});var Gt=u((Fh,Cn)=>{"use strict";Cn.exports=function(t){return t==null}});var zt=u((qh,gn)=>{"use strict";var ka=Gt(),Va=TypeError;gn.exports=function(t){if(ka(t))throw new Va("Can't call method on "+t);return t}});var Ee=u((Bh,En)=>{"use strict";var Ma=bn(),Na=zt();En.exports=function(t){return Ma(Na(t))}});var le=u((Dh,In)=>{"use strict";var La=_();In.exports=function(t){return typeof t=="object"?t!==null:La(t)}});var rt=u((Hh,Tn)=>{"use strict";Tn.exports={}});var nt=u((Uh,Sn)=>{"use strict";var Wt=rt(),Kt=W(),ja=_(),xn=function(t){return ja(t)?t:void 0};Sn.exports=function(t,e){return arguments.length<2?xn(Wt[t])||xn(Kt[t]):Wt[t]&&Wt[t][e]||Kt[t]&&Kt[t][e]}});var An=u((Gh,wn)=>{"use strict";var $a=H();wn.exports=$a({}.isPrototypeOf)});var kn=u((zh,Pn)=>{"use strict";var _a=W(),Rn=_a.navigator,On=Rn&&Rn.userAgent;Pn.exports=On?String(On):""});var _n=u((Wh,$n)=>{"use strict";var jn=W(),Qt=kn(),Vn=jn.process,Mn=jn.Deno,Nn=Vn&&Vn.versions||Mn&&Mn.version,Ln=Nn&&Nn.v8,U,it;Ln&&(U=Ln.split("."),it=U[0]>0&&U[0]<4?1:+(U[0]+U[1]));!it&&Qt&&(U=Qt.match(/Edge\/(\d+)/),(!U||U[1]>=74)&&(U=Qt.match(/Chrome\/(\d+)/),U&&(it=+U[1])));$n.exports=it});var Xt=u((Kh,qn)=>{"use strict";var Fn=_n(),Fa=$(),qa=W(),Ba=qa.String;qn.exports=!!Object.getOwnPropertySymbols&&!Fa(function(){var t=Symbol("symbol detection");return!Ba(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&Fn&&Fn<41})});var Yt=u((Qh,Bn)=>{"use strict";var Da=Xt();Bn.exports=Da&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Zt=u((Xh,Dn)=>{"use strict";var Ha=nt(),Ua=_(),Ga=An(),za=Yt(),Wa=Object;Dn.exports=za?function(t){return typeof t=="symbol"}:function(t){var e=Ha("Symbol");return Ua(e)&&Ga(e.prototype,Wa(t))}});var Un=u((Yh,Hn)=>{"use strict";var Ka=String;Hn.exports=function(t){try{return Ka(t)}catch{return"Object"}}});var Jt=u((Zh,Gn)=>{"use strict";var Qa=_(),Xa=Un(),Ya=TypeError;Gn.exports=function(t){if(Qa(t))return t;throw new Ya(Xa(t)+" is not a function")}});var Wn=u((Jh,zn)=>{"use strict";var Za=Jt(),Ja=Gt();zn.exports=function(t,e){var r=t[e];return Ja(r)?void 0:Za(r)}});var Qn=u((ed,Kn)=>{"use strict";var er=tt(),tr=_(),rr=le(),ec=TypeError;Kn.exports=function(t,e){var r,n;if(e==="string"&&tr(r=t.toString)&&!rr(n=er(r,t))||tr(r=t.valueOf)&&!rr(n=er(r,t))||e!=="string"&&tr(r=t.toString)&&!rr(n=er(r,t)))return n;throw new ec("Can't convert object to primitive value")}});var Yn=u((td,Xn)=>{"use strict";Xn.exports=!0});var ei=u((rd,Jn)=>{"use strict";var Zn=W(),tc=Object.defineProperty;Jn.exports=function(t,e){try{tc(Zn,t,{value:e,configurable:!0,writable:!0})}catch{Zn[t]=e}return e}});var st=u((nd,ni)=>{"use strict";var rc=Yn(),nc=W(),ic=ei(),ti="__core-js_shared__",ri=ni.exports=nc[ti]||ic(ti,{});(ri.versions||(ri.versions=[])).push({version:"3.38.0",mode:rc?"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 nr=u((id,si)=>{"use strict";var ii=st();si.exports=function(t,e){return ii[t]||(ii[t]=e||{})}});var Ie=u((sd,oi)=>{"use strict";var sc=zt(),oc=Object;oi.exports=function(t){return oc(sc(t))}});var pe=u((od,ai)=>{"use strict";var ac=H(),cc=Ie(),lc=ac({}.hasOwnProperty);ai.exports=Object.hasOwn||function(e,r){return lc(cc(e),r)}});var ir=u((ad,ci)=>{"use strict";var pc=H(),uc=0,hc=Math.random(),dc=pc(1 .toString);ci.exports=function(t){return"Symbol("+(t===void 0?"":t)+")_"+dc(++uc+hc,36)}});var Te=u((cd,pi)=>{"use strict";var mc=W(),fc=nr(),li=pe(),vc=ir(),yc=Xt(),bc=Yt(),ue=mc.Symbol,sr=fc("wks"),Cc=bc?ue.for||ue:ue&&ue.withoutSetter||vc;pi.exports=function(t){return li(sr,t)||(sr[t]=yc&&li(ue,t)?ue[t]:Cc("Symbol."+t)),sr[t]}});var mi=u((ld,di)=>{"use strict";var gc=tt(),ui=le(),hi=Zt(),Ec=Wn(),Ic=Qn(),Tc=Te(),xc=TypeError,Sc=Tc("toPrimitive");di.exports=function(t,e){if(!ui(t)||hi(t))return t;var r=Ec(t,Sc),n;if(r){if(e===void 0&&(e="default"),n=gc(r,t,e),!ui(n)||hi(n))return n;throw new xc("Can't convert object to primitive value")}return e===void 0&&(e="number"),Ic(t,e)}});var or=u((pd,fi)=>{"use strict";var wc=mi(),Ac=Zt();fi.exports=function(t){var e=wc(t,"string");return Ac(e)?e:e+""}});var bi=u((ud,yi)=>{"use strict";var Rc=W(),vi=le(),ar=Rc.document,Oc=vi(ar)&&vi(ar.createElement);yi.exports=function(t){return Oc?ar.createElement(t):{}}});var cr=u((hd,Ci)=>{"use strict";var Pc=Z(),kc=$(),Vc=bi();Ci.exports=!Pc&&!kc(function(){return Object.defineProperty(Vc("div"),"a",{get:function(){return 7}}).a!==7})});var Ii=u(Ei=>{"use strict";var Mc=Z(),Nc=tt(),Lc=Dt(),jc=Ht(),$c=Ee(),_c=or(),Fc=pe(),qc=cr(),gi=Object.getOwnPropertyDescriptor;Ei.f=Mc?gi:function(e,r){if(e=$c(e),r=_c(r),qc)try{return gi(e,r)}catch{}if(Fc(e,r))return jc(!Nc(Lc.f,e,r),e[r])}});var xi=u((md,Ti)=>{"use strict";var Bc=$(),Dc=_(),Hc=/#|\.prototype\./,xe=function(t,e){var r=Gc[Uc(t)];return r===Wc?!0:r===zc?!1:Dc(e)?Bc(e):!!e},Uc=xe.normalize=function(t){return String(t).replace(Hc,".").toLowerCase()},Gc=xe.data={},zc=xe.NATIVE="N",Wc=xe.POLYFILL="P";Ti.exports=xe});var lr=u((fd,wi)=>{"use strict";var Si=qt(),Kc=Jt(),Qc=Ce(),Xc=Si(Si.bind);wi.exports=function(t,e){return Kc(t),e===void 0?t:Qc?Xc(t,e):function(){return t.apply(e,arguments)}}});var Ri=u((vd,Ai)=>{"use strict";var Yc=Z(),Zc=$();Ai.exports=Yc&&Zc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Pi=u((yd,Oi)=>{"use strict";var Jc=le(),el=String,tl=TypeError;Oi.exports=function(t){if(Jc(t))return t;throw new tl(el(t)+" is not an object")}});var Mi=u(Vi=>{"use strict";var rl=Z(),nl=cr(),il=Ri(),ot=Pi(),ki=or(),sl=TypeError,pr=Object.defineProperty,ol=Object.getOwnPropertyDescriptor,ur="enumerable",hr="configurable",dr="writable";Vi.f=rl?il?function(e,r,n){if(ot(e),r=ki(r),ot(n),typeof e=="function"&&r==="prototype"&&"value"in n&&dr in n&&!n[dr]){var i=ol(e,r);i&&i[dr]&&(e[r]=n.value,n={configurable:hr in n?n[hr]:i[hr],enumerable:ur in n?n[ur]:i[ur],writable:!1})}return pr(e,r,n)}:pr:function(e,r,n){if(ot(e),r=ki(r),ot(n),nl)try{return pr(e,r,n)}catch{}if("get"in n||"set"in n)throw new sl("Accessors not supported");return"value"in n&&(e[r]=n.value),e}});var Li=u((Cd,Ni)=>{"use strict";var al=Z(),cl=Mi(),ll=Ht();Ni.exports=al?function(t,e,r){return cl.f(t,e,ll(1,r))}:function(t,e,r){return t[e]=r,t}});var we=u((gd,$i)=>{"use strict";var Se=W(),pl=rn(),ul=qt(),hl=_(),dl=Ii().f,ml=xi(),he=rt(),fl=lr(),de=Li(),ji=pe();st();var vl=function(t){var e=function(r,n,i){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,n)}return new t(r,n,i)}return pl(t,this,arguments)};return e.prototype=t.prototype,e};$i.exports=function(t,e){var r=t.target,n=t.global,i=t.stat,s=t.proto,c=n?Se:i?Se[r]:Se[r]&&Se[r].prototype,o=n?he:he[r]||de(he,r,{})[r],a=o.prototype,l,d,m,f,b,P,T,E,x;for(f in e)l=ml(n?f:r+(i?".":"#")+f,t.forced),d=!l&&c&&ji(c,f),P=o[f],d&&(t.dontCallGetSet?(x=dl(c,f),T=x&&x.value):T=c[f]),b=d&&T?T:e[f],!(!l&&!s&&typeof P==typeof b)&&(t.bind&&d?E=fl(b,Se):t.wrap&&d?E=vl(b):s&&hl(b)?E=ul(b):E=b,(t.sham||b&&b.sham||P&&P.sham)&&de(E,"sham",!0),de(o,f,E),s&&(m=r+"Prototype",ji(he,m)||de(he,m,{}),de(he[m],f,b),t.real&&a&&(l||!a[f])&&de(a,f,b)))}});var Fi=u((Ed,_i)=>{"use strict";var yl=Math.ceil,bl=Math.floor;_i.exports=Math.trunc||function(e){var r=+e;return(r>0?bl:yl)(r)}});var Ae=u((Id,qi)=>{"use strict";var Cl=Fi();qi.exports=function(t){var e=+t;return e!==e||e===0?0:Cl(e)}});var Di=u((Td,Bi)=>{"use strict";var gl=Ae(),El=Math.min;Bi.exports=function(t){var e=gl(t);return e>0?El(e,9007199254740991):0}});var Re=u((xd,Hi)=>{"use strict";var Il=Di();Hi.exports=function(t){return Il(t.length)}});var at=u((Sd,Ui)=>{"use strict";Ui.exports=function(){}});var Gi=u(()=>{"use strict";var Tl=we(),xl=Ie(),Sl=Re(),wl=Ae(),Al=at();Tl({target:"Array",proto:!0},{at:function(e){var r=xl(this),n=Sl(r),i=wl(e),s=i>=0?i:n+i;return s<0||s>=n?void 0:r[s]}});Al("at")});var ct=u((Rd,zi)=>{"use strict";var Rl=nt();zi.exports=Rl});var Ki=u((Od,Wi)=>{"use strict";Gi();var Ol=ct();Wi.exports=Ol("Array","at")});var Xi=u((Pd,Qi)=>{"use strict";var Pl=Ki();Qi.exports=Pl});var mr=u((kd,Yi)=>{"use strict";var kl=Xi();Yi.exports=kl});var hs=u((km,us)=>{"use strict";var Ul=nr(),Gl=ir(),ps=Ul("keys");us.exports=function(t){return ps[t]||(ps[t]=Gl(t))}});var ms=u((Vm,ds)=>{"use strict";var zl=$();ds.exports=!zl(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})});var ys=u((Mm,vs)=>{"use strict";var Wl=pe(),Kl=_(),Ql=Ie(),Xl=hs(),Yl=ms(),fs=Xl("IE_PROTO"),Sr=Object,Zl=Sr.prototype;vs.exports=Yl?Sr.getPrototypeOf:function(t){var e=Ql(t);if(Wl(e,fs))return e[fs];var r=e.constructor;return Kl(r)&&e instanceof r?r.prototype:e instanceof Sr?Zl:null}});var Cs=u((Nm,bs)=>{"use strict";var Jl=Ae(),ep=Math.max,tp=Math.min;bs.exports=function(t,e){var r=Jl(t);return r<0?ep(r+e,0):tp(r,e)}});var wr=u((Lm,Es)=>{"use strict";var rp=Ee(),np=Cs(),ip=Re(),gs=function(t){return function(e,r,n){var i=rp(e),s=ip(i);if(s===0)return!t&&-1;var c=np(n,s),o;if(t&&r!==r){for(;s>c;)if(o=i[c++],o!==o)return!0}else for(;s>c;c++)if((t||c in i)&&i[c]===r)return t||c||0;return!t&&-1}};Es.exports={includes:gs(!0),indexOf:gs(!1)}});var Ts=u((jm,Is)=>{"use strict";Is.exports={}});var ws=u(($m,Ss)=>{"use strict";var sp=H(),Ar=pe(),op=Ee(),ap=wr().indexOf,cp=Ts(),xs=sp([].push);Ss.exports=function(t,e){var r=op(t),n=0,i=[],s;for(s in r)!Ar(cp,s)&&Ar(r,s)&&xs(i,s);for(;e.length>n;)Ar(r,s=e[n++])&&(~ap(i,s)||xs(i,s));return i}});var Rs=u((_m,As)=>{"use strict";As.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Ps=u((Fm,Os)=>{"use strict";var lp=ws(),pp=Rs();Os.exports=Object.keys||function(e){return lp(e,pp)}});var js=u((qm,Ls)=>{"use strict";var Vs=Z(),up=$(),Ms=H(),hp=ys(),dp=Ps(),mp=Ee(),fp=Dt().f,Ns=Ms(fp),vp=Ms([].push),yp=Vs&&up(function(){var t=Object.create(null);return t[2]=2,!Ns(t,2)}),ks=function(t){return function(e){for(var r=mp(e),n=dp(r),i=yp&&hp(r)===null,s=n.length,c=0,o=[],a;s>c;)a=n[c++],(!Vs||(i?a in r:Ns(r,a)))&&vp(o,t?[a,r[a]]:r[a]);return o}};Ls.exports={entries:ks(!0),values:ks(!1)}});var $s=u(()=>{"use strict";var bp=we(),Cp=js().values;bp({target:"Object",stat:!0},{values:function(e){return Cp(e)}})});var Fs=u((Hm,_s)=>{"use strict";$s();var gp=rt();_s.exports=gp.Object.values});var Bs=u((Um,qs)=>{"use strict";var Ep=Fs();qs.exports=Ep});var Et=u((Gm,Ds)=>{"use strict";var Ip=Bs();Ds.exports=Ip});var Gs=u(()=>{"use strict";var Tp=we(),xp=wr().includes,Sp=$(),wp=at(),Ap=Sp(function(){return!Array(1).includes()});Tp({target:"Array",proto:!0,forced:Ap},{includes:function(e){return xp(this,e,arguments.length>1?arguments[1]:void 0)}});wp("includes")});var Ws=u((Xm,zs)=>{"use strict";Gs();var Rp=ct();zs.exports=Rp("Array","includes")});var Qs=u((Ym,Ks)=>{"use strict";var Op=Ws();Ks.exports=Op});var It=u((Zm,Xs)=>{"use strict";var Pp=Qs();Xs.exports=Pp});var kr=u((mf,no)=>{"use strict";var Vp=ge();no.exports=Array.isArray||function(e){return Vp(e)==="Array"}});var so=u((ff,io)=>{"use strict";var Mp=TypeError,Np=9007199254740991;io.exports=function(t){if(t>Np)throw Mp("Maximum allowed index exceeded");return t}});var co=u((vf,ao)=>{"use strict";var Lp=kr(),jp=Re(),$p=so(),_p=lr(),oo=function(t,e,r,n,i,s,c,o){for(var a=i,l=0,d=c?_p(c,o):!1,m,f;l<n;)l in r&&(m=d?d(r[l],l,e):r[l],s>0&&Lp(m)?(f=jp(m),a=oo(t,e,m,f,a,s-1)-1):($p(a+1),t[a]=m),a++),l++;return a};ao.exports=oo});var uo=u((yf,po)=>{"use strict";var Fp=Te(),qp=Fp("toStringTag"),lo={};lo[qp]="z";po.exports=String(lo)==="[object z]"});var mo=u((bf,ho)=>{"use strict";var Bp=uo(),Dp=_(),xt=ge(),Hp=Te(),Up=Hp("toStringTag"),Gp=Object,zp=xt(function(){return arguments}())==="Arguments",Wp=function(t,e){try{return t[e]}catch{}};ho.exports=Bp?xt:function(t){var e,r,n;return t===void 0?"Undefined":t===null?"Null":typeof(r=Wp(e=Gp(t),Up))=="string"?r:zp?xt(e):(n=xt(e))==="Object"&&Dp(e.callee)?"Arguments":n}});var vo=u((Cf,fo)=>{"use strict";var Kp=H(),Qp=_(),Vr=st(),Xp=Kp(Function.toString);Qp(Vr.inspectSource)||(Vr.inspectSource=function(t){return Xp(t)});fo.exports=Vr.inspectSource});var Io=u((gf,Eo)=>{"use strict";var Yp=H(),Zp=$(),yo=_(),Jp=mo(),eu=nt(),tu=vo(),bo=function(){},Co=eu("Reflect","construct"),Mr=/^\s*(?:class|function)\b/,ru=Yp(Mr.exec),nu=!Mr.test(bo),qe=function(e){if(!yo(e))return!1;try{return Co(bo,[],e),!0}catch{return!1}},go=function(e){if(!yo(e))return!1;switch(Jp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return nu||!!ru(Mr,tu(e))}catch{return!0}};go.sham=!0;Eo.exports=!Co||Zp(function(){var t;return qe(qe.call)||!qe(Object)||!qe(function(){t=!0})||t})?go:qe});var wo=u((Ef,So)=>{"use strict";var To=kr(),iu=Io(),su=le(),ou=Te(),au=ou("species"),xo=Array;So.exports=function(t){var e;return To(t)&&(e=t.constructor,iu(e)&&(e===xo||To(e.prototype))?e=void 0:su(e)&&(e=e[au],e===null&&(e=void 0))),e===void 0?xo:e}});var Ro=u((If,Ao)=>{"use strict";var cu=wo();Ao.exports=function(t,e){return new(cu(t))(e===0?0:e)}});var Oo=u(()=>{"use strict";var lu=we(),pu=co(),uu=Ie(),hu=Re(),du=Ae(),mu=Ro();lu({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,r=uu(this),n=hu(r),i=mu(r,0);return i.length=pu(i,r,r,n,0,e===void 0?1:du(e)),i}})});var Po=u(()=>{"use strict";var fu=at();fu("flat")});var Vo=u((Af,ko)=>{"use strict";Oo();Po();var vu=ct();ko.exports=vu("Array","flat")});var No=u((Rf,Mo)=>{"use strict";var yu=Vo();Mo.exports=yu});var jo=u((Of,Lo)=>{"use strict";var bu=No();Lo.exports=bu});var Ou={};fa(Ou,{ContainerTypes:()=>y.ContainerTypes,ControlTypes:()=>y.ControlTypes,CustomError:()=>M,EVENT_NAMES:()=>w,EventActionTypes:()=>y.EventActionTypes,EventTypes:()=>y.EventTypes,Interactives:()=>De,ManifestController:()=>ne,SDKInfo:()=>Ru,chapterIdsToVKVideoIds:()=>wt,compareVersions:()=>bt,containerTypes:()=>Ll,controlTypes:()=>jl,eventActionTypes:()=>br,eventTypes:()=>$l,getChapterIdByVkVideoId:()=>ra,getVKVideoIdByMedia:()=>jr,getVideoRawIdByMedia:()=>ea,graphEventTypes:()=>ve,hasEndTemplate:()=>_e,interactivesEventTypes:()=>O,isAreaControl:()=>Nl,isButtonControl:()=>Ml,isLastChapter:()=>G,isOneTextCtrlContainer:()=>re,isSupportedManifest:()=>y.isSupportedManifest,isTextControl:()=>Ne,isVKVariantItem:()=>ta,isValidManifest:()=>yr,migrateManifestToLatestVersion:()=>y.migrateManifestToLatestVersion,utils:()=>ca,vkVideoIdsToChapterIds:()=>$r});module.exports=va(Ou);var Br="1.0.34-dev.3bb5d797.0";var Pt=class{constructor(e){this.layout=e}},Ge=class extends Pt{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,r){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${r.width})`,e.style.height=`calc(var(--interactive-content-height) * ${r.height})`,e.style.left=`calc(var(--interactive-content-width) * ${r.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${r.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};function Dr(t){return"features"in t}var oe=class{constructor(e,r){this.container=e,this.options=r,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&Dr(this.options)&&this.options.features[e]}addControlFactory(e,r){this.factories.set(e.trim().toLowerCase(),r),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){return this.container.controls?.reduce((e,r)=>{let n=r.type.trim().toLowerCase(),i=this.factories.get(n);if(i){let s=i(r,this.options);if(s)return[...e,s]}return[...e]},[])||[]}};function kt(t,e=1){let r="0",n="0",i="0";return t.length===4?(r="0x"+t[1]+t[1],n="0x"+t[2]+t[2],i="0x"+t[3]+t[3]):t.length===7&&(r="0x"+t[1]+t[2],n="0x"+t[3]+t[4],i="0x"+t[5]+t[6]),`rgba(${+r},${+n},${+i},${e})`}var Hr="interactive",L={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},Ur=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(Ur||{}),Gr=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(Gr||{}),zr=(n=>(n.start="left",n.end="right",n.center="center",n))(zr||{}),ze=({target:t,props:e})=>{t.style.alignItems=(e?.gravityVertical&&Ur[e.gravityVertical])??"center",t.style.justifyContent=(e?.gravityHorizontal&&Gr[e.gravityHorizontal])??"center",t.style.textAlign=(e?.alignment&&zr[e.alignment])??"center"},We=({target:t,props:e,fallback:r,dependsOn:n})=>{t.style.color=e?.text?.color??r.textColor,t.style.fontSize=`calc(${n.height} * ${e?.text?.size??r.textSize})`,t.textContent=e?.text?.value??r.textContent},Ke=({target:t,props:e,fallback:r})=>{t.style.backgroundColor=kt(e?.background?.color??r.backgroundColor,e?.background?.alpha??r.backgroundAlpha)},Qe=({target:t,props:e,fallback:r,dependsOn:n})=>{t.style.border=`calc(${n.height} * ${e?.shape?.border?.width??r.borderWidth}) solid ${kt(e?.shape?.border?.color??r.borderColor,e?.shape?.border?.alpha??r.borderAlpha)}`,t.style.borderRadius=`calc(${n.height} * ${e?.shape?.roundCorners??r.roundCorners})`},ae=({target:t,layoutParams:e,fallback:r})=>{let n=e.angle??r.angle;n=n&&n*-1,t.style.transform=`rotate(${n}rad)`};var Vt="int",Y=(n=>(n.AREA=`${Vt}_area`,n.TEXT=`${Vt}_text`,n.BUTTON=`${Vt}_bttn`,n))(Y||{});function Wr(t){return"features"in t}var ce="interactive-control",k={common:ce,wrapper:`${ce}-wrapper`,disabled:`${ce}-disabled`,button:`${ce}-button`,area:`${ce}-area`,text:`${ce}-text`};var Q=class{constructor(e,r){this.control=e;this.options=r;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){let r=document.createElement("div");r.classList.add(k.wrapper),e.setControlLayout(r,this.control.layoutParams);let n=(this.control.layoutParams.innerSizesDependOn??L.innerSizesDependOn)==="self"?{height:r.style.height,width:r.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:r,dimensions:n}}createClickListener(e){return r=>{r.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&Wr(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(r=>{switch(r.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:r.action,controlId:this.control.id,controlType:this.control.type})),this.container?.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){this.container?.element&&this.clickListener&&this.container?.element.removeEventListener("click",this.clickListener)}};var Xe=(t,e)=>{if(t.type.trim().toLowerCase()==="area")return new Mt(t,e)},Mt=class extends Q{constructor(e,r){super(e,r)}createView({parentElement:e,callbacks:r}){if(super.createContainerElement(r),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(k.common,k.area),n.setAttribute("data-testid",Y.AREA),Ke({target:n,props:this.control.props,fallback:{...L,backgroundColor:"transparent"}}),Qe({target:n,props:this.control.props,fallback:{...L,borderAlpha:0},dependsOn:this.container.dimensions}),ae({target:n,layoutParams:this.control.layoutParams,fallback:L}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(k.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(k.disabled)}getElement(){return this.controlElement}onProgress(){}onResize(){}};var Ye=t=>{let e=document.createElement("span");switch(t){case"Button":case"button":{let r=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(r.style,n),r.append(e);let i={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,i),r}default:{let r={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,r),e}}};var Ze=(t,e)=>{if(t.type.trim().toLowerCase()==="button")return new Nt(t,e)},Nt=class extends Q{constructor(e,r){super(e,r)}createView({parentElement:e,callbacks:r}){if(super.createContainerElement(r),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(k.common,k.button),n.setAttribute("data-testid",Y.BUTTON),ae({target:n,layoutParams:this.control.layoutParams,fallback:L}),Ke({target:n,props:this.control.props,fallback:L}),Qe({target:n,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),ze({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=Ye(this.control.type.trim().toLowerCase()),s=i.firstElementChild??i;We({target:s,props:this.control.props,fallback:L,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(k.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(k.disabled)}getElement(){return this.controlElement}onProgress(){}onResize(){}};var Kr=(t,e)=>{if(t.type.trim().toLowerCase()==="text")return new Lt(t,e)},Lt=class extends Q{constructor(e,r){super(e,r)}createView({parentElement:e,callbacks:r}){if(super.createContainerElement(r),!this.container)return;let n=document.createElement("div");n.classList.add(k.common,k.text),n.setAttribute("data-testid",Y.TEXT),ae({target:n,layoutParams:this.control.layoutParams,fallback:L}),ze({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=Ye(this.control.type.trim().toLowerCase()),s=i.firstElementChild??i;We({target:s,props:this.control.props,fallback:L,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(){}};var jt="interactive-container",j={common:jt,hidden:`${jt}-hidden`,disabled:`${jt}-disabled`};var Je=(t,e,r)=>{if(t.type.trim().toLowerCase()==="choice")return new $t(t,e,r)},$t=class extends oe{constructor(r,n,i){super(r,i);this.containerElement=null;this.rootElement=n,this.layout=new Ge(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Ze),this.addControlFactory("text",Kr),this.addControlFactory("area",Xe)}createView({eventCallback:r}){let n=document.createElement("div");return n.classList.add(j.common,j.disabled),requestAnimationFrame(()=>{n.classList.remove(j.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(i=>{i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),i.setEvents(r)}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let r=this.getElement();r&&r.classList.add(j.hidden)}show(){let r=this.getElement();r&&r.classList.remove(j.hidden)}enable(){let r=this.getElement();r&&(r.classList.remove(j.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let r=this.getElement();r&&(r.classList.add(j.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let r=this.getElement();r&&(this.controls.forEach(n=>n.removeListeners()),r.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(r,n){n&&this.controls.forEach(i=>{i.onProgress(r)})}onResize(r){r&&this.controls.forEach(n=>{n.onResize()})}};var oa=z(mr(),1),g=require("@vkontakte/videoplayer-shared"),ye=require("@vkontakte/videoplayer-statistics");var rs=require("@vkontakte/videoplayer-shared");function Oe(t,e){let r;return(...n)=>{clearTimeout(r),r=setTimeout(()=>t(...n),e)}}var J=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,Pe=t=>J(t,"Object"),lt=t=>J(t,"String"),pt=t=>J(t,"Array"),ut=t=>J(t,"Number"),Zi=t=>J(t,"Function");var fr=t=>ut(t)&&!isNaN(t);var ee=t=>Pe(t)&&Object.keys(t).length===0,vr=t=>pt(t)&&!t.length;var ke=(t,e)=>lt(t)&&(e?t.trim():t).length;var Ji="video_interactive",es="videoint";var ts=250,Ve=class{constructor(e){this.handleZoomChange=Oe(e=>{this.lastZoomInfo=e},ts);this.onResize=e=>{if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let r=this.getNextPoint();r&&this.ngEditor?.zoomTo(r),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,r=[])=>{if(this.isReady=!1,!ut(e.graph.edit.chapters[0].x)){this.onError?.("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(r),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(r)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:r,onError:n,lang:i,visitedChapters:s=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=r,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=Vl(e),this.resizeObserver=new ResizeObserver(Oe(this.onResize,ts)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor?.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor?.updateVideosInfo(e)}async show(){this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&this.ngEditor?.focusChapter(this.currentChapterId),this.isHidden=!1)}async initNgEditor(){if(!this.manifest)return;let e;try{e=await(0,rs.loadVKLangPack)(this.lang,Ji,es)}catch{this.onError?.("Unable to load graph language pack")}let{GraphEditor:r}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new r(this.graphWrapperElement,{mode:"read",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 Vl(t){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",t.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(r=>r.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let r=-1,n=!1,i=Math.round(this._player.info.position$.getValue()*1e3);for(let s of this._containers){let c=s.startTime-e;if(c<=i&&(s.endTime&&i<=s.endTime||s.endTime===null)){n=!0;break}i<c&&(r=r===-1?c:Math.min(r,c))}return!n&&r!==-1?r:null}}};var y=require("@interactiveplatform/movika-manifest");var ns={metadata:"Object",chapters:"Array"},yr=t=>{if(!Pe(t))return!1;for(let e in ns)if(!t[e]||!J(t[e],ns[e]))return!1;return(0,y.isSupportedManifest)(t.metadata.version)},Ne=t=>t.type===y.ControlTypes.Text,Ml=t=>t.type===y.ControlTypes.Button,Nl=t=>t.type===y.ControlTypes.Area,Ll={Choice:"Choice",TextInput:"TextInput"},jl={Button:"Button",Area:"Area",Text:"Text"},$l={onClick:"onClick",onSuspense:"onSuspense"},br={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var M=class{constructor(e,r,...n){this.severity=e;this.category=r;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var ht=class{constructor(){this.listeners={}}addListener(e,r){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(r),this}on(e,r){return this.addListener(e,r)}once(e,r){this.listeners[e]=this.listeners[e]||[];let n=()=>{r(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,r){return this.removeListener(e,r)}reset(){this.listeners={}}removeListener(e,r){let n=this.listeners[e]||[];for(let i=n.length;i>0;i--)if(n[i]===r){n.splice(i,1);break}return this}emit(e,...r){let n=this.listeners[e];return n?(n.forEach(i=>{i(...r)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var dt=class{constructor(e){this.fns=[];this.addFn=(e,r=!1)=>{Zi(e)&&(this.fns.push(e),r&&this.updateFn())};this.removeFn=(e,r=!1)=>{this.fns=this.fns.filter(n=>n!==e),r&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var ls=require("@vkontakte/videoplayer-shared");var mt=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,r){return _l(...this.loaders[e])(r)}};function _l(...t){return async function(r){let n=[...t];for(;n.length>0;)r=await n.shift()(r);return r}}function Le(t,e,r){return t?{...t,[e]:t[e]?[r,...t[e]]:[r]}:{[e]:[r]}}function ft({actions:t,errors:e,chapterId:r,...n}){if(r){let i=t.getManifest();if(i){let s=t.getChapter(i.chapters,r);if(s){let c=t.getMedia(i.media,s.videoId),o=t.getGraph(i.graph,s.id);return c?{...n,actions:t,errors:e,result:{chapter:s,media:c,graph:o}}:{...n,errors:Le(e,ft.name,"Could not find media"),actions:t}}}}return{...n,errors:Le(e,ft.name,"Could not find chapter"),actions:t}}var vt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,r,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:r,options:n})}removeEventListener(e,r){if(!(e in this.listeners))return;let n=this.listeners[e];for(let i=0,s=n.length;i<s;i++)if(n[i].callback===r){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,s=n.length;i<s;i++){let c=n[i];try{c.callback.call(this,e)}catch(o){Promise.resolve().then(()=>{throw o})}c.options&&c.options.once&&this.removeEventListener(e.type,c.callback)}return!e.defaultPrevented}},me=class extends vt{constructor(){super(),this.listeners||vt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},je=class{constructor(){Object.defineProperty(this,"signal",{value:new me,writable:!0,configurable:!0})}abort(e){let r;try{r=new Event("abort")}catch{typeof document<"u"?document.createEvent?(r=document.createEvent("Event"),r.initEvent("abort",!1,!1)):(r=document.createEventObject(),r.type="abort"):r={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(r)}toString(){return"[object AbortController]"}};typeof Symbol<"u"&&Symbol.toStringTag&&(je.prototype[Symbol.toStringTag]="AbortController",me.prototype[Symbol.toStringTag]="AbortSignal");function yt(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof t.Request=="function"&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}function Cr(t){typeof t=="function"&&(t={fetch:t});let{fetch:e,Request:r=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=t;if(!yt({fetch:e,Request:r,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:e,Request:s};let s=r;(s&&!s.prototype.hasOwnProperty("signal")||i)&&(s=function(l,d){let m;d&&d.signal&&(m=d.signal,delete d.signal);let f=new r(l,d);return m&&Object.defineProperty(f,"signal",{writable:!1,enumerable:!1,configurable:!0,value:m}),f},s.prototype=r.prototype);let c=e;return{fetch:(a,l)=>{let d=s&&s.prototype.isPrototypeOf(a)?a.signal:l?l.signal:void 0;if(d){let m;try{m=new DOMException("Aborted","AbortError")}catch{m=new Error("Aborted"),m.name="AbortError"}if(d.aborted)return Promise.reject(m);let f=new Promise((b,P)=>{d.addEventListener("abort",()=>P(m),{once:!0})});return l&&l.signal&&delete l.signal,Promise.race([f,c(a,l)])}return c(a,l)},Request:s}}var $e=yt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),is=$e?Cr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,gr=$e?is.fetch:window.fetch,hm=$e?is.Request:window.Request,dm=$e?je:window.AbortController,mm=$e?me:window.AbortSignal;var bt=(t="",e="")=>{let r=t.split("."),n=e.split("."),i=0;for(let s=0;s<Math.max(r.length,n.length)&&!i;s++)r[s]>n[s]?i=1:r[s]<n[s]?i=-1:i=0;return i};var Fl=async t=>{try{let e={},r;if(lt(t)){r=new URL(t).href;let i=await gr(r);if(!i.ok)return{};e=await i.json()}else if(Pe(t))e=t;else return{};if(!yr(e))return{};let n=e.metadata.media;if(lt(n)&&!("media"in e))try{let i;r?i=new URL(n,r).href:(i=new URL(n).href,r=i);let s=await gr(i);if(!s.ok)throw new Error;e.metadata.media=await s.json()}catch{return Dl(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:r}}catch{return{}}};async function ss(t){let{manifest:e,manifestURL:r}=await Fl(t);if(!e)throw new Error("Failed on fetch");let n=(0,y.migrateManifestToLatestVersion)(e);return n.media=ql(n.media,r),delete n.metadata.media,n}function Ct(t,e){if(e)return t.find(r=>r.id===e)}function Er(t,e){return t.edit?.chapters?t.edit.chapters.find(r=>r.id===e):t.view?.chapters?t.view.chapters.find(r=>r.id===e):void 0}function Ir(t,e){return t.videos.find(r=>r.id===e)}function ql(t,e){return{...t,videos:t.videos.map(r=>({...r,variants:r.variants.map(n=>{let i="url"in n?n.url:"",s=Bl(i,e);return{...n,url:s||i}})}))}}function Bl(t="",e){try{return new URL(t,e).href}catch{return""}}function Dl(t){return bt(t,"3.2.0")>=0}var gt=t=>pt(t)&&!vr(t),G=t=>t.order==="end",_e=t=>pt(t.containers)&&!vr(t.containers)&&G(t),os=(t,e)=>{let r=t*1e3;return gt(e.controls)&&r<(e.startTime??0)},Tr=(t,e)=>{let r=t*1e3;return gt(e.controls)&&r>=(e.startTime??0)&&r<=(e.endTime??1/0)};var te=(t=[])=>t.some(e=>e.action.type==="expect"),xr=(t=[])=>t.find(e=>e.action.type==="expect"),Hl=t=>t?.length===1,re=t=>Hl(t)&&Ne(t[0]);function as(t,...e){return r=>typeof e[0]=="object"&&typeof r=="object"?t({...e[0],...r}):t(...e,...r)}var cs=(t,e)=>{let r=T=>e.find(({container:x})=>x.container.id===T)?.container.isRemoved,n=te(t.events)&&!r(t.id),i=(T,E=!1,x=!1)=>{let h=x?"every":"some";return T.controls[h](p=>{let v=E?T.endTime===t.endTime:!0;return p.events?.[h](C=>C.action?.type===br.openURI)&&v})},s=T=>T.some(({container:E})=>i(E.container,!0,!1)&&!E.isRemoved),c=T=>T.every(({container:E})=>E.isRemoved?!0:i(E.container,!0,!0)),o=e.filter(({container:T})=>T.container.id!==t.id&&te(T.container.events)&&T.container.endTime===t.endTime&&!T.isRemoved).length,a=T=>T.controls.some(E=>E.events?.some(x=>x.action?.args?.shouldOpenNow)),l=n||o>0,d=s(e),m=i(t),f=c(e),b=n?!1:o>0,P=a(t);return{isExpectTime:l,hasOtherExpect:o>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:f,isExpectEventForCurrentContainer:b,hasShouldOpenNowEvent:P}};var ne=class extends mt{constructor(r,n){super(r);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new ls.ValueSubject(null);this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(r){this.release();let n=await this.exec("manifestLoaders",{actions:{addErrorMessage:Le},result:null,errors:null,source:r});return n.errors&&this.errorHandler(n.errors),this.manifest=await ss(n.result??r),this}async setInitial(){return this.setNext()}async setNext(r=this.manifest?.metadata.initChapterId){if(!r)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",ft({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Er,getChapter:Ct,getMedia:Ir,getByBranches:this.getByBranches.bind(this),addErrorMessage:Le},result:null,errors:null,chapterId:r}));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(r){this.onError(r),console.error("Something went wrong with loaders",{errors:r})}getInitial(){return this.getByChapterId(this.manifest?.metadata.initChapterId)||null}getByChapterId(r=this.manifest?.metadata.initChapterId){if(!r||!this.manifest)return null;let n=Ct(this.manifest.chapters,r);if(n){let i=Ir(this.manifest.media,n.videoId),s=Er(this.manifest.graph,n.id);if(i)return{chapter:n,media:i,graph:s}}return null}getBranches(r=this.chapter?.id){if(r===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let n=Ct(this.manifest?.chapters||[],r);return this.getByBranches(n?.branches)}}getByBranches(r=[]){return r.reduce((n,i)=>{let s=this.getByChapterId(i.chapterId);return s&&n.push(s),n},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter?.id===this.manifest?.metadata.initChapterId}isEndChapter(){return this.chapter?G(this.chapter):!1}};var Ys=z(Et(),1),Zs=require("@vkontakte/videoplayer-core"),X=require("@vkontakte/videoplayer-shared");var Hs=t=>{let e=t.variants.find(r=>r.payload?.type==="vk");if(e&&e.payload){let[r,n]=e.payload.id.split("_");return[r,n]}return[]};var Us=z(Et(),1);function Rr(){let t=new Map;function e({listId:s=Math.random().toString(),itemId:c=Math.random().toString(),...o}){let a=t.get(s),l={...o};return a?a[c]=l:t.set(s,{[c]:l}),{listId:s,itemId:c,...o}}function r(s){s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),s.statistics?.oneStat.destroy(),s.statistics?.statSubscription.unsubscribe()}function n(s,c){let o=t.get(s);if(!o)throw Error("Can't remove. Not find.");if(c){let a=o[c];a&&r(a),delete o[c],Object.keys(o).length||t.delete(s)}else{for(let a of(0,Us.default)(o))r(a);t.delete(s)}}function i(){for(let s of t)n(s[0])}return{createPlayer:e,removePlayer:n,map:t,removeAll:i}}var fe=z(It(),1);function Or(t,e=[]){let r={},n,i=!e.length;for(let s of t.variants)if(!n&&"cover"in s&&(n=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(i||(0,fe.default)(e,"mp4"))&&(r.MPEG={...r.MPEG,[s.standard??"Invariant quality"]:s.url});break;case"mpeg":(i||(0,fe.default)(e,"mpeg"))&&(r.MPEG={...r.MPEG,[s.standard??"Invariant quality"]:s.url});break;case"hls":(i||(0,fe.default)(e,"hls"))&&(r={...r,HLS:{type:"url",url:s.url}});break;case"dash":(i||(0,fe.default)(e,"dash"))&&(r={...r,DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}});break;default:break}return{sources:r,thumbUrl:n,title:t.title??""}}var Fe=(t,e)=>{let r=t.info.currentQuality$.getValue(),n=t.info.availableQualities$.getValue();r!==e&&(0,fe.default)(n,e)&&(t.setQuality(e),t.setAutoQuality(!1))};var kp=2;function Pr(t){let e=Rr(),r=new X.Subscription,n={},i=null,s=!1,c,o=new X.ValueSubject(null);t&&a(t);function a(E){i=E}function l(E,x,h){if(!i)throw Error("need to set interactive controller");if(!i.options)return;let v=(e.map.get(E)??{})[x];if(v){n={chapterId:h,listId:E,itemId:x,...v};let C=n.player;n.subscription.add(C.info.currentQuality$.subscribe(I=>{let S=C.info.position$.getValue(),R=C.info.isAutoQualityEnabled$.getValue();if(!(!I||!S||R))for(let V of e.map)(0,Ys.default)(V[1]).forEach(({player:A})=>{Fe(A,I)})})).add(C.events.started$.subscribe(()=>{d(x)})),v.container.remove(),i.setPlayer(v.player),s||(i.init(),s=!0),o.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}async function d(E){if(!i)throw Error("need to set interactive controller");if(ee(n)||E!==n.itemId)return;let x=i.getChapterBranches(),h=new Set;for(let p of x)h.has(p.media.id)||(await f({media:p.media,chapterId:p.chapter.id,setAsActive:!1,title:p.chapter.label}),h.add(p.media.id))}async function m({chapter:{id:E},manifestVideo:x}){if(ee(n)||!i)return;let h=n.player.info.muted$.getValue(),p=n.player.info.currentQuality$.getValue(),v=n.player.info.isAutoQualityEnabled$.getValue(),C=n.player.info.volume$.getValue(),I=n.player.info.currentPlaybackRate$.getValue(),S=!v,R=!1;for(let V of e.map)if(V[0]===x.id&&!i.state.isReplay$.getValue()){let A=Object.keys(V[1]);for(let N of A)N===n.itemId?(A.length<kp||(R=!0),e.removePlayer(V[0],N)):(R=!0,l(V[0],N,E),S?Fe(n.player,p):n.player.setAutoQuality(!0),n.player.setVolume(C),n.player.setMuted(h),n.player.setPlaybackRate(I))}else e.removePlayer(V[0]);R||(await f({media:x,chapterId:E,setAsActive:!0,playbackRate:I}),S?Fe(n.player,p):n.player.setAutoQuality(!0),n.player.setVolume(C),n.player.setMuted(h))}async function f({media:E,chapterId:x,prefetch:h=!0,setAsActive:p=!0,autoplay:v=!1,preferredExt:C,title:I,playbackRate:S}){let R=Math.random().toString(),V=document.createElement("div");c.append(V);let A;if(i?.options?.vkVideoLoader){let He=Hs(E);He.length&&(A=await i.options.vkVideoLoader(...He))}let N=i?.options?.coreConfig||void 0,q={...N,configName:[...N?.configName??[],"interactive"]},B={container:V,...A?.videos?.[0]||{sources:Or(E,C).sources},title:I,failoverHosts:A?.failoverHosts||[]},D=new Zs.Player(q,X.Tracer.createRootTracer());D.initVideo(B);let K=null;if(A?.videos&&i?.options.createOneStat){let He=A.videos[0],Ot=i.options.createOneStat(He),Fr=new X.Subscription;Ot&&(Fr.add(Ot.attachTo(D)),K={oneStat:Ot,statSubscription:Fr})}let ie=new X.Subscription,la=n?.player?.info.isAutoQualityEnabled$.getValue();ie.add(D.events.canplay$.subscribe(function(){la||Fe(D,n.player.info.currentQuality$.getValue()),S&&D.setPlaybackRate(S)}));let se=e.createPlayer({listId:E.id,itemId:R,player:D,container:V,sources:Or(E,C).sources,config:B,subscription:ie,statistics:K});return p&&l(E.id,se.itemId,x),v&&se.player.play(),h&&!v&&se.player.prepare(),{player:se.player,config:se.config,statistics:se.statistics}}function b(){P(),i=null,c.remove()}function P(){r.unsubscribe(),e.removeAll(),n={},s=!1}async function T(){if(!i)throw Error("need to set interactive controller");P(),c=document.createElement("div");let{media:E,chapter:x}=i.getCurrentChapter();E&&x?(r.add(i.events.chapterChanged$.subscribe(m)),await f({media:E,chapterId:x.id,title:x.label})):console.error("not found")}return{...e,init:T,setInteractiveController:a,createPlayer:f,removeAll:b,getActivePlayer:function(){return n},activePlayerChanged:o}}var w={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},ve={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},O={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var eo=z(It(),1),to=require("@vkontakte/videoplayer-shared");var Tt=class{constructor({player:e,container:r,branches:n,selectBranches:i,interactiveEvents:s,globalEvents:c,globalEventEmitter:o,getContainerEventState:a,permanentTextControls:l,interactiveTimeOpenUri:d,disabledControls$:m,onRemove:f}){this.hide=()=>{setTimeout(()=>{this.gameState!==4&&(te(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:r}=this.getContainerEventState();if(this.container.show?.(),this.interactiveTimeOpenUri&&r)return;this.emitContainerVisibilityEvent(!0,!1)}else{let r={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(i,s)=>{let{isExpectTime:c,hasOtherExpect:o,hasOpenURIEvent:a,hasOpenURIEventInCurrentContainer:l,isAllOpenURIEventsValid:d,hasShouldOpenNowEvent:m}=this.getContainerEventState(),f=this.interactiveTimeOpenUri&&!l,b=this.interactiveTimeOpenUri&&l;if((!this.interactiveTimeOpenUri||f)&&(this.isSelectedControlEvent=!0),i!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||f)){if(this.interactiveTimeOpenUri){let P=!o&&!d&&l;P&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:P})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&a&&this.gameState!==5){if(b){let T=((E,x,h,p)=>!E&&!x&&h||E&&!x&&h&&!p||E&&!x&&h&&p)(c,o,d,this.isSelectedContainerEvent);this.fakeRemoveView(T)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!c||!o||!m)&&(this.selectBranches.stopExpect(),s())}},isEOV:()=>this.gameState===4},n=as(this.selectBranches.onControlEvent,r);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,eo.default)(i,this.gameState)&&!this.isPermanentText)return;let s=this.player.getExactTime();if(os(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Tr(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let l=this.gameState;this.gameState=3,l===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:l}=this.getContainerEventState(),d=this.selectBranches.state.isExpect,m=this.interactiveTimeOpenUri&&l;if(m&&!d){let f=this.container.getElement();f&&(f.style.visibility!=="hidden"&&this.container.hide?.(),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!m&&this.removeView()}let c=Tr(s,this.container.container),o=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:o,currentTime:s,isInteractiveTime:c};this.container.onProgress(s*1e3,c),this.globalEventEmitter.emit(w.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=r,this.branches=n,this.selectBranches=i,this.subscription=new to.Subscription,this.player=e,this.interactiveEvents=s,this.getContainerEventState=a,this.isPermanentText=l&&re(r.container.controls),this.interactiveTimeOpenUri=d,this.disabledControls$=m,this.onRemove=f,this.globalEventEmitter=o,this.gameState=0,this.globalEvents=c,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,r=!1){e?(this.globalEventEmitter.emit(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:O.visibility,visibility:e,isFirst:r}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:r})):(this.globalEventEmitter.emit(w.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?.()}))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:r}=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,!r&&!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:r}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||r:te(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(w.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()}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 ro=(t=[])=>t.reduce((e,r,n)=>{let i=(r?.controls??[]).filter(s=>!Ne(s));if(gt(i)){let s=[r.startTime??0,r.endTime??1/0],c={id:r.id,isRemoved:!1};if(!n)e.push({subjects:[c],range:s});else{let o=[],a=-1/0,l=1/0,d=[],m=[];for(let f=0;f<e.length;f++){let b=e[f];if(m.push(...b.subjects),b.range[0]<l&&(l=b.range[0]),b.range[1]>a&&(a=b.range[1]),s[0]>=b.range[0]&&s[1]<=b.range[1])return e[f].subjects.push(c),e;s[0]<b.range[0]&&s[1]>b.range[0]&&(o.push(f),d=d.concat(b.subjects)),s[0]>=b.range[0]&&s[0]<=b.range[1]&&(o.push(f),d=d.concat(b.subjects),s[0]=b.range[0]),s[1]>=b.range[0]&&s[1]<=b.range[1]&&(o.push(f),d=d.concat(b.subjects),s[1]=b.range[1])}if(m.push(c),s[0]<=l&&s[1]>=a)return[{subjects:m,range:s}];o.length&&o.reverse().forEach(f=>{e.splice(f,1)}),e.push({subjects:d.concat([c]),range:s})}}return e},[]).sort((e,r)=>e.range[0]-r.range[0]);var _o=z(It(),1),Nr=z(Et(),1),Fo=z(jo(),1);function $o(){let t={};function e(){for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&delete t[o]}function r(o){let a={};for(let l in t)+l<=o&&(a[l]=t[l]);return a}function n(o){let a={};for(let l in t)+l>=o&&(a[l]=t[l]);return a}function i({timestamp:o,priority:a,initiator:l}){if(fr(o)){let d=t[o]??null;if(d&&a&&ke(a,!0)){let m={},f=d[a];return f&&(m={...m,...f}),m=ee(m)?null:m,m&&ke(l,!0)?m[l]??null:m}return d}return null}function s({timestamp:o,priority:a,initiator:l}){if(fr(o))if(t[o]){if(a&&ke(a,!0))if(t[o][a]){if(l&&ke(l,!0))if(t[o][a][l]){if(delete t[o][a][l],!ee(t[o][a]))return!0}else return!1;if(delete t[o][a],!ee(t[o]))return!0}else return!1;return delete t[o]}else return!1;return!1}function c({timestamp:o,priority:a,initiator:l,...d}){t[o]?.[a]?.[l]?t[o][a][l].push({...d}):t[o]?.[a]?t[o][a]={...t[o][a],[l]:[{...d}]}:t[o]?t[o]={...t[o],[a]:{[l]:[{...d}]}}:t[o]={[a]:{[l]:[{...d}]}}}return{map:t,remove:s,add:c,removeAll:e,get:i,getLte:r,getGte:n}}var Cu=[y.EventActionTypes.expect,y.EventActionTypes.setNextBranch],gu=1/0;function qo(t,e){let r=t,n,i=Eu(e),s=$o(),c,o=()=>{b(),h()},a=p=>{s.add.call(void 0,p),T()},l=(p=[])=>{for(let v of p)if(v.action(),(0,_o.default)(Cu,v.actionType))break},d=(p=1/0)=>{let v=St(s.get({timestamp:p,priority:"control"})??{}),C=St(s.get({timestamp:p,priority:"container"})??{}),I=St(s.get({timestamp:p,priority:"chapter"})??{});return[...v,...C,...I]},m=p=>{i.isReady(p)&&l(d(p))},f=()=>{l([...St(s.get({timestamp:1/0,priority:"chapter"})??{})])},b=()=>{n&&(c?.unsubscribe(),n=void 0)},P=p=>{},T=()=>{n||(n=()=>setTimeout(()=>{m(1/0)}),c=r.events.ended$.subscribe(n))},E=p=>{b(),r=p},x=p=>{p.priority==="container"&&i.resetCalled(p.timestamp),s.remove(p)},h=()=>{i.release(),s.removeAll()};return{setPlayer:E,add:a,remove:x,exec:m,execEndOfVideo:f,listen:T,unlisten:b,release:o,containersEventsCallState:i,getPreparedToExecActions:d}}function Eu(t){let e=new Map;return{setCalled:({timestamp:o,id:a})=>{let l=e.get(o);l&&l[a]!==void 0&&(l[a]=!0)},setData:(o=[])=>{for(let a of o){let l=a.endTime??gu,d=e.get(l);e.set(l,{...d,[a.id]:!1})}},resetCalled:o=>{let a=e.get(o);if(a)for(let l in a)a[l]=!1},isReady:o=>{let a=e.get(o);if(!a)return!0;let l=(0,Nr.default)(a);return t?l.some(m=>m):!l.some(m=>!m)},release:()=>e.clear()}}function St(t){return(0,Fo.default)((0,Nr.default)(t)).sort(e=>e.actionType===y.EventActionTypes.expect?-1:1)}var Bo={videoContentHeight:0,videoContentWidth:0},Do=t=>{let{height:e,width:r}=t.info.intrinsicVideoSize$.getValue()||{};if(!(e&&r))return Bo;let{clientHeight:n,clientWidth:i}=t.experimental.element$.getValue()||{};if(!(n&&i))return Bo;let s=e/r,c=n/i,o,a;return c>s?(a=i,o=i*s):c<s?(a=n/s,o=n):(a=i,o=n),{videoContentWidth:a,videoContentHeight:o}};var Iu=250;function Ho(t){let e,r=new ResizeObserver(o=>{s(o),e=s.bind(null,o)});function n(o){let{parentElement:a,player:l}=t();if(a&&l){let{videoContentWidth:d,videoContentHeight:m}=Do(l);a.style.setProperty("--interactive-content-width",`${d}px`),a.style.setProperty("--interactive-content-height",`${m}px`),a.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function i(){let{parentElement:o}=t();o.removeAttribute("style")}let s=Oe(o=>{let{fns:a=[]}=t();n(o);for(let l of a)l()},Iu);function c(){e=void 0,r.disconnect(),i()}return{resizeObserver:r,calc:()=>{e?.()},release:c}}var Tu=t=>Math.floor(Math.random()*t),Go=t=>{let e=t.length,r=1/0,n=null;for(;e--;){let i=t[e],s=i.weight??1;s<r&&(r=s,n=i)}return n},zo=t=>{let e=t.length,r=-1/0,n=null;for(;e--;){let i=t[e],s=i.weight??0;s>r&&(r=s,n=i)}return n};var Wo=t=>{let e=t.length,r=Tu(e);return t[r]},Uo=1,Ko=t=>{let e=0;for(let n=0;n<t.length;++n)e+=t[n].weight??Uo;let r=Math.random()*e;e=0;for(let n=0;n<t.length-1;++n)if(e+=t[n].weight??Uo,e>=r)return t[n];return t[t.length-1]};var Qo={shouldOpenNow:!0,isDetachContainer:!0},Xo="after-expect";var Lr=(t,e=!1)=>({...t,args:e?{...t.args,...Qo}:{...Qo,...t.args}}),Jo=({globalEventEmitter:t,globalEvents:e,player:r,interactiveEvents:n})=>{let i={isExpect:!1},s=()=>{i.isExpect&&(i.isExpect=!1)},c=({action:h,controlType:p,controlId:v,containerId:C,branches:I=[],onEvent:S,isEOV:R=()=>!1,isDisabled:V=()=>!1})=>{let A=Lr(h,R()),N={timestamp:1/0,priority:"control",initiator:v,actionType:A.type},q=V(),B=t.emit.bind(t,w.interactives,{subjectId:v,subjectType:p,subjectName:"control",type:q?O.actionChoiceCanceled:O.actionChoice,actionType:h.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:C,...A.args}}),D=()=>{e.interactiveActionChoice$.next({subjectId:v,subjectType:p,subjectName:"control",type:q?"action-choice-canceled":"action-choice",actionType:h.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:C,...A.args}})};if(q){B(),D();return}switch(A.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let K=I.find(ie=>ie.id===A.args.branchId);if(!K)return;S(A.args.isDetachContainer,b.bind(null,{subjectId:v,subjectName:"control"})),B(),D(),A.args.shouldOpenNow?T({subjectId:v,subjectName:"control",subjectType:p,action:A,payload:{chapterId:K.chapterId,autoSelect:!1}}):n.add({...N,action:T.bind(null,{subjectId:v,subjectName:"control",subjectType:p,action:A,payload:{chapterId:K.chapterId,autoSelect:!1}})});return}case y.EventActionTypes.continuePlayback.trim().toLowerCase():{S(A.args.isDetachContainer,b.bind(null,{subjectId:v,subjectName:"control"})),B(),D(),A.args.shouldOpenNow?P({subjectId:v,subjectName:"control",subjectType:p,action:h}):n.add({...N,action:P.bind(null,{subjectId:v,subjectName:"control",subjectType:p,action:h})});return}case y.EventActionTypes.openURI.trim().toLowerCase():{S(A.args.isDetachContainer,b.bind(null,{subjectId:v,subjectName:"control"})),B(),D(),A.args.shouldOpenNow?x({subjectId:v,subjectName:"control",subjectType:p,action:A,payload:{URI:h.args.uri}}):n.add({...N,action:x.bind(null,{subjectId:v,subjectName:"control",subjectType:p,action:A,payload:{URI:h.args.uri}})});return}default:{let K="Unexpected control event",ie=new M(1,1,{message:K});d(ie,K);return}}},o=({action:h,container:{id:p,endTime:v},branches:C=[],isEOV:I=!1,autoSelected:S=!1})=>{let R=Lr(h,I),V={timestamp:!R.args.shouldOpenNow||I?1/0:v??1/0,priority:"container",initiator:p,actionType:R.type},A=t.emit.bind(t,w.interactives,{subjectId:p,subjectName:"container",type:O.actionChoice,actionType:R.type,payload:{invokeImmediately:R.args.shouldOpenNow,...R.args}}),N=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"container",type:"action-choice",actionType:R.type,payload:{invokeImmediately:R.args.shouldOpenNow,...R.args}})};switch(R.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let q=C.find(B=>B.id===R.args.branchId);if(!q)return;A(),N(),n.add({...V,action:T.bind(null,{subjectId:p,subjectName:"container",action:R,payload:{chapterId:q.chapterId,autoSelect:S}})});return}case y.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case y.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case y.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case y.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case y.EventActionTypes.continuePlayback.trim().toLowerCase():{A(),N(),n.add({...V,action:P.bind(null,{subjectId:p,subjectName:"container",action:R})});return}case y.EventActionTypes.openURI.trim().toLowerCase():{A(),N(),n.add({...V,action:x.bind(null,{subjectId:p,subjectName:"container",action:R,payload:{URI:h.args.uri}})});return}default:{let q="Unexpected container event",B=new M(1,1,{message:q});d(B,q);return}}};function a({container:h,branches:p,isEOV:v=!1}){let C=xr(h.events);if(C){let I=Lr(C.action,v);t.emit(w.interactives,{subjectId:h.id,subjectName:"container",type:O.actionChoice,actionType:I.type,payload:{invokeImmediately:I.args.shouldOpenNow,...I.args}}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"container",type:"action-choice",actionType:I.type,payload:{invokeImmediately:I.args.shouldOpenNow,...I.args}}),n.add({timestamp:v?1/0:h.endTime??1/0,priority:"container",initiator:h.id,actionType:y.EventActionTypes.expect,action:f.bind(null,{subjectId:h.id,subjectName:"container"})}),i.isExpect=!0}else for(let I of h.events??[])o({action:I.action,container:h,branches:p,isEOV:v})}let l=({chapterId:h,action:p,branches:v=[]})=>{let C=t.emit.bind(t,w.interactives,{subjectId:h,subjectName:"chapter",type:O.actionChoice,actionType:p.type,payload:p.args}),I=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"chapter",type:"action-choice",actionType:p.type,payload:p.args})};switch(p.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let S=v.find(R=>R.id===p.args.branchId);return S?.chapterId?(C(),I(),T.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:S.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let S=Wo(v);return S?.chapterId?(C(),I(),T.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:S.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setRandomBranch.trim().toLowerCase():{let S=Ko(v);return S?.chapterId?(C(),I(),T.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:S.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let S=zo(v);return S?.chapterId?(C(),I(),T.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:S.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let S=Go(v);return S?.chapterId?(C(),I(),T.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{chapterId:S.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.continuePlayback.trim().toLowerCase():return C(),I(),P.bind(null,{subjectId:h,subjectName:"chapter",action:p});case y.EventActionTypes.openURI.trim().toLowerCase():return C(),I(),x.bind(null,{subjectId:h,subjectName:"chapter",action:p,payload:{URI:p.args.uri}});default:{let S="Unexpected chapter event",R=new M(1,1,{message:S});d(R,S);return}}};function d(h,p){console.error(p),e.error$.next(h),t.emit(w.errors,h)}function m(h){let p=xr(h.events);if(p){if(G(h))return;t.emit(w.interactives,{subjectId:h.id,subjectName:"chapter",type:O.actionChoice,actionType:p.action.type,payload:p.action.args}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"chapter",type:"action-choice",actionType:p.action.type,payload:p.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:y.EventActionTypes.expect,action:f.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else h.events?.forEach(v=>{let C=l({chapterId:h.id,action:v.action,branches:h.branches});C&&n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:v.action.type,action:C})})}let f=({subjectId:h,subjectName:p})=>{r.pause(),t.emit(w.interactives,{subjectId:h,subjectName:p,type:O.actionExecution,actionType:y.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,type:"action-execution",actionType:y.EventActionTypes.expect})},b=({subjectId:h,subjectName:p})=>{r.info.isEnded$.getValue()?n.execEndOfVideo():r.play(),t.emit(w.interactives,{subjectId:h,subjectName:p,type:O.actionExecution,actionType:Xo}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,type:"action-execution",actionType:Xo})},P=({subjectId:h,subjectName:p,subjectType:v,action:C})=>{t.emit(w.interactives,{subjectId:h,subjectName:p,subjectType:v,type:O.actionExecution,actionType:C.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:C.type})},T=({subjectId:h,subjectName:p,subjectType:v,action:C,payload:I})=>{I.behaviour="change-chapter",t.emit(w.interactives,{subjectId:h,subjectName:p,subjectType:v,type:O.actionExecution,actionType:C.type,payload:I}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:C.type,payload:I})},E=({subjectId:h,subjectName:p,subjectType:v,action:C,payload:I})=>{I.behaviour="change-manifest",t.emit(w.interactives,{subjectId:h,subjectName:p,subjectType:v,type:O.actionExecution,actionType:C.type,payload:I}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:C.type,payload:I})},x=({subjectId:h,subjectName:p,subjectType:v,action:C,payload:I})=>{if(!I.URI)return;let S=window.open(I.URI,"_blank","noopener,noreferrer");S&&(S.opener=null),t.emit(w.interactives,{subjectId:h,subjectName:p,subjectType:v,type:O.actionExecution,actionType:C.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:p,subjectType:v,type:"action-execution",actionType:C.type})};return{onControlEvent:c,onContainerEvent:o,onChapterEvent:l,onExpectEvent:f,expectEventHandler:b,setManifestChapterEvents:m,setManifestContainerEvents:a,stopExpect:s,state:i}};var _r=z(mr(),1),F=require("@vkontakte/videoplayer-shared");var wt=(t,e)=>{let r={};return t.map(n=>{if(!r[n]){let i=e.chapters.find(c=>c.id===n);if(!i)return null;let s=e.media.videos.find(c=>i.videoId===c.id);if(!s)return null;r[n]=jr(s)}return r[n]}).filter(Boolean)},ea=t=>{for(let e of t.variants)if(ta(e)&&e.payload)return e.payload.id},ta=t=>!!(t.type==="custom"&&t.payload&&t.payload.type==="vk"),jr=t=>{let e=ea(t);if(!e)return null;let r=e.split("_").pop();return r?parseInt(r,10):null},ra=(t,e)=>{for(let r of t.media.videos)if(e===jr(r)){for(let n of t.chapters)if(n.videoId===r.id)return n.id;return}},$r=(t,e)=>t.reduce((r,n)=>{let i=ra(e,n);return i?[...r,i]:r},[]);var Be=class{constructor({globalEventEmitter:e,videoId:r,interactiveController:n,historyApi:i,settings:s}){this.state={history$:new F.ValueSubject([]),hasPrevChapter$:new F.ValueSubject(!1),prevChapter$:new F.ValueSubject(null),isInitialChapter$:new F.ValueSubject(!1),isGoBackLimited$:new F.ValueSubject(!1)};this.#r=null;this.#o=!1;this.#e=null;this.#p=null;this.events={inited$:new F.Subject,destroyed$:new F.Subject,error$:new F.Subject};this.#n=null;this.#i=null;this.#t=null;this.#a=new F.Subscription;this.#c=!1;this.#l=0;this.#n=r,this.#t=e,this.#i=n,this.#r=i,this.#s=s,this.state.history$&&this.#a&&this.#a?.add(this.state.history$.subscribe(c=>{this.state.prevChapter$.next((0,_r.default)(c,-2)||null),this.state.hasPrevChapter$.next(c.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===this.#e?.metadata?.initChapterId),this.state.isGoBackLimited$.next(this.#l===this.#s.maxLength-1)}))}#r;#s;#o;#e;#p;#n;#i;#t;#a;#c;#l;async setManifest(e){if(!this.#i||!this.#t)return;this.#e=e,await this.getProjectHistory();let r=this.getInitialChapterId();await this.#i.setChapter({chapterId:r,pushToHistory:!1}),this.#o||(this.#o=!0,this.events.inited$.next({initChapterId:r}))}get inited(){return this.#o}async updateHistory(e,r=!0){if(!this.#e)return;this.#c?(this.#c=!1,this.#l++):this.#l=0;let n=this.#e,i=e.length-this.#s.maxLength,s=i>0?e.slice(i):e,c=wt(s,n);if(this.#p=c,this.state.history$.next(s),!(!r||!this.#r||!this.#n))try{await this.#r.save(this.#n,c)}catch{let a=new M(1,5,"Unable to save interactive history");this.events.error$.next(a),this.#t?.emit(w.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(w.errors,n)}this.#c=!0;let e=this.state.history$.getValue().slice(0,-1),r=e.pop();this.state.history$.next(e),await this.#i.setChapter({chapterId:r,playPrev:!0})}async getProjectHistory(){if(!this.#e||!this.#n)return;let e=this.#e,r=[this.getInitialVideoId()];if(this.#r)try{let i=await this.#r.get(this.#n);i.length&&(r=i)}catch{let s=new M(1,5,"Error while trying to fetch data");this.events.error$.next(s),this.#t?.emit(w.errors,s)}let n=$r(r,e);this.state.history$.next(n)}getInitialChapterId(){let e=this.state.history$.getValue();return(0,_r.default)(e,-1)||this.#s.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return wt([e],this.#e).pop()}return null}destroy(){this.#n=null,this.#r=null,this.#i=null,this.#a?.unsubscribe(),this.#a=null,this.#o=!1,this.#t?.emit(w.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var At=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 r=e.data,n=r.length;for(let i=3;i<n;i+=40)if(r[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,r=!1){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;r&&(i=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,r&&i&&this.restore(i),this._prevSizeId=n}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),r=new Image;return r.crossOrigin="anonymous",r.src=e,await r.decode(),r}restore(e){this.rootElement&&this.rootElement.getContext("2d")?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}};var Rt=class{constructor({parentElement:e,endOffsetMs:r=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let r=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(r);if(this.isContainerTime(r))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;
@@ -42,19 +42,19 @@
42
42
 
43
43
  ${Su}
44
44
 
45
- .${P.common} {
45
+ .${k.common} {
46
46
  display: flex;
47
47
  width: 100%;
48
48
  height: 100%;
49
49
  font-family: inherit;
50
50
  }
51
51
 
52
- .${P.disabled} {
52
+ .${k.disabled} {
53
53
  cursor: default;
54
54
  }
55
55
 
56
- .${P.button},
57
- .${P.area} {
56
+ .${k.button},
57
+ .${k.area} {
58
58
  cursor: pointer;
59
59
  }
60
- `,ia=t=>{let e=document.createElement("style");e.textContent=wu,t.prepend(e)};var aa=require("@vkontakte/videoplayer-core"),sa=Object.freeze({lang:g.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function Au(){let t=document.createElement("div");return t.classList.add("interactive-chapter"),t}var De=class{constructor(e){this.playerSubscriptions=new g.Subscription;this.subscriptions=new g.Subscription;this.globalEventEmitter=new ht;this.animation=new dt;this.seekToInteractiveController=new Me;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Au();this.factories=new Map([["choice",Je]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new g.Subscription;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new g.ValueSubject(null),isInitialChapter$:new g.ValueSubject(!1),isFirstChapter$:new g.ValueSubject(!0),isEndChapter$:new g.ValueSubject(!1),isInteractiveExpectation$:new g.ValueSubject(!1),isReplay$:new g.ValueSubject(!1),calledByInteractive$:new g.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new g.ValueSubject(!1),disabledControls$:new g.ValueSubject(!1),interactiveRanges$:new g.ValueSubject([]),isInteractiveTime$:new g.ValueSubject(!1),statistics$:new g.ValueSubject(null),isSeekable$:new g.ValueSubject(!1)};this.events={noInteraction$:new g.Subject,graphVisibilityChanged$:new g.Subject,watchAgainIsClicked$:new g.Subject,chapterChanged$:new g.Subject,playerChanged$:new g.Subject,error$:new g.Subject,eachTick$:new g.Subject,manifestChanged$:new g.Subject,interactiveRangeEnded$:new g.Subject,interactiveContainerRemoved$:new g.Subject,interactiveContainerFakeRemoved$:new g.Subject,interactiveActionExecution$:new g.Subject,interactiveActionChoice$:new g.Subject,interactiveVisibilityChanged$:new g.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(w.errors,e)};this.clearHistoryIfEnded=()=>{let e=this.player?.info.isEnded$.getValue(),r=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&G(n)&&!r&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:r,...n}=e;if(r){let{statSubscription:i,oneStat:s}=r;i.add(s.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(r)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(w.playerChanged,n)};this.onPlaybackStarted=()=>{this.resizeManager?.calc(),this.animation.requestAnimation()};this.destroyGameControllers=(e=!0)=>{this.gameControllers.forEach(r=>{!e&&r.isPermanentText||(this.animation.removeFn(r.whilePlaying),r.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:r}=this.state,i=r.getValue().map(s=>({...s,subjects:s.subjects.filter(c=>c.id!==e)}));r.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};this._options={...sa,...e,config:{...sa.config,...e.config}},this._options.parentElement.append(this.rootElement),this.historyController=new Be({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:this._options.projectInfo?.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Rt({parentElement:this._options.parentElement,onError:n=>{let i=new M(1,6,n);this.emitErrorEvent(i)}})),ia(this._options.parentElement),this.subscriptions.add((0,g.fromEvent)(this.rootElement,"mousedown").subscribe(n=>n.stopPropagation())).add((0,g.fromEvent)(this.rootElement,"mouseup").subscribe(n=>n.stopPropagation())),this.manifestController=new ne(this._options.loaders,n=>{let i=new M(1,3,n);this.emitErrorEvent(i)});let r=[];this._options.lastFrame&&r.push(()=>{this.lastFrame?.updateCanvasDimensions(!0)}),r.push(()=>{let n=this.state.isInteractiveTime$.getValue();for(let i of this.gameControllers)i.onResize(n)}),this.resizeManager=Ho(()=>({player:this.player,parentElement:this._options.parentElement,fns:r})),this._options.graph&&(this.graph=new Ve({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:n=>{this.setChapter({chapterId:n}),this.globalEventEmitter.emit(w.graph,{type:ve.watchAgainClicked,chapterId:n}),this.events.watchAgainIsClicked$.next(n)},onError:n=>{let i=new M(1,2,{message:n});this.emitErrorEvent(i)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:r})=>{this.handleFakeRemoval(e,r)})).add(this.events.interactiveActionExecution$.subscribe(e=>{if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),e.payload?.behaviour==="change-chapter"){let{chapterId:r}=e.payload;this.setChapter({chapterId:r}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(e.payload?.behaviour==="change-manifest"){let{manifestURL:r}=e.payload;r&&this.setManifest(r)}e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:r,payload:n})=>{e!=="action-choice"||r==="chapter"||"invokeImmediately"in n&&n.invokeImmediately||this.destroyGameControllers(!1)}))}async initSeamless(){this.seamlessController=kr(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let r=e*1e3,i=this.getInteractiveRanges().reverse().find(({range:s})=>r>=s[1]);if(i){let s=i.range.join("-");this.endedRanges.has(s)||(this.endedRanges.add(s),this.globalEventEmitter.emit(w.interactives,{type:O.rangeEnded,payload:i,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:i}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe((0,g.once)()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,g.combine)({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:r,isInteractiveExpectation:n})=>{let i;if(n)i=!0;else{let a=e*1e3;i=!!r.find(({range:[d,m],subjects:f})=>d<a&&a<m&&f.some(b=>!b.isRemoved)&&f.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let s=!!this.noInteractionTimeout,o=this.player?.info.playbackState$.getValue()==="playing"||n;i&&!s&&o?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):s&&!o&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{this.lastFrame?.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{e&&this.lastFrame?.setVideoElement(e)})).add(this.player.events.firstFrame$.subscribe(()=>{this.lastFrame?.reset(),setTimeout(()=>{this.lastFrame?.hide(),this.lastFrame?.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){let e=this.manifestController.chapter;e&&this.appState===1&&(this.selectBranches?.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),this.interactiveEvents?.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(r=>r.container.container).filter(r=>!re(r.controls))),this._options.lastFrame&&this.animation.addFn(()=>{this.player&&this.lastFrame?.onEachTick(this.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let r=[];return e.containers.forEach(n=>{let i=n.type.trim().toLowerCase(),c=this.factories.get(i)?.(n,this.rootElement);if(c&&this.selectBranches&&this.interactiveEvents&&this.player){let o=new Tt({player:this.player,container:c,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>cs(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)}});this.animation.addFn(o.whilePlaying,!0),r.push(o)}}),r}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let r=this.state.isSeekable$.getValue(),n=!!this.seekToInteractiveController.getNextInteractiveTime();(n&&!r||!n&&r)&&this.state.isSeekable$.next(!r)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){if(this.updateLastEventInfo(),!this.historyController.inited)return;let r=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(n&&G(n)&&_e(n))??!1,s=this.manifestController.manifest?.metadata.initChapterId===e,c=this.historyController.state.history$.getValue();if(s||i&&r){this.historyController.updateHistory([e]);return}(0,oa.default)(c,-1)!==e&&this.historyController.updateHistory([...c,e])}handleFakeRemoval(e,r){let{interactiveRanges$:n}=this.state,s=n.getValue().map(c=>{let o=c.subjects.some(l=>l.id===e),a=c.subjects.map(l=>r&&o||l.id===e?{...l,isRemoved:!0}:l);return{...c,subjects:a}});n.next(s)}reset(){this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),this.interactiveEvents?.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}get options(){return this._options}init(){this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&(this.resizeManager?.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let r=await this.manifestController.setManifest(e);if(r.manifest)return this.graph&&this.graph.handleManifestChange(r.manifest),await this.historyController.setManifest(r.manifest),this.events.manifestChanged$.next(r.manifest),this.globalEventEmitter.emit(w.manifestChanged,{manifest:r.manifest}),this.setGameControllers(),r.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=qo(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Jo({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:r=!0,playPrev:n=!1}={}){this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&aa.clientChecker.browser.isSafari&&await na(35);let i=!n&&this.state.isEndChapter$.getValue()&&this.getCurrentManifest()?.metadata.initChapterId===e;this.state.isReplay$.next(i);let{chapter:s,media:c,graph:o}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||i)&&this.state.isFirstChapter$.next(!0),!(!s||!c)&&(r&&this.pushChapterToHistory(s.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(s),this.lastFrame?.setCurrentChapter(s),this.events.chapterChanged$.next({chapter:s,manifestVideo:c}),this.globalEventEmitter.emit(w.chapterChanged,{chapter:s,media:c,graph:o}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new g.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(r=>{e.next(r?ye.InteractiveInterfaceClick.GRAPH_SHOW:ye.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(ye.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:r,subjectName:n,subjectType:i})=>{r!=="action-choice"||n!=="control"||(i==="Button"&&e.next(ye.InteractiveInterfaceClick.NEXT_BUTTON),i==="Area"&&e.next(ye.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new g.Observable(e=>{this.events.playerChanged$.subscribe(({config:r})=>{r?.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(r.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(w.graph,{type:ve.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){Array.isArray(e)&&this.graph?.setVisitedChapters(e)}updateGraphVideosInfo(e){Array.isArray(e)&&this.graph?.updateVideosInfo(e)}deadEndCheck(){return!(this.interactiveEvents?.getPreparedToExecActions()||[]).some(n=>n.actionType===y.EventActionTypes.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(r=>!r.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),r=this.player.info.duration$.getValue();return e===r&&this.gameControllers.some(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&te(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,y.isSupportedManifest)(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){return ro(this.manifestController.chapter?.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,r){return this.globalEventEmitter.on(e,r),this}off(e,r){return this.globalEventEmitter.off(e,r),this}once(e,r){return this.globalEventEmitter.once(e,r),this}destroy(){this.clearHistoryIfEnded(),this.destroyGameControllers(),this.gameControllers=[],this.graph?.destroy(),this.seamlessControllerSubs.unsubscribe(),this.seamlessController?.removeAll(),this.resizeManager?.release(),this.animation.release(),this.interactiveEvents?.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),this.lastFrame?.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var ca={Container:oe,createChoiceContainer:Je,createAreaControl:Xe,createButtonControl:Ze,classnamesPrefix:Hr};var Ru={version:Br};
60
+ `,ia=t=>{let e=document.createElement("style");e.textContent=wu,t.prepend(e)};var aa=require("@vkontakte/videoplayer-core"),sa=Object.freeze({lang:g.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function Au(){let t=document.createElement("div");return t.classList.add("interactive-chapter"),t}var De=class{constructor(e){this.playerSubscriptions=new g.Subscription;this.subscriptions=new g.Subscription;this.globalEventEmitter=new ht;this.animation=new dt;this.seekToInteractiveController=new Me;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Au();this.factories=new Map([["choice",Je]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new g.Subscription;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new g.ValueSubject(null),isInitialChapter$:new g.ValueSubject(!1),isFirstChapter$:new g.ValueSubject(!0),isEndChapter$:new g.ValueSubject(!1),isInteractiveExpectation$:new g.ValueSubject(!1),isReplay$:new g.ValueSubject(!1),calledByInteractive$:new g.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new g.ValueSubject(!1),disabledControls$:new g.ValueSubject(!1),interactiveRanges$:new g.ValueSubject([]),isInteractiveTime$:new g.ValueSubject(!1),statistics$:new g.ValueSubject(null),isSeekable$:new g.ValueSubject(!1)};this.events={noInteraction$:new g.Subject,graphVisibilityChanged$:new g.Subject,watchAgainIsClicked$:new g.Subject,chapterChanged$:new g.Subject,playerChanged$:new g.Subject,error$:new g.Subject,eachTick$:new g.Subject,manifestChanged$:new g.Subject,interactiveRangeEnded$:new g.Subject,interactiveContainerRemoved$:new g.Subject,interactiveContainerFakeRemoved$:new g.Subject,interactiveActionExecution$:new g.Subject,interactiveActionChoice$:new g.Subject,interactiveVisibilityChanged$:new g.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(w.errors,e)};this.clearHistoryIfEnded=()=>{let e=this.player?.info.isEnded$.getValue(),r=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&G(n)&&!r&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:r,...n}=e;if(r){let{statSubscription:i,oneStat:s}=r;i.add(s.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(r)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(w.playerChanged,n)};this.onPlaybackStarted=()=>{this.resizeManager?.calc(),this.animation.requestAnimation()};this.destroyGameControllers=(e=!0)=>{this.gameControllers.forEach(r=>{!e&&r.isPermanentText||(this.animation.removeFn(r.whilePlaying),r.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:r}=this.state,i=r.getValue().map(s=>({...s,subjects:s.subjects.filter(c=>c.id!==e)}));r.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};this._options={...sa,...e,config:{...sa.config,...e.config}},this._options.parentElement.append(this.rootElement),this.historyController=new Be({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:this._options.projectInfo?.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Rt({parentElement:this._options.parentElement,onError:n=>{let i=new M(1,6,n);this.emitErrorEvent(i)}})),ia(this._options.parentElement),this.subscriptions.add((0,g.fromEvent)(this.rootElement,"mousedown").subscribe(n=>n.stopPropagation())).add((0,g.fromEvent)(this.rootElement,"mouseup").subscribe(n=>n.stopPropagation())),this.manifestController=new ne(this._options.loaders,n=>{let i=new M(1,3,n);this.emitErrorEvent(i)});let r=[];this._options.lastFrame&&r.push(()=>{this.lastFrame?.updateCanvasDimensions(!0)}),r.push(()=>{let n=this.state.isInteractiveTime$.getValue();for(let i of this.gameControllers)i.onResize(n)}),this.resizeManager=Ho(()=>({player:this.player,parentElement:this._options.parentElement,fns:r})),this._options.graph&&(this.graph=new Ve({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:n=>{this.setChapter({chapterId:n}),this.globalEventEmitter.emit(w.graph,{type:ve.watchAgainClicked,chapterId:n}),this.events.watchAgainIsClicked$.next(n)},onError:n=>{let i=new M(1,2,{message:n});this.emitErrorEvent(i)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:r})=>{this.handleFakeRemoval(e,r)})).add(this.events.interactiveActionExecution$.subscribe(e=>{if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),e.payload?.behaviour==="change-chapter"){let{chapterId:r}=e.payload;this.setChapter({chapterId:r}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(e.payload?.behaviour==="change-manifest"){let{manifestURL:r}=e.payload;r&&this.setManifest(r)}e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:r,payload:n})=>{e!=="action-choice"||r==="chapter"||"invokeImmediately"in n&&n.invokeImmediately||this.destroyGameControllers(!1)}))}async initSeamless(){this.seamlessController=Pr(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let r=e*1e3,i=this.getInteractiveRanges().reverse().find(({range:s})=>r>=s[1]);if(i){let s=i.range.join("-");this.endedRanges.has(s)||(this.endedRanges.add(s),this.globalEventEmitter.emit(w.interactives,{type:O.rangeEnded,payload:i,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:i}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe((0,g.once)()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,g.combine)({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:r,isInteractiveExpectation:n})=>{let i;if(n)i=!0;else{let a=e*1e3;i=!!r.find(({range:[d,m],subjects:f})=>d<a&&a<m&&f.some(b=>!b.isRemoved)&&f.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let s=!!this.noInteractionTimeout,o=this.player?.info.playbackState$.getValue()==="playing"||n;i&&!s&&o?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):s&&!o&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{this.lastFrame?.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{e&&this.lastFrame?.setVideoElement(e)})).add(this.player.events.firstFrame$.subscribe(()=>{this.lastFrame?.reset(),setTimeout(()=>{this.lastFrame?.hide(),this.lastFrame?.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){let e=this.manifestController.chapter;e&&this.appState===1&&(this.selectBranches?.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),this.interactiveEvents?.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(r=>r.container.container).filter(r=>!re(r.controls))),this._options.lastFrame&&this.animation.addFn(()=>{this.player&&this.lastFrame?.onEachTick(this.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let r=[];return e.containers.forEach(n=>{let i=n.type.trim().toLowerCase(),c=this.factories.get(i)?.(n,this.rootElement);if(c&&this.selectBranches&&this.interactiveEvents&&this.player){let o=new Tt({player:this.player,container:c,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>cs(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)}});this.animation.addFn(o.whilePlaying,!0),r.push(o)}}),r}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let r=this.state.isSeekable$.getValue(),n=!!this.seekToInteractiveController.getNextInteractiveTime();(n&&!r||!n&&r)&&this.state.isSeekable$.next(!r)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){if(this.updateLastEventInfo(),!this.historyController.inited)return;let r=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(n&&G(n)&&_e(n))??!1,s=this.manifestController.manifest?.metadata.initChapterId===e,c=this.historyController.state.history$.getValue();if(s||i&&r){this.historyController.updateHistory([e]);return}(0,oa.default)(c,-1)!==e&&this.historyController.updateHistory([...c,e])}handleFakeRemoval(e,r){let{interactiveRanges$:n}=this.state,s=n.getValue().map(c=>{let o=c.subjects.some(l=>l.id===e),a=c.subjects.map(l=>r&&o||l.id===e?{...l,isRemoved:!0}:l);return{...c,subjects:a}});n.next(s)}reset(){this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),this.interactiveEvents?.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}get options(){return this._options}init(){this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&(this.resizeManager?.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let r=await this.manifestController.setManifest(e);if(r.manifest)return this.graph&&this.graph.handleManifestChange(r.manifest),await this.historyController.setManifest(r.manifest),this.events.manifestChanged$.next(r.manifest),this.globalEventEmitter.emit(w.manifestChanged,{manifest:r.manifest}),this.setGameControllers(),r.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=qo(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Jo({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:r=!0,playPrev:n=!1}={}){this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&aa.clientChecker.browser.isSafari&&await na(35);let i=!n&&this.state.isEndChapter$.getValue()&&this.getCurrentManifest()?.metadata.initChapterId===e;this.state.isReplay$.next(i);let{chapter:s,media:c,graph:o}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||i)&&this.state.isFirstChapter$.next(!0),!(!s||!c)&&(r&&this.pushChapterToHistory(s.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(s),this.lastFrame?.setCurrentChapter(s),this.events.chapterChanged$.next({chapter:s,manifestVideo:c}),this.globalEventEmitter.emit(w.chapterChanged,{chapter:s,media:c,graph:o}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new g.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(r=>{e.next(r?ye.InteractiveInterfaceClick.GRAPH_SHOW:ye.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(ye.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:r,subjectName:n,subjectType:i})=>{r!=="action-choice"||n!=="control"||(i==="Button"&&e.next(ye.InteractiveInterfaceClick.NEXT_BUTTON),i==="Area"&&e.next(ye.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new g.Observable(e=>{this.events.playerChanged$.subscribe(({config:r})=>{r?.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(r.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(w.graph,{type:ve.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){Array.isArray(e)&&this.graph?.setVisitedChapters(e)}updateGraphVideosInfo(e){Array.isArray(e)&&this.graph?.updateVideosInfo(e)}deadEndCheck(){return!(this.interactiveEvents?.getPreparedToExecActions()||[]).some(n=>n.actionType===y.EventActionTypes.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(r=>!r.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),r=this.player.info.duration$.getValue();return e===r&&this.gameControllers.some(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&te(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,y.isSupportedManifest)(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){return ro(this.manifestController.chapter?.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,r){return this.globalEventEmitter.on(e,r),this}off(e,r){return this.globalEventEmitter.off(e,r),this}once(e,r){return this.globalEventEmitter.once(e,r),this}destroy(){this.clearHistoryIfEnded(),this.destroyGameControllers(),this.gameControllers=[],this.graph?.destroy(),this.seamlessControllerSubs.unsubscribe(),this.seamlessController?.removeAll(),this.resizeManager?.release(),this.animation.release(),this.interactiveEvents?.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),this.lastFrame?.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var ca={Container:oe,createChoiceContainer:Je,createAreaControl:Xe,createButtonControl:Ze,classnamesPrefix:Hr};var Ru={version:Br};