@vkontakte/videoplayer-interactive 1.0.29-dev.a60090ed.0 → 1.0.29-dev.ac01cfb7.0

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