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