@vkontakte/videoplayer-interactive 1.0.39-dev.2be73400.0 → 1.0.39-dev.6edf3cda.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +76 -6
- package/es2015.esm.js +76 -6
- package/es2018.cjs.js +76 -6
- package/es2018.esm.js +76 -6
- package/es2024.cjs.js +76 -6
- package/es2024.esm.js +76 -6
- package/esnext.cjs.js +76 -6
- package/esnext.esm.js +76 -6
- package/evergreen.esm.js +76 -6
- package/package.json +4 -4
- package/types/modules/Interactives/containers/ChoiceContainer.d.ts +2 -1
- package/types/modules/Interactives/containers/types.d.ts +2 -1
- package/types/modules/Interactives/controls/AreaControl.d.ts +2 -0
- package/types/modules/Interactives/controls/ButtonControl.d.ts +7 -1
- package/types/modules/Interactives/controls/Control.d.ts +2 -0
- package/types/modules/Interactives/controls/TextControl.d.ts +2 -0
- package/types/modules/Interactives/controls/types.d.ts +1 -1
- package/types/modules/Interactives/index.d.ts +8 -1
- package/types/modules/Interactives/types.d.ts +2 -0
- package/types/modules/Interactives/utils/ControlFillAnimation/ControlFillAnimation.d.ts +34 -0
- package/types/modules/Interactives/utils/ControlFillAnimation/index.d.ts +1 -0
- package/types/modules/Interactives/utils/ControlFillAnimation/utils.d.ts +12 -0
- package/types/modules/Interactives/utils/GameController.d.ts +3 -1
- package/types/modules/Interactives/utils/angleUtils.d.ts +23 -0
package/es2024.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.39-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.39-dev.6edf3cda.0
|
|
3
|
+
* Mon, 09 Jun 2025 10:20:24 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-39/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var Ra=Object.create;var Ze=Object.defineProperty;var ka=Object.getOwnPropertyDescriptor;var Oa=Object.getOwnPropertyNames;var Pa=Object.getPrototypeOf,Va=Object.prototype.hasOwnProperty;var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ma=(r,e)=>{for(var t in e)Ze(r,t,{get:e[t],enumerable:!0})},rn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Oa(e))!Va.call(r,i)&&i!==t&&Ze(r,i,{get:()=>e[i],enumerable:!(n=ka(e,i))||n.enumerable});return r};var D=(r,e,t)=>(t=r!=null?Ra(Pa(r)):{},rn(e||!r||!r.__esModule?Ze(t,"default",{value:r,enumerable:!0}):t,r)),La=r=>rn(Ze({},"__esModule",{value:!0}),r);var Q=p((er,fn)=>{"use strict";var we=function(r){return r&&r.Math===Math&&r};fn.exports=we(typeof globalThis=="object"&&globalThis)||we(typeof window=="object"&&window)||we(typeof self=="object"&&self)||we(typeof global=="object"&&global)||we(typeof er=="object"&&er)||function(){return this}()||Function("return this")()});var F=p((dd,vn)=>{"use strict";vn.exports=function(r){try{return!!r()}catch{return!0}}});var Ae=p((md,yn)=>{"use strict";var $a=F();yn.exports=!$a(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var In=p((fd,En)=>{"use strict";var ja=Ae(),gn=Function.prototype,bn=gn.apply,Cn=gn.call;En.exports=typeof Reflect=="object"&&Reflect.apply||(ja?Cn.bind(bn):function(){return Cn.apply(bn,arguments)})});var H=p((vd,Sn)=>{"use strict";var xn=Ae(),Tn=Function.prototype,tr=Tn.call,Fa=xn&&Tn.bind.bind(tr,tr);Sn.exports=xn?Fa:function(r){return function(){return tr.apply(r,arguments)}}});var Re=p((yd,An)=>{"use strict";var wn=H(),Ba=wn({}.toString),qa=wn("".slice);An.exports=function(r){return qa(Ba(r),8,-1)}});var rr=p((bd,Rn)=>{"use strict";var Da=Re(),Ha=H();Rn.exports=function(r){if(Da(r)==="Function")return Ha(r)}});var B=p((Cd,kn)=>{"use strict";var nr=typeof document=="object"&&document.all;kn.exports=typeof nr>"u"&&nr!==void 0?function(r){return typeof r=="function"||r===nr}:function(r){return typeof r=="function"}});var oe=p((gd,On)=>{"use strict";var Ua=F();On.exports=!Ua(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var mt=p((Ed,Pn)=>{"use strict";var Ga=Ae(),dt=Function.prototype.call;Pn.exports=Ga?dt.bind(dt):function(){return dt.apply(dt,arguments)}});var ir=p(Ln=>{"use strict";var Vn={}.propertyIsEnumerable,Mn=Object.getOwnPropertyDescriptor,za=Mn&&!Vn.call({1:2},1);Ln.f=za?function(e){var t=Mn(this,e);return!!t&&t.enumerable}:Vn});var or=p((xd,Nn)=>{"use strict";Nn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var $n=p((Td,_n)=>{"use strict";var Wa=H(),Ka=F(),Qa=Re(),sr=Object,Xa=Wa("".split);_n.exports=Ka(function(){return!sr("z").propertyIsEnumerable(0)})?function(r){return Qa(r)==="String"?Xa(r,""):sr(r)}:sr});var ar=p((Sd,jn)=>{"use strict";jn.exports=function(r){return r==null}});var lr=p((wd,Fn)=>{"use strict";var Ya=ar(),Za=TypeError;Fn.exports=function(r){if(Ya(r))throw new Za("Can't call method on "+r);return r}});var ke=p((Ad,Bn)=>{"use strict";var Ja=$n(),el=lr();Bn.exports=function(r){return Ja(el(r))}});var me=p((Rd,qn)=>{"use strict";var tl=B();qn.exports=function(r){return typeof r=="object"?r!==null:tl(r)}});var ft=p((kd,Dn)=>{"use strict";Dn.exports={}});var vt=p((Od,Un)=>{"use strict";var cr=ft(),pr=Q(),rl=B(),Hn=function(r){return rl(r)?r:void 0};Un.exports=function(r,e){return arguments.length<2?Hn(cr[r])||Hn(pr[r]):cr[r]&&cr[r][e]||pr[r]&&pr[r][e]}});var zn=p((Pd,Gn)=>{"use strict";var nl=H();Gn.exports=nl({}.isPrototypeOf)});var Xn=p((Vd,Qn)=>{"use strict";var il=Q(),Wn=il.navigator,Kn=Wn&&Wn.userAgent;Qn.exports=Kn?String(Kn):""});var ni=p((Md,ri)=>{"use strict";var ti=Q(),ur=Xn(),Yn=ti.process,Zn=ti.Deno,Jn=Yn&&Yn.versions||Zn&&Zn.version,ei=Jn&&Jn.v8,U,yt;ei&&(U=ei.split("."),yt=U[0]>0&&U[0]<4?1:+(U[0]+U[1]));!yt&&ur&&(U=ur.match(/Edge\/(\d+)/),(!U||U[1]>=74)&&(U=ur.match(/Chrome\/(\d+)/),U&&(yt=+U[1])));ri.exports=yt});var hr=p((Ld,oi)=>{"use strict";var ii=ni(),ol=F(),sl=Q(),al=sl.String;oi.exports=!!Object.getOwnPropertySymbols&&!ol(function(){var r=Symbol("symbol detection");return!al(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&ii&&ii<41})});var dr=p((Nd,si)=>{"use strict";var ll=hr();si.exports=ll&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var mr=p((_d,ai)=>{"use strict";var cl=vt(),pl=B(),ul=zn(),hl=dr(),dl=Object;ai.exports=hl?function(r){return typeof r=="symbol"}:function(r){var e=cl("Symbol");return pl(e)&&ul(e.prototype,dl(r))}});var ci=p(($d,li)=>{"use strict";var ml=String;li.exports=function(r){try{return ml(r)}catch{return"Object"}}});var fr=p((jd,pi)=>{"use strict";var fl=B(),vl=ci(),yl=TypeError;pi.exports=function(r){if(fl(r))return r;throw new yl(vl(r)+" is not a function")}});var hi=p((Fd,ui)=>{"use strict";var bl=fr(),Cl=ar();ui.exports=function(r,e){var t=r[e];return Cl(t)?void 0:bl(t)}});var mi=p((Bd,di)=>{"use strict";var vr=mt(),yr=B(),br=me(),gl=TypeError;di.exports=function(r,e){var t,n;if(e==="string"&&yr(t=r.toString)&&!br(n=vr(t,r))||yr(t=r.valueOf)&&!br(n=vr(t,r))||e!=="string"&&yr(t=r.toString)&&!br(n=vr(t,r)))return n;throw new gl("Can't convert object to primitive value")}});var vi=p((qd,fi)=>{"use strict";fi.exports=!0});var Ci=p((Dd,bi)=>{"use strict";var yi=Q(),El=Object.defineProperty;bi.exports=function(r,e){try{El(yi,r,{value:e,configurable:!0,writable:!0})}catch{yi[r]=e}return e}});var bt=p((Hd,Ii)=>{"use strict";var Il=vi(),xl=Q(),Tl=Ci(),gi="__core-js_shared__",Ei=Ii.exports=xl[gi]||Tl(gi,{});(Ei.versions||(Ei.versions=[])).push({version:"3.38.0",mode:Il?"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 Cr=p((Ud,Ti)=>{"use strict";var xi=bt();Ti.exports=function(r,e){return xi[r]||(xi[r]=e||{})}});var Oe=p((Gd,Si)=>{"use strict";var Sl=lr(),wl=Object;Si.exports=function(r){return wl(Sl(r))}});var fe=p((zd,wi)=>{"use strict";var Al=H(),Rl=Oe(),kl=Al({}.hasOwnProperty);wi.exports=Object.hasOwn||function(e,t){return kl(Rl(e),t)}});var gr=p((Wd,Ai)=>{"use strict";var Ol=H(),Pl=0,Vl=Math.random(),Ml=Ol(1 .toString);Ai.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Ml(++Pl+Vl,36)}});var Pe=p((Kd,ki)=>{"use strict";var Ll=Q(),Nl=Cr(),Ri=fe(),_l=gr(),$l=hr(),jl=dr(),ve=Ll.Symbol,Er=Nl("wks"),Fl=jl?ve.for||ve:ve&&ve.withoutSetter||_l;ki.exports=function(r){return Ri(Er,r)||(Er[r]=$l&&Ri(ve,r)?ve[r]:Fl("Symbol."+r)),Er[r]}});var Mi=p((Qd,Vi)=>{"use strict";var Bl=mt(),Oi=me(),Pi=mr(),ql=hi(),Dl=mi(),Hl=Pe(),Ul=TypeError,Gl=Hl("toPrimitive");Vi.exports=function(r,e){if(!Oi(r)||Pi(r))return r;var t=ql(r,Gl),n;if(t){if(e===void 0&&(e="default"),n=Bl(t,r,e),!Oi(n)||Pi(n))return n;throw new Ul("Can't convert object to primitive value")}return e===void 0&&(e="number"),Dl(r,e)}});var Ir=p((Xd,Li)=>{"use strict";var zl=Mi(),Wl=mr();Li.exports=function(r){var e=zl(r,"string");return Wl(e)?e:e+""}});var $i=p((Yd,_i)=>{"use strict";var Kl=Q(),Ni=me(),xr=Kl.document,Ql=Ni(xr)&&Ni(xr.createElement);_i.exports=function(r){return Ql?xr.createElement(r):{}}});var Tr=p((Zd,ji)=>{"use strict";var Xl=oe(),Yl=F(),Zl=$i();ji.exports=!Xl&&!Yl(function(){return Object.defineProperty(Zl("div"),"a",{get:function(){return 7}}).a!==7})});var qi=p(Bi=>{"use strict";var Jl=oe(),ec=mt(),tc=ir(),rc=or(),nc=ke(),ic=Ir(),oc=fe(),sc=Tr(),Fi=Object.getOwnPropertyDescriptor;Bi.f=Jl?Fi:function(e,t){if(e=nc(e),t=ic(t),sc)try{return Fi(e,t)}catch{}if(oc(e,t))return rc(!ec(tc.f,e,t),e[t])}});var Hi=p((em,Di)=>{"use strict";var ac=F(),lc=B(),cc=/#|\.prototype\./,Ve=function(r,e){var t=uc[pc(r)];return t===dc?!0:t===hc?!1:lc(e)?ac(e):!!e},pc=Ve.normalize=function(r){return String(r).replace(cc,".").toLowerCase()},uc=Ve.data={},hc=Ve.NATIVE="N",dc=Ve.POLYFILL="P";Di.exports=Ve});var Sr=p((tm,Gi)=>{"use strict";var Ui=rr(),mc=fr(),fc=Ae(),vc=Ui(Ui.bind);Gi.exports=function(r,e){return mc(r),e===void 0?r:fc?vc(r,e):function(){return r.apply(e,arguments)}}});var Wi=p((rm,zi)=>{"use strict";var yc=oe(),bc=F();zi.exports=yc&&bc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Qi=p((nm,Ki)=>{"use strict";var Cc=me(),gc=String,Ec=TypeError;Ki.exports=function(r){if(Cc(r))return r;throw new Ec(gc(r)+" is not an object")}});var Zi=p(Yi=>{"use strict";var Ic=oe(),xc=Tr(),Tc=Wi(),Ct=Qi(),Xi=Ir(),Sc=TypeError,wr=Object.defineProperty,wc=Object.getOwnPropertyDescriptor,Ar="enumerable",Rr="configurable",kr="writable";Yi.f=Ic?Tc?function(e,t,n){if(Ct(e),t=Xi(t),Ct(n),typeof e=="function"&&t==="prototype"&&"value"in n&&kr in n&&!n[kr]){var i=wc(e,t);i&&i[kr]&&(e[t]=n.value,n={configurable:Rr in n?n[Rr]:i[Rr],enumerable:Ar in n?n[Ar]:i[Ar],writable:!1})}return wr(e,t,n)}:wr:function(e,t,n){if(Ct(e),t=Xi(t),Ct(n),xc)try{return wr(e,t,n)}catch{}if("get"in n||"set"in n)throw new Sc("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var eo=p((om,Ji)=>{"use strict";var Ac=oe(),Rc=Zi(),kc=or();Ji.exports=Ac?function(r,e,t){return Rc.f(r,e,kc(1,t))}:function(r,e,t){return r[e]=t,r}});var Le=p((sm,ro)=>{"use strict";var Me=Q(),Oc=In(),Pc=rr(),Vc=B(),Mc=qi().f,Lc=Hi(),ye=ft(),Nc=Sr(),be=eo(),to=fe();bt();var _c=function(r){var e=function(t,n,i){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,n)}return new r(t,n,i)}return Oc(r,this,arguments)};return e.prototype=r.prototype,e};ro.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,o=r.proto,l=n?Me:i?Me[t]:Me[t]&&Me[t].prototype,s=n?ye:ye[t]||be(ye,t,{})[t],a=s.prototype,c,d,f,v,y,k,w,C,u;for(v in e)c=Lc(n?v:t+(i?".":"#")+v,r.forced),d=!c&&l&&to(l,v),k=s[v],d&&(r.dontCallGetSet?(u=Mc(l,v),w=u&&u.value):w=l[v]),y=d&&w?w:e[v],!(!c&&!o&&typeof k==typeof y)&&(r.bind&&d?C=Nc(y,Me):r.wrap&&d?C=_c(y):o&&Vc(y)?C=Pc(y):C=y,(r.sham||y&&y.sham||k&&k.sham)&&be(C,"sham",!0),be(s,v,C),o&&(f=t+"Prototype",to(ye,f)||be(ye,f,{}),be(ye[f],v,y),r.real&&a&&(c||!a[v])&&be(a,v,y)))}});var io=p((am,no)=>{"use strict";var $c=Math.ceil,jc=Math.floor;no.exports=Math.trunc||function(e){var t=+e;return(t>0?jc:$c)(t)}});var Ne=p((lm,oo)=>{"use strict";var Fc=io();oo.exports=function(r){var e=+r;return e!==e||e===0?0:Fc(e)}});var ao=p((cm,so)=>{"use strict";var Bc=Ne(),qc=Math.min;so.exports=function(r){var e=Bc(r);return e>0?qc(e,9007199254740991):0}});var _e=p((pm,lo)=>{"use strict";var Dc=ao();lo.exports=function(r){return Dc(r.length)}});var gt=p((um,co)=>{"use strict";co.exports=function(){}});var po=p(()=>{"use strict";var Hc=Le(),Uc=Oe(),Gc=_e(),zc=Ne(),Wc=gt();Hc({target:"Array",proto:!0},{at:function(e){var t=Uc(this),n=Gc(t),i=zc(e),o=i>=0?i:n+i;return o<0||o>=n?void 0:t[o]}});Wc("at")});var Et=p((mm,uo)=>{"use strict";var Kc=vt();uo.exports=Kc});var mo=p((fm,ho)=>{"use strict";po();var Qc=Et();ho.exports=Qc("Array","at")});var vo=p((vm,fo)=>{"use strict";var Xc=mo();fo.exports=Xc});var Or=p((ym,yo)=>{"use strict";var Yc=vo();yo.exports=Yc});var wo=p((nf,So)=>{"use strict";var pp=Ne(),up=Math.max,hp=Math.min;So.exports=function(r,e){var t=pp(r);return t<0?up(t+e,0):hp(t,e)}});var $r=p((of,Ro)=>{"use strict";var dp=ke(),mp=wo(),fp=_e(),Ao=function(r){return function(e,t,n){var i=dp(e),o=fp(i);if(o===0)return!r&&-1;var l=mp(n,o),s;if(r&&t!==t){for(;o>l;)if(s=i[l++],s!==s)return!0}else for(;o>l;l++)if((r||l in i)&&i[l]===t)return r||l||0;return!r&&-1}};Ro.exports={includes:Ao(!0),indexOf:Ao(!1)}});var ko=p(()=>{"use strict";var vp=Le(),yp=$r().includes,bp=F(),Cp=gt(),gp=bp(function(){return!Array(1).includes()});vp({target:"Array",proto:!0,forced:gp},{includes:function(e){return yp(this,e,arguments.length>1?arguments[1]:void 0)}});Cp("includes")});var Po=p((lf,Oo)=>{"use strict";ko();var Ep=Et();Oo.exports=Ep("Array","includes")});var Mo=p((cf,Vo)=>{"use strict";var Ip=Po();Vo.exports=Ip});var Ue=p((pf,Lo)=>{"use strict";var xp=Mo();Lo.exports=xp});var Do=p((gf,qo)=>{"use strict";var Sp=Cr(),wp=gr(),Bo=Sp("keys");qo.exports=function(r){return Bo[r]||(Bo[r]=wp(r))}});var Uo=p((Ef,Ho)=>{"use strict";var Ap=F();Ho.exports=!Ap(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Wo=p((If,zo)=>{"use strict";var Rp=fe(),kp=B(),Op=Oe(),Pp=Do(),Vp=Uo(),Go=Pp("IE_PROTO"),Br=Object,Mp=Br.prototype;zo.exports=Vp?Br.getPrototypeOf:function(r){var e=Op(r);if(Rp(e,Go))return e[Go];var t=e.constructor;return kp(t)&&e instanceof t?t.prototype:e instanceof Br?Mp:null}});var Qo=p((xf,Ko)=>{"use strict";Ko.exports={}});var Zo=p((Tf,Yo)=>{"use strict";var Lp=H(),qr=fe(),Np=ke(),_p=$r().indexOf,$p=Qo(),Xo=Lp([].push);Yo.exports=function(r,e){var t=Np(r),n=0,i=[],o;for(o in t)!qr($p,o)&&qr(t,o)&&Xo(i,o);for(;e.length>n;)qr(t,o=e[n++])&&(~_p(i,o)||Xo(i,o));return i}});var es=p((Sf,Jo)=>{"use strict";Jo.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var rs=p((wf,ts)=>{"use strict";var jp=Zo(),Fp=es();ts.exports=Object.keys||function(e){return jp(e,Fp)}});var ls=p((Af,as)=>{"use strict";var is=oe(),Bp=F(),os=H(),qp=Wo(),Dp=rs(),Hp=ke(),Up=ir().f,ss=os(Up),Gp=os([].push),zp=is&&Bp(function(){var r=Object.create(null);return r[2]=2,!ss(r,2)}),ns=function(r){return function(e){for(var t=Hp(e),n=Dp(t),i=zp&&qp(t)===null,o=n.length,l=0,s=[],a;o>l;)a=n[l++],(!is||(i?a in t:ss(t,a)))&&Gp(s,r?[a,t[a]]:t[a]);return s}};as.exports={entries:ns(!0),values:ns(!1)}});var cs=p(()=>{"use strict";var Wp=Le(),Kp=ls().values;Wp({target:"Object",stat:!0},{values:function(e){return Kp(e)}})});var us=p((Of,ps)=>{"use strict";cs();var Qp=ft();ps.exports=Qp.Object.values});var ds=p((Pf,hs)=>{"use strict";var Xp=us();hs.exports=Xp});var Vt=p((Vf,ms)=>{"use strict";var Yp=ds();ms.exports=Yp});var zr=p((Jf,xs)=>{"use strict";var Jp=Re();xs.exports=Array.isArray||function(e){return Jp(e)==="Array"}});var Ss=p((ev,Ts)=>{"use strict";var eu=TypeError,tu=9007199254740991;Ts.exports=function(r){if(r>tu)throw eu("Maximum allowed index exceeded");return r}});var Rs=p((tv,As)=>{"use strict";var ru=zr(),nu=_e(),iu=Ss(),ou=Sr(),ws=function(r,e,t,n,i,o,l,s){for(var a=i,c=0,d=l?ou(l,s):!1,f,v;c<n;)c in t&&(f=d?d(t[c],c,e):t[c],o>0&&ru(f)?(v=nu(f),a=ws(r,e,f,v,a,o-1)-1):(iu(a+1),r[a]=f),a++),c++;return a};As.exports=ws});var Ps=p((rv,Os)=>{"use strict";var su=Pe(),au=su("toStringTag"),ks={};ks[au]="z";Os.exports=String(ks)==="[object z]"});var Ms=p((nv,Vs)=>{"use strict";var lu=Ps(),cu=B(),Lt=Re(),pu=Pe(),uu=pu("toStringTag"),hu=Object,du=Lt(function(){return arguments}())==="Arguments",mu=function(r,e){try{return r[e]}catch{}};Vs.exports=lu?Lt:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=mu(e=hu(r),uu))=="string"?t:du?Lt(e):(n=Lt(e))==="Object"&&cu(e.callee)?"Arguments":n}});var Ns=p((iv,Ls)=>{"use strict";var fu=H(),vu=B(),Wr=bt(),yu=fu(Function.toString);vu(Wr.inspectSource)||(Wr.inspectSource=function(r){return yu(r)});Ls.exports=Wr.inspectSource});var qs=p((ov,Bs)=>{"use strict";var bu=H(),Cu=F(),_s=B(),gu=Ms(),Eu=vt(),Iu=Ns(),$s=function(){},js=Eu("Reflect","construct"),Kr=/^\s*(?:class|function)\b/,xu=bu(Kr.exec),Tu=!Kr.test($s),Ke=function(e){if(!_s(e))return!1;try{return js($s,[],e),!0}catch{return!1}},Fs=function(e){if(!_s(e))return!1;switch(gu(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Tu||!!xu(Kr,Iu(e))}catch{return!0}};Fs.sham=!0;Bs.exports=!js||Cu(function(){var r;return Ke(Ke.call)||!Ke(Object)||!Ke(function(){r=!0})||r})?Fs:Ke});var Gs=p((sv,Us)=>{"use strict";var Ds=zr(),Su=qs(),wu=me(),Au=Pe(),Ru=Au("species"),Hs=Array;Us.exports=function(r){var e;return Ds(r)&&(e=r.constructor,Su(e)&&(e===Hs||Ds(e.prototype))?e=void 0:wu(e)&&(e=e[Ru],e===null&&(e=void 0))),e===void 0?Hs:e}});var Ws=p((av,zs)=>{"use strict";var ku=Gs();zs.exports=function(r,e){return new(ku(r))(e===0?0:e)}});var Ks=p(()=>{"use strict";var Ou=Le(),Pu=Rs(),Vu=Oe(),Mu=_e(),Lu=Ne(),Nu=Ws();Ou({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Vu(this),n=Mu(t),i=Nu(t,0);return i.length=Pu(i,t,t,n,0,e===void 0?1:Lu(e)),i}})});var Qs=p(()=>{"use strict";var _u=gt();_u("flat")});var Ys=p((hv,Xs)=>{"use strict";Ks();Qs();var $u=Et();Xs.exports=$u("Array","flat")});var Js=p((dv,Zs)=>{"use strict";var ju=Ys();Zs.exports=ju});var ta=p((mv,ea)=>{"use strict";var Fu=Js();ea.exports=Fu});var Qu={};Ma(Qu,{ContainerTypes:()=>b.ContainerTypes,ControlTypes:()=>b.ControlTypes,CustomError:()=>M,EVENT_NAMES:()=>S,EventActionTypes:()=>b.EventActionTypes,EventTypes:()=>b.EventTypes,Interactives:()=>Xe,ManifestController:()=>le,SDKInfo:()=>Ku,chapterIdsToVKVideoIds:()=>_t,compareVersions:()=>Rt,containerTypes:()=>tp,controlTypes:()=>rp,eventActionTypes:()=>Vr,eventTypes:()=>np,getChapterIdByVkVideoId:()=>Ca,getVKVideoIdByMedia:()=>Yr,getVideoRawIdByMedia:()=>ya,graphEventTypes:()=>Ee,hasEndTemplate:()=>Ge,interactivesEventTypes:()=>O,isAreaControl:()=>ep,isButtonControl:()=>Jc,isLastChapter:()=>G,isOneTextCtrlContainer:()=>ae,isSupportedManifest:()=>b.isSupportedManifest,isTextControl:()=>Be,isVKVariantItem:()=>ba,isValidManifest:()=>Pr,migrateManifestToLatestVersion:()=>b.migrateManifestToLatestVersion,utils:()=>wa,vkVideoIdsToChapterIds:()=>Zr});module.exports=La(Qu);var nn="1.0.39-dev.2be73400.0";var ut=require("@vkontakte/videoplayer-shared/es2024");var Bt=class{constructor(e){this.layout=e}},Je=class extends Bt{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))`}};function on(r){return"features"in r}var ue=class{constructor(e,t){this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&on(this.options)&&this.options.features[e]}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 n=t.type.trim().toLowerCase(),i=this.factories.get(n);if(i){let o=i(t,this.options);if(o)return[...e,o]}return[...e]},[])||[]}};var ne=require("@vkontakte/videoplayer-shared/es2024");var X=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Y=r=>X(r,"Object"),et=r=>X(r,"String"),tt=r=>X(r,"Array"),rt=r=>X(r,"Number"),sn=r=>X(r,"Function"),an=r=>X(r,"Boolean"),qt=r=>rt(r)&&!isNaN(r);var te=r=>Y(r)&&Object.keys(r).length===0,Dt=r=>tt(r)&&!r.length;var xe=(r,e)=>et(r)&&(e?r.trim():r).length;function Te(r,e=1){let t="0",n="0",i="0";return r.length===4?(t="0x"+r[1]+r[1],n="0x"+r[2]+r[2],i="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],n="0x"+r[3]+r[4],i="0x"+r[5]+r[6]),`rgba(${+t},${+n},${+i},${e})`}var ln="interactive",P={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},cn=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(cn||{}),pn=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(pn||{}),un=(n=>(n.start="left",n.end="right",n.center="center",n))(un||{}),nt=({target:r,props:e})=>{r.style.alignItems=(e?.gravityVertical&&cn[e.gravityVertical])??"center",r.style.justifyContent=(e?.gravityHorizontal&&pn[e.gravityHorizontal])??"center",r.style.textAlign=(e?.alignment&&un[e.alignment])??"center"},it=({target:r,props:e,fallback:t,dependsOn:n})=>{r.style.color=e?.text?.color??t.textColor,r.style.fontSize=`calc(${n.height} * ${e?.text?.size??t.textSize})`,r.textContent=e?.text?.value??t.textContent},ot=({target:r,props:e,fallback:t})=>{r.style.backgroundColor=Te(e?.background?.color??t.backgroundColor,e?.background?.alpha??t.backgroundAlpha)},Se=({target:r,props:e,fallback:t,dependsOn:n,useRawValues:i=!1})=>{let o=i?t.borderWidthRawValue:`calc(${n.height} * ${e?.shape?.border?.width??t.borderWidth})`,l=i?t.roundCornersRawValue:`calc(${n.height} * ${e?.shape?.roundCorners??t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Te(i?t.borderColor:e?.shape?.border?.color??t.borderColor,i?t.borderAlpha:e?.shape?.border?.alpha??t.borderAlpha),r.style.borderRadius=l},hn=({target:r,isDark:e,baseDimension:t,fallback:n})=>{let l=Te(n.shadowColorLight,n.shadowColorAlpha),s=Te(n.shadowColorDark,n.shadowColorAlpha),a=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${a} ${c} ${e?s:l}`;r.style.boxShadow=d},he=({target:r,layoutParams:e,fallback:t})=>{let n=e.angle??t.angle;n=n&&n*-1,r.style.transform=`rotate(${n}rad)`};var K=require("@vkontakte/videoplayer-shared/es2024");var Ht="interactive-control-tap",de={common:Ht,animation:`${Ht}-animation`,visible:`${Ht}-visible`};var Na=60,st=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:n=Na,useDimensionsBasedSize:i=!1}){this.onElementClick=e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let n=t.getBoundingClientRect(),i={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},o=Math.min(i.width,i.height),l=n.left+n.width/2,s=n.top+n.height/2,a=e.clientX-l,c=e.clientY-s,d=_a(a,c,this.controlRotateAngleRad);this.element.style.width=o+"px",this.element.style.left=d.x+n.width/2-o/2+"px",this.element.style.top=d.y+n.height/2-o/2+"px",this.element.classList.add(de.visible,de.animation)};this.onAnimationEnd=e=>{!e.target||!e.currentTarget||e.target===e.currentTarget&&this.element.classList.remove(de.visible,de.animation)};let o=document.createElement("div");o.classList.add(de.common),this.controlRotateAngleRad=e,this.element=o,this.clickCancelCondition=t,this.circleDiameterPx=n,this.useDimensionsBasedSize=i}};function _a(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var Ut="int",re=(n=>(n.AREA=`${Ut}_area`,n.TEXT=`${Ut}_text`,n.BUTTON=`${Ut}_bttn`,n))(re||{});function Gt(r){return"features"in r}var W="interactive-control",R={common:W,selected:`${W}-selected`,wrapper:`${W}-wrapper`,disabled:`${W}-disabled`,button:`${W}-button`,area:`${W}-area`,text:`${W}-text`,blinkAnim:`${W}-blink-anim`,blinkAnimButton:`${W}-blink-anim-button`,blinkAnimArea:`${W}-blink-anim-area`},dn=40;var M=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var Z=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new K.Subscription;this.error$=new K.Subject;this.isInteracted$=new K.ValueSubject(!1)}onError(e="",t){let n=new M(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(n)}addControlTap(e){if(this.featureIsEnabled("controlsTapPlace")&&this.container){let t=this.control.layoutParams.angle??P.angle;this.controlTap=new st({controlRotateAngleRad:t,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?dn:void 0}),this.subscriptions.add((0,K.fromEvent)(e,"click").subscribe(this.controlTap.onElementClick,n=>this.onError("Control click tap animation error",n))).add((0,K.fromEvent)(this.controlTap.element,"animationend").subscribe(this.controlTap.onAnimationEnd,n=>this.onError("Tap animationend error",n))),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 n=(this.control.layoutParams.innerSizesDependOn??P.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"},i=()=>e.isContainerDisabled?.()??!1;this.container={element:t,dimensions:n,isManifestContainerDisabled:i}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted$.next(!0),e()}}featureIsEnabled(e){return this.options&&Gt(this.options)&&this.options.features[e]}isTouch(){return this.options&&Gt(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,K.fromEvent)(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),i=>this.onError("Error happened on control interaction",i)));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var Kt="interactive-blink-anim-reference",N={common:Kt,animation:`${Kt}-animation`,disabled:`${Kt}-disabled`},at=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(N.common,N.animation),this._element=e}restart(){this._element&&(this._element.classList.add(N.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(N.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var Qt="interactive-container",_={common:Qt,hidden:`${Qt}-hidden`,disabled:`${Qt}-disabled`};var lt=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Xt(r,e)},Xt=class extends Z{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(R.common,R.area),n.setAttribute("data-testid",re.AREA),ot({target:n,props:this.control.props,fallback:{...P,backgroundColor:"transparent"}}),he({target:n,layoutParams:this.control.layoutParams,fallback:P}),this.addControlTap(n),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.updateShadowStyles(),this.registerEvents()}registerEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,ne.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(_.disabled))return;let t=e.parentElement;if(t){let n=t.querySelector(`.${N.common}`);n&&this.syncBlinkAnimation(n)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,ne.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(_.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,ne.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(an(e)){let t=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";hn({target:this.controlElement,props:this.control.props,fallback:P,isDark:e,baseDimension:t}),Se({target:this.controlElement,props:this.control.props,fallback:{...P,borderColor:e?P.shadowColorDark:P.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${this.control.props?.shape?.roundCorners??P.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else Se({target:this.controlElement,props:this.control.props,fallback:{...P,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(N.disabled)||(this.controlElement.classList.add(N.disabled),this.subscriptions.add((0,ne.fromEvent)(e,"animationiteration").pipe((0,ne.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(N.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)})}onProgress(){}onResize(){}};var ie=require("@vkontakte/videoplayer-shared/es2024");var ct=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,n),t.append(e);let i={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,i),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 pt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new Yt(r,e)},Yt=class extends Z{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(R.common,R.button),n.setAttribute("data-testid",re.BUTTON),he({target:n,layoutParams:this.control.layoutParams,fallback:P}),ot({target:n,props:this.control.props,fallback:P}),Se({target:n,props:this.control.props,fallback:P,dependsOn:this.container.dimensions}),nt({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=ct(this.control.type.trim().toLowerCase()),o=i.firstElementChild??i;it({target:o,props:this.control.props,fallback:P,dependsOn:this.container.dimensions}),this.addControlTap(n),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.registerEvents()}registerEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,ie.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(_.disabled))return;let t=e.parentElement;if(t){let n=t.querySelector(`.${N.common}`);n&&this.syncBlinkAnimation(n)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,ie.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(_.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,ie.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(N.disabled)||(this.controlElement.classList.add(N.disabled),this.subscriptions.add((0,ie.fromEvent)(e,"animationiteration").pipe((0,ie.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(N.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)})}onProgress(){}onResize(){}updateShadowStyles(){}};var mn=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new Zt(r,e)},Zt=class extends Z{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(R.common,R.text),n.setAttribute("data-testid",re.TEXT),he({target:n,layoutParams:this.control.layoutParams,fallback:P}),nt({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=ct(this.control.type.trim().toLowerCase()),o=i.firstElementChild??i;it({target:o,props:this.control.props,fallback:P,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}onError(){}};var ht=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new Jt(r,e,t)},Jt=class extends ue{constructor(t,n,i){super(t,i);this.containerElement=null;this.controlSubscriptions=new ut.Subscription;this.error$=new ut.Subject;this.rootElement=n,this.layout=new Je(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",pt),this.addControlFactory("text",mn),this.addControlFactory("area",lt)}createView({eventCallback:t}){let n=document.createElement("div");return n.classList.add(_.common,_.disabled),requestAnimationFrame(()=>{n.classList.remove(_.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(i=>{i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout,isContainerDisabled:()=>this.isDisabled}}),i.setEvents(t),this.controlSubscriptions.add(i.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}hide(){let t=this.getElement();t&&t.classList.add(_.hidden)}show(){let t=this.getElement();t&&t.classList.remove(_.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(_.disabled),this.controls.forEach(n=>n.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(_.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(this.controlSubscriptions.unsubscribe(),this.controls.forEach(n=>n.removeListeners()),t.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,n){n&&this.controls.forEach(i=>{i.onProgress(t)})}onResize(t){t&&this.controls.forEach(n=>{n.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(n=>n.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(n=>n.toggleBlinkAnimation(t))}};var Ta=D(Or(),1),g=require("@vkontakte/videoplayer-shared/es2024"),Ie=require("@vkontakte/videoplayer-statistics/es2024");var Eo=require("@vkontakte/videoplayer-shared/es2024");function $e(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var bo="video_interactive",Co="videoint";var go=250,je=class{constructor(e){this.handleZoomChange=$e(e=>{this.lastZoomInfo=e},go);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,!rt(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:n,lang:i,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,this.onError=n,this.lang=i??"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Zc(e),this.resizeObserver=new ResizeObserver($e(this.onResize,go)),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,Eo.loadVKLangPack)(this.lang,bo,Co)}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:n,...i})=>{n==="openPreview"&&"chapterId"in i&&this.onOpenPreviewClick?.(i.chapterId)}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){this.hide(),this.manifest=null,this.resizeObserver.disconnect(),this.ngEditor?.setVisitedChapters([]),this.onOpenPreviewClick=void 0,this.ngEditor?.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Zc(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 Fe=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,n=!1,i=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let l=o.startTime-e;if(l<=i&&(o.endTime&&i<=o.endTime||o.endTime===null)){n=!0;break}i<l&&(t=t===-1?l:Math.min(t,l))}return!n&&t!==-1?t:null}}};var b=require("@interactiveplatform/movika-manifest");var Io={metadata:"Object",chapters:"Array"},Pr=r=>{if(!Y(r))return!1;for(let e in Io)if(!r[e]||!X(r[e],Io[e]))return!1;return(0,b.isSupportedManifest)(r.metadata.version)},Be=r=>r.type===b.ControlTypes.Text,Jc=r=>r.type===b.ControlTypes.Button,ep=r=>r.type===b.ControlTypes.Area,tp={Choice:"Choice",TextInput:"TextInput"},rp={Button:"Button",Area:"Area",Text:"Text"},np={onClick:"onClick",onSuspense:"onSuspense"},Vr={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var It=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 n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let n=this.listeners[e]||[];for(let i=n.length;i>0;i--)if(n[i]===t){n.splice(i,1);break}return this}emit(e,...t){let n=this.listeners[e];return n?(n.forEach(i=>{i(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var xt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{sn(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(n=>n!==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 Fo=require("@vkontakte/videoplayer-shared/es2024");var Tt=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,t){return ip(...this.loaders[e])(t)}};function ip(...r){return async function(t){let n=[...r];for(;n.length>0;)t=await n.shift()(t);return t}}function qe(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function St({actions:r,errors:e,chapterId:t,...n}){if(t){let i=r.getManifest();if(i){let o=r.getChapter(i.chapters,t);if(o){let l=r.getMedia(i.media,o.videoId),s=r.getGraph(i.graph,o.id);return l?{...n,actions:r,errors:e,result:{chapter:o,media:l,graph:s}}:{...n,errors:qe(e,St.name,"Could not find media"),actions:r}}}}return{...n,errors:qe(e,St.name,"Could not find chapter"),actions:r}}var wt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){if(!(e in this.listeners))return;let n=this.listeners[e];for(let i=0,o=n.length;i<o;i++)if(n[i].callback===t){n.splice(i,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let n=this.listeners[e.type].slice();for(let i=0,o=n.length;i<o;i++){let l=n[i];try{l.callback.call(this,e)}catch(s){Promise.resolve().then(()=>{throw s})}l.options&&l.options.once&&this.removeEventListener(e.type,l.callback)}return!e.defaultPrevented}},Ce=class extends wt{constructor(){super(),this.listeners||wt.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)}},De=class{constructor(){Object.defineProperty(this,"signal",{value:new Ce,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 n=e;if(n===void 0)if(typeof document>"u")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch{n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol<"u"&&Symbol.toStringTag&&(De.prototype[Symbol.toStringTag]="AbortController",Ce.prototype[Symbol.toStringTag]="AbortSignal");function At(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 Mr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=r;if(!At({fetch:e,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||i)&&(o=function(c,d){let f;d&&d.signal&&(f=d.signal,delete d.signal);let v=new t(c,d);return f&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:f}),v},o.prototype=t.prototype);let l=e;return{fetch:(a,c)=>{let d=o&&o.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(d){let f;try{f=new DOMException("Aborted","AbortError")}catch{f=new Error("Aborted"),f.name="AbortError"}if(d.aborted)return Promise.reject(f);let v=new Promise((y,k)=>{d.addEventListener("abort",()=>k(f),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([v,l(a,c)])}return l(a,c)},Request:o}}var op=()=>"fetch"in window,He=op()&&At({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),xo=He?Mr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Lr=He?xo.fetch:window.fetch,Wm=He?xo.Request:window.Request,Km=He?De:window.AbortController,Qm=He?Ce:window.AbortSignal;var Rt=(r="",e="")=>{let t=r.split("."),n=e.split("."),i=0;for(let o=0;o<Math.max(t.length,n.length)&&!i;o++)t[o]>n[o]?i=1:t[o]<n[o]?i=-1:i=0;return i};var sp=async r=>{try{let e={},t;if(et(r)){t=new URL(r).href;let i=await Lr(t);if(!i.ok)return{};e=await i.json()}else if(Y(r))e=r;else return{};if(!Pr(e))return{};let n=e.metadata.media;if(et(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let o=await Lr(i);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch{return cp(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch{return{}}};async function To(r){let{manifest:e,manifestURL:t}=await sp(r);if(!e)throw new Error("Failed on fetch");let n=(0,b.migrateManifestToLatestVersion)(e);return n.media=ap(n.media,t),delete n.metadata.media,n}function kt(r,e){if(e)return r.find(t=>t.id===e)}function Nr(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 _r(r,e){return r.videos.find(t=>t.id===e)}function ap(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(n=>{let i="url"in n?n.url:"",o=lp(i,e);return{...n,url:o||i}})}))}}function lp(r="",e){try{return new URL(r,e).href}catch{return""}}function cp(r){return Rt(r,"3.2.0")>=0}var No=D(Ue(),1);var Ot=r=>tt(r)&&!Dt(r),G=r=>r.order==="end",Ge=r=>tt(r.containers)&&!Dt(r.containers)&&G(r),_o=(r,e)=>{let t=r*1e3;return Ot(e.controls)&&t<(e.startTime??0)},jr=(r,e)=>{let t=r*1e3;return Ot(e.controls)&&t>=(e.startTime??0)&&t<=(e.endTime??1/0)};var se=(r=[])=>r.some(e=>e.action.type==="expect"),Fr=(r=[])=>r.find(e=>e.action.type==="expect"),Tp=r=>r?.length===1,ae=r=>Tp(r)&&Be(r[0]);function $o(r=[],e=1/0,t=[]){return r.filter(({container:n})=>!(0,No.default)(t,n.container.id)&&se(n.container.events)&&n.container.endTime===e&&!n.isRemoved)}function Pt({gameControllers:r=[],subjectName:e,subjectId:t,execFn:n}){for(let i of r)if(e==="container"&&i.container.container.id===t){n(i),$o(r,i.container.container.endTime,[i.container.container.id]).forEach(l=>{n(l)});break}}var jo=(r,e)=>{let t=w=>e.find(({container:u})=>u.container.id===w)?.container.isRemoved,n=se(r.events)&&!t(r.id),i=(w,C=!1,u=!1)=>{let h=u?"every":"some";return w.controls[h](m=>{let I=C?w.endTime===r.endTime:!0;return m.events?.[h](E=>E.action?.type===Vr.openURI)&&I})},o=w=>w.some(({container:C})=>i(C.container,!0,!1)&&!C.isRemoved),l=w=>w.every(({container:C})=>C.isRemoved?!0:i(C.container,!0,!0)),s=$o(e,r.endTime,[r.id]).length,a=w=>w.controls.some(C=>C.events?.some(u=>u.action?.args?.shouldOpenNow)),c=n||s>0,d=o(e),f=i(r),v=l(e),y=n?!1:s>0,k=a(r);return{isExpectTime:c,hasOtherExpect:s>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:f,isAllOpenURIEventsValid:v,isExpectEventForCurrentContainer:y,hasShouldOpenNowEvent:k}};var le=class extends Tt{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Fo.ValueSubject(null);this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){this.release();let n=await this.exec("manifestLoaders",{actions:{addErrorMessage:qe},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=await To(n.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 n=await this.exec("chapterLoaders",St({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Nr,getChapter:kt,getMedia:_r,getByBranches:this.getByBranches.bind(this),addErrorMessage:qe},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),n.result&&(this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.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 n=kt(this.manifest.chapters,t);if(n){let i=_r(this.manifest.media,n.videoId),o=Nr(this.manifest.graph,n.id);if(i)return{chapter:n,media:i,graph:o}}return null}getBranches(t=this.chapter?.id){if(t===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let n=kt(this.manifest?.chapters||[],t);return this.getByBranches(n?.branches)}}getByBranches(t=[]){return t.reduce((n,i)=>{let o=this.getByChapterId(i.chapterId);return o&&n.push(o),n},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter?.id===this.manifest?.metadata.initChapterId}isEndChapter(){return this.chapter?G(this.chapter):!1}};var ys=D(Vt(),1),bs=require("@vkontakte/videoplayer-core/es2024"),J=require("@vkontakte/videoplayer-shared/es2024");var fs=r=>{let e=r.variants.find(t=>t.payload?.type==="vk");if(e&&e.payload){let[t,n]=e.payload.id.split("_");return[t,n]}return[]};var vs=D(Vt(),1);function Dr(){let r=new Map;function e({listId:o=Math.random().toString(),itemId:l=Math.random().toString(),...s}){let a=r.get(o),c={...s};return a?a[l]=c:r.set(o,{[l]:c}),{listId:o,itemId:l,...s}}function t(o){o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),o.statistics?.oneStat.destroy(),o.statistics?.statSubscription.unsubscribe()}function n(o,l){let s=r.get(o);if(!s)throw Error("Can't remove. Not find.");if(l){let a=s[l];a&&t(a),delete s[l],Object.keys(s).length||r.delete(o)}else{for(let a of(0,vs.default)(s))t(a);r.delete(o)}}function i(){for(let o of r)n(o[0])}return{createPlayer:e,removePlayer:n,map:r,removeAll:i}}var ge=D(Ue(),1);function Hr(r,e=[]){let t={},n,i=!e.length;for(let o of r.variants)if(!n&&"cover"in o&&(n=o.cover),"url"in o)switch(o.type.toLowerCase()){case"mp4":(i||(0,ge.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"mpeg":(i||(0,ge.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[o.standard??"Invariant quality"]:o.url});break;case"hls":(i||(0,ge.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:o.url}});break;case"dash":(i||(0,ge.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:o.url}});break;default:break}return{sources:t,thumbUrl:n,title:r.title??""}}var ze=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,ge.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Zp=2;function Ur(r){let e=Dr(),t=new J.Subscription,n={},i=null,o=!1,l,s=new J.ValueSubject(null);r&&a(r);function a(C){i=C}function c(C,u,h){if(!i)throw Error("need to set interactive controller");if(!i.options)return;let I=(e.map.get(C)??{})[u];if(I){n={chapterId:h,listId:C,itemId:u,...I};let E=n.player;n.subscription.add(E.info.currentQuality$.subscribe(x=>{let A=E.info.position$.getValue(),$=E.info.isAutoQualityEnabled$.getValue();if(!(!x||!A||$))for(let T of e.map)(0,ys.default)(T[1]).forEach(({player:V})=>{ze(V,x)})})).add(E.events.started$.subscribe(()=>{d(u)})),I.container.remove(),i.setPlayer(I.player),o||(i.init(),o=!0),s.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}async function d(C){if(!i)throw Error("need to set interactive controller");if(te(n)||C!==n.itemId)return;let u=i.getChapterBranches(),h=new Set;for(let m of u)h.has(m.media.id)||(await v({media:m.media,chapterId:m.chapter.id,setAsActive:!1,title:m.chapter.label}),h.add(m.media.id))}async function f({chapter:{id:C},manifestVideo:u}){if(te(n)||!i)return;let h=n.player.info.muted$.getValue(),m=n.player.info.currentQuality$.getValue(),I=n.player.info.isAutoQualityEnabled$.getValue(),E=n.player.info.volume$.getValue(),x=n.player.info.currentPlaybackRate$.getValue(),A=!I,$=!1;for(let T of e.map)if(T[0]===u.id&&!i.state.isReplay$.getValue()){let V=Object.keys(T[1]);for(let L of V)L===n.itemId?(V.length<Zp||($=!0),e.removePlayer(T[0],L)):($=!0,c(T[0],L,C),A?ze(n.player,m):n.player.setAutoQuality(!0),n.player.setVolume(E),n.player.setMuted(h),n.player.setPlaybackRate(x))}else e.removePlayer(T[0]);$||(await v({media:u,chapterId:C,setAsActive:!0,playbackRate:x}),A?ze(n.player,m):n.player.setAutoQuality(!0),n.player.setVolume(E),n.player.setMuted(h))}async function v({media:C,chapterId:u,prefetch:h=!0,setAsActive:m=!0,autoplay:I=!1,preferredExt:E,title:x,playbackRate:A}){let $=Math.random().toString(),T=document.createElement("div");l.append(T);let V;if(i?.options?.vkVideoLoader){let Ye=fs(C);Ye.length&&(V=await i.options.vkVideoLoader(...Ye))}let L=i?.options?.coreConfig||void 0,z={...L,configName:[...L?.configName??[],"interactive"]},ee={container:T,...V?.videos?.[0]||{sources:Hr(C,E).sources},title:x,failoverHosts:V?.failoverHosts||[]},j=new bs.Player(z,J.Tracer.createRootTracer());j.initVideo(ee);let ce=null;if(V?.videos&&i?.options.createOneStat){let Ye=V.videos[0],Ft=i.options.createOneStat(Ye),tn=new J.Subscription;Ft&&(tn.add(Ft.attachTo(j)),ce={oneStat:Ft,statSubscription:tn})}let en=new J.Subscription,Aa=n?.player?.info.isAutoQualityEnabled$.getValue();en.add(j.events.canplay$.subscribe(function(){Aa||ze(j,n.player.info.currentQuality$.getValue()),A&&j.setPlaybackRate(A)}));let pe=e.createPlayer({listId:C.id,itemId:$,player:j,container:T,sources:Hr(C,E).sources,config:ee,subscription:en,statistics:ce});return m&&c(C.id,pe.itemId,u),I&&pe.player.play(),h&&!I&&pe.player.prepare(),{player:pe.player,config:pe.config,statistics:pe.statistics}}function y(){k(),i=null,l.remove()}function k(){t.unsubscribe(),e.removeAll(),n={},o=!1}async function w(){if(!i)throw Error("need to set interactive controller");k(),l=document.createElement("div");let{media:C,chapter:u}=i.getCurrentChapter();C&&u?(t.add(i.events.chapterChanged$.subscribe(f)),await v({media:C,chapterId:u.id,title:u.label})):console.error("not found")}return{...e,init:w,setInteractiveController:a,createPlayer:v,removeAll:y,getActivePlayer:function(){return n},activePlayerChanged:s}}var S={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Ee={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},O={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var gs=D(Ue(),1),Es=require("@vkontakte/videoplayer-shared/es2024");function Gr(r){return function(...t){return r(...t.reverse())}}function We(r,...e){return(...t)=>Y(e[0])&&Y(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var Mt=class{constructor({player:e,container:t,branches:n,selectBranches:i,interactiveEvents:o,globalEvents:l,globalEventEmitter:s,getContainerEventState:a,permanentTextControls:c,interactiveTimeOpenUri:d,disabledControls$:f,onRemove:v,onError:y}){this.hide=()=>{setTimeout(()=>{this.gameState!==4&&(se(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)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:(i,o)=>{let{isExpectTime:l,hasOtherExpect:s,hasOpenURIEvent:a,hasOpenURIEventInCurrentContainer:c,isAllOpenURIEventsValid:d,hasShouldOpenNowEvent:f}=this.getContainerEventState(),v=this.interactiveTimeOpenUri&&!c,y=this.interactiveTimeOpenUri&&c;if((!this.interactiveTimeOpenUri||v)&&(this.isSelectedControlEvent=!0),i!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||v)){if(this.interactiveTimeOpenUri){let k=!s&&!d&&c;k&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:k})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&a&&this.gameState!==5){if(y){let w=((C,u,h,m)=>!C&&!u&&h||C&&!u&&h&&!m||C&&!u&&h&&m)(l,s,d,this.isSelectedContainerEvent);this.fakeRemoveView(w)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!l||!s||!f)&&(this.selectBranches.stopExpect(),o())}},isEOV:()=>this.gameState===4},n=We(this.selectBranches.onControlEvent,t);this.container.createView({eventCallback:n}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&this.container.disable?.()}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,i=[6,5];if(!n||(0,gs.default)(i,this.gameState)&&!this.isPermanentText)return;let o=this.player.getExactTime();if(_o(o,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(jr(o,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let c=this.gameState;this.gameState=3,c===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:c}=this.getContainerEventState(),d=this.selectBranches.state.isExpect,f=this.interactiveTimeOpenUri&&c;if(f&&!d){let v=this.container.getElement();v&&(v.style.visibility!=="hidden"&&this.container.hide?.(),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!f&&this.removeView()}let l=jr(o,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:o,isInteractiveTime:l};this.container.onProgress(o*1e3,l),this.globalEventEmitter.emit(S.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new Es.Subscription,this.player=e,this.interactiveEvents=o,this.getContainerEventState=a,this.isPermanentText=c&&ae(t.container.controls),this.interactiveTimeOpenUri=d,this.disabledControls$=f,this.onRemove=v,this.globalEventEmitter=s,this.gameState=0,this.globalEvents=l,this.onError=y,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:O.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(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:O.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(),n=this.interactiveTimeOpenUri?e||t:se(this.container.container.events)||e;(this.isSelectedControlEvent||!n)&&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(){this.container.removeView(),this.globalEventEmitter.emit(S.interactives,{subjectId:this.container.container.id,subjectName:"container",type:O.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)}destroy(){this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:this.container.container.endTime??1/0,id:this.container.container.id})}};var Is=(r=[])=>r.reduce((e,t,n)=>{let i=(t?.controls??[]).filter(o=>!Be(o));if(Ot(i)){let o=[t.startTime??0,t.endTime??1/0],l={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[l],range:o});else{let s=[],a=-1/0,c=1/0,d=[],f=[];for(let v=0;v<e.length;v++){let y=e[v];if(f.push(...y.subjects),y.range[0]<c&&(c=y.range[0]),y.range[1]>a&&(a=y.range[1]),o[0]>=y.range[0]&&o[1]<=y.range[1])return e[v].subjects.push(l),e;o[0]<y.range[0]&&o[1]>y.range[0]&&(s.push(v),d=d.concat(y.subjects)),o[0]>=y.range[0]&&o[0]<=y.range[1]&&(s.push(v),d=d.concat(y.subjects),o[0]=y.range[0]),o[1]>=y.range[0]&&o[1]<=y.range[1]&&(s.push(v),d=d.concat(y.subjects),o[1]=y.range[1])}if(f.push(l),o[0]<=c&&o[1]>=a)return[{subjects:f,range:o}];s.length&&s.reverse().forEach(v=>{e.splice(v,1)}),e.push({subjects:d.concat([l]),range:o})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var na=D(Ue(),1),Qr=D(Vt(),1),ia=D(ta(),1);function ra(){let r={};function e(){for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&delete r[s]}function t(s){let a={};for(let c in r)+c<=s&&(a[c]=r[c]);return a}function n(s){let a={};for(let c in r)+c>=s&&(a[c]=r[c]);return a}function i({timestamp:s,priority:a,initiator:c}){if(qt(s)){let d=r[s]??null;if(d&&a&&xe(a,!0)){let f={},v=d[a];return v&&(f={...f,...v}),f=te(f)?null:f,f&&xe(c,!0)?f[c]??null:f}return d}return null}function o({timestamp:s,priority:a,initiator:c}){if(qt(s))if(r[s]){if(a&&xe(a,!0))if(r[s][a]){if(c&&xe(c,!0))if(r[s][a][c]){if(delete r[s][a][c],!te(r[s][a]))return!0}else return!1;if(delete r[s][a],!te(r[s]))return!0}else return!1;return delete r[s]}else return!1;return!1}function l({timestamp:s,priority:a,initiator:c,...d}){r[s]?.[a]?.[c]?r[s][a][c].push({...d}):r[s]?.[a]?r[s][a]={...r[s][a],[c]:[{...d}]}:r[s]?r[s]={...r[s],[a]:{[c]:[{...d}]}}:r[s]={[a]:{[c]:[{...d}]}}}return{map:r,remove:o,add:l,removeAll:e,get:i,getLte:t,getGte:n}}var Bu=[b.EventActionTypes.expect,b.EventActionTypes.setNextBranch],qu=1/0;function oa(r,e){let t=r,n,i=Du(e),o=ra(),l,s=()=>{y(),u()},a=h=>{o.add.call(void 0,h),k()},c=(h=[])=>{for(let m of h)if(m.action(),(0,na.default)(Bu,m.actionType))break},d=(h=1/0)=>{let m=Nt(o.get({timestamp:h,priority:"control"})??{}),I=Nt(o.get({timestamp:h,priority:"container"})??{}),E=Nt(o.get({timestamp:h,priority:"chapter"})??{});return[...m,...I,...E]},f=h=>{i.isReady(h)&&c(d(h))},v=()=>{c([...Nt(o.get({timestamp:1/0,priority:"chapter"})??{})])},y=()=>{n&&(l?.unsubscribe(),n=void 0)},k=()=>{n||(n=()=>setTimeout(()=>{f(1/0)}),l=t.events.ended$.subscribe(n))},w=h=>{y(),t=h},C=h=>{h.priority==="container"&&i.resetCalled(h.timestamp),o.remove(h)},u=()=>{i.release(),o.removeAll()};return{setPlayer:w,add:a,remove:C,exec:f,execEndOfVideo:v,listen:k,unlisten:y,release:s,containersEventsCallState:i,getPreparedToExecActions:d}}function Du(r){let e=new Map;return{setCalled:({timestamp:s,id:a})=>{let c=e.get(s);c&&c[a]!==void 0&&(c[a]=!0)},setData:(s=[])=>{for(let a of s){let c=a.endTime??qu,d=e.get(c);e.set(c,{...d,[a.id]:!1})}},resetCalled:s=>{let a=e.get(s);if(a)for(let c in a)a[c]=!1},isReady:s=>{let a=e.get(s);if(!a)return!0;let c=(0,Qr.default)(a);return r?c.some(f=>f):!c.some(f=>!f)},release:()=>e.clear()}}function Nt(r){return(0,ia.default)((0,Qr.default)(r)).sort(e=>e.actionType===b.EventActionTypes.expect?-1:1)}var sa={videoContentHeight:0,videoContentWidth:0},aa=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return sa;let{clientHeight:n,clientWidth:i}=r.experimental.element$.getValue()||{};if(!(n&&i))return sa;let o=e/t,l=n/i,s,a;return l>o?(a=i,s=i*o):l<o?(a=n/o,s=n):(a=i,s=n),{videoContentWidth:a,videoContentHeight:s}};var Hu=250;function la(r){let e,t=new ResizeObserver(s=>{o(s),e=o.bind(null,s)});function n(s){let{parentElement:a,player:c}=r();if(a&&c){let{videoContentWidth:d,videoContentHeight:f}=aa(c);a.style.setProperty("--interactive-content-width",`${d}px`),a.style.setProperty("--interactive-content-height",`${f}px`),a.style.setProperty("--interactive-width",`${s[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${s[0].contentRect.height}px`)}}function i(){let{parentElement:s}=r();s.removeAttribute("style")}let o=$e(s=>{let{fns:a=[]}=r();n(s);for(let c of a)c()},Hu);function l(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e?.()},release:l}}var Uu=r=>Math.floor(Math.random()*r),pa=r=>{let e=r.length,t=1/0,n=null;for(;e--;){let i=r[e],o=i.weight??1;o<t&&(t=o,n=i)}return n},ua=r=>{let e=r.length,t=-1/0,n=null;for(;e--;){let i=r[e],o=i.weight??0;o>t&&(t=o,n=i)}return n};var ha=r=>{let e=r.length,t=Uu(e);return r[t]},ca=1,da=r=>{let e=0;for(let n=0;n<r.length;++n)e+=r[n].weight??ca;let t=Math.random()*e;e=0;for(let n=0;n<r.length-1;++n)if(e+=r[n].weight??ca,e>=t)return r[n];return r[r.length-1]};var ma={shouldOpenNow:!0,isDetachContainer:!0},fa="after-expect",Xr=(r,e=!1)=>({...r,args:e?{...r.args,...ma}:{...ma,...r.args}}),va=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},o=()=>{i.isExpect&&(i.isExpect=!1)},l=({action:u,controlType:h,controlId:m,containerId:I,branches:E=[],onEvent:x,isEOV:A=()=>!1,isDisabled:$=()=>!1})=>{let T=Xr(u,A()),V={timestamp:1/0,priority:"control",initiator:m,actionType:T.type},L=$(),z=r.emit.bind(r,S.interactives,{subjectId:m,subjectType:h,subjectName:"control",type:L?O.actionChoiceCanceled:O.actionChoice,actionType:u.type,payload:{invokeImmediately:T.args.shouldOpenNow,containerId:I,...T.args}}),ee=()=>{e.interactiveActionChoice$.next({subjectId:m,subjectType:h,subjectName:"control",type:L?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:T.args.shouldOpenNow,containerId:I,...T.args}})};if(L){z(),ee();return}switch(T.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let j=E.find(ce=>ce.id===T.args.branchId);if(!j)return;x(T.args.isDetachContainer,y.bind(null,{subjectId:m,subjectName:"control"})),z(),ee(),T.args.shouldOpenNow?w({subjectId:m,subjectName:"control",subjectType:h,action:T,payload:{chapterId:j.chapterId,autoSelect:!1}}):n.add({...V,action:w.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:T,payload:{chapterId:j.chapterId,autoSelect:!1}})});return}case b.EventActionTypes.continuePlayback.trim().toLowerCase():{x(T.args.isDetachContainer,y.bind(null,{subjectId:m,subjectName:"control"})),z(),ee(),T.args.shouldOpenNow?k({subjectId:m,subjectName:"control",subjectType:h,action:u}):n.add({...V,action:k.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:u})});return}case b.EventActionTypes.openURI.trim().toLowerCase():{x(T.args.isDetachContainer,y.bind(null,{subjectId:m,subjectName:"control"})),z(),ee(),T.args.shouldOpenNow?C({subjectId:m,subjectName:"control",subjectType:h,action:T,payload:{URI:u.args.uri}}):n.add({...V,action:C.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:T,payload:{URI:u.args.uri}})});return}default:{let j="Unexpected control event",ce=new M(1,1,{message:j});d(ce,j);return}}},s=({action:u,container:{id:h,endTime:m},branches:I=[],isEOV:E=!1,autoSelected:x=!1})=>{let A=Xr(u,E),$={timestamp:!A.args.shouldOpenNow||E?1/0:m??1/0,priority:"container",initiator:h,actionType:A.type},T=r.emit.bind(r,S.interactives,{subjectId:h,subjectName:"container",type:O.actionChoice,actionType:A.type,payload:{invokeImmediately:A.args.shouldOpenNow,...A.args}}),V=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:A.type,payload:{invokeImmediately:A.args.shouldOpenNow,...A.args}})};switch(A.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let L=I.find(z=>z.id===A.args.branchId);if(!L)return;T(),V(),n.add({...$,action:w.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{chapterId:L.chapterId,autoSelect:x}})});return}case b.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case b.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case b.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case b.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case b.EventActionTypes.continuePlayback.trim().toLowerCase():{T(),V(),n.add({...$,action:k.bind(null,{subjectId:h,subjectName:"container",action:A})});return}case b.EventActionTypes.openURI.trim().toLowerCase():{T(),V(),n.add({...$,action:C.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{URI:u.args.uri}})});return}default:{let L="Unexpected container event",z=new M(1,1,{message:L});d(z,L);return}}};function a({container:u,branches:h,isEOV:m=!1}){let I=Fr(u.events);if(I){let E=Xr(I.action,m);r.emit(S.interactives,{subjectId:u.id,subjectName:"container",type:O.actionChoice,actionType:E.type,payload:{invokeImmediately:E.args.shouldOpenNow,...E.args}}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:E.type,payload:{invokeImmediately:E.args.shouldOpenNow,...E.args}}),n.add({timestamp:m?1/0:u.endTime??1/0,priority:"container",initiator:u.id,actionType:b.EventActionTypes.expect,action:v.bind(null,{subjectId:u.id,subjectName:"container"})}),i.isExpect=!0}else for(let E of u.events??[])s({action:E.action,container:u,branches:h,isEOV:m})}let c=({chapterId:u,action:h,branches:m=[]})=>{let I=r.emit.bind(r,S.interactives,{subjectId:u,subjectName:"chapter",type:O.actionChoice,actionType:h.type,payload:h.args}),E=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let x=m.find(A=>A.id===h.args.branchId);return x?.chapterId?(I(),E(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let x=ha(m);return x?.chapterId?(I(),E(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setRandomBranch.trim().toLowerCase():{let x=da(m);return x?.chapterId?(I(),E(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let x=ua(m);return x?.chapterId?(I(),E(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let x=pa(m);return x?.chapterId?(I(),E(),w.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:x.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.continuePlayback.trim().toLowerCase():return I(),E(),k.bind(null,{subjectId:u,subjectName:"chapter",action:h});case b.EventActionTypes.openURI.trim().toLowerCase():return I(),E(),C.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let x="Unexpected chapter event",A=new M(1,1,{message:x});d(A,x);return}}};function d(u,h){console.error(h),e.error$.next(u),r.emit(S.errors,u)}function f(u){let h=Fr(u.events);if(h){if(G(u))return;r.emit(S.interactives,{subjectId:u.id,subjectName:"chapter",type:O.actionChoice,actionType:h.action.type,payload:h.action.args}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"chapter",type:"action-choice",actionType:h.action.type,payload:h.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:b.EventActionTypes.expect,action:v.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else u.events?.forEach(m=>{let I=c({chapterId:u.id,action:m.action,branches:u.branches});I&&n.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:m.action.type,action:I})})}let v=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(S.interactives,{subjectId:u,subjectName:h,type:O.actionExecution,actionType:b.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:b.EventActionTypes.expect})},y=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(S.interactives,{subjectId:u,subjectName:h,type:O.actionExecution,actionType:fa}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:fa})},k=({subjectId:u,subjectName:h,subjectType:m,action:I})=>{r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:m,type:O.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:I.type})},w=({subjectId:u,subjectName:h,subjectType:m,action:I,payload:E})=>{E.behaviour="change-chapter",r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:m,type:O.actionExecution,actionType:I.type,payload:E}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:I.type,payload:E})},C=({subjectId:u,subjectName:h,subjectType:m,action:I,payload:E})=>{if(!E.URI)return;let x=window.open(E.URI,"_blank","noopener,noreferrer");x&&(x.opener=null),r.emit(S.interactives,{subjectId:u,subjectName:h,subjectType:m,type:O.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:I.type})};return{onControlEvent:l,onContainerEvent:s,onChapterEvent:c,onExpectEvent:v,expectEventHandler:y,setManifestChapterEvents:f,setManifestContainerEvents:a,stopExpect:o,state:i}};var Jr=D(Or(),1),q=require("@vkontakte/videoplayer-shared/es2024");var _t=(r,e)=>{let t={};return r.map(n=>{if(!t[n]){let i=e.chapters.find(l=>l.id===n);if(!i)return null;let o=e.media.videos.find(l=>i.videoId===l.id);if(!o)return null;t[n]=Yr(o)}return t[n]}).filter(Boolean)},ya=r=>{for(let e of r.variants)if(ba(e)&&e.payload)return e.payload.id},ba=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),Yr=r=>{let e=ya(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Ca=(r,e)=>{for(let t of r.media.videos)if(e===Yr(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},Zr=(r,e)=>r.reduce((t,n)=>{let i=Ca(e,n);return i?[...t,i]:t},[]);var Qe=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:o}){this.state={history$:new q.ValueSubject([]),hasPrevChapter$:new q.ValueSubject(!1),prevChapter$:new q.ValueSubject(null),isInitialChapter$:new q.ValueSubject(!1),isGoBackLimited$:new q.ValueSubject(!1)};this.#r=null;this.#s=!1;this.#e=null;this.#p=null;this.events={inited$:new q.Subject,destroyed$:new q.Subject,error$:new q.Subject};this.#n=null;this.#i=null;this.#t=null;this.#a=new q.Subscription;this.#l=!1;this.#c=0;this.#n=t,this.#t=e,this.#i=n,this.#r=i,this.#o=o,this.state.history$&&this.#a&&this.#a?.add(this.state.history$.subscribe(l=>{this.state.prevChapter$.next((0,Jr.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===this.#e?.metadata?.initChapterId),this.state.isGoBackLimited$.next(this.#c===this.#o.maxLength-1)}))}#r;#o;#s;#e;#p;#n;#i;#t;#a;#l;#c;async setManifest(e){if(!this.#i||!this.#t)return;this.#e=e,await this.getProjectHistory();let t=this.getInitialChapterId();await this.#i.setChapter({chapterId:t,pushToHistory:!1}),this.#s||(this.#s=!0,this.events.inited$.next({initChapterId:t}))}get inited(){return this.#s}async updateHistory(e,t=!0){if(!this.#e)return;this.#l?(this.#l=!1,this.#c++):this.#c=0;let n=this.#e,i=e.length-this.#o.maxLength,o=i>0?e.slice(i):e,l=_t(o,n);if(this.#p=l,this.state.history$.next(o),!(!t||!this.#r||!this.#n))try{await this.#r.save(this.#n,l)}catch{let a=new M(1,5,"Unable to save interactive history");this.events.error$.next(a),this.#t?.emit(S.errors,a)}}async goBack(){if(!this.state||!this.#i){let n=new M(1,5,"Unable to save interactive history");return this.events.error$.next(n),this.#t?.emit(S.errors,n)}this.#l=!0;let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await this.#i.setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){if(!this.#e||!this.#n)return;let e=this.#e,t=[this.getInitialVideoId()];if(this.#r)try{let i=await this.#r.get(this.#n);i.length&&(t=i)}catch{let o=new M(1,5,"Error while trying to fetch data");this.events.error$.next(o),this.#t?.emit(S.errors,o)}let n=Zr(t,e);this.state.history$.next(n)}getInitialChapterId(){let e=this.state.history$.getValue();return(0,Jr.default)(e,-1)||this.#o.initChapterId||this.#e?.metadata.initChapterId}getInitialVideoId(){if(this.#e){let e=this.getInitialChapterId();return _t([e],this.#e).pop()}return null}destroy(){this.#n=null,this.#r=null,this.#i=null,this.#a?.unsubscribe(),this.#a=null,this.#s=!1,this.#t?.emit(S.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var $t=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,n=t.length;for(let i=3;i<n;i+=40)if(t[i]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){this.canvasImgSrc&&this.rootElement.getContext("2d")?.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height)}async updateCanvasDimensions(e,t=!1){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;t&&(i=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&i&&this.restore(i),this._prevSizeId=n}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 jt=class{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
6
|
+
"use strict";var qs=Object.create;var et=Object.defineProperty;var Ds=Object.getOwnPropertyDescriptor;var Hs=Object.getOwnPropertyNames;var Us=Object.getPrototypeOf,Gs=Object.prototype.hasOwnProperty;var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),zs=(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 Hs(e))!Gs.call(r,n)&&n!==t&&et(r,n,{get:()=>e[n],enumerable:!(i=Ds(e,n))||i.enumerable});return r};var H=(r,e,t)=>(t=r!=null?qs(Us(r)):{},li(e||!r||!r.__esModule?et(t,"default",{value:r,enumerable:!0}):t,r)),Ws=r=>li(et({},"__esModule",{value:!0}),r);var X=p((ar,wi)=>{"use strict";var Re=function(r){return r&&r.Math===Math&&r};wi.exports=Re(typeof globalThis=="object"&&globalThis)||Re(typeof window=="object"&&window)||Re(typeof self=="object"&&self)||Re(typeof global=="object"&&global)||Re(typeof ar=="object"&&ar)||function(){return this}()||Function("return this")()});var B=p((_d,Ri)=>{"use strict";Ri.exports=function(r){try{return!!r()}catch{return!0}}});var ke=p(($d,ki)=>{"use strict";var Js=B();ki.exports=!Js(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Li=p((jd,Vi)=>{"use strict";var el=ke(),Mi=Function.prototype,Oi=Mi.apply,Pi=Mi.call;Vi.exports=typeof Reflect=="object"&&Reflect.apply||(el?Pi.bind(Oi):function(){return Pi.apply(Oi,arguments)})});var U=p((Bd,_i)=>{"use strict";var Fi=ke(),Ni=Function.prototype,sr=Ni.call,tl=Fi&&Ni.bind.bind(sr,sr);_i.exports=Fi?tl:function(r){return function(){return sr.apply(r,arguments)}}});var Oe=p((qd,ji)=>{"use strict";var $i=U(),rl=$i({}.toString),il=$i("".slice);ji.exports=function(r){return il(rl(r),8,-1)}});var lr=p((Dd,Bi)=>{"use strict";var nl=Oe(),ol=U();Bi.exports=function(r){if(nl(r)==="Function")return ol(r)}});var q=p((Hd,qi)=>{"use strict";var cr=typeof document=="object"&&document.all;qi.exports=typeof cr>"u"&&cr!==void 0?function(r){return typeof r=="function"||r===cr}:function(r){return typeof r=="function"}});var se=p((Ud,Di)=>{"use strict";var al=B();Di.exports=!al(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var gt=p((Gd,Hi)=>{"use strict";var sl=ke(),yt=Function.prototype.call;Hi.exports=sl?yt.bind(yt):function(){return yt.apply(yt,arguments)}});var pr=p(zi=>{"use strict";var Ui={}.propertyIsEnumerable,Gi=Object.getOwnPropertyDescriptor,ll=Gi&&!Ui.call({1:2},1);zi.f=ll?function(e){var t=Gi(this,e);return!!t&&t.enumerable}:Ui});var ur=p((Wd,Wi)=>{"use strict";Wi.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Qi=p((Kd,Ki)=>{"use strict";var cl=U(),pl=B(),ul=Oe(),hr=Object,hl=cl("".split);Ki.exports=pl(function(){return!hr("z").propertyIsEnumerable(0)})?function(r){return ul(r)==="String"?hl(r,""):hr(r)}:hr});var dr=p((Qd,Xi)=>{"use strict";Xi.exports=function(r){return r==null}});var mr=p((Xd,Yi)=>{"use strict";var dl=dr(),ml=TypeError;Yi.exports=function(r){if(dl(r))throw new ml("Can't call method on "+r);return r}});var Pe=p((Yd,Zi)=>{"use strict";var fl=Qi(),vl=mr();Zi.exports=function(r){return fl(vl(r))}});var ve=p((Zd,Ji)=>{"use strict";var bl=q();Ji.exports=function(r){return typeof r=="object"?r!==null:bl(r)}});var Ct=p((Jd,en)=>{"use strict";en.exports={}});var Et=p((em,rn)=>{"use strict";var fr=Ct(),vr=X(),yl=q(),tn=function(r){return yl(r)?r:void 0};rn.exports=function(r,e){return arguments.length<2?tn(fr[r])||tn(vr[r]):fr[r]&&fr[r][e]||vr[r]&&vr[r][e]}});var on=p((tm,nn)=>{"use strict";var gl=U();nn.exports=gl({}.isPrototypeOf)});var cn=p((rm,ln)=>{"use strict";var Cl=X(),an=Cl.navigator,sn=an&&an.userAgent;ln.exports=sn?String(sn):""});var vn=p((im,fn)=>{"use strict";var mn=X(),br=cn(),pn=mn.process,un=mn.Deno,hn=pn&&pn.versions||un&&un.version,dn=hn&&hn.v8,G,Tt;dn&&(G=dn.split("."),Tt=G[0]>0&&G[0]<4?1:+(G[0]+G[1]));!Tt&&br&&(G=br.match(/Edge\/(\d+)/),(!G||G[1]>=74)&&(G=br.match(/Chrome\/(\d+)/),G&&(Tt=+G[1])));fn.exports=Tt});var yr=p((nm,yn)=>{"use strict";var bn=vn(),El=B(),Tl=X(),xl=Tl.String;yn.exports=!!Object.getOwnPropertySymbols&&!El(function(){var r=Symbol("symbol detection");return!xl(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&bn&&bn<41})});var gr=p((om,gn)=>{"use strict";var Il=yr();gn.exports=Il&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Cr=p((am,Cn)=>{"use strict";var Sl=Et(),Al=q(),wl=on(),Rl=gr(),kl=Object;Cn.exports=Rl?function(r){return typeof r=="symbol"}:function(r){var e=Sl("Symbol");return Al(e)&&wl(e.prototype,kl(r))}});var Tn=p((sm,En)=>{"use strict";var Ol=String;En.exports=function(r){try{return Ol(r)}catch{return"Object"}}});var Er=p((lm,xn)=>{"use strict";var Pl=q(),Ml=Tn(),Vl=TypeError;xn.exports=function(r){if(Pl(r))return r;throw new Vl(Ml(r)+" is not a function")}});var Sn=p((cm,In)=>{"use strict";var Ll=Er(),Fl=dr();In.exports=function(r,e){var t=r[e];return Fl(t)?void 0:Ll(t)}});var wn=p((pm,An)=>{"use strict";var Tr=gt(),xr=q(),Ir=ve(),Nl=TypeError;An.exports=function(r,e){var t,i;if(e==="string"&&xr(t=r.toString)&&!Ir(i=Tr(t,r))||xr(t=r.valueOf)&&!Ir(i=Tr(t,r))||e!=="string"&&xr(t=r.toString)&&!Ir(i=Tr(t,r)))return i;throw new Nl("Can't convert object to primitive value")}});var kn=p((um,Rn)=>{"use strict";Rn.exports=!0});var Mn=p((hm,Pn)=>{"use strict";var On=X(),_l=Object.defineProperty;Pn.exports=function(r,e){try{_l(On,r,{value:e,configurable:!0,writable:!0})}catch{On[r]=e}return e}});var xt=p((dm,Fn)=>{"use strict";var $l=kn(),jl=X(),Bl=Mn(),Vn="__core-js_shared__",Ln=Fn.exports=jl[Vn]||Bl(Vn,{});(Ln.versions||(Ln.versions=[])).push({version:"3.38.0",mode:$l?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var Sr=p((mm,_n)=>{"use strict";var Nn=xt();_n.exports=function(r,e){return Nn[r]||(Nn[r]=e||{})}});var Me=p((fm,$n)=>{"use strict";var ql=mr(),Dl=Object;$n.exports=function(r){return Dl(ql(r))}});var be=p((vm,jn)=>{"use strict";var Hl=U(),Ul=Me(),Gl=Hl({}.hasOwnProperty);jn.exports=Object.hasOwn||function(e,t){return Gl(Ul(e),t)}});var Ar=p((bm,Bn)=>{"use strict";var zl=U(),Wl=0,Kl=Math.random(),Ql=zl(1 .toString);Bn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Ql(++Wl+Kl,36)}});var Ve=p((ym,Dn)=>{"use strict";var Xl=X(),Yl=Sr(),qn=be(),Zl=Ar(),Jl=yr(),ec=gr(),ye=Xl.Symbol,wr=Yl("wks"),tc=ec?ye.for||ye:ye&&ye.withoutSetter||Zl;Dn.exports=function(r){return qn(wr,r)||(wr[r]=Jl&&qn(ye,r)?ye[r]:tc("Symbol."+r)),wr[r]}});var zn=p((gm,Gn)=>{"use strict";var rc=gt(),Hn=ve(),Un=Cr(),ic=Sn(),nc=wn(),oc=Ve(),ac=TypeError,sc=oc("toPrimitive");Gn.exports=function(r,e){if(!Hn(r)||Un(r))return r;var t=ic(r,sc),i;if(t){if(e===void 0&&(e="default"),i=rc(t,r,e),!Hn(i)||Un(i))return i;throw new ac("Can't convert object to primitive value")}return e===void 0&&(e="number"),nc(r,e)}});var Rr=p((Cm,Wn)=>{"use strict";var lc=zn(),cc=Cr();Wn.exports=function(r){var e=lc(r,"string");return cc(e)?e:e+""}});var Xn=p((Em,Qn)=>{"use strict";var pc=X(),Kn=ve(),kr=pc.document,uc=Kn(kr)&&Kn(kr.createElement);Qn.exports=function(r){return uc?kr.createElement(r):{}}});var Or=p((Tm,Yn)=>{"use strict";var hc=se(),dc=B(),mc=Xn();Yn.exports=!hc&&!dc(function(){return Object.defineProperty(mc("div"),"a",{get:function(){return 7}}).a!==7})});var eo=p(Jn=>{"use strict";var fc=se(),vc=gt(),bc=pr(),yc=ur(),gc=Pe(),Cc=Rr(),Ec=be(),Tc=Or(),Zn=Object.getOwnPropertyDescriptor;Jn.f=fc?Zn:function(e,t){if(e=gc(e),t=Cc(t),Tc)try{return Zn(e,t)}catch{}if(Ec(e,t))return yc(!vc(bc.f,e,t),e[t])}});var ro=p((Im,to)=>{"use strict";var xc=B(),Ic=q(),Sc=/#|\.prototype\./,Le=function(r,e){var t=wc[Ac(r)];return t===kc?!0:t===Rc?!1:Ic(e)?xc(e):!!e},Ac=Le.normalize=function(r){return String(r).replace(Sc,".").toLowerCase()},wc=Le.data={},Rc=Le.NATIVE="N",kc=Le.POLYFILL="P";to.exports=Le});var Pr=p((Sm,no)=>{"use strict";var io=lr(),Oc=Er(),Pc=ke(),Mc=io(io.bind);no.exports=function(r,e){return Oc(r),e===void 0?r:Pc?Mc(r,e):function(){return r.apply(e,arguments)}}});var ao=p((Am,oo)=>{"use strict";var Vc=se(),Lc=B();oo.exports=Vc&&Lc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var lo=p((wm,so)=>{"use strict";var Fc=ve(),Nc=String,_c=TypeError;so.exports=function(r){if(Fc(r))return r;throw new _c(Nc(r)+" is not an object")}});var uo=p(po=>{"use strict";var $c=se(),jc=Or(),Bc=ao(),It=lo(),co=Rr(),qc=TypeError,Mr=Object.defineProperty,Dc=Object.getOwnPropertyDescriptor,Vr="enumerable",Lr="configurable",Fr="writable";po.f=$c?Bc?function(e,t,i){if(It(e),t=co(t),It(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Fr in i&&!i[Fr]){var n=Dc(e,t);n&&n[Fr]&&(e[t]=i.value,i={configurable:Lr in i?i[Lr]:n[Lr],enumerable:Vr in i?i[Vr]:n[Vr],writable:!1})}return Mr(e,t,i)}:Mr:function(e,t,i){if(It(e),t=co(t),It(i),jc)try{return Mr(e,t,i)}catch{}if("get"in i||"set"in i)throw new qc("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var mo=p((km,ho)=>{"use strict";var Hc=se(),Uc=uo(),Gc=ur();ho.exports=Hc?function(r,e,t){return Uc.f(r,e,Gc(1,t))}:function(r,e,t){return r[e]=t,r}});var Ne=p((Om,vo)=>{"use strict";var Fe=X(),zc=Li(),Wc=lr(),Kc=q(),Qc=eo().f,Xc=ro(),ge=Ct(),Yc=Pr(),Ce=mo(),fo=be();xt();var Zc=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 zc(r,this,arguments)};return e.prototype=r.prototype,e};vo.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,l=i?Fe:n?Fe[t]:Fe[t]&&Fe[t].prototype,a=i?ge:ge[t]||Ce(ge,t,{})[t],s=a.prototype,c,d,m,f,b,k,x,g,u;for(f in e)c=Xc(i?f:t+(n?".":"#")+f,r.forced),d=!c&&l&&fo(l,f),k=a[f],d&&(r.dontCallGetSet?(u=Qc(l,f),x=u&&u.value):x=l[f]),b=d&&x?x:e[f],!(!c&&!o&&typeof k==typeof b)&&(r.bind&&d?g=Yc(b,Fe):r.wrap&&d?g=Zc(b):o&&Kc(b)?g=Wc(b):g=b,(r.sham||b&&b.sham||k&&k.sham)&&Ce(g,"sham",!0),Ce(a,f,g),o&&(m=t+"Prototype",fo(ge,m)||Ce(ge,m,{}),Ce(ge[m],f,b),r.real&&s&&(c||!s[f])&&Ce(s,f,b)))}});var yo=p((Pm,bo)=>{"use strict";var Jc=Math.ceil,ep=Math.floor;bo.exports=Math.trunc||function(e){var t=+e;return(t>0?ep:Jc)(t)}});var _e=p((Mm,go)=>{"use strict";var tp=yo();go.exports=function(r){var e=+r;return e!==e||e===0?0:tp(e)}});var Eo=p((Vm,Co)=>{"use strict";var rp=_e(),ip=Math.min;Co.exports=function(r){var e=rp(r);return e>0?ip(e,9007199254740991):0}});var $e=p((Lm,To)=>{"use strict";var np=Eo();To.exports=function(r){return np(r.length)}});var St=p((Fm,xo)=>{"use strict";xo.exports=function(){}});var Io=p(()=>{"use strict";var op=Ne(),ap=Me(),sp=$e(),lp=_e(),cp=St();op({target:"Array",proto:!0},{at:function(e){var t=ap(this),i=sp(t),n=lp(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});cp("at")});var At=p(($m,So)=>{"use strict";var pp=Et();So.exports=pp});var wo=p((jm,Ao)=>{"use strict";Io();var up=At();Ao.exports=up("Array","at")});var ko=p((Bm,Ro)=>{"use strict";var hp=wo();Ro.exports=hp});var Nr=p((qm,Oo)=>{"use strict";var dp=ko();Oo.exports=dp});var jo=p((Rf,$o)=>{"use strict";var Ap=_e(),wp=Math.max,Rp=Math.min;$o.exports=function(r,e){var t=Ap(r);return t<0?wp(t+e,0):Rp(t,e)}});var Hr=p((kf,qo)=>{"use strict";var kp=Pe(),Op=jo(),Pp=$e(),Bo=function(r){return function(e,t,i){var n=kp(e),o=Pp(n);if(o===0)return!r&&-1;var l=Op(i,o),a;if(r&&t!==t){for(;o>l;)if(a=n[l++],a!==a)return!0}else for(;o>l;l++)if((r||l in n)&&n[l]===t)return r||l||0;return!r&&-1}};qo.exports={includes:Bo(!0),indexOf:Bo(!1)}});var Do=p(()=>{"use strict";var Mp=Ne(),Vp=Hr().includes,Lp=B(),Fp=St(),Np=Lp(function(){return!Array(1).includes()});Mp({target:"Array",proto:!0,forced:Np},{includes:function(e){return Vp(this,e,arguments.length>1?arguments[1]:void 0)}});Fp("includes")});var Uo=p((Mf,Ho)=>{"use strict";Do();var _p=At();Ho.exports=_p("Array","includes")});var zo=p((Vf,Go)=>{"use strict";var $p=Uo();Go.exports=$p});var ze=p((Lf,Wo)=>{"use strict";var jp=zo();Wo.exports=jp});var ta=p((Uf,ea)=>{"use strict";var qp=Sr(),Dp=Ar(),Jo=qp("keys");ea.exports=function(r){return Jo[r]||(Jo[r]=Dp(r))}});var ia=p((Gf,ra)=>{"use strict";var Hp=B();ra.exports=!Hp(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var aa=p((zf,oa)=>{"use strict";var Up=be(),Gp=q(),zp=Me(),Wp=ta(),Kp=ia(),na=Wp("IE_PROTO"),zr=Object,Qp=zr.prototype;oa.exports=Kp?zr.getPrototypeOf:function(r){var e=zp(r);if(Up(e,na))return e[na];var t=e.constructor;return Gp(t)&&e instanceof t?t.prototype:e instanceof zr?Qp:null}});var la=p((Wf,sa)=>{"use strict";sa.exports={}});var ua=p((Kf,pa)=>{"use strict";var Xp=U(),Wr=be(),Yp=Pe(),Zp=Hr().indexOf,Jp=la(),ca=Xp([].push);pa.exports=function(r,e){var t=Yp(r),i=0,n=[],o;for(o in t)!Wr(Jp,o)&&Wr(t,o)&&ca(n,o);for(;e.length>i;)Wr(t,o=e[i++])&&(~Zp(n,o)||ca(n,o));return n}});var da=p((Qf,ha)=>{"use strict";ha.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var fa=p((Xf,ma)=>{"use strict";var eu=ua(),tu=da();ma.exports=Object.keys||function(e){return eu(e,tu)}});var Ea=p((Yf,Ca)=>{"use strict";var ba=se(),ru=B(),ya=U(),iu=aa(),nu=fa(),ou=Pe(),au=pr().f,ga=ya(au),su=ya([].push),lu=ba&&ru(function(){var r=Object.create(null);return r[2]=2,!ga(r,2)}),va=function(r){return function(e){for(var t=ou(e),i=nu(t),n=lu&&iu(t)===null,o=i.length,l=0,a=[],s;o>l;)s=i[l++],(!ba||(n?s in t:ga(t,s)))&&su(a,r?[s,t[s]]:t[s]);return a}};Ca.exports={entries:va(!0),values:va(!1)}});var Ta=p(()=>{"use strict";var cu=Ne(),pu=Ea().values;cu({target:"Object",stat:!0},{values:function(e){return pu(e)}})});var Ia=p((ev,xa)=>{"use strict";Ta();var uu=Ct();xa.exports=uu.Object.values});var Aa=p((tv,Sa)=>{"use strict";var hu=Ia();Sa.exports=hu});var _t=p((rv,wa)=>{"use strict";var du=Aa();wa.exports=du});var Zr=p((xv,Na)=>{"use strict";var fu=Oe();Na.exports=Array.isArray||function(e){return fu(e)==="Array"}});var $a=p((Iv,_a)=>{"use strict";var vu=TypeError,bu=9007199254740991;_a.exports=function(r){if(r>bu)throw vu("Maximum allowed index exceeded");return r}});var qa=p((Sv,Ba)=>{"use strict";var yu=Zr(),gu=$e(),Cu=$a(),Eu=Pr(),ja=function(r,e,t,i,n,o,l,a){for(var s=n,c=0,d=l?Eu(l,a):!1,m,f;c<i;)c in t&&(m=d?d(t[c],c,e):t[c],o>0&&yu(m)?(f=gu(m),s=ja(r,e,m,f,s,o-1)-1):(Cu(s+1),r[s]=m),s++),c++;return s};Ba.exports=ja});var Ua=p((Av,Ha)=>{"use strict";var Tu=Ve(),xu=Tu("toStringTag"),Da={};Da[xu]="z";Ha.exports=String(Da)==="[object z]"});var za=p((wv,Ga)=>{"use strict";var Iu=Ua(),Su=q(),jt=Oe(),Au=Ve(),wu=Au("toStringTag"),Ru=Object,ku=jt(function(){return arguments}())==="Arguments",Ou=function(r,e){try{return r[e]}catch{}};Ga.exports=Iu?jt:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=Ou(e=Ru(r),wu))=="string"?t:ku?jt(e):(i=jt(e))==="Object"&&Su(e.callee)?"Arguments":i}});var Ka=p((Rv,Wa)=>{"use strict";var Pu=U(),Mu=q(),Jr=xt(),Vu=Pu(Function.toString);Mu(Jr.inspectSource)||(Jr.inspectSource=function(r){return Vu(r)});Wa.exports=Jr.inspectSource});var es=p((kv,Ja)=>{"use strict";var Lu=U(),Fu=B(),Qa=q(),Nu=za(),_u=Et(),$u=Ka(),Xa=function(){},Ya=_u("Reflect","construct"),ei=/^\s*(?:class|function)\b/,ju=Lu(ei.exec),Bu=!ei.test(Xa),Xe=function(e){if(!Qa(e))return!1;try{return Ya(Xa,[],e),!0}catch{return!1}},Za=function(e){if(!Qa(e))return!1;switch(Nu(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Bu||!!ju(ei,$u(e))}catch{return!0}};Za.sham=!0;Ja.exports=!Ya||Fu(function(){var r;return Xe(Xe.call)||!Xe(Object)||!Xe(function(){r=!0})||r})?Za:Xe});var ns=p((Ov,is)=>{"use strict";var ts=Zr(),qu=es(),Du=ve(),Hu=Ve(),Uu=Hu("species"),rs=Array;is.exports=function(r){var e;return ts(r)&&(e=r.constructor,qu(e)&&(e===rs||ts(e.prototype))?e=void 0:Du(e)&&(e=e[Uu],e===null&&(e=void 0))),e===void 0?rs:e}});var as=p((Pv,os)=>{"use strict";var Gu=ns();os.exports=function(r,e){return new(Gu(r))(e===0?0:e)}});var ss=p(()=>{"use strict";var zu=Ne(),Wu=qa(),Ku=Me(),Qu=$e(),Xu=_e(),Yu=as();zu({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Ku(this),i=Qu(t),n=Yu(t,0);return n.length=Wu(n,t,t,i,0,e===void 0?1:Xu(e)),n}})});var ls=p(()=>{"use strict";var Zu=St();Zu("flat")});var ps=p((Nv,cs)=>{"use strict";ss();ls();var Ju=At();cs.exports=Ju("Array","flat")});var hs=p((_v,us)=>{"use strict";var eh=ps();us.exports=eh});var ms=p(($v,ds)=>{"use strict";var th=hs();ds.exports=th});var uh={};zs(uh,{ContainerTypes:()=>y.ContainerTypes,ControlTypes:()=>y.ControlTypes,CustomError:()=>V,EVENT_NAMES:()=>A,EventActionTypes:()=>y.EventActionTypes,EventTypes:()=>y.EventTypes,Interactives:()=>Ze,ManifestController:()=>pe,SDKInfo:()=>ph,chapterIdsToVKVideoIds:()=>qt,compareVersions:()=>Vt,containerTypes:()=>bp,controlTypes:()=>yp,eventActionTypes:()=>$r,eventTypes:()=>gp,getChapterIdByVkVideoId:()=>Ms,getVKVideoIdByMedia:()=>ii,getVideoRawIdByMedia:()=>Os,graphEventTypes:()=>xe,hasEndTemplate:()=>We,interactivesEventTypes:()=>P,isAreaControl:()=>vp,isButtonControl:()=>fp,isLastChapter:()=>z,isOneTextCtrlContainer:()=>ce,isSupportedManifest:()=>y.isSupportedManifest,isTextControl:()=>De,isVKVariantItem:()=>Ps,isValidManifest:()=>_r,migrateManifestToLatestVersion:()=>y.migrateManifestToLatestVersion,utils:()=>js,vkVideoIdsToChapterIds:()=>ni});module.exports=Ws(uh);var ci="1.0.39-dev.6edf3cda.0";var vt=require("@vkontakte/videoplayer-shared/es2024");var Gt=class{constructor(e){this.layout=e}},tt=class extends Gt{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))`}};function pi(r){return"features"in r}var de=class{constructor(e,t){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]}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 oe=require("@vkontakte/videoplayer-shared/es2024");var Z=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,J=r=>Z(r,"Object"),rt=r=>Z(r,"String"),it=r=>Z(r,"Array"),nt=r=>Z(r,"Number"),ui=r=>Z(r,"Function"),hi=r=>Z(r,"Boolean"),zt=r=>nt(r)&&!isNaN(r);var ie=r=>J(r)&&Object.keys(r).length===0,Wt=r=>it(r)&&!r.length;var Se=(r,e)=>rt(r)&&(e?r.trim():r).length;function Ae(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 di="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},mi=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(mi||{}),fi=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(fi||{}),vi=(i=>(i.start="left",i.end="right",i.center="center",i))(vi||{}),ot=({target:r,props:e})=>{r.style.alignItems=(e?.gravityVertical&&mi[e.gravityVertical])??"center",r.style.justifyContent=(e?.gravityHorizontal&&fi[e.gravityHorizontal])??"center",r.style.textAlign=(e?.alignment&&vi[e.alignment])??"center"},at=({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},st=({target:r,props:e,fallback:t})=>{r.style.backgroundColor=Ae(e?.background?.color??t.backgroundColor,e?.background?.alpha??t.backgroundAlpha)},we=({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})`,l=n?t.roundCornersRawValue:`calc(${i.height} * ${e?.shape?.roundCorners??t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=Ae(n?t.borderColor:e?.shape?.border?.color??t.borderColor,n?t.borderAlpha:e?.shape?.border?.alpha??t.borderAlpha),r.style.borderRadius=l},bi=({target:r,isDark:e,baseDimension:t,fallback:i})=>{let l=Ae(i.shadowColorLight,i.shadowColorAlpha),a=Ae(i.shadowColorDark,i.shadowColorAlpha),s=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${s} ${c} ${e?a:l}`;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 Q=require("@vkontakte/videoplayer-shared/es2024");var Kt="interactive-control-tap",fe={common:Kt,animation:`${Kt}-animation`,visible:`${Kt}-visible`};var Ks=60,lt=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=Ks,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),l=i.left+i.width/2,a=i.top+i.height/2,s=e.clientX-l,c=e.clientY-a,d=Qs(s,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.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 Qs(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var Qt="int",ne=(i=>(i.AREA=`${Qt}_area`,i.TEXT=`${Qt}_text`,i.BUTTON=`${Qt}_bttn`,i))(ne||{});function Xt(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`},yi=40;var V=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var ee=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new Q.Subscription;this.error$=new Q.Subject;this.isInteracted$=new Q.ValueSubject(!1)}onError(e="",t){let i=new V(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(i)}addControlTap(e){if(this.featureIsEnabled("controlsTapPlace")&&this.container){let t=this.control.layoutParams.angle??O.angle;this.controlTap=new lt({controlRotateAngleRad:t,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?yi:void 0}),this.subscriptions.add((0,Q.fromEvent)(e,"click").subscribe(this.controlTap.onElementClick,i=>this.onError("Control click tap animation error",i))).add((0,Q.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$.next(!0),e()}}featureIsEnabled(e){return this.options&&Xt(this.options)&&this.options.features[e]}isTouch(){return this.options&&Xt(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,Q.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 Jt="interactive-blink-anim-reference",F={common:Jt,animation:`${Jt}-animation`,disabled:`${Jt}-disabled`},ct=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(F.common,F.animation),this._element=e}restart(){this._element&&(this._element.classList.add(F.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(F.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var er="interactive-container",N={common:er,hidden:`${er}-hidden`,disabled:`${er}-disabled`};var pt=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new tr(r,e)},tr=class extends ee{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(R.common,R.area),i.setAttribute("data-testid",ne.AREA),st({target:i,props:this.control.props,fallback:{...O,backgroundColor:"transparent"}}),me({target:i,layoutParams:this.control.layoutParams,fallback:O}),this.addControlTap(i),this.container.element.append(i),e.append(this.container.element),this.controlElement=i,this.updateShadowStyles(),this.registerEvents()}registerEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,oe.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(N.disabled))return;let t=e.parentElement;if(t){let i=t.querySelector(`.${F.common}`);i&&this.syncBlinkAnimation(i)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,oe.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(N.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,oe.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(hi(e)){let t=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";bi({target:this.controlElement,props:this.control.props,fallback:O,isDark:e,baseDimension:t}),we({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 we({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(F.disabled)||(this.controlElement.classList.add(F.disabled),this.subscriptions.add((0,oe.fromEvent)(e,"animationiteration").pipe((0,oe.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(F.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 ae=require("@vkontakte/videoplayer-shared/es2024");var ut=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 ht=Math.PI,rr=2*ht,dt=ht/2,gi=3*dt,Xs=0,Ys=[Xs,dt,ht,gi];function Ci(r){return r===dt}function Ei(r){return r===ht}function Ti(r){return r===gi}function xi(r){return(r%rr+rr)%rr}function Zs(r){for(let e of Ys)if(r===e)return e}function Ii(r){if(Zs(r))return null;let t=Math.floor(r/dt)+1;return[1,2,3,4][t-1]}function Si(r){return r*180/Math.PI}var Y="interactive-control-fill-animation",_={common:Y,fillerWrapper:`${Y}-filler-wrapper`,filler:`${Y}-filler`,fillHeight:`${Y}-fill-height`,fillWidth:`${Y}-fill-width`,fromTop:`${Y}-from-top`,fromBottom:`${Y}-from-bottom`,fromLeft:`${Y}-from-left`,fromRight:`${Y}-from-right`};var mt=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=xi(e.rotateAngle),l=Ii(o),a=l!==null,c=l===2||!a&&Ei(o)||l===3,d=!a&&Ci(o),m=!a&&Ti(o),f=!c&&!d&&!m,b=d||m,k=a&&!b,x=k?o:0;t.style.borderRadius=e.borderRadius,i.style.transform=`skew(${x*-1}rad)`,b?(n.classList.add(_.fillHeight,d?_.fromTop:_.fromBottom),i.classList.add(_.fillHeight,d?_.fromTop:_.fromBottom)):(n.classList.add(_.fillWidth,f?_.fromLeft:_.fromRight),i.classList.add(_.fillWidth)),e.debug&&console.log(`[interactive ${r.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:b,rotateAngleRad:o,rotateAngelDeg:Si(o),rotateAngleRaw:e.rotateAngle,fromRight:c,fromTop:d,fromBottom:m,fromLeft:f}),this.useSkew=k,this.fromLeft=f,this.rotateAngle=o,this.fillAnimationElement=t,this.fillAnimationFillerElement=n,this.fillAnimationFillerWrapperElement=i,this.startTime=e.startTime,this.endTime=e.endTime,this.shouldFillHeight=b,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 ft=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new ir(r,e)},ir=class extends ee{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(R.common,R.button),i.setAttribute("data-testid",ne.BUTTON),me({target:i,layoutParams:this.control.layoutParams,fallback:O}),st({target:i,props:this.control.props,fallback:O}),we({target:i,props:this.control.props,fallback:O,dependsOn:this.container.dimensions}),ot({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=ut(this.control.type.trim().toLowerCase()),o=n.firstElementChild??n;at({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 mt({startTime:this.startTime,endTime:this.endTime,rotateAngle:this.control.layoutParams.angle??O.angle,borderRadius:i.style.borderRadius})),i.append(n,this.controlFillAnimation?.fillAnimationElement??""),this.container.element.append(this.controlTap?.element??"",i),e.append(this.container.element),this.controlElement=i,this.registerEvents()}registerEvents(){if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add((0,ae.fromEvent)(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(N.disabled))return;let t=e.parentElement;if(t){let i=t.querySelector(`.${F.common}`);i&&this.syncBlinkAnimation(i)}},t=>this.onError("Error happened in mouseleave callback",t))),this.subscriptions.add((0,ae.fromEvent)(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(N.disabled)||this.onBlinkHovering()},t=>this.onError("Error happened in mouseenter callback",t))).add((0,ae.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(F.disabled)||(this.controlElement.classList.add(F.disabled),this.subscriptions.add((0,ae.fromEvent)(e,"animationiteration").pipe((0,ae.once)()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(F.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 Ai=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new nr(r,e)},nr=class extends ee{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(R.common,R.text),i.setAttribute("data-testid",ne.TEXT),me({target:i,layoutParams:this.control.layoutParams,fallback:O}),ot({target:i,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let n=ut(this.control.type.trim().toLowerCase()),o=n.firstElementChild??n;at({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(){}onError(){}};var bt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new or(r,e,t)},or=class extends de{constructor(t,i,n){super(t,n);this.containerElement=null;this.controlSubscriptions=new vt.Subscription;this.error$=new vt.Subject;this.rootElement=i,this.layout=new tt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",ft),this.addControlFactory("text",Ai),this.addControlFactory("area",pt)}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.controlSubscriptions.add(o.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!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(){let t=this.getElement();t&&(this.controlSubscriptions.unsubscribe(),this.controls.forEach(i=>i.removeListeners()),t.remove(),this.isRemoved=!0,this.containerElement=null)}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=H(Nr(),1),C=require("@vkontakte/videoplayer-shared/es2024"),Ie=require("@vkontakte/videoplayer-statistics/es2024");var Lo=require("@vkontakte/videoplayer-shared/es2024");function je(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var Po="video_interactive",Mo="videoint";var Vo=250,Be=class{constructor(e){this.handleZoomChange=je(e=>{this.lastZoomInfo=e},Vo);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,!nt(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=mp(e),this.resizeObserver=new ResizeObserver(je(this.onResize,Vo)),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,Lo.loadVKLangPack)(this.lang,Po,Mo)}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 mp(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 qe=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 l=o.startTime-e;if(l<=n&&(o.endTime&&n<=o.endTime||o.endTime===null)){i=!0;break}n<l&&(t=t===-1?l:Math.min(t,l))}return!i&&t!==-1?t:null}}};var y=require("@interactiveplatform/movika-manifest");var Fo={metadata:"Object",chapters:"Array"},_r=r=>{if(!J(r))return!1;for(let e in Fo)if(!r[e]||!Z(r[e],Fo[e]))return!1;return(0,y.isSupportedManifest)(r.metadata.version)},De=r=>r.type===y.ControlTypes.Text,fp=r=>r.type===y.ControlTypes.Button,vp=r=>r.type===y.ControlTypes.Area,bp={Choice:"Choice",TextInput:"TextInput"},yp={Button:"Button",Area:"Area",Text:"Text"},gp={onClick:"onClick",onSuspense:"onSuspense"},$r={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var wt=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 Rt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{ui(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 Zo=require("@vkontakte/videoplayer-shared/es2024");var kt=class{constructor(e){this.loaders={chapterLoaders:e?.chapterLoaders??[],manifestLoaders:e?.manifestLoaders??[]}}async exec(e,t){return Cp(...this.loaders[e])(t)}};function Cp(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function He(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function Ot({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 l=r.getMedia(n.media,o.videoId),a=r.getGraph(n.graph,o.id);return l?{...i,actions:r,errors:e,result:{chapter:o,media:l,graph:a}}:{...i,errors:He(e,Ot.name,"Could not find media"),actions:r}}}}return{...i,errors:He(e,Ot.name,"Could not find chapter"),actions:r}}var Pt=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 l=i[n];try{l.callback.call(this,e)}catch(a){Promise.resolve().then(()=>{throw a})}l.options&&l.options.once&&this.removeEventListener(e.type,l.callback)}return!e.defaultPrevented}},Ee=class extends Pt{constructor(){super(),this.listeners||Pt.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)}},Ue=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&&(Ue.prototype[Symbol.toStringTag]="AbortController",Ee.prototype[Symbol.toStringTag]="AbortSignal");function Mt(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 jr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Mt({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 f=new t(c,d);return m&&Object.defineProperty(f,"signal",{writable:!1,enumerable:!1,configurable:!0,value:m}),f},o.prototype=t.prototype);let l=e;return{fetch:(s,c)=>{let d=o&&o.prototype.isPrototypeOf(s)?s.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 f=new Promise((b,k)=>{d.addEventListener("abort",()=>k(m),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([f,l(s,c)])}return l(s,c)},Request:o}}var Ep=()=>"fetch"in window,Ge=Ep()&&Mt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),No=Ge?jr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Br=Ge?No.fetch:window.fetch,yf=Ge?No.Request:window.Request,gf=Ge?Ue:window.AbortController,Cf=Ge?Ee:window.AbortSignal;var Vt=(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 Tp=async r=>{try{let e={},t;if(rt(r)){t=new URL(r).href;let n=await Br(t);if(!n.ok)return{};e=await n.json()}else if(J(r))e=r;else return{};if(!_r(e))return{};let i=e.metadata.media;if(rt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=await Br(n);if(!o.ok)throw new Error;e.metadata.media=await o.json()}catch{return Sp(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch{return{}}};async function _o(r){let{manifest:e,manifestURL:t}=await Tp(r);if(!e)throw new Error("Failed on fetch");let i=(0,y.migrateManifestToLatestVersion)(e);return i.media=xp(i.media,t),delete i.metadata.media,i}function Lt(r,e){if(e)return r.find(t=>t.id===e)}function qr(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 Dr(r,e){return r.videos.find(t=>t.id===e)}function xp(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=Ip(n,e);return{...i,url:o||n}})}))}}function Ip(r="",e){try{return new URL(r,e).href}catch{return""}}function Sp(r){return Vt(r,"3.2.0")>=0}var Ko=H(ze(),1);var Ft=r=>it(r)&&!Wt(r),z=r=>r.order==="end",We=r=>it(r.containers)&&!Wt(r.containers)&&z(r),Qo=(r,e)=>{let t=r*1e3;return Ft(e.controls)&&t<(e.startTime??0)},Ur=(r,e)=>{let t=r*1e3;return Ft(e.controls)&&t>=(e.startTime??0)&&t<=(e.endTime??1/0)};var le=(r=[])=>r.some(e=>e.action.type==="expect"),Gr=(r=[])=>r.find(e=>e.action.type==="expect"),Bp=r=>r?.length===1,ce=r=>Bp(r)&&De(r[0]);function Xo(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)}function Nt({gameControllers:r=[],subjectName:e,subjectId:t,execFn:i}){for(let n of r)if(e==="container"&&n.container.container.id===t){i(n),Xo(r,n.container.container.endTime,[n.container.container.id]).forEach(l=>{i(l)});break}}var Yo=(r,e)=>{let t=x=>e.find(({container:u})=>u.container.id===x)?.container.isRemoved,i=le(r.events)&&!t(r.id),n=(x,g=!1,u=!1)=>{let h=u?"every":"some";return x.controls[h](v=>{let E=g?x.endTime===r.endTime:!0;return v.events?.[h](T=>T.action?.type===$r.openURI)&&E})},o=x=>x.some(({container:g})=>n(g.container,!0,!1)&&!g.isRemoved),l=x=>x.every(({container:g})=>g.isRemoved?!0:n(g.container,!0,!0)),a=Xo(e,r.endTime,[r.id]).length,s=x=>x.controls.some(g=>g.events?.some(u=>u.action?.args?.shouldOpenNow)),c=i||a>0,d=o(e),m=n(r),f=l(e),b=i?!1:a>0,k=s(r);return{isExpectTime:c,hasOtherExpect:a>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:f,isExpectEventForCurrentContainer:b,hasShouldOpenNowEvent:k}};var pe=class extends kt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Zo.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:He},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await _o(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",Ot({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:qr,getChapter:Lt,getMedia:Dr,getByBranches:this.getByBranches.bind(this),addErrorMessage:He},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=Lt(this.manifest.chapters,t);if(i){let n=Dr(this.manifest.media,i.videoId),o=qr(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=Lt(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?z(this.chapter):!1}};var Oa=H(_t(),1),Pa=require("@vkontakte/videoplayer-core/es2024"),te=require("@vkontakte/videoplayer-shared/es2024");var Ra=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 ka=H(_t(),1);function Kr(){let r=new Map;function e({listId:o=Math.random().toString(),itemId:l=Math.random().toString(),...a}){let s=r.get(o),c={...a};return s?s[l]=c:r.set(o,{[l]:c}),{listId:o,itemId:l,...a}}function t(o){o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),o.statistics?.oneStat.destroy(),o.statistics?.statSubscription.unsubscribe()}function i(o,l){let a=r.get(o);if(!a)throw Error("Can't remove. Not find.");if(l){let s=a[l];s&&t(s),delete a[l],Object.keys(a).length||r.delete(o)}else{for(let s of(0,ka.default)(a))t(s);r.delete(o)}}function n(){for(let o of r)i(o[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var Te=H(ze(),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 mu=2;function Xr(r){let e=Kr(),t=new te.Subscription,i={},n=null,o=!1,l,a=new te.ValueSubject(null);r&&s(r);function s(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(I=>{let w=T.info.position$.getValue(),$=T.info.isAutoQualityEnabled$.getValue();if(!(!I||!w||$))for(let S of e.map)(0,Oa.default)(S[1]).forEach(({player:M})=>{Ke(M,I)})})).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(ie(i)||g!==i.itemId)return;let u=n.getChapterBranches(),h=new Set;for(let v of u)h.has(v.media.id)||(await f({media:v.media,chapterId:v.chapter.id,setAsActive:!1,title:v.chapter.label}),h.add(v.media.id))}async function m({chapter:{id:g},manifestVideo:u}){if(ie(i)||!n)return;let h=i.player.info.muted$.getValue(),v=i.player.info.currentQuality$.getValue(),E=i.player.info.isAutoQualityEnabled$.getValue(),T=i.player.info.volume$.getValue(),I=i.player.info.currentPlaybackRate$.getValue(),w=!E,$=!1;for(let S of e.map)if(S[0]===u.id&&!n.state.isReplay$.getValue()){let M=Object.keys(S[1]);for(let L of M)L===i.itemId?(M.length<mu||($=!0),e.removePlayer(S[0],L)):($=!0,c(S[0],L,g),w?Ke(i.player,v):i.player.setAutoQuality(!0),i.player.setVolume(T),i.player.setMuted(h),i.player.setPlaybackRate(I))}else e.removePlayer(S[0]);$||(await f({media:u,chapterId:g,setAsActive:!0,playbackRate:I}),w?Ke(i.player,v):i.player.setAutoQuality(!0),i.player.setVolume(T),i.player.setMuted(h))}async function f({media:g,chapterId:u,prefetch:h=!0,setAsActive:v=!0,autoplay:E=!1,preferredExt:T,title:I,playbackRate:w}){let $=Math.random().toString(),S=document.createElement("div");l.append(S);let M;if(n?.options?.vkVideoLoader){let Je=Ra(g);Je.length&&(M=await n.options.vkVideoLoader(...Je))}let L=n?.options?.coreConfig||void 0,W={...L,configName:[...L?.configName??[],"interactive"]},re={container:S,...M?.videos?.[0]||{sources:Qr(g,T).sources},title:I,failoverHosts:M?.failoverHosts||[]},j=new Pa.Player(W,te.Tracer.createRootTracer());j.initVideo(re);let ue=null;if(M?.videos&&n?.options.createOneStat){let Je=M.videos[0],Ut=n.options.createOneStat(Je),si=new te.Subscription;Ut&&(si.add(Ut.attachTo(j)),ue={oneStat:Ut,statSubscription:si})}let ai=new te.Subscription,Bs=i?.player?.info.isAutoQualityEnabled$.getValue();ai.add(j.events.canplay$.subscribe(function(){Bs||Ke(j,i.player.info.currentQuality$.getValue()),w&&j.setPlaybackRate(w)}));let he=e.createPlayer({listId:g.id,itemId:$,player:j,container:S,sources:Qr(g,T).sources,config:re,subscription:ai,statistics:ue});return v&&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 b(){k(),n=null,l.remove()}function k(){t.unsubscribe(),e.removeAll(),i={},o=!1}async function x(){if(!n)throw Error("need to set interactive controller");k(),l=document.createElement("div");let{media:g,chapter:u}=n.getCurrentChapter();g&&u?(t.add(n.events.chapterChanged$.subscribe(m)),await f({media:g,chapterId:u.id,title:u.label})):console.error("not found")}return{...e,init:x,setInteractiveController:s,createPlayer:f,removeAll:b,getActivePlayer:function(){return i},activePlayerChanged:a}}var A={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},xe={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=H(ze(),1),La=require("@vkontakte/videoplayer-shared/es2024");function Yr(r){return function(...t){return r(...t.reverse())}}function Qe(r,...e){return(...t)=>J(e[0])&&J(t[0])?r({...e[0],...t[0]}):r(...e,...t)}var $t=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:l,globalEventEmitter:a,getContainerEventState:s,permanentTextControls:c,interactiveTimeOpenUri:d,disabledControls$:m,onRemove:f,onError:b,disableTextControlContainerVisibilityEvents:k=!1}){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,l)=>{let{isExpectTime:a,hasOtherExpect:s,hasOpenURIEvent:c,hasOpenURIEventInCurrentContainer:d,isAllOpenURIEventsValid:m,hasShouldOpenNowEvent:f}=this.getContainerEventState(),b=this.interactiveTimeOpenUri&&!d,k=this.interactiveTimeOpenUri&&d;if((!this.interactiveTimeOpenUri||b)&&(this.isSelectedControlEvent=!0),o!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||b)){if(this.interactiveTimeOpenUri){let x=!s&&!m&&d;x&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:x})}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,v,E)=>!u&&!h&&v||u&&!h&&v&&!E||u&&!h&&v&&E)(a,s,m,this.isSelectedContainerEvent);this.fakeRemoveView(g)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!a||!s||!f)&&(this.selectBranches.stopExpect(),l())}},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(),i=e instanceof HTMLVideoElement?e.readyState:void 0,n=[6,5];if(!i||(0,Va.default)(n,this.gameState)&&!this.isPermanentText)return;let o=this.player.getExactTime();if(Qo(o,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Ur(o,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let c=this.gameState;this.gameState=3,c===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:c}=this.getContainerEventState(),d=this.selectBranches.state.isExpect,m=this.interactiveTimeOpenUri&&c;if(m&&!d){let f=this.container.getElement();f&&(f.style.visibility!=="hidden"&&this.container.hide?.(),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!m&&this.removeView()}let l=Ur(o,this.container.container),a=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:a,currentTime:o,isInteractiveTime:l};this.container.onProgress(o*1e3,l),this.globalEventEmitter.emit(A.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new La.Subscription,this.player=e,this.interactiveEvents=o,this.getContainerEventState=s;let x=ce(t.container.controls);this.isPermanentText=c&&x,this.disableTextControlContainerVisibilityEvents=k&&x,this.interactiveTimeOpenUri=d,this.disabledControls$=m,this.onRemove=f,this.globalEventEmitter=a,this.gameState=0,this.globalEvents=l,this.onError=b,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(A.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(A.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(){this.container.removeView(),this.globalEventEmitter.emit(A.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)}destroy(){this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:this.container.container.endTime??1/0,id:this.container.container.id})}};var Fa=(r=[])=>r.reduce((e,t,i)=>{let n=(t?.controls??[]).filter(o=>!De(o));if(Ft(n)){let o=[t.startTime??0,t.endTime??1/0],l={id:t.id,isRemoved:!1};if(!i)e.push({subjects:[l],range:o});else{let a=[],s=-1/0,c=1/0,d=[],m=[];for(let f=0;f<e.length;f++){let b=e[f];if(m.push(...b.subjects),b.range[0]<c&&(c=b.range[0]),b.range[1]>s&&(s=b.range[1]),o[0]>=b.range[0]&&o[1]<=b.range[1])return e[f].subjects.push(l),e;o[0]<b.range[0]&&o[1]>b.range[0]&&(a.push(f),d=d.concat(b.subjects)),o[0]>=b.range[0]&&o[0]<=b.range[1]&&(a.push(f),d=d.concat(b.subjects),o[0]=b.range[0]),o[1]>=b.range[0]&&o[1]<=b.range[1]&&(a.push(f),d=d.concat(b.subjects),o[1]=b.range[1])}if(m.push(l),o[0]<=c&&o[1]>=s)return[{subjects:m,range:o}];a.length&&a.reverse().forEach(f=>{e.splice(f,1)}),e.push({subjects:d.concat([l]),range:o})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var vs=H(ze(),1),ti=H(_t(),1),bs=H(ms(),1);function fs(){let r={};function e(){for(let a in r)Object.prototype.hasOwnProperty.call(r,a)&&delete r[a]}function t(a){let s={};for(let c in r)+c<=a&&(s[c]=r[c]);return s}function i(a){let s={};for(let c in r)+c>=a&&(s[c]=r[c]);return s}function n({timestamp:a,priority:s,initiator:c}){if(zt(a)){let d=r[a]??null;if(d&&s&&Se(s,!0)){let m={},f=d[s];return f&&(m={...m,...f}),m=ie(m)?null:m,m&&Se(c,!0)?m[c]??null:m}return d}return null}function o({timestamp:a,priority:s,initiator:c}){if(zt(a))if(r[a]){if(s&&Se(s,!0))if(r[a][s]){if(c&&Se(c,!0))if(r[a][s][c]){if(delete r[a][s][c],!ie(r[a][s]))return!0}else return!1;if(delete r[a][s],!ie(r[a]))return!0}else return!1;return delete r[a]}else return!1;return!1}function l({timestamp:a,priority:s,initiator:c,...d}){r[a]?.[s]?.[c]?r[a][s][c].push({...d}):r[a]?.[s]?r[a][s]={...r[a][s],[c]:[{...d}]}:r[a]?r[a]={...r[a],[s]:{[c]:[{...d}]}}:r[a]={[s]:{[c]:[{...d}]}}}return{map:r,remove:o,add:l,removeAll:e,get:n,getLte:t,getGte:i}}var rh=[y.EventActionTypes.expect,y.EventActionTypes.setNextBranch],ih=1/0;function ys(r,e){let t=r,i,n=nh(e),o=fs(),l,a=()=>{b(),u()},s=h=>{o.add.call(void 0,h),k()},c=(h=[])=>{for(let v of h)if(v.action(),(0,vs.default)(rh,v.actionType))break},d=(h=1/0)=>{let v=Bt(o.get({timestamp:h,priority:"control"})??{}),E=Bt(o.get({timestamp:h,priority:"container"})??{}),T=Bt(o.get({timestamp:h,priority:"chapter"})??{});return[...v,...E,...T]},m=h=>{n.isReady(h)&&c(d(h))},f=()=>{c([...Bt(o.get({timestamp:1/0,priority:"chapter"})??{})])},b=()=>{i&&(l?.unsubscribe(),i=void 0)},k=()=>{i||(i=()=>setTimeout(()=>{m(1/0)}),l=t.events.ended$.subscribe(i))},x=h=>{b(),t=h},g=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),o.remove(h)},u=()=>{n.release(),o.removeAll()};return{setPlayer:x,add:s,remove:g,exec:m,execEndOfVideo:f,listen:k,unlisten:b,release:a,containersEventsCallState:n,getPreparedToExecActions:d}}function nh(r){let e=new Map;return{setCalled:({timestamp:a,id:s})=>{let c=e.get(a);c&&c[s]!==void 0&&(c[s]=!0)},setData:(a=[])=>{for(let s of a){let c=s.endTime??ih,d=e.get(c);e.set(c,{...d,[s.id]:!1})}},resetCalled:a=>{let s=e.get(a);if(s)for(let c in s)s[c]=!1},isReady:a=>{let s=e.get(a);if(!s)return!0;let c=(0,ti.default)(s);return r?c.some(m=>m):!c.some(m=>!m)},release:()=>e.clear()}}function Bt(r){return(0,bs.default)((0,ti.default)(r)).sort(e=>e.actionType===y.EventActionTypes.expect?-1:1)}var gs={videoContentHeight:0,videoContentWidth:0},Cs=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return gs;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return gs;let o=e/t,l=i/n,a,s;return l>o?(s=n,a=n*o):l<o?(s=i/o,a=i):(s=n,a=i),{videoContentWidth:s,videoContentHeight:a}};var oh=250;function Es(r){let e,t=new ResizeObserver(a=>{o(a),e=o.bind(null,a)});function i(a){let{parentElement:s,player:c}=r();if(s&&c){let{videoContentWidth:d,videoContentHeight:m}=Cs(c);s.style.setProperty("--interactive-content-width",`${d}px`),s.style.setProperty("--interactive-content-height",`${m}px`),s.style.setProperty("--interactive-width",`${a[0].contentRect.width}px`),s.style.setProperty("--interactive-height",`${a[0].contentRect.height}px`)}}function n(){let{parentElement:a}=r();a.removeAttribute("style")}let o=je(a=>{let{fns:s=[]}=r();i(a);for(let c of s)c()},oh);function l(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e?.()},release:l}}var ah=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},Is=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 Ss=r=>{let e=r.length,t=ah(e);return r[t]},Ts=1,As=r=>{let e=0;for(let i=0;i<r.length;++i)e+=r[i].weight??Ts;let t=Math.random()*e;e=0;for(let i=0;i<r.length-1;++i)if(e+=r[i].weight??Ts,e>=t)return r[i];return r[r.length-1]};var ws={shouldOpenNow:!0,isDetachContainer:!0},Rs="after-expect",ri=(r,e=!1)=>({...r,args:e?{...r.args,...ws}:{...ws,...r.args}}),ks=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:u,controlType:h,controlId:v,containerId:E,branches:T=[],onEvent:I,isEOV:w=()=>!1,isDisabled:$=()=>!1})=>{let S=ri(u,w()),M={timestamp:1/0,priority:"control",initiator:v,actionType:S.type},L=$(),W=r.emit.bind(r,A.interactives,{subjectId:v,subjectType:h,subjectName:"control",type:L?P.actionChoiceCanceled:P.actionChoice,actionType:u.type,payload:{invokeImmediately:S.args.shouldOpenNow,containerId:E,...S.args}}),re=()=>{e.interactiveActionChoice$.next({subjectId:v,subjectType:h,subjectName:"control",type:L?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:S.args.shouldOpenNow,containerId:E,...S.args}})};if(L){W(),re();return}switch(S.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let j=T.find(ue=>ue.id===S.args.branchId);if(!j)return;I(S.args.isDetachContainer,b.bind(null,{subjectId:v,subjectName:"control"})),W(),re(),S.args.shouldOpenNow?x({subjectId:v,subjectName:"control",subjectType:h,action:S,payload:{chapterId:j.chapterId,autoSelect:!1}}):i.add({...M,action:x.bind(null,{subjectId:v,subjectName:"control",subjectType:h,action:S,payload:{chapterId:j.chapterId,autoSelect:!1}})});return}case y.EventActionTypes.continuePlayback.trim().toLowerCase():{I(S.args.isDetachContainer,b.bind(null,{subjectId:v,subjectName:"control"})),W(),re(),S.args.shouldOpenNow?k({subjectId:v,subjectName:"control",subjectType:h,action:u}):i.add({...M,action:k.bind(null,{subjectId:v,subjectName:"control",subjectType:h,action:u})});return}case y.EventActionTypes.openURI.trim().toLowerCase():{I(S.args.isDetachContainer,b.bind(null,{subjectId:v,subjectName:"control"})),W(),re(),S.args.shouldOpenNow?g({subjectId:v,subjectName:"control",subjectType:h,action:S,payload:{URI:u.args.uri}}):i.add({...M,action:g.bind(null,{subjectId:v,subjectName:"control",subjectType:h,action:S,payload:{URI:u.args.uri}})});return}default:{let j="Unexpected control event",ue=new V(1,1,{message:j});d(ue,j);return}}},a=({action:u,container:{id:h,endTime:v},branches:E=[],isEOV:T=!1,autoSelected:I=!1})=>{let w=ri(u,T),$={timestamp:!w.args.shouldOpenNow||T?1/0:v??1/0,priority:"container",initiator:h,actionType:w.type},S=r.emit.bind(r,A.interactives,{subjectId:h,subjectName:"container",type:P.actionChoice,actionType:w.type,payload:{invokeImmediately:w.args.shouldOpenNow,...w.args}}),M=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:w.type,payload:{invokeImmediately:w.args.shouldOpenNow,...w.args}})};switch(w.type.trim().toLowerCase()){case y.EventActionTypes.setNextBranch.trim().toLowerCase():{let L=E.find(W=>W.id===w.args.branchId);if(!L)return;S(),M(),i.add({...$,action:x.bind(null,{subjectId:h,subjectName:"container",action:w,payload:{chapterId:L.chapterId,autoSelect:I}})});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():{S(),M(),i.add({...$,action:k.bind(null,{subjectId:h,subjectName:"container",action:w})});return}case y.EventActionTypes.openURI.trim().toLowerCase():{S(),M(),i.add({...$,action:g.bind(null,{subjectId:h,subjectName:"container",action:w,payload:{URI:u.args.uri}})});return}default:{let L="Unexpected container event",W=new V(1,1,{message:L});d(W,L);return}}};function s({container:u,branches:h,isEOV:v=!1}){let E=Gr(u.events);if(E){let T=ri(E.action,v);r.emit(A.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:v?1/0:u.endTime??1/0,priority:"container",initiator:u.id,actionType:y.EventActionTypes.expect,action:f.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:v})}let c=({chapterId:u,action:h,branches:v=[]})=>{let E=r.emit.bind(r,A.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 I=v.find(w=>w.id===h.args.branchId);return I?.chapterId?(E(),T(),x.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let I=Ss(v);return I?.chapterId?(E(),T(),x.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setRandomBranch.trim().toLowerCase():{let I=As(v);return I?.chapterId?(E(),T(),x.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let I=Is(v);return I?.chapterId?(E(),T(),x.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.chapterId,autoSelect:!0}})):void 0}case y.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let I=xs(v);return I?.chapterId?(E(),T(),x.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:I.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 I="Unexpected chapter event",w=new V(1,1,{message:I});d(w,I);return}}};function d(u,h){console.error(h),e.error$.next(u),r.emit(A.errors,u)}function m(u){let h=Gr(u.events);if(h){if(z(u))return;r.emit(A.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:f.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else u.events?.forEach(v=>{let E=c({chapterId:u.id,action:v.action,branches:u.branches});E&&i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:v.action.type,action:E})})}let f=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(A.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})},b=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(A.interactives,{subjectId:u,subjectName:h,type:P.actionExecution,actionType:Rs}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:Rs})},k=({subjectId:u,subjectName:h,subjectType:v,action:E})=>{r.emit(A.interactives,{subjectId:u,subjectName:h,subjectType:v,type:P.actionExecution,actionType:E.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:v,type:"action-execution",actionType:E.type})},x=({subjectId:u,subjectName:h,subjectType:v,action:E,payload:T})=>{T.behaviour="change-chapter",r.emit(A.interactives,{subjectId:u,subjectName:h,subjectType:v,type:P.actionExecution,actionType:E.type,payload:T}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:v,type:"action-execution",actionType:E.type,payload:T})},g=({subjectId:u,subjectName:h,subjectType:v,action:E,payload:T})=>{if(!T.URI)return;let I=window.open(T.URI,"_blank","noopener,noreferrer");I&&(I.opener=null),r.emit(A.interactives,{subjectId:u,subjectName:h,subjectType:v,type:P.actionExecution,actionType:E.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:v,type:"action-execution",actionType:E.type})};return{onControlEvent:l,onContainerEvent:a,onChapterEvent:c,onExpectEvent:f,expectEventHandler:b,setManifestChapterEvents:m,setManifestContainerEvents:s,stopExpect:o,state:n}};var oi=H(Nr(),1),D=require("@vkontakte/videoplayer-shared/es2024");var qt=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(l=>l.id===i);if(!n)return null;let o=e.media.videos.find(l=>n.videoId===l.id);if(!o)return null;t[i]=ii(o)}return t[i]}).filter(Boolean)},Os=r=>{for(let e of r.variants)if(Ps(e)&&e.payload)return e.payload.id},Ps=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),ii=r=>{let e=Os(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Ms=(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=Ms(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(l=>{this.state.prevChapter$.next((0,oi.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===this.#e?.metadata?.initChapterId),this.state.isGoBackLimited$.next(this.#c===this.#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,l=qt(o,i);if(this.#p=l,this.state.history$.next(o),!(!t||!this.#r||!this.#i))try{await this.#r.save(this.#i,l)}catch{let s=new V(1,5,"Unable to save interactive history");this.events.error$.next(s),this.#t?.emit(A.errors,s)}}async goBack(){if(!this.state||!this.#n){let i=new V(1,5,"Unable to save interactive history");return this.events.error$.next(i),this.#t?.emit(A.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 V(1,5,"Error while trying to fetch data");this.events.error$.next(o),this.#t?.emit(A.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 qt([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(A.historyDestroyed),this.events.destroyed$.next(),this.#t=null}};var Dt=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 Ht=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;
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
height: var(--interactive-height);
|
|
12
12
|
background-color: var(--black);
|
|
13
13
|
visibility: hidden;
|
|
14
|
-
`,this.lastFrameCanvas=new
|
|
14
|
+
`,this.lastFrameCanvas=new Dt,this.endOffsetMs=t,this._callbacks={onError:i},this.lastFrameCanvas.rootElement.style.cssText=`
|
|
15
15
|
position: absolute;
|
|
16
16
|
top: 50%;
|
|
17
17
|
left: 50%;
|
|
18
18
|
transform: translate(-50%, -50%);
|
|
19
|
-
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),
|
|
19
|
+
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),i={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(i,e)}catch(n){this._onError(n)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>t.controls?.length&&e>=(t.startTime??0)&&e<=Math.min(t.endTime??1/0,this.currentVideoDurationMs-this.endOffsetMs))}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){this._callbacks?.onError?.(e)}};function Vs(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var Ls=`/* interactive-container */
|
|
20
20
|
.interactive-container {
|
|
21
21
|
opacity: 1;
|
|
22
22
|
visibility: visible;
|
|
@@ -181,4 +181,74 @@
|
|
|
181
181
|
opacity: var(--interactive-area-hover-opacity);
|
|
182
182
|
animation: none;
|
|
183
183
|
}
|
|
184
|
-
`;var Ia=r=>{let e=document.createElement("style");e.textContent=Ea,r.prepend(e)};var Sa=require("@vkontakte/videoplayer-core/es2024");var xa=Object.freeze({lang:g.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},isTouch:!1,animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1,controlsTapPlace:!1}});function Wu(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var Xe=class{constructor(e){this.playerSubscriptions=new g.Subscription;this.subscriptions=new g.Subscription;this.globalEventEmitter=new It;this.animation=new xt;this.seekToInteractiveController=new Fe;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Wu();this.factories=new Map([["choice",ht]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new g.Subscription;this.graph=null;this.lastFrame=null;this.blinkAnimationRef=null;this.appState=0;this.state={prevChapter$:new g.ValueSubject(null),isInitialChapter$:new g.ValueSubject(!1),isFirstChapter$:new g.ValueSubject(!0),isEndChapter$:new g.ValueSubject(!1),isInteractiveExpectation$:new g.ValueSubject(!1),isReplay$:new g.ValueSubject(!1),calledByInteractive$:new g.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new g.ValueSubject(!1),disabledControls$:new g.ValueSubject(!1),interactiveRanges$:new g.ValueSubject([]),isInteractiveTime$:new g.ValueSubject(!1),statistics$:new g.ValueSubject(null),isSeekable$:new g.ValueSubject(!1)};this.events={noInteraction$:new g.Subject,graphVisibilityChanged$:new g.Subject,watchAgainIsClicked$:new g.Subject,chapterChanged$:new g.Subject,playerChanged$:new g.Subject,error$:new g.Subject,eachTick$:new g.Subject,manifestChanged$:new g.Subject,interactiveRangeEnded$:new g.Subject,interactiveContainerRemoved$:new g.Subject,interactiveContainerFakeRemoved$:new g.Subject,interactiveActionExecution$:new g.Subject,interactiveActionChoice$:new g.Subject,interactiveVisibilityChanged$:new g.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(S.errors,e)};this.clearHistoryIfEnded=()=>{let e=this.player?.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&G(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...n}=e;if(t){let{statSubscription:i,oneStat:o}=t;i.add(o.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(S.playerChanged,n)};this.onPlaybackStarted=()=>{this.resizeManager?.calc(),this.animation.requestAnimation()};this.destroyGameControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,i=t.getValue().map(o=>({...o,subjects:o.subjects.filter(l=>l.id!==e)}));t.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};if(this._options={...xa,...e,config:{...xa.config,...e.config}},this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new at,this.blinkAnimationRef.create();let i=this.blinkAnimationRef.element;i&&this.rootElement.append(i)}this._options.parentElement.append(this.rootElement),this.historyController=new Qe({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:this._options.projectInfo?.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new jt({parentElement:this._options.parentElement,onError:i=>{let o=new M(1,6,i);this.emitErrorEvent(o)}})),Ia(this._options.parentElement),this.subscriptions.add((0,g.fromEvent)(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add((0,g.fromEvent)(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new le(this._options.loaders,i=>{let o=new M(1,3,i);this.emitErrorEvent(o)});let n=[];this._options.lastFrame&&n.push(()=>{this.lastFrame?.updateCanvasDimensions(!0)}),n.push(()=>{let i=this.state.isInteractiveTime$.getValue();for(let o of this.gameControllers)o.onResize(i)}),this.resizeManager=la(()=>({player:this.player,parentElement:this._options.parentElement,fns:n})),this._options.graph&&(this.graph=new je({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(S.graph,{type:Ee.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let o=new M(1,2,{message:i});this.emitErrorEvent(o)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),e.payload?.behaviour==="change-chapter"){let{chapterId:t}=e.payload;this.setChapter({chapterId:t}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(e.payload?.behaviour==="change-manifest"){let{manifestURL:t}=e.payload;t&&this.setManifest(t)}e.actionType==="expect"?(this.state.isInteractiveExpectation$.next(!0),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType==="after-expect"&&(this.state.isInteractiveExpectation$.next(!1),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}))})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:n})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in n&&n.invokeImmediately||this.destroyGameControllers(!1)}))}async initSeamless(){this.seamlessController=Ur(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,i=this.getInteractiveRanges().reverse().find(({range:o})=>t>=o[1]);if(i){let o=i.range.join("-");this.endedRanges.has(o)||(this.endedRanges.add(o),this.globalEventEmitter.emit(S.interactives,{type:O.rangeEnded,payload:i,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:i}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe((0,g.once)()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,g.combine)({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:n})=>{let i;if(n)i=!0;else{let a=e*1e3;i=!!t.find(({range:[d,f],subjects:v})=>d<a&&a<f&&v.some(y=>!y.isRemoved)&&v.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let o=!!this.noInteractionTimeout,s=this.player?.info.playbackState$.getValue()==="playing"||n;i&&!o&&s?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):o&&!s&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{this.lastFrame?.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{e&&this.lastFrame?.setVideoElement(e)})).add(this.player.events.firstFrame$.subscribe(()=>{this.lastFrame?.reset(),setTimeout(()=>{this.lastFrame?.hide(),this.lastFrame?.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){let e=this.manifestController.chapter;e&&this.appState===1&&(this.selectBranches?.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),this.interactiveEvents?.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(t=>t.container.container).filter(t=>!ae(t.controls))),this._options.lastFrame&&this.animation.addFn(()=>{this.player&&this.lastFrame?.onEachTick(this.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let t=[];return e.containers.forEach(n=>{let i=n.type.trim().toLowerCase(),l=this.factories.get(i)?.(n,this.rootElement,{isTouch:this._options?.isTouch??!1,features:{controlsExpectTimeBlinkAnimation:this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation,controlsTapPlace:this._options.animationsFeatureToggles?.controlsTapPlace}});if(l&&this.selectBranches&&this.interactiveEvents&&this.player){let s=new Mt({player:this.player,container:l,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>jo(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)},onError:this.emitErrorEvent});this.animation.addFn(s.whilePlaying,!0),t.push(s)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),n=!!this.seekToInteractiveController.getNextInteractiveTime();(n&&!t||!n&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(n&&G(n)&&Ge(n))??!1,o=this.manifestController.manifest?.metadata.initChapterId===e,l=this.historyController.state.history$.getValue();if(o||i&&t){this.historyController.updateHistory([e]);return}(0,Ta.default)(l,-1)!==e&&this.historyController.updateHistory([...l,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,o=n.getValue().map(l=>{let s=l.subjects.some(c=>c.id===e),a=l.subjects.map(c=>t&&s||c.id===e?{...c,isRemoved:!0}:c);return{...l,subjects:a}});n.next(o)}reset(){this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),this.interactiveEvents?.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}toggleBlinkAnimation(e){if(!this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation)return;let t=(n,i)=>{n.toggleBlinkAnimation(i)};Pt({...e,gameControllers:this.gameControllers,execFn:We(Gr(t),e.isExpect)}),e.isExpect&&this.blinkAnimationRef?.restart()}updateControlsShadowStyles(e){if(!this._options.animationsFeatureToggles?.areaControlShadow)return;let t=(n,i)=>{n.updateControlsShadowStyles(i)};e.isExpect?Pt({...e,gameControllers:this.gameControllers,execFn:We(Gr(t),!1)}):Pt({...e,gameControllers:this.gameControllers,execFn:t})}get options(){return this._options}init(){this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&(this.resizeManager?.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(S.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=oa(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=va({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&Sa.clientChecker.browser.isSafari&&await ga(35);let i=!n&&this.state.isEndChapter$.getValue()&&this.getCurrentManifest()?.metadata.initChapterId===e;this.state.isReplay$.next(i);let{chapter:o,media:l,graph:s}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||i)&&this.state.isFirstChapter$.next(!0),!(!o||!l)&&(t&&this.pushChapterToHistory(o.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(o),this.lastFrame?.setCurrentChapter(o),this.events.chapterChanged$.next({chapter:o,manifestVideo:l}),this.globalEventEmitter.emit(S.chapterChanged,{chapter:o,media:l,graph:s}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new g.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?Ie.InteractiveInterfaceClick.GRAPH_SHOW:Ie.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Ie.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(Ie.InteractiveInterfaceClick.NEXT_BUTTON),i==="Area"&&e.next(Ie.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new g.Observable(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t?.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(S.graph,{type:Ee.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){Array.isArray(e)&&this.graph?.setVisitedChapters(e)}updateGraphVideosInfo(e){Array.isArray(e)&&this.graph?.updateVideosInfo(e)}deadEndCheck(){return!(this.interactiveEvents?.getPreparedToExecActions()||[]).some(n=>n.actionType===b.EventActionTypes.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&se(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,b.isSupportedManifest)(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){return Is(this.manifestController.chapter?.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){this.clearHistoryIfEnded(),this.blinkAnimationRef?.destroy(),this.destroyGameControllers(),this.gameControllers=[],this.graph?.destroy(),this.seamlessControllerSubs.unsubscribe(),this.seamlessController?.removeAll(),this.resizeManager?.release(),this.animation.release(),this.interactiveEvents?.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),this.lastFrame?.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var wa={Container:ue,createChoiceContainer:ht,createAreaControl:lt,createButtonControl:pt,classnamesPrefix:ln};var Ku={version:nn};
|
|
184
|
+
|
|
185
|
+
/* fill animation */
|
|
186
|
+
|
|
187
|
+
.interactive-control-fill-animation {
|
|
188
|
+
position: absolute;
|
|
189
|
+
overflow: hidden;
|
|
190
|
+
z-index: -1;
|
|
191
|
+
pointer-events: none;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.interactive-control-fill-animation-filler-wrapper {
|
|
195
|
+
position: absolute;
|
|
196
|
+
width: 100%;
|
|
197
|
+
height: 100%;
|
|
198
|
+
transform-origin: center;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-fill-width {
|
|
202
|
+
top: 0;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-fill-height {
|
|
206
|
+
left: 0;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-right {
|
|
210
|
+
right: 0;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-left {
|
|
214
|
+
left: 0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-top {
|
|
218
|
+
top: 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-bottom {
|
|
222
|
+
bottom: 0;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.interactive-control-fill-animation-filler {
|
|
226
|
+
width: 100%;
|
|
227
|
+
height: 100%;
|
|
228
|
+
background-color: rgba(173, 211, 255, 0.32);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.interactive-control-fill-animation-filler.interactive-control-fill-animation-fill-width {
|
|
232
|
+
transform: scaleX(0);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.interactive-control-fill-animation-filler.interactive-control-fill-animation-fill-height {
|
|
236
|
+
transform: scaleY(0);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.interactive-control-fill-animation-filler.interactive-control-fill-animation-from-right {
|
|
240
|
+
transform-origin: right;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.interactive-control-fill-animation-filler.interactive-control-fill-animation-from-left {
|
|
244
|
+
transform-origin: left;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.interactive-control-fill-animation-filler.interactive-control-fill-animation-from-top {
|
|
248
|
+
transform-origin: top;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.interactive-control-fill-animation-filler.interactive-control-fill-animation-from-bottom {
|
|
252
|
+
transform-origin: bottom;
|
|
253
|
+
}
|
|
254
|
+
`;var Fs=r=>{let e=document.createElement("style");e.textContent=Ls,r.prepend(e)};var $s=require("@vkontakte/videoplayer-core/es2024");var Ns=Object.freeze({lang:C.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},isTouch:!1,disableTextControlContainerVisibilityEvents:!1,animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1,controlsTapPlace:!1,controlsFillAnimation:!1}});function ch(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var Ze=class{constructor(e){this.playerSubscriptions=new C.Subscription;this.subscriptions=new C.Subscription;this.globalEventEmitter=new wt;this.animation=new Rt;this.seekToInteractiveController=new qe;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=ch();this.factories=new Map([["choice",bt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new C.Subscription;this.graph=null;this.lastFrame=null;this.blinkAnimationRef=null;this.appState=0;this.state={prevChapter$:new C.ValueSubject(null),isInitialChapter$:new C.ValueSubject(!1),isFirstChapter$:new C.ValueSubject(!0),isEndChapter$:new C.ValueSubject(!1),isInteractiveExpectation$:new C.ValueSubject(!1),isReplay$:new C.ValueSubject(!1),calledByInteractive$:new C.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new C.ValueSubject(!1),disabledControls$:new C.ValueSubject(!1),interactiveRanges$:new C.ValueSubject([]),isInteractiveTime$:new C.ValueSubject(!1),statistics$:new C.ValueSubject(null),isSeekable$:new C.ValueSubject(!1)};this.events={noInteraction$:new C.Subject,graphVisibilityChanged$:new C.Subject,watchAgainIsClicked$:new C.Subject,chapterChanged$:new C.Subject,playerChanged$:new C.Subject,error$:new C.Subject,eachTick$:new C.Subject,manifestChanged$:new C.Subject,interactiveRangeEnded$:new C.Subject,interactiveContainerRemoved$:new C.Subject,interactiveContainerFakeRemoved$:new C.Subject,interactiveActionExecution$:new C.Subject,interactiveActionChoice$:new C.Subject,interactiveVisibilityChanged$:new C.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(A.errors,e)};this.clearHistoryIfEnded=()=>{let e=this.player?.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:i}=this.getCurrentChapter();e&&i&&z(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...i}=e;if(t){let{statSubscription:n,oneStat:o}=t;n.add(o.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(i),this.globalEventEmitter.emit(A.playerChanged,i)};this.onPlaybackStarted=()=>{this.resizeManager?.calc(),this.animation.requestAnimation()};this.destroyGameControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(o=>({...o,subjects:o.subjects.filter(l=>l.id!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};if(this._options={...Ns,...e,config:{...Ns.config,...e.config}},this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new ct,this.blinkAnimationRef.create();let n=this.blinkAnimationRef.element;n&&this.rootElement.append(n)}this._options.parentElement.append(this.rootElement),this.historyController=new Ye({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:this._options.projectInfo?.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Ht({parentElement:this._options.parentElement,onError:n=>{let o=new V(1,6,n);this.emitErrorEvent(o)}})),Fs(this._options.parentElement),this.subscriptions.add((0,C.fromEvent)(this.rootElement,"mousedown").subscribe(n=>n.stopPropagation())).add((0,C.fromEvent)(this.rootElement,"mouseup").subscribe(n=>n.stopPropagation())),this.manifestController=new pe(this._options.loaders,n=>{let o=new V(1,3,n);this.emitErrorEvent(o)});let i=[];this._options.lastFrame&&i.push(()=>{this.lastFrame?.updateCanvasDimensions(!0)}),i.push(()=>{let n=this.state.isInteractiveTime$.getValue();for(let o of this.gameControllers)o.onResize(n)}),this.resizeManager=Es(()=>({player:this.player,parentElement:this._options.parentElement,fns:i})),this._options.graph&&(this.graph=new Be({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:n=>{this.setChapter({chapterId:n}),this.globalEventEmitter.emit(A.graph,{type:xe.watchAgainClicked,chapterId:n}),this.events.watchAgainIsClicked$.next(n)},onError:n=>{let o=new V(1,2,{message:n});this.emitErrorEvent(o)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),e.payload?.behaviour==="change-chapter"){let{chapterId:t}=e.payload;this.setChapter({chapterId:t}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(e.payload?.behaviour==="change-manifest"){let{manifestURL:t}=e.payload;t&&this.setManifest(t)}e.actionType==="expect"?(this.state.isInteractiveExpectation$.next(!0),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType==="after-expect"&&(this.state.isInteractiveExpectation$.next(!1),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}))})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:i})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in i&&i.invokeImmediately||this.destroyGameControllers(!1)}))}async initSeamless(){this.seamlessController=Xr(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:o})=>t>=o[1]);if(n){let o=n.range.join("-");this.endedRanges.has(o)||(this.endedRanges.add(o),this.globalEventEmitter.emit(A.interactives,{type:P.rangeEnded,payload:n,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:n}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe((0,C.once)()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,C.combine)({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:i})=>{let n;if(i)n=!0;else{let s=e*1e3;n=!!t.find(({range:[d,m],subjects:f})=>d<s&&s<m&&f.some(b=>!b.isRemoved)&&f.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let o=!!this.noInteractionTimeout,a=this.player?.info.playbackState$.getValue()==="playing"||i;n&&!o&&a?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):o&&!a&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{this.lastFrame?.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{e&&this.lastFrame?.setVideoElement(e)})).add(this.player.events.firstFrame$.subscribe(()=>{this.lastFrame?.reset(),setTimeout(()=>{this.lastFrame?.hide(),this.lastFrame?.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){let e=this.manifestController.chapter;e&&this.appState===1&&(this.selectBranches?.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),this.interactiveEvents?.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(t=>t.container.container).filter(t=>!ce(t.controls))),this._options.lastFrame&&this.animation.addFn(()=>{this.player&&this.lastFrame?.onEachTick(this.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let t=[];return e.containers.forEach(i=>{let n=i.type.trim().toLowerCase(),l=this.factories.get(n)?.(i,this.rootElement,{isTouch:this._options?.isTouch??!1,features:{controlsExpectTimeBlinkAnimation:this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation,controlsTapPlace:this._options.animationsFeatureToggles?.controlsTapPlace,controlsFillAnimation:this._options.animationsFeatureToggles?.controlsFillAnimation}});if(l&&this.selectBranches&&this.interactiveEvents&&this.player){let a=new $t({player:this.player,container:l,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>Yo(i,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(i.id)},onError:this.emitErrorEvent,disableTextControlContainerVisibilityEvents:this.options.disableTextControlContainerVisibilityEvents??!1});this.animation.addFn(a.whilePlaying,!0),t.push(a)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),i=!!this.seekToInteractiveController.getNextInteractiveTime();(i&&!t||!i&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(i&&z(i)&&We(i))??!1,o=this.manifestController.manifest?.metadata.initChapterId===e,l=this.historyController.state.history$.getValue();if(o||n&&t){this.historyController.updateHistory([e]);return}(0,_s.default)(l,-1)!==e&&this.historyController.updateHistory([...l,e])}handleFakeRemoval(e,t){let{interactiveRanges$:i}=this.state,o=i.getValue().map(l=>{let a=l.subjects.some(c=>c.id===e),s=l.subjects.map(c=>t&&a||c.id===e?{...c,isRemoved:!0}:c);return{...l,subjects:s}});i.next(o)}reset(){this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),this.interactiveEvents?.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}toggleBlinkAnimation(e){if(!this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation)return;let t=(i,n)=>{i.toggleBlinkAnimation(n)};Nt({...e,gameControllers:this.gameControllers,execFn:Qe(Yr(t),e.isExpect)}),e.isExpect&&this.blinkAnimationRef?.restart()}updateControlsShadowStyles(e){if(!this._options.animationsFeatureToggles?.areaControlShadow)return;let t=(i,n)=>{i.updateControlsShadowStyles(n)};e.isExpect?Nt({...e,gameControllers:this.gameControllers,execFn:Qe(Yr(t),!1)}):Nt({...e,gameControllers:this.gameControllers,execFn:t})}get options(){return this._options}init(){this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&(this.resizeManager?.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(A.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=ys(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=ks({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:i=!1}={}){this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&$s.clientChecker.browser.isSafari&&await Vs(35);let n=!i&&this.state.isEndChapter$.getValue()&&this.getCurrentManifest()?.metadata.initChapterId===e;this.state.isReplay$.next(n);let{chapter:o,media:l,graph:a}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||n)&&this.state.isFirstChapter$.next(!0),!(!o||!l)&&(t&&this.pushChapterToHistory(o.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(o),this.lastFrame?.setCurrentChapter(o),this.events.chapterChanged$.next({chapter:o,manifestVideo:l}),this.globalEventEmitter.emit(A.chapterChanged,{chapter:o,media:l,graph:a}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new C.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?Ie.InteractiveInterfaceClick.GRAPH_SHOW:Ie.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Ie.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(Ie.InteractiveInterfaceClick.NEXT_BUTTON),n==="Area"&&e.next(Ie.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new C.Observable(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t?.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(A.graph,{type:xe.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){Array.isArray(e)&&this.graph?.setVisitedChapters(e)}updateGraphVideosInfo(e){Array.isArray(e)&&this.graph?.updateVideosInfo(e)}deadEndCheck(){return!(this.interactiveEvents?.getPreparedToExecActions()||[]).some(i=>i.actionType===y.EventActionTypes.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(i=>{let n=i.container.container;return!i.container.isRemoved&&n.endTime===null&&le(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,y.isSupportedManifest)(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){return Fa(this.manifestController.chapter?.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){this.clearHistoryIfEnded(),this.blinkAnimationRef?.destroy(),this.destroyGameControllers(),this.gameControllers=[],this.graph?.destroy(),this.seamlessControllerSubs.unsubscribe(),this.seamlessController?.removeAll(),this.resizeManager?.release(),this.animation.release(),this.interactiveEvents?.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),this.lastFrame?.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var js={Container:de,createChoiceContainer:bt,createAreaControl:pt,createButtonControl:ft,classnamesPrefix:di};var ph={version:ci};
|