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