@vkontakte/videoplayer-interactive 1.0.40-dev.64a00d86.0 → 1.0.40-dev.7807e4e6.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.cjs.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.40-dev.64a00d86.0
3
- * Fri, 20 Jun 2025 12:35:34 GMT
2
+ * @vkontakte/videoplayer-interactive v1.0.40-dev.7807e4e6.0
3
+ * Fri, 20 Jun 2025 11:40:21 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-40/doc/
5
5
  */
6
- "use strict";var Ds=Object.create;var et=Object.defineProperty;var Hs=Object.getOwnPropertyDescriptor;var Us=Object.getOwnPropertyNames;var Gs=Object.getPrototypeOf,zs=Object.prototype.hasOwnProperty;var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ws=(r,e)=>{for(var t in e)et(r,t,{get:e[t],enumerable:!0})},li=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Us(e))!zs.call(r,n)&&n!==t&&et(r,n,{get:()=>e[n],enumerable:!(i=Hs(e,n))||i.enumerable});return r};var W=(r,e,t)=>(t=r!=null?Ds(Gs(r)):{},li(e||!r||!r.__esModule?et(t,"default",{value:r,enumerable:!0}):t,r)),Ks=r=>li(et({},"__esModule",{value:!0}),r);var Q=p((er,Ci)=>{"use strict";var Re=function(r){return r&&r.Math===Math&&r};Ci.exports=Re(typeof globalThis=="object"&&globalThis)||Re(typeof window=="object"&&window)||Re(typeof self=="object"&&self)||Re(typeof global=="object"&&global)||Re(typeof er=="object"&&er)||function(){return this}()||Function("return this")()});var B=p((Bh,Ei)=>{"use strict";Ei.exports=function(r){try{return!!r()}catch{return!0}}});var ke=p((qh,Ti)=>{"use strict";var Ys=B();Ti.exports=!Ys(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Si=p((Dh,wi)=>{"use strict";var Zs=ke(),Ai=Function.prototype,Ii=Ai.apply,xi=Ai.call;wi.exports=typeof Reflect=="object"&&Reflect.apply||(Zs?xi.bind(Ii):function(){return xi.apply(Ii,arguments)})});var H=p((Hh,Oi)=>{"use strict";var Ri=ke(),ki=Function.prototype,tr=ki.call,Js=Ri&&ki.bind.bind(tr,tr);Oi.exports=Ri?Js:function(r){return function(){return tr.apply(r,arguments)}}});var Oe=p((Uh,Li)=>{"use strict";var Pi=H(),el=Pi({}.toString),tl=Pi("".slice);Li.exports=function(r){return tl(el(r),8,-1)}});var rr=p((Gh,Fi)=>{"use strict";var rl=Oe(),il=H();Fi.exports=function(r){if(rl(r)==="Function")return il(r)}});var q=p((zh,Mi)=>{"use strict";var ir=typeof document=="object"&&document.all;Mi.exports=typeof ir>"u"&&ir!==void 0?function(r){return typeof r=="function"||r===ir}:function(r){return typeof r=="function"}});var se=p((Wh,Vi)=>{"use strict";var nl=B();Vi.exports=!nl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ut=p((Kh,Ni)=>{"use strict";var ol=ke(),pt=Function.prototype.call;Ni.exports=ol?pt.bind(pt):function(){return pt.apply(pt,arguments)}});var nr=p(ji=>{"use strict";var $i={}.propertyIsEnumerable,_i=Object.getOwnPropertyDescriptor,al=_i&&!$i.call({1:2},1);ji.f=al?function(e){var t=_i(this,e);return!!t&&t.enumerable}:$i});var or=p((Xh,Bi)=>{"use strict";Bi.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Di=p((Yh,qi)=>{"use strict";var sl=H(),ll=B(),cl=Oe(),ar=Object,pl=sl("".split);qi.exports=ll(function(){return!ar("z").propertyIsEnumerable(0)})?function(r){return cl(r)==="String"?pl(r,""):ar(r)}:ar});var sr=p((Zh,Hi)=>{"use strict";Hi.exports=function(r){return r==null}});var lr=p((Jh,Ui)=>{"use strict";var ul=sr(),hl=TypeError;Ui.exports=function(r){if(ul(r))throw new hl("Can't call method on "+r);return r}});var Pe=p((ed,Gi)=>{"use strict";var dl=Di(),ml=lr();Gi.exports=function(r){return dl(ml(r))}});var ve=p((td,zi)=>{"use strict";var fl=q();zi.exports=function(r){return typeof r=="object"?r!==null:fl(r)}});var ht=p((rd,Wi)=>{"use strict";Wi.exports={}});var dt=p((id,Qi)=>{"use strict";var cr=ht(),pr=Q(),vl=q(),Ki=function(r){return vl(r)?r:void 0};Qi.exports=function(r,e){return arguments.length<2?Ki(cr[r])||Ki(pr[r]):cr[r]&&cr[r][e]||pr[r]&&pr[r][e]}});var Yi=p((nd,Xi)=>{"use strict";var bl=H();Xi.exports=bl({}.isPrototypeOf)});var tn=p((od,en)=>{"use strict";var yl=Q(),Zi=yl.navigator,Ji=Zi&&Zi.userAgent;en.exports=Ji?String(Ji):""});var cn=p((ad,ln)=>{"use strict";var sn=Q(),ur=tn(),rn=sn.process,nn=sn.Deno,on=rn&&rn.versions||nn&&nn.version,an=on&&on.v8,U,mt;an&&(U=an.split("."),mt=U[0]>0&&U[0]<4?1:+(U[0]+U[1]));!mt&&ur&&(U=ur.match(/Edge\/(\d+)/),(!U||U[1]>=74)&&(U=ur.match(/Chrome\/(\d+)/),U&&(mt=+U[1])));ln.exports=mt});var hr=p((sd,un)=>{"use strict";var pn=cn(),gl=B(),Cl=Q(),El=Cl.String;un.exports=!!Object.getOwnPropertySymbols&&!gl(function(){var r=Symbol("symbol detection");return!El(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&pn&&pn<41})});var dr=p((ld,hn)=>{"use strict";var Tl=hr();hn.exports=Tl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var mr=p((cd,dn)=>{"use strict";var Il=dt(),xl=q(),Al=Yi(),wl=dr(),Sl=Object;dn.exports=wl?function(r){return typeof r=="symbol"}:function(r){var e=Il("Symbol");return xl(e)&&Al(e.prototype,Sl(r))}});var fn=p((pd,mn)=>{"use strict";var Rl=String;mn.exports=function(r){try{return Rl(r)}catch{return"Object"}}});var fr=p((ud,vn)=>{"use strict";var kl=q(),Ol=fn(),Pl=TypeError;vn.exports=function(r){if(kl(r))return r;throw new Pl(Ol(r)+" is not a function")}});var yn=p((hd,bn)=>{"use strict";var Ll=fr(),Fl=sr();bn.exports=function(r,e){var t=r[e];return Fl(t)?void 0:Ll(t)}});var Cn=p((dd,gn)=>{"use strict";var vr=ut(),br=q(),yr=ve(),Ml=TypeError;gn.exports=function(r,e){var t,i;if(e==="string"&&br(t=r.toString)&&!yr(i=vr(t,r))||br(t=r.valueOf)&&!yr(i=vr(t,r))||e!=="string"&&br(t=r.toString)&&!yr(i=vr(t,r)))return i;throw new Ml("Can't convert object to primitive value")}});var Tn=p((md,En)=>{"use strict";En.exports=!0});var An=p((fd,xn)=>{"use strict";var In=Q(),Vl=Object.defineProperty;xn.exports=function(r,e){try{Vl(In,r,{value:e,configurable:!0,writable:!0})}catch{In[r]=e}return e}});var ft=p((vd,Rn)=>{"use strict";var Nl=Tn(),$l=Q(),_l=An(),wn="__core-js_shared__",Sn=Rn.exports=$l[wn]||_l(wn,{});(Sn.versions||(Sn.versions=[])).push({version:"3.38.0",mode:Nl?"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 gr=p((bd,On)=>{"use strict";var kn=ft();On.exports=function(r,e){return kn[r]||(kn[r]=e||{})}});var Le=p((yd,Pn)=>{"use strict";var jl=lr(),Bl=Object;Pn.exports=function(r){return Bl(jl(r))}});var be=p((gd,Ln)=>{"use strict";var ql=H(),Dl=Le(),Hl=ql({}.hasOwnProperty);Ln.exports=Object.hasOwn||function(e,t){return Hl(Dl(e),t)}});var Cr=p((Cd,Fn)=>{"use strict";var Ul=H(),Gl=0,zl=Math.random(),Wl=Ul(1 .toString);Fn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Wl(++Gl+zl,36)}});var Fe=p((Ed,Vn)=>{"use strict";var Kl=Q(),Ql=gr(),Mn=be(),Xl=Cr(),Yl=hr(),Zl=dr(),ye=Kl.Symbol,Er=Ql("wks"),Jl=Zl?ye.for||ye:ye&&ye.withoutSetter||Xl;Vn.exports=function(r){return Mn(Er,r)||(Er[r]=Yl&&Mn(ye,r)?ye[r]:Jl("Symbol."+r)),Er[r]}});var jn=p((Td,_n)=>{"use strict";var ec=ut(),Nn=ve(),$n=mr(),tc=yn(),rc=Cn(),ic=Fe(),nc=TypeError,oc=ic("toPrimitive");_n.exports=function(r,e){if(!Nn(r)||$n(r))return r;var t=tc(r,oc),i;if(t){if(e===void 0&&(e="default"),i=ec(t,r,e),!Nn(i)||$n(i))return i;throw new nc("Can't convert object to primitive value")}return e===void 0&&(e="number"),rc(r,e)}});var Tr=p((Id,Bn)=>{"use strict";var ac=jn(),sc=mr();Bn.exports=function(r){var e=ac(r,"string");return sc(e)?e:e+""}});var Hn=p((xd,Dn)=>{"use strict";var lc=Q(),qn=ve(),Ir=lc.document,cc=qn(Ir)&&qn(Ir.createElement);Dn.exports=function(r){return cc?Ir.createElement(r):{}}});var xr=p((Ad,Un)=>{"use strict";var pc=se(),uc=B(),hc=Hn();Un.exports=!pc&&!uc(function(){return Object.defineProperty(hc("div"),"a",{get:function(){return 7}}).a!==7})});var Wn=p(zn=>{"use strict";var dc=se(),mc=ut(),fc=nr(),vc=or(),bc=Pe(),yc=Tr(),gc=be(),Cc=xr(),Gn=Object.getOwnPropertyDescriptor;zn.f=dc?Gn:function(e,t){if(e=bc(e),t=yc(t),Cc)try{return Gn(e,t)}catch{}if(gc(e,t))return vc(!mc(fc.f,e,t),e[t])}});var Qn=p((Sd,Kn)=>{"use strict";var Ec=B(),Tc=q(),Ic=/#|\.prototype\./,Me=function(r,e){var t=Ac[xc(r)];return t===Sc?!0:t===wc?!1:Tc(e)?Ec(e):!!e},xc=Me.normalize=function(r){return String(r).replace(Ic,".").toLowerCase()},Ac=Me.data={},wc=Me.NATIVE="N",Sc=Me.POLYFILL="P";Kn.exports=Me});var Ar=p((Rd,Yn)=>{"use strict";var Xn=rr(),Rc=fr(),kc=ke(),Oc=Xn(Xn.bind);Yn.exports=function(r,e){return Rc(r),e===void 0?r:kc?Oc(r,e):function(){return r.apply(e,arguments)}}});var Jn=p((kd,Zn)=>{"use strict";var Pc=se(),Lc=B();Zn.exports=Pc&&Lc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var to=p((Od,eo)=>{"use strict";var Fc=ve(),Mc=String,Vc=TypeError;eo.exports=function(r){if(Fc(r))return r;throw new Vc(Mc(r)+" is not an object")}});var no=p(io=>{"use strict";var Nc=se(),$c=xr(),_c=Jn(),vt=to(),ro=Tr(),jc=TypeError,wr=Object.defineProperty,Bc=Object.getOwnPropertyDescriptor,Sr="enumerable",Rr="configurable",kr="writable";io.f=Nc?_c?function(e,t,i){if(vt(e),t=ro(t),vt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&kr in i&&!i[kr]){var n=Bc(e,t);n&&n[kr]&&(e[t]=i.value,i={configurable:Rr in i?i[Rr]:n[Rr],enumerable:Sr in i?i[Sr]:n[Sr],writable:!1})}return wr(e,t,i)}:wr:function(e,t,i){if(vt(e),t=ro(t),vt(i),$c)try{return wr(e,t,i)}catch{}if("get"in i||"set"in i)throw new jc("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var ao=p((Ld,oo)=>{"use strict";var qc=se(),Dc=no(),Hc=or();oo.exports=qc?function(r,e,t){return Dc.f(r,e,Hc(1,t))}:function(r,e,t){return r[e]=t,r}});var Ne=p((Fd,lo)=>{"use strict";var Ve=Q(),Uc=Si(),Gc=rr(),zc=q(),Wc=Wn().f,Kc=Qn(),ge=ht(),Qc=Ar(),Ce=ao(),so=be();ft();var Xc=function(r){var e=function(t,i,n){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,i)}return new r(t,i,n)}return Uc(r,this,arguments)};return e.prototype=r.prototype,e};lo.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,s=i?Ve:n?Ve[t]:Ve[t]&&Ve[t].prototype,a=i?ge:ge[t]||Ce(ge,t,{})[t],l=a.prototype,c,d,m,b,v,k,I,g,u;for(b in e)c=Kc(i?b:t+(n?".":"#")+b,r.forced),d=!c&&s&&so(s,b),k=a[b],d&&(r.dontCallGetSet?(u=Wc(s,b),I=u&&u.value):I=s[b]),v=d&&I?I:e[b],!(!c&&!o&&typeof k==typeof v)&&(r.bind&&d?g=Qc(v,Ve):r.wrap&&d?g=Xc(v):o&&zc(v)?g=Gc(v):g=v,(r.sham||v&&v.sham||k&&k.sham)&&Ce(g,"sham",!0),Ce(a,b,g),o&&(m=t+"Prototype",so(ge,m)||Ce(ge,m,{}),Ce(ge[m],b,v),r.real&&l&&(c||!l[b])&&Ce(l,b,v)))}});var po=p((Md,co)=>{"use strict";var Yc=Math.ceil,Zc=Math.floor;co.exports=Math.trunc||function(e){var t=+e;return(t>0?Zc:Yc)(t)}});var $e=p((Vd,uo)=>{"use strict";var Jc=po();uo.exports=function(r){var e=+r;return e!==e||e===0?0:Jc(e)}});var mo=p((Nd,ho)=>{"use strict";var ep=$e(),tp=Math.max,rp=Math.min;ho.exports=function(r,e){var t=ep(r);return t<0?tp(t+e,0):rp(t,e)}});var vo=p(($d,fo)=>{"use strict";var ip=$e(),np=Math.min;fo.exports=function(r){var e=ip(r);return e>0?np(e,9007199254740991):0}});var _e=p((_d,bo)=>{"use strict";var op=vo();bo.exports=function(r){return op(r.length)}});var Or=p((jd,go)=>{"use strict";var ap=Pe(),sp=mo(),lp=_e(),yo=function(r){return function(e,t,i){var n=ap(e),o=lp(n);if(o===0)return!r&&-1;var s=sp(i,o),a;if(r&&t!==t){for(;o>s;)if(a=n[s++],a!==a)return!0}else for(;o>s;s++)if((r||s in n)&&n[s]===t)return r||s||0;return!r&&-1}};go.exports={includes:yo(!0),indexOf:yo(!1)}});var bt=p((Bd,Co)=>{"use strict";Co.exports=function(){}});var Eo=p(()=>{"use strict";var cp=Ne(),pp=Or().includes,up=B(),hp=bt(),dp=up(function(){return!Array(1).includes()});cp({target:"Array",proto:!0,forced:dp},{includes:function(e){return pp(this,e,arguments.length>1?arguments[1]:void 0)}});hp("includes")});var yt=p((Hd,To)=>{"use strict";var mp=dt();To.exports=mp});var xo=p((Ud,Io)=>{"use strict";Eo();var fp=yt();Io.exports=fp("Array","includes")});var wo=p((Gd,Ao)=>{"use strict";var vp=xo();Ao.exports=vp});var gt=p((zd,So)=>{"use strict";var bp=wo();So.exports=bp});var Do=p(()=>{"use strict";var Rp=Ne(),kp=Le(),Op=_e(),Pp=$e(),Lp=bt();Rp({target:"Array",proto:!0},{at:function(e){var t=kp(this),i=Op(t),n=Pp(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});Lp("at")});var Uo=p((cf,Ho)=>{"use strict";Do();var Fp=yt();Ho.exports=Fp("Array","at")});var zo=p((pf,Go)=>{"use strict";var Mp=Uo();Go.exports=Mp});var qr=p((uf,Wo)=>{"use strict";var Vp=zo();Wo.exports=Vp});var ia=p((Yf,ra)=>{"use strict";var Hp=gr(),Up=Cr(),ta=Hp("keys");ra.exports=function(r){return ta[r]||(ta[r]=Up(r))}});var oa=p((Zf,na)=>{"use strict";var Gp=B();na.exports=!Gp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var la=p((Jf,sa)=>{"use strict";var zp=be(),Wp=q(),Kp=Le(),Qp=ia(),Xp=oa(),aa=Qp("IE_PROTO"),zr=Object,Yp=zr.prototype;sa.exports=Xp?zr.getPrototypeOf:function(r){var e=Kp(r);if(zp(e,aa))return e[aa];var t=e.constructor;return Wp(t)&&e instanceof t?t.prototype:e instanceof zr?Yp:null}});var pa=p((ev,ca)=>{"use strict";ca.exports={}});var da=p((tv,ha)=>{"use strict";var Zp=H(),Wr=be(),Jp=Pe(),eu=Or().indexOf,tu=pa(),ua=Zp([].push);ha.exports=function(r,e){var t=Jp(r),i=0,n=[],o;for(o in t)!Wr(tu,o)&&Wr(t,o)&&ua(n,o);for(;e.length>i;)Wr(t,o=e[i++])&&(~eu(n,o)||ua(n,o));return n}});var fa=p((rv,ma)=>{"use strict";ma.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var ba=p((iv,va)=>{"use strict";var ru=da(),iu=fa();va.exports=Object.keys||function(e){return ru(e,iu)}});var Ia=p((nv,Ta)=>{"use strict";var ga=se(),nu=B(),Ca=H(),ou=la(),au=ba(),su=Pe(),lu=nr().f,Ea=Ca(lu),cu=Ca([].push),pu=ga&&nu(function(){var r=Object.create(null);return r[2]=2,!Ea(r,2)}),ya=function(r){return function(e){for(var t=su(e),i=au(t),n=pu&&ou(t)===null,o=i.length,s=0,a=[],l;o>s;)l=i[s++],(!ga||(n?l in t:Ea(t,l)))&&cu(a,r?[l,t[l]]:t[l]);return a}};Ta.exports={entries:ya(!0),values:ya(!1)}});var xa=p(()=>{"use strict";var uu=Ne(),hu=Ia().values;uu({target:"Object",stat:!0},{values:function(e){return hu(e)}})});var wa=p((sv,Aa)=>{"use strict";xa();var du=ht();Aa.exports=du.Object.values});var Ra=p((lv,Sa)=>{"use strict";var mu=wa();Sa.exports=mu});var _t=p((cv,ka)=>{"use strict";var fu=Ra();ka.exports=fu});var Zr=p((Ov,$a)=>{"use strict";var bu=Oe();$a.exports=Array.isArray||function(e){return bu(e)==="Array"}});var ja=p((Pv,_a)=>{"use strict";var yu=TypeError,gu=9007199254740991;_a.exports=function(r){if(r>gu)throw yu("Maximum allowed index exceeded");return r}});var Da=p((Lv,qa)=>{"use strict";var Cu=Zr(),Eu=_e(),Tu=ja(),Iu=Ar(),Ba=function(r,e,t,i,n,o,s,a){for(var l=n,c=0,d=s?Iu(s,a):!1,m,b;c<i;)c in t&&(m=d?d(t[c],c,e):t[c],o>0&&Cu(m)?(b=Eu(m),l=Ba(r,e,m,b,l,o-1)-1):(Tu(l+1),r[l]=m),l++),c++;return l};qa.exports=Ba});var Ga=p((Fv,Ua)=>{"use strict";var xu=Fe(),Au=xu("toStringTag"),Ha={};Ha[Au]="z";Ua.exports=String(Ha)==="[object z]"});var Wa=p((Mv,za)=>{"use strict";var wu=Ga(),Su=q(),Bt=Oe(),Ru=Fe(),ku=Ru("toStringTag"),Ou=Object,Pu=Bt(function(){return arguments}())==="Arguments",Lu=function(r,e){try{return r[e]}catch{}};za.exports=wu?Bt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=Lu(e=Ou(r),ku))=="string"?t:Pu?Bt(e):(i=Bt(e))==="Object"&&Su(e.callee)?"Arguments":i}});var Qa=p((Vv,Ka)=>{"use strict";var Fu=H(),Mu=q(),Jr=ft(),Vu=Fu(Function.toString);Mu(Jr.inspectSource)||(Jr.inspectSource=function(r){return Vu(r)});Ka.exports=Jr.inspectSource});var ts=p((Nv,es)=>{"use strict";var Nu=H(),$u=B(),Xa=q(),_u=Wa(),ju=dt(),Bu=Qa(),Ya=function(){},Za=ju("Reflect","construct"),ei=/^\s*(?:class|function)\b/,qu=Nu(ei.exec),Du=!ei.test(Ya),Xe=function(e){if(!Xa(e))return!1;try{return Za(Ya,[],e),!0}catch{return!1}},Ja=function(e){if(!Xa(e))return!1;switch(_u(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Du||!!qu(ei,Bu(e))}catch{return!0}};Ja.sham=!0;es.exports=!Za||$u(function(){var r;return Xe(Xe.call)||!Xe(Object)||!Xe(function(){r=!0})||r})?Ja:Xe});var os=p(($v,ns)=>{"use strict";var rs=Zr(),Hu=ts(),Uu=ve(),Gu=Fe(),zu=Gu("species"),is=Array;ns.exports=function(r){var e;return rs(r)&&(e=r.constructor,Hu(e)&&(e===is||rs(e.prototype))?e=void 0:Uu(e)&&(e=e[zu],e===null&&(e=void 0))),e===void 0?is:e}});var ss=p((_v,as)=>{"use strict";var Wu=os();as.exports=function(r,e){return new(Wu(r))(e===0?0:e)}});var ls=p(()=>{"use strict";var Ku=Ne(),Qu=Da(),Xu=Le(),Yu=_e(),Zu=$e(),Ju=ss();Ku({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Xu(this),i=Yu(t),n=Ju(t,0);return n.length=Qu(n,t,t,i,0,e===void 0?1:Zu(e)),n}})});var cs=p(()=>{"use strict";var eh=bt();eh("flat")});var us=p((Hv,ps)=>{"use strict";ls();cs();var th=yt();ps.exports=th("Array","flat")});var ds=p((Uv,hs)=>{"use strict";var rh=us();hs.exports=rh});var fs=p((Gv,ms)=>{"use strict";var ih=ds();ms.exports=ih});var dh={};Ws(dh,{ContainerTypes:()=>y.ContainerTypes,ControlTypes:()=>y.ControlTypes,CustomError:()=>F,EVENT_NAMES:()=>w,EventActionTypes:()=>y.EventActionTypes,EventTypes:()=>y.EventTypes,Interactives:()=>Ze,ManifestController:()=>pe,SDKInfo:()=>hh,chapterIdsToVKVideoIds:()=>Dt,compareVersions:()=>Nt,containerTypes:()=>Cp,controlTypes:()=>Ep,eventActionTypes:()=>Ip,eventTypes:()=>Tp,getChapterIdByVkVideoId:()=>Fs,getVKVideoIdByMedia:()=>ii,getVideoRawIdByMedia:()=>Ps,graphEventTypes:()=>Ie,hasEndTemplate:()=>Be,interactivesEventTypes:()=>P,isAreaControl:()=>gp,isButtonControl:()=>yp,isLastChapter:()=>G,isOneTextCtrlContainer:()=>ce,isSupportedManifest:()=>y.isSupportedManifest,isTextControl:()=>je,isVKVariantItem:()=>Ls,isValidManifest:()=>Pr,migrateManifestToLatestVersion:()=>y.migrateManifestToLatestVersion,utils:()=>Bs,vkVideoIdsToChapterIds:()=>ni});module.exports=Ks(dh);var ci="1.0.40-dev.64a00d86.0";var qe=require("@vkontakte/videoplayer-shared");var zt=class{constructor(e){this.layout=e}},tt=class extends zt{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * (${t.width} + ${2e-4}))`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var ui=require("@vkontakte/videoplayer-shared");function pi(r){return"features"in r}var F=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};function rt({emitter$:r,error:e,subjectId:t,message:i="",severity:n=1,category:o=1}){let s=new F(n,o,{message:i,error:e,details:{id:t}});r.next(s)}var de=class{constructor(e,t){this.error$=new ui.Subject;this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&pi(this.options)&&this.options.features[e]}onError(e="",t){rt({emitter$:this.error$,error:t,message:e,subjectId:this.container.id})}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){return this.container.controls?.reduce((e,t)=>{let i=t.type.trim().toLowerCase(),n=this.factories.get(i);if(n){let o=n(t,this.options);if(o)return[...e,o]}return[...e]},[])||[]}};var Y=require("@vkontakte/videoplayer-shared");var ee=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,te=r=>ee(r,"Object"),it=r=>ee(r,"String"),nt=r=>ee(r,"Array"),ot=r=>ee(r,"Number"),hi=r=>ee(r,"Function"),di=r=>ee(r,"Boolean"),Qt=r=>ot(r)&&!isNaN(r);var oe=r=>te(r)&&Object.keys(r).length===0,Xt=r=>nt(r)&&!r.length;var Ae=(r,e)=>it(r)&&(e?r.trim():r).length;function we(r,e=1){let t="0",i="0",n="0";return r.length===4?(t="0x"+r[1]+r[1],i="0x"+r[2]+r[2],n="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],i="0x"+r[3]+r[4],n="0x"+r[5]+r[6]),`rgba(${+t},${+i},${+n},${e})`}var mi="interactive",O={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},fi=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(fi||{}),vi=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(vi||{}),bi=(i=>(i.start="left",i.end="right",i.center="center",i))(bi||{}),at=({target:r,props:e})=>{r.style.alignItems=(e?.gravityVertical&&fi[e.gravityVertical])??"center",r.style.justifyContent=(e?.gravityHorizontal&&vi[e.gravityHorizontal])??"center",r.style.textAlign=(e?.alignment&&bi[e.alignment])??"center"},st=({target:r,props:e,fallback:t,dependsOn:i})=>{r.style.color=e?.text?.color??t.textColor,r.style.fontSize=`calc(${i.height} * ${e?.text?.size??t.textSize})`,r.textContent=e?.text?.value??t.textContent},lt=({target:r,props:e,fallback:t})=>{r.style.backgroundColor=we(e?.background?.color??t.backgroundColor,e?.background?.alpha??t.backgroundAlpha)},Se=({target:r,props:e,fallback:t,dependsOn:i,useRawValues:n=!1})=>{let o=n?t.borderWidthRawValue:`calc(${i.height} * ${e?.shape?.border?.width??t.borderWidth})`,s=n?t.roundCornersRawValue:`calc(${i.height} * ${e?.shape?.roundCorners??t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=we(n?t.borderColor:e?.shape?.border?.color??t.borderColor,n?t.borderAlpha:e?.shape?.border?.alpha??t.borderAlpha),r.style.borderRadius=s},yi=({target:r,isDark:e,baseDimension:t,fallback:i})=>{let s=we(i.shadowColorLight,i.shadowColorAlpha),a=we(i.shadowColorDark,i.shadowColorAlpha),l=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${l} ${c} ${e?a:s}`;r.style.boxShadow=d},me=({target:r,layoutParams:e,fallback:t})=>{let i=e.angle??t.angle;i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};var X=require("@vkontakte/videoplayer-shared");var Yt="interactive-control-tap",fe={common:Yt,animation:`${Yt}-animation`,visible:`${Yt}-visible`};var Qs=60,ct=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=Qs,useDimensionsBasedSize:n=!1}){this.onElementClick=e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let i=t.getBoundingClientRect(),n={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},o=Math.min(n.width,n.height),s=i.left+i.width/2,a=i.top+i.height/2,l=e.clientX-s,c=e.clientY-a,d=Xs(l,c,this.controlRotateAngleRad);this.element.style.width=o+"px",this.element.style.left=d.x+i.width/2-o/2+"px",this.element.style.top=d.y+i.height/2-o/2+"px",this.element.classList.add(fe.visible,fe.animation)};this.onAnimationEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.element.classList.remove(fe.visible,fe.animation)};let o=document.createElement("div");o.classList.add(fe.common),this.controlRotateAngleRad=e,this.element=o,this.clickCancelCondition=t,this.circleDiameterPx=i,this.useDimensionsBasedSize=n}};function Xs(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var Zt="int",ae=(i=>(i.AREA=`${Zt}_area`,i.TEXT=`${Zt}_text`,i.BUTTON=`${Zt}_bttn`,i))(ae||{});function Jt(r){return"features"in r}var K="interactive-control",R={common:K,selected:`${K}-selected`,wrapper:`${K}-wrapper`,disabled:`${K}-disabled`,button:`${K}-button`,area:`${K}-area`,text:`${K}-text`,blinkAnim:`${K}-blink-anim`,blinkAnimButton:`${K}-blink-anim-button`,blinkAnimArea:`${K}-blink-anim-area`},gi=40;var ko=W(gt(),1);var y=require("@interactiveplatform/movika-manifest");var Ro={metadata:"Object",chapters:"Array"},Pr=r=>{if(!te(r))return!1;for(let e in Ro)if(!r[e]||!ee(r[e],Ro[e]))return!1;return(0,y.isSupportedManifest)(r.metadata.version)},je=r=>r.type===y.ControlTypes.Text,yp=r=>r.type===y.ControlTypes.Button,gp=r=>r.type===y.ControlTypes.Area,Cp={Choice:"Choice",TextInput:"TextInput"},Ep={Button:"Button",Area:"Area",Text:"Text"},Tp={onClick:"onClick",onSuspense:"onSuspense"},Ip={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Ct=r=>nt(r)&&!Xt(r),G=r=>r.order==="end",Be=r=>nt(r.containers)&&!Xt(r.containers)&&G(r),Oo=(r,e)=>{let t=r*1e3;return Ct(e.controls)&&t<(e.startTime??0)},Lr=(r,e)=>{let t=r*1e3;return Ct(e.controls)&&t>=(e.startTime??0)&&t<=(e.endTime??1/0)};var le=(r=[])=>r.some(e=>e.action.type==="expect"),Fr=(r=[])=>r.find(e=>e.action.type==="expect"),xp=r=>r?.length===1,ce=r=>xp(r)&&je(r[0]);function Po(r=[],e=1/0,t=[]){return r.filter(({container:i})=>!(0,ko.default)(t,i.container.id)&&le(i.container.events)&&i.container.endTime===e&&!i.isRemoved&&!i.willRemoved)}function Et({gameControllers:r=[],subjectName:e,subjectId:t,execFn:i}){for(let n of r)if(e==="container"&&n.container.container.id===t){i(n),Po(r,n.container.container.endTime,[n.container.container.id]).forEach(s=>{i(s)});break}}function Lo(r){for(let e of r.events)if(e.action.type==="openURI")return!0;return!1}var Fo=(r,e)=>{let t=I=>e.find(({container:u})=>u.container.id===I)?.container.isRemoved,i=le(r.events)&&!t(r.id),n=(I,g=!1,u=!1)=>{let h=u?"every":"some";return I.controls[h](f=>{let E=g?I.endTime===r.endTime:!0;return f.events?.[h](T=>T.action?.type===y.EventActionTypes.openURI)&&E})},o=I=>I.some(({container:g})=>n(g.container,!0,!1)&&!g.isRemoved),s=I=>I.every(({container:g})=>g.isRemoved||g.willRemoved?!0:n(g.container,!0,!0)),a=Po(e,r.endTime,[r.id]).length,l=I=>I.controls.some(g=>g.events?.some(u=>u.action?.args?.shouldOpenNow)),c=i||a>0,d=o(e),m=n(r),b=s(e),v=i?!1:a>0,k=l(r);return{isExpectTime:c,hasOtherExpect:a>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:b,isExpectEventForCurrentContainer:v,hasShouldOpenNowEvent:k}};var re=class r{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new X.Subscription;this.error$=new X.Subject;this.isInteracted=!1;this.isRemoved=!1;this.onControlSelect=()=>{this.container?.isManifestContainerDisabled()||Lo(this.control)||this.container?.element?.classList.add("interactive-control-wrapper-selected")};this.onTransitionEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}}removeView(e=!1){let t=this.getElement();if(t){if(e){if(t.classList.contains("interactive-control-before-remove"))return;t.classList.add("interactive-control-before-remove"),this.subscriptions.add((0,X.fromEvent)(t,"transitionend").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n))).add((0,X.fromEvent)(t,"transitioncancel").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n)));return}this.removeListeners(),t.remove(),this.isRemoved=!0}}onError(e="",t){rt({emitter$:this.error$,error:t,message:e,subjectId:this.control.id})}addControlTap(e){if(this.featureIsEnabled("controlsTapPlace")&&this.container){let t=this.control.layoutParams.angle??O.angle;this.controlTap=new ct({controlRotateAngleRad:t,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?gi:void 0}),this.subscriptions.add((0,X.fromEvent)(e,"click").subscribe(this.controlTap.onElementClick,i=>this.onError("Control click tap animation error",i))).add((0,X.fromEvent)(this.controlTap.element,"animationend").subscribe(this.controlTap.onAnimationEnd,i=>this.onError("Tap animationend error",i))),this.container.element.append(this.controlTap.element)}}createContainerElement(e){let t=document.createElement("div");t.classList.add(R.wrapper),e.setControlLayout(t,this.control.layoutParams);let i=(this.control.layoutParams.innerSizesDependOn??O.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"},n=()=>e.isContainerDisabled?.()??!1;this.container={element:t,dimensions:i,isManifestContainerDisabled:n}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted=!0,e()}}featureIsEnabled(e){return this.options&&Jt(this.options)&&this.options.features[e]}isTouch(){return this.options&&Jt(this.options)&&this.options.isTouch}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add((0,X.fromEvent)(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),n=>this.onError("Error happened on control interaction",n)));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var Mr="interactive-blink-anim-reference",V={common:Mr,animation:`${Mr}-animation`,disabled:`${Mr}-disabled`},Tt=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(V.common,V.animation),this._element=e}restart(){this._element&&(this._element.classList.add(V.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(V.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var Vr="interactive-container",N={common:Vr,hidden:`${Vr}-hidden`,disabled:`${Vr}-disabled`};var It=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Nr(r,e)},Nr=class extends re{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(R.common,R.area),i.setAttribute("data-testid",ae.AREA),lt({target:i,props:this.control.props,fallback:{...O,backgroundColor:"transparent"}}),me({target:i,layoutParams:this.control.layoutParams,fallback:O}),this.addControlTap(i),this.subscriptions.add((0,Y.fromEvent)(this.container.element,"click").pipe((0,Y.once)()).subscribe(this.onControlSelect,n=>this.onError("Control click handler error",n))),this.container.element.append(i),e.append(this.container.element),this.controlElement=i,this.updateShadowStyles(),this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,Y.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(N.disabled))return;let t=e.parentElement;if(t){let i=t.querySelector(`.${V.common}`);i&&this.syncBlinkAnimation(i)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,Y.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(N.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,Y.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(R.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(R.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){if(!(!this.container||!this.controlElement))if(di(e)){let t=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";yi({target:this.controlElement,props:this.control.props,fallback:O,isDark:e,baseDimension:t}),Se({target:this.controlElement,props:this.control.props,fallback:{...O,borderColor:e?O.shadowColorDark:O.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${this.control.props?.shape?.roundCorners??O.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else Se({target:this.controlElement,props:this.control.props,fallback:{...O,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(R.blinkAnim,e),this.controlElement?.classList.toggle(R.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${R.blinkAnimArea}`)||this.controlElement.classList.contains(R.selected)||this.controlElement.classList.contains(V.disabled)||(this.controlElement.classList.add(V.disabled),this.subscriptions.add((0,Y.fromEvent)(e,"animationiteration").pipe((0,Y.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(V.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${R.blinkAnimArea}`)||this.controlElement.classList.contains(R.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}};var J=require("@vkontakte/videoplayer-shared");var xt=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),i={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,i),t.append(e);let n={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,n),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var At=Math.PI,$r=2*At,wt=At/2,Mo=3*wt,Ap=0,wp=[Ap,wt,At,Mo];function Vo(r){return r===wt}function No(r){return r===At}function $o(r){return r===Mo}function _o(r){return(r%$r+$r)%$r}function Sp(r){for(let e of wp)if(r===e)return e}function jo(r){if(Sp(r))return null;let t=Math.floor(r/wt)+1;return[1,2,3,4][t-1]}function Bo(r){return r*180/Math.PI}var Z="interactive-control-fill-animation",$={common:Z,fillerWrapper:`${Z}-filler-wrapper`,filler:`${Z}-filler`,fillHeight:`${Z}-fill-height`,fillWidth:`${Z}-fill-width`,fromTop:`${Z}-from-top`,fromBottom:`${Z}-from-bottom`,fromLeft:`${Z}-from-left`,fromRight:`${Z}-from-right`};var St=class r{constructor(e){this.widthExpansionCoef=0;let t=document.createElement("div");t.classList.add($.common);let i=document.createElement("div");i.classList.add($.fillerWrapper);let n=document.createElement("div");n.classList.add($.filler),i.append(n),t.append(i);let o=_o(e.rotateAngle),s=jo(o),a=s!==null,c=s===2||!a&&No(o)||s===3,d=!a&&Vo(o),m=!a&&$o(o),b=!c&&!d&&!m,v=d||m,k=a&&!v,I=k?o:0;t.style.borderRadius=e.borderRadius,i.style.transform=`skew(${I*-1}rad)`,v?(n.classList.add($.fillHeight,d?$.fromTop:$.fromBottom),i.classList.add($.fillHeight,d?$.fromTop:$.fromBottom)):(n.classList.add($.fillWidth,b?$.fromLeft:$.fromRight),i.classList.add($.fillWidth)),e.debug&&console.log(`[interactive ${r.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:v,rotateAngleRad:o,rotateAngelDeg:Bo(o),rotateAngleRaw:e.rotateAngle,fromRight:c,fromTop:d,fromBottom:m,fromLeft:b}),this.useSkew=k,this.fromLeft=b,this.rotateAngle=o,this.fillAnimationElement=t,this.fillAnimationFillerElement=n,this.fillAnimationFillerWrapperElement=i,this.startTime=e.startTime,this.endTime=e.endTime,this.shouldFillHeight=v,this.isDebug=e.debug??!1}updateDimension(e){this.fillAnimationElement.style.top=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.left=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.width=`${e.width}px`,this.fillAnimationElement.style.height=`${e.height}px`;let t=this.calcWidthExpansionCoef({rotateAngle:this.rotateAngle,isSkewed:this.useSkew,initWidth:e.width,initHeight:e.height});!this.shouldFillHeight&&(this.fillAnimationFillerWrapperElement.style.width=100*t+100+"%",this.fillAnimationFillerWrapperElement.style[`${this.fromLeft?"left":"right"}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((o=>o<this.startTime||o>this.endTime)(e))return;let i=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/i,0),1);this.shouldFillHeight?this.fillAnimationFillerElement.style.transform=`scaleY(${n})`:this.fillAnimationFillerElement.style.transform=`scaleX(${n})`}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:i,initHeight:n}){return t?(i+n*Math.abs(Math.tan(e)))/i-1:0}};var Rt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new _r(r,e)},_r=class extends re{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(R.common,R.button),i.setAttribute("data-testid",ae.BUTTON),me({target:i,layoutParams:this.control.layoutParams,fallback:O}),lt({target:i,props:this.control.props,fallback:O}),Se({target:i,props:this.control.props,fallback:O,dependsOn:this.container.dimensions}),at({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=xt(this.control.type.trim().toLowerCase()),o=n.firstElementChild??n;st({target:o,props:this.control.props,fallback:O,dependsOn:this.container.dimensions}),this.addControlTap(i),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled("controlsFillAnimation")&&(this.controlFillAnimation=new St({startTime:this.startTime,endTime:this.endTime,rotateAngle:this.control.layoutParams.angle??O.angle,borderRadius:i.style.borderRadius})),this.subscriptions.add((0,J.fromEvent)(i,"click").pipe((0,J.once)()).subscribe(this.onControlSelect,s=>this.onError("Control click handler error",s))),i.append(n,this.controlFillAnimation?.fillAnimationElement??""),this.container.element.append(this.controlTap?.element??"",i),e.append(this.container.element),this.controlElement=i,this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,J.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(N.disabled))return;let t=e.parentElement;if(t){let i=t.querySelector(`.${V.common}`);i&&this.syncBlinkAnimation(i)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,J.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(N.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,J.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(R.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(R.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(R.blinkAnim,e),this.controlElement?.classList.toggle(R.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${R.blinkAnimButton}`)||this.controlElement.classList.contains(R.selected)||this.controlElement.classList.contains(V.disabled)||(this.controlElement.classList.add(V.disabled),this.subscriptions.add((0,J.fromEvent)(e,"animationiteration").pipe((0,J.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(V.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${R.blinkAnimButton}`)||this.controlElement.classList.contains(R.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}updateFillAnimationDimensions(){if(!this.container||!this.controlElement||!this.controlFillAnimation)return;let e=getComputedStyle(this.controlElement),t={width:parseFloat(e.width),height:parseFloat(e.height),borderWidth:parseFloat(e.borderWidth)||0};this.controlFillAnimation.updateDimension(t)}setShowTimeRange(e,t){this.startTime=e,this.endTime=t}onProgress(e){this.controlFillAnimation?.updateAnimation(e)}onResize(){this.updateFillAnimationDimensions()}updateShadowStyles(){}};var qo=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new jr(r,e)},jr=class extends re{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("div");i.classList.add(R.common,R.text),i.setAttribute("data-testid",ae.TEXT),me({target:i,layoutParams:this.control.layoutParams,fallback:O}),at({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=xt(this.control.type.trim().toLowerCase()),o=n.firstElementChild??n;st({target:o,props:this.control.props,fallback:O,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}setShowTimeRange(){}updateFillAnimationDimensions(){}};var kt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new Br(r,e,t)},Br=class r extends de{constructor(t,i,n){super(t,n);this.containerElement=null;this.subscriptions=new qe.Subscription;this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&this.removeView()};this.rootElement=i,this.layout=new tt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Rt),this.addControlFactory("text",qo),this.addControlFactory("area",It)}createView({eventCallback:t,videoDurationMs:i}){let n=document.createElement("div");return n.classList.add(N.common,N.disabled),requestAnimationFrame(()=>{n.classList.remove(N.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(o=>{o.setShowTimeRange(this.container.startTime,this.container.endTime??i),o.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout,isContainerDisabled:()=>this.isDisabled}}),o.setEvents(t),this.subscriptions.add(o.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.willRemoved=!1,this.containerElement=n,this.updateControlsFillAnimationDimensions(),n}updateControlsFillAnimationDimensions(){for(let t of this.controls)t.updateFillAnimationDimensions()}hide(){let t=this.getElement();t&&t.classList.add(N.hidden)}show(){let t=this.getElement();t&&t.classList.remove(N.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(N.disabled),this.controls.forEach(i=>i.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(N.disabled),this.controls.forEach(i=>i.disable()),this.isDisabled=!0)}removeView(t=!1,i=!1){let n=this.getElement();if(n){if(t){if(this.willRemoved)return;this.willRemoved=!0,i&&n.classList.add("interactive-container-before-remove-delay"),n.classList.add("interactive-container-before-remove"),this.subscriptions.add((0,qe.fromEvent)(n,"transitionend").subscribe(this.onTransitionEnd,s=>this.onError(`${r.name} remove view transition error`,s))).add((0,qe.fromEvent)(n,"transitioncancel").subscribe(this.onTransitionEnd,s=>this.onError(`${r.name} remove view transition error`,s)));return}this.subscriptions.unsubscribe(),this.removeAllControls(),n.remove(),this.isRemoved=!0,this.willRemoved=!1,this.containerElement=null}}removeAllControls(t=!1){this.controls.forEach(i=>i.removeView(t))}removeNonInteractedControls(t=!1){this.controls.forEach(i=>{i.isInteracted||i.removeView(t)})}isInteracted(){return this.controls.some(t=>t.isInteracted)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,i){i&&this.controls.forEach(n=>{n.onProgress(t)})}onResize(t){t&&this.controls.forEach(i=>{i.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(i=>i.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(i=>i.toggleBlinkAnimation(t))}};var _s=W(qr(),1),C=require("@vkontakte/videoplayer-shared"),xe=require("@vkontakte/videoplayer-statistics");var Yo=require("@vkontakte/videoplayer-shared");function De(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var Ko="video_interactive",Qo="videoint";var Xo=250,He=class{constructor(e){this.handleZoomChange=De(e=>{this.lastZoomInfo=e},Xo);this.onResize=e=>{if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&this.ngEditor?.zoomTo(t,void 0,{isFromCenter:!0}),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?.("Chapter 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,t=[])=>{if(this.isReady=!1,!ot(e.graph.edit.chapters[0].x)){this.onError?.("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:i,lang:n,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,this.onError=i,this.lang=n??"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Np(e),this.resizeObserver=new ResizeObserver(De(this.onResize,Xo)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor?.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor?.updateVideosInfo(e)}async show(){this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&this.ngEditor?.focusChapter(this.currentChapterId),this.isHidden=!1)}async initNgEditor(){if(!this.manifest)return;let e;try{e=await(0,Yo.loadVKLangPack)(this.lang,Ko,Qo)}catch{this.onError?.("Unable to load graph language pack")}let{GraphEditor:t}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name: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 Np(r){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",r.append(e),e}var Ue=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,i=!1,n=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let s=o.startTime-e;if(s<=n&&(o.endTime&&n<=o.endTime||o.endTime===null)){i=!0;break}n<s&&(t=t===-1?s:Math.min(t,s))}return!i&&t!==-1?t:null}}};var Ot=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let i=()=>{t(),this.off(e,i)};return this.listeners[e].push(i),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let i=this.listeners[e]||[];for(let n=i.length;n>0;n--)if(i[n]===t){i.splice(n,1);break}return this}emit(e,...t){let i=this.listeners[e];return i?(i.forEach(n=>{n(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var Pt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{hi(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var ea=require("@vkontakte/videoplayer-shared");var Lt=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,t){return $p(...this.loaders[e])(t)}};function $p(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function Ge(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function Ft({actions:r,errors:e,chapterId:t,...i}){if(t){let n=r.getManifest();if(n){let o=r.getChapter(n.chapters,t);if(o){let s=r.getMedia(n.media,o.videoId),a=r.getGraph(n.graph,o.id);return s?{...i,actions:r,errors:e,result:{chapter:o,media:s,graph:a}}:{...i,errors:Ge(e,Ft.name,"Could not find media"),actions:r}}}}return{...i,errors:Ge(e,Ft.name,"Could not find chapter"),actions:r}}var Mt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let n=0,o=i.length;n<o;n++)if(i[n].callback===t){i.splice(n,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let i=this.listeners[e.type].slice();for(let n=0,o=i.length;n<o;n++){let s=i[n];try{s.callback.call(this,e)}catch(a){Promise.resolve().then(()=>{throw a})}s.options&&s.options.once&&this.removeEventListener(e.type,s.callback)}return!e.defaultPrevented}},Ee=class extends Mt{constructor(){super(),this.listeners||Mt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},ze=class{constructor(){Object.defineProperty(this,"signal",{value:new Ee,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch{typeof document<"u"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={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(t)}toString(){return"[object AbortController]"}};typeof Symbol<"u"&&Symbol.toStringTag&&(ze.prototype[Symbol.toStringTag]="AbortController",Ee.prototype[Symbol.toStringTag]="AbortSignal");function Vt(r){return r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof r.Request=="function"&&!r.Request.prototype.hasOwnProperty("signal")||!r.AbortController}function Dr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Vt({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||n)&&(o=function(c,d){let m;d&&d.signal&&(m=d.signal,delete d.signal);let b=new t(c,d);return m&&Object.defineProperty(b,"signal",{writable:!1,enumerable:!1,configurable:!0,value:m}),b},o.prototype=t.prototype);let s=e;return{fetch:(l,c)=>{let d=o&&o.prototype.isPrototypeOf(l)?l.signal:c?c.signal:void 0;if(d){let m;try{m=new DOMException("Aborted","AbortError")}catch{m=new Error("Aborted"),m.name="AbortError"}if(d.aborted)return Promise.reject(m);let b=new Promise((v,k)=>{d.addEventListener("abort",()=>k(m),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([b,s(l,c)])}return s(l,c)},Request:o}}var _p=()=>"fetch"in window,We=_p()&&Vt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Zo=We?Dr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Hr=We?Zo.fetch:window.fetch,Vf=We?Zo.Request:window.Request,Nf=We?ze:window.AbortController,$f=We?Ee:window.AbortSignal;var Nt=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let o=0;o<Math.max(t.length,i.length)&&!n;o++)t[o]>i[o]?n=1:t[o]<i[o]?n=-1:n=0;return n};var jp=async r=>{try{let e={},t;if(it(r)){t=new URL(r).href;let n=await Hr(t);if(!n.ok)return{};e=await n.json()}else if(te(r))e=r;else return{};if(!Pr(e))return{};let i=e.metadata.media;if(it(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=await Hr(n);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch{return Dp(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch{return{}}};async function Jo(r){let{manifest:e,manifestURL:t}=await jp(r);if(!e)throw new Error("Failed on fetch");let i=(0,y.migrateManifestToLatestVersion)(e);return i.media=Bp(i.media,t),delete i.metadata.media,i}function $t(r,e){if(e)return r.find(t=>t.id===e)}function Ur(r,e){return r.edit?.chapters?r.edit.chapters.find(t=>t.id===e):r.view?.chapters?r.view.chapters.find(t=>t.id===e):void 0}function Gr(r,e){return r.videos.find(t=>t.id===e)}function Bp(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=qp(n,e);return{...i,url:o||n}})}))}}function qp(r="",e){try{return new URL(r,e).href}catch{return""}}function Dp(r){return Nt(r,"3.2.0")>=0}var pe=class extends Lt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new ea.ValueSubject(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){this.release();let i=await this.exec("manifestLoaders",{actions:{addErrorMessage:Ge},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await Jo(i.result??t),this}async setInitial(){return this.setNext()}async setNext(t=this.manifest?.metadata.initChapterId){if(!t)return this;this.prevChapter$.next(this.chapter);let i=await this.exec("chapterLoaders",Ft({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Ur,getChapter:$t,getMedia:Gr,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ge},result:null,errors:null,chapterId:t}));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(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){return this.getByChapterId(this.manifest?.metadata.initChapterId)||null}getByChapterId(t=this.manifest?.metadata.initChapterId){if(!t||!this.manifest)return null;let i=$t(this.manifest.chapters,t);if(i){let n=Gr(this.manifest.media,i.videoId),o=Ur(this.manifest.graph,i.id);if(n)return{chapter:i,media:n,graph:o}}return null}getBranches(t=this.chapter?.id){if(t===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let i=$t(this.manifest?.chapters||[],t);return this.getByBranches(i?.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let o=this.getByChapterId(n.chapterId);return o&&i.push(o),i},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter?.id===this.manifest?.metadata.initChapterId}isEndChapter(){return this.chapter?G(this.chapter):!1}};var La=W(_t(),1),Fa=require("@vkontakte/videoplayer-core"),ie=require("@vkontakte/videoplayer-shared");var Oa=r=>{let e=r.variants.find(t=>t.payload?.type==="vk");if(e&&e.payload){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var Pa=W(_t(),1);function Kr(){let r=new Map;function e({listId:o=Math.random().toString(),itemId:s=Math.random().toString(),...a}){let l=r.get(o),c={...a};return l?l[s]=c:r.set(o,{[s]:c}),{listId:o,itemId:s,...a}}function t(o){o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),o.statistics?.oneStat.destroy(),o.statistics?.statSubscription.unsubscribe()}function i(o,s){let a=r.get(o);if(!a)throw Error("Can't remove. Not find.");if(s){let l=a[s];l&&t(l),delete a[s],Object.keys(a).length||r.delete(o)}else{for(let l of(0,Pa.default)(a))t(l);r.delete(o)}}function n(){for(let o of r)i(o[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var Te=W(gt(),1);function Qr(r,e=[]){let t={},i,n=!e.length;for(let o of r.variants)if(!i&&"cover"in o&&(i=o.cover),"url"in o)switch(o.type.toLowerCase()){case"mp4":(n||(0,Te.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"mpeg":(n||(0,Te.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"hls":(n||(0,Te.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:o.url}});break;case"dash":(n||(0,Te.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:o.url}});break;default:break}return{sources:t,thumbUrl:i,title:r.title??""}}var Ke=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,Te.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var vu=2;function Xr(r){let e=Kr(),t=new ie.Subscription,i={},n=null,o=!1,s,a=new ie.ValueSubject(null);r&&l(r);function l(g){n=g}function c(g,u,h){if(!n)throw Error("need to set interactive controller");if(!n.options)return;let E=(e.map.get(g)??{})[u];if(E){i={chapterId:h,listId:g,itemId:u,...E};let T=i.player;i.subscription.add(T.info.currentQuality$.subscribe(x=>{let S=T.info.position$.getValue(),_=T.info.isAutoQualityEnabled$.getValue();if(!(!x||!S||_))for(let A of e.map)(0,La.default)(A[1]).forEach(({player:L})=>{Ke(L,x)})})).add(T.events.started$.subscribe(()=>{d(u)})),E.container.remove(),n.setPlayer(E.player),o||(n.init(),o=!0),a.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}async function d(g){if(!n)throw Error("need to set interactive controller");if(oe(i)||g!==i.itemId)return;let u=n.getChapterBranches(),h=new Set;for(let f of u)h.has(f.media.id)||(await b({media:f.media,chapterId:f.chapter.id,setAsActive:!1,title:f.chapter.label}),h.add(f.media.id))}async function m({chapter:{id:g},manifestVideo:u}){if(oe(i)||!n)return;let h=i.player.info.muted$.getValue(),f=i.player.info.currentQuality$.getValue(),E=i.player.info.isAutoQualityEnabled$.getValue(),T=i.player.info.volume$.getValue(),x=i.player.info.currentPlaybackRate$.getValue(),S=!E,_=!1;for(let A of e.map)if(A[0]===u.id&&!n.state.isReplay$.getValue()){let L=Object.keys(A[1]);for(let M of L)M===i.itemId?(L.length<vu||(_=!0),e.removePlayer(A[0],M)):(_=!0,c(A[0],M,g),S?Ke(i.player,f):i.player.setAutoQuality(!0),i.player.setVolume(T),i.player.setMuted(h),i.player.setPlaybackRate(x))}else e.removePlayer(A[0]);_||(await b({media:u,chapterId:g,setAsActive:!0,playbackRate:x}),S?Ke(i.player,f):i.player.setAutoQuality(!0),i.player.setVolume(T),i.player.setMuted(h))}async function b({media:g,chapterId:u,prefetch:h=!0,setAsActive:f=!0,autoplay:E=!1,preferredExt:T,title:x,playbackRate:S}){let _=Math.random().toString(),A=document.createElement("div");s.append(A);let L;if(n?.options?.vkVideoLoader){let Je=Oa(g);Je.length&&(L=await n.options.vkVideoLoader(...Je))}let M=n?.options?.coreConfig||void 0,z={...M,configName:[...M?.configName??[],"interactive"]},ne={container:A,...L?.videos?.[0]||{sources:Qr(g,T).sources},title:x,failoverHosts:L?.failoverHosts||[]},j=new Fa.Player(z,ie.TracerFactory.createRootTracer());j.initVideo(ne);let ue=null;if(L?.videos&&n?.options.createOneStat){let Je=L.videos[0],Gt=n.options.createOneStat(Je),si=new ie.Subscription;Gt&&(si.add(Gt.attachTo(j)),ue={oneStat:Gt,statSubscription:si})}let ai=new ie.Subscription,qs=i?.player?.info.isAutoQualityEnabled$.getValue();ai.add(j.events.canplay$.subscribe(function(){qs||Ke(j,i.player.info.currentQuality$.getValue()),S&&j.setPlaybackRate(S)}));let he=e.createPlayer({listId:g.id,itemId:_,player:j,container:A,sources:Qr(g,T).sources,config:ne,subscription:ai,statistics:ue});return f&&c(g.id,he.itemId,u),E&&he.player.play(),h&&!E&&he.player.prepare(),{player:he.player,config:he.config,statistics:he.statistics}}function v(){k(),n=null,s.remove()}function k(){t.unsubscribe(),e.removeAll(),i={},o=!1}async function I(){if(!n)throw Error("need to set interactive controller");k(),s=document.createElement("div");let{media:g,chapter:u}=n.getCurrentChapter();g&&u?(t.add(n.events.chapterChanged$.subscribe(m)),await b({media:g,chapterId:u.id,title:u.label})):console.error("not found")}return{...e,init:I,setInteractiveController:l,createPlayer:b,removeAll:v,getActivePlayer:function(){return i},activePlayerChanged:a}}var w={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Ie={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},P={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Va=require("@vkontakte/videoplayer-shared");function Yr(r){return function(...t){return r(...t.reverse())}}function Qe(r,...e){return(...t)=>te(e[0])&&te(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var jt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:s,globalEventEmitter:a,getContainerEventState:l,permanentTextControls:c,interactiveTimeOpenUri:d,disabledControls$:m,onRemove:b,onError:v,disableTextControlContainerVisibilityEvents:k=!1,features:I}){this.hide=()=>{setTimeout(()=>{this.gameState!==4&&(le(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()){let{hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState();if(this.container.show?.(),this.interactiveTimeOpenUri&&t||this.disableTextControlContainerVisibilityEvents)return;this.emitContainerVisibilityEvent(!0,!1)}else{let t={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(o,s)=>{let{isExpectTime:a,hasOtherExpect:l,hasOpenURIEvent:c,hasOpenURIEventInCurrentContainer:d,isAllOpenURIEventsValid:m,hasShouldOpenNowEvent:b}=this.getContainerEventState(),v=this.interactiveTimeOpenUri&&!d,k=this.interactiveTimeOpenUri&&d;if((!this.interactiveTimeOpenUri||v)&&(this.isSelectedControlEvent=!0),o!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||v)){if(this.interactiveTimeOpenUri){let I=!l&&!m&&d;I&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:I})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&c&&this.gameState!==5){if(k){let g=((u,h,f,E)=>!u&&!h&&f||u&&!h&&f&&!E||u&&!h&&f&&E)(a,l,m,this.isSelectedContainerEvent);this.fakeRemoveView(g)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!a||!l||!b)&&(this.selectBranches.stopExpect(),s())}},isEOV:()=>this.gameState===4},i=Qe(this.selectBranches.onControlEvent,t),n=(this.player?.info.duration$.getValue()??1/0)*1e3;this.container.createView({eventCallback:i,videoDurationMs:n}),this.disableTextControlContainerVisibilityEvents||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();if(!(e instanceof HTMLVideoElement?e.readyState:void 0)||this.isRemovedOrDestroyed()&&!this.isPermanentText)return;let n=this.player.getExactTime();if(Oo(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Lr(n,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let l=this.gameState;this.gameState=3,l===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:l}=this.getContainerEventState(),c=this.selectBranches.state.isExpect,d=this.interactiveTimeOpenUri&&l;if(d&&!c){let m=this.container.getElement();m&&(m.style.visibility!=="hidden"&&this.container.hide?.(),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!d&&this.removeView()}let o=Lr(n,this.container.container),s=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:s,currentTime:n,isInteractiveTime:o};this.container.onProgress(n*1e3,o),this.globalEventEmitter.emit(w.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Va.Subscription,this.player=e,this.interactiveEvents=o,this.getContainerEventState=l;let g=ce(t.container.controls);this.isPermanentText=c&&g,this.disableTextControlContainerVisibilityEvents=k&&g,this.interactiveTimeOpenUri=d,this.disabledControls$=m,this.onRemove=b,this.globalEventEmitter=a,this.gameState=0,this.globalEvents=s,this.onError=v,this.features=I,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.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?.()})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();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,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime??1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),i=this.interactiveTimeOpenUri?e||t:le(this.container.container.events)||e;(this.isSelectedControlEvent||!i)&&this.removeView()}onBeforeStartTime(){this.container.hide?.(),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(e=this.features.controlsHideAnimation){if(e){if(this.isRemovedOrDestroyed())return;this.container.removeNonInteractedControls(!0),this.container.removeView(!0,!0)}else this.container.removeView();this.globalEventEmitter.emit(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,this.onRemove?.()}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}isInteracted(){return this.container.isInteracted()}isRemovedOrDestroyed(e=!0){let t=e?this.container.willRemoved:!1;return this.gameState===5||t||this.gameState===6}destroy(e=!1){this.reset(),this.removeView(e),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 Na=(r=[])=>r.reduce((e,t,i)=>{let n=(t?.controls??[]).filter(o=>!je(o));if(Ct(n)){let o=[t.startTime??0,t.endTime??1/0],s={id:t.id,isRemoved:!1};if(!i)e.push({subjects:[s],range:o});else{let a=[],l=-1/0,c=1/0,d=[],m=[];for(let b=0;b<e.length;b++){let v=e[b];if(m.push(...v.subjects),v.range[0]<c&&(c=v.range[0]),v.range[1]>l&&(l=v.range[1]),o[0]>=v.range[0]&&o[1]<=v.range[1])return e[b].subjects.push(s),e;o[0]<v.range[0]&&o[1]>v.range[0]&&(a.push(b),d=d.concat(v.subjects)),o[0]>=v.range[0]&&o[0]<=v.range[1]&&(a.push(b),d=d.concat(v.subjects),o[0]=v.range[0]),o[1]>=v.range[0]&&o[1]<=v.range[1]&&(a.push(b),d=d.concat(v.subjects),o[1]=v.range[1])}if(m.push(s),o[0]<=c&&o[1]>=l)return[{subjects:m,range:o}];a.length&&a.reverse().forEach(b=>{e.splice(b,1)}),e.push({subjects:d.concat([s]),range:o})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var bs=W(gt(),1),ti=W(_t(),1),ys=W(fs(),1);function vs(){let r={};function e(){for(let a in r)Object.prototype.hasOwnProperty.call(r,a)&&delete r[a]}function t(a){let l={};for(let c in r)+c<=a&&(l[c]=r[c]);return l}function i(a){let l={};for(let c in r)+c>=a&&(l[c]=r[c]);return l}function n({timestamp:a,priority:l,initiator:c}){if(Qt(a)){let d=r[a]??null;if(d&&l&&Ae(l,!0)){let m={},b=d[l];return b&&(m={...m,...b}),m=oe(m)?null:m,m&&Ae(c,!0)?m[c]??null:m}return d}return null}function o({timestamp:a,priority:l,initiator:c}){if(Qt(a))if(r[a]){if(l&&Ae(l,!0))if(r[a][l]){if(c&&Ae(c,!0))if(r[a][l][c]){if(delete r[a][l][c],!oe(r[a][l]))return!0}else return!1;if(delete r[a][l],!oe(r[a]))return!0}else return!1;return delete r[a]}else return!1;return!1}function s({timestamp:a,priority:l,initiator:c,...d}){r[a]?.[l]?.[c]?r[a][l][c].push({...d}):r[a]?.[l]?r[a][l]={...r[a][l],[c]:[{...d}]}:r[a]?r[a]={...r[a],[l]:{[c]:[{...d}]}}:r[a]={[l]:{[c]:[{...d}]}}}return{map:r,remove:o,add:s,removeAll:e,get:n,getLte:t,getGte:i}}var nh=[y.EventActionTypes.expect,y.EventActionTypes.setNextBranch],oh=1/0;function gs(r,e){let t=r,i,n=ah(e),o=vs(),s,a=()=>{v(),u()},l=h=>{o.add.call(void 0,h),k()},c=(h=[])=>{for(let f of h)if(f.action(),(0,bs.default)(nh,f.actionType))break},d=(h=1/0)=>{let f=qt(o.get({timestamp:h,priority:"control"})??{}),E=qt(o.get({timestamp:h,priority:"container"})??{}),T=qt(o.get({timestamp:h,priority:"chapter"})??{});return[...f,...E,...T]},m=h=>{n.isReady(h)&&c(d(h))},b=()=>{c([...qt(o.get({timestamp:1/0,priority:"chapter"})??{})])},v=()=>{i&&(s?.unsubscribe(),i=void 0)},k=()=>{i||(i=()=>setTimeout(()=>{m(1/0)}),s=t.events.ended$.subscribe(i))},I=h=>{v(),t=h},g=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),o.remove(h)},u=()=>{n.release(),o.removeAll()};return{setPlayer:I,add:l,remove:g,exec:m,execEndOfVideo:b,listen:k,unlisten:v,release:a,containersEventsCallState:n,getPreparedToExecActions:d}}function ah(r){let e=new Map;return{setCalled:({timestamp:a,id:l})=>{let c=e.get(a);c&&c[l]!==void 0&&(c[l]=!0)},setData:(a=[])=>{for(let l of a){let c=l.endTime??oh,d=e.get(c);e.set(c,{...d,[l.id]:!1})}},resetCalled:a=>{let l=e.get(a);if(l)for(let c in l)l[c]=!1},isReady:a=>{let l=e.get(a);if(!l)return!0;let c=(0,ti.default)(l);return r?c.some(m=>m):!c.some(m=>!m)},release:()=>e.clear()}}function qt(r){return(0,ys.default)((0,ti.default)(r)).sort(e=>e.actionType===y.EventActionTypes.expect?-1:1)}var Cs={videoContentHeight:0,videoContentWidth:0},Es=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Cs;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return Cs;let o=e/t,s=i/n,a,l;return s>o?(l=n,a=n*o):s<o?(l=i/o,a=i):(l=n,a=i),{videoContentWidth:l,videoContentHeight:a}};var sh=250;function Ts(r){let e,t=new ResizeObserver(a=>{o(a),e=o.bind(null,a)});function i(a){let{parentElement:l,player:c}=r();if(l&&c){let{videoContentWidth:d,videoContentHeight:m}=Es(c);l.style.setProperty("--interactive-content-width",`${d}px`),l.style.setProperty("--interactive-content-height",`${m}px`),l.style.setProperty("--interactive-width",`${a[0].contentRect.width}px`),l.style.setProperty("--interactive-height",`${a[0].contentRect.height}px`)}}function n(){let{parentElement:a}=r();a.removeAttribute("style")}let o=De(a=>{let{fns:l=[]}=r();i(a);for(let c of l)c()},sh);function s(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e?.()},release:s}}var lh=r=>Math.floor(Math.random()*r),xs=r=>{let e=r.length,t=1/0,i=null;for(;e--;){let n=r[e],o=n.weight??1;o<t&&(t=o,i=n)}return i},As=r=>{let e=r.length,t=-1/0,i=null;for(;e--;){let n=r[e],o=n.weight??0;o>t&&(t=o,i=n)}return i};var ws=r=>{let e=r.length,t=lh(e);return r[t]},Is=1,Ss=r=>{let e=0;for(let i=0;i<r.length;++i)e+=r[i].weight??Is;let t=Math.random()*e;e=0;for(let i=0;i<r.length-1;++i)if(e+=r[i].weight??Is,e>=t)return r[i];return r[r.length-1]};var Rs={shouldOpenNow:!0,isDetachContainer:!0},ks="after-expect",ri=(r,e=!1)=>({...r,args:e?{...r.args,...Rs}:{...Rs,...r.args}}),Os=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},s=({action:u,controlType:h,controlId:f,containerId:E,branches:T=[],onEvent:x,isEOV:S=()=>!1,isDisabled:_=()=>!1})=>{let A=ri(u,S()),L={timestamp:1/0,priority:"control",initiator:f,actionType:A.type},M=_(),z=r.emit.bind(r,w.interactives,{subjectId:f,subjectType:h,subjectName:"control",type:M?P.actionChoiceCanceled:P.actionChoice,actionType:u.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:E,...A.args}}),ne=()=>{e.interactiveActionChoice$.next({subjectId:f,subjectType:h,subjectName:"control",type:M?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:E,...A.args}})};if(M){z(),ne();return}switch(A.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let j=T.find(ue=>ue.id===A.args.branchId);if(!j)return;x(A.args.isDetachContainer,v.bind(null,{subjectId:f,subjectName:"control"})),z(),ne(),A.args.shouldOpenNow?I({subjectId:f,subjectName:"control",subjectType:h,action:A,payload:{chapterId:j.chapterId,autoSelect:!1}}):i.add({...L,action:I.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:A,payload:{chapterId:j.chapterId,autoSelect:!1}})});return}case y.EventActionTypes.continuePlayback.trim().toLowerCase():{x(A.args.isDetachContainer,v.bind(null,{subjectId:f,subjectName:"control"})),z(),ne(),A.args.shouldOpenNow?k({subjectId:f,subjectName:"control",subjectType:h,action:u}):i.add({...L,action:k.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:u})});return}case y.EventActionTypes.openURI.trim().toLowerCase():{x(A.args.isDetachContainer,v.bind(null,{subjectId:f,subjectName:"control"})),z(),ne(),A.args.shouldOpenNow?g({subjectId:f,subjectName:"control",subjectType:h,action:A,payload:{URI:u.args.uri}}):i.add({...L,action:g.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:A,payload:{URI:u.args.uri}})});return}default:{let j="Unexpected control event",ue=new F(1,1,{message:j});d(ue,j);return}}},a=({action:u,container:{id:h,endTime:f},branches:E=[],isEOV:T=!1,autoSelected:x=!1})=>{let S=ri(u,T),_={timestamp:!S.args.shouldOpenNow||T?1/0:f??1/0,priority:"container",initiator:h,actionType:S.type},A=r.emit.bind(r,w.interactives,{subjectId:h,subjectName:"container",type:P.actionChoice,actionType:S.type,payload:{invokeImmediately:S.args.shouldOpenNow,...S.args}}),L=()=>{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 y.EventActionTypes.setNextBranch.trim().toLowerCase():{let M=E.find(z=>z.id===S.args.branchId);if(!M)return;A(),L(),i.add({..._,action:I.bind(null,{subjectId:h,subjectName:"container",action:S,payload:{chapterId:M.chapterId,autoSelect:x}})});return}case y.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case y.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case y.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case y.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case y.EventActionTypes.continuePlayback.trim().toLowerCase():{A(),L(),i.add({..._,action:k.bind(null,{subjectId:h,subjectName:"container",action:S})});return}case y.EventActionTypes.openURI.trim().toLowerCase():{A(),L(),i.add({..._,action:g.bind(null,{subjectId:h,subjectName:"container",action:S,payload:{URI:u.args.uri}})});return}default:{let M="Unexpected container event",z=new F(1,1,{message:M});d(z,M);return}}};function l({container:u,branches:h,isEOV:f=!1}){let E=Fr(u.events);if(E){let T=ri(E.action,f);r.emit(w.interactives,{subjectId:u.id,subjectName:"container",type:P.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),i.add({timestamp:f?1/0:u.endTime??1/0,priority:"container",initiator:u.id,actionType:y.EventActionTypes.expect,action:b.bind(null,{subjectId:u.id,subjectName:"container"})}),n.isExpect=!0}else for(let T of u.events??[])a({action:T.action,container:u,branches:h,isEOV:f})}let c=({chapterId:u,action:h,branches:f=[]})=>{let E=r.emit.bind(r,w.interactives,{subjectId:u,subjectName:"chapter",type:P.actionChoice,actionType:h.type,payload:h.args}),T=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let x=f.find(S=>S.id===h.args.branchId);return x?.chapterId?(E(),T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let x=ws(f);return x?.chapterId?(E(),T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setRandomBranch.trim().toLowerCase():{let x=Ss(f);return x?.chapterId?(E(),T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let x=As(f);return x?.chapterId?(E(),T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let x=xs(f);return x?.chapterId?(E(),T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.continuePlayback.trim().toLowerCase():return E(),T(),k.bind(null,{subjectId:u,subjectName:"chapter",action:h});case y.EventActionTypes.openURI.trim().toLowerCase():return E(),T(),g.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let x="Unexpected chapter event",S=new F(1,1,{message:x});d(S,x);return}}};function d(u,h){console.error(h),e.error$.next(u),r.emit(w.errors,u)}function m(u){let h=Fr(u.events);if(h){if(G(u))return;r.emit(w.interactives,{subjectId:u.id,subjectName:"chapter",type:P.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:y.EventActionTypes.expect,action:b.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else u.events?.forEach(f=>{let E=c({chapterId:u.id,action:f.action,branches:u.branches});E&&i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:f.action.type,action:E})})}let b=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(w.interactives,{subjectId:u,subjectName:h,type:P.actionExecution,actionType:y.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:y.EventActionTypes.expect})},v=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(w.interactives,{subjectId:u,subjectName:h,type:P.actionExecution,actionType:ks}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:ks})},k=({subjectId:u,subjectName:h,subjectType:f,action:E})=>{r.emit(w.interactives,{subjectId:u,subjectName:h,subjectType:f,type:P.actionExecution,actionType:E.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:E.type})},I=({subjectId:u,subjectName:h,subjectType:f,action:E,payload:T})=>{T.behaviour="change-chapter",r.emit(w.interactives,{subjectId:u,subjectName:h,subjectType:f,type:P.actionExecution,actionType:E.type,payload:T}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:E.type,payload:T})},g=({subjectId:u,subjectName:h,subjectType:f,action:E,payload:T})=>{if(!T.URI)return;let x=window.open(T.URI,"_blank","noopener,noreferrer");x&&(x.opener=null),r.emit(w.interactives,{subjectId:u,subjectName:h,subjectType:f,type:P.actionExecution,actionType:E.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:E.type})};return{onControlEvent:s,onContainerEvent:a,onChapterEvent:c,onExpectEvent:b,expectEventHandler:v,setManifestChapterEvents:m,setManifestContainerEvents:l,stopExpect:o,state:n}};var oi=W(qr(),1),D=require("@vkontakte/videoplayer-shared");var Dt=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(s=>s.id===i);if(!n)return null;let o=e.media.videos.find(s=>n.videoId===s.id);if(!o)return null;t[i]=ii(o)}return t[i]}).filter(Boolean)},Ps=r=>{for(let e of r.variants)if(Ls(e)&&e.payload)return e.payload.id},Ls=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),ii=r=>{let e=Ps(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Fs=(r,e)=>{for(let t of r.media.videos)if(e===ii(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},ni=(r,e)=>r.reduce((t,i)=>{let n=Fs(e,i);return n?[...t,n]:t},[]);var Ye=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new D.ValueSubject([]),hasPrevChapter$:new D.ValueSubject(!1),prevChapter$:new D.ValueSubject(null),isInitialChapter$:new D.ValueSubject(!1),isGoBackLimited$:new D.ValueSubject(!1)};this.#r=null;this.#a=!1;this.#e=null;this.#p=null;this.events={inited$:new D.Subject,destroyed$:new D.Subject,error$:new D.Subject};this.#i=null;this.#n=null;this.#t=null;this.#s=new D.Subscription;this.#l=!1;this.#c=0;this.#i=t,this.#t=e,this.#n=i,this.#r=n,this.#o=o,this.state.history$&&this.#s&&this.#s?.add(this.state.history$.subscribe(s=>{this.state.prevChapter$.next((0,oi.default)(s,-2)||null),this.state.hasPrevChapter$.next(s.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===this.#e?.metadata?.initChapterId),this.state.isGoBackLimited$.next(this.#c===this.#o.maxLength-1)}))}#r;#o;#a;#e;#p;#i;#n;#t;#s;#l;#c;async setManifest(e){if(!this.#n||!this.#t)return;this.#e=e,await this.getProjectHistory();let t=this.getInitialChapterId();await this.#n.setChapter({chapterId:t,pushToHistory:!1}),this.#a||(this.#a=!0,this.events.inited$.next({initChapterId:t}))}get inited(){return this.#a}async updateHistory(e,t=!0){if(!this.#e)return;this.#l?(this.#l=!1,this.#c++):this.#c=0;let i=this.#e,n=e.length-this.#o.maxLength,o=n>0?e.slice(n):e,s=Dt(o,i);if(this.#p=s,this.state.history$.next(o),!(!t||!this.#r||!this.#i))try{await this.#r.save(this.#i,s)}catch{let l=new F(1,5,"Unable to save interactive history");this.events.error$.next(l),this.#t?.emit(w.errors,l)}}async goBack(){if(!this.state||!this.#n){let i=new F(1,5,"Unable to save interactive history");return this.events.error$.next(i),this.#t?.emit(w.errors,i)}this.#l=!0;let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await this.#n.setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){if(!this.#e||!this.#i)return;let e=this.#e,t=[this.getInitialVideoId()];if(this.#r)try{let n=await this.#r.get(this.#i);n.length&&(t=n)}catch{let o=new F(1,5,"Error while trying to fetch data");this.events.error$.next(o),this.#t?.emit(w.errors,o)}let i=ni(t,e);this.state.history$.next(i)}getInitialChapterId(){let e=this.state.history$.getValue();return(0,oi.default)(e,-1)||this.#o.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return Dt([e],this.#e).pop()}return null}destroy(){this.#i=null,this.#r=null,this.#n=null,this.#s?.unsubscribe(),this.#s=null,this.#a=!1,this.#t?.emit(w.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var Ht=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 t=e.data,i=t.length;for(let n=3;n<i;n+=40)if(t[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,t=!1){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){this.rootElement&&this.rootElement.getContext("2d")?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}};var Ut=class{constructor({parentElement:e,endOffsetMs:t=250,onError:i}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,i=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(i)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
6
+ "use strict";var Ds=Object.create;var et=Object.defineProperty;var Hs=Object.getOwnPropertyDescriptor;var Us=Object.getOwnPropertyNames;var Gs=Object.getPrototypeOf,zs=Object.prototype.hasOwnProperty;var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ws=(r,e)=>{for(var t in e)et(r,t,{get:e[t],enumerable:!0})},li=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Us(e))!zs.call(r,n)&&n!==t&&et(r,n,{get:()=>e[n],enumerable:!(i=Hs(e,n))||i.enumerable});return r};var W=(r,e,t)=>(t=r!=null?Ds(Gs(r)):{},li(e||!r||!r.__esModule?et(t,"default",{value:r,enumerable:!0}):t,r)),Ks=r=>li(et({},"__esModule",{value:!0}),r);var Q=p((er,Ci)=>{"use strict";var Re=function(r){return r&&r.Math===Math&&r};Ci.exports=Re(typeof globalThis=="object"&&globalThis)||Re(typeof window=="object"&&window)||Re(typeof self=="object"&&self)||Re(typeof global=="object"&&global)||Re(typeof er=="object"&&er)||function(){return this}()||Function("return this")()});var B=p((Bh,Ei)=>{"use strict";Ei.exports=function(r){try{return!!r()}catch{return!0}}});var ke=p((qh,Ti)=>{"use strict";var Ys=B();Ti.exports=!Ys(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Si=p((Dh,wi)=>{"use strict";var Zs=ke(),Ai=Function.prototype,Ii=Ai.apply,xi=Ai.call;wi.exports=typeof Reflect=="object"&&Reflect.apply||(Zs?xi.bind(Ii):function(){return xi.apply(Ii,arguments)})});var H=p((Hh,Oi)=>{"use strict";var Ri=ke(),ki=Function.prototype,tr=ki.call,Js=Ri&&ki.bind.bind(tr,tr);Oi.exports=Ri?Js:function(r){return function(){return tr.apply(r,arguments)}}});var Oe=p((Uh,Li)=>{"use strict";var Pi=H(),el=Pi({}.toString),tl=Pi("".slice);Li.exports=function(r){return tl(el(r),8,-1)}});var rr=p((Gh,Fi)=>{"use strict";var rl=Oe(),il=H();Fi.exports=function(r){if(rl(r)==="Function")return il(r)}});var q=p((zh,Mi)=>{"use strict";var ir=typeof document=="object"&&document.all;Mi.exports=typeof ir>"u"&&ir!==void 0?function(r){return typeof r=="function"||r===ir}:function(r){return typeof r=="function"}});var se=p((Wh,Vi)=>{"use strict";var nl=B();Vi.exports=!nl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ut=p((Kh,Ni)=>{"use strict";var ol=ke(),pt=Function.prototype.call;Ni.exports=ol?pt.bind(pt):function(){return pt.apply(pt,arguments)}});var nr=p(ji=>{"use strict";var $i={}.propertyIsEnumerable,_i=Object.getOwnPropertyDescriptor,al=_i&&!$i.call({1:2},1);ji.f=al?function(e){var t=_i(this,e);return!!t&&t.enumerable}:$i});var or=p((Xh,Bi)=>{"use strict";Bi.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Di=p((Yh,qi)=>{"use strict";var sl=H(),ll=B(),cl=Oe(),ar=Object,pl=sl("".split);qi.exports=ll(function(){return!ar("z").propertyIsEnumerable(0)})?function(r){return cl(r)==="String"?pl(r,""):ar(r)}:ar});var sr=p((Zh,Hi)=>{"use strict";Hi.exports=function(r){return r==null}});var lr=p((Jh,Ui)=>{"use strict";var ul=sr(),hl=TypeError;Ui.exports=function(r){if(ul(r))throw new hl("Can't call method on "+r);return r}});var Pe=p((ed,Gi)=>{"use strict";var dl=Di(),ml=lr();Gi.exports=function(r){return dl(ml(r))}});var ve=p((td,zi)=>{"use strict";var fl=q();zi.exports=function(r){return typeof r=="object"?r!==null:fl(r)}});var ht=p((rd,Wi)=>{"use strict";Wi.exports={}});var dt=p((id,Qi)=>{"use strict";var cr=ht(),pr=Q(),vl=q(),Ki=function(r){return vl(r)?r:void 0};Qi.exports=function(r,e){return arguments.length<2?Ki(cr[r])||Ki(pr[r]):cr[r]&&cr[r][e]||pr[r]&&pr[r][e]}});var Yi=p((nd,Xi)=>{"use strict";var bl=H();Xi.exports=bl({}.isPrototypeOf)});var tn=p((od,en)=>{"use strict";var yl=Q(),Zi=yl.navigator,Ji=Zi&&Zi.userAgent;en.exports=Ji?String(Ji):""});var cn=p((ad,ln)=>{"use strict";var sn=Q(),ur=tn(),rn=sn.process,nn=sn.Deno,on=rn&&rn.versions||nn&&nn.version,an=on&&on.v8,U,mt;an&&(U=an.split("."),mt=U[0]>0&&U[0]<4?1:+(U[0]+U[1]));!mt&&ur&&(U=ur.match(/Edge\/(\d+)/),(!U||U[1]>=74)&&(U=ur.match(/Chrome\/(\d+)/),U&&(mt=+U[1])));ln.exports=mt});var hr=p((sd,un)=>{"use strict";var pn=cn(),gl=B(),Cl=Q(),El=Cl.String;un.exports=!!Object.getOwnPropertySymbols&&!gl(function(){var r=Symbol("symbol detection");return!El(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&pn&&pn<41})});var dr=p((ld,hn)=>{"use strict";var Tl=hr();hn.exports=Tl&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var mr=p((cd,dn)=>{"use strict";var Il=dt(),xl=q(),Al=Yi(),wl=dr(),Sl=Object;dn.exports=wl?function(r){return typeof r=="symbol"}:function(r){var e=Il("Symbol");return xl(e)&&Al(e.prototype,Sl(r))}});var fn=p((pd,mn)=>{"use strict";var Rl=String;mn.exports=function(r){try{return Rl(r)}catch{return"Object"}}});var fr=p((ud,vn)=>{"use strict";var kl=q(),Ol=fn(),Pl=TypeError;vn.exports=function(r){if(kl(r))return r;throw new Pl(Ol(r)+" is not a function")}});var yn=p((hd,bn)=>{"use strict";var Ll=fr(),Fl=sr();bn.exports=function(r,e){var t=r[e];return Fl(t)?void 0:Ll(t)}});var Cn=p((dd,gn)=>{"use strict";var vr=ut(),br=q(),yr=ve(),Ml=TypeError;gn.exports=function(r,e){var t,i;if(e==="string"&&br(t=r.toString)&&!yr(i=vr(t,r))||br(t=r.valueOf)&&!yr(i=vr(t,r))||e!=="string"&&br(t=r.toString)&&!yr(i=vr(t,r)))return i;throw new Ml("Can't convert object to primitive value")}});var Tn=p((md,En)=>{"use strict";En.exports=!0});var An=p((fd,xn)=>{"use strict";var In=Q(),Vl=Object.defineProperty;xn.exports=function(r,e){try{Vl(In,r,{value:e,configurable:!0,writable:!0})}catch{In[r]=e}return e}});var ft=p((vd,Rn)=>{"use strict";var Nl=Tn(),$l=Q(),_l=An(),wn="__core-js_shared__",Sn=Rn.exports=$l[wn]||_l(wn,{});(Sn.versions||(Sn.versions=[])).push({version:"3.38.0",mode:Nl?"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 gr=p((bd,On)=>{"use strict";var kn=ft();On.exports=function(r,e){return kn[r]||(kn[r]=e||{})}});var Le=p((yd,Pn)=>{"use strict";var jl=lr(),Bl=Object;Pn.exports=function(r){return Bl(jl(r))}});var be=p((gd,Ln)=>{"use strict";var ql=H(),Dl=Le(),Hl=ql({}.hasOwnProperty);Ln.exports=Object.hasOwn||function(e,t){return Hl(Dl(e),t)}});var Cr=p((Cd,Fn)=>{"use strict";var Ul=H(),Gl=0,zl=Math.random(),Wl=Ul(1 .toString);Fn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Wl(++Gl+zl,36)}});var Fe=p((Ed,Vn)=>{"use strict";var Kl=Q(),Ql=gr(),Mn=be(),Xl=Cr(),Yl=hr(),Zl=dr(),ye=Kl.Symbol,Er=Ql("wks"),Jl=Zl?ye.for||ye:ye&&ye.withoutSetter||Xl;Vn.exports=function(r){return Mn(Er,r)||(Er[r]=Yl&&Mn(ye,r)?ye[r]:Jl("Symbol."+r)),Er[r]}});var jn=p((Td,_n)=>{"use strict";var ec=ut(),Nn=ve(),$n=mr(),tc=yn(),rc=Cn(),ic=Fe(),nc=TypeError,oc=ic("toPrimitive");_n.exports=function(r,e){if(!Nn(r)||$n(r))return r;var t=tc(r,oc),i;if(t){if(e===void 0&&(e="default"),i=ec(t,r,e),!Nn(i)||$n(i))return i;throw new nc("Can't convert object to primitive value")}return e===void 0&&(e="number"),rc(r,e)}});var Tr=p((Id,Bn)=>{"use strict";var ac=jn(),sc=mr();Bn.exports=function(r){var e=ac(r,"string");return sc(e)?e:e+""}});var Hn=p((xd,Dn)=>{"use strict";var lc=Q(),qn=ve(),Ir=lc.document,cc=qn(Ir)&&qn(Ir.createElement);Dn.exports=function(r){return cc?Ir.createElement(r):{}}});var xr=p((Ad,Un)=>{"use strict";var pc=se(),uc=B(),hc=Hn();Un.exports=!pc&&!uc(function(){return Object.defineProperty(hc("div"),"a",{get:function(){return 7}}).a!==7})});var Wn=p(zn=>{"use strict";var dc=se(),mc=ut(),fc=nr(),vc=or(),bc=Pe(),yc=Tr(),gc=be(),Cc=xr(),Gn=Object.getOwnPropertyDescriptor;zn.f=dc?Gn:function(e,t){if(e=bc(e),t=yc(t),Cc)try{return Gn(e,t)}catch{}if(gc(e,t))return vc(!mc(fc.f,e,t),e[t])}});var Qn=p((Sd,Kn)=>{"use strict";var Ec=B(),Tc=q(),Ic=/#|\.prototype\./,Me=function(r,e){var t=Ac[xc(r)];return t===Sc?!0:t===wc?!1:Tc(e)?Ec(e):!!e},xc=Me.normalize=function(r){return String(r).replace(Ic,".").toLowerCase()},Ac=Me.data={},wc=Me.NATIVE="N",Sc=Me.POLYFILL="P";Kn.exports=Me});var Ar=p((Rd,Yn)=>{"use strict";var Xn=rr(),Rc=fr(),kc=ke(),Oc=Xn(Xn.bind);Yn.exports=function(r,e){return Rc(r),e===void 0?r:kc?Oc(r,e):function(){return r.apply(e,arguments)}}});var Jn=p((kd,Zn)=>{"use strict";var Pc=se(),Lc=B();Zn.exports=Pc&&Lc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var to=p((Od,eo)=>{"use strict";var Fc=ve(),Mc=String,Vc=TypeError;eo.exports=function(r){if(Fc(r))return r;throw new Vc(Mc(r)+" is not an object")}});var no=p(io=>{"use strict";var Nc=se(),$c=xr(),_c=Jn(),vt=to(),ro=Tr(),jc=TypeError,wr=Object.defineProperty,Bc=Object.getOwnPropertyDescriptor,Sr="enumerable",Rr="configurable",kr="writable";io.f=Nc?_c?function(e,t,i){if(vt(e),t=ro(t),vt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&kr in i&&!i[kr]){var n=Bc(e,t);n&&n[kr]&&(e[t]=i.value,i={configurable:Rr in i?i[Rr]:n[Rr],enumerable:Sr in i?i[Sr]:n[Sr],writable:!1})}return wr(e,t,i)}:wr:function(e,t,i){if(vt(e),t=ro(t),vt(i),$c)try{return wr(e,t,i)}catch{}if("get"in i||"set"in i)throw new jc("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var ao=p((Ld,oo)=>{"use strict";var qc=se(),Dc=no(),Hc=or();oo.exports=qc?function(r,e,t){return Dc.f(r,e,Hc(1,t))}:function(r,e,t){return r[e]=t,r}});var Ne=p((Fd,lo)=>{"use strict";var Ve=Q(),Uc=Si(),Gc=rr(),zc=q(),Wc=Wn().f,Kc=Qn(),ge=ht(),Qc=Ar(),Ce=ao(),so=be();ft();var Xc=function(r){var e=function(t,i,n){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,i)}return new r(t,i,n)}return Uc(r,this,arguments)};return e.prototype=r.prototype,e};lo.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,s=i?Ve:n?Ve[t]:Ve[t]&&Ve[t].prototype,a=i?ge:ge[t]||Ce(ge,t,{})[t],l=a.prototype,c,d,m,b,v,k,I,g,u;for(b in e)c=Kc(i?b:t+(n?".":"#")+b,r.forced),d=!c&&s&&so(s,b),k=a[b],d&&(r.dontCallGetSet?(u=Wc(s,b),I=u&&u.value):I=s[b]),v=d&&I?I:e[b],!(!c&&!o&&typeof k==typeof v)&&(r.bind&&d?g=Qc(v,Ve):r.wrap&&d?g=Xc(v):o&&zc(v)?g=Gc(v):g=v,(r.sham||v&&v.sham||k&&k.sham)&&Ce(g,"sham",!0),Ce(a,b,g),o&&(m=t+"Prototype",so(ge,m)||Ce(ge,m,{}),Ce(ge[m],b,v),r.real&&l&&(c||!l[b])&&Ce(l,b,v)))}});var po=p((Md,co)=>{"use strict";var Yc=Math.ceil,Zc=Math.floor;co.exports=Math.trunc||function(e){var t=+e;return(t>0?Zc:Yc)(t)}});var $e=p((Vd,uo)=>{"use strict";var Jc=po();uo.exports=function(r){var e=+r;return e!==e||e===0?0:Jc(e)}});var mo=p((Nd,ho)=>{"use strict";var ep=$e(),tp=Math.max,rp=Math.min;ho.exports=function(r,e){var t=ep(r);return t<0?tp(t+e,0):rp(t,e)}});var vo=p(($d,fo)=>{"use strict";var ip=$e(),np=Math.min;fo.exports=function(r){var e=ip(r);return e>0?np(e,9007199254740991):0}});var _e=p((_d,bo)=>{"use strict";var op=vo();bo.exports=function(r){return op(r.length)}});var Or=p((jd,go)=>{"use strict";var ap=Pe(),sp=mo(),lp=_e(),yo=function(r){return function(e,t,i){var n=ap(e),o=lp(n);if(o===0)return!r&&-1;var s=sp(i,o),a;if(r&&t!==t){for(;o>s;)if(a=n[s++],a!==a)return!0}else for(;o>s;s++)if((r||s in n)&&n[s]===t)return r||s||0;return!r&&-1}};go.exports={includes:yo(!0),indexOf:yo(!1)}});var bt=p((Bd,Co)=>{"use strict";Co.exports=function(){}});var Eo=p(()=>{"use strict";var cp=Ne(),pp=Or().includes,up=B(),hp=bt(),dp=up(function(){return!Array(1).includes()});cp({target:"Array",proto:!0,forced:dp},{includes:function(e){return pp(this,e,arguments.length>1?arguments[1]:void 0)}});hp("includes")});var yt=p((Hd,To)=>{"use strict";var mp=dt();To.exports=mp});var xo=p((Ud,Io)=>{"use strict";Eo();var fp=yt();Io.exports=fp("Array","includes")});var wo=p((Gd,Ao)=>{"use strict";var vp=xo();Ao.exports=vp});var gt=p((zd,So)=>{"use strict";var bp=wo();So.exports=bp});var Do=p(()=>{"use strict";var Rp=Ne(),kp=Le(),Op=_e(),Pp=$e(),Lp=bt();Rp({target:"Array",proto:!0},{at:function(e){var t=kp(this),i=Op(t),n=Pp(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});Lp("at")});var Uo=p((cf,Ho)=>{"use strict";Do();var Fp=yt();Ho.exports=Fp("Array","at")});var zo=p((pf,Go)=>{"use strict";var Mp=Uo();Go.exports=Mp});var qr=p((uf,Wo)=>{"use strict";var Vp=zo();Wo.exports=Vp});var ia=p((Yf,ra)=>{"use strict";var Hp=gr(),Up=Cr(),ta=Hp("keys");ra.exports=function(r){return ta[r]||(ta[r]=Up(r))}});var oa=p((Zf,na)=>{"use strict";var Gp=B();na.exports=!Gp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var la=p((Jf,sa)=>{"use strict";var zp=be(),Wp=q(),Kp=Le(),Qp=ia(),Xp=oa(),aa=Qp("IE_PROTO"),zr=Object,Yp=zr.prototype;sa.exports=Xp?zr.getPrototypeOf:function(r){var e=Kp(r);if(zp(e,aa))return e[aa];var t=e.constructor;return Wp(t)&&e instanceof t?t.prototype:e instanceof zr?Yp:null}});var pa=p((ev,ca)=>{"use strict";ca.exports={}});var da=p((tv,ha)=>{"use strict";var Zp=H(),Wr=be(),Jp=Pe(),eu=Or().indexOf,tu=pa(),ua=Zp([].push);ha.exports=function(r,e){var t=Jp(r),i=0,n=[],o;for(o in t)!Wr(tu,o)&&Wr(t,o)&&ua(n,o);for(;e.length>i;)Wr(t,o=e[i++])&&(~eu(n,o)||ua(n,o));return n}});var fa=p((rv,ma)=>{"use strict";ma.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var ba=p((iv,va)=>{"use strict";var ru=da(),iu=fa();va.exports=Object.keys||function(e){return ru(e,iu)}});var Ia=p((nv,Ta)=>{"use strict";var ga=se(),nu=B(),Ca=H(),ou=la(),au=ba(),su=Pe(),lu=nr().f,Ea=Ca(lu),cu=Ca([].push),pu=ga&&nu(function(){var r=Object.create(null);return r[2]=2,!Ea(r,2)}),ya=function(r){return function(e){for(var t=su(e),i=au(t),n=pu&&ou(t)===null,o=i.length,s=0,a=[],l;o>s;)l=i[s++],(!ga||(n?l in t:Ea(t,l)))&&cu(a,r?[l,t[l]]:t[l]);return a}};Ta.exports={entries:ya(!0),values:ya(!1)}});var xa=p(()=>{"use strict";var uu=Ne(),hu=Ia().values;uu({target:"Object",stat:!0},{values:function(e){return hu(e)}})});var wa=p((sv,Aa)=>{"use strict";xa();var du=ht();Aa.exports=du.Object.values});var Ra=p((lv,Sa)=>{"use strict";var mu=wa();Sa.exports=mu});var _t=p((cv,ka)=>{"use strict";var fu=Ra();ka.exports=fu});var Zr=p((Ov,$a)=>{"use strict";var bu=Oe();$a.exports=Array.isArray||function(e){return bu(e)==="Array"}});var ja=p((Pv,_a)=>{"use strict";var yu=TypeError,gu=9007199254740991;_a.exports=function(r){if(r>gu)throw yu("Maximum allowed index exceeded");return r}});var Da=p((Lv,qa)=>{"use strict";var Cu=Zr(),Eu=_e(),Tu=ja(),Iu=Ar(),Ba=function(r,e,t,i,n,o,s,a){for(var l=n,c=0,d=s?Iu(s,a):!1,m,b;c<i;)c in t&&(m=d?d(t[c],c,e):t[c],o>0&&Cu(m)?(b=Eu(m),l=Ba(r,e,m,b,l,o-1)-1):(Tu(l+1),r[l]=m),l++),c++;return l};qa.exports=Ba});var Ga=p((Fv,Ua)=>{"use strict";var xu=Fe(),Au=xu("toStringTag"),Ha={};Ha[Au]="z";Ua.exports=String(Ha)==="[object z]"});var Wa=p((Mv,za)=>{"use strict";var wu=Ga(),Su=q(),Bt=Oe(),Ru=Fe(),ku=Ru("toStringTag"),Ou=Object,Pu=Bt(function(){return arguments}())==="Arguments",Lu=function(r,e){try{return r[e]}catch{}};za.exports=wu?Bt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=Lu(e=Ou(r),ku))=="string"?t:Pu?Bt(e):(i=Bt(e))==="Object"&&Su(e.callee)?"Arguments":i}});var Qa=p((Vv,Ka)=>{"use strict";var Fu=H(),Mu=q(),Jr=ft(),Vu=Fu(Function.toString);Mu(Jr.inspectSource)||(Jr.inspectSource=function(r){return Vu(r)});Ka.exports=Jr.inspectSource});var ts=p((Nv,es)=>{"use strict";var Nu=H(),$u=B(),Xa=q(),_u=Wa(),ju=dt(),Bu=Qa(),Ya=function(){},Za=ju("Reflect","construct"),ei=/^\s*(?:class|function)\b/,qu=Nu(ei.exec),Du=!ei.test(Ya),Xe=function(e){if(!Xa(e))return!1;try{return Za(Ya,[],e),!0}catch{return!1}},Ja=function(e){if(!Xa(e))return!1;switch(_u(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Du||!!qu(ei,Bu(e))}catch{return!0}};Ja.sham=!0;es.exports=!Za||$u(function(){var r;return Xe(Xe.call)||!Xe(Object)||!Xe(function(){r=!0})||r})?Ja:Xe});var os=p(($v,ns)=>{"use strict";var rs=Zr(),Hu=ts(),Uu=ve(),Gu=Fe(),zu=Gu("species"),is=Array;ns.exports=function(r){var e;return rs(r)&&(e=r.constructor,Hu(e)&&(e===is||rs(e.prototype))?e=void 0:Uu(e)&&(e=e[zu],e===null&&(e=void 0))),e===void 0?is:e}});var ss=p((_v,as)=>{"use strict";var Wu=os();as.exports=function(r,e){return new(Wu(r))(e===0?0:e)}});var ls=p(()=>{"use strict";var Ku=Ne(),Qu=Da(),Xu=Le(),Yu=_e(),Zu=$e(),Ju=ss();Ku({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Xu(this),i=Yu(t),n=Ju(t,0);return n.length=Qu(n,t,t,i,0,e===void 0?1:Zu(e)),n}})});var cs=p(()=>{"use strict";var eh=bt();eh("flat")});var us=p((Hv,ps)=>{"use strict";ls();cs();var th=yt();ps.exports=th("Array","flat")});var ds=p((Uv,hs)=>{"use strict";var rh=us();hs.exports=rh});var fs=p((Gv,ms)=>{"use strict";var ih=ds();ms.exports=ih});var dh={};Ws(dh,{ContainerTypes:()=>y.ContainerTypes,ControlTypes:()=>y.ControlTypes,CustomError:()=>F,EVENT_NAMES:()=>w,EventActionTypes:()=>y.EventActionTypes,EventTypes:()=>y.EventTypes,Interactives:()=>Ze,ManifestController:()=>pe,SDKInfo:()=>hh,chapterIdsToVKVideoIds:()=>Dt,compareVersions:()=>Nt,containerTypes:()=>Cp,controlTypes:()=>Ep,eventActionTypes:()=>Ip,eventTypes:()=>Tp,getChapterIdByVkVideoId:()=>Fs,getVKVideoIdByMedia:()=>ii,getVideoRawIdByMedia:()=>Ps,graphEventTypes:()=>Ie,hasEndTemplate:()=>Be,interactivesEventTypes:()=>P,isAreaControl:()=>gp,isButtonControl:()=>yp,isLastChapter:()=>G,isOneTextCtrlContainer:()=>ce,isSupportedManifest:()=>y.isSupportedManifest,isTextControl:()=>je,isVKVariantItem:()=>Ls,isValidManifest:()=>Pr,migrateManifestToLatestVersion:()=>y.migrateManifestToLatestVersion,utils:()=>Bs,vkVideoIdsToChapterIds:()=>ni});module.exports=Ks(dh);var ci="1.0.40-dev.7807e4e6.0";var qe=require("@vkontakte/videoplayer-shared");var zt=class{constructor(e){this.layout=e}},tt=class extends zt{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * (${t.width} + ${2e-4}))`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var ui=require("@vkontakte/videoplayer-shared");function pi(r){return"features"in r}var F=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};function rt({emitter$:r,error:e,subjectId:t,message:i="",severity:n=1,category:o=1}){let s=new F(n,o,{message:i,error:e,details:{id:t}});r.next(s)}var de=class{constructor(e,t){this.error$=new ui.Subject;this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&pi(this.options)&&this.options.features[e]}onError(e="",t){rt({emitter$:this.error$,error:t,message:e,subjectId:this.container.id})}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){return this.container.controls?.reduce((e,t)=>{let i=t.type.trim().toLowerCase(),n=this.factories.get(i);if(n){let o=n(t,this.options);if(o)return[...e,o]}return[...e]},[])||[]}};var Y=require("@vkontakte/videoplayer-shared");var ee=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,te=r=>ee(r,"Object"),it=r=>ee(r,"String"),nt=r=>ee(r,"Array"),ot=r=>ee(r,"Number"),hi=r=>ee(r,"Function"),di=r=>ee(r,"Boolean"),Qt=r=>ot(r)&&!isNaN(r);var oe=r=>te(r)&&Object.keys(r).length===0,Xt=r=>nt(r)&&!r.length;var Ae=(r,e)=>it(r)&&(e?r.trim():r).length;function we(r,e=1){let t="0",i="0",n="0";return r.length===4?(t="0x"+r[1]+r[1],i="0x"+r[2]+r[2],n="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],i="0x"+r[3]+r[4],n="0x"+r[5]+r[6]),`rgba(${+t},${+i},${+n},${e})`}var mi="interactive",O={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},fi=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(fi||{}),vi=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(vi||{}),bi=(i=>(i.start="left",i.end="right",i.center="center",i))(bi||{}),at=({target:r,props:e})=>{r.style.alignItems=(e?.gravityVertical&&fi[e.gravityVertical])??"center",r.style.justifyContent=(e?.gravityHorizontal&&vi[e.gravityHorizontal])??"center",r.style.textAlign=(e?.alignment&&bi[e.alignment])??"center"},st=({target:r,props:e,fallback:t,dependsOn:i})=>{r.style.color=e?.text?.color??t.textColor,r.style.fontSize=`calc(${i.height} * ${e?.text?.size??t.textSize})`,r.textContent=e?.text?.value??t.textContent},lt=({target:r,props:e,fallback:t})=>{r.style.backgroundColor=we(e?.background?.color??t.backgroundColor,e?.background?.alpha??t.backgroundAlpha)},Se=({target:r,props:e,fallback:t,dependsOn:i,useRawValues:n=!1})=>{let o=n?t.borderWidthRawValue:`calc(${i.height} * ${e?.shape?.border?.width??t.borderWidth})`,s=n?t.roundCornersRawValue:`calc(${i.height} * ${e?.shape?.roundCorners??t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=we(n?t.borderColor:e?.shape?.border?.color??t.borderColor,n?t.borderAlpha:e?.shape?.border?.alpha??t.borderAlpha),r.style.borderRadius=s},yi=({target:r,isDark:e,baseDimension:t,fallback:i})=>{let s=we(i.shadowColorLight,i.shadowColorAlpha),a=we(i.shadowColorDark,i.shadowColorAlpha),l=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${l} ${c} ${e?a:s}`;r.style.boxShadow=d},me=({target:r,layoutParams:e,fallback:t})=>{let i=e.angle??t.angle;i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};var X=require("@vkontakte/videoplayer-shared");var Yt="interactive-control-tap",fe={common:Yt,animation:`${Yt}-animation`,visible:`${Yt}-visible`};var Qs=60,ct=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=Qs,useDimensionsBasedSize:n=!1}){this.onElementClick=e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let i=t.getBoundingClientRect(),n={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},o=Math.min(n.width,n.height),s=i.left+i.width/2,a=i.top+i.height/2,l=e.clientX-s,c=e.clientY-a,d=Xs(l,c,this.controlRotateAngleRad);this.element.style.width=o+"px",this.element.style.left=d.x+i.width/2-o/2+"px",this.element.style.top=d.y+i.height/2-o/2+"px",this.element.classList.add(fe.visible,fe.animation)};this.onAnimationEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.element.classList.remove(fe.visible,fe.animation)};let o=document.createElement("div");o.classList.add(fe.common),this.controlRotateAngleRad=e,this.element=o,this.clickCancelCondition=t,this.circleDiameterPx=i,this.useDimensionsBasedSize=n}};function Xs(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var Zt="int",ae=(i=>(i.AREA=`${Zt}_area`,i.TEXT=`${Zt}_text`,i.BUTTON=`${Zt}_bttn`,i))(ae||{});function Jt(r){return"features"in r}var K="interactive-control",R={common:K,selected:`${K}-selected`,wrapper:`${K}-wrapper`,disabled:`${K}-disabled`,button:`${K}-button`,area:`${K}-area`,text:`${K}-text`,blinkAnim:`${K}-blink-anim`,blinkAnimButton:`${K}-blink-anim-button`,blinkAnimArea:`${K}-blink-anim-area`},gi=40;var ko=W(gt(),1);var y=require("@interactiveplatform/movika-manifest");var Ro={metadata:"Object",chapters:"Array"},Pr=r=>{if(!te(r))return!1;for(let e in Ro)if(!r[e]||!ee(r[e],Ro[e]))return!1;return(0,y.isSupportedManifest)(r.metadata.version)},je=r=>r.type===y.ControlTypes.Text,yp=r=>r.type===y.ControlTypes.Button,gp=r=>r.type===y.ControlTypes.Area,Cp={Choice:"Choice",TextInput:"TextInput"},Ep={Button:"Button",Area:"Area",Text:"Text"},Tp={onClick:"onClick",onSuspense:"onSuspense"},Ip={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Ct=r=>nt(r)&&!Xt(r),G=r=>r.order==="end",Be=r=>nt(r.containers)&&!Xt(r.containers)&&G(r),Oo=(r,e)=>{let t=r*1e3;return Ct(e.controls)&&t<(e.startTime??0)},Lr=(r,e)=>{let t=r*1e3;return Ct(e.controls)&&t>=(e.startTime??0)&&t<=(e.endTime??1/0)};var le=(r=[])=>r.some(e=>e.action.type==="expect"),Fr=(r=[])=>r.find(e=>e.action.type==="expect"),xp=r=>r?.length===1,ce=r=>xp(r)&&je(r[0]);function Po(r=[],e=1/0,t=[]){return r.filter(({container:i})=>!(0,ko.default)(t,i.container.id)&&le(i.container.events)&&i.container.endTime===e&&!i.isRemoved&&!i.willRemoved)}function Et({gameControllers:r=[],subjectName:e,subjectId:t,execFn:i}){for(let n of r)if(e==="container"&&n.container.container.id===t){i(n),Po(r,n.container.container.endTime,[n.container.container.id]).forEach(s=>{i(s)});break}}function Lo(r){for(let e of r.events)if(e.action.type==="openURI")return!0;return!1}var Fo=(r,e)=>{let t=I=>e.find(({container:u})=>u.container.id===I)?.container.isRemoved,i=le(r.events)&&!t(r.id),n=(I,g=!1,u=!1)=>{let h=u?"every":"some";return I.controls[h](f=>{let E=g?I.endTime===r.endTime:!0;return f.events?.[h](T=>T.action?.type===y.EventActionTypes.openURI)&&E})},o=I=>I.some(({container:g})=>n(g.container,!0,!1)&&!g.isRemoved),s=I=>I.every(({container:g})=>g.isRemoved||g.willRemoved?!0:n(g.container,!0,!0)),a=Po(e,r.endTime,[r.id]).length,l=I=>I.controls.some(g=>g.events?.some(u=>u.action?.args?.shouldOpenNow)),c=i||a>0,d=o(e),m=n(r),b=s(e),v=i?!1:a>0,k=l(r);return{isExpectTime:c,hasOtherExpect:a>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:b,isExpectEventForCurrentContainer:v,hasShouldOpenNowEvent:k}};var re=class r{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new X.Subscription;this.error$=new X.Subject;this.isInteracted=!1;this.isRemoved=!1;this.onControlSelect=()=>{this.container?.isManifestContainerDisabled()||Lo(this.control)||this.container?.element?.classList.add("interactive-control-wrapper-selected")};this.onTransitionEnd=e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}}removeView(e=!1){let t=this.getElement();if(t){if(e){if(t.classList.contains("interactive-control-before-remove"))return;t.classList.add("interactive-control-before-remove"),this.subscriptions.add((0,X.fromEvent)(t,"transitionend").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n))).add((0,X.fromEvent)(t,"transitioncancel").subscribe(this.onTransitionEnd,n=>this.onError(`${r.name} remove view transition error`,n)));return}this.removeListeners(),t.remove(),this.isRemoved=!0}}onError(e="",t){rt({emitter$:this.error$,error:t,message:e,subjectId:this.control.id})}addControlTap(e){if(this.featureIsEnabled("controlsTapPlace")&&this.container){let t=this.control.layoutParams.angle??O.angle;this.controlTap=new ct({controlRotateAngleRad:t,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?gi:void 0}),this.subscriptions.add((0,X.fromEvent)(e,"click").subscribe(this.controlTap.onElementClick,i=>this.onError("Control click tap animation error",i))).add((0,X.fromEvent)(this.controlTap.element,"animationend").subscribe(this.controlTap.onAnimationEnd,i=>this.onError("Tap animationend error",i))),this.container.element.append(this.controlTap.element)}}createContainerElement(e){let t=document.createElement("div");t.classList.add(R.wrapper),e.setControlLayout(t,this.control.layoutParams);let i=(this.control.layoutParams.innerSizesDependOn??O.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"},n=()=>e.isContainerDisabled?.()??!1;this.container={element:t,dimensions:i,isManifestContainerDisabled:n}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted=!0,e()}}featureIsEnabled(e){return this.options&&Jt(this.options)&&this.options.features[e]}isTouch(){return this.options&&Jt(this.options)&&this.options.isTouch}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add((0,X.fromEvent)(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),n=>this.onError("Error happened on control interaction",n)));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var Mr="interactive-blink-anim-reference",V={common:Mr,animation:`${Mr}-animation`,disabled:`${Mr}-disabled`},Tt=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(V.common,V.animation),this._element=e}restart(){this._element&&(this._element.classList.add(V.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(V.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var Vr="interactive-container",N={common:Vr,hidden:`${Vr}-hidden`,disabled:`${Vr}-disabled`};var It=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Nr(r,e)},Nr=class extends re{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(R.common,R.area),i.setAttribute("data-testid",ae.AREA),lt({target:i,props:this.control.props,fallback:{...O,backgroundColor:"transparent"}}),me({target:i,layoutParams:this.control.layoutParams,fallback:O}),this.addControlTap(i),this.subscriptions.add((0,Y.fromEvent)(this.container.element,"click").pipe((0,Y.once)()).subscribe(this.onControlSelect,n=>this.onError("Control click handler error",n))),this.container.element.append(i),e.append(this.container.element),this.controlElement=i,this.updateShadowStyles(),this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,Y.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(N.disabled))return;let t=e.parentElement;if(t){let i=t.querySelector(`.${V.common}`);i&&this.syncBlinkAnimation(i)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,Y.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(N.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,Y.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(R.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(R.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){if(!(!this.container||!this.controlElement))if(di(e)){let t=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";yi({target:this.controlElement,props:this.control.props,fallback:O,isDark:e,baseDimension:t}),Se({target:this.controlElement,props:this.control.props,fallback:{...O,borderColor:e?O.shadowColorDark:O.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${this.control.props?.shape?.roundCorners??O.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else Se({target:this.controlElement,props:this.control.props,fallback:{...O,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(R.blinkAnim,e),this.controlElement?.classList.toggle(R.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${R.blinkAnimArea}`)||this.controlElement.classList.contains(R.selected)||this.controlElement.classList.contains(V.disabled)||(this.controlElement.classList.add(V.disabled),this.subscriptions.add((0,Y.fromEvent)(e,"animationiteration").pipe((0,Y.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(V.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${R.blinkAnimArea}`)||this.controlElement.classList.contains(R.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}};var J=require("@vkontakte/videoplayer-shared");var xt=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),i={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,i),t.append(e);let n={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,n),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var At=Math.PI,$r=2*At,wt=At/2,Mo=3*wt,Ap=0,wp=[Ap,wt,At,Mo];function Vo(r){return r===wt}function No(r){return r===At}function $o(r){return r===Mo}function _o(r){return(r%$r+$r)%$r}function Sp(r){for(let e of wp)if(r===e)return e}function jo(r){if(Sp(r))return null;let t=Math.floor(r/wt)+1;return[1,2,3,4][t-1]}function Bo(r){return r*180/Math.PI}var Z="interactive-control-fill-animation",$={common:Z,fillerWrapper:`${Z}-filler-wrapper`,filler:`${Z}-filler`,fillHeight:`${Z}-fill-height`,fillWidth:`${Z}-fill-width`,fromTop:`${Z}-from-top`,fromBottom:`${Z}-from-bottom`,fromLeft:`${Z}-from-left`,fromRight:`${Z}-from-right`};var St=class r{constructor(e){this.widthExpansionCoef=0;let t=document.createElement("div");t.classList.add($.common);let i=document.createElement("div");i.classList.add($.fillerWrapper);let n=document.createElement("div");n.classList.add($.filler),i.append(n),t.append(i);let o=_o(e.rotateAngle),s=jo(o),a=s!==null,c=s===2||!a&&No(o)||s===3,d=!a&&Vo(o),m=!a&&$o(o),b=!c&&!d&&!m,v=d||m,k=a&&!v,I=k?o:0;t.style.borderRadius=e.borderRadius,i.style.transform=`skew(${I*-1}rad)`,v?(n.classList.add($.fillHeight,d?$.fromTop:$.fromBottom),i.classList.add($.fillHeight,d?$.fromTop:$.fromBottom)):(n.classList.add($.fillWidth,b?$.fromLeft:$.fromRight),i.classList.add($.fillWidth)),e.debug&&console.log(`[interactive ${r.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:v,rotateAngleRad:o,rotateAngelDeg:Bo(o),rotateAngleRaw:e.rotateAngle,fromRight:c,fromTop:d,fromBottom:m,fromLeft:b}),this.useSkew=k,this.fromLeft=b,this.rotateAngle=o,this.fillAnimationElement=t,this.fillAnimationFillerElement=n,this.fillAnimationFillerWrapperElement=i,this.startTime=e.startTime,this.endTime=e.endTime,this.shouldFillHeight=v,this.isDebug=e.debug??!1}updateDimension(e){this.fillAnimationElement.style.top=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.left=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.width=`${e.width}px`,this.fillAnimationElement.style.height=`${e.height}px`;let t=this.calcWidthExpansionCoef({rotateAngle:this.rotateAngle,isSkewed:this.useSkew,initWidth:e.width,initHeight:e.height});!this.shouldFillHeight&&(this.fillAnimationFillerWrapperElement.style.width=100*t+100+"%",this.fillAnimationFillerWrapperElement.style[`${this.fromLeft?"left":"right"}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((o=>o<this.startTime||o>this.endTime)(e))return;let i=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/i,0),1);this.shouldFillHeight?this.fillAnimationFillerElement.style.transform=`scaleY(${n})`:this.fillAnimationFillerElement.style.transform=`scaleX(${n})`}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:i,initHeight:n}){return t?(i+n*Math.abs(Math.tan(e)))/i-1:0}};var Rt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new _r(r,e)},_r=class extends re{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("button");i.type="button",i.classList.add(R.common,R.button),i.setAttribute("data-testid",ae.BUTTON),me({target:i,layoutParams:this.control.layoutParams,fallback:O}),lt({target:i,props:this.control.props,fallback:O}),Se({target:i,props:this.control.props,fallback:O,dependsOn:this.container.dimensions}),at({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=xt(this.control.type.trim().toLowerCase()),o=n.firstElementChild??n;st({target:o,props:this.control.props,fallback:O,dependsOn:this.container.dimensions}),this.addControlTap(i),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled("controlsFillAnimation")&&(this.controlFillAnimation=new St({startTime:this.startTime,endTime:this.endTime,rotateAngle:this.control.layoutParams.angle??O.angle,borderRadius:i.style.borderRadius})),this.subscriptions.add((0,J.fromEvent)(i,"click").pipe((0,J.once)()).subscribe(this.onControlSelect,s=>this.onError("Control click handler error",s))),i.append(n,this.controlFillAnimation?.fillAnimationElement??""),this.container.element.append(this.controlTap?.element??"",i),e.append(this.container.element),this.controlElement=i,this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,J.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(N.disabled))return;let t=e.parentElement;if(t){let i=t.querySelector(`.${V.common}`);i&&this.syncBlinkAnimation(i)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,J.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(N.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,J.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},t=>this.onError("Error happened in mouseleave callback",t))))}disable(){this.controlElement&&this.controlElement.classList.add(R.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(R.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(R.blinkAnim,e),this.controlElement?.classList.toggle(R.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${R.blinkAnimButton}`)||this.controlElement.classList.contains(R.selected)||this.controlElement.classList.contains(V.disabled)||(this.controlElement.classList.add(V.disabled),this.subscriptions.add((0,J.fromEvent)(e,"animationiteration").pipe((0,J.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(V.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${R.blinkAnimButton}`)||this.controlElement.classList.contains(R.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}updateFillAnimationDimensions(){if(!this.container||!this.controlElement||!this.controlFillAnimation)return;let e=getComputedStyle(this.controlElement),t={width:parseFloat(e.width),height:parseFloat(e.height),borderWidth:parseFloat(e.borderWidth)||0};this.controlFillAnimation.updateDimension(t)}setShowTimeRange(e,t){this.startTime=e,this.endTime=t}onProgress(e){this.controlFillAnimation?.updateAnimation(e)}onResize(){this.updateFillAnimationDimensions()}updateShadowStyles(){}};var qo=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new jr(r,e)},jr=class extends re{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let i=document.createElement("div");i.classList.add(R.common,R.text),i.setAttribute("data-testid",ae.TEXT),me({target:i,layoutParams:this.control.layoutParams,fallback:O}),at({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=xt(this.control.type.trim().toLowerCase()),o=n.firstElementChild??n;st({target:o,props:this.control.props,fallback:O,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}setShowTimeRange(){}updateFillAnimationDimensions(){}};var kt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new Br(r,e,t)},Br=class r extends de{constructor(t,i,n){super(t,n);this.containerElement=null;this.subscriptions=new qe.Subscription;this.onTransitionEnd=t=>{t.stopPropagation(),!(!t.target||!t.currentTarget)&&t.target===t.currentTarget&&this.removeView()};this.rootElement=i,this.layout=new tt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Rt),this.addControlFactory("text",qo),this.addControlFactory("area",It)}createView({eventCallback:t,videoDurationMs:i}){let n=document.createElement("div");return n.classList.add(N.common,N.disabled),requestAnimationFrame(()=>{n.classList.remove(N.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(o=>{o.setShowTimeRange(this.container.startTime,this.container.endTime??i),o.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout,isContainerDisabled:()=>this.isDisabled}}),o.setEvents(t),this.subscriptions.add(o.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.willRemoved=!1,this.containerElement=n,this.updateControlsFillAnimationDimensions(),n}updateControlsFillAnimationDimensions(){for(let t of this.controls)t.updateFillAnimationDimensions()}hide(){let t=this.getElement();t&&t.classList.add(N.hidden)}show(){let t=this.getElement();t&&t.classList.remove(N.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(N.disabled),this.controls.forEach(i=>i.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(N.disabled),this.controls.forEach(i=>i.disable()),this.isDisabled=!0)}removeView(t=!1,i=!1){let n=this.getElement();if(n){if(t){if(this.willRemoved)return;this.willRemoved=!0,i&&n.classList.add("interactive-container-before-remove-delay"),n.classList.add("interactive-container-before-remove"),this.subscriptions.add((0,qe.fromEvent)(n,"transitionend").subscribe(this.onTransitionEnd,s=>this.onError(`${r.name} remove view transition error`,s))).add((0,qe.fromEvent)(n,"transitioncancel").subscribe(this.onTransitionEnd,s=>this.onError(`${r.name} remove view transition error`,s)));return}this.subscriptions.unsubscribe(),this.removeAllControls(),n.remove(),this.isRemoved=!0,this.willRemoved=!1,this.containerElement=null}}removeAllControls(t=!1){this.controls.forEach(i=>i.removeView(t))}removeNonInteractedControls(t=!1){this.controls.forEach(i=>{i.isInteracted||i.removeView(t)})}isInteracted(){return this.controls.some(t=>t.isInteracted)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,i){i&&this.controls.forEach(n=>{n.onProgress(t)})}onResize(t){t&&this.controls.forEach(i=>{i.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(i=>i.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(i=>i.toggleBlinkAnimation(t))}};var _s=W(qr(),1),C=require("@vkontakte/videoplayer-shared"),xe=require("@vkontakte/videoplayer-statistics");var Yo=require("@vkontakte/videoplayer-shared");function De(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var Ko="video_interactive",Qo="videoint";var Xo=250,He=class{constructor(e){this.handleZoomChange=De(e=>{this.lastZoomInfo=e},Xo);this.onResize=e=>{if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&this.ngEditor?.zoomTo(t,void 0,{isFromCenter:!0}),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?.("Chapter 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,t=[])=>{if(this.isReady=!1,!ot(e.graph.edit.chapters[0].x)){this.onError?.("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:i,lang:n,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,this.onError=i,this.lang=n??"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Np(e),this.resizeObserver=new ResizeObserver(De(this.onResize,Xo)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor?.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor?.updateVideosInfo(e)}async show(){this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&this.ngEditor?.focusChapter(this.currentChapterId),this.isHidden=!1)}async initNgEditor(){if(!this.manifest)return;let e;try{e=await(0,Yo.loadVKLangPack)(this.lang,Ko,Qo)}catch{this.onError?.("Unable to load graph language pack")}let{GraphEditor:t}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name: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 Np(r){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",r.append(e),e}var Ue=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,i=!1,n=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let s=o.startTime-e;if(s<=n&&(o.endTime&&n<=o.endTime||o.endTime===null)){i=!0;break}n<s&&(t=t===-1?s:Math.min(t,s))}return!i&&t!==-1?t:null}}};var Ot=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let i=()=>{t(),this.off(e,i)};return this.listeners[e].push(i),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let i=this.listeners[e]||[];for(let n=i.length;n>0;n--)if(i[n]===t){i.splice(n,1);break}return this}emit(e,...t){let i=this.listeners[e];return i?(i.forEach(n=>{n(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var Pt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{hi(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var ea=require("@vkontakte/videoplayer-shared");var Lt=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,t){return $p(...this.loaders[e])(t)}};function $p(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function Ge(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function Ft({actions:r,errors:e,chapterId:t,...i}){if(t){let n=r.getManifest();if(n){let o=r.getChapter(n.chapters,t);if(o){let s=r.getMedia(n.media,o.videoId),a=r.getGraph(n.graph,o.id);return s?{...i,actions:r,errors:e,result:{chapter:o,media:s,graph:a}}:{...i,errors:Ge(e,Ft.name,"Could not find media"),actions:r}}}}return{...i,errors:Ge(e,Ft.name,"Could not find chapter"),actions:r}}var Mt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let n=0,o=i.length;n<o;n++)if(i[n].callback===t){i.splice(n,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let i=this.listeners[e.type].slice();for(let n=0,o=i.length;n<o;n++){let s=i[n];try{s.callback.call(this,e)}catch(a){Promise.resolve().then(()=>{throw a})}s.options&&s.options.once&&this.removeEventListener(e.type,s.callback)}return!e.defaultPrevented}},Ee=class extends Mt{constructor(){super(),this.listeners||Mt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},ze=class{constructor(){Object.defineProperty(this,"signal",{value:new Ee,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch{typeof document<"u"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={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(t)}toString(){return"[object AbortController]"}};typeof Symbol<"u"&&Symbol.toStringTag&&(ze.prototype[Symbol.toStringTag]="AbortController",Ee.prototype[Symbol.toStringTag]="AbortSignal");function Vt(r){return r.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof r.Request=="function"&&!r.Request.prototype.hasOwnProperty("signal")||!r.AbortController}function Dr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Vt({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||n)&&(o=function(c,d){let m;d&&d.signal&&(m=d.signal,delete d.signal);let b=new t(c,d);return m&&Object.defineProperty(b,"signal",{writable:!1,enumerable:!1,configurable:!0,value:m}),b},o.prototype=t.prototype);let s=e;return{fetch:(l,c)=>{let d=o&&o.prototype.isPrototypeOf(l)?l.signal:c?c.signal:void 0;if(d){let m;try{m=new DOMException("Aborted","AbortError")}catch{m=new Error("Aborted"),m.name="AbortError"}if(d.aborted)return Promise.reject(m);let b=new Promise((v,k)=>{d.addEventListener("abort",()=>k(m),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([b,s(l,c)])}return s(l,c)},Request:o}}var _p=()=>"fetch"in window,We=_p()&&Vt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Zo=We?Dr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Hr=We?Zo.fetch:window.fetch,Vf=We?Zo.Request:window.Request,Nf=We?ze:window.AbortController,$f=We?Ee:window.AbortSignal;var Nt=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let o=0;o<Math.max(t.length,i.length)&&!n;o++)t[o]>i[o]?n=1:t[o]<i[o]?n=-1:n=0;return n};var jp=async r=>{try{let e={},t;if(it(r)){t=new URL(r).href;let n=await Hr(t);if(!n.ok)return{};e=await n.json()}else if(te(r))e=r;else return{};if(!Pr(e))return{};let i=e.metadata.media;if(it(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=await Hr(n);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch{return Dp(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch{return{}}};async function Jo(r){let{manifest:e,manifestURL:t}=await jp(r);if(!e)throw new Error("Failed on fetch");let i=(0,y.migrateManifestToLatestVersion)(e);return i.media=Bp(i.media,t),delete i.metadata.media,i}function $t(r,e){if(e)return r.find(t=>t.id===e)}function Ur(r,e){return r.edit?.chapters?r.edit.chapters.find(t=>t.id===e):r.view?.chapters?r.view.chapters.find(t=>t.id===e):void 0}function Gr(r,e){return r.videos.find(t=>t.id===e)}function Bp(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=qp(n,e);return{...i,url:o||n}})}))}}function qp(r="",e){try{return new URL(r,e).href}catch{return""}}function Dp(r){return Nt(r,"3.2.0")>=0}var pe=class extends Lt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new ea.ValueSubject(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){this.release();let i=await this.exec("manifestLoaders",{actions:{addErrorMessage:Ge},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await Jo(i.result??t),this}async setInitial(){return this.setNext()}async setNext(t=this.manifest?.metadata.initChapterId){if(!t)return this;this.prevChapter$.next(this.chapter);let i=await this.exec("chapterLoaders",Ft({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Ur,getChapter:$t,getMedia:Gr,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ge},result:null,errors:null,chapterId:t}));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(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){return this.getByChapterId(this.manifest?.metadata.initChapterId)||null}getByChapterId(t=this.manifest?.metadata.initChapterId){if(!t||!this.manifest)return null;let i=$t(this.manifest.chapters,t);if(i){let n=Gr(this.manifest.media,i.videoId),o=Ur(this.manifest.graph,i.id);if(n)return{chapter:i,media:n,graph:o}}return null}getBranches(t=this.chapter?.id){if(t===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let i=$t(this.manifest?.chapters||[],t);return this.getByBranches(i?.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let o=this.getByChapterId(n.chapterId);return o&&i.push(o),i},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter?.id===this.manifest?.metadata.initChapterId}isEndChapter(){return this.chapter?G(this.chapter):!1}};var La=W(_t(),1),Fa=require("@vkontakte/videoplayer-core"),ie=require("@vkontakte/videoplayer-shared");var Oa=r=>{let e=r.variants.find(t=>t.payload?.type==="vk");if(e&&e.payload){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var Pa=W(_t(),1);function Kr(){let r=new Map;function e({listId:o=Math.random().toString(),itemId:s=Math.random().toString(),...a}){let l=r.get(o),c={...a};return l?l[s]=c:r.set(o,{[s]:c}),{listId:o,itemId:s,...a}}function t(o){o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),o.statistics?.oneStat.destroy(),o.statistics?.statSubscription.unsubscribe()}function i(o,s){let a=r.get(o);if(!a)throw Error("Can't remove. Not find.");if(s){let l=a[s];l&&t(l),delete a[s],Object.keys(a).length||r.delete(o)}else{for(let l of(0,Pa.default)(a))t(l);r.delete(o)}}function n(){for(let o of r)i(o[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var Te=W(gt(),1);function Qr(r,e=[]){let t={},i,n=!e.length;for(let o of r.variants)if(!i&&"cover"in o&&(i=o.cover),"url"in o)switch(o.type.toLowerCase()){case"mp4":(n||(0,Te.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"mpeg":(n||(0,Te.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"hls":(n||(0,Te.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:o.url}});break;case"dash":(n||(0,Te.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:o.url}});break;default:break}return{sources:t,thumbUrl:i,title:r.title??""}}var Ke=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,Te.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var vu=2;function Xr(r){let e=Kr(),t=new ie.Subscription,i={},n=null,o=!1,s,a=new ie.ValueSubject(null);r&&l(r);function l(g){n=g}function c(g,u,h){if(!n)throw Error("need to set interactive controller");if(!n.options)return;let E=(e.map.get(g)??{})[u];if(E){i={chapterId:h,listId:g,itemId:u,...E};let T=i.player;i.subscription.add(T.info.currentQuality$.subscribe(x=>{let S=T.info.position$.getValue(),_=T.info.isAutoQualityEnabled$.getValue();if(!(!x||!S||_))for(let A of e.map)(0,La.default)(A[1]).forEach(({player:L})=>{Ke(L,x)})})).add(T.events.started$.subscribe(()=>{d(u)})),E.container.remove(),n.setPlayer(E.player),o||(n.init(),o=!0),a.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}async function d(g){if(!n)throw Error("need to set interactive controller");if(oe(i)||g!==i.itemId)return;let u=n.getChapterBranches(),h=new Set;for(let f of u)h.has(f.media.id)||(await b({media:f.media,chapterId:f.chapter.id,setAsActive:!1,title:f.chapter.label}),h.add(f.media.id))}async function m({chapter:{id:g},manifestVideo:u}){if(oe(i)||!n)return;let h=i.player.info.muted$.getValue(),f=i.player.info.currentQuality$.getValue(),E=i.player.info.isAutoQualityEnabled$.getValue(),T=i.player.info.volume$.getValue(),x=i.player.info.currentPlaybackRate$.getValue(),S=!E,_=!1;for(let A of e.map)if(A[0]===u.id&&!n.state.isReplay$.getValue()){let L=Object.keys(A[1]);for(let M of L)M===i.itemId?(L.length<vu||(_=!0),e.removePlayer(A[0],M)):(_=!0,c(A[0],M,g),S?Ke(i.player,f):i.player.setAutoQuality(!0),i.player.setVolume(T),i.player.setMuted(h),i.player.setPlaybackRate(x))}else e.removePlayer(A[0]);_||(await b({media:u,chapterId:g,setAsActive:!0,playbackRate:x}),S?Ke(i.player,f):i.player.setAutoQuality(!0),i.player.setVolume(T),i.player.setMuted(h))}async function b({media:g,chapterId:u,prefetch:h=!0,setAsActive:f=!0,autoplay:E=!1,preferredExt:T,title:x,playbackRate:S}){let _=Math.random().toString(),A=document.createElement("div");s.append(A);let L;if(n?.options?.vkVideoLoader){let Je=Oa(g);Je.length&&(L=await n.options.vkVideoLoader(...Je))}let M=n?.options?.coreConfig||void 0,z={...M,configName:[...M?.configName??[],"interactive"]},ne={container:A,...L?.videos?.[0]||{sources:Qr(g,T).sources},title:x,failoverHosts:L?.failoverHosts||[]},j=new Fa.Player(z,ie.TracerFactory.createRootTracer());j.initVideo(ne);let ue=null;if(L?.videos&&n?.options.createOneStat){let Je=L.videos[0],Gt=n.options.createOneStat(Je),si=new ie.Subscription;Gt&&(si.add(Gt.attachTo(j)),ue={oneStat:Gt,statSubscription:si})}let ai=new ie.Subscription,qs=i?.player?.info.isAutoQualityEnabled$.getValue();ai.add(j.events.canplay$.subscribe(function(){qs||Ke(j,i.player.info.currentQuality$.getValue()),S&&j.setPlaybackRate(S)}));let he=e.createPlayer({listId:g.id,itemId:_,player:j,container:A,sources:Qr(g,T).sources,config:ne,subscription:ai,statistics:ue});return f&&c(g.id,he.itemId,u),E&&he.player.play(),h&&!E&&he.player.prepare(),{player:he.player,config:he.config,statistics:he.statistics}}function v(){k(),n=null,s.remove()}function k(){t.unsubscribe(),e.removeAll(),i={},o=!1}async function I(){if(!n)throw Error("need to set interactive controller");k(),s=document.createElement("div");let{media:g,chapter:u}=n.getCurrentChapter();g&&u?(t.add(n.events.chapterChanged$.subscribe(m)),await b({media:g,chapterId:u.id,title:u.label})):console.error("not found")}return{...e,init:I,setInteractiveController:l,createPlayer:b,removeAll:v,getActivePlayer:function(){return i},activePlayerChanged:a}}var w={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Ie={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},P={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Va=require("@vkontakte/videoplayer-shared");function Yr(r){return function(...t){return r(...t.reverse())}}function Qe(r,...e){return(...t)=>te(e[0])&&te(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var jt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:s,globalEventEmitter:a,getContainerEventState:l,permanentTextControls:c,interactiveTimeOpenUri:d,disabledControls$:m,onRemove:b,onError:v,disableTextControlContainerVisibilityEvents:k=!1,features:I}){this.hide=()=>{setTimeout(()=>{this.gameState!==4&&(le(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()){let{hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState();if(this.container.show?.(),this.interactiveTimeOpenUri&&t||this.disableTextControlContainerVisibilityEvents)return;this.emitContainerVisibilityEvent(!0,!1)}else{let t={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(o,s)=>{let{isExpectTime:a,hasOtherExpect:l,hasOpenURIEvent:c,hasOpenURIEventInCurrentContainer:d,isAllOpenURIEventsValid:m,hasShouldOpenNowEvent:b}=this.getContainerEventState(),v=this.interactiveTimeOpenUri&&!d,k=this.interactiveTimeOpenUri&&d;if((!this.interactiveTimeOpenUri||v)&&(this.isSelectedControlEvent=!0),o!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||v)){if(this.interactiveTimeOpenUri){let I=!l&&!m&&d;I&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:I})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&c&&this.gameState!==5){if(k){let g=((u,h,f,E)=>!u&&!h&&f||u&&!h&&f&&!E||u&&!h&&f&&E)(a,l,m,this.isSelectedContainerEvent);this.fakeRemoveView(g)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!a||!l||!b)&&(this.selectBranches.stopExpect(),s())}},isEOV:()=>this.gameState===4},i=Qe(this.selectBranches.onControlEvent,t),n=(this.player?.info.duration$.getValue()??1/0)*1e3;this.container.createView({eventCallback:i,videoDurationMs:n}),this.disableTextControlContainerVisibilityEvents||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();if(!(e instanceof HTMLVideoElement?e.readyState:void 0)||this.isRemovedOrDestroyed()&&!this.isPermanentText)return;let n=this.player.getExactTime();if(Oo(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Lr(n,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let l=this.gameState;this.gameState=3,l===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:l}=this.getContainerEventState(),c=this.selectBranches.state.isExpect,d=this.interactiveTimeOpenUri&&l;if(d&&!c){let m=this.container.getElement();m&&(m.style.visibility!=="hidden"&&this.container.hide?.(),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!d&&this.removeView()}let o=Lr(n,this.container.container),s=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:s,currentTime:n,isInteractiveTime:o};this.container.onProgress(n*1e3,o),this.globalEventEmitter.emit(w.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Va.Subscription,this.player=e,this.interactiveEvents=o,this.getContainerEventState=l;let g=ce(t.container.controls);this.isPermanentText=c&&g,this.disableTextControlContainerVisibilityEvents=k&&g,this.interactiveTimeOpenUri=d,this.disabledControls$=m,this.onRemove=b,this.globalEventEmitter=a,this.gameState=0,this.globalEvents=s,this.onError=v,this.features=I,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.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?.()})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();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,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime??1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),i=this.interactiveTimeOpenUri?e||t:le(this.container.container.events)||e;(this.isSelectedControlEvent||!i)&&this.removeView()}onBeforeStartTime(){this.container.hide?.(),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(e=this.features.controlsHideAnimation){if(e){if(this.isRemovedOrDestroyed())return;this.container.removeNonInteractedControls(!0),this.container.removeView(!0,!0)}else this.container.removeView();this.globalEventEmitter.emit(w.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,this.onRemove?.()}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}isInteracted(){return this.container.isInteracted()}isRemovedOrDestroyed(e=!0){let t=e?this.container.willRemoved:!1;return this.gameState===5||t||this.gameState===6}destroy(e=!1){this.reset(),this.removeView(e),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 Na=(r=[])=>r.reduce((e,t,i)=>{let n=(t?.controls??[]).filter(o=>!je(o));if(Ct(n)){let o=[t.startTime??0,t.endTime??1/0],s={id:t.id,isRemoved:!1};if(!i)e.push({subjects:[s],range:o});else{let a=[],l=-1/0,c=1/0,d=[],m=[];for(let b=0;b<e.length;b++){let v=e[b];if(m.push(...v.subjects),v.range[0]<c&&(c=v.range[0]),v.range[1]>l&&(l=v.range[1]),o[0]>=v.range[0]&&o[1]<=v.range[1])return e[b].subjects.push(s),e;o[0]<v.range[0]&&o[1]>v.range[0]&&(a.push(b),d=d.concat(v.subjects)),o[0]>=v.range[0]&&o[0]<=v.range[1]&&(a.push(b),d=d.concat(v.subjects),o[0]=v.range[0]),o[1]>=v.range[0]&&o[1]<=v.range[1]&&(a.push(b),d=d.concat(v.subjects),o[1]=v.range[1])}if(m.push(s),o[0]<=c&&o[1]>=l)return[{subjects:m,range:o}];a.length&&a.reverse().forEach(b=>{e.splice(b,1)}),e.push({subjects:d.concat([s]),range:o})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var bs=W(gt(),1),ti=W(_t(),1),ys=W(fs(),1);function vs(){let r={};function e(){for(let a in r)Object.prototype.hasOwnProperty.call(r,a)&&delete r[a]}function t(a){let l={};for(let c in r)+c<=a&&(l[c]=r[c]);return l}function i(a){let l={};for(let c in r)+c>=a&&(l[c]=r[c]);return l}function n({timestamp:a,priority:l,initiator:c}){if(Qt(a)){let d=r[a]??null;if(d&&l&&Ae(l,!0)){let m={},b=d[l];return b&&(m={...m,...b}),m=oe(m)?null:m,m&&Ae(c,!0)?m[c]??null:m}return d}return null}function o({timestamp:a,priority:l,initiator:c}){if(Qt(a))if(r[a]){if(l&&Ae(l,!0))if(r[a][l]){if(c&&Ae(c,!0))if(r[a][l][c]){if(delete r[a][l][c],!oe(r[a][l]))return!0}else return!1;if(delete r[a][l],!oe(r[a]))return!0}else return!1;return delete r[a]}else return!1;return!1}function s({timestamp:a,priority:l,initiator:c,...d}){r[a]?.[l]?.[c]?r[a][l][c].push({...d}):r[a]?.[l]?r[a][l]={...r[a][l],[c]:[{...d}]}:r[a]?r[a]={...r[a],[l]:{[c]:[{...d}]}}:r[a]={[l]:{[c]:[{...d}]}}}return{map:r,remove:o,add:s,removeAll:e,get:n,getLte:t,getGte:i}}var nh=[y.EventActionTypes.expect,y.EventActionTypes.setNextBranch],oh=1/0;function gs(r,e){let t=r,i,n=ah(e),o=vs(),s,a=()=>{v(),u()},l=h=>{o.add.call(void 0,h),k()},c=(h=[])=>{for(let f of h)if(f.action(),(0,bs.default)(nh,f.actionType))break},d=(h=1/0)=>{let f=qt(o.get({timestamp:h,priority:"control"})??{}),E=qt(o.get({timestamp:h,priority:"container"})??{}),T=qt(o.get({timestamp:h,priority:"chapter"})??{});return[...f,...E,...T]},m=h=>{n.isReady(h)&&c(d(h))},b=()=>{c([...qt(o.get({timestamp:1/0,priority:"chapter"})??{})])},v=()=>{i&&(s?.unsubscribe(),i=void 0)},k=()=>{i||(i=()=>setTimeout(()=>{m(1/0)}),s=t.events.ended$.subscribe(i))},I=h=>{v(),t=h},g=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),o.remove(h)},u=()=>{n.release(),o.removeAll()};return{setPlayer:I,add:l,remove:g,exec:m,execEndOfVideo:b,listen:k,unlisten:v,release:a,containersEventsCallState:n,getPreparedToExecActions:d}}function ah(r){let e=new Map;return{setCalled:({timestamp:a,id:l})=>{let c=e.get(a);c&&c[l]!==void 0&&(c[l]=!0)},setData:(a=[])=>{for(let l of a){let c=l.endTime??oh,d=e.get(c);e.set(c,{...d,[l.id]:!1})}},resetCalled:a=>{let l=e.get(a);if(l)for(let c in l)l[c]=!1},isReady:a=>{let l=e.get(a);if(!l)return!0;let c=(0,ti.default)(l);return r?c.some(m=>m):!c.some(m=>!m)},release:()=>e.clear()}}function qt(r){return(0,ys.default)((0,ti.default)(r)).sort(e=>e.actionType===y.EventActionTypes.expect?-1:1)}var Cs={videoContentHeight:0,videoContentWidth:0},Es=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Cs;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return Cs;let o=e/t,s=i/n,a,l;return s>o?(l=n,a=n*o):s<o?(l=i/o,a=i):(l=n,a=i),{videoContentWidth:l,videoContentHeight:a}};var sh=250;function Ts(r){let e,t=new ResizeObserver(a=>{o(a),e=o.bind(null,a)});function i(a){let{parentElement:l,player:c}=r();if(l&&c){let{videoContentWidth:d,videoContentHeight:m}=Es(c);l.style.setProperty("--interactive-content-width",`${d}px`),l.style.setProperty("--interactive-content-height",`${m}px`),l.style.setProperty("--interactive-width",`${a[0].contentRect.width}px`),l.style.setProperty("--interactive-height",`${a[0].contentRect.height}px`)}}function n(){let{parentElement:a}=r();a.removeAttribute("style")}let o=De(a=>{let{fns:l=[]}=r();i(a);for(let c of l)c()},sh);function s(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e?.()},release:s}}var lh=r=>Math.floor(Math.random()*r),xs=r=>{let e=r.length,t=1/0,i=null;for(;e--;){let n=r[e],o=n.weight??1;o<t&&(t=o,i=n)}return i},As=r=>{let e=r.length,t=-1/0,i=null;for(;e--;){let n=r[e],o=n.weight??0;o>t&&(t=o,i=n)}return i};var ws=r=>{let e=r.length,t=lh(e);return r[t]},Is=1,Ss=r=>{let e=0;for(let i=0;i<r.length;++i)e+=r[i].weight??Is;let t=Math.random()*e;e=0;for(let i=0;i<r.length-1;++i)if(e+=r[i].weight??Is,e>=t)return r[i];return r[r.length-1]};var Rs={shouldOpenNow:!0,isDetachContainer:!0},ks="after-expect",ri=(r,e=!1)=>({...r,args:e?{...r.args,...Rs}:{...Rs,...r.args}}),Os=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},s=({action:u,controlType:h,controlId:f,containerId:E,branches:T=[],onEvent:x,isEOV:S=()=>!1,isDisabled:_=()=>!1})=>{let A=ri(u,S()),L={timestamp:1/0,priority:"control",initiator:f,actionType:A.type},M=_(),z=r.emit.bind(r,w.interactives,{subjectId:f,subjectType:h,subjectName:"control",type:M?P.actionChoiceCanceled:P.actionChoice,actionType:u.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:E,...A.args}}),ne=()=>{e.interactiveActionChoice$.next({subjectId:f,subjectType:h,subjectName:"control",type:M?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:A.args.shouldOpenNow,containerId:E,...A.args}})};if(M){z(),ne();return}switch(A.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let j=T.find(ue=>ue.id===A.args.branchId);if(!j)return;x(A.args.isDetachContainer,v.bind(null,{subjectId:f,subjectName:"control"})),z(),ne(),A.args.shouldOpenNow?I({subjectId:f,subjectName:"control",subjectType:h,action:A,payload:{chapterId:j.chapterId,autoSelect:!1}}):i.add({...L,action:I.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:A,payload:{chapterId:j.chapterId,autoSelect:!1}})});return}case y.EventActionTypes.continuePlayback.trim().toLowerCase():{x(A.args.isDetachContainer,v.bind(null,{subjectId:f,subjectName:"control"})),z(),ne(),A.args.shouldOpenNow?k({subjectId:f,subjectName:"control",subjectType:h,action:u}):i.add({...L,action:k.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:u})});return}case y.EventActionTypes.openURI.trim().toLowerCase():{x(A.args.isDetachContainer,v.bind(null,{subjectId:f,subjectName:"control"})),z(),ne(),A.args.shouldOpenNow?g({subjectId:f,subjectName:"control",subjectType:h,action:A,payload:{URI:u.args.uri}}):i.add({...L,action:g.bind(null,{subjectId:f,subjectName:"control",subjectType:h,action:A,payload:{URI:u.args.uri}})});return}default:{let j="Unexpected control event",ue=new F(1,1,{message:j});d(ue,j);return}}},a=({action:u,container:{id:h,endTime:f},branches:E=[],isEOV:T=!1,autoSelected:x=!1})=>{let S=ri(u,T),_={timestamp:!S.args.shouldOpenNow||T?1/0:f??1/0,priority:"container",initiator:h,actionType:S.type},A=r.emit.bind(r,w.interactives,{subjectId:h,subjectName:"container",type:P.actionChoice,actionType:S.type,payload:{invokeImmediately:S.args.shouldOpenNow,...S.args}}),L=()=>{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 y.EventActionTypes.setNextBranch.trim().toLowerCase():{let M=E.find(z=>z.id===S.args.branchId);if(!M)return;A(),L(),i.add({..._,action:I.bind(null,{subjectId:h,subjectName:"container",action:S,payload:{chapterId:M.chapterId,autoSelect:x}})});return}case y.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case y.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case y.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case y.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case y.EventActionTypes.continuePlayback.trim().toLowerCase():{A(),L(),i.add({..._,action:k.bind(null,{subjectId:h,subjectName:"container",action:S})});return}case y.EventActionTypes.openURI.trim().toLowerCase():{A(),L(),i.add({..._,action:g.bind(null,{subjectId:h,subjectName:"container",action:S,payload:{URI:u.args.uri}})});return}default:{let M="Unexpected container event",z=new F(1,1,{message:M});d(z,M);return}}};function l({container:u,branches:h,isEOV:f=!1}){let E=Fr(u.events);if(E){let T=ri(E.action,f);r.emit(w.interactives,{subjectId:u.id,subjectName:"container",type:P.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),i.add({timestamp:f?1/0:u.endTime??1/0,priority:"container",initiator:u.id,actionType:y.EventActionTypes.expect,action:b.bind(null,{subjectId:u.id,subjectName:"container"})}),n.isExpect=!0}else for(let T of u.events??[])a({action:T.action,container:u,branches:h,isEOV:f})}let c=({chapterId:u,action:h,branches:f=[]})=>{let E=r.emit.bind(r,w.interactives,{subjectId:u,subjectName:"chapter",type:P.actionChoice,actionType:h.type,payload:h.args}),T=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let x=f.find(S=>S.id===h.args.branchId);return x?.chapterId?(E(),T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let x=ws(f);return x?.chapterId?(E(),T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setRandomBranch.trim().toLowerCase():{let x=Ss(f);return x?.chapterId?(E(),T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let x=As(f);return x?.chapterId?(E(),T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let x=xs(f);return x?.chapterId?(E(),T(),I.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.continuePlayback.trim().toLowerCase():return E(),T(),k.bind(null,{subjectId:u,subjectName:"chapter",action:h});case y.EventActionTypes.openURI.trim().toLowerCase():return E(),T(),g.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let x="Unexpected chapter event",S=new F(1,1,{message:x});d(S,x);return}}};function d(u,h){console.error(h),e.error$.next(u),r.emit(w.errors,u)}function m(u){let h=Fr(u.events);if(h){if(G(u))return;r.emit(w.interactives,{subjectId:u.id,subjectName:"chapter",type:P.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:y.EventActionTypes.expect,action:b.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else u.events?.forEach(f=>{let E=c({chapterId:u.id,action:f.action,branches:u.branches});E&&i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:f.action.type,action:E})})}let b=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(w.interactives,{subjectId:u,subjectName:h,type:P.actionExecution,actionType:y.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:y.EventActionTypes.expect})},v=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(w.interactives,{subjectId:u,subjectName:h,type:P.actionExecution,actionType:ks}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:ks})},k=({subjectId:u,subjectName:h,subjectType:f,action:E})=>{r.emit(w.interactives,{subjectId:u,subjectName:h,subjectType:f,type:P.actionExecution,actionType:E.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:E.type})},I=({subjectId:u,subjectName:h,subjectType:f,action:E,payload:T})=>{T.behaviour="change-chapter",r.emit(w.interactives,{subjectId:u,subjectName:h,subjectType:f,type:P.actionExecution,actionType:E.type,payload:T}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:E.type,payload:T})},g=({subjectId:u,subjectName:h,subjectType:f,action:E,payload:T})=>{if(!T.URI)return;let x=window.open(T.URI,"_blank","noopener,noreferrer");x&&(x.opener=null),r.emit(w.interactives,{subjectId:u,subjectName:h,subjectType:f,type:P.actionExecution,actionType:E.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:f,type:"action-execution",actionType:E.type})};return{onControlEvent:s,onContainerEvent:a,onChapterEvent:c,onExpectEvent:b,expectEventHandler:v,setManifestChapterEvents:m,setManifestContainerEvents:l,stopExpect:o,state:n}};var oi=W(qr(),1),D=require("@vkontakte/videoplayer-shared");var Dt=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(s=>s.id===i);if(!n)return null;let o=e.media.videos.find(s=>n.videoId===s.id);if(!o)return null;t[i]=ii(o)}return t[i]}).filter(Boolean)},Ps=r=>{for(let e of r.variants)if(Ls(e)&&e.payload)return e.payload.id},Ls=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),ii=r=>{let e=Ps(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Fs=(r,e)=>{for(let t of r.media.videos)if(e===ii(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},ni=(r,e)=>r.reduce((t,i)=>{let n=Fs(e,i);return n?[...t,n]:t},[]);var Ye=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new D.ValueSubject([]),hasPrevChapter$:new D.ValueSubject(!1),prevChapter$:new D.ValueSubject(null),isInitialChapter$:new D.ValueSubject(!1),isGoBackLimited$:new D.ValueSubject(!1)};this.#r=null;this.#a=!1;this.#e=null;this.#p=null;this.events={inited$:new D.Subject,destroyed$:new D.Subject,error$:new D.Subject};this.#i=null;this.#n=null;this.#t=null;this.#s=new D.Subscription;this.#l=!1;this.#c=0;this.#i=t,this.#t=e,this.#n=i,this.#r=n,this.#o=o,this.state.history$&&this.#s&&this.#s?.add(this.state.history$.subscribe(s=>{this.state.prevChapter$.next((0,oi.default)(s,-2)||null),this.state.hasPrevChapter$.next(s.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===this.#e?.metadata?.initChapterId),this.state.isGoBackLimited$.next(this.#c===this.#o.maxLength-1)}))}#r;#o;#a;#e;#p;#i;#n;#t;#s;#l;#c;async setManifest(e){if(!this.#n||!this.#t)return;this.#e=e,await this.getProjectHistory();let t=this.getInitialChapterId();await this.#n.setChapter({chapterId:t,pushToHistory:!1}),this.#a||(this.#a=!0,this.events.inited$.next({initChapterId:t}))}get inited(){return this.#a}async updateHistory(e,t=!0){if(!this.#e)return;this.#l?(this.#l=!1,this.#c++):this.#c=0;let i=this.#e,n=e.length-this.#o.maxLength,o=n>0?e.slice(n):e,s=Dt(o,i);if(this.#p=s,this.state.history$.next(o),!(!t||!this.#r||!this.#i))try{await this.#r.save(this.#i,s)}catch{let l=new F(1,5,"Unable to save interactive history");this.events.error$.next(l),this.#t?.emit(w.errors,l)}}async goBack(){if(!this.state||!this.#n){let i=new F(1,5,"Unable to save interactive history");return this.events.error$.next(i),this.#t?.emit(w.errors,i)}this.#l=!0;let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await this.#n.setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){if(!this.#e||!this.#i)return;let e=this.#e,t=[this.getInitialVideoId()];if(this.#r)try{let n=await this.#r.get(this.#i);n.length&&(t=n)}catch{let o=new F(1,5,"Error while trying to fetch data");this.events.error$.next(o),this.#t?.emit(w.errors,o)}let i=ni(t,e);this.state.history$.next(i)}getInitialChapterId(){let e=this.state.history$.getValue();return(0,oi.default)(e,-1)||this.#o.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return Dt([e],this.#e).pop()}return null}destroy(){this.#i=null,this.#r=null,this.#n=null,this.#s?.unsubscribe(),this.#s=null,this.#a=!1,this.#t?.emit(w.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var Ht=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 t=e.data,i=t.length;for(let n=3;n<i;n+=40)if(t[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,t=!1){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){this.rootElement&&this.rootElement.getContext("2d")?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}};var Ut=class{constructor({parentElement:e,endOffsetMs:t=250,onError:i}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,i=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(i)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
7
7
  position: absolute;
8
8
  top: 0;
9
9
  left: 0;