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