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