@vkontakte/videoplayer-interactive 1.0.56-dev.93671684.0 → 1.0.56-dev.c21b8ad0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es2018.esm.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.56-dev.93671684.0
3
- * Fri, 16 Jan 2026 09:30:44 GMT
2
+ * @vkontakte/videoplayer-interactive v1.0.56-dev.c21b8ad0.0
3
+ * Wed, 21 Jan 2026 11:20:07 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-56/doc/
5
5
  */
6
- var El=Object.create;var ki=Object.defineProperty;var Tl=Object.getOwnPropertyDescriptor;var Il=Object.getOwnPropertyNames;var xl=Object.getPrototypeOf,Al=Object.prototype.hasOwnProperty;var Pi=r=>{throw TypeError(r)};var u=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Sl=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Il(e))!Al.call(r,n)&&n!==t&&ki(r,n,{get:()=>e[n],enumerable:!(i=Tl(e,n))||i.enumerable});return r};var Y=(r,e,t)=>(t=r!=null?El(xl(r)):{},Sl(e||!r||!r.__esModule?ki(t,"default",{value:r,enumerable:!0}):t,r));var Vi=(r,e,t)=>e.has(r)||Pi("Cannot "+t);var S=(r,e,t)=>(Vi(r,e,"read from private field"),t?t.call(r):e.get(r)),H=(r,e,t)=>e.has(r)?Pi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),L=(r,e,t,i)=>(Vi(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var Mi=(r,e,t,i)=>({set _(n){L(r,e,n,t)},get _(){return S(r,e,i)}});var J=u((mr,Ui)=>{"use strict";var $e=function(r){return r&&r.Math===Math&&r};Ui.exports=$e(typeof globalThis=="object"&&globalThis)||$e(typeof window=="object"&&window)||$e(typeof self=="object"&&self)||$e(typeof global=="object"&&global)||$e(typeof mr=="object"&&mr)||function(){return this}()||Function("return this")()});var U=u((Ld,Gi)=>{"use strict";Gi.exports=function(r){try{return!!r()}catch(e){return!0}}});var je=u((Fd,Wi)=>{"use strict";var kl=U();Wi.exports=!kl(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Yi=u((Nd,Xi)=>{"use strict";var Pl=je(),Qi=Function.prototype,zi=Qi.apply,Ki=Qi.call;Xi.exports=typeof Reflect=="object"&&Reflect.apply||(Pl?Ki.bind(zi):function(){return Ki.apply(zi,arguments)})});var K=u(($d,en)=>{"use strict";var Zi=je(),Ji=Function.prototype,fr=Ji.call,Vl=Zi&&Ji.bind.bind(fr,fr);en.exports=Zi?Vl:function(r){return function(){return fr.apply(r,arguments)}}});var Be=u((jd,rn)=>{"use strict";var tn=K(),Ml=tn({}.toString),_l=tn("".slice);rn.exports=function(r){return _l(Ml(r),8,-1)}});var vr=u((Bd,nn)=>{"use strict";var Ll=Be(),Fl=K();nn.exports=function(r){if(Ll(r)==="Function")return Fl(r)}});var G=u((qd,on)=>{"use strict";var br=typeof document=="object"&&document.all;on.exports=typeof br=="undefined"&&br!==void 0?function(r){return typeof r=="function"||r===br}:function(r){return typeof r=="function"}});var he=u((Dd,sn)=>{"use strict";var Nl=U();sn.exports=!Nl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Et=u((Hd,an)=>{"use strict";var $l=je(),Ct=Function.prototype.call;an.exports=$l?Ct.bind(Ct):function(){return Ct.apply(Ct,arguments)}});var yr=u(un=>{"use strict";var ln={}.propertyIsEnumerable,cn=Object.getOwnPropertyDescriptor,jl=cn&&!ln.call({1:2},1);un.f=jl?function(e){var t=cn(this,e);return!!t&&t.enumerable}:ln});var gr=u((Gd,pn)=>{"use strict";pn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var dn=u((Wd,hn)=>{"use strict";var Bl=K(),ql=U(),Dl=Be(),Cr=Object,Hl=Bl("".split);hn.exports=ql(function(){return!Cr("z").propertyIsEnumerable(0)})?function(r){return Dl(r)==="String"?Hl(r,""):Cr(r)}:Cr});var Er=u((zd,mn)=>{"use strict";mn.exports=function(r){return r==null}});var Tr=u((Kd,fn)=>{"use strict";var Ul=Er(),Gl=TypeError;fn.exports=function(r){if(Ul(r))throw new Gl("Can't call method on "+r);return r}});var qe=u((Qd,vn)=>{"use strict";var Wl=dn(),zl=Tr();vn.exports=function(r){return Wl(zl(r))}});var Ie=u((Xd,bn)=>{"use strict";var Kl=G();bn.exports=function(r){return typeof r=="object"?r!==null:Kl(r)}});var De=u((Yd,yn)=>{"use strict";yn.exports={}});var Tt=u((Zd,Cn)=>{"use strict";var Ir=De(),xr=J(),Ql=G(),gn=function(r){return Ql(r)?r:void 0};Cn.exports=function(r,e){return arguments.length<2?gn(Ir[r])||gn(xr[r]):Ir[r]&&Ir[r][e]||xr[r]&&xr[r][e]}});var Tn=u((Jd,En)=>{"use strict";var Xl=K();En.exports=Xl({}.isPrototypeOf)});var Sn=u((em,An)=>{"use strict";var Yl=J(),In=Yl.navigator,xn=In&&In.userAgent;An.exports=xn?String(xn):""});var Mn=u((tm,Vn)=>{"use strict";var Pn=J(),Ar=Sn(),wn=Pn.process,Rn=Pn.Deno,On=wn&&wn.versions||Rn&&Rn.version,kn=On&&On.v8,Q,It;kn&&(Q=kn.split("."),It=Q[0]>0&&Q[0]<4?1:+(Q[0]+Q[1]));!It&&Ar&&(Q=Ar.match(/Edge\/(\d+)/),(!Q||Q[1]>=74)&&(Q=Ar.match(/Chrome\/(\d+)/),Q&&(It=+Q[1])));Vn.exports=It});var Sr=u((rm,Ln)=>{"use strict";var _n=Mn(),Zl=U(),Jl=J(),ec=Jl.String;Ln.exports=!!Object.getOwnPropertySymbols&&!Zl(function(){var r=Symbol("symbol detection");return!ec(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&_n&&_n<41})});var wr=u((im,Fn)=>{"use strict";var tc=Sr();Fn.exports=tc&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Rr=u((nm,Nn)=>{"use strict";var rc=Tt(),ic=G(),nc=Tn(),oc=wr(),sc=Object;Nn.exports=oc?function(r){return typeof r=="symbol"}:function(r){var e=rc("Symbol");return ic(e)&&nc(e.prototype,sc(r))}});var jn=u((om,$n)=>{"use strict";var ac=String;$n.exports=function(r){try{return ac(r)}catch(e){return"Object"}}});var Or=u((sm,Bn)=>{"use strict";var lc=G(),cc=jn(),uc=TypeError;Bn.exports=function(r){if(lc(r))return r;throw new uc(cc(r)+" is not a function")}});var Dn=u((am,qn)=>{"use strict";var pc=Or(),hc=Er();qn.exports=function(r,e){var t=r[e];return hc(t)?void 0:pc(t)}});var Un=u((lm,Hn)=>{"use strict";var kr=Et(),Pr=G(),Vr=Ie(),dc=TypeError;Hn.exports=function(r,e){var t,i;if(e==="string"&&Pr(t=r.toString)&&!Vr(i=kr(t,r))||Pr(t=r.valueOf)&&!Vr(i=kr(t,r))||e!=="string"&&Pr(t=r.toString)&&!Vr(i=kr(t,r)))return i;throw new dc("Can't convert object to primitive value")}});var Wn=u((cm,Gn)=>{"use strict";Gn.exports=!0});var Qn=u((um,Kn)=>{"use strict";var zn=J(),mc=Object.defineProperty;Kn.exports=function(r,e){try{mc(zn,r,{value:e,configurable:!0,writable:!0})}catch(t){zn[r]=e}return e}});var xt=u((pm,Zn)=>{"use strict";var fc=Wn(),vc=J(),bc=Qn(),Xn="__core-js_shared__",Yn=Zn.exports=vc[Xn]||bc(Xn,{});(Yn.versions||(Yn.versions=[])).push({version:"3.43.0",mode:fc?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Mr=u((hm,eo)=>{"use strict";var Jn=xt();eo.exports=function(r,e){return Jn[r]||(Jn[r]=e||{})}});var He=u((dm,to)=>{"use strict";var yc=Tr(),gc=Object;to.exports=function(r){return gc(yc(r))}});var xe=u((mm,ro)=>{"use strict";var Cc=K(),Ec=He(),Tc=Cc({}.hasOwnProperty);ro.exports=Object.hasOwn||function(e,t){return Tc(Ec(e),t)}});var _r=u((fm,io)=>{"use strict";var Ic=K(),xc=0,Ac=Math.random(),Sc=Ic(1.1.toString);io.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Sc(++xc+Ac,36)}});var Ue=u((vm,oo)=>{"use strict";var wc=J(),Rc=Mr(),no=xe(),Oc=_r(),kc=Sr(),Pc=wr(),Ae=wc.Symbol,Lr=Rc("wks"),Vc=Pc?Ae.for||Ae:Ae&&Ae.withoutSetter||Oc;oo.exports=function(r){return no(Lr,r)||(Lr[r]=kc&&no(Ae,r)?Ae[r]:Vc("Symbol."+r)),Lr[r]}});var co=u((bm,lo)=>{"use strict";var Mc=Et(),so=Ie(),ao=Rr(),_c=Dn(),Lc=Un(),Fc=Ue(),Nc=TypeError,$c=Fc("toPrimitive");lo.exports=function(r,e){if(!so(r)||ao(r))return r;var t=_c(r,$c),i;if(t){if(e===void 0&&(e="default"),i=Mc(t,r,e),!so(i)||ao(i))return i;throw new Nc("Can't convert object to primitive value")}return e===void 0&&(e="number"),Lc(r,e)}});var Fr=u((ym,uo)=>{"use strict";var jc=co(),Bc=Rr();uo.exports=function(r){var e=jc(r,"string");return Bc(e)?e:e+""}});var mo=u((gm,ho)=>{"use strict";var qc=J(),po=Ie(),Nr=qc.document,Dc=po(Nr)&&po(Nr.createElement);ho.exports=function(r){return Dc?Nr.createElement(r):{}}});var $r=u((Cm,fo)=>{"use strict";var Hc=he(),Uc=U(),Gc=mo();fo.exports=!Hc&&!Uc(function(){return Object.defineProperty(Gc("div"),"a",{get:function(){return 7}}).a!==7})});var yo=u(bo=>{"use strict";var Wc=he(),zc=Et(),Kc=yr(),Qc=gr(),Xc=qe(),Yc=Fr(),Zc=xe(),Jc=$r(),vo=Object.getOwnPropertyDescriptor;bo.f=Wc?vo:function(e,t){if(e=Xc(e),t=Yc(t),Jc)try{return vo(e,t)}catch(i){}if(Zc(e,t))return Qc(!zc(Kc.f,e,t),e[t])}});var Co=u((Tm,go)=>{"use strict";var eu=U(),tu=G(),ru=/#|\.prototype\./,Ge=function(r,e){var t=nu[iu(r)];return t===su?!0:t===ou?!1:tu(e)?eu(e):!!e},iu=Ge.normalize=function(r){return String(r).replace(ru,".").toLowerCase()},nu=Ge.data={},ou=Ge.NATIVE="N",su=Ge.POLYFILL="P";go.exports=Ge});var jr=u((Im,To)=>{"use strict";var Eo=vr(),au=Or(),lu=je(),cu=Eo(Eo.bind);To.exports=function(r,e){return au(r),e===void 0?r:lu?cu(r,e):function(){return r.apply(e,arguments)}}});var xo=u((xm,Io)=>{"use strict";var uu=he(),pu=U();Io.exports=uu&&pu(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var So=u((Am,Ao)=>{"use strict";var hu=Ie(),du=String,mu=TypeError;Ao.exports=function(r){if(hu(r))return r;throw new mu(du(r)+" is not an object")}});var Oo=u(Ro=>{"use strict";var fu=he(),vu=$r(),bu=xo(),At=So(),wo=Fr(),yu=TypeError,Br=Object.defineProperty,gu=Object.getOwnPropertyDescriptor,qr="enumerable",Dr="configurable",Hr="writable";Ro.f=fu?bu?function(e,t,i){if(At(e),t=wo(t),At(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Hr in i&&!i[Hr]){var n=gu(e,t);n&&n[Hr]&&(e[t]=i.value,i={configurable:Dr in i?i[Dr]:n[Dr],enumerable:qr in i?i[qr]:n[qr],writable:!1})}return Br(e,t,i)}:Br:function(e,t,i){if(At(e),t=wo(t),At(i),vu)try{return Br(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new yu("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Po=u((wm,ko)=>{"use strict";var Cu=he(),Eu=Oo(),Tu=gr();ko.exports=Cu?function(r,e,t){return Eu.f(r,e,Tu(1,t))}:function(r,e,t){return r[e]=t,r}});var Re=u((Rm,Mo)=>{"use strict";var We=J(),Iu=Yi(),xu=vr(),Au=G(),Su=yo().f,wu=Co(),Se=De(),Ru=jr(),we=Po(),Vo=xe();xt();var Ou=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 Iu(r,this,arguments)};return e.prototype=r.prototype,e};Mo.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,a=i?We:n?We[t]:We[t]&&We[t].prototype,s=i?Se:Se[t]||we(Se,t,{})[t],l=s.prototype,c,d,f,v,y,C,E,m,p;for(v in e)c=wu(i?v:t+(n?".":"#")+v,r.forced),d=!c&&a&&Vo(a,v),C=s[v],d&&(r.dontCallGetSet?(p=Su(a,v),E=p&&p.value):E=a[v]),y=d&&E?E:e[v],!(!c&&!o&&typeof C==typeof y)&&(r.bind&&d?m=Ru(y,We):r.wrap&&d?m=Ou(y):o&&Au(y)?m=xu(y):m=y,(r.sham||y&&y.sham||C&&C.sham)&&we(m,"sham",!0),we(s,v,m),o&&(f=t+"Prototype",Vo(Se,f)||we(Se,f,{}),we(Se[f],v,y),r.real&&l&&(c||!l[v])&&we(l,v,y)))}});var Lo=u((Om,_o)=>{"use strict";var ku=Math.ceil,Pu=Math.floor;_o.exports=Math.trunc||function(e){var t=+e;return(t>0?Pu:ku)(t)}});var ze=u((km,Fo)=>{"use strict";var Vu=Lo();Fo.exports=function(r){var e=+r;return e!==e||e===0?0:Vu(e)}});var $o=u((Pm,No)=>{"use strict";var Mu=ze(),_u=Math.max,Lu=Math.min;No.exports=function(r,e){var t=Mu(r);return t<0?_u(t+e,0):Lu(t,e)}});var Bo=u((Vm,jo)=>{"use strict";var Fu=ze(),Nu=Math.min;jo.exports=function(r){var e=Fu(r);return e>0?Nu(e,9007199254740991):0}});var Ke=u((Mm,qo)=>{"use strict";var $u=Bo();qo.exports=function(r){return $u(r.length)}});var Ur=u((_m,Ho)=>{"use strict";var ju=qe(),Bu=$o(),qu=Ke(),Do=function(r){return function(e,t,i){var n=ju(e),o=qu(n);if(o===0)return!r&&-1;var a=Bu(i,o),s;if(r&&t!==t){for(;o>a;)if(s=n[a++],s!==s)return!0}else for(;o>a;a++)if((r||a in n)&&n[a]===t)return r||a||0;return!r&&-1}};Ho.exports={includes:Do(!0),indexOf:Do(!1)}});var St=u((Lm,Uo)=>{"use strict";Uo.exports=function(){}});var Go=u(()=>{"use strict";var Du=Re(),Hu=Ur().includes,Uu=U(),Gu=St(),Wu=Uu(function(){return!Array(1).includes()});Du({target:"Array",proto:!0,forced:Wu},{includes:function(e){return Hu(this,e,arguments.length>1?arguments[1]:void 0)}});Gu("includes")});var wt=u(($m,Wo)=>{"use strict";var zu=Tt();Wo.exports=zu});var Ko=u((jm,zo)=>{"use strict";Go();var Ku=wt();zo.exports=Ku("Array","includes")});var Xo=u((Bm,Qo)=>{"use strict";var Qu=Ko();Qo.exports=Qu});var Rt=u((qm,Yo)=>{"use strict";var Xu=Xo();Yo.exports=Xu});var bs=u(()=>{"use strict";var np=Re(),op=He(),sp=Ke(),ap=ze(),lp=St();np({target:"Array",proto:!0},{at:function(e){var t=op(this),i=sp(t),n=ap(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});lp("at")});var gs=u((yv,ys)=>{"use strict";bs();var cp=wt();ys.exports=cp("Array","at")});var Es=u((gv,Cs)=>{"use strict";var up=gs();Cs.exports=up});var ei=u((Cv,Ts)=>{"use strict";var pp=Es();Ts.exports=pp});var Rs=u((Nv,ws)=>{"use strict";var mp=Mr(),fp=_r(),Ss=mp("keys");ws.exports=function(r){return Ss[r]||(Ss[r]=fp(r))}});var ks=u(($v,Os)=>{"use strict";var vp=U();Os.exports=!vp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Ms=u((jv,Vs)=>{"use strict";var bp=xe(),yp=G(),gp=He(),Cp=Rs(),Ep=ks(),Ps=Cp("IE_PROTO"),ti=Object,Tp=ti.prototype;Vs.exports=Ep?ti.getPrototypeOf:function(r){var e=gp(r);if(bp(e,Ps))return e[Ps];var t=e.constructor;return yp(t)&&e instanceof t?t.prototype:e instanceof ti?Tp:null}});var Ls=u((Bv,_s)=>{"use strict";_s.exports={}});var $s=u((qv,Ns)=>{"use strict";var Ip=K(),ri=xe(),xp=qe(),Ap=Ur().indexOf,Sp=Ls(),Fs=Ip([].push);Ns.exports=function(r,e){var t=xp(r),i=0,n=[],o;for(o in t)!ri(Sp,o)&&ri(t,o)&&Fs(n,o);for(;e.length>i;)ri(t,o=e[i++])&&(~Ap(n,o)||Fs(n,o));return n}});var Bs=u((Dv,js)=>{"use strict";js.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Ds=u((Hv,qs)=>{"use strict";var wp=$s(),Rp=Bs();qs.exports=Object.keys||function(e){return wp(e,Rp)}});var ii=u((Uv,zs)=>{"use strict";var Us=he(),Op=U(),Gs=K(),kp=Ms(),Pp=Ds(),Vp=qe(),Mp=yr().f,Ws=Gs(Mp),_p=Gs([].push),Lp=Us&&Op(function(){var r=Object.create(null);return r[2]=2,!Ws(r,2)}),Hs=function(r){return function(e){for(var t=Vp(e),i=Pp(t),n=Lp&&kp(t)===null,o=i.length,a=0,s=[],l;o>a;)l=i[a++],(!Us||(n?l in t:Ws(t,l)))&&_p(s,r?[l,t[l]]:t[l]);return s}};zs.exports={entries:Hs(!0),values:Hs(!1)}});var Ks=u(()=>{"use strict";var Fp=Re(),Np=ii().entries;Fp({target:"Object",stat:!0},{entries:function(e){return Np(e)}})});var Xs=u((zv,Qs)=>{"use strict";Ks();var $p=De();Qs.exports=$p.Object.entries});var Zs=u((Kv,Ys)=>{"use strict";var jp=Xs();Ys.exports=jp});var ea=u((Qv,Js)=>{"use strict";var Bp=Zs();Js.exports=Bp});var sa=u(()=>{"use strict";var Kp=Re(),Qp=ii().values;Kp({target:"Object",stat:!0},{values:function(e){return Qp(e)}})});var la=u((kb,aa)=>{"use strict";sa();var Xp=De();aa.exports=Xp.Object.values});var ua=u((Pb,ca)=>{"use strict";var Yp=la();ca.exports=Yp});var Yt=u((Vb,pa)=>{"use strict";var Zp=ua();pa.exports=Zp});var mi=u((ry,ba)=>{"use strict";var nh=Be();ba.exports=Array.isArray||function(e){return nh(e)==="Array"}});var ga=u((iy,ya)=>{"use strict";var oh=TypeError,sh=9007199254740991;ya.exports=function(r){if(r>sh)throw oh("Maximum allowed index exceeded");return r}});var Ta=u((ny,Ea)=>{"use strict";var ah=mi(),lh=Ke(),ch=ga(),uh=jr(),Ca=function(r,e,t,i,n,o,a,s){for(var l=n,c=0,d=a?uh(a,s):!1,f,v;c<i;)c in t&&(f=d?d(t[c],c,e):t[c],o>0&&ah(f)?(v=lh(f),l=Ca(r,e,f,v,l,o-1)-1):(ch(l+1),r[l]=f),l++),c++;return l};Ea.exports=Ca});var Aa=u((oy,xa)=>{"use strict";var ph=Ue(),hh=ph("toStringTag"),Ia={};Ia[hh]="z";xa.exports=String(Ia)==="[object z]"});var wa=u((sy,Sa)=>{"use strict";var dh=Aa(),mh=G(),Jt=Be(),fh=Ue(),vh=fh("toStringTag"),bh=Object,yh=Jt(function(){return arguments}())==="Arguments",gh=function(r,e){try{return r[e]}catch(t){}};Sa.exports=dh?Jt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=gh(e=bh(r),vh))=="string"?t:yh?Jt(e):(i=Jt(e))==="Object"&&mh(e.callee)?"Arguments":i}});var Oa=u((ay,Ra)=>{"use strict";var Ch=K(),Eh=G(),fi=xt(),Th=Ch(Function.toString);Eh(fi.inspectSource)||(fi.inspectSource=function(r){return Th(r)});Ra.exports=fi.inspectSource});var La=u((ly,_a)=>{"use strict";var Ih=K(),xh=U(),ka=G(),Ah=wa(),Sh=Tt(),wh=Oa(),Pa=function(){},Va=Sh("Reflect","construct"),vi=/^\s*(?:class|function)\b/,Rh=Ih(vi.exec),Oh=!vi.test(Pa),st=function(e){if(!ka(e))return!1;try{return Va(Pa,[],e),!0}catch(t){return!1}},Ma=function(e){if(!ka(e))return!1;switch(Ah(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Oh||!!Rh(vi,wh(e))}catch(t){return!0}};Ma.sham=!0;_a.exports=!Va||xh(function(){var r;return st(st.call)||!st(Object)||!st(function(){r=!0})||r})?Ma:st});var ja=u((cy,$a)=>{"use strict";var Fa=mi(),kh=La(),Ph=Ie(),Vh=Ue(),Mh=Vh("species"),Na=Array;$a.exports=function(r){var e;return Fa(r)&&(e=r.constructor,kh(e)&&(e===Na||Fa(e.prototype))?e=void 0:Ph(e)&&(e=e[Mh],e===null&&(e=void 0))),e===void 0?Na:e}});var qa=u((uy,Ba)=>{"use strict";var _h=ja();Ba.exports=function(r,e){return new(_h(r))(e===0?0:e)}});var Da=u(()=>{"use strict";var Lh=Re(),Fh=Ta(),Nh=He(),$h=Ke(),jh=ze(),Bh=qa();Lh({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Nh(this),i=$h(t),n=Bh(t,0);return n.length=Fh(n,t,t,i,0,e===void 0?1:jh(e)),n}})});var Ha=u(()=>{"use strict";var qh=St();qh("flat")});var Ga=u((fy,Ua)=>{"use strict";Da();Ha();var Dh=wt();Ua.exports=Dh("Array","flat")});var za=u((vy,Wa)=>{"use strict";var Hh=Ga();Wa.exports=Hh});var Qa=u((by,Ka)=>{"use strict";var Uh=za();Ka.exports=Uh});var _i="1.0.56-dev.93671684.0";import{fromEvent as vs,Subscription as ip}from"@vkontakte/videoplayer-shared/es2018";var sr=class{constructor(e,t){this.layout=e;this.cssVarsManager=t}},pt=class extends sr{constructor(t,i){super(t,i);this.cssVarsManager=i;this.cssVarsManager=i}setContainerLayout(t){t.style.position="relative"}setControlLayout(t,i){let n=this.cssVarsManager.getPropValue("--interactive-content-width"),o=this.cssVarsManager.getPropValue("--interactive-content-height"),a=this.cssVarsManager.getPropValue("--interactive-width"),s=this.cssVarsManager.getPropValue("--interactive-height"),l=2e-4;t.style.position="absolute",t.style.width=`calc(${n} * (${i.width} + ${l}))`,t.style.height=`calc(${o} * ${i.height})`,t.style.left=`calc(${n} * ${i.x} + ((${a} - ${n}) / 2))`,t.style.top=`calc(${o} * ${i.y} + ((${s} - ${o}) / 2))`}};import{Subject as wl}from"@vkontakte/videoplayer-shared/es2018";function Li(r){return"features"in r}var F=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};function ht({emitter$:r,error:e,subjectId:t,message:i="",severity:n=1,category:o=1}){let a=new F(n,o,{message:i,error:e,details:{id:t}});r.next(a)}var Ce=class{constructor(e,t,i){this.error$=new wl;this.container=e,this.options=i,this.factories=new Map,this.controls=[],this.setControls(),this.cssVarsManager=t}featureIsEnabled(e){return this.options&&this.options.features&&Li(this.options)&&this.options.features[e]}onError(e="",t){ht({emitter$:this.error$,error:t,message:e,subjectId:this.container.id})}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(),o=this.factories.get(n);if(o){let a=o(i,this.options);if(a)return[...t,a]}return[...t]},[]))||[]}};import{fromEvent as Xe,once as ss}from"@vkontakte/videoplayer-shared/es2018";var se=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,ae=r=>se(r,"Object"),dt=r=>se(r,"String"),mt=r=>se(r,"Array"),ft=r=>se(r,"Number"),Fi=r=>se(r,"Function"),Ni=r=>se(r,"Boolean"),cr=r=>ft(r)&&!isNaN(r);var ue=r=>ae(r)&&Object.keys(r).length===0,ur=r=>mt(r)&&!r.length;var Le=(r,e)=>dt(r)&&(e?r.trim():r).length;function Fe(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 $i="interactive",V={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},ji=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(ji||{}),Bi=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(Bi||{}),qi=(i=>(i.start="left",i.end="right",i.center="center",i))(qi||{}),vt=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&ji[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&Bi[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&qi[e.alignment])!=null?n:"center"},bt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,o,a,s,l,c;r.style.color=(o=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?o:t.textColor,r.style.fontSize=`calc(${i.height} * ${(s=(a=e==null?void 0:e.text)==null?void 0:a.size)!=null?s:t.textSize})`,r.textContent=(c=(l=e==null?void 0:e.text)==null?void 0:l.value)!=null?c:t.textContent},yt=({target:r,props:e,fallback:t})=>{var i,n,o,a;r.style.backgroundColor=Fe((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(a=(o=e==null?void 0:e.background)==null?void 0:o.alpha)!=null?a:t.backgroundAlpha)},Ne=({target:r,props:e,fallback:t,dependsOn:i,useRawValues:n=!1})=>{var s,l,c,d,f,v,y,C,E,m,p;let o=n?t.borderWidthRawValue:`calc(${i.height} * ${(c=(l=(s=e==null?void 0:e.shape)==null?void 0:s.border)==null?void 0:l.width)!=null?c:t.borderWidth})`,a=n?t.roundCornersRawValue:`calc(${i.height} * ${(f=(d=e==null?void 0:e.shape)==null?void 0:d.roundCorners)!=null?f:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Fe(n?t.borderColor:(C=(y=(v=e==null?void 0:e.shape)==null?void 0:v.border)==null?void 0:y.color)!=null?C:t.borderColor,n?t.borderAlpha:(p=(m=(E=e==null?void 0:e.shape)==null?void 0:E.border)==null?void 0:m.alpha)!=null?p:t.borderAlpha),r.style.borderRadius=a},Di=({target:r,isDark:e,baseDimension:t,fallback:i})=>{let a=Fe(i.shadowColorLight,i.shadowColorAlpha),s=Fe(i.shadowColorDark,i.shadowColorAlpha),l=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${l} ${c} ${e?s:a}`;r.style.boxShadow=d},Ee=({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)`};import{fromEvent as Qe,Subject as Zu,Subscription as Ju}from"@vkontakte/videoplayer-shared/es2018";var pr="interactive-control-tap",Te={common:pr,animation:`${pr}-animation`,visible:`${pr}-visible`};var Rl=60,gt=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=Rl,useDimensionsBasedSize:n=!1}){this.onElementClick=e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let i=t.getBoundingClientRect(),n={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},o=Math.min(n.width,n.height),a=i.left+i.width/2,s=i.top+i.height/2,l=e.clientX-a,c=e.clientY-s,d=Ol(l,c,this.controlRotateAngleRad);this.element.style.width=o+"px",this.element.style.left=d.x+i.width/2-o/2+"px",this.element.style.top=d.y+i.height/2-o/2+"px",this.element.classList.add(Te.visible,Te.animation)};this.onAnimationEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.element.classList.remove(Te.visible,Te.animation)};let o=document.createElement("div");o.classList.add(Te.common),this.controlRotateAngleRad=e,this.element=o,this.clickCancelCondition=t,this.circleDiameterPx=i,this.useDimensionsBasedSize=n}};function Ol(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var hr="int",pe=(i=>(i.AREA=`${hr}_area`,i.TEXT=`${hr}_text`,i.BUTTON=`${hr}_bttn`,i))(pe||{});function dr(r){return"features"in r}var Z="interactive-control",k={common:Z,selected:`${Z}-selected`,wrapper:`${Z}-wrapper`,disabled:`${Z}-disabled`,button:`${Z}-button`,area:`${Z}-area`,text:`${Z}-text`,blinkAnim:`${Z}-blink-anim`,blinkAnimButton:`${Z}-blink-anim-button`,blinkAnimArea:`${Z}-blink-anim-area`},Hi=40;var ts=Y(Rt(),1);import{isSupportedManifest as kt,ContainerTypes as ef,ControlTypes as Pt,EventActionTypes as R,EventTypes as tf,migrateManifestToLatestVersion as es,compareVersions as rf}from"@interactiveplatform/movika-manifest";var Zo={metadata:"Object",chapters:"Array"},Jo=r=>{if(!ae(r))return!1;for(let e in Zo)if(!r[e]||!se(r[e],Zo[e]))return!1;return kt(r.metadata.version)},Ot=r=>r.type===Pt.Text,Gm=r=>r.type===Pt.Button,Wm=r=>r.type===Pt.Area,zm={Choice:"Choice",TextInput:"TextInput"},Km={Button:"Button",Area:"Area",Text:"Text"},Qm={onClick:"onClick",onSuspense:"onSuspense"},Xm={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Vt=r=>mt(r)&&!ur(r),ee=r=>r.order==="end",Mt=r=>mt(r.containers)&&!ur(r.containers)&&ee(r),rs=(r,e)=>{var i;let t=r*1e3;return Vt(e.controls)&&t<((i=e.startTime)!=null?i:0)},Gr=(r,e)=>{var i,n;let t=r*1e3;return Vt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var de=(r=[])=>r.some(e=>e.action.type==="expect"),Wr=(r=[])=>r.find(e=>e.action.type==="expect"),Yu=r=>(r==null?void 0:r.length)===1,Oe=r=>Yu(r)&&Ot(r[0]);function is(r=[],e=1/0,t=[]){return r.filter(({container:i})=>!(0,ts.default)(t,i.container.id)&&de(i.container.events)&&i.container.endTime===e&&!i.isRemoved&&!i.willRemoved)}function _t({gameControllers:r=[],subjectName:e,subjectId:t,execFn:i}){for(let n of r)if(e==="container"&&n.container.container.id===t){i(n),is(r,n.container.container.endTime,[n.container.container.id]).forEach(a=>{i(a)});break}}function ns(r){for(let e of r.events)if(e.action.type==="openURI")return!0;return!1}var os=(r,e)=>{let t=E=>{let m=e.find(({container:p})=>p.container.id===E);return m==null?void 0:m.container.isRemoved},i=de(r.events)&&!t(r.id),n=(E,m=!1,p=!1)=>{let h=p?"every":"some";return E.controls[h](b=>{var x;let I=m?E.endTime===r.endTime:!0;return((x=b.events)==null?void 0:x[h](g=>{var T;return((T=g.action)==null?void 0:T.type)===R.openURI}))&&I})},o=E=>E.some(({container:m})=>n(m.container,!0,!1)&&!m.isRemoved),a=E=>E.every(({container:m})=>m.isRemoved||m.willRemoved?!0:n(m.container,!0,!0)),s=is(e,r.endTime,[r.id]).length,l=E=>E.controls.some(m=>{var p;return(p=m.events)==null?void 0:p.some(h=>{var b,I;return(I=(b=h.action)==null?void 0:b.args)==null?void 0:I.shouldOpenNow})}),c=i||s>0,d=o(e),f=n(r),v=a(e),y=i?!1:s>0,C=l(r);return{isExpectTime:c,hasOtherExpect:s>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:f,isAllOpenURIEventsValid:v,isExpectEventForCurrentContainer:y,hasShouldOpenNowEvent:C}};var le=class r{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new Ju;this.error$=new Zu;this.isInteracted=!1;this.isRemoved=!1;this.cssVarsManager=null;this.onControlSelect=()=>{var e,t,i;(e=this.container)!=null&&e.isManifestContainerDisabled()||ns(this.control)||(i=(t=this.container)==null?void 0:t.element)==null||i.classList.add("interactive-control-wrapper-selected")};this.onTransitionEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}}setCssVarsManager(e){this.cssVarsManager=e}removeView(e=!1){let t=this.getElement();if(t){if(e){if(t.classList.contains("interactive-control-before-remove"))return;t.classList.add("interactive-control-before-remove"),this.subscriptions.add(Qe(t,"transitionend").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n))).add(Qe(t,"transitioncancel").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n)));return}this.removeListeners(),t.remove(),this.isRemoved=!0}}onError(e="",t){ht({emitter$:this.error$,error:t,message:e,subjectId:this.control.id})}addControlTap(e){var t;if(this.featureIsEnabled("controlsTapPlace")&&this.container){let i=(t=this.control.layoutParams.angle)!=null?t:V.angle;this.controlTap=new gt({controlRotateAngleRad:i,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?Hi:void 0}),this.subscriptions.add(Qe(e,"click").subscribe(this.controlTap.onElementClick,n=>this.onError("Control click tap animation error",n))).add(Qe(this.controlTap.element,"animationend").subscribe(this.controlTap.onAnimationEnd,n=>this.onError("Tap animationend error",n))),this.container.element.append(this.controlTap.element)}}createContainerElement(e){var o,a,s,l,c;let t=document.createElement("div");t.classList.add(k.wrapper),e.setControlLayout(t,this.control.layoutParams);let i=((o=this.control.layoutParams.innerSizesDependOn)!=null?o:V.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:(s=(a=this.cssVarsManager)==null?void 0:a.getPropValue("--interactive-content-height"))!=null?s:0,width:(c=(l=this.cssVarsManager)==null?void 0:l.getPropValue("--interactive-content-width"))!=null?c:0},n=()=>{var d,f;return(f=(d=e.isContainerDisabled)==null?void 0:d.call(e))!=null?f:!1};this.container={element:t,dimensions:i,isManifestContainerDisabled:n}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted=!0,e()}}featureIsEnabled(e){return this.options&&dr(this.options)&&this.options.features[e]}isTouch(){return this.options&&dr(this.options)&&this.options.isTouch}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add(Qe(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),n=>this.onError("Error happened on control interaction",n)));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var zr="interactive-blink-anim-reference",N={common:zr,animation:`${zr}-animation`,disabled:`${zr}-disabled`},Lt=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(N.common,N.animation),this._element=e}restart(){this._element&&(this._element.classList.add(N.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(N.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var Kr="interactive-container",$={common:Kr,hidden:`${Kr}-hidden`,disabled:`${Kr}-disabled`};var Ft=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Qr(r,e)},Qr=class extends le{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(k.common,k.area),i.setAttribute("data-testid",pe.AREA),yt({target:i,props:this.control.props,fallback:{...V,backgroundColor:"transparent"}}),Ee({target:i,layoutParams:this.control.layoutParams,fallback:V}),this.addControlTap(i),this.subscriptions.add(Xe(this.container.element,"click").pipe(ss()).subscribe(this.onControlSelect,n=>this.onError("Control click handler error",n))),this.container.element.append(i),e.append(this.container.element),this.controlElement=i,this.updateShadowStyles(),this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(Xe(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains($.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${N.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(Xe(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains($.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(Xe(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(k.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(k.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){var t,i,n;if(!(!this.container||!this.controlElement))if(Ni(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";Di({target:this.controlElement,props:this.control.props,fallback:V,isDark:e,baseDimension:o}),Ne({target:this.controlElement,props:this.control.props,fallback:{...V,borderColor:e?V.shadowColorDark:V.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${(n=(i=(t=this.control.props)==null?void 0:t.shape)==null?void 0:i.roundCorners)!=null?n:V.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else Ne({target:this.controlElement,props:this.control.props,fallback:{...V,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(k.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(k.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${k.blinkAnimArea}`)||this.controlElement.classList.contains(k.selected)||this.controlElement.classList.contains(N.disabled)||(this.controlElement.classList.add(N.disabled),this.subscriptions.add(Xe(e,"animationiteration").pipe(ss()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(N.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${k.blinkAnimArea}`)||this.controlElement.classList.contains(k.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}};import{fromEvent as Ye,once as ms}from"@vkontakte/videoplayer-shared/es2018";var Nt=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),i={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,i),t.append(e);let n={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,n),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var $t=Math.PI,Xr=2*$t,jt=$t/2,as=3*jt,ep=0,tp=[ep,jt,$t,as];function ls(r){return r===jt}function cs(r){return r===$t}function us(r){return r===as}function ps(r){return(r%Xr+Xr)%Xr}function rp(r){for(let e of tp)if(r===e)return e}function hs(r){if(rp(r))return null;let t=Math.floor(r/jt)+1;return[1,2,3,4][t-1]}function ds(r){return r*180/Math.PI}var re="interactive-control-fill-animation",j={common:re,fillerWrapper:`${re}-filler-wrapper`,filler:`${re}-filler`,fillHeight:`${re}-fill-height`,fillWidth:`${re}-fill-width`,fromTop:`${re}-from-top`,fromBottom:`${re}-from-bottom`,fromLeft:`${re}-from-left`,fromRight:`${re}-from-right`};var Bt=class r{constructor(e){this.widthExpansionCoef=0;var m;let t=document.createElement("div");t.classList.add(j.common);let i=document.createElement("div");i.classList.add(j.fillerWrapper);let n=document.createElement("div");n.classList.add(j.filler),i.append(n),t.append(i);let o=ps(e.rotateAngle),a=hs(o),s=a!==null,c=a===2||!s&&cs(o)||a===3,d=!s&&ls(o),f=!s&&us(o),v=!c&&!d&&!f,y=d||f,C=s&&!y,E=C?o:0;t.style.borderRadius=e.borderRadius,i.style.transform=`skew(${E*-1}rad)`,y?(n.classList.add(j.fillHeight,d?j.fromTop:j.fromBottom),i.classList.add(j.fillHeight,d?j.fromTop:j.fromBottom)):(n.classList.add(j.fillWidth,v?j.fromLeft:j.fromRight),i.classList.add(j.fillWidth)),e.debug&&console.log(`[interactive ${r.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:y,rotateAngleRad:o,rotateAngelDeg:ds(o),rotateAngleRaw:e.rotateAngle,fromRight:c,fromTop:d,fromBottom:f,fromLeft:v}),this.useSkew=C,this.fromLeft=v,this.rotateAngle=o,this.fillAnimationElement=t,this.fillAnimationFillerElement=n,this.fillAnimationFillerWrapperElement=i,this.startTime=e.startTime,this.endTime=e.endTime,this.shouldFillHeight=y,this.isDebug=(m=e.debug)!=null?m:!1}updateDimension(e){this.fillAnimationElement.style.top=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.left=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.width=`${e.width}px`,this.fillAnimationElement.style.height=`${e.height}px`;let t=this.calcWidthExpansionCoef({rotateAngle:this.rotateAngle,isSkewed:this.useSkew,initWidth:e.width,initHeight:e.height});!this.shouldFillHeight&&(this.fillAnimationFillerWrapperElement.style.width=100*t+100+"%",this.fillAnimationFillerWrapperElement.style[`${this.fromLeft?"left":"right"}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((o=>o<this.startTime||o>this.endTime)(e))return;let i=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/i,0),1);this.shouldFillHeight?this.fillAnimationFillerElement.style.transform=`scaleY(${n})`:this.fillAnimationFillerElement.style.transform=`scaleX(${n})`}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:i,initHeight:n}){return t?(i+n*Math.abs(Math.tan(e)))/i-1:0}};var qt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new Yr(r,e)},Yr=class extends le{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a,s,l,c,d,f;if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(k.common,k.button),i.setAttribute("data-testid",pe.BUTTON),Ee({target:i,layoutParams:this.control.layoutParams,fallback:V}),yt({target:i,props:this.control.props,fallback:V}),Ne({target:i,props:this.control.props,fallback:V,dependsOn:this.container.dimensions}),vt({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=Nt(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;bt({target:o,props:this.control.props,fallback:V,dependsOn:this.container.dimensions}),this.addControlTap(i),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled("controlsFillAnimation")&&(this.controlFillAnimation=new Bt({startTime:this.startTime,endTime:this.endTime,rotateAngle:(s=this.control.layoutParams.angle)!=null?s:V.angle,borderRadius:i.style.borderRadius})),this.subscriptions.add(Ye(i,"click").pipe(ms()).subscribe(this.onControlSelect,v=>this.onError("Control click handler error",v))),i.append(n,(c=(l=this.controlFillAnimation)==null?void 0:l.fillAnimationElement)!=null?c:""),this.container.element.append((f=(d=this.controlTap)==null?void 0:d.element)!=null?f:"",i),e.append(this.container.element),this.controlElement=i,this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(Ye(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains($.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${N.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(Ye(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains($.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(Ye(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(k.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(k.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(k.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(k.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${k.blinkAnimButton}`)||this.controlElement.classList.contains(k.selected)||this.controlElement.classList.contains(N.disabled)||(this.controlElement.classList.add(N.disabled),this.subscriptions.add(Ye(e,"animationiteration").pipe(ms()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(N.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${k.blinkAnimButton}`)||this.controlElement.classList.contains(k.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}updateFillAnimationDimensions(){if(!this.container||!this.controlElement||!this.controlFillAnimation)return;let e=getComputedStyle(this.controlElement),t={width:parseFloat(e.width),height:parseFloat(e.height),borderWidth:parseFloat(e.borderWidth)||0};this.controlFillAnimation.updateDimension(t)}setShowTimeRange(e,t){this.startTime=e,this.endTime=t}onProgress(e){var t;(t=this.controlFillAnimation)==null||t.updateAnimation(e)}onResize(){this.updateFillAnimationDimensions()}updateShadowStyles(){}};var fs=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new Zr(r,e)},Zr=class extends le{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a;if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("div");i.classList.add(k.common,k.text),i.setAttribute("data-testid",pe.TEXT),Ee({target:i,layoutParams:this.control.layoutParams,fallback:V}),vt({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=Nt(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;bt({target:o,props:this.control.props,fallback:V,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}setShowTimeRange(){}updateFillAnimationDimensions(){}};var Dt=(r,e,t,i)=>{if(r.type.trim().toLowerCase()==="choice")return new Jr(r,e,t,i)},Jr=class r extends Ce{constructor(t,i,n,o){super(t,n,o);this.containerElement=null;this.subscriptions=new ip;this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&this.removeView()};this.rootElement=i,this.layout=new pt(this.container.layout,n),this.cssVarsManager=n,this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",qt),this.addControlFactory("text",fs),this.addControlFactory("area",Ft)}createView({eventCallback:t,videoDurationMs:i}){let n=document.createElement("div");return n.classList.add($.common,$.disabled),n.setAttribute("data-subjectId",this.container.id),requestAnimationFrame(()=>{n.classList.remove($.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(o=>{var a;o.setShowTimeRange(this.container.startTime,(a=this.container.endTime)!=null?a:i),o.setCssVarsManager(this.cssVarsManager),o.createView({parentElement:n,callbacks:{setControlLayout:(s,l)=>this.layout.setControlLayout(s,l),isContainerDisabled:()=>this.isDisabled}}),o.setEvents(t),this.subscriptions.add(o.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.willRemoved=!1,this.containerElement=n,this.updateControlsFillAnimationDimensions(),n}updateControlsFillAnimationDimensions(){for(let t of this.controls)t.updateFillAnimationDimensions()}hide(){let t=this.getElement();t&&t.classList.add($.hidden)}show(){let t=this.getElement();t&&t.classList.remove($.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove($.disabled),this.controls.forEach(i=>i.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add($.disabled),this.controls.forEach(i=>i.disable()),this.isDisabled=!0)}removeView(t=!1,i=!1){let n=this.getElement();if(n){if(t){if(this.willRemoved)return;this.willRemoved=!0,i&&n.classList.add("interactive-container-before-remove-delay"),n.classList.add("interactive-container-before-remove"),this.subscriptions.add(vs(n,"transitionend").subscribe(this.onTransitionEnd,a=>this.onError(`${r.name} remove view transition error`,a))).add(vs(n,"transitioncancel").subscribe(this.onTransitionEnd,a=>this.onError(`${r.name} remove view transition error`,a)));return}this.subscriptions.unsubscribe(),this.removeAllControls(),n.remove(),this.isRemoved=!0,this.willRemoved=!1,this.containerElement=null}}removeAllControls(t=!1){this.controls.forEach(i=>i.removeView(t))}removeNonInteractedControls(t=!1){this.controls.forEach(i=>{i.isInteracted||i.removeView(t)})}isInteracted(){return this.controls.some(t=>t.isInteracted)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,i){i&&this.controls.forEach(n=>{n.onProgress(t)})}onResize(t){t&&this.controls.forEach(i=>{i.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(i=>i.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(i=>i.toggleBlinkAnimation(t))}};var gl=Y(ei(),1);import{combine as rd,InterfaceLanguage as id,Observable as vl,once as nd,Subject as B,Subscription as Ti,ValueSubject as D,fromEvent as bl}from"@vkontakte/videoplayer-shared/es2018";import{InteractiveInterfaceClick as ct}from"@vkontakte/videoplayer-statistics/es2018";import{loadVKLangPack as hp}from"@vkontakte/videoplayer-shared/es2018";function Ze(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var Is="video_interactive",xs="videoint";var As=250,Je=class{constructor(e){this.handleZoomChange=Ze(e=>{this.lastZoomInfo=e},As);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,void 0,{isFromCenter:!0})),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,"Chapter 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,!ft(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"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:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),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=dp(e),this.resizeObserver=new ResizeObserver(Ze(this.onResize,As)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}async show(){var e;this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)}async initNgEditor(){var i;if(!this.manifest)return;let e;try{e=await hp(this.lang,Is,xs)}catch(n){(i=this.onError)==null||i.call(this,"Unable to load graph language pack")}let{GraphEditor:t}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name:n,...o})=>{var a;n==="openPreview"&&"chapterId"in o&&((a=this.onOpenPreviewClick)==null||a.call(this,o.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 dp(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 et=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 o of this._containers){let a=o.startTime-e;if(a<=n&&(o.endTime&&n<=o.endTime||o.endTime===null)){i=!0;break}n<a&&(t=t===-1?a:Math.min(t,a))}return!i&&t!==-1?t:null}}};var Ht=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 Ut=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Fi(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 ta=Y(ea(),1),Gt=class r{constructor(e){this.rootElement=e;this.rootElementProps={};this.isCssVarsSupported=r.checkCssVarsSupport(e)}static checkCssVarsSupport(e){let t="--test-key",i="test";e.style.setProperty(t,i);let n=e.style.getPropertyValue(t)===i;return n&&e.style.removeProperty(t),n}getPropValue(e){var t;return this.isCssVarsSupported?`var(${e})`:(t=this.rootElementProps[e])!=null?t:""}setup(e){if(this.rootElementProps={...this.rootElementProps,...e},this.isCssVarsSupported)for(let[t,i]of(0,ta.default)(e))this.rootElement.style.setProperty(t,i)}cleanup(){for(let e in this.rootElementProps)this.rootElement.style.removeProperty(e);this.rootElementProps={}}setProp(e,t){this.rootElementProps[e]=t,this.isCssVarsSupported&&this.rootElement.style.setProperty(e,t)}};import{ValueSubject as zp}from"@vkontakte/videoplayer-shared/es2018";var Wt=class{constructor(e){var t,i;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(i=e==null?void 0:e.manifestLoaders)!=null?i:[]}}async exec(e,t){return qp(...this.loaders[e])(t)}};function qp(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function tt(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function zt({actions:r,errors:e,chapterId:t,...i}){if(t){let n=r.getManifest();if(n){let o=r.getChapter(n.chapters,t);if(o){let a=r.getMedia(n.media,o.videoId),s=r.getGraph(n.graph,o.id);return a?{...i,actions:r,errors:e,result:{chapter:o,media:a,graph:s}}:{...i,errors:tt(e,zt.name,"Could not find media"),actions:r}}}}return{...i,errors:tt(e,zt.name,"Could not find chapter"),actions:r}}var{NativeAbortSignal:Zv,NativeAbortController:Jv}=function(r){return{NativeAbortSignal:r.AbortSignal,NativeAbortController:r.AbortController}}(typeof self!="undefined"?self:global);function ra(r){let e;try{e=new Event("abort")}catch(t){typeof document!="undefined"?document.createEvent?(e=document.createEvent("Event"),e.initEvent("abort",!1,!1)):(e=document.createEventObject(),e.type="abort"):e={type:"abort",bubbles:!1,cancelable:!1}}return e.reason=r,e}function ia(r){if(r===void 0)if(typeof document=="undefined")r=new Error("This operation was aborted"),r.name="AbortError";else try{r=new DOMException("signal is aborted without reason"),Object.defineProperty(r,"name",{value:"AbortError"})}catch(e){r=new Error("This operation was aborted"),r.name="AbortError"}return r}var Kt=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,o=i.length;n<o;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,o=i.length;n<o;n++){let a=i[n];try{a.callback.call(this,e)}catch(s){Promise.resolve().then(()=>{throw s})}a.options&&a.options.once&&this.removeEventListener(e.type,a.callback)}return!e.defaultPrevented}},ke=class extends Kt{constructor(){super(),this.listeners||Kt.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)}throwIfAborted(){let{aborted:e,reason:t="Aborted"}=this;if(e)throw t}static timeout(e){let t=new me;return setTimeout(()=>t.abort(new DOMException(`This signal is timeout in ${e}ms`,"TimeoutError")),e),t.signal}static any(e){let t=new me;function i(){t.abort(this.reason),n()}function n(){for(let o of e)o.removeEventListener("abort",i)}for(let o of e)if(o.aborted){t.abort(o.reason);break}else o.addEventListener("abort",i);return t.signal}},me=class{constructor(){Object.defineProperty(this,"signal",{value:new ke,writable:!0,configurable:!0})}abort(e){let t=ia(e),i=ra(t);this.signal.reason=t,this.signal.dispatchEvent(i)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(me.prototype[Symbol.toStringTag]="AbortController",ke.prototype[Symbol.toStringTag]="AbortSignal");function Qt(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 ni(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Qt({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||n)&&(o=function(c,d){let f;d&&d.signal&&(f=d.signal,delete d.signal);let v=new t(c,d);return f&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:f}),v},o.prototype=t.prototype);let a=e;return{fetch:(l,c)=>{let d=o&&o.prototype.isPrototypeOf(l)?l.signal:c?c.signal:void 0;if(d){let f;try{f=new DOMException("Aborted","AbortError")}catch(y){f=new Error("Aborted"),f.name="AbortError"}if(d.aborted)return Promise.reject(f);let v=new Promise((y,C)=>{d.addEventListener("abort",()=>C(f),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([v,a(l,c)])}return a(l,c)},Request:o}}var W=typeof globalThis=="object"&&globalThis||typeof window=="object"&&window;var Dp=()=>"fetch"in W,rt=Dp()&&Qt({fetch:W.fetch,Request:W.Request,AbortController:W.AbortController}),na=rt?ni({fetch:W.fetch,Request:W.Request,AbortController:W.AbortController}):void 0,oi=rt?na.fetch:W.fetch,pb=rt?na.Request:W.Request,hb=rt?me:W.AbortController,db=rt?ke:W.AbortSignal;var si=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let o=0;o<Math.max(t.length,i.length)&&!n;o++)t[o]>i[o]?n=1:t[o]<i[o]?n=-1:n=0;return n};var Hp=async r=>{try{let e={},t;if(dt(r)){t=new URL(r).href;let n=await oi(t);if(!n.ok)return{};e=await n.json()}else if(ae(r))e=r;else return{};if(!Jo(e))return{};let i=e.metadata.media;if(dt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=await oi(n);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch(n){return Wp(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function oa(r){let{manifest:e,manifestURL:t}=await Hp(r);if(!e)throw new Error("Failed on fetch");let i=es(e);return i.media=Up(i.media,t),delete i.metadata.media,i}function Xt(r,e){if(e)return r.find(t=>t.id===e)}function ai(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 li(r,e){return r.videos.find(t=>t.id===e)}function Up(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=Gp(n,e);return{...i,url:o||n}})}))}}function Gp(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Wp(r){return si(r,"3.2.0")>=0}var Pe=class extends Wt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new zp(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){var n;this.release();let i=await this.exec("manifestLoaders",{actions:{addErrorMessage:tt},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await oa((n=i.result)!=null?n:t),this}async setInitial(){return this.setNext()}async setNext(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",zt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:ai,getChapter:Xt,getMedia:li,getByBranches:this.getByBranches.bind(this),addErrorMessage:tt},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),n.result&&(this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph),this}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){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=Xt(this.manifest.chapters,t);if(n){let o=li(this.manifest.media,n.videoId),a=ai(this.manifest.graph,n.id);if(o)return{chapter:n,media:o,graph:a}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,o,a;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let s=Xt(((a=this.manifest)==null?void 0:a.chapters)||[],t);return this.getByBranches(s==null?void 0:s.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let o=this.getByChapterId(n.chapterId);return o&&i.push(o),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?ee(this.chapter):!1}};var ma=Y(Yt(),1);import{Player as Jp}from"@vkontakte/videoplayer-core/es2018";import{Subscription as pi,TracerFactory as eh,ValueSubject as th}from"@vkontakte/videoplayer-shared/es2018";var ha=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 da=Y(Yt(),1);function ci(){let r=new Map;function e({listId:o=Math.random().toString(),itemId:a=Math.random().toString(),...s}){let l=r.get(o),c={...s};return l?l[a]=c:r.set(o,{[a]:c}),{listId:o,itemId:a,...s}}function t(o){var a,s;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(a=o.statistics)==null||a.oneStat.destroy(),(s=o.statistics)==null||s.statSubscription.unsubscribe()}function i(o,a){let s=r.get(o);if(!s)throw Error("Can't remove. Not find.");if(a){let l=s[a];l&&t(l),delete s[a],Object.keys(s).length||r.delete(o)}else{for(let l of(0,da.default)(s))t(l);r.delete(o)}}function n(){for(let o of r)i(o[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var Ve=Y(Rt(),1);function ui(r,e=[]){var o,a,s;let t={},i,n=!e.length;for(let l of r.variants)if(!i&&"cover"in l&&(i=l.cover),"url"in l)switch(l.type.toLowerCase()){case"mp4":(n||(0,Ve.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[(o=l.standard)!=null?o:"Invariant quality"]:l.url});break;case"mpeg":(n||(0,Ve.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[(a=l.standard)!=null?a:"Invariant quality"]:l.url});break;case"hls":(n||(0,Ve.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:l.url}});break;case"dash":(n||(0,Ve.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:l.url}});break;default:break}return{sources:t,thumbUrl:i,title:(s=r.title)!=null?s:""}}var it=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,Ve.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var rh=2;function hi(r){let e=ci(),t=new pi,i={},n=null,o=!1,a,s=new th(null);r&&l(r);function l(m){n=m}function c(m,p,h){var x;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let I=((x=e.map.get(m))!=null?x:{})[p];if(I){i={chapterId:h,listId:m,itemId:p,...I};let g=i.player;i.subscription.add(g.info.currentQuality$.subscribe(T=>{let M=g.info.position$.getValue(),A=g.info.isAutoQualityEnabled$.getValue();if(!(!T||!M||A))for(let O of e.map)(0,ma.default)(O[1]).forEach(({player:P})=>{it(P,T)})})).add(g.events.started$.subscribe(()=>{d(p)})),I.container.remove(),n.setPlayer(I.player),o||(n.init(),o=!0),s.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}async function d(m){if(!n)throw Error("need to set interactive controller");if(ue(i)||m!==i.itemId)return;let p=n.getChapterBranches(),h=new Set;for(let b of p)h.has(b.media.id)||(await v({media:b.media,chapterId:b.chapter.id,setAsActive:!1,title:b.chapter.label}),h.add(b.media.id))}async function f({chapter:{id:m},manifestVideo:p}){if(ue(i)||!n)return;let h=i.player.info.muted$.getValue(),b=i.player.info.currentQuality$.getValue(),I=i.player.info.isAutoQualityEnabled$.getValue(),x=i.player.info.volume$.getValue(),g=i.player.info.currentPlaybackRate$.getValue(),T=!I,M=!1;for(let A of e.map)if(A[0]===p.id&&!n.state.isReplay$.getValue()){let O=Object.keys(A[1]);for(let P of O)P===i.itemId?(O.length<rh||(M=!0),e.removePlayer(A[0],P)):(M=!0,c(A[0],P,m),T?it(i.player,b):i.player.setAutoQuality(!0),i.player.setVolume(x),i.player.setMuted(h),i.player.setPlaybackRate(g))}else e.removePlayer(A[0]);M||(await v({media:p,chapterId:m,setAsActive:!0,playbackRate:g}),T?it(i.player,b):i.player.setAutoQuality(!0),i.player.setVolume(x),i.player.setMuted(h))}async function v({media:m,chapterId:p,prefetch:h=!0,setAsActive:b=!0,autoplay:I=!1,preferredExt:x,title:g,playbackRate:T}){var xi,Ai,Si,wi,Ri;let M=Math.random().toString(),A=document.createElement("div");a.append(A);let O;if((xi=n==null?void 0:n.options)!=null&&xi.vkVideoLoader){let ut=ha(m);ut.length&&(O=await n.options.vkVideoLoader(...ut))}let P=((Ai=n==null?void 0:n.options)==null?void 0:Ai.coreConfig)||void 0,X={...P,configName:[...(Si=P==null?void 0:P.configName)!=null?Si:[],"interactive"]},ce={container:A,...((wi=O==null?void 0:O.videos)==null?void 0:wi[0])||{sources:ui(m,x).sources},title:g,failoverHosts:(O==null?void 0:O.failoverHosts)||[]},q=new Jp(X,eh.createRootTracer());q.initVideo(ce);let ye=null;if(O!=null&&O.videos&&(n!=null&&n.options.createOneStat)){let ut=O.videos[0],or=n.options.createOneStat(ut),Oi=new pi;or&&(Oi.add(or.attachTo(q)),ye={oneStat:or,statSubscription:Oi})}let Ii=new pi,Cl=(Ri=i==null?void 0:i.player)==null?void 0:Ri.info.isAutoQualityEnabled$.getValue();Ii.add(q.events.canplay$.subscribe(function(){Cl||it(q,i.player.info.currentQuality$.getValue()),T&&q.setPlaybackRate(T)}));let ge=e.createPlayer({listId:m.id,itemId:M,player:q,container:A,sources:ui(m,x).sources,config:ce,subscription:Ii,statistics:ye});return b&&c(m.id,ge.itemId,p),I&&ge.player.play(),h&&!I&&ge.player.prepare(),{player:ge.player,config:ge.config,statistics:ge.statistics}}function y(){C(),n=null,a.remove()}function C(){t.unsubscribe(),e.removeAll(),i={},o=!1}async function E(){if(!n)throw Error("need to set interactive controller");C(),a=document.createElement("div");let{media:m,chapter:p}=n.getCurrentChapter();m&&p?(t.add(n.events.chapterChanged$.subscribe(f)),await v({media:m,chapterId:p.id,title:p.label})):console.error("not found")}return{...e,init:E,setInteractiveController:l,createPlayer:v,removeAll:y,getActivePlayer:function(){return i},activePlayerChanged:s}}var w={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},nt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},_={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};import{Subscription as ih}from"@vkontakte/videoplayer-shared/es2018";function di(r){return function(...t){return r(...t.reverse())}}function ot(r,...e){return(...t)=>ae(e[0])&&ae(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var Zt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:a,globalEventEmitter:s,getContainerEventState:l,permanentTextControls:c,interactiveTimeOpenUri:d,disabledControls$:f,onRemove:v,onError:y,disableTextControlContainerVisibilityEvents:C=!1,features:E}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(de(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,i,n,o,a,s;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:l}=this.getContainerEventState();if((i=(t=this.container).show)==null||i.call(t),this.interactiveTimeOpenUri&&l||this.disableTextControlContainerVisibilityEvents)return;this.emitContainerVisibilityEvent(!0,!1)}else{let l={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(f,v)=>{let{isExpectTime:y,hasOtherExpect:C,hasOpenURIEvent:E,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:p,hasShouldOpenNowEvent:h}=this.getContainerEventState(),b=this.interactiveTimeOpenUri&&!m,I=this.interactiveTimeOpenUri&&m;if((!this.interactiveTimeOpenUri||b)&&(this.isSelectedControlEvent=!0),f!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||b)){if(this.interactiveTimeOpenUri){let x=!C&&!p&&m;x&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:x})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&E&&this.gameState!==5){if(I){let g=((T,M,A,O)=>!T&&!M&&A||T&&!M&&A&&!O||T&&!M&&A&&O)(y,C,p,this.isSelectedContainerEvent);this.fakeRemoveView(g)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!y||!C||!h)&&(this.selectBranches.stopExpect(),v())}},isEOV:()=>this.gameState===4},c=ot(this.selectBranches.onControlEvent,l),d=((o=(n=this.player)==null?void 0:n.info.duration$.getValue())!=null?o:1/0)*1e3;this.container.createView({eventCallback:c,videoDurationMs:d}),this.disableTextControlContainerVisibilityEvents||this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((s=(a=this.container).disable)==null||s.call(a))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var l,c,d;let e=this.player.experimental.element$.getValue(),t=e instanceof HTMLVideoElement;if(this.features.enableAvPlayerSupport&&(t||(t=e instanceof HTMLObjectElement&&(e==null?void 0:e.getAttribute("type"))==="application/avplayer")),!(t?e==null?void 0:e.readyState:void 0)||this.isRemovedOrDestroyed()&&!this.isPermanentText)return;let n=this.player.getExactTime();if(rs(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Gr(n,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{let{hasOpenURIEventInCurrentContainer:f}=this.getContainerEventState(),v=this.selectBranches.state.isExpect,y=this.interactiveTimeOpenUri&&f;if(y&&!v){let C=this.container.getElement();C&&(C.style.visibility!=="hidden"&&((c=(l=this.container).hide)==null||c.call(l)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!y&&this.removeView()}let o=Gr(n,this.container.container),a=this.container.container.startTime?[this.container.container.startTime,(d=this.container.container.endTime)!=null?d:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:a,currentTime:n,isInteractiveTime:o};this.container.onProgress(n*1e3,o),this.globalEventEmitter.emit(w.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new ih,this.player=e,this.interactiveEvents=o,this.getContainerEventState=l;let m=Oe(t.container.controls);this.isPermanentText=c&&m,this.disableTextControlContainerVisibilityEvents=C&&m,this.interactiveTimeOpenUri=d,this.disabledControls$=f,this.onRemove=v,this.globalEventEmitter=s,this.gameState=0,this.globalEvents=a,this.onError=y,this.features=E,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{var t,i,n,o;e?(i=(t=this.container).disable)==null||i.call(t):(o=(n=this.container).enable)==null||o.call(n)})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){var i,n;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(i=this.container.container.endTime)!=null?i:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((n=this.container.container.endTime)!=null?n:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),i=this.interactiveTimeOpenUri?e||t:de(this.container.container.events)||e;(this.isSelectedControlEvent||!i)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(e=this.features.controlsHideAnimation){var t;if(e){if(this.isRemovedOrDestroyed())return;this.container.removeNonInteractedControls(!0),this.container.removeView(!0,!0)}else this.container.removeView();this.globalEventEmitter.emit(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,(t=this.onRemove)==null||t.call(this)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}isInteracted(){return this.container.isInteracted()}isRemovedOrDestroyed(e=!0){let t=e?this.container.willRemoved:!1;return this.gameState===5||t||this.gameState===6}destroy(e=!1){var t;this.reset(),this.removeView(e),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(t=this.container.container.endTime)!=null?t:1/0,id:this.container.container.id})}};var va=(r=[])=>r.reduce((e,t,i)=>{var o,a,s;let n=((o=t==null?void 0:t.controls)!=null?o:[]).filter(l=>!Ot(l));if(Vt(n)){let l=[(a=t.startTime)!=null?a:0,(s=t.endTime)!=null?s:1/0],c={id:t.id,isRemoved:!1};if(!i)e.push({subjects:[c],range:l});else{let d=[],f=-1/0,v=1/0,y=[],C=[];for(let E=0;E<e.length;E++){let m=e[E];if(C.push(...m.subjects),m.range[0]<v&&(v=m.range[0]),m.range[1]>f&&(f=m.range[1]),l[0]>=m.range[0]&&l[1]<=m.range[1])return e[E].subjects.push(c),e;l[0]<m.range[0]&&l[1]>m.range[0]&&(d.push(E),y=y.concat(m.subjects)),l[0]>=m.range[0]&&l[0]<=m.range[1]&&(d.push(E),y=y.concat(m.subjects),l[0]=m.range[0]),l[1]>=m.range[0]&&l[1]<=m.range[1]&&(d.push(E),y=y.concat(m.subjects),l[1]=m.range[1])}if(C.push(c),l[0]<=v&&l[1]>=f)return[{subjects:C,range:l}];d.length&&d.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:y.concat([c]),range:l})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var Ya=Y(Rt(),1),bi=Y(Yt(),1),Za=Y(Qa(),1);function Xa(){let r={};function e(){for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]}function t(s){let l={};for(let c in r)+c<=s&&(l[c]=r[c]);return l}function i(s){let l={};for(let c in r)+c>=s&&(l[c]=r[c]);return l}function n({timestamp:s,priority:l,initiator:c}){var d;if(cr(s)){let f=(d=r[s])!=null?d:null;if(f&&l&&Le(l,!0)){let v={},y=f[l];if(y&&(v={...v,...y}),v=ue(v)?null:v,v&&Le(c,!0)){let C=v[c];return C!=null?C:null}return v}return f}return null}function o({timestamp:s,priority:l,initiator:c}){if(cr(s))if(r[s]){if(l&&Le(l,!0))if(r[s][l]){if(c&&Le(c,!0))if(r[s][l][c]){if(delete r[s][l][c],!ue(r[s][l]))return!0}else return!1;if(delete r[s][l],!ue(r[s]))return!0}else return!1;return delete r[s]}else return!1;return!1}function a({timestamp:s,priority:l,initiator:c,...d}){var f,v,y;(v=(f=r[s])==null?void 0:f[l])!=null&&v[c]?r[s][l][c].push({...d}):(y=r[s])!=null&&y[l]?r[s][l]={...r[s][l],[c]:[{...d}]}:r[s]?r[s]={...r[s],[l]:{[c]:[{...d}]}}:r[s]={[l]:{[c]:[{...d}]}}}return{map:r,remove:o,add:a,removeAll:e,get:n,getLte:t,getGte:i}}var Gh=[R.expect,R.setNextBranch],Wh=1/0;function Ja(r,e){let t=r,i,n=zh(e),o=Xa(),a,s=()=>{y(),p()},l=h=>{o.add.call(void 0,h),C()},c=(h=[])=>{for(let b of h)if(b.action(),(0,Ya.default)(Gh,b.actionType))break},d=(h=1/0)=>{var g,T,M;let b=er((g=o.get({timestamp:h,priority:"control"}))!=null?g:{}),I=er((T=o.get({timestamp:h,priority:"container"}))!=null?T:{}),x=er((M=o.get({timestamp:h,priority:"chapter"}))!=null?M:{});return[...b,...I,...x]},f=h=>{n.isReady(h)&&c(d(h))},v=()=>{var h;c([...er((h=o.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},y=()=>{i&&(a==null||a.unsubscribe(),i=void 0)},C=()=>{i||(i=()=>setTimeout(()=>{f(1/0)}),a=t.events.ended$.subscribe(i))},E=h=>{y(),t=h},m=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),o.remove(h)},p=()=>{n.release(),o.removeAll()};return{setPlayer:E,add:l,remove:m,exec:f,execEndOfVideo:v,listen:C,unlisten:y,release:s,containersEventsCallState:n,getPreparedToExecActions:d}}function zh(r){let e=new Map;return{setCalled:({timestamp:s,id:l})=>{let c=e.get(s);c&&c[l]!==void 0&&(c[l]=!0)},setData:(s=[])=>{var l;for(let c of s){let d=(l=c.endTime)!=null?l:Wh,f=e.get(d);e.set(d,{...f,[c.id]:!1})}},resetCalled:s=>{let l=e.get(s);if(l)for(let c in l)l[c]=!1},isReady:s=>{let l=e.get(s);if(!l)return!0;let c=(0,bi.default)(l);return r?c.some(f=>f):!c.some(f=>!f)},release:()=>e.clear()}}function er(r){return(0,Za.default)((0,bi.default)(r)).sort(e=>e.actionType===R.expect?-1:1)}var el={videoContentHeight:0,videoContentWidth:0},tl=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return el;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return el;let o=e/t,a=i/n,s,l;return a>o?(l=n,s=n*o):a<o?(l=i/o,s=i):(l=n,s=i),{videoContentWidth:l,videoContentHeight:s}};var Kh=250;function rl(r){let e,t=new ResizeObserver(s=>{o(s),e=o.bind(null,s)});function i(s){let{parentElement:l,player:c,cssVarsManager:d}=r();if(!l||!c)return;let{videoContentWidth:f,videoContentHeight:v}=tl(c);d.setup({"--interactive-content-width":`${f}px`,"--interactive-content-height":`${v}px`,"--interactive-width":`${s[0].contentRect.width}px`,"--interactive-height":`${s[0].contentRect.height}px`})}function n(){let{parentElement:s}=r();s.removeAttribute("style")}let o=Ze(s=>{let{fns:l=[]}=r();i(s);for(let c of l)c()},Kh);function a(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:a}}var Qh=r=>Math.floor(Math.random()*r),nl=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let o=r[e],a=(n=o.weight)!=null?n:1;a<t&&(t=a,i=o)}return i},ol=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let o=r[e],a=(n=o.weight)!=null?n:0;a>t&&(t=a,i=o)}return i};var sl=r=>{let e=r.length,t=Qh(e);return r[t]},il=1,al=r=>{var i,n;let e=0;for(let o=0;o<r.length;++o)e+=(i=r[o].weight)!=null?i:il;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(n=r[o].weight)!=null?n:il,e>=t)return r[o];return r[r.length-1]};var ll={shouldOpenNow:!0,isDetachContainer:!0},cl="after-expect",yi=(r,e=!1)=>({...r,args:e?{...r.args,...ll}:{...ll,...r.args}}),ul=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},a=({action:p,controlType:h,controlId:b,containerId:I,branches:x=[],onEvent:g,isEOV:T=()=>!1,isDisabled:M=()=>!1})=>{let A=yi(p,T()),O={timestamp:1/0,priority:"control",initiator:b,actionType:A.type},P=M(),X=r.emit.bind(r,w.interactives,{subjectId:b,subjectType:h,subjectName:"control",type:P?_.actionChoiceCanceled:_.actionChoice,actionType:p.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:I,...A.args}}),ce=()=>{e.interactiveActionChoice$.next({subjectId:b,subjectType:h,subjectName:"control",type:P?"action-choice-canceled":"action-choice",actionType:p.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:I,...A.args}})};if(P){X(),ce();return}switch(A.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let q=x.find(ye=>ye.id===A.args.branchId);if(!q)return;g(A.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),X(),ce(),A.args.shouldOpenNow?E({subjectId:b,subjectName:"control",subjectType:h,action:A,payload:{chapterId:q.chapterId,autoSelect:!1}}):i.add({...O,action:E.bind(null,{subjectId:b,subjectName:"control",subjectType:h,action:A,payload:{chapterId:q.chapterId,autoSelect:!1}})});return}case R.continuePlayback.trim().toLowerCase():{g(A.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),X(),ce(),A.args.shouldOpenNow?C({subjectId:b,subjectName:"control",subjectType:h,action:p}):i.add({...O,action:C.bind(null,{subjectId:b,subjectName:"control",subjectType:h,action:p})});return}case R.openURI.trim().toLowerCase():{g(A.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),X(),ce(),A.args.shouldOpenNow?m({subjectId:b,subjectName:"control",subjectType:h,action:A,payload:{URI:p.args.uri}}):i.add({...O,action:m.bind(null,{subjectId:b,subjectName:"control",subjectType:h,action:A,payload:{URI:p.args.uri}})});return}default:{let q="Unexpected control event",ye=new F(1,1,{message:q});d(ye,q);return}}},s=({action:p,container:{id:h,endTime:b},branches:I=[],isEOV:x=!1,autoSelected:g=!1})=>{let T=yi(p,x),M={timestamp:!T.args.shouldOpenNow||x?1/0:b!=null?b:1/0,priority:"container",initiator:h,actionType:T.type},A=r.emit.bind(r,w.interactives,{subjectId:h,subjectName:"container",type:_.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),O=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}})};switch(T.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let P=I.find(X=>X.id===T.args.branchId);if(!P)return;A(),O(),i.add({...M,action:E.bind(null,{subjectId:h,subjectName:"container",action:T,payload:{chapterId:P.chapterId,autoSelect:g}})});return}case R.setMaxWeightBranch.trim().toLowerCase():return;case R.setMinWeightBranch.trim().toLowerCase():return;case R.setRandomBranch.trim().toLowerCase():return;case R.setWeightlessRandomBranch.trim().toLowerCase():return;case R.continuePlayback.trim().toLowerCase():{A(),O(),i.add({...M,action:C.bind(null,{subjectId:h,subjectName:"container",action:T})});return}case R.openURI.trim().toLowerCase():{A(),O(),i.add({...M,action:m.bind(null,{subjectId:h,subjectName:"container",action:T,payload:{URI:p.args.uri}})});return}default:{let P="Unexpected container event",X=new F(1,1,{message:P});d(X,P);return}}};function l({container:p,branches:h,isEOV:b=!1}){var x,g;let I=Wr(p.events);if(I){let T=yi(I.action,b);r.emit(w.interactives,{subjectId:p.id,subjectName:"container",type:_.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),i.add({timestamp:b?1/0:(x=p.endTime)!=null?x:1/0,priority:"container",initiator:p.id,actionType:R.expect,action:v.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let T of(g=p.events)!=null?g:[])s({action:T.action,container:p,branches:h,isEOV:b})}let c=({chapterId:p,action:h,branches:b=[]})=>{let I=r.emit.bind(r,w.interactives,{subjectId:p,subjectName:"chapter",type:_.actionChoice,actionType:h.type,payload:h.args}),x=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let g=b.find(T=>T.id===h.args.branchId);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setWeightlessRandomBranch.trim().toLowerCase():{let g=sl(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setRandomBranch.trim().toLowerCase():{let g=al(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setMaxWeightBranch.trim().toLowerCase():{let g=ol(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setMinWeightBranch.trim().toLowerCase():{let g=nl(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.continuePlayback.trim().toLowerCase():return I(),x(),C.bind(null,{subjectId:p,subjectName:"chapter",action:h});case R.openURI.trim().toLowerCase():return I(),x(),m.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let g="Unexpected chapter event",T=new F(1,1,{message:g});d(T,g);return}}};function d(p,h){console.error(h),e.error$.next(p),r.emit(w.errors,p)}function f(p){var b;let h=Wr(p.events);if(h){if(ee(p))return;r.emit(w.interactives,{subjectId:p.id,subjectName:"chapter",type:_.actionChoice,actionType:h.action.type,payload:h.action.args}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"chapter",type:"action-choice",actionType:h.action.type,payload:h.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:R.expect,action:v.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(b=p.events)==null||b.forEach(I=>{let x=c({chapterId:p.id,action:I.action,branches:p.branches});x&&i.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:I.action.type,action:x})})}let v=({subjectId:p,subjectName:h})=>{t.pause(),r.emit(w.interactives,{subjectId:p,subjectName:h,type:_.actionExecution,actionType:R.expect}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:R.expect})},y=({subjectId:p,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(w.interactives,{subjectId:p,subjectName:h,type:_.actionExecution,actionType:cl}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:cl})},C=({subjectId:p,subjectName:h,subjectType:b,action:I})=>{r.emit(w.interactives,{subjectId:p,subjectName:h,subjectType:b,type:_.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:b,type:"action-execution",actionType:I.type})},E=({subjectId:p,subjectName:h,subjectType:b,action:I,payload:x})=>{x.behaviour="change-chapter",r.emit(w.interactives,{subjectId:p,subjectName:h,subjectType:b,type:_.actionExecution,actionType:I.type,payload:x}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:b,type:"action-execution",actionType:I.type,payload:x})},m=({subjectId:p,subjectName:h,subjectType:b,action:I,payload:x})=>{if(!x.URI)return;let g=window.open(x.URI,"_blank","noopener,noreferrer");g&&(g.opener=null),r.emit(w.interactives,{subjectId:p,subjectName:h,subjectType:b,type:_.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:b,type:"action-execution",actionType:I.type})};return{onControlEvent:a,onContainerEvent:s,onChapterEvent:c,onExpectEvent:v,expectEventHandler:y,setManifestChapterEvents:f,setManifestContainerEvents:l,stopExpect:o,state:n}};var Ei=Y(ei(),1);import{Subscription as ed,Subject as Ci,ValueSubject as at}from"@vkontakte/videoplayer-shared/es2018";var gi=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(a=>a.id===i);if(!n)return null;let o=e.media.videos.find(a=>n.videoId===a.id);if(!o)return null;t[i]=pl(o)}return t[i]}).filter(Boolean)},Yh=r=>{for(let e of r.variants)if(Zh(e)&&e.payload)return e.payload.id},Zh=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),pl=r=>{let e=Yh(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Jh=(r,e)=>{for(let t of r.media.videos)if(e===pl(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},hl=(r,e)=>r.reduce((t,i)=>{let n=Jh(e,i);return n?[...t,n]:t},[]);var ie,fe,ve,z,tr,ne,oe,te,be,Me,_e,lt=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new at([]),hasPrevChapter$:new at(!1),prevChapter$:new at(null),isInitialChapter$:new at(!1),isGoBackLimited$:new at(!1)};H(this,ie,null);H(this,fe);H(this,ve,!1);H(this,z,null);H(this,tr,null);this.events={inited$:new Ci,destroyed$:new Ci,error$:new Ci};H(this,ne,null);H(this,oe,null);H(this,te,null);H(this,be,new ed);H(this,Me,!1);H(this,_e,0);var a;L(this,ne,t),L(this,te,e),L(this,oe,i),L(this,ie,n),L(this,fe,o),this.state.history$&&S(this,be)&&((a=S(this,be))==null||a.add(this.state.history$.subscribe(s=>{var l,c;this.state.prevChapter$.next((0,Ei.default)(s,-2)||null),this.state.hasPrevChapter$.next(s.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(l=S(this,z))==null?void 0:l.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(S(this,_e)===S(this,fe).maxLength-1)})))}async setManifest(e){if(!S(this,oe)||!S(this,te))return;L(this,z,e),await this.getProjectHistory();let t=this.getInitialChapterId();await S(this,oe).setChapter({chapterId:t,pushToHistory:!1}),S(this,ve)||(L(this,ve,!0),this.events.inited$.next({initChapterId:t}))}get inited(){return S(this,ve)}async updateHistory(e,t=!0){var s;if(!S(this,z))return;S(this,Me)?(L(this,Me,!1),Mi(this,_e)._++):L(this,_e,0);let i=S(this,z),n=e.length-S(this,fe).maxLength,o=n>0?e.slice(n):e,a=gi(o,i);if(L(this,tr,a),this.state.history$.next(o),!(!t||!S(this,ie)||!S(this,ne)))try{await S(this,ie).save(S(this,ne),a)}catch(l){let c=new F(1,5,"Unable to save interactive history");this.events.error$.next(c),(s=S(this,te))==null||s.emit(w.errors,c)}}async goBack(){var i;if(!this.state||!S(this,oe)){let n=new F(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=S(this,te))==null?void 0:i.emit(w.errors,n)}L(this,Me,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await S(this,oe).setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){var n;if(!S(this,z)||!S(this,ne))return;let e=S(this,z),t=[this.getInitialVideoId()];if(S(this,ie))try{let o=await S(this,ie).get(S(this,ne));o.length&&(t=o)}catch(o){let a=new F(1,5,"Error while trying to fetch data");this.events.error$.next(a),(n=S(this,te))==null||n.emit(w.errors,a)}let i=hl(t,e);this.state.history$.next(i)}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,Ei.default)(e,-1)||S(this,fe).initChapterId||((t=S(this,z))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(S(this,z)){let e=this.getInitialChapterId();return gi([e],S(this,z)).pop()}return null}destroy(){var e,t;L(this,ne,null),L(this,ie,null),L(this,oe,null),(e=S(this,be))==null||e.unsubscribe(),L(this,be,null),L(this,ve,!1),(t=S(this,te))==null||t.emit(w.historyDestroyed),this.events.destroyed$.next(),L(this,te,null)}};ie=new WeakMap,fe=new WeakMap,ve=new WeakMap,z=new WeakMap,tr=new WeakMap,ne=new WeakMap,oe=new WeakMap,te=new WeakMap,be=new WeakMap,Me=new WeakMap,_e=new WeakMap;var rr=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 o=3;o<i;o+=40)if(t[o]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}async updateCanvasDimensions(e,t=!1){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var ir=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
+ var Cl=Object.create;var Oi=Object.defineProperty;var El=Object.getOwnPropertyDescriptor;var Tl=Object.getOwnPropertyNames;var Il=Object.getPrototypeOf,xl=Object.prototype.hasOwnProperty;var ki=r=>{throw TypeError(r)};var u=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Al=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Tl(e))!xl.call(r,n)&&n!==t&&Oi(r,n,{get:()=>e[n],enumerable:!(i=El(e,n))||i.enumerable});return r};var Y=(r,e,t)=>(t=r!=null?Cl(Il(r)):{},Al(e||!r||!r.__esModule?Oi(t,"default",{value:r,enumerable:!0}):t,r));var Pi=(r,e,t)=>e.has(r)||ki("Cannot "+t);var S=(r,e,t)=>(Pi(r,e,"read from private field"),t?t.call(r):e.get(r)),H=(r,e,t)=>e.has(r)?ki("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),_=(r,e,t,i)=>(Pi(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var Vi=(r,e,t,i)=>({set _(n){_(r,e,n,t)},get _(){return S(r,e,i)}});var J=u((mr,Hi)=>{"use strict";var $e=function(r){return r&&r.Math===Math&&r};Hi.exports=$e(typeof globalThis=="object"&&globalThis)||$e(typeof window=="object"&&window)||$e(typeof self=="object"&&self)||$e(typeof global=="object"&&global)||$e(typeof mr=="object"&&mr)||function(){return this}()||Function("return this")()});var U=u((_d,Ui)=>{"use strict";Ui.exports=function(r){try{return!!r()}catch(e){return!0}}});var je=u((Ld,Gi)=>{"use strict";var Ol=U();Gi.exports=!Ol(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Xi=u((Fd,Qi)=>{"use strict";var kl=je(),Ki=Function.prototype,Wi=Ki.apply,zi=Ki.call;Qi.exports=typeof Reflect=="object"&&Reflect.apply||(kl?zi.bind(Wi):function(){return zi.apply(Wi,arguments)})});var K=u((Nd,Ji)=>{"use strict";var Yi=je(),Zi=Function.prototype,fr=Zi.call,Pl=Yi&&Zi.bind.bind(fr,fr);Ji.exports=Yi?Pl:function(r){return function(){return fr.apply(r,arguments)}}});var Be=u(($d,tn)=>{"use strict";var en=K(),Vl=en({}.toString),Ml=en("".slice);tn.exports=function(r){return Ml(Vl(r),8,-1)}});var vr=u((jd,rn)=>{"use strict";var _l=Be(),Ll=K();rn.exports=function(r){if(_l(r)==="Function")return Ll(r)}});var G=u((Bd,nn)=>{"use strict";var br=typeof document=="object"&&document.all;nn.exports=typeof br=="undefined"&&br!==void 0?function(r){return typeof r=="function"||r===br}:function(r){return typeof r=="function"}});var he=u((qd,on)=>{"use strict";var Fl=U();on.exports=!Fl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Et=u((Dd,sn)=>{"use strict";var Nl=je(),Ct=Function.prototype.call;sn.exports=Nl?Ct.bind(Ct):function(){return Ct.apply(Ct,arguments)}});var yr=u(cn=>{"use strict";var an={}.propertyIsEnumerable,ln=Object.getOwnPropertyDescriptor,$l=ln&&!an.call({1:2},1);cn.f=$l?function(e){var t=ln(this,e);return!!t&&t.enumerable}:an});var gr=u((Ud,un)=>{"use strict";un.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var hn=u((Gd,pn)=>{"use strict";var jl=K(),Bl=U(),ql=Be(),Cr=Object,Dl=jl("".split);pn.exports=Bl(function(){return!Cr("z").propertyIsEnumerable(0)})?function(r){return ql(r)==="String"?Dl(r,""):Cr(r)}:Cr});var Er=u((Wd,dn)=>{"use strict";dn.exports=function(r){return r==null}});var Tr=u((zd,mn)=>{"use strict";var Hl=Er(),Ul=TypeError;mn.exports=function(r){if(Hl(r))throw new Ul("Can't call method on "+r);return r}});var qe=u((Kd,fn)=>{"use strict";var Gl=hn(),Wl=Tr();fn.exports=function(r){return Gl(Wl(r))}});var Ie=u((Qd,vn)=>{"use strict";var zl=G();vn.exports=function(r){return typeof r=="object"?r!==null:zl(r)}});var De=u((Xd,bn)=>{"use strict";bn.exports={}});var Tt=u((Yd,gn)=>{"use strict";var Ir=De(),xr=J(),Kl=G(),yn=function(r){return Kl(r)?r:void 0};gn.exports=function(r,e){return arguments.length<2?yn(Ir[r])||yn(xr[r]):Ir[r]&&Ir[r][e]||xr[r]&&xr[r][e]}});var En=u((Zd,Cn)=>{"use strict";var Ql=K();Cn.exports=Ql({}.isPrototypeOf)});var An=u((Jd,xn)=>{"use strict";var Xl=J(),Tn=Xl.navigator,In=Tn&&Tn.userAgent;xn.exports=In?String(In):""});var Vn=u((em,Pn)=>{"use strict";var kn=J(),Ar=An(),Sn=kn.process,wn=kn.Deno,Rn=Sn&&Sn.versions||wn&&wn.version,On=Rn&&Rn.v8,Q,It;On&&(Q=On.split("."),It=Q[0]>0&&Q[0]<4?1:+(Q[0]+Q[1]));!It&&Ar&&(Q=Ar.match(/Edge\/(\d+)/),(!Q||Q[1]>=74)&&(Q=Ar.match(/Chrome\/(\d+)/),Q&&(It=+Q[1])));Pn.exports=It});var Sr=u((tm,_n)=>{"use strict";var Mn=Vn(),Yl=U(),Zl=J(),Jl=Zl.String;_n.exports=!!Object.getOwnPropertySymbols&&!Yl(function(){var r=Symbol("symbol detection");return!Jl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Mn&&Mn<41})});var wr=u((rm,Ln)=>{"use strict";var ec=Sr();Ln.exports=ec&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Rr=u((im,Fn)=>{"use strict";var tc=Tt(),rc=G(),ic=En(),nc=wr(),oc=Object;Fn.exports=nc?function(r){return typeof r=="symbol"}:function(r){var e=tc("Symbol");return rc(e)&&ic(e.prototype,oc(r))}});var $n=u((nm,Nn)=>{"use strict";var sc=String;Nn.exports=function(r){try{return sc(r)}catch(e){return"Object"}}});var Or=u((om,jn)=>{"use strict";var ac=G(),lc=$n(),cc=TypeError;jn.exports=function(r){if(ac(r))return r;throw new cc(lc(r)+" is not a function")}});var qn=u((sm,Bn)=>{"use strict";var uc=Or(),pc=Er();Bn.exports=function(r,e){var t=r[e];return pc(t)?void 0:uc(t)}});var Hn=u((am,Dn)=>{"use strict";var kr=Et(),Pr=G(),Vr=Ie(),hc=TypeError;Dn.exports=function(r,e){var t,i;if(e==="string"&&Pr(t=r.toString)&&!Vr(i=kr(t,r))||Pr(t=r.valueOf)&&!Vr(i=kr(t,r))||e!=="string"&&Pr(t=r.toString)&&!Vr(i=kr(t,r)))return i;throw new hc("Can't convert object to primitive value")}});var Gn=u((lm,Un)=>{"use strict";Un.exports=!0});var Kn=u((cm,zn)=>{"use strict";var Wn=J(),dc=Object.defineProperty;zn.exports=function(r,e){try{dc(Wn,r,{value:e,configurable:!0,writable:!0})}catch(t){Wn[r]=e}return e}});var xt=u((um,Yn)=>{"use strict";var mc=Gn(),fc=J(),vc=Kn(),Qn="__core-js_shared__",Xn=Yn.exports=fc[Qn]||vc(Qn,{});(Xn.versions||(Xn.versions=[])).push({version:"3.43.0",mode:mc?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Mr=u((pm,Jn)=>{"use strict";var Zn=xt();Jn.exports=function(r,e){return Zn[r]||(Zn[r]=e||{})}});var He=u((hm,eo)=>{"use strict";var bc=Tr(),yc=Object;eo.exports=function(r){return yc(bc(r))}});var xe=u((dm,to)=>{"use strict";var gc=K(),Cc=He(),Ec=gc({}.hasOwnProperty);to.exports=Object.hasOwn||function(e,t){return Ec(Cc(e),t)}});var _r=u((mm,ro)=>{"use strict";var Tc=K(),Ic=0,xc=Math.random(),Ac=Tc(1.1.toString);ro.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Ac(++Ic+xc,36)}});var Ue=u((fm,no)=>{"use strict";var Sc=J(),wc=Mr(),io=xe(),Rc=_r(),Oc=Sr(),kc=wr(),Ae=Sc.Symbol,Lr=wc("wks"),Pc=kc?Ae.for||Ae:Ae&&Ae.withoutSetter||Rc;no.exports=function(r){return io(Lr,r)||(Lr[r]=Oc&&io(Ae,r)?Ae[r]:Pc("Symbol."+r)),Lr[r]}});var lo=u((vm,ao)=>{"use strict";var Vc=Et(),oo=Ie(),so=Rr(),Mc=qn(),_c=Hn(),Lc=Ue(),Fc=TypeError,Nc=Lc("toPrimitive");ao.exports=function(r,e){if(!oo(r)||so(r))return r;var t=Mc(r,Nc),i;if(t){if(e===void 0&&(e="default"),i=Vc(t,r,e),!oo(i)||so(i))return i;throw new Fc("Can't convert object to primitive value")}return e===void 0&&(e="number"),_c(r,e)}});var Fr=u((bm,co)=>{"use strict";var $c=lo(),jc=Rr();co.exports=function(r){var e=$c(r,"string");return jc(e)?e:e+""}});var ho=u((ym,po)=>{"use strict";var Bc=J(),uo=Ie(),Nr=Bc.document,qc=uo(Nr)&&uo(Nr.createElement);po.exports=function(r){return qc?Nr.createElement(r):{}}});var $r=u((gm,mo)=>{"use strict";var Dc=he(),Hc=U(),Uc=ho();mo.exports=!Dc&&!Hc(function(){return Object.defineProperty(Uc("div"),"a",{get:function(){return 7}}).a!==7})});var bo=u(vo=>{"use strict";var Gc=he(),Wc=Et(),zc=yr(),Kc=gr(),Qc=qe(),Xc=Fr(),Yc=xe(),Zc=$r(),fo=Object.getOwnPropertyDescriptor;vo.f=Gc?fo:function(e,t){if(e=Qc(e),t=Xc(t),Zc)try{return fo(e,t)}catch(i){}if(Yc(e,t))return Kc(!Wc(zc.f,e,t),e[t])}});var go=u((Em,yo)=>{"use strict";var Jc=U(),eu=G(),tu=/#|\.prototype\./,Ge=function(r,e){var t=iu[ru(r)];return t===ou?!0:t===nu?!1:eu(e)?Jc(e):!!e},ru=Ge.normalize=function(r){return String(r).replace(tu,".").toLowerCase()},iu=Ge.data={},nu=Ge.NATIVE="N",ou=Ge.POLYFILL="P";yo.exports=Ge});var jr=u((Tm,Eo)=>{"use strict";var Co=vr(),su=Or(),au=je(),lu=Co(Co.bind);Eo.exports=function(r,e){return su(r),e===void 0?r:au?lu(r,e):function(){return r.apply(e,arguments)}}});var Io=u((Im,To)=>{"use strict";var cu=he(),uu=U();To.exports=cu&&uu(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Ao=u((xm,xo)=>{"use strict";var pu=Ie(),hu=String,du=TypeError;xo.exports=function(r){if(pu(r))return r;throw new du(hu(r)+" is not an object")}});var Ro=u(wo=>{"use strict";var mu=he(),fu=$r(),vu=Io(),At=Ao(),So=Fr(),bu=TypeError,Br=Object.defineProperty,yu=Object.getOwnPropertyDescriptor,qr="enumerable",Dr="configurable",Hr="writable";wo.f=mu?vu?function(e,t,i){if(At(e),t=So(t),At(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Hr in i&&!i[Hr]){var n=yu(e,t);n&&n[Hr]&&(e[t]=i.value,i={configurable:Dr in i?i[Dr]:n[Dr],enumerable:qr in i?i[qr]:n[qr],writable:!1})}return Br(e,t,i)}:Br:function(e,t,i){if(At(e),t=So(t),At(i),fu)try{return Br(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new bu("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var ko=u((Sm,Oo)=>{"use strict";var gu=he(),Cu=Ro(),Eu=gr();Oo.exports=gu?function(r,e,t){return Cu.f(r,e,Eu(1,t))}:function(r,e,t){return r[e]=t,r}});var Re=u((wm,Vo)=>{"use strict";var We=J(),Tu=Xi(),Iu=vr(),xu=G(),Au=bo().f,Su=go(),Se=De(),wu=jr(),we=ko(),Po=xe();xt();var Ru=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 Tu(r,this,arguments)};return e.prototype=r.prototype,e};Vo.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,a=i?We:n?We[t]:We[t]&&We[t].prototype,s=i?Se:Se[t]||we(Se,t,{})[t],l=s.prototype,c,d,f,v,y,C,E,m,p;for(v in e)c=Su(i?v:t+(n?".":"#")+v,r.forced),d=!c&&a&&Po(a,v),C=s[v],d&&(r.dontCallGetSet?(p=Au(a,v),E=p&&p.value):E=a[v]),y=d&&E?E:e[v],!(!c&&!o&&typeof C==typeof y)&&(r.bind&&d?m=wu(y,We):r.wrap&&d?m=Ru(y):o&&xu(y)?m=Iu(y):m=y,(r.sham||y&&y.sham||C&&C.sham)&&we(m,"sham",!0),we(s,v,m),o&&(f=t+"Prototype",Po(Se,f)||we(Se,f,{}),we(Se[f],v,y),r.real&&l&&(c||!l[v])&&we(l,v,y)))}});var _o=u((Rm,Mo)=>{"use strict";var Ou=Math.ceil,ku=Math.floor;Mo.exports=Math.trunc||function(e){var t=+e;return(t>0?ku:Ou)(t)}});var ze=u((Om,Lo)=>{"use strict";var Pu=_o();Lo.exports=function(r){var e=+r;return e!==e||e===0?0:Pu(e)}});var No=u((km,Fo)=>{"use strict";var Vu=ze(),Mu=Math.max,_u=Math.min;Fo.exports=function(r,e){var t=Vu(r);return t<0?Mu(t+e,0):_u(t,e)}});var jo=u((Pm,$o)=>{"use strict";var Lu=ze(),Fu=Math.min;$o.exports=function(r){var e=Lu(r);return e>0?Fu(e,9007199254740991):0}});var Ke=u((Vm,Bo)=>{"use strict";var Nu=jo();Bo.exports=function(r){return Nu(r.length)}});var Ur=u((Mm,Do)=>{"use strict";var $u=qe(),ju=No(),Bu=Ke(),qo=function(r){return function(e,t,i){var n=$u(e),o=Bu(n);if(o===0)return!r&&-1;var a=ju(i,o),s;if(r&&t!==t){for(;o>a;)if(s=n[a++],s!==s)return!0}else for(;o>a;a++)if((r||a in n)&&n[a]===t)return r||a||0;return!r&&-1}};Do.exports={includes:qo(!0),indexOf:qo(!1)}});var St=u((_m,Ho)=>{"use strict";Ho.exports=function(){}});var Uo=u(()=>{"use strict";var qu=Re(),Du=Ur().includes,Hu=U(),Uu=St(),Gu=Hu(function(){return!Array(1).includes()});qu({target:"Array",proto:!0,forced:Gu},{includes:function(e){return Du(this,e,arguments.length>1?arguments[1]:void 0)}});Uu("includes")});var wt=u((Nm,Go)=>{"use strict";var Wu=Tt();Go.exports=Wu});var zo=u(($m,Wo)=>{"use strict";Uo();var zu=wt();Wo.exports=zu("Array","includes")});var Qo=u((jm,Ko)=>{"use strict";var Ku=zo();Ko.exports=Ku});var Rt=u((Bm,Xo)=>{"use strict";var Qu=Qo();Xo.exports=Qu});var vs=u(()=>{"use strict";var ip=Re(),np=He(),op=Ke(),sp=ze(),ap=St();ip({target:"Array",proto:!0},{at:function(e){var t=np(this),i=op(t),n=sp(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});ap("at")});var ys=u((bv,bs)=>{"use strict";vs();var lp=wt();bs.exports=lp("Array","at")});var Cs=u((yv,gs)=>{"use strict";var cp=ys();gs.exports=cp});var ei=u((gv,Es)=>{"use strict";var up=Cs();Es.exports=up});var ws=u((Fv,Ss)=>{"use strict";var dp=Mr(),mp=_r(),As=dp("keys");Ss.exports=function(r){return As[r]||(As[r]=mp(r))}});var Os=u((Nv,Rs)=>{"use strict";var fp=U();Rs.exports=!fp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Vs=u(($v,Ps)=>{"use strict";var vp=xe(),bp=G(),yp=He(),gp=ws(),Cp=Os(),ks=gp("IE_PROTO"),ti=Object,Ep=ti.prototype;Ps.exports=Cp?ti.getPrototypeOf:function(r){var e=yp(r);if(vp(e,ks))return e[ks];var t=e.constructor;return bp(t)&&e instanceof t?t.prototype:e instanceof ti?Ep:null}});var _s=u((jv,Ms)=>{"use strict";Ms.exports={}});var Ns=u((Bv,Fs)=>{"use strict";var Tp=K(),ri=xe(),Ip=qe(),xp=Ur().indexOf,Ap=_s(),Ls=Tp([].push);Fs.exports=function(r,e){var t=Ip(r),i=0,n=[],o;for(o in t)!ri(Ap,o)&&ri(t,o)&&Ls(n,o);for(;e.length>i;)ri(t,o=e[i++])&&(~xp(n,o)||Ls(n,o));return n}});var js=u((qv,$s)=>{"use strict";$s.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var qs=u((Dv,Bs)=>{"use strict";var Sp=Ns(),wp=js();Bs.exports=Object.keys||function(e){return Sp(e,wp)}});var ii=u((Hv,Ws)=>{"use strict";var Hs=he(),Rp=U(),Us=K(),Op=Vs(),kp=qs(),Pp=qe(),Vp=yr().f,Gs=Us(Vp),Mp=Us([].push),_p=Hs&&Rp(function(){var r=Object.create(null);return r[2]=2,!Gs(r,2)}),Ds=function(r){return function(e){for(var t=Pp(e),i=kp(t),n=_p&&Op(t)===null,o=i.length,a=0,s=[],l;o>a;)l=i[a++],(!Hs||(n?l in t:Gs(t,l)))&&Mp(s,r?[l,t[l]]:t[l]);return s}};Ws.exports={entries:Ds(!0),values:Ds(!1)}});var zs=u(()=>{"use strict";var Lp=Re(),Fp=ii().entries;Lp({target:"Object",stat:!0},{entries:function(e){return Fp(e)}})});var Qs=u((Wv,Ks)=>{"use strict";zs();var Np=De();Ks.exports=Np.Object.entries});var Ys=u((zv,Xs)=>{"use strict";var $p=Qs();Xs.exports=$p});var Js=u((Kv,Zs)=>{"use strict";var jp=Ys();Zs.exports=jp});var oa=u(()=>{"use strict";var zp=Re(),Kp=ii().values;zp({target:"Object",stat:!0},{values:function(e){return Kp(e)}})});var aa=u((Ob,sa)=>{"use strict";oa();var Qp=De();sa.exports=Qp.Object.values});var ca=u((kb,la)=>{"use strict";var Xp=aa();la.exports=Xp});var Yt=u((Pb,ua)=>{"use strict";var Yp=ca();ua.exports=Yp});var mi=u((ty,va)=>{"use strict";var ih=Be();va.exports=Array.isArray||function(e){return ih(e)==="Array"}});var ya=u((ry,ba)=>{"use strict";var nh=TypeError,oh=9007199254740991;ba.exports=function(r){if(r>oh)throw nh("Maximum allowed index exceeded");return r}});var Ea=u((iy,Ca)=>{"use strict";var sh=mi(),ah=Ke(),lh=ya(),ch=jr(),ga=function(r,e,t,i,n,o,a,s){for(var l=n,c=0,d=a?ch(a,s):!1,f,v;c<i;)c in t&&(f=d?d(t[c],c,e):t[c],o>0&&sh(f)?(v=ah(f),l=ga(r,e,f,v,l,o-1)-1):(lh(l+1),r[l]=f),l++),c++;return l};Ca.exports=ga});var xa=u((ny,Ia)=>{"use strict";var uh=Ue(),ph=uh("toStringTag"),Ta={};Ta[ph]="z";Ia.exports=String(Ta)==="[object z]"});var Sa=u((oy,Aa)=>{"use strict";var hh=xa(),dh=G(),Jt=Be(),mh=Ue(),fh=mh("toStringTag"),vh=Object,bh=Jt(function(){return arguments}())==="Arguments",yh=function(r,e){try{return r[e]}catch(t){}};Aa.exports=hh?Jt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=yh(e=vh(r),fh))=="string"?t:bh?Jt(e):(i=Jt(e))==="Object"&&dh(e.callee)?"Arguments":i}});var Ra=u((sy,wa)=>{"use strict";var gh=K(),Ch=G(),fi=xt(),Eh=gh(Function.toString);Ch(fi.inspectSource)||(fi.inspectSource=function(r){return Eh(r)});wa.exports=fi.inspectSource});var _a=u((ay,Ma)=>{"use strict";var Th=K(),Ih=U(),Oa=G(),xh=Sa(),Ah=Tt(),Sh=Ra(),ka=function(){},Pa=Ah("Reflect","construct"),vi=/^\s*(?:class|function)\b/,wh=Th(vi.exec),Rh=!vi.test(ka),st=function(e){if(!Oa(e))return!1;try{return Pa(ka,[],e),!0}catch(t){return!1}},Va=function(e){if(!Oa(e))return!1;switch(xh(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Rh||!!wh(vi,Sh(e))}catch(t){return!0}};Va.sham=!0;Ma.exports=!Pa||Ih(function(){var r;return st(st.call)||!st(Object)||!st(function(){r=!0})||r})?Va:st});var $a=u((ly,Na)=>{"use strict";var La=mi(),Oh=_a(),kh=Ie(),Ph=Ue(),Vh=Ph("species"),Fa=Array;Na.exports=function(r){var e;return La(r)&&(e=r.constructor,Oh(e)&&(e===Fa||La(e.prototype))?e=void 0:kh(e)&&(e=e[Vh],e===null&&(e=void 0))),e===void 0?Fa:e}});var Ba=u((cy,ja)=>{"use strict";var Mh=$a();ja.exports=function(r,e){return new(Mh(r))(e===0?0:e)}});var qa=u(()=>{"use strict";var _h=Re(),Lh=Ea(),Fh=He(),Nh=Ke(),$h=ze(),jh=Ba();_h({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Fh(this),i=Nh(t),n=jh(t,0);return n.length=Lh(n,t,t,i,0,e===void 0?1:$h(e)),n}})});var Da=u(()=>{"use strict";var Bh=St();Bh("flat")});var Ua=u((my,Ha)=>{"use strict";qa();Da();var qh=wt();Ha.exports=qh("Array","flat")});var Wa=u((fy,Ga)=>{"use strict";var Dh=Ua();Ga.exports=Dh});var Ka=u((vy,za)=>{"use strict";var Hh=Wa();za.exports=Hh});var Mi="1.0.56-dev.c21b8ad0.0";import{fromEvent as fs,Subscription as rp}from"@vkontakte/videoplayer-shared/es2018";var sr=class{constructor(e,t){this.layout=e;this.cssVarsManager=t}},pt=class extends sr{constructor(t,i){super(t,i);this.cssVarsManager=i;this.cssVarsManager=i}setContainerLayout(t){t.style.position="relative"}setControlLayout(t,i){let n=this.cssVarsManager.getPropValue("--interactive-content-width"),o=this.cssVarsManager.getPropValue("--interactive-content-height"),a=this.cssVarsManager.getPropValue("--interactive-width"),s=this.cssVarsManager.getPropValue("--interactive-height"),l=2e-4;t.style.position="absolute",t.style.width=`calc(${n} * (${i.width} + ${l}))`,t.style.height=`calc(${o} * ${i.height})`,t.style.left=`calc(${n} * ${i.x} + ((${a} - ${n}) / 2))`,t.style.top=`calc(${o} * ${i.y} + ((${s} - ${o}) / 2))`}};import{Subject as Sl}from"@vkontakte/videoplayer-shared/es2018";function _i(r){return"features"in r}var F=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};function ht({emitter$:r,error:e,subjectId:t,message:i="",severity:n=1,category:o=1}){let a=new F(n,o,{message:i,error:e,details:{id:t}});r.next(a)}var Ce=class{constructor(e,t,i){this.error$=new Sl;this.container=e,this.options=i,this.factories=new Map,this.controls=[],this.setControls(),this.cssVarsManager=t}featureIsEnabled(e){return this.options&&this.options.features&&_i(this.options)&&this.options.features[e]}onError(e="",t){ht({emitter$:this.error$,error:t,message:e,subjectId:this.container.id})}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(),o=this.factories.get(n);if(o){let a=o(i,this.options);if(a)return[...t,a]}return[...t]},[]))||[]}};import{fromEvent as Xe,once as os}from"@vkontakte/videoplayer-shared/es2018";var se=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,ae=r=>se(r,"Object"),dt=r=>se(r,"String"),mt=r=>se(r,"Array"),ft=r=>se(r,"Number"),Li=r=>se(r,"Function"),Fi=r=>se(r,"Boolean"),cr=r=>ft(r)&&!isNaN(r);var ue=r=>ae(r)&&Object.keys(r).length===0,ur=r=>mt(r)&&!r.length;var Le=(r,e)=>dt(r)&&(e?r.trim():r).length;function Fe(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 Ni="interactive",P={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},$i=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))($i||{}),ji=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(ji||{}),Bi=(i=>(i.start="left",i.end="right",i.center="center",i))(Bi||{}),vt=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&$i[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&ji[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&Bi[e.alignment])!=null?n:"center"},bt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,o,a,s,l,c;r.style.color=(o=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?o:t.textColor,r.style.fontSize=`calc(${i.height} * ${(s=(a=e==null?void 0:e.text)==null?void 0:a.size)!=null?s:t.textSize})`,r.textContent=(c=(l=e==null?void 0:e.text)==null?void 0:l.value)!=null?c:t.textContent},yt=({target:r,props:e,fallback:t})=>{var i,n,o,a;r.style.backgroundColor=Fe((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(a=(o=e==null?void 0:e.background)==null?void 0:o.alpha)!=null?a:t.backgroundAlpha)},Ne=({target:r,props:e,fallback:t,dependsOn:i,useRawValues:n=!1})=>{var s,l,c,d,f,v,y,C,E,m,p;let o=n?t.borderWidthRawValue:`calc(${i.height} * ${(c=(l=(s=e==null?void 0:e.shape)==null?void 0:s.border)==null?void 0:l.width)!=null?c:t.borderWidth})`,a=n?t.roundCornersRawValue:`calc(${i.height} * ${(f=(d=e==null?void 0:e.shape)==null?void 0:d.roundCorners)!=null?f:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Fe(n?t.borderColor:(C=(y=(v=e==null?void 0:e.shape)==null?void 0:v.border)==null?void 0:y.color)!=null?C:t.borderColor,n?t.borderAlpha:(p=(m=(E=e==null?void 0:e.shape)==null?void 0:E.border)==null?void 0:m.alpha)!=null?p:t.borderAlpha),r.style.borderRadius=a},qi=({target:r,isDark:e,baseDimension:t,fallback:i})=>{let a=Fe(i.shadowColorLight,i.shadowColorAlpha),s=Fe(i.shadowColorDark,i.shadowColorAlpha),l=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${l} ${c} ${e?s:a}`;r.style.boxShadow=d},Ee=({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)`};import{fromEvent as Qe,Subject as Yu,Subscription as Zu}from"@vkontakte/videoplayer-shared/es2018";var pr="interactive-control-tap",Te={common:pr,animation:`${pr}-animation`,visible:`${pr}-visible`};var wl=60,gt=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=wl,useDimensionsBasedSize:n=!1}){this.onElementClick=e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let i=t.getBoundingClientRect(),n={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},o=Math.min(n.width,n.height),a=i.left+i.width/2,s=i.top+i.height/2,l=e.clientX-a,c=e.clientY-s,d=Rl(l,c,this.controlRotateAngleRad);this.element.style.width=o+"px",this.element.style.left=d.x+i.width/2-o/2+"px",this.element.style.top=d.y+i.height/2-o/2+"px",this.element.classList.add(Te.visible,Te.animation)};this.onAnimationEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.element.classList.remove(Te.visible,Te.animation)};let o=document.createElement("div");o.classList.add(Te.common),this.controlRotateAngleRad=e,this.element=o,this.clickCancelCondition=t,this.circleDiameterPx=i,this.useDimensionsBasedSize=n}};function Rl(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var hr="int",pe=(i=>(i.AREA=`${hr}_area`,i.TEXT=`${hr}_text`,i.BUTTON=`${hr}_bttn`,i))(pe||{});function dr(r){return"features"in r}var Z="interactive-control",k={common:Z,selected:`${Z}-selected`,wrapper:`${Z}-wrapper`,disabled:`${Z}-disabled`,button:`${Z}-button`,area:`${Z}-area`,text:`${Z}-text`,blinkAnim:`${Z}-blink-anim`,blinkAnimButton:`${Z}-blink-anim-button`,blinkAnimArea:`${Z}-blink-anim-area`},Di=40;var es=Y(Rt(),1);import{isSupportedManifest as kt,ContainerTypes as Jm,ControlTypes as Pt,EventActionTypes as R,EventTypes as ef,migrateManifestToLatestVersion as Jo,compareVersions as tf}from"@interactiveplatform/movika-manifest";var Yo={metadata:"Object",chapters:"Array"},Zo=r=>{if(!ae(r))return!1;for(let e in Yo)if(!r[e]||!se(r[e],Yo[e]))return!1;return kt(r.metadata.version)},Ot=r=>r.type===Pt.Text,Um=r=>r.type===Pt.Button,Gm=r=>r.type===Pt.Area,Wm={Choice:"Choice",TextInput:"TextInput"},zm={Button:"Button",Area:"Area",Text:"Text"},Km={onClick:"onClick",onSuspense:"onSuspense"},Qm={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Vt=r=>mt(r)&&!ur(r),ee=r=>r.order==="end",Mt=r=>mt(r.containers)&&!ur(r.containers)&&ee(r),ts=(r,e)=>{var i;let t=r*1e3;return Vt(e.controls)&&t<((i=e.startTime)!=null?i:0)},Gr=(r,e)=>{var i,n;let t=r*1e3;return Vt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var de=(r=[])=>r.some(e=>e.action.type==="expect"),Wr=(r=[])=>r.find(e=>e.action.type==="expect"),Xu=r=>(r==null?void 0:r.length)===1,Oe=r=>Xu(r)&&Ot(r[0]);function rs(r=[],e=1/0,t=[]){return r.filter(({container:i})=>!(0,es.default)(t,i.container.id)&&de(i.container.events)&&i.container.endTime===e&&!i.isRemoved&&!i.willRemoved)}function _t({gameControllers:r=[],subjectName:e,subjectId:t,execFn:i}){for(let n of r)if(e==="container"&&n.container.container.id===t){i(n),rs(r,n.container.container.endTime,[n.container.container.id]).forEach(a=>{i(a)});break}}function is(r){for(let e of r.events)if(e.action.type==="openURI")return!0;return!1}var ns=(r,e)=>{let t=E=>{let m=e.find(({container:p})=>p.container.id===E);return m==null?void 0:m.container.isRemoved},i=de(r.events)&&!t(r.id),n=(E,m=!1,p=!1)=>{let h=p?"every":"some";return E.controls[h](b=>{var x;let I=m?E.endTime===r.endTime:!0;return((x=b.events)==null?void 0:x[h](g=>{var T;return((T=g.action)==null?void 0:T.type)===R.openURI}))&&I})},o=E=>E.some(({container:m})=>n(m.container,!0,!1)&&!m.isRemoved),a=E=>E.every(({container:m})=>m.isRemoved||m.willRemoved?!0:n(m.container,!0,!0)),s=rs(e,r.endTime,[r.id]).length,l=E=>E.controls.some(m=>{var p;return(p=m.events)==null?void 0:p.some(h=>{var b,I;return(I=(b=h.action)==null?void 0:b.args)==null?void 0:I.shouldOpenNow})}),c=i||s>0,d=o(e),f=n(r),v=a(e),y=i?!1:s>0,C=l(r);return{isExpectTime:c,hasOtherExpect:s>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:f,isAllOpenURIEventsValid:v,isExpectEventForCurrentContainer:y,hasShouldOpenNowEvent:C}};var le=class r{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new Zu;this.error$=new Yu;this.isInteracted=!1;this.isRemoved=!1;this.cssVarsManager=null;this.onControlSelect=()=>{var e,t,i;(e=this.container)!=null&&e.isManifestContainerDisabled()||is(this.control)||(i=(t=this.container)==null?void 0:t.element)==null||i.classList.add("interactive-control-wrapper-selected")};this.onTransitionEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}}setCssVarsManager(e){this.cssVarsManager=e}removeView(e=!1){let t=this.getElement();if(t){if(e){if(t.classList.contains("interactive-control-before-remove"))return;t.classList.add("interactive-control-before-remove"),this.subscriptions.add(Qe(t,"transitionend").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n))).add(Qe(t,"transitioncancel").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n)));return}this.removeListeners(),t.remove(),this.isRemoved=!0}}onError(e="",t){ht({emitter$:this.error$,error:t,message:e,subjectId:this.control.id})}addControlTap(e){var t;if(this.featureIsEnabled("controlsTapPlace")&&this.container){let i=(t=this.control.layoutParams.angle)!=null?t:P.angle;this.controlTap=new gt({controlRotateAngleRad:i,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?Di:void 0}),this.subscriptions.add(Qe(e,"click").subscribe(this.controlTap.onElementClick,n=>this.onError("Control click tap animation error",n))).add(Qe(this.controlTap.element,"animationend").subscribe(this.controlTap.onAnimationEnd,n=>this.onError("Tap animationend error",n))),this.container.element.append(this.controlTap.element)}}createContainerElement(e){var o,a,s,l,c;let t=document.createElement("div");t.classList.add(k.wrapper),e.setControlLayout(t,this.control.layoutParams);let i=((o=this.control.layoutParams.innerSizesDependOn)!=null?o:P.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:(s=(a=this.cssVarsManager)==null?void 0:a.getPropValue("--interactive-content-height"))!=null?s:0,width:(c=(l=this.cssVarsManager)==null?void 0:l.getPropValue("--interactive-content-width"))!=null?c:0},n=()=>{var d,f;return(f=(d=e.isContainerDisabled)==null?void 0:d.call(e))!=null?f:!1};this.container={element:t,dimensions:i,isManifestContainerDisabled:n}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted=!0,e()}}featureIsEnabled(e){return this.options&&dr(this.options)&&this.options.features[e]}isTouch(){return this.options&&dr(this.options)&&this.options.isTouch}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add(Qe(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),n=>this.onError("Error happened on control interaction",n)));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var zr="interactive-blink-anim-reference",N={common:zr,animation:`${zr}-animation`,disabled:`${zr}-disabled`},Lt=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(N.common,N.animation),this._element=e}restart(){this._element&&(this._element.classList.add(N.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(N.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var Kr="interactive-container",$={common:Kr,hidden:`${Kr}-hidden`,disabled:`${Kr}-disabled`};var Ft=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Qr(r,e)},Qr=class extends le{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(k.common,k.area),i.setAttribute("data-testid",pe.AREA),yt({target:i,props:this.control.props,fallback:{...P,backgroundColor:"transparent"}}),Ee({target:i,layoutParams:this.control.layoutParams,fallback:P}),this.addControlTap(i),this.subscriptions.add(Xe(this.container.element,"click").pipe(os()).subscribe(this.onControlSelect,n=>this.onError("Control click handler error",n))),this.container.element.append(i),e.append(this.container.element),this.controlElement=i,this.updateShadowStyles(),this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(Xe(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains($.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${N.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(Xe(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains($.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(Xe(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(k.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(k.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){var t,i,n;if(!(!this.container||!this.controlElement))if(Fi(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";qi({target:this.controlElement,props:this.control.props,fallback:P,isDark:e,baseDimension:o}),Ne({target:this.controlElement,props:this.control.props,fallback:{...P,borderColor:e?P.shadowColorDark:P.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${(n=(i=(t=this.control.props)==null?void 0:t.shape)==null?void 0:i.roundCorners)!=null?n:P.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else Ne({target:this.controlElement,props:this.control.props,fallback:{...P,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(k.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(k.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${k.blinkAnimArea}`)||this.controlElement.classList.contains(k.selected)||this.controlElement.classList.contains(N.disabled)||(this.controlElement.classList.add(N.disabled),this.subscriptions.add(Xe(e,"animationiteration").pipe(os()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(N.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${k.blinkAnimArea}`)||this.controlElement.classList.contains(k.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}};import{fromEvent as Ye,once as ds}from"@vkontakte/videoplayer-shared/es2018";var Nt=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),i={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,i),t.append(e);let n={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,n),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var $t=Math.PI,Xr=2*$t,jt=$t/2,ss=3*jt,Ju=0,ep=[Ju,jt,$t,ss];function as(r){return r===jt}function ls(r){return r===$t}function cs(r){return r===ss}function us(r){return(r%Xr+Xr)%Xr}function tp(r){for(let e of ep)if(r===e)return e}function ps(r){if(tp(r))return null;let t=Math.floor(r/jt)+1;return[1,2,3,4][t-1]}function hs(r){return r*180/Math.PI}var re="interactive-control-fill-animation",j={common:re,fillerWrapper:`${re}-filler-wrapper`,filler:`${re}-filler`,fillHeight:`${re}-fill-height`,fillWidth:`${re}-fill-width`,fromTop:`${re}-from-top`,fromBottom:`${re}-from-bottom`,fromLeft:`${re}-from-left`,fromRight:`${re}-from-right`};var Bt=class r{constructor(e){this.widthExpansionCoef=0;var m;let t=document.createElement("div");t.classList.add(j.common);let i=document.createElement("div");i.classList.add(j.fillerWrapper);let n=document.createElement("div");n.classList.add(j.filler),i.append(n),t.append(i);let o=us(e.rotateAngle),a=ps(o),s=a!==null,c=a===2||!s&&ls(o)||a===3,d=!s&&as(o),f=!s&&cs(o),v=!c&&!d&&!f,y=d||f,C=s&&!y,E=C?o:0;t.style.borderRadius=e.borderRadius,i.style.transform=`skew(${E*-1}rad)`,y?(n.classList.add(j.fillHeight,d?j.fromTop:j.fromBottom),i.classList.add(j.fillHeight,d?j.fromTop:j.fromBottom)):(n.classList.add(j.fillWidth,v?j.fromLeft:j.fromRight),i.classList.add(j.fillWidth)),e.debug&&console.log(`[interactive ${r.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:y,rotateAngleRad:o,rotateAngelDeg:hs(o),rotateAngleRaw:e.rotateAngle,fromRight:c,fromTop:d,fromBottom:f,fromLeft:v}),this.useSkew=C,this.fromLeft=v,this.rotateAngle=o,this.fillAnimationElement=t,this.fillAnimationFillerElement=n,this.fillAnimationFillerWrapperElement=i,this.startTime=e.startTime,this.endTime=e.endTime,this.shouldFillHeight=y,this.isDebug=(m=e.debug)!=null?m:!1}updateDimension(e){this.fillAnimationElement.style.top=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.left=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.width=`${e.width}px`,this.fillAnimationElement.style.height=`${e.height}px`;let t=this.calcWidthExpansionCoef({rotateAngle:this.rotateAngle,isSkewed:this.useSkew,initWidth:e.width,initHeight:e.height});!this.shouldFillHeight&&(this.fillAnimationFillerWrapperElement.style.width=100*t+100+"%",this.fillAnimationFillerWrapperElement.style[`${this.fromLeft?"left":"right"}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((o=>o<this.startTime||o>this.endTime)(e))return;let i=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/i,0),1);this.shouldFillHeight?this.fillAnimationFillerElement.style.transform=`scaleY(${n})`:this.fillAnimationFillerElement.style.transform=`scaleX(${n})`}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:i,initHeight:n}){return t?(i+n*Math.abs(Math.tan(e)))/i-1:0}};var qt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new Yr(r,e)},Yr=class extends le{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a,s,l,c,d,f;if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(k.common,k.button),i.setAttribute("data-testid",pe.BUTTON),Ee({target:i,layoutParams:this.control.layoutParams,fallback:P}),yt({target:i,props:this.control.props,fallback:P}),Ne({target:i,props:this.control.props,fallback:P,dependsOn:this.container.dimensions}),vt({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=Nt(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;bt({target:o,props:this.control.props,fallback:P,dependsOn:this.container.dimensions}),this.addControlTap(i),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled("controlsFillAnimation")&&(this.controlFillAnimation=new Bt({startTime:this.startTime,endTime:this.endTime,rotateAngle:(s=this.control.layoutParams.angle)!=null?s:P.angle,borderRadius:i.style.borderRadius})),this.subscriptions.add(Ye(i,"click").pipe(ds()).subscribe(this.onControlSelect,v=>this.onError("Control click handler error",v))),i.append(n,(c=(l=this.controlFillAnimation)==null?void 0:l.fillAnimationElement)!=null?c:""),this.container.element.append((f=(d=this.controlTap)==null?void 0:d.element)!=null?f:"",i),e.append(this.container.element),this.controlElement=i,this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(Ye(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains($.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${N.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(Ye(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains($.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(Ye(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(k.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(k.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(k.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(k.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${k.blinkAnimButton}`)||this.controlElement.classList.contains(k.selected)||this.controlElement.classList.contains(N.disabled)||(this.controlElement.classList.add(N.disabled),this.subscriptions.add(Ye(e,"animationiteration").pipe(ds()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(N.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${k.blinkAnimButton}`)||this.controlElement.classList.contains(k.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}updateFillAnimationDimensions(){if(!this.container||!this.controlElement||!this.controlFillAnimation)return;let e=getComputedStyle(this.controlElement),t={width:parseFloat(e.width),height:parseFloat(e.height),borderWidth:parseFloat(e.borderWidth)||0};this.controlFillAnimation.updateDimension(t)}setShowTimeRange(e,t){this.startTime=e,this.endTime=t}onProgress(e){var t;(t=this.controlFillAnimation)==null||t.updateAnimation(e)}onResize(){this.updateFillAnimationDimensions()}updateShadowStyles(){}};var ms=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new Zr(r,e)},Zr=class extends le{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a;if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("div");i.classList.add(k.common,k.text),i.setAttribute("data-testid",pe.TEXT),Ee({target:i,layoutParams:this.control.layoutParams,fallback:P}),vt({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=Nt(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;bt({target:o,props:this.control.props,fallback:P,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}setShowTimeRange(){}updateFillAnimationDimensions(){}};var Dt=(r,e,t,i)=>{if(r.type.trim().toLowerCase()==="choice")return new Jr(r,e,t,i)},Jr=class r extends Ce{constructor(t,i,n,o){super(t,n,o);this.containerElement=null;this.subscriptions=new rp;this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&this.removeView()};this.rootElement=i,this.layout=new pt(this.container.layout,n),this.cssVarsManager=n,this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",qt),this.addControlFactory("text",ms),this.addControlFactory("area",Ft)}createView({eventCallback:t,videoDurationMs:i}){let n=document.createElement("div");return n.classList.add($.common,$.disabled),n.setAttribute("data-subjectId",this.container.id),requestAnimationFrame(()=>{n.classList.remove($.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(o=>{var a;o.setShowTimeRange(this.container.startTime,(a=this.container.endTime)!=null?a:i),o.setCssVarsManager(this.cssVarsManager),o.createView({parentElement:n,callbacks:{setControlLayout:(s,l)=>this.layout.setControlLayout(s,l),isContainerDisabled:()=>this.isDisabled}}),o.setEvents(t),this.subscriptions.add(o.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.willRemoved=!1,this.containerElement=n,this.updateControlsFillAnimationDimensions(),n}updateControlsFillAnimationDimensions(){for(let t of this.controls)t.updateFillAnimationDimensions()}hide(){let t=this.getElement();t&&t.classList.add($.hidden)}show(){let t=this.getElement();t&&t.classList.remove($.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove($.disabled),this.controls.forEach(i=>i.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add($.disabled),this.controls.forEach(i=>i.disable()),this.isDisabled=!0)}removeView(t=!1,i=!1){let n=this.getElement();if(n){if(t){if(this.willRemoved)return;this.willRemoved=!0,i&&n.classList.add("interactive-container-before-remove-delay"),n.classList.add("interactive-container-before-remove"),this.subscriptions.add(fs(n,"transitionend").subscribe(this.onTransitionEnd,a=>this.onError(`${r.name} remove view transition error`,a))).add(fs(n,"transitioncancel").subscribe(this.onTransitionEnd,a=>this.onError(`${r.name} remove view transition error`,a)));return}this.subscriptions.unsubscribe(),this.removeAllControls(),n.remove(),this.isRemoved=!0,this.willRemoved=!1,this.containerElement=null}}removeAllControls(t=!1){this.controls.forEach(i=>i.removeView(t))}removeNonInteractedControls(t=!1){this.controls.forEach(i=>{i.isInteracted||i.removeView(t)})}isInteracted(){return this.controls.some(t=>t.isInteracted)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,i){i&&this.controls.forEach(n=>{n.onProgress(t)})}onResize(t){t&&this.controls.forEach(i=>{i.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(i=>i.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(i=>i.toggleBlinkAnimation(t))}};var yl=Y(ei(),1);import{combine as td,InterfaceLanguage as rd,Observable as fl,once as id,Subject as B,Subscription as Ti,ValueSubject as D,fromEvent as vl}from"@vkontakte/videoplayer-shared/es2018";import{InteractiveInterfaceClick as ct}from"@vkontakte/videoplayer-statistics/es2018";import{loadVKLangPack as pp}from"@vkontakte/videoplayer-shared/es2018";function Ze(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var Ts="video_interactive",Is="videoint";var xs=250,Je=class{constructor(e){this.handleZoomChange=Ze(e=>{this.lastZoomInfo=e},xs);this.onResize=e=>{var i;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((i=this.ngEditor)==null||i.zoomTo(t,void 0,{isFromCenter:!0})),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,"Chapter 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,!ft(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"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:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),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=hp(e),this.resizeObserver=new ResizeObserver(Ze(this.onResize,xs)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}async show(){var e;this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)}async initNgEditor(){var i;if(!this.manifest)return;let e;try{e=await pp(this.lang,Ts,Is)}catch(n){(i=this.onError)==null||i.call(this,"Unable to load graph language pack")}let{GraphEditor:t}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name:n,...o})=>{var a;n==="openPreview"&&"chapterId"in o&&((a=this.onOpenPreviewClick)==null||a.call(this,o.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 hp(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 et=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 o of this._containers){let a=o.startTime-e;if(a<=n&&(o.endTime&&n<=o.endTime||o.endTime===null)){i=!0;break}n<a&&(t=t===-1?a:Math.min(t,a))}return!i&&t!==-1?t:null}}};var Ht=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 Ut=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Li(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 ea=Y(Js(),1),Gt=class r{constructor(e){this.rootElement=e;this.rootElementProps={};this.isCssVarsSupported=r.checkCssVarsSupport(e)}static checkCssVarsSupport(e){let t="--test-key",i="test";e.style.setProperty(t,i);let n=e.style.getPropertyValue(t)===i;return n&&e.style.removeProperty(t),n}getPropValue(e){var t;return this.isCssVarsSupported?`var(${e})`:(t=this.rootElementProps[e])!=null?t:""}setup(e){if(this.rootElementProps={...this.rootElementProps,...e},this.isCssVarsSupported)for(let[t,i]of(0,ea.default)(e))this.rootElement.style.setProperty(t,i)}cleanup(){for(let e in this.rootElementProps)this.rootElement.style.removeProperty(e);this.rootElementProps={}}setProp(e,t){this.rootElementProps[e]=t,this.isCssVarsSupported&&this.rootElement.style.setProperty(e,t)}};import{ValueSubject as Wp}from"@vkontakte/videoplayer-shared/es2018";var Wt=class{constructor(e){var t,i;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(i=e==null?void 0:e.manifestLoaders)!=null?i:[]}}async exec(e,t){return Bp(...this.loaders[e])(t)}};function Bp(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function tt(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function zt({actions:r,errors:e,chapterId:t,...i}){if(t){let n=r.getManifest();if(n){let o=r.getChapter(n.chapters,t);if(o){let a=r.getMedia(n.media,o.videoId),s=r.getGraph(n.graph,o.id);return a?{...i,actions:r,errors:e,result:{chapter:o,media:a,graph:s}}:{...i,errors:tt(e,zt.name,"Could not find media"),actions:r}}}}return{...i,errors:tt(e,zt.name,"Could not find chapter"),actions:r}}var{NativeAbortSignal:Yv,NativeAbortController:Zv}=function(r){return{NativeAbortSignal:r.AbortSignal,NativeAbortController:r.AbortController}}(typeof self!="undefined"?self:global);function ta(r){let e;try{e=new Event("abort")}catch(t){typeof document!="undefined"?document.createEvent?(e=document.createEvent("Event"),e.initEvent("abort",!1,!1)):(e=document.createEventObject(),e.type="abort"):e={type:"abort",bubbles:!1,cancelable:!1}}return e.reason=r,e}function ra(r){if(r===void 0)if(typeof document=="undefined")r=new Error("This operation was aborted"),r.name="AbortError";else try{r=new DOMException("signal is aborted without reason"),Object.defineProperty(r,"name",{value:"AbortError"})}catch(e){r=new Error("This operation was aborted"),r.name="AbortError"}return r}var Kt=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,o=i.length;n<o;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,o=i.length;n<o;n++){let a=i[n];try{a.callback.call(this,e)}catch(s){Promise.resolve().then(()=>{throw s})}a.options&&a.options.once&&this.removeEventListener(e.type,a.callback)}return!e.defaultPrevented}},ke=class extends Kt{constructor(){super(),this.listeners||Kt.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)}throwIfAborted(){let{aborted:e,reason:t="Aborted"}=this;if(e)throw t}static timeout(e){let t=new me;return setTimeout(()=>t.abort(new DOMException(`This signal is timeout in ${e}ms`,"TimeoutError")),e),t.signal}static any(e){let t=new me;function i(){t.abort(this.reason),n()}function n(){for(let o of e)o.removeEventListener("abort",i)}for(let o of e)if(o.aborted){t.abort(o.reason);break}else o.addEventListener("abort",i);return t.signal}},me=class{constructor(){Object.defineProperty(this,"signal",{value:new ke,writable:!0,configurable:!0})}abort(e){let t=ra(e),i=ta(t);this.signal.reason=t,this.signal.dispatchEvent(i)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(me.prototype[Symbol.toStringTag]="AbortController",ke.prototype[Symbol.toStringTag]="AbortSignal");function Qt(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 ni(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Qt({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||n)&&(o=function(c,d){let f;d&&d.signal&&(f=d.signal,delete d.signal);let v=new t(c,d);return f&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:f}),v},o.prototype=t.prototype);let a=e;return{fetch:(l,c)=>{let d=o&&o.prototype.isPrototypeOf(l)?l.signal:c?c.signal:void 0;if(d){let f;try{f=new DOMException("Aborted","AbortError")}catch(y){f=new Error("Aborted"),f.name="AbortError"}if(d.aborted)return Promise.reject(f);let v=new Promise((y,C)=>{d.addEventListener("abort",()=>C(f),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([v,a(l,c)])}return a(l,c)},Request:o}}var W=typeof globalThis=="object"&&globalThis||typeof window=="object"&&window;var qp=()=>"fetch"in W,rt=qp()&&Qt({fetch:W.fetch,Request:W.Request,AbortController:W.AbortController}),ia=rt?ni({fetch:W.fetch,Request:W.Request,AbortController:W.AbortController}):void 0,oi=rt?ia.fetch:W.fetch,ub=rt?ia.Request:W.Request,pb=rt?me:W.AbortController,hb=rt?ke:W.AbortSignal;var si=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let o=0;o<Math.max(t.length,i.length)&&!n;o++)t[o]>i[o]?n=1:t[o]<i[o]?n=-1:n=0;return n};var Dp=async r=>{try{let e={},t;if(dt(r)){t=new URL(r).href;let n=await oi(t);if(!n.ok)return{};e=await n.json()}else if(ae(r))e=r;else return{};if(!Zo(e))return{};let i=e.metadata.media;if(dt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=await oi(n);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch(n){return Gp(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function na(r){let{manifest:e,manifestURL:t}=await Dp(r);if(!e)throw new Error("Failed on fetch");let i=Jo(e);return i.media=Hp(i.media,t),delete i.metadata.media,i}function Xt(r,e){if(e)return r.find(t=>t.id===e)}function ai(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 li(r,e){return r.videos.find(t=>t.id===e)}function Hp(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=Up(n,e);return{...i,url:o||n}})}))}}function Up(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Gp(r){return si(r,"3.2.0")>=0}var Pe=class extends Wt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Wp(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){var n;this.release();let i=await this.exec("manifestLoaders",{actions:{addErrorMessage:tt},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await na((n=i.result)!=null?n:t),this}async setInitial(){return this.setNext()}async setNext(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",zt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:ai,getChapter:Xt,getMedia:li,getByBranches:this.getByBranches.bind(this),addErrorMessage:tt},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),n.result&&(this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph),this}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){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=Xt(this.manifest.chapters,t);if(n){let o=li(this.manifest.media,n.videoId),a=ai(this.manifest.graph,n.id);if(o)return{chapter:n,media:o,graph:a}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,o,a;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let s=Xt(((a=this.manifest)==null?void 0:a.chapters)||[],t);return this.getByBranches(s==null?void 0:s.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let o=this.getByChapterId(n.chapterId);return o&&i.push(o),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?ee(this.chapter):!1}};var da=Y(Yt(),1);import{Player as Zp}from"@vkontakte/videoplayer-core/es2018";import{Subscription as pi,TracerFactory as Jp,ValueSubject as eh}from"@vkontakte/videoplayer-shared/es2018";var pa=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&e.payload){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var ha=Y(Yt(),1);function ci(){let r=new Map;function e({listId:o=Math.random().toString(),itemId:a=Math.random().toString(),...s}){let l=r.get(o),c={...s};return l?l[a]=c:r.set(o,{[a]:c}),{listId:o,itemId:a,...s}}function t(o){var a,s;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(a=o.statistics)==null||a.oneStat.destroy(),(s=o.statistics)==null||s.statSubscription.unsubscribe()}function i(o,a){let s=r.get(o);if(!s)throw Error("Can't remove. Not find.");if(a){let l=s[a];l&&t(l),delete s[a],Object.keys(s).length||r.delete(o)}else{for(let l of(0,ha.default)(s))t(l);r.delete(o)}}function n(){for(let o of r)i(o[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var Ve=Y(Rt(),1);function ui(r,e=[]){var o,a,s;let t={},i,n=!e.length;for(let l of r.variants)if(!i&&"cover"in l&&(i=l.cover),"url"in l)switch(l.type.toLowerCase()){case"mp4":(n||(0,Ve.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[(o=l.standard)!=null?o:"Invariant quality"]:l.url});break;case"mpeg":(n||(0,Ve.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[(a=l.standard)!=null?a:"Invariant quality"]:l.url});break;case"hls":(n||(0,Ve.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:l.url}});break;case"dash":(n||(0,Ve.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:l.url}});break;default:break}return{sources:t,thumbUrl:i,title:(s=r.title)!=null?s:""}}var it=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,Ve.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var th=2;function hi(r){let e=ci(),t=new pi,i={},n=null,o=!1,a,s=new eh(null);r&&l(r);function l(m){n=m}function c(m,p,h){var x;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let I=((x=e.map.get(m))!=null?x:{})[p];if(I){i={chapterId:h,listId:m,itemId:p,...I};let g=i.player;i.subscription.add(g.info.currentQuality$.subscribe(T=>{let V=g.info.position$.getValue(),A=g.info.isAutoQualityEnabled$.getValue();if(!(!T||!V||A))for(let O of e.map)(0,da.default)(O[1]).forEach(({player:L})=>{it(L,T)})})).add(g.events.started$.subscribe(()=>{d(p)})),I.container.remove(),n.setPlayer(I.player),o||(n.init(),o=!0),s.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}async function d(m){if(!n)throw Error("need to set interactive controller");if(ue(i)||m!==i.itemId)return;let p=n.getChapterBranches(),h=new Set;for(let b of p)h.has(b.media.id)||(await v({media:b.media,chapterId:b.chapter.id,setAsActive:!1,title:b.chapter.label}),h.add(b.media.id))}async function f({chapter:{id:m},manifestVideo:p}){if(ue(i)||!n)return;let h=i.player.info.muted$.getValue(),b=i.player.info.currentQuality$.getValue(),I=i.player.info.isAutoQualityEnabled$.getValue(),x=i.player.info.volume$.getValue(),g=i.player.info.currentPlaybackRate$.getValue(),T=!I,V=!1;for(let A of e.map)if(A[0]===p.id&&!n.state.isReplay$.getValue()){let O=Object.keys(A[1]);for(let L of O)L===i.itemId?(O.length<th||(V=!0),e.removePlayer(A[0],L)):(V=!0,c(A[0],L,m),T?it(i.player,b):i.player.setAutoQuality(!0),i.player.setVolume(x),i.player.setMuted(h),i.player.setPlaybackRate(g))}else e.removePlayer(A[0]);V||(await v({media:p,chapterId:m,setAsActive:!0,playbackRate:g}),T?it(i.player,b):i.player.setAutoQuality(!0),i.player.setVolume(x),i.player.setMuted(h))}async function v({media:m,chapterId:p,prefetch:h=!0,setAsActive:b=!0,autoplay:I=!1,preferredExt:x,title:g,playbackRate:T}){var xi,Ai,Si,wi;let V=Math.random().toString(),A=document.createElement("div");a.append(A);let O;if((xi=n==null?void 0:n.options)!=null&&xi.vkVideoLoader){let ut=pa(m);ut.length&&(O=await n.options.vkVideoLoader(...ut))}let X={...((Ai=n==null?void 0:n.options)==null?void 0:Ai.coreConfig)||void 0},ce={container:A,...((Si=O==null?void 0:O.videos)==null?void 0:Si[0])||{sources:ui(m,x).sources},title:g,failoverHosts:(O==null?void 0:O.failoverHosts)||[]},q=new Zp(X,Jp.createRootTracer());q.initVideo(ce);let ye=null;if(O!=null&&O.videos&&(n!=null&&n.options.createOneStat)){let ut=O.videos[0],or=n.options.createOneStat(ut),Ri=new pi;or&&(Ri.add(or.attachTo(q)),ye={oneStat:or,statSubscription:Ri})}let Ii=new pi,gl=(wi=i==null?void 0:i.player)==null?void 0:wi.info.isAutoQualityEnabled$.getValue();Ii.add(q.events.canplay$.subscribe(function(){gl||it(q,i.player.info.currentQuality$.getValue()),T&&q.setPlaybackRate(T)}));let ge=e.createPlayer({listId:m.id,itemId:V,player:q,container:A,sources:ui(m,x).sources,config:ce,subscription:Ii,statistics:ye});return b&&c(m.id,ge.itemId,p),I&&ge.player.play(),h&&!I&&ge.player.prepare(),{player:ge.player,config:ge.config,statistics:ge.statistics}}function y(){C(),n=null,a.remove()}function C(){t.unsubscribe(),e.removeAll(),i={},o=!1}async function E(){if(!n)throw Error("need to set interactive controller");C(),a=document.createElement("div");let{media:m,chapter:p}=n.getCurrentChapter();m&&p?(t.add(n.events.chapterChanged$.subscribe(f)),await v({media:m,chapterId:p.id,title:p.label})):console.error("not found")}return{...e,init:E,setInteractiveController:l,createPlayer:v,removeAll:y,getActivePlayer:function(){return i},activePlayerChanged:s}}var w={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},nt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},M={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};import{Subscription as rh}from"@vkontakte/videoplayer-shared/es2018";function di(r){return function(...t){return r(...t.reverse())}}function ot(r,...e){return(...t)=>ae(e[0])&&ae(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var Zt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:a,globalEventEmitter:s,getContainerEventState:l,permanentTextControls:c,interactiveTimeOpenUri:d,disabledControls$:f,onRemove:v,onError:y,disableTextControlContainerVisibilityEvents:C=!1,features:E}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(de(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,i,n,o,a,s;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:l}=this.getContainerEventState();if((i=(t=this.container).show)==null||i.call(t),this.interactiveTimeOpenUri&&l||this.disableTextControlContainerVisibilityEvents)return;this.emitContainerVisibilityEvent(!0,!1)}else{let l={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(f,v)=>{let{isExpectTime:y,hasOtherExpect:C,hasOpenURIEvent:E,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:p,hasShouldOpenNowEvent:h}=this.getContainerEventState(),b=this.interactiveTimeOpenUri&&!m,I=this.interactiveTimeOpenUri&&m;if((!this.interactiveTimeOpenUri||b)&&(this.isSelectedControlEvent=!0),f!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||b)){if(this.interactiveTimeOpenUri){let x=!C&&!p&&m;x&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:x})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&E&&this.gameState!==5){if(I){let g=((T,V,A,O)=>!T&&!V&&A||T&&!V&&A&&!O||T&&!V&&A&&O)(y,C,p,this.isSelectedContainerEvent);this.fakeRemoveView(g)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!y||!C||!h)&&(this.selectBranches.stopExpect(),v())}},isEOV:()=>this.gameState===4},c=ot(this.selectBranches.onControlEvent,l),d=((o=(n=this.player)==null?void 0:n.info.duration$.getValue())!=null?o:1/0)*1e3;this.container.createView({eventCallback:c,videoDurationMs:d}),this.disableTextControlContainerVisibilityEvents||this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((s=(a=this.container).disable)==null||s.call(a))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var l,c,d;let e=this.player.experimental.element$.getValue(),t=e instanceof HTMLVideoElement;if(this.features.enableAvPlayerSupport&&(t||(t=e instanceof HTMLObjectElement&&(e==null?void 0:e.getAttribute("type"))==="application/avplayer")),!(t?e==null?void 0:e.readyState:void 0)||this.isRemovedOrDestroyed()&&!this.isPermanentText)return;let n=this.player.getExactTime();if(ts(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Gr(n,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{let{hasOpenURIEventInCurrentContainer:f}=this.getContainerEventState(),v=this.selectBranches.state.isExpect,y=this.interactiveTimeOpenUri&&f;if(y&&!v){let C=this.container.getElement();C&&(C.style.visibility!=="hidden"&&((c=(l=this.container).hide)==null||c.call(l)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!y&&this.removeView()}let o=Gr(n,this.container.container),a=this.container.container.startTime?[this.container.container.startTime,(d=this.container.container.endTime)!=null?d:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:a,currentTime:n,isInteractiveTime:o};this.container.onProgress(n*1e3,o),this.globalEventEmitter.emit(w.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new rh,this.player=e,this.interactiveEvents=o,this.getContainerEventState=l;let m=Oe(t.container.controls);this.isPermanentText=c&&m,this.disableTextControlContainerVisibilityEvents=C&&m,this.interactiveTimeOpenUri=d,this.disabledControls$=f,this.onRemove=v,this.globalEventEmitter=s,this.gameState=0,this.globalEvents=a,this.onError=y,this.features=E,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{var t,i,n,o;e?(i=(t=this.container).disable)==null||i.call(t):(o=(n=this.container).enable)==null||o.call(n)})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){var i,n;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(i=this.container.container.endTime)!=null?i:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((n=this.container.container.endTime)!=null?n:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),i=this.interactiveTimeOpenUri?e||t:de(this.container.container.events)||e;(this.isSelectedControlEvent||!i)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(e=this.features.controlsHideAnimation){var t;if(e){if(this.isRemovedOrDestroyed())return;this.container.removeNonInteractedControls(!0),this.container.removeView(!0,!0)}else this.container.removeView();this.globalEventEmitter.emit(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,(t=this.onRemove)==null||t.call(this)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}isInteracted(){return this.container.isInteracted()}isRemovedOrDestroyed(e=!0){let t=e?this.container.willRemoved:!1;return this.gameState===5||t||this.gameState===6}destroy(e=!1){var t;this.reset(),this.removeView(e),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(t=this.container.container.endTime)!=null?t:1/0,id:this.container.container.id})}};var fa=(r=[])=>r.reduce((e,t,i)=>{var o,a,s;let n=((o=t==null?void 0:t.controls)!=null?o:[]).filter(l=>!Ot(l));if(Vt(n)){let l=[(a=t.startTime)!=null?a:0,(s=t.endTime)!=null?s:1/0],c={id:t.id,isRemoved:!1};if(!i)e.push({subjects:[c],range:l});else{let d=[],f=-1/0,v=1/0,y=[],C=[];for(let E=0;E<e.length;E++){let m=e[E];if(C.push(...m.subjects),m.range[0]<v&&(v=m.range[0]),m.range[1]>f&&(f=m.range[1]),l[0]>=m.range[0]&&l[1]<=m.range[1])return e[E].subjects.push(c),e;l[0]<m.range[0]&&l[1]>m.range[0]&&(d.push(E),y=y.concat(m.subjects)),l[0]>=m.range[0]&&l[0]<=m.range[1]&&(d.push(E),y=y.concat(m.subjects),l[0]=m.range[0]),l[1]>=m.range[0]&&l[1]<=m.range[1]&&(d.push(E),y=y.concat(m.subjects),l[1]=m.range[1])}if(C.push(c),l[0]<=v&&l[1]>=f)return[{subjects:C,range:l}];d.length&&d.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:y.concat([c]),range:l})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var Xa=Y(Rt(),1),bi=Y(Yt(),1),Ya=Y(Ka(),1);function Qa(){let r={};function e(){for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]}function t(s){let l={};for(let c in r)+c<=s&&(l[c]=r[c]);return l}function i(s){let l={};for(let c in r)+c>=s&&(l[c]=r[c]);return l}function n({timestamp:s,priority:l,initiator:c}){var d;if(cr(s)){let f=(d=r[s])!=null?d:null;if(f&&l&&Le(l,!0)){let v={},y=f[l];if(y&&(v={...v,...y}),v=ue(v)?null:v,v&&Le(c,!0)){let C=v[c];return C!=null?C:null}return v}return f}return null}function o({timestamp:s,priority:l,initiator:c}){if(cr(s))if(r[s]){if(l&&Le(l,!0))if(r[s][l]){if(c&&Le(c,!0))if(r[s][l][c]){if(delete r[s][l][c],!ue(r[s][l]))return!0}else return!1;if(delete r[s][l],!ue(r[s]))return!0}else return!1;return delete r[s]}else return!1;return!1}function a({timestamp:s,priority:l,initiator:c,...d}){var f,v,y;(v=(f=r[s])==null?void 0:f[l])!=null&&v[c]?r[s][l][c].push({...d}):(y=r[s])!=null&&y[l]?r[s][l]={...r[s][l],[c]:[{...d}]}:r[s]?r[s]={...r[s],[l]:{[c]:[{...d}]}}:r[s]={[l]:{[c]:[{...d}]}}}return{map:r,remove:o,add:a,removeAll:e,get:n,getLte:t,getGte:i}}var Uh=[R.expect,R.setNextBranch],Gh=1/0;function Za(r,e){let t=r,i,n=Wh(e),o=Qa(),a,s=()=>{y(),p()},l=h=>{o.add.call(void 0,h),C()},c=(h=[])=>{for(let b of h)if(b.action(),(0,Xa.default)(Uh,b.actionType))break},d=(h=1/0)=>{var g,T,V;let b=er((g=o.get({timestamp:h,priority:"control"}))!=null?g:{}),I=er((T=o.get({timestamp:h,priority:"container"}))!=null?T:{}),x=er((V=o.get({timestamp:h,priority:"chapter"}))!=null?V:{});return[...b,...I,...x]},f=h=>{n.isReady(h)&&c(d(h))},v=()=>{var h;c([...er((h=o.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},y=()=>{i&&(a==null||a.unsubscribe(),i=void 0)},C=()=>{i||(i=()=>setTimeout(()=>{f(1/0)}),a=t.events.ended$.subscribe(i))},E=h=>{y(),t=h},m=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),o.remove(h)},p=()=>{n.release(),o.removeAll()};return{setPlayer:E,add:l,remove:m,exec:f,execEndOfVideo:v,listen:C,unlisten:y,release:s,containersEventsCallState:n,getPreparedToExecActions:d}}function Wh(r){let e=new Map;return{setCalled:({timestamp:s,id:l})=>{let c=e.get(s);c&&c[l]!==void 0&&(c[l]=!0)},setData:(s=[])=>{var l;for(let c of s){let d=(l=c.endTime)!=null?l:Gh,f=e.get(d);e.set(d,{...f,[c.id]:!1})}},resetCalled:s=>{let l=e.get(s);if(l)for(let c in l)l[c]=!1},isReady:s=>{let l=e.get(s);if(!l)return!0;let c=(0,bi.default)(l);return r?c.some(f=>f):!c.some(f=>!f)},release:()=>e.clear()}}function er(r){return(0,Ya.default)((0,bi.default)(r)).sort(e=>e.actionType===R.expect?-1:1)}var Ja={videoContentHeight:0,videoContentWidth:0},el=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Ja;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return Ja;let o=e/t,a=i/n,s,l;return a>o?(l=n,s=n*o):a<o?(l=i/o,s=i):(l=n,s=i),{videoContentWidth:l,videoContentHeight:s}};var zh=250;function tl(r){let e,t=new ResizeObserver(s=>{o(s),e=o.bind(null,s)});function i(s){let{parentElement:l,player:c,cssVarsManager:d}=r();if(!l||!c)return;let{videoContentWidth:f,videoContentHeight:v}=el(c);d.setup({"--interactive-content-width":`${f}px`,"--interactive-content-height":`${v}px`,"--interactive-width":`${s[0].contentRect.width}px`,"--interactive-height":`${s[0].contentRect.height}px`})}function n(){let{parentElement:s}=r();s.removeAttribute("style")}let o=Ze(s=>{let{fns:l=[]}=r();i(s);for(let c of l)c()},zh);function a(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:a}}var Kh=r=>Math.floor(Math.random()*r),il=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let o=r[e],a=(n=o.weight)!=null?n:1;a<t&&(t=a,i=o)}return i},nl=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let o=r[e],a=(n=o.weight)!=null?n:0;a>t&&(t=a,i=o)}return i};var ol=r=>{let e=r.length,t=Kh(e);return r[t]},rl=1,sl=r=>{var i,n;let e=0;for(let o=0;o<r.length;++o)e+=(i=r[o].weight)!=null?i:rl;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(n=r[o].weight)!=null?n:rl,e>=t)return r[o];return r[r.length-1]};var al={shouldOpenNow:!0,isDetachContainer:!0},ll="after-expect",yi=(r,e=!1)=>({...r,args:e?{...r.args,...al}:{...al,...r.args}}),cl=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},a=({action:p,controlType:h,controlId:b,containerId:I,branches:x=[],onEvent:g,isEOV:T=()=>!1,isDisabled:V=()=>!1})=>{let A=yi(p,T()),O={timestamp:1/0,priority:"control",initiator:b,actionType:A.type},L=V(),X=r.emit.bind(r,w.interactives,{subjectId:b,subjectType:h,subjectName:"control",type:L?M.actionChoiceCanceled:M.actionChoice,actionType:p.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:I,...A.args}}),ce=()=>{e.interactiveActionChoice$.next({subjectId:b,subjectType:h,subjectName:"control",type:L?"action-choice-canceled":"action-choice",actionType:p.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:I,...A.args}})};if(L){X(),ce();return}switch(A.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let q=x.find(ye=>ye.id===A.args.branchId);if(!q)return;g(A.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),X(),ce(),A.args.shouldOpenNow?E({subjectId:b,subjectName:"control",subjectType:h,action:A,payload:{chapterId:q.chapterId,autoSelect:!1}}):i.add({...O,action:E.bind(null,{subjectId:b,subjectName:"control",subjectType:h,action:A,payload:{chapterId:q.chapterId,autoSelect:!1}})});return}case R.continuePlayback.trim().toLowerCase():{g(A.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),X(),ce(),A.args.shouldOpenNow?C({subjectId:b,subjectName:"control",subjectType:h,action:p}):i.add({...O,action:C.bind(null,{subjectId:b,subjectName:"control",subjectType:h,action:p})});return}case R.openURI.trim().toLowerCase():{g(A.args.isDetachContainer,y.bind(null,{subjectId:b,subjectName:"control"})),X(),ce(),A.args.shouldOpenNow?m({subjectId:b,subjectName:"control",subjectType:h,action:A,payload:{URI:p.args.uri}}):i.add({...O,action:m.bind(null,{subjectId:b,subjectName:"control",subjectType:h,action:A,payload:{URI:p.args.uri}})});return}default:{let q="Unexpected control event",ye=new F(1,1,{message:q});d(ye,q);return}}},s=({action:p,container:{id:h,endTime:b},branches:I=[],isEOV:x=!1,autoSelected:g=!1})=>{let T=yi(p,x),V={timestamp:!T.args.shouldOpenNow||x?1/0:b!=null?b:1/0,priority:"container",initiator:h,actionType:T.type},A=r.emit.bind(r,w.interactives,{subjectId:h,subjectName:"container",type:M.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),O=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}})};switch(T.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let L=I.find(X=>X.id===T.args.branchId);if(!L)return;A(),O(),i.add({...V,action:E.bind(null,{subjectId:h,subjectName:"container",action:T,payload:{chapterId:L.chapterId,autoSelect:g}})});return}case R.setMaxWeightBranch.trim().toLowerCase():return;case R.setMinWeightBranch.trim().toLowerCase():return;case R.setRandomBranch.trim().toLowerCase():return;case R.setWeightlessRandomBranch.trim().toLowerCase():return;case R.continuePlayback.trim().toLowerCase():{A(),O(),i.add({...V,action:C.bind(null,{subjectId:h,subjectName:"container",action:T})});return}case R.openURI.trim().toLowerCase():{A(),O(),i.add({...V,action:m.bind(null,{subjectId:h,subjectName:"container",action:T,payload:{URI:p.args.uri}})});return}default:{let L="Unexpected container event",X=new F(1,1,{message:L});d(X,L);return}}};function l({container:p,branches:h,isEOV:b=!1}){var x,g;let I=Wr(p.events);if(I){let T=yi(I.action,b);r.emit(w.interactives,{subjectId:p.id,subjectName:"container",type:M.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),i.add({timestamp:b?1/0:(x=p.endTime)!=null?x:1/0,priority:"container",initiator:p.id,actionType:R.expect,action:v.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let T of(g=p.events)!=null?g:[])s({action:T.action,container:p,branches:h,isEOV:b})}let c=({chapterId:p,action:h,branches:b=[]})=>{let I=r.emit.bind(r,w.interactives,{subjectId:p,subjectName:"chapter",type:M.actionChoice,actionType:h.type,payload:h.args}),x=()=>{e.interactiveActionChoice$.next({subjectId:p,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let g=b.find(T=>T.id===h.args.branchId);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setWeightlessRandomBranch.trim().toLowerCase():{let g=ol(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setRandomBranch.trim().toLowerCase():{let g=sl(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setMaxWeightBranch.trim().toLowerCase():{let g=nl(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.setMinWeightBranch.trim().toLowerCase():{let g=il(b);return g!=null&&g.chapterId?(I(),x(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:g.chapterId,autoSelect:!0}})):void 0}case R.continuePlayback.trim().toLowerCase():return I(),x(),C.bind(null,{subjectId:p,subjectName:"chapter",action:h});case R.openURI.trim().toLowerCase():return I(),x(),m.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let g="Unexpected chapter event",T=new F(1,1,{message:g});d(T,g);return}}};function d(p,h){console.error(h),e.error$.next(p),r.emit(w.errors,p)}function f(p){var b;let h=Wr(p.events);if(h){if(ee(p))return;r.emit(w.interactives,{subjectId:p.id,subjectName:"chapter",type:M.actionChoice,actionType:h.action.type,payload:h.action.args}),e.interactiveActionChoice$.next({subjectId:p.id,subjectName:"chapter",type:"action-choice",actionType:h.action.type,payload:h.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:R.expect,action:v.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(b=p.events)==null||b.forEach(I=>{let x=c({chapterId:p.id,action:I.action,branches:p.branches});x&&i.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:I.action.type,action:x})})}let v=({subjectId:p,subjectName:h})=>{t.pause(),r.emit(w.interactives,{subjectId:p,subjectName:h,type:M.actionExecution,actionType:R.expect}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:R.expect})},y=({subjectId:p,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(w.interactives,{subjectId:p,subjectName:h,type:M.actionExecution,actionType:ll}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,type:"action-execution",actionType:ll})},C=({subjectId:p,subjectName:h,subjectType:b,action:I})=>{r.emit(w.interactives,{subjectId:p,subjectName:h,subjectType:b,type:M.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:b,type:"action-execution",actionType:I.type})},E=({subjectId:p,subjectName:h,subjectType:b,action:I,payload:x})=>{x.behaviour="change-chapter",r.emit(w.interactives,{subjectId:p,subjectName:h,subjectType:b,type:M.actionExecution,actionType:I.type,payload:x}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:b,type:"action-execution",actionType:I.type,payload:x})},m=({subjectId:p,subjectName:h,subjectType:b,action:I,payload:x})=>{if(!x.URI)return;let g=window.open(x.URI,"_blank","noopener,noreferrer");g&&(g.opener=null),r.emit(w.interactives,{subjectId:p,subjectName:h,subjectType:b,type:M.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:p,subjectName:h,subjectType:b,type:"action-execution",actionType:I.type})};return{onControlEvent:a,onContainerEvent:s,onChapterEvent:c,onExpectEvent:v,expectEventHandler:y,setManifestChapterEvents:f,setManifestContainerEvents:l,stopExpect:o,state:n}};var Ei=Y(ei(),1);import{Subscription as Jh,Subject as Ci,ValueSubject as at}from"@vkontakte/videoplayer-shared/es2018";var gi=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(a=>a.id===i);if(!n)return null;let o=e.media.videos.find(a=>n.videoId===a.id);if(!o)return null;t[i]=ul(o)}return t[i]}).filter(Boolean)},Xh=r=>{for(let e of r.variants)if(Yh(e)&&e.payload)return e.payload.id},Yh=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),ul=r=>{let e=Xh(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Zh=(r,e)=>{for(let t of r.media.videos)if(e===ul(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},pl=(r,e)=>r.reduce((t,i)=>{let n=Zh(e,i);return n?[...t,n]:t},[]);var ie,fe,ve,z,tr,ne,oe,te,be,Me,_e,lt=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new at([]),hasPrevChapter$:new at(!1),prevChapter$:new at(null),isInitialChapter$:new at(!1),isGoBackLimited$:new at(!1)};H(this,ie,null);H(this,fe);H(this,ve,!1);H(this,z,null);H(this,tr,null);this.events={inited$:new Ci,destroyed$:new Ci,error$:new Ci};H(this,ne,null);H(this,oe,null);H(this,te,null);H(this,be,new Jh);H(this,Me,!1);H(this,_e,0);var a;_(this,ne,t),_(this,te,e),_(this,oe,i),_(this,ie,n),_(this,fe,o),this.state.history$&&S(this,be)&&((a=S(this,be))==null||a.add(this.state.history$.subscribe(s=>{var l,c;this.state.prevChapter$.next((0,Ei.default)(s,-2)||null),this.state.hasPrevChapter$.next(s.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(l=S(this,z))==null?void 0:l.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(S(this,_e)===S(this,fe).maxLength-1)})))}async setManifest(e){if(!S(this,oe)||!S(this,te))return;_(this,z,e),await this.getProjectHistory();let t=this.getInitialChapterId();await S(this,oe).setChapter({chapterId:t,pushToHistory:!1}),S(this,ve)||(_(this,ve,!0),this.events.inited$.next({initChapterId:t}))}get inited(){return S(this,ve)}async updateHistory(e,t=!0){var s;if(!S(this,z))return;S(this,Me)?(_(this,Me,!1),Vi(this,_e)._++):_(this,_e,0);let i=S(this,z),n=e.length-S(this,fe).maxLength,o=n>0?e.slice(n):e,a=gi(o,i);if(_(this,tr,a),this.state.history$.next(o),!(!t||!S(this,ie)||!S(this,ne)))try{await S(this,ie).save(S(this,ne),a)}catch(l){let c=new F(1,5,"Unable to save interactive history");this.events.error$.next(c),(s=S(this,te))==null||s.emit(w.errors,c)}}async goBack(){var i;if(!this.state||!S(this,oe)){let n=new F(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=S(this,te))==null?void 0:i.emit(w.errors,n)}_(this,Me,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await S(this,oe).setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){var n;if(!S(this,z)||!S(this,ne))return;let e=S(this,z),t=[this.getInitialVideoId()];if(S(this,ie))try{let o=await S(this,ie).get(S(this,ne));o.length&&(t=o)}catch(o){let a=new F(1,5,"Error while trying to fetch data");this.events.error$.next(a),(n=S(this,te))==null||n.emit(w.errors,a)}let i=pl(t,e);this.state.history$.next(i)}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,Ei.default)(e,-1)||S(this,fe).initChapterId||((t=S(this,z))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(S(this,z)){let e=this.getInitialChapterId();return gi([e],S(this,z)).pop()}return null}destroy(){var e,t;_(this,ne,null),_(this,ie,null),_(this,oe,null),(e=S(this,be))==null||e.unsubscribe(),_(this,be,null),_(this,ve,!1),(t=S(this,te))==null||t.emit(w.historyDestroyed),this.events.destroyed$.next(),_(this,te,null)}};ie=new WeakMap,fe=new WeakMap,ve=new WeakMap,z=new WeakMap,tr=new WeakMap,ne=new WeakMap,oe=new WeakMap,te=new WeakMap,be=new WeakMap,Me=new WeakMap,_e=new WeakMap;var rr=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 o=3;o<i;o+=40)if(t[o]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}async updateCanvasDimensions(e,t=!1){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var ir=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,7 +16,7 @@ var El=Object.create;var ki=Object.defineProperty;var Tl=Object.getOwnPropertyDe
16
16
  top: 50%;
17
17
  left: 50%;
18
18
  transform: translate(-50%, -50%);
19
- `,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),i={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(i,e)}catch(n){this._onError(n)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var i,n,o;return((i=t.controls)==null?void 0:i.length)&&e>=((n=t.startTime)!=null?n:0)&&e<=Math.min((o=t.endTime)!=null?o: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 dl(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var ml=`/* interactive-container */
19
+ `,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),i={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(i,e)}catch(n){this._onError(n)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var i,n,o;return((i=t.controls)==null?void 0:i.length)&&e>=((n=t.startTime)!=null?n:0)&&e<=Math.min((o=t.endTime)!=null?o: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 hl(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var dl=`/* interactive-container */
20
20
  .interactive-container {
21
21
  opacity: 1;
22
22
  visibility: visible;
@@ -282,4 +282,4 @@ var El=Object.create;var ki=Object.defineProperty;var Tl=Object.getOwnPropertyDe
282
282
  .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-bottom {
283
283
  transform-origin: bottom;
284
284
  }
285
- `;var fl=r=>{let e=document.createElement("style");e.textContent=ml,r.prepend(e)};import{clientChecker as od}from"@vkontakte/videoplayer-core/es2018";var yl=Object.freeze({lang:id.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},isTouch:!1,disableTextControlContainerVisibilityEvents:!1,animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1,controlsTapPlace:!1,controlsFillAnimation:!1,controlsHideAnimation:!1},enableAvPlayerSupport:!1});function sd(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var nr=class{constructor(e){this.playerSubscriptions=new Ti;this.subscriptions=new Ti;this.globalEventEmitter=new Ht;this.animation=new Ut;this.seekToInteractiveController=new et;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=sd();this.factories=new Map([["choice",Dt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new Ti;this.graph=null;this.lastFrame=null;this.blinkAnimationRef=null;this.appState=0;this.state={prevChapter$:new D(null),isInitialChapter$:new D(!1),isFirstChapter$:new D(!0),isEndChapter$:new D(!1),isInteractiveExpectation$:new D(!1),isReplay$:new D(!1),calledByInteractive$:new D(!1),lastChapterChangeWasInitiatedByInteractive$:new D(!1),disabledControls$:new D(!1),interactiveRanges$:new D([]),isInteractiveTime$:new D(!1),statistics$:new D(null),isSeekable$:new D(!1)};this.events={noInteraction$:new B,graphVisibilityChanged$:new B,watchAgainIsClicked$:new B,chapterChanged$:new B,playerChanged$:new B,error$:new B,eachTick$:new B,manifestChanged$:new B,interactiveRangeEnded$:new B,interactiveContainerRemoved$:new B,interactiveContainerFakeRemoved$:new B,interactiveActionExecution$:new B,interactiveActionChoice$:new B,interactiveVisibilityChanged$:new B};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(w.errors,e)};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&&ee(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...i}=e;if(t){let{statSubscription:n,oneStat:o}=t;n.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(w.playerChanged,i)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.destroyGameControllers=({removeTextControls:e=!0,withTransition:t=!1}={})=>{for(let i of this.gameControllers)!e&&i.isPermanentText||(this.animation.removeFn(i.whilePlaying),i.destroy(t))};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(o=>({...o,subjects:o.subjects.filter(a=>a.id!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var n,o,a;if(this._options={...yl,...e,config:{...yl.config,...e.config}},(n=this._options.animationsFeatureToggles)==null?void 0:n.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new Lt,this.blinkAnimationRef.create();let s=this.blinkAnimationRef.element;s&&this.rootElement.append(s)}this._options.parentElement.append(this.rootElement),this.historyController=new lt({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(o=this._options.projectInfo)==null?void 0:o.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new ir({parentElement:this._options.parentElement,onError:s=>{let l=new F(1,6,s);this.emitErrorEvent(l)}})),fl(this._options.parentElement),this.subscriptions.add(bl(this.rootElement,"mousedown").subscribe(s=>s.stopPropagation())).add(bl(this.rootElement,"mouseup").subscribe(s=>s.stopPropagation())),this.manifestController=new Pe(this._options.loaders,s=>{let l=new F(1,3,s);this.emitErrorEvent(l)});let i=[];this._options.lastFrame&&i.push(()=>{var s;(s=this.lastFrame)==null||s.updateCanvasDimensions(!0)}),i.push(()=>{let s=this.state.isInteractiveTime$.getValue();for(let l of this.gameControllers)l.onResize(s)}),this.cssVarsManager=new Gt((a=this._options)==null?void 0:a.parentElement),this.resizeManager=rl(()=>({player:this.player,cssVarsManager:this.cssVarsManager,parentElement:this._options.parentElement,fns:i})),this._options.graph&&(this.graph=new Je({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:s=>{this.setChapter({chapterId:s}),this.globalEventEmitter.emit(w.graph,{type:nt.watchAgainClicked,chapterId:s}),this.events.watchAgainIsClicked$.next(s)},onError:s=>{let l=new F(1,2,{message:s});this.emitErrorEvent(l)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{var t,i;if(this.state.calledByInteractive$.next(!0),(e.actionType==="setNextBranch"||!this._options.endChapterHistoryFix)&&this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:n}=e.payload;this.setChapter({chapterId:n}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:n}=e.payload;n&&this.setManifest(n)}e.actionType==="expect"?(this.state.isInteractiveExpectation$.next(!0),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType==="after-expect"&&(this.state.isInteractiveExpectation$.next(!1),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}))})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:i})=>{var n;e!=="action-choice"||t==="chapter"||"invokeImmediately"in i&&i.invokeImmediately||this.destroyGameControllers({removeTextControls:!1,withTransition:(n=this._options.animationsFeatureToggles)==null?void 0:n.controlsHideAnimation})}))}async initSeamless(){this.seamlessController=hi(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:o})=>t>=o[1]);if(n){let o=n.range.join("-");this.endedRanges.has(o)||(this.endedRanges.add(o),this.globalEventEmitter.emit(w.interactives,{type:_.rangeEnded,payload:n,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:n}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(nd()).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(rd({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:i})=>{var l;let n;if(i)n=!0;else{let c=e*1e3;n=!!t.find(({range:[f,v],subjects:y})=>f<c&&c<v&&y.some(C=>!C.isRemoved)&&y.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let o=!!this.noInteractionTimeout,s=((l=this.player)==null?void 0:l.info.playbackState$.getValue())==="playing"||i;n&&!o&&s?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):o&&!s&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{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.getGameControllers(e),(i=this.interactiveEvents)==null||i.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(n=>n.container.container).filter(n=>!Oe(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)}getGameControllers(e){let t=[];return e.containers.forEach(i=>{var s,l,c,d,f,v,y;let n=i.type.trim().toLowerCase(),o=this.factories.get(n),a=o==null?void 0:o(i,this.rootElement,this.cssVarsManager,{isTouch:(l=(s=this._options)==null?void 0:s.isTouch)!=null?l:!1,features:{controlsExpectTimeBlinkAnimation:(c=this._options.animationsFeatureToggles)==null?void 0:c.controlsExpectTimeBlinkAnimation,controlsTapPlace:(d=this._options.animationsFeatureToggles)==null?void 0:d.controlsTapPlace,controlsFillAnimation:(f=this._options.animationsFeatureToggles)==null?void 0:f.controlsFillAnimation}});if(a&&this.selectBranches&&this.interactiveEvents&&this.player){let C=new Zt({player:this.player,container:a,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>os(i,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(i.id)},onError:this.emitErrorEvent,disableTextControlContainerVisibilityEvents:(v=this.options.disableTextControlContainerVisibilityEvents)!=null?v:!1,features:{controlsHideAnimation:(y=this._options.animationsFeatureToggles)==null?void 0:y.controlsHideAnimation,enableAvPlayerSupport:this._options.enableAvPlayerSupport}});this.animation.addFn(C.whilePlaying,!0),t.push(C)}}),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 s,l;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(s=i&&ee(i)&&Mt(i))!=null?s:!1,o=((l=this.manifestController.manifest)==null?void 0:l.metadata.initChapterId)===e,a=this.historyController.state.history$.getValue();if(o||n&&t){this.historyController.updateHistory([e]);return}(0,gl.default)(a,-1)!==e&&this.historyController.updateHistory([...a,e])}handleFakeRemoval(e,t){let{interactiveRanges$:i}=this.state,o=i.getValue().map(a=>{let s=a.subjects.some(c=>c.id===e),l=a.subjects.map(c=>t&&s||c.id===e?{...c,isRemoved:!0}:c);return{...a,subjects:l}});i.next(o)}reset(){var e;this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this._options.endChapterHistoryFix&&this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1),this.clearNoInteractionTimeout())}toggleBlinkAnimation(e){var i,n;if(!((i=this._options.animationsFeatureToggles)!=null&&i.controlsExpectTimeBlinkAnimation))return;let t=(o,a)=>{o.toggleBlinkAnimation(a)};_t({...e,gameControllers:this.gameControllers,execFn:ot(di(t),e.isExpect)}),e.isExpect&&((n=this.blinkAnimationRef)==null||n.restart())}updateControlsShadowStyles(e){var i;if(!((i=this._options.animationsFeatureToggles)!=null&&i.areaControlShadow))return;let t=(n,o)=>{n.updateControlsShadowStyles(o)};e.isExpect?_t({...e,gameControllers:this.gameControllers,execFn:ot(di(t),!1)}):_t({...e,gameControllers:this.gameControllers,execFn:t})}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(w.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=Ja(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=ul({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:i=!1}={}){var l,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&od.browser.isSafari&&await dl(35);let n=!i&&this.state.isEndChapter$.getValue()&&((l=this.getCurrentManifest())==null?void 0:l.metadata.initChapterId)===e;this.state.isReplay$.next(n);let{chapter:o,media:a,graph:s}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||n)&&this.state.isFirstChapter$.next(!0),!(!o||!a)&&(t&&this.pushChapterToHistory(o.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(o),this.state.isInteractiveTime$.next(!1),this.state.isInteractiveExpectation$.next(!1),(c=this.lastFrame)==null||c.setCurrentChapter(o),this.events.chapterChanged$.next({chapter:o,manifestVideo:a}),this.globalEventEmitter.emit(w.chapterChanged,{chapter:o,media:a,graph:s}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new vl(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?ct.GRAPH_SHOW:ct.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(ct.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(ct.NEXT_BUTTON),n==="Area"&&e.next(ct.NEXT_AREA))}))}),nextMovie$:new vl(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(w.graph,{type:nt.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===R.setNextBranch)}allControlsAreRemoved(e=!0){return!this.gameControllers.some(i=>{var o;let n=e&&((o=this._options.animationsFeatureToggles)!=null&&o.controlsHideAnimation)?i.container.willRemoved:!0;return!i.container.isRemoved||!n})}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&&!i.container.willRemoved&&n.endTime===null&&de(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&kt(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 va((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,o,a;this.clearHistoryIfEnded(),(e=this.blinkAnimationRef)==null||e.destroy(),this.destroyGameControllers(),this.gameControllers=[],(t=this.graph)==null||t.destroy(),this.seamlessControllerSubs.unsubscribe(),(i=this.seamlessController)==null||i.removeAll(),(n=this.resizeManager)==null||n.release(),this.animation.release(),(o=this.interactiveEvents)==null||o.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),(a=this.lastFrame)==null||a.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var ad={Container:Ce,createChoiceContainer:Dt,createAreaControl:Ft,createButtonControl:qt,classnamesPrefix:$i};var _g={version:_i};export{ef as ContainerTypes,Pt as ControlTypes,F as CustomError,w as EVENT_NAMES,R as EventActionTypes,tf as EventTypes,nr as Interactives,Pe as ManifestController,_g as SDKInfo,gi as chapterIdsToVKVideoIds,si as compareVersions,zm as containerTypes,Km as controlTypes,Xm as eventActionTypes,Qm as eventTypes,Jh as getChapterIdByVkVideoId,pl as getVKVideoIdByMedia,Yh as getVideoRawIdByMedia,nt as graphEventTypes,Mt as hasEndTemplate,_ as interactivesEventTypes,Wm as isAreaControl,Gm as isButtonControl,ee as isLastChapter,Oe as isOneTextCtrlContainer,kt as isSupportedManifest,Ot as isTextControl,Zh as isVKVariantItem,Jo as isValidManifest,es as migrateManifestToLatestVersion,ad as utils,hl as vkVideoIdsToChapterIds};
285
+ `;var ml=r=>{let e=document.createElement("style");e.textContent=dl,r.prepend(e)};import{clientChecker as nd}from"@vkontakte/videoplayer-core/es2018";var bl=Object.freeze({lang:rd.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},isTouch:!1,disableTextControlContainerVisibilityEvents:!1,animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1,controlsTapPlace:!1,controlsFillAnimation:!1,controlsHideAnimation:!1},enableAvPlayerSupport:!1});function od(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var nr=class{constructor(e){this.playerSubscriptions=new Ti;this.subscriptions=new Ti;this.globalEventEmitter=new Ht;this.animation=new Ut;this.seekToInteractiveController=new et;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=od();this.factories=new Map([["choice",Dt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new Ti;this.graph=null;this.lastFrame=null;this.blinkAnimationRef=null;this.appState=0;this.state={prevChapter$:new D(null),isInitialChapter$:new D(!1),isFirstChapter$:new D(!0),isEndChapter$:new D(!1),isInteractiveExpectation$:new D(!1),isReplay$:new D(!1),calledByInteractive$:new D(!1),lastChapterChangeWasInitiatedByInteractive$:new D(!1),disabledControls$:new D(!1),interactiveRanges$:new D([]),isInteractiveTime$:new D(!1),statistics$:new D(null),isSeekable$:new D(!1)};this.events={noInteraction$:new B,graphVisibilityChanged$:new B,watchAgainIsClicked$:new B,chapterChanged$:new B,playerChanged$:new B,error$:new B,eachTick$:new B,manifestChanged$:new B,interactiveRangeEnded$:new B,interactiveContainerRemoved$:new B,interactiveContainerFakeRemoved$:new B,interactiveActionExecution$:new B,interactiveActionChoice$:new B,interactiveVisibilityChanged$:new B};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(w.errors,e)};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&&ee(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...i}=e;if(t){let{statSubscription:n,oneStat:o}=t;n.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(w.playerChanged,i)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.destroyGameControllers=({removeTextControls:e=!0,withTransition:t=!1}={})=>{for(let i of this.gameControllers)!e&&i.isPermanentText||(this.animation.removeFn(i.whilePlaying),i.destroy(t))};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(o=>({...o,subjects:o.subjects.filter(a=>a.id!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var n,o,a;if(this._options={...bl,...e,config:{...bl.config,...e.config}},(n=this._options.animationsFeatureToggles)==null?void 0:n.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new Lt,this.blinkAnimationRef.create();let s=this.blinkAnimationRef.element;s&&this.rootElement.append(s)}this._options.parentElement.append(this.rootElement),this.historyController=new lt({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(o=this._options.projectInfo)==null?void 0:o.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new ir({parentElement:this._options.parentElement,onError:s=>{let l=new F(1,6,s);this.emitErrorEvent(l)}})),ml(this._options.parentElement),this.subscriptions.add(vl(this.rootElement,"mousedown").subscribe(s=>s.stopPropagation())).add(vl(this.rootElement,"mouseup").subscribe(s=>s.stopPropagation())),this.manifestController=new Pe(this._options.loaders,s=>{let l=new F(1,3,s);this.emitErrorEvent(l)});let i=[];this._options.lastFrame&&i.push(()=>{var s;(s=this.lastFrame)==null||s.updateCanvasDimensions(!0)}),i.push(()=>{let s=this.state.isInteractiveTime$.getValue();for(let l of this.gameControllers)l.onResize(s)}),this.cssVarsManager=new Gt((a=this._options)==null?void 0:a.parentElement),this.resizeManager=tl(()=>({player:this.player,cssVarsManager:this.cssVarsManager,parentElement:this._options.parentElement,fns:i})),this._options.graph&&(this.graph=new Je({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:s=>{this.setChapter({chapterId:s}),this.globalEventEmitter.emit(w.graph,{type:nt.watchAgainClicked,chapterId:s}),this.events.watchAgainIsClicked$.next(s)},onError:s=>{let l=new F(1,2,{message:s});this.emitErrorEvent(l)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{var t,i;if(this.state.calledByInteractive$.next(!0),(e.actionType==="setNextBranch"||!this._options.endChapterHistoryFix)&&this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:n}=e.payload;this.setChapter({chapterId:n}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:n}=e.payload;n&&this.setManifest(n)}e.actionType==="expect"?(this.state.isInteractiveExpectation$.next(!0),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType==="after-expect"&&(this.state.isInteractiveExpectation$.next(!1),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}))})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:i})=>{var n;e!=="action-choice"||t==="chapter"||"invokeImmediately"in i&&i.invokeImmediately||this.destroyGameControllers({removeTextControls:!1,withTransition:(n=this._options.animationsFeatureToggles)==null?void 0:n.controlsHideAnimation})}))}async initSeamless(){this.seamlessController=hi(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:o})=>t>=o[1]);if(n){let o=n.range.join("-");this.endedRanges.has(o)||(this.endedRanges.add(o),this.globalEventEmitter.emit(w.interactives,{type:M.rangeEnded,payload:n,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:n}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(id()).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(td({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:i})=>{var l;let n;if(i)n=!0;else{let c=e*1e3;n=!!t.find(({range:[f,v],subjects:y})=>f<c&&c<v&&y.some(C=>!C.isRemoved)&&y.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let o=!!this.noInteractionTimeout,s=((l=this.player)==null?void 0:l.info.playbackState$.getValue())==="playing"||i;n&&!o&&s?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):o&&!s&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{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.getGameControllers(e),(i=this.interactiveEvents)==null||i.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(n=>n.container.container).filter(n=>!Oe(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)}getGameControllers(e){let t=[];return e.containers.forEach(i=>{var s,l,c,d,f,v,y;let n=i.type.trim().toLowerCase(),o=this.factories.get(n),a=o==null?void 0:o(i,this.rootElement,this.cssVarsManager,{isTouch:(l=(s=this._options)==null?void 0:s.isTouch)!=null?l:!1,features:{controlsExpectTimeBlinkAnimation:(c=this._options.animationsFeatureToggles)==null?void 0:c.controlsExpectTimeBlinkAnimation,controlsTapPlace:(d=this._options.animationsFeatureToggles)==null?void 0:d.controlsTapPlace,controlsFillAnimation:(f=this._options.animationsFeatureToggles)==null?void 0:f.controlsFillAnimation}});if(a&&this.selectBranches&&this.interactiveEvents&&this.player){let C=new Zt({player:this.player,container:a,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>ns(i,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(i.id)},onError:this.emitErrorEvent,disableTextControlContainerVisibilityEvents:(v=this.options.disableTextControlContainerVisibilityEvents)!=null?v:!1,features:{controlsHideAnimation:(y=this._options.animationsFeatureToggles)==null?void 0:y.controlsHideAnimation,enableAvPlayerSupport:this._options.enableAvPlayerSupport}});this.animation.addFn(C.whilePlaying,!0),t.push(C)}}),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 s,l;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(s=i&&ee(i)&&Mt(i))!=null?s:!1,o=((l=this.manifestController.manifest)==null?void 0:l.metadata.initChapterId)===e,a=this.historyController.state.history$.getValue();if(o||n&&t){this.historyController.updateHistory([e]);return}(0,yl.default)(a,-1)!==e&&this.historyController.updateHistory([...a,e])}handleFakeRemoval(e,t){let{interactiveRanges$:i}=this.state,o=i.getValue().map(a=>{let s=a.subjects.some(c=>c.id===e),l=a.subjects.map(c=>t&&s||c.id===e?{...c,isRemoved:!0}:c);return{...a,subjects:l}});i.next(o)}reset(){var e;this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this._options.endChapterHistoryFix&&this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1),this.clearNoInteractionTimeout())}toggleBlinkAnimation(e){var i,n;if(!((i=this._options.animationsFeatureToggles)!=null&&i.controlsExpectTimeBlinkAnimation))return;let t=(o,a)=>{o.toggleBlinkAnimation(a)};_t({...e,gameControllers:this.gameControllers,execFn:ot(di(t),e.isExpect)}),e.isExpect&&((n=this.blinkAnimationRef)==null||n.restart())}updateControlsShadowStyles(e){var i;if(!((i=this._options.animationsFeatureToggles)!=null&&i.areaControlShadow))return;let t=(n,o)=>{n.updateControlsShadowStyles(o)};e.isExpect?_t({...e,gameControllers:this.gameControllers,execFn:ot(di(t),!1)}):_t({...e,gameControllers:this.gameControllers,execFn:t})}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(w.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=Za(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=cl({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:i=!1}={}){var l,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&nd.browser.isSafari&&await hl(35);let n=!i&&this.state.isEndChapter$.getValue()&&((l=this.getCurrentManifest())==null?void 0:l.metadata.initChapterId)===e;this.state.isReplay$.next(n);let{chapter:o,media:a,graph:s}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||n)&&this.state.isFirstChapter$.next(!0),!(!o||!a)&&(t&&this.pushChapterToHistory(o.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(o),this.state.isInteractiveTime$.next(!1),this.state.isInteractiveExpectation$.next(!1),(c=this.lastFrame)==null||c.setCurrentChapter(o),this.events.chapterChanged$.next({chapter:o,manifestVideo:a}),this.globalEventEmitter.emit(w.chapterChanged,{chapter:o,media:a,graph:s}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new fl(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?ct.GRAPH_SHOW:ct.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(ct.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(ct.NEXT_BUTTON),n==="Area"&&e.next(ct.NEXT_AREA))}))}),nextMovie$:new fl(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(w.graph,{type:nt.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===R.setNextBranch)}allControlsAreRemoved(e=!0){return!this.gameControllers.some(i=>{var o;let n=e&&((o=this._options.animationsFeatureToggles)!=null&&o.controlsHideAnimation)?i.container.willRemoved:!0;return!i.container.isRemoved||!n})}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&&!i.container.willRemoved&&n.endTime===null&&de(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&kt(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 fa((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,o,a;this.clearHistoryIfEnded(),(e=this.blinkAnimationRef)==null||e.destroy(),this.destroyGameControllers(),this.gameControllers=[],(t=this.graph)==null||t.destroy(),this.seamlessControllerSubs.unsubscribe(),(i=this.seamlessController)==null||i.removeAll(),(n=this.resizeManager)==null||n.release(),this.animation.release(),(o=this.interactiveEvents)==null||o.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),(a=this.lastFrame)==null||a.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var sd={Container:Ce,createChoiceContainer:Dt,createAreaControl:Ft,createButtonControl:qt,classnamesPrefix:Ni};var Mg={version:Mi};export{Jm as ContainerTypes,Pt as ControlTypes,F as CustomError,w as EVENT_NAMES,R as EventActionTypes,ef as EventTypes,nr as Interactives,Pe as ManifestController,Mg as SDKInfo,gi as chapterIdsToVKVideoIds,si as compareVersions,Wm as containerTypes,zm as controlTypes,Qm as eventActionTypes,Km as eventTypes,Zh as getChapterIdByVkVideoId,ul as getVKVideoIdByMedia,Xh as getVideoRawIdByMedia,nt as graphEventTypes,Mt as hasEndTemplate,M as interactivesEventTypes,Gm as isAreaControl,Um as isButtonControl,ee as isLastChapter,Oe as isOneTextCtrlContainer,kt as isSupportedManifest,Ot as isTextControl,Yh as isVKVariantItem,Zo as isValidManifest,Jo as migrateManifestToLatestVersion,sd as utils,pl as vkVideoIdsToChapterIds};