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