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