@vkontakte/videoplayer-interactive 1.0.31-dev.684e92f5.0 → 1.0.31-dev.a8108f50.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 +43 -6
- package/es2015.esm.js +43 -6
- package/es2018.cjs.js +43 -6
- package/es2018.esm.js +43 -6
- package/esnext.cjs.js +43 -6
- package/esnext.esm.js +43 -6
- package/evergreen.esm.js +43 -6
- package/package.json +4 -4
- package/types/modules/Interactives/Interactives.d.ts +0 -1
- package/types/modules/Interactives/containers/ChoiceContainer.d.ts +8 -8
- package/types/modules/Interactives/containers/Container.d.ts +7 -5
- package/types/modules/Interactives/containers/index.d.ts +2 -0
- package/types/modules/Interactives/containers/types.d.ts +9 -0
- package/types/modules/Interactives/containers/utils.d.ts +6 -0
- package/types/modules/Interactives/controls/AreaControl.d.ts +11 -2
- package/types/modules/Interactives/controls/ButtonControl.d.ts +11 -2
- package/types/modules/Interactives/controls/Control.d.ts +12 -9
- package/types/modules/Interactives/controls/TextControl.d.ts +11 -2
- package/types/modules/Interactives/controls/index.d.ts +4 -2
- package/types/modules/Interactives/controls/types.d.ts +17 -8
- package/types/modules/Interactives/controls/utils.d.ts +9 -0
- package/types/modules/Interactives/index.d.ts +39 -4
- package/types/modules/Interactives/styles.d.ts +1 -0
- package/types/modules/Interactives/types.d.ts +4 -12
- package/types/modules/Interactives/utils/GameController.d.ts +5 -9
- package/types/modules/Interactives/utils/InteractiveEvents.d.ts +1 -1
- package/types/modules/Interactives/utils/events.d.ts +1 -3
- package/types/modules/Interactives/utils/events.types.d.ts +0 -2
- package/types/modules/Interactives/utils/gameUtils.d.ts +1 -2
- package/types/modules/Interactives/utils/getInteractiveRanges.d.ts +1 -5
- package/types/modules/Interactives/utils/renderingUtils.d.ts +0 -3
package/es2018.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.31-dev.
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.31-dev.a8108f50.0
|
|
3
|
+
* Mon, 17 Feb 2025 12:16:24 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-31/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var wo=Object.create;var tt=Object.defineProperty;var Ao=Object.getOwnPropertyDescriptor;var Ro=Object.getOwnPropertyNames;var Oo=Object.getPrototypeOf,Po=Object.prototype.hasOwnProperty;var nn=r=>{throw TypeError(r)};var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ko=(r,e)=>{for(var t in e)tt(r,t,{get:e[t],enumerable:!0})},an=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ro(e))!Po.call(r,i)&&i!==t&&tt(r,i,{get:()=>e[i],enumerable:!(n=Ao(e,i))||n.enumerable});return r};var Q=(r,e,t)=>(t=r!=null?wo(Oo(r)):{},an(e||!r||!r.__esModule?tt(t,"default",{value:r,enumerable:!0}):t,r)),Vo=r=>an(tt({},"__esModule",{value:!0}),r);var sn=(r,e,t)=>e.has(r)||nn("Cannot "+t);var A=(r,e,t)=>(sn(r,e,"read from private field"),t?t.call(r):e.get(r)),_=(r,e,t)=>e.has(r)?nn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),j=(r,e,t,n)=>(sn(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var on=(r,e,t,n)=>({set _(i){j(r,e,i,t)},get _(){return A(r,e,n)}});var Y=p((Yt,fn)=>{"use strict";var Oe=function(r){return r&&r.Math===Math&&r};fn.exports=Oe(typeof globalThis=="object"&&globalThis)||Oe(typeof window=="object"&&window)||Oe(typeof self=="object"&&self)||Oe(typeof global=="object"&&global)||Oe(typeof Yt=="object"&&Yt)||function(){return this}()||Function("return this")()});var F=p((kh,mn)=>{"use strict";mn.exports=function(r){try{return!!r()}catch(e){return!0}}});var Pe=p((Vh,vn)=>{"use strict";var jo=F();vn.exports=!jo(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var En=p((Mh,Cn)=>{"use strict";var No=Pe(),gn=Function.prototype,yn=gn.apply,bn=gn.call;Cn.exports=typeof Reflect=="object"&&Reflect.apply||(No?bn.bind(yn):function(){return bn.apply(yn,arguments)})});var z=p((jh,xn)=>{"use strict";var In=Pe(),Tn=Function.prototype,Xt=Tn.call,$o=In&&Tn.bind.bind(Xt,Xt);xn.exports=In?$o:function(r){return function(){return Xt.apply(r,arguments)}}});var ke=p((Nh,wn)=>{"use strict";var Sn=z(),Lo=Sn({}.toString),_o=Sn("".slice);wn.exports=function(r){return _o(Lo(r),8,-1)}});var Zt=p(($h,An)=>{"use strict";var Fo=ke(),qo=z();An.exports=function(r){if(Fo(r)==="Function")return qo(r)}});var q=p((Lh,Rn)=>{"use strict";var Jt=typeof document=="object"&&document.all;Rn.exports=typeof Jt=="undefined"&&Jt!==void 0?function(r){return typeof r=="function"||r===Jt}:function(r){return typeof r=="function"}});var ae=p((_h,On)=>{"use strict";var Bo=F();On.exports=!Bo(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var dt=p((Fh,Pn)=>{"use strict";var Do=Pe(),ht=Function.prototype.call;Pn.exports=Do?ht.bind(ht):function(){return ht.apply(ht,arguments)}});var er=p(Mn=>{"use strict";var kn={}.propertyIsEnumerable,Vn=Object.getOwnPropertyDescriptor,Ho=Vn&&!kn.call({1:2},1);Mn.f=Ho?function(e){var t=Vn(this,e);return!!t&&t.enumerable}:kn});var tr=p((Bh,jn)=>{"use strict";jn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var $n=p((Dh,Nn)=>{"use strict";var Uo=z(),Go=F(),zo=ke(),rr=Object,Wo=Uo("".split);Nn.exports=Go(function(){return!rr("z").propertyIsEnumerable(0)})?function(r){return zo(r)==="String"?Wo(r,""):rr(r)}:rr});var nr=p((Hh,Ln)=>{"use strict";Ln.exports=function(r){return r==null}});var ir=p((Uh,_n)=>{"use strict";var Ko=nr(),Qo=TypeError;_n.exports=function(r){if(Ko(r))throw new Qo("Can't call method on "+r);return r}});var Ve=p((Gh,Fn)=>{"use strict";var Yo=$n(),Xo=ir();Fn.exports=function(r){return Yo(Xo(r))}});var be=p((zh,qn)=>{"use strict";var Zo=q();qn.exports=function(r){return typeof r=="object"?r!==null:Zo(r)}});var ft=p((Wh,Bn)=>{"use strict";Bn.exports={}});var mt=p((Kh,Hn)=>{"use strict";var ar=ft(),sr=Y(),Jo=q(),Dn=function(r){return Jo(r)?r:void 0};Hn.exports=function(r,e){return arguments.length<2?Dn(ar[r])||Dn(sr[r]):ar[r]&&ar[r][e]||sr[r]&&sr[r][e]}});var Gn=p((Qh,Un)=>{"use strict";var ec=z();Un.exports=ec({}.isPrototypeOf)});var Qn=p((Yh,Kn)=>{"use strict";var tc=Y(),zn=tc.navigator,Wn=zn&&zn.userAgent;Kn.exports=Wn?String(Wn):""});var ri=p((Xh,ti)=>{"use strict";var ei=Y(),or=Qn(),Yn=ei.process,Xn=ei.Deno,Zn=Yn&&Yn.versions||Xn&&Xn.version,Jn=Zn&&Zn.v8,W,vt;Jn&&(W=Jn.split("."),vt=W[0]>0&&W[0]<4?1:+(W[0]+W[1]));!vt&&or&&(W=or.match(/Edge\/(\d+)/),(!W||W[1]>=74)&&(W=or.match(/Chrome\/(\d+)/),W&&(vt=+W[1])));ti.exports=vt});var cr=p((Zh,ii)=>{"use strict";var ni=ri(),rc=F(),nc=Y(),ic=nc.String;ii.exports=!!Object.getOwnPropertySymbols&&!rc(function(){var r=Symbol("symbol detection");return!ic(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&ni&&ni<41})});var lr=p((Jh,ai)=>{"use strict";var ac=cr();ai.exports=ac&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var ur=p((ed,si)=>{"use strict";var sc=mt(),oc=q(),cc=Gn(),lc=lr(),uc=Object;si.exports=lc?function(r){return typeof r=="symbol"}:function(r){var e=sc("Symbol");return oc(e)&&cc(e.prototype,uc(r))}});var ci=p((td,oi)=>{"use strict";var pc=String;oi.exports=function(r){try{return pc(r)}catch(e){return"Object"}}});var pr=p((rd,li)=>{"use strict";var hc=q(),dc=ci(),fc=TypeError;li.exports=function(r){if(hc(r))return r;throw new fc(dc(r)+" is not a function")}});var pi=p((nd,ui)=>{"use strict";var mc=pr(),vc=nr();ui.exports=function(r,e){var t=r[e];return vc(t)?void 0:mc(t)}});var di=p((id,hi)=>{"use strict";var hr=dt(),dr=q(),fr=be(),yc=TypeError;hi.exports=function(r,e){var t,n;if(e==="string"&&dr(t=r.toString)&&!fr(n=hr(t,r))||dr(t=r.valueOf)&&!fr(n=hr(t,r))||e!=="string"&&dr(t=r.toString)&&!fr(n=hr(t,r)))return n;throw new yc("Can't convert object to primitive value")}});var mi=p((ad,fi)=>{"use strict";fi.exports=!0});var bi=p((sd,yi)=>{"use strict";var vi=Y(),bc=Object.defineProperty;yi.exports=function(r,e){try{bc(vi,r,{value:e,configurable:!0,writable:!0})}catch(t){vi[r]=e}return e}});var yt=p((od,Ei)=>{"use strict";var gc=mi(),Cc=Y(),Ec=bi(),gi="__core-js_shared__",Ci=Ei.exports=Cc[gi]||Ec(gi,{});(Ci.versions||(Ci.versions=[])).push({version:"3.38.0",mode:gc?"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 mr=p((cd,Ti)=>{"use strict";var Ii=yt();Ti.exports=function(r,e){return Ii[r]||(Ii[r]=e||{})}});var Me=p((ld,xi)=>{"use strict";var Ic=ir(),Tc=Object;xi.exports=function(r){return Tc(Ic(r))}});var ge=p((ud,Si)=>{"use strict";var xc=z(),Sc=Me(),wc=xc({}.hasOwnProperty);Si.exports=Object.hasOwn||function(e,t){return wc(Sc(e),t)}});var vr=p((pd,wi)=>{"use strict";var Ac=z(),Rc=0,Oc=Math.random(),Pc=Ac(1 .toString);wi.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Pc(++Rc+Oc,36)}});var je=p((hd,Ri)=>{"use strict";var kc=Y(),Vc=mr(),Ai=ge(),Mc=vr(),jc=cr(),Nc=lr(),Ce=kc.Symbol,yr=Vc("wks"),$c=Nc?Ce.for||Ce:Ce&&Ce.withoutSetter||Mc;Ri.exports=function(r){return Ai(yr,r)||(yr[r]=jc&&Ai(Ce,r)?Ce[r]:$c("Symbol."+r)),yr[r]}});var Vi=p((dd,ki)=>{"use strict";var Lc=dt(),Oi=be(),Pi=ur(),_c=pi(),Fc=di(),qc=je(),Bc=TypeError,Dc=qc("toPrimitive");ki.exports=function(r,e){if(!Oi(r)||Pi(r))return r;var t=_c(r,Dc),n;if(t){if(e===void 0&&(e="default"),n=Lc(t,r,e),!Oi(n)||Pi(n))return n;throw new Bc("Can't convert object to primitive value")}return e===void 0&&(e="number"),Fc(r,e)}});var br=p((fd,Mi)=>{"use strict";var Hc=Vi(),Uc=ur();Mi.exports=function(r){var e=Hc(r,"string");return Uc(e)?e:e+""}});var $i=p((md,Ni)=>{"use strict";var Gc=Y(),ji=be(),gr=Gc.document,zc=ji(gr)&&ji(gr.createElement);Ni.exports=function(r){return zc?gr.createElement(r):{}}});var Cr=p((vd,Li)=>{"use strict";var Wc=ae(),Kc=F(),Qc=$i();Li.exports=!Wc&&!Kc(function(){return Object.defineProperty(Qc("div"),"a",{get:function(){return 7}}).a!==7})});var qi=p(Fi=>{"use strict";var Yc=ae(),Xc=dt(),Zc=er(),Jc=tr(),el=Ve(),tl=br(),rl=ge(),nl=Cr(),_i=Object.getOwnPropertyDescriptor;Fi.f=Yc?_i:function(e,t){if(e=el(e),t=tl(t),nl)try{return _i(e,t)}catch(n){}if(rl(e,t))return Jc(!Xc(Zc.f,e,t),e[t])}});var Di=p((bd,Bi)=>{"use strict";var il=F(),al=q(),sl=/#|\.prototype\./,Ne=function(r,e){var t=cl[ol(r)];return t===ul?!0:t===ll?!1:al(e)?il(e):!!e},ol=Ne.normalize=function(r){return String(r).replace(sl,".").toLowerCase()},cl=Ne.data={},ll=Ne.NATIVE="N",ul=Ne.POLYFILL="P";Bi.exports=Ne});var Er=p((gd,Ui)=>{"use strict";var Hi=Zt(),pl=pr(),hl=Pe(),dl=Hi(Hi.bind);Ui.exports=function(r,e){return pl(r),e===void 0?r:hl?dl(r,e):function(){return r.apply(e,arguments)}}});var zi=p((Cd,Gi)=>{"use strict";var fl=ae(),ml=F();Gi.exports=fl&&ml(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Ki=p((Ed,Wi)=>{"use strict";var vl=be(),yl=String,bl=TypeError;Wi.exports=function(r){if(vl(r))return r;throw new bl(yl(r)+" is not an object")}});var Xi=p(Yi=>{"use strict";var gl=ae(),Cl=Cr(),El=zi(),bt=Ki(),Qi=br(),Il=TypeError,Ir=Object.defineProperty,Tl=Object.getOwnPropertyDescriptor,Tr="enumerable",xr="configurable",Sr="writable";Yi.f=gl?El?function(e,t,n){if(bt(e),t=Qi(t),bt(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Sr in n&&!n[Sr]){var i=Tl(e,t);i&&i[Sr]&&(e[t]=n.value,n={configurable:xr in n?n[xr]:i[xr],enumerable:Tr in n?n[Tr]:i[Tr],writable:!1})}return Ir(e,t,n)}:Ir:function(e,t,n){if(bt(e),t=Qi(t),bt(n),Cl)try{return Ir(e,t,n)}catch(i){}if("get"in n||"set"in n)throw new Il("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var Ji=p((Td,Zi)=>{"use strict";var xl=ae(),Sl=Xi(),wl=tr();Zi.exports=xl?function(r,e,t){return Sl.f(r,e,wl(1,t))}:function(r,e,t){return r[e]=t,r}});var Le=p((xd,ta)=>{"use strict";var $e=Y(),Al=En(),Rl=Zt(),Ol=q(),Pl=qi().f,kl=Di(),Ee=ft(),Vl=Er(),Ie=Ji(),ea=ge();yt();var Ml=function(r){var e=function(t,n,i){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,n)}return new r(t,n,i)}return Al(r,this,arguments)};return e.prototype=r.prototype,e};ta.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,a=r.proto,o=n?$e:i?$e[t]:$e[t]&&$e[t].prototype,c=n?Ee:Ee[t]||Ie(Ee,t,{})[t],s=c.prototype,l,y,m,v,g,R,E,f,O;for(v in e)l=kl(n?v:t+(i?".":"#")+v,r.forced),y=!l&&o&&ea(o,v),R=c[v],y&&(r.dontCallGetSet?(O=Pl(o,v),E=O&&O.value):E=o[v]),g=y&&E?E:e[v],!(!l&&!a&&typeof R==typeof g)&&(r.bind&&y?f=Vl(g,$e):r.wrap&&y?f=Ml(g):a&&Ol(g)?f=Rl(g):f=g,(r.sham||g&&g.sham||R&&R.sham)&&Ie(f,"sham",!0),Ie(c,v,f),a&&(m=t+"Prototype",ea(Ee,m)||Ie(Ee,m,{}),Ie(Ee[m],v,g),r.real&&s&&(l||!s[v])&&Ie(s,v,g)))}});var na=p((Sd,ra)=>{"use strict";var jl=Math.ceil,Nl=Math.floor;ra.exports=Math.trunc||function(e){var t=+e;return(t>0?Nl:jl)(t)}});var _e=p((wd,ia)=>{"use strict";var $l=na();ia.exports=function(r){var e=+r;return e!==e||e===0?0:$l(e)}});var sa=p((Ad,aa)=>{"use strict";var Ll=_e(),_l=Math.min;aa.exports=function(r){var e=Ll(r);return e>0?_l(e,9007199254740991):0}});var Fe=p((Rd,oa)=>{"use strict";var Fl=sa();oa.exports=function(r){return Fl(r.length)}});var gt=p((Od,ca)=>{"use strict";ca.exports=function(){}});var la=p(()=>{"use strict";var ql=Le(),Bl=Me(),Dl=Fe(),Hl=_e(),Ul=gt();ql({target:"Array",proto:!0},{at:function(e){var t=Bl(this),n=Dl(t),i=Hl(e),a=i>=0?i:n+i;return a<0||a>=n?void 0:t[a]}});Ul("at")});var Ct=p((Vd,ua)=>{"use strict";var Gl=mt();ua.exports=Gl});var ha=p((Md,pa)=>{"use strict";la();var zl=Ct();pa.exports=zl("Array","at")});var fa=p((jd,da)=>{"use strict";var Wl=ha();da.exports=Wl});var wr=p((Nd,ma)=>{"use strict";var Kl=fa();ma.exports=Kl});var Pa=p(($f,Oa)=>{"use strict";var ou=mr(),cu=vr(),Ra=ou("keys");Oa.exports=function(r){return Ra[r]||(Ra[r]=cu(r))}});var Va=p((Lf,ka)=>{"use strict";var lu=F();ka.exports=!lu(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Na=p((_f,ja)=>{"use strict";var uu=ge(),pu=q(),hu=Me(),du=Pa(),fu=Va(),Ma=du("IE_PROTO"),Lr=Object,mu=Lr.prototype;ja.exports=fu?Lr.getPrototypeOf:function(r){var e=hu(r);if(uu(e,Ma))return e[Ma];var t=e.constructor;return pu(t)&&e instanceof t?t.prototype:e instanceof Lr?mu:null}});var La=p((Ff,$a)=>{"use strict";var vu=_e(),yu=Math.max,bu=Math.min;$a.exports=function(r,e){var t=vu(r);return t<0?yu(t+e,0):bu(t,e)}});var _r=p((qf,Fa)=>{"use strict";var gu=Ve(),Cu=La(),Eu=Fe(),_a=function(r){return function(e,t,n){var i=gu(e),a=Eu(i);if(a===0)return!r&&-1;var o=Cu(n,a),c;if(r&&t!==t){for(;a>o;)if(c=i[o++],c!==c)return!0}else for(;a>o;o++)if((r||o in i)&&i[o]===t)return r||o||0;return!r&&-1}};Fa.exports={includes:_a(!0),indexOf:_a(!1)}});var Ba=p((Bf,qa)=>{"use strict";qa.exports={}});var Ua=p((Df,Ha)=>{"use strict";var Iu=z(),Fr=ge(),Tu=Ve(),xu=_r().indexOf,Su=Ba(),Da=Iu([].push);Ha.exports=function(r,e){var t=Tu(r),n=0,i=[],a;for(a in t)!Fr(Su,a)&&Fr(t,a)&&Da(i,a);for(;e.length>n;)Fr(t,a=e[n++])&&(~xu(i,a)||Da(i,a));return i}});var za=p((Hf,Ga)=>{"use strict";Ga.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Ka=p((Uf,Wa)=>{"use strict";var wu=Ua(),Au=za();Wa.exports=Object.keys||function(e){return wu(e,Au)}});var es=p((Gf,Ja)=>{"use strict";var Ya=ae(),Ru=F(),Xa=z(),Ou=Na(),Pu=Ka(),ku=Ve(),Vu=er().f,Za=Xa(Vu),Mu=Xa([].push),ju=Ya&&Ru(function(){var r=Object.create(null);return r[2]=2,!Za(r,2)}),Qa=function(r){return function(e){for(var t=ku(e),n=Pu(t),i=ju&&Ou(t)===null,a=n.length,o=0,c=[],s;a>o;)s=n[o++],(!Ya||(i?s in t:Za(t,s)))&&Mu(c,r?[s,t[s]]:t[s]);return c}};Ja.exports={entries:Qa(!0),values:Qa(!1)}});var ts=p(()=>{"use strict";var Nu=Le(),$u=es().values;Nu({target:"Object",stat:!0},{values:function(e){return $u(e)}})});var ns=p((Kf,rs)=>{"use strict";ts();var Lu=ft();rs.exports=Lu.Object.values});var as=p((Qf,is)=>{"use strict";var _u=ns();is.exports=_u});var Mt=p((Yf,ss)=>{"use strict";var Fu=as();ss.exports=Fu});var ls=p(()=>{"use strict";var qu=Le(),Bu=_r().includes,Du=F(),Hu=gt(),Uu=Du(function(){return!Array(1).includes()});qu({target:"Array",proto:!0,forced:Uu},{includes:function(e){return Bu(this,e,arguments.length>1?arguments[1]:void 0)}});Hu("includes")});var ps=p((tm,us)=>{"use strict";ls();var Gu=Ct();us.exports=Gu("Array","includes")});var ds=p((rm,hs)=>{"use strict";var zu=ps();hs.exports=zu});var jt=p((nm,fs)=>{"use strict";var Wu=ds();fs.exports=Wu});var Hr=p((bm,Es)=>{"use strict";var Qu=ke();Es.exports=Array.isArray||function(e){return Qu(e)==="Array"}});var Ts=p((gm,Is)=>{"use strict";var Yu=TypeError,Xu=9007199254740991;Is.exports=function(r){if(r>Xu)throw Yu("Maximum allowed index exceeded");return r}});var ws=p((Cm,Ss)=>{"use strict";var Zu=Hr(),Ju=Fe(),ep=Ts(),tp=Er(),xs=function(r,e,t,n,i,a,o,c){for(var s=i,l=0,y=o?tp(o,c):!1,m,v;l<n;)l in t&&(m=y?y(t[l],l,e):t[l],a>0&&Zu(m)?(v=Ju(m),s=xs(r,e,m,v,s,a-1)-1):(ep(s+1),r[s]=m),s++),l++;return s};Ss.exports=xs});var Os=p((Em,Rs)=>{"use strict";var rp=je(),np=rp("toStringTag"),As={};As[np]="z";Rs.exports=String(As)==="[object z]"});var ks=p((Im,Ps)=>{"use strict";var ip=Os(),ap=q(),$t=ke(),sp=je(),op=sp("toStringTag"),cp=Object,lp=$t(function(){return arguments}())==="Arguments",up=function(r,e){try{return r[e]}catch(t){}};Ps.exports=ip?$t:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=up(e=cp(r),op))=="string"?t:lp?$t(e):(n=$t(e))==="Object"&&ap(e.callee)?"Arguments":n}});var Ms=p((Tm,Vs)=>{"use strict";var pp=z(),hp=q(),Ur=yt(),dp=pp(Function.toString);hp(Ur.inspectSource)||(Ur.inspectSource=function(r){return dp(r)});Vs.exports=Ur.inspectSource});var Fs=p((xm,_s)=>{"use strict";var fp=z(),mp=F(),js=q(),vp=ks(),yp=mt(),bp=Ms(),Ns=function(){},$s=yp("Reflect","construct"),Gr=/^\s*(?:class|function)\b/,gp=fp(Gr.exec),Cp=!Gr.test(Ns),Xe=function(e){if(!js(e))return!1;try{return $s(Ns,[],e),!0}catch(t){return!1}},Ls=function(e){if(!js(e))return!1;switch(vp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Cp||!!gp(Gr,bp(e))}catch(t){return!0}};Ls.sham=!0;_s.exports=!$s||mp(function(){var r;return Xe(Xe.call)||!Xe(Object)||!Xe(function(){r=!0})||r})?Ls:Xe});var Hs=p((Sm,Ds)=>{"use strict";var qs=Hr(),Ep=Fs(),Ip=be(),Tp=je(),xp=Tp("species"),Bs=Array;Ds.exports=function(r){var e;return qs(r)&&(e=r.constructor,Ep(e)&&(e===Bs||qs(e.prototype))?e=void 0:Ip(e)&&(e=e[xp],e===null&&(e=void 0))),e===void 0?Bs:e}});var Gs=p((wm,Us)=>{"use strict";var Sp=Hs();Us.exports=function(r,e){return new(Sp(r))(e===0?0:e)}});var zs=p(()=>{"use strict";var wp=Le(),Ap=ws(),Rp=Me(),Op=Fe(),Pp=_e(),kp=Gs();wp({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Rp(this),n=Op(t),i=kp(t,0);return i.length=Ap(i,t,t,n,0,e===void 0?1:Pp(e)),i}})});var Ws=p(()=>{"use strict";var Vp=gt();Vp("flat")});var Qs=p((km,Ks)=>{"use strict";zs();Ws();var Mp=Ct();Ks.exports=Mp("Array","flat")});var Xs=p((Vm,Ys)=>{"use strict";var jp=Qs();Ys.exports=jp});var Js=p((Mm,Zs)=>{"use strict";var Np=Xs();Zs.exports=Np});var Up={};ko(Up,{ContainerTypes:()=>C.ContainerTypes,ControlTypes:()=>C.ControlTypes,CustomError:()=>N,EVENT_NAMES:()=>P,EventActionTypes:()=>C.EventActionTypes,EventTypes:()=>C.EventTypes,Interactives:()=>Je,ManifestController:()=>ue,SDKInfo:()=>Hp,chapterIdsToVKVideoIds:()=>_t,compareVersions:()=>Pt,containerTypes:()=>Zl,controlTypes:()=>Jl,eventActionTypes:()=>Pr,eventTypes:()=>eu,getChapterIdByVkVideoId:()=>Co,getVKVideoIdByMedia:()=>Kr,getVideoRawIdByMedia:()=>bo,graphEventTypes:()=>Se,hasEndTemplate:()=>Qe,interactivesEventTypes:()=>k,isAreaControl:()=>Xl,isButtonControl:()=>Yl,isLastChapter:()=>K,isOneTextCtrlContainer:()=>le,isSupportedManifest:()=>C.isSupportedManifest,isTextControl:()=>Ge,isVKVariantItem:()=>go,isValidManifest:()=>Or,migrateManifestToLatestVersion:()=>C.migrateManifestToLatestVersion,utils:()=>xo,vkVideoIdsToChapterIds:()=>Qr});module.exports=Vo(Up);var cn="1.0.31-dev.684e92f5.0";function Ht(r,e=1){let t="0",n="0",i="0";return r.length===4?(t="0x"+r[1]+r[1],n="0x"+r[2]+r[2],i="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],n="0x"+r[3]+r[4],i="0x"+r[5]+r[6]),`rgba(${+t},${+n},${+i},${e})`}var L="interactive",Mo="interactive-controls-container",rt=()=>document.querySelector(`.${Mo}`),ln=.4,$={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},un=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(un||{}),pn=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(pn||{}),hn=(n=>(n.start="left",n.end="right",n.center="center",n))(hn||{}),nt=({target:r,props:e})=>{var t,n,i;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&un[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(n=(e==null?void 0:e.gravityHorizontal)&&pn[e.gravityHorizontal])!=null?n:"center",r.style.textAlign=(i=(e==null?void 0:e.alignment)&&hn[e.alignment])!=null?i:"center"},it=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,a,o,c,s,l;r.style.color=(a=(i=e==null?void 0:e.text)==null?void 0:i.color)!=null?a:t.textColor,r.style.fontSize=`calc(${n.height} * ${(c=(o=e==null?void 0:e.text)==null?void 0:o.size)!=null?c:t.textSize})`,r.textContent=(l=(s=e==null?void 0:e.text)==null?void 0:s.value)!=null?l:t.textContent},at=({target:r,props:e,fallback:t})=>{var n,i,a,o;r.style.backgroundColor=Ht((i=(n=e==null?void 0:e.background)==null?void 0:n.color)!=null?i:t.backgroundColor,(o=(a=e==null?void 0:e.background)==null?void 0:a.alpha)!=null?o:t.backgroundAlpha)},st=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,a,o,c,s,l,y,m,v,g,R;r.style.border=`calc(${n.height} * ${(o=(a=(i=e==null?void 0:e.shape)==null?void 0:i.border)==null?void 0:a.width)!=null?o:t.borderWidth}) solid ${Ht((l=(s=(c=e==null?void 0:e.shape)==null?void 0:c.border)==null?void 0:s.color)!=null?l:t.borderColor,(v=(m=(y=e==null?void 0:e.shape)==null?void 0:y.border)==null?void 0:m.alpha)!=null?v:t.borderAlpha)}`,r.style.borderRadius=`calc(${n.height} * ${(R=(g=e==null?void 0:e.shape)==null?void 0:g.roundCorners)!=null?R:t.roundCorners})`},ve=({target:r,layoutParams:e,fallback:t})=>{var i;let n=(i=e.angle)!=null?i:t.angle;n=n&&n*-1,r.style.transform=`rotate(${n}rad)`};var J=class{constructor(e){this.control=e;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){var i;let t=document.createElement("div");t.classList.add(`${L}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let n=((i=this.control.layoutParams.innerSizesDependOn)!=null?i:$.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:n}}createClickListener(e){return t=>{t.stopPropagation(),e()}}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var i;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(i=this.container)==null||i.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){var e,t;(e=this.container)!=null&&e.element&&this.clickListener&&((t=this.container)==null||t.element.removeEventListener("click",this.clickListener))}};var Ut="int",ie=(n=>(n.AREA=`${Ut}_area`,n.TEXT=`${Ut}_text`,n.BUTTON=`${Ut}_bttn`,n))(ie||{});var ot=r=>{if(r.type.trim().toLowerCase()==="area")return new Gt(r)},Gt=class extends J{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(`${L}-${this.control.id}`),n.setAttribute("data-testid",ie.AREA),n.style.display="flex",n.style.width="100%",n.style.height="100%",n.style.cursor="pointer",at({target:n,props:this.control.props,fallback:{...$,backgroundColor:"transparent"}}),st({target:n,props:this.control.props,fallback:{...$,borderAlpha:0},dependsOn:this.container.dimensions}),ve({target:n,layoutParams:this.control.layoutParams,fallback:$}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var ct=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,n),t.append(e);let i={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,i),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var lt=r=>{if(r.type.trim().toLowerCase()==="button")return new zt(r)},zt=class extends J{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){var o;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(`${L}-${this.control.id}`),n.setAttribute("data-testid",ie.BUTTON),n.style.display="flex",n.style.width="100%",n.style.height="100%",n.style.cursor="pointer",n.style.fontFamily="inherit",ve({target:n,layoutParams:this.control.layoutParams,fallback:$}),at({target:n,props:this.control.props,fallback:$}),st({target:n,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),nt({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=ct(this.control.type.trim().toLowerCase()),a=(o=i.firstElementChild)!=null?o:i;it({target:a,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var dn=r=>{if(r.type.trim().toLowerCase()==="text")return new Wt(r)},Wt=class extends J{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){var o;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(`${L}-${this.control.id}`),n.setAttribute("data-testid",ie.TEXT),n.style.display="flex",n.style.width="100%",n.style.height="100%",n.style.fontFamily="inherit",ve({target:n,layoutParams:this.control.layoutParams,fallback:$}),nt({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=ct(this.control.type.trim().toLowerCase()),a=(o=i.firstElementChild)!=null?o:i;it({target:a,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){}enable(){}getElement(){return this.controlElement}};var Kt=class{constructor(e){this.layout=e}},ut=class extends Kt{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})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var ye=class{constructor(e){this.container=e,this.factories=new Map,this.controls=[],this.setControls()}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(){var e;return((e=this.container.controls)==null?void 0:e.reduce((t,n)=>{let i=n.type.trim().toLowerCase(),a=this.factories.get(i);if(a){let o=a(n);if(o)return[...t,o]}return[...t]},[]))||[]}};var pt=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new Qt(r,e)},Qt=class extends ye{constructor(e,t){super(e),this.rootElement=t!=null?t:rt(),this.layout=new ut(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",lt),this.addControlFactory("text",dn),this.addControlFactory("area",ot)}createView(e){let t=document.createElement("div");return t.classList.add(`${L}-${this.container.id}`),this.layout.setContainerLayout(t),this.controls.forEach(n=>{n.createView({parentElement:t,layoutCallback:this.layout.setControlLayout}),n.setEvents(e)}),this.rootElement.append(t),this.isRemoved=!1,t}hide(){let e=this.getElement();e&&(e.style.visibility="hidden")}show(){let e=this.getElement();e&&(e.style.visibility="visible")}enable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.enable()),e.style.opacity="1",this.isDisabled=!1)}disable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.disable()),e.style.opacity=`${ln}`,this.isDisabled=!0)}removeView(e=!1){var t;(!this.isRemoved||e)&&(this.controls.forEach(n=>n.removeListeners()),(t=this.getElement())==null||t.remove(),this.isRemoved=!0)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${L}-${this.container.id}`)}};var To=Q(wr(),1),x=require("@vkontakte/videoplayer-shared/es2018"),Re=require("@vkontakte/videoplayer-statistics/es2018");var Ca=require("@vkontakte/videoplayer-shared/es2018");function qe(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var se=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Be=r=>se(r,"Object"),Et=r=>se(r,"String"),It=r=>se(r,"Array"),Tt=r=>se(r,"Number"),va=r=>se(r,"Function");var Ar=r=>Tt(r)&&!isNaN(r);var oe=r=>Be(r)&&Object.keys(r).length===0,Rr=r=>It(r)&&!r.length;var De=(r,e)=>Et(r)&&(e?r.trim():r).length;var ya="video_interactive",ba="videoint";var ga=250,He=class{constructor(e){this.handleZoomChange=qe(e=>{this.lastZoomInfo=e},ga);this.onResize=e=>{var n;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((n=this.ngEditor)==null||n.zoomTo(t)),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,n,i;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(e.id),(n=this.ngEditor)==null||n.selectChapter(e.id),(i=this.ngEditor)==null||i.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var n;if(this.isReady=!1,!Tt(e.graph.edit.chapters[0].x)){(n=this.onError)==null||n.call(this,"Can't show graph"),console.error("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:n,lang:i,visitedChapters:a=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(a),this.onOpenPreviewClick=t,this.onError=n,this.lang=i!=null?i:"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Ql(e),this.resizeObserver=new ResizeObserver(qe(this.onResize,ga)),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){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}async show(){var e;this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)}async initNgEditor(){if(!this.manifest)return;let e;try{e=await(0,Ca.loadVKLangPack)(this.lang,ya,ba)}catch(n){console.log("Unable to load graph language pack")}let{GraphEditor:t}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name:n,...i})=>{var a;n==="openPreview"&&"chapterId"in i&&((a=this.onOpenPreviewClick)==null||a.call(this,i.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Ql(r){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",r.append(e),e}var Ue=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,n=!1,i=Math.round(this._player.info.position$.getValue()*1e3);for(let a of this._containers){let o=a.startTime-e;if(o<=i&&(a.endTime&&i<=a.endTime||a.endTime===null)){n=!0;break}i<o&&(t=t===-1?o:Math.min(t,o))}return!n&&t!==-1?t:null}}};var C=require("@interactiveplatform/movika-manifest");var Ea={metadata:"Object",chapters:"Array"},Or=r=>{if(!Be(r))return!1;for(let e in Ea)if(!r[e]||!se(r[e],Ea[e]))return!1;return(0,C.isSupportedManifest)(r.metadata.version)},Ge=r=>r.type===C.ControlTypes.Text,Yl=r=>r.type===C.ControlTypes.Button,Xl=r=>r.type===C.ControlTypes.Area,Zl={Choice:"Choice",TextInput:"TextInput"},Jl={Button:"Button",Area:"Area",Text:"Text"},eu={onClick:"onClick",onSuspense:"onSuspense"},Pr={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var N=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var xt=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let n=this.listeners[e]||[];for(let i=n.length;i>0;i--)if(n[i]===t){n.splice(i,1);break}return this}emit(e,...t){let n=this.listeners[e];return n?(n.forEach(i=>{i(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var St=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{va(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(n=>n!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var Aa=require("@vkontakte/videoplayer-shared/es2018");var wt=class{constructor(e){var t,n;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(n=e==null?void 0:e.manifestLoaders)!=null?n:[]}}async exec(e,t){return tu(...this.loaders[e])(t)}};function tu(...r){return async function(t){let n=[...r];for(;n.length>0;)t=await n.shift()(t);return t}}function ze(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function At({actions:r,errors:e,chapterId:t,...n}){if(t){let i=r.getManifest();if(i){let a=r.getChapter(i.chapters,t);if(a){let o=r.getMedia(i.media,a.videoId),c=r.getGraph(i.graph,a.id);return o?{...n,actions:r,errors:e,result:{chapter:a,media:o,graph:c}}:{...n,errors:ze(e,At.name,"Could not find media"),actions:r}}}}return{...n,errors:ze(e,At.name,"Could not find chapter"),actions:r}}var Rt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){if(!(e in this.listeners))return;let n=this.listeners[e];for(let i=0,a=n.length;i<a;i++)if(n[i].callback===t){n.splice(i,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let n=this.listeners[e.type].slice();for(let i=0,a=n.length;i<a;i++){let o=n[i];try{o.callback.call(this,e)}catch(c){Promise.resolve().then(()=>{throw c})}o.options&&o.options.once&&this.removeEventListener(e.type,o.callback)}return!e.defaultPrevented}},Te=class extends Rt{constructor(){super(),this.listeners||Rt.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)}},We=class{constructor(){Object.defineProperty(this,"signal",{value:new Te,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(i){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let n=e;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(i){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(We.prototype[Symbol.toStringTag]="AbortController",Te.prototype[Symbol.toStringTag]="AbortSignal");function Ot(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 kr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=r;if(!Ot({fetch:e,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:e,Request:a};let a=t;(a&&!a.prototype.hasOwnProperty("signal")||i)&&(a=function(l,y){let m;y&&y.signal&&(m=y.signal,delete y.signal);let v=new t(l,y);return m&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:m}),v},a.prototype=t.prototype);let o=e;return{fetch:(s,l)=>{let y=a&&a.prototype.isPrototypeOf(s)?s.signal:l?l.signal:void 0;if(y){let m;try{m=new DOMException("Aborted","AbortError")}catch(g){m=new Error("Aborted"),m.name="AbortError"}if(y.aborted)return Promise.reject(m);let v=new Promise((g,R)=>{y.addEventListener("abort",()=>R(m),{once:!0})});return l&&l.signal&&delete l.signal,Promise.race([v,o(s,l)])}return o(s,l)},Request:a}}var Ke=Ot({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ia=Ke?kr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Vr=Ke?Ia.fetch:window.fetch,yf=Ke?Ia.Request:window.Request,bf=Ke?We:window.AbortController,gf=Ke?Te:window.AbortSignal;var Pt=(r="",e="")=>{let t=r.split("."),n=e.split("."),i=0;for(let a=0;a<Math.max(t.length,n.length)&&!i;a++)t[a]>n[a]?i=1:t[a]<n[a]?i=-1:i=0;return i};var ru=async r=>{try{let e={},t;if(Et(r)){t=new URL(r).href;let i=await Vr(t);if(!i.ok)return{};e=await i.json()}else if(Be(r))e=r;else return{};if(!Or(e))return{};let n=e.metadata.media;if(Et(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let a=await Vr(i);if(!a.ok)throw new Error;e.metadata.media=await a.json()}catch(i){return au(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function Ta(r){let{manifest:e,manifestURL:t}=await ru(r);if(!e)throw new Error("Failed on fetch");let n=(0,C.migrateManifestToLatestVersion)(e);return n.media=nu(n.media,t),delete n.metadata.media,n}function kt(r,e){if(e)return r.find(t=>t.id===e)}function Mr(r,e){var t,n;return(t=r.edit)!=null&&t.chapters?r.edit.chapters.find(i=>i.id===e):(n=r.view)!=null&&n.chapters?r.view.chapters.find(i=>i.id===e):void 0}function jr(r,e){return r.videos.find(t=>t.id===e)}function nu(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(n=>{let i="url"in n?n.url:"",a=iu(i,e);return{...n,url:a||i}})}))}}function iu(r="",e){try{return new URL(r,e).href}catch(t){return""}}function au(r){return Pt(r,"3.2.0")>=0}var Vt=r=>It(r)&&!Rr(r),K=r=>r.order==="end",Qe=r=>It(r.containers)&&!Rr(r.containers)&&K(r),xa=(r,e)=>{var n;let t=r*1e3;return Vt(e.controls)&&t<((n=e.startTime)!=null?n:0)},Nr=(r,e)=>{var n,i;let t=r*1e3;return Vt(e.controls)&&t>=((n=e.startTime)!=null?n:0)&&t<=((i=e.endTime)!=null?i:1/0)};var ce=(r=[])=>r.some(e=>e.action.type==="expect"),$r=(r=[])=>r.find(e=>e.action.type==="expect"),su=r=>(r==null?void 0:r.length)===1,le=r=>su(r)&&Ge(r[0]);function Sa(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r({...e[0],...t}):r(...e,...t)}var wa=(r,e)=>{let t=E=>{let f=e.find(({container:O})=>O.container.id===E);return f==null?void 0:f.container.isRemoved},n=ce(r.events)&&!t(r.id),i=(E,f=!1,O=!1)=>{let h=O?"every":"some";return E.controls[h](u=>{var I;let d=f?E.endTime===r.endTime:!0;return((I=u.events)==null?void 0:I[h](T=>{var b;return((b=T.action)==null?void 0:b.type)===Pr.openURI}))&&d})},a=E=>E.some(({container:f})=>i(f.container,!0,!1)&&!f.isRemoved),o=E=>E.every(({container:f})=>f.isRemoved?!0:i(f.container,!0,!0)),c=e.filter(({container:E})=>E.container.id!==r.id&&ce(E.container.events)&&E.container.endTime===r.endTime&&!E.isRemoved).length,s=E=>E.controls.some(f=>{var O;return(O=f.events)==null?void 0:O.some(h=>{var u,d;return(d=(u=h.action)==null?void 0:u.args)==null?void 0:d.shouldOpenNow})}),l=n||c>0,y=a(e),m=i(r),v=o(e),g=n?!1:c>0,R=s(r);return{isExpectTime:l,hasOtherExpect:c>0,hasOpenURIEvent:y,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:v,isExpectEventForCurrentContainer:g,hasShouldOpenNowEvent:R}};var ue=class extends wt{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Aa.ValueSubject(null);this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){var i;this.release();let n=await this.exec("manifestLoaders",{actions:{addErrorMessage:ze},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=await Ta((i=n.result)!=null?i:t),this}async setInitial(){return this.setNext()}async setNext(t=(n=>(n=this.manifest)==null?void 0:n.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let i=await this.exec("chapterLoaders",At({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Mr,getChapter:kt,getMedia:jr,getByBranches:this.getByBranches.bind(this),addErrorMessage:ze},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(){var n;return this.getByChapterId((n=this.manifest)==null?void 0:n.metadata.initChapterId)||null}getByChapterId(t=(n=>(n=this.manifest)==null?void 0:n.metadata.initChapterId)()){if(!t||!this.manifest)return null;let i=kt(this.manifest.chapters,t);if(i){let a=jr(this.manifest.media,i.videoId),o=Mr(this.manifest.graph,i.id);if(a)return{chapter:i,media:a,graph:o}}return null}getBranches(t=(n=>(n=this.chapter)==null?void 0:n.id)()){var i,a,o;if(t===((i=this.chapter)==null?void 0:i.id))return this.getByBranches((a=this.chapter)==null?void 0:a.branches);{let c=kt(((o=this.manifest)==null?void 0:o.chapters)||[],t);return this.getByBranches(c==null?void 0:c.branches)}}getByBranches(t=[]){return t.reduce((n,i)=>{let a=this.getByChapterId(i.chapterId);return a&&n.push(a),n},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,n;return((t=this.chapter)==null?void 0:t.id)===((n=this.manifest)==null?void 0:n.metadata.initChapterId)}isEndChapter(){return this.chapter?K(this.chapter):!1}};var ms=Q(Mt(),1),vs=require("@vkontakte/videoplayer-core/es2018"),ne=require("@vkontakte/videoplayer-shared/es2018");var os=r=>{let e=r.variants.find(t=>{var n;return((n=t.payload)==null?void 0:n.type)==="vk"});if(e&&e.payload){let[t,n]=e.payload.id.split("_");return[t,n]}return[]};var cs=Q(Mt(),1);function qr(){let r=new Map;function e({listId:a=Math.random().toString(),itemId:o=Math.random().toString(),...c}){let s=r.get(a),l={...c};return s?s[o]=l:r.set(a,{[o]:l}),{listId:a,itemId:o,...c}}function t(a){var o,c;a.player.destroy(),a.container.remove(),a.subscription.unsubscribe(),(o=a.statistics)==null||o.oneStat.destroy(),(c=a.statistics)==null||c.statSubscription.unsubscribe()}function n(a,o){let c=r.get(a);if(!c)throw Error("Can't remove. Not find.");if(o){let s=c[o];s&&t(s),delete c[o],Object.keys(c).length||r.delete(a)}else{for(let s of(0,cs.default)(c))t(s);r.delete(a)}}function i(){for(let a of r)n(a[0])}return{createPlayer:e,removePlayer:n,map:r,removeAll:i}}var xe=Q(jt(),1);function Br(r,e=[]){var a,o,c;let t={},n,i=!e.length;for(let s of r.variants)if(!n&&"cover"in s&&(n=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(i||(0,xe.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[(a=s.standard)!=null?a:"Invariant quality"]:s.url});break;case"mpeg":(i||(0,xe.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[(o=s.standard)!=null?o:"Invariant quality"]:s.url});break;case"hls":(i||(0,xe.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:s.url}});break;case"dash":(i||(0,xe.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}});break;default:break}return{sources:t,thumbUrl:n,title:(c=r.title)!=null?c:""}}var Ye=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,xe.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Ku=2;function Dr(r){let e=qr(),t=new ne.Subscription,n={},i=null,a=!1,o,c=new ne.ValueSubject(null);r&&s(r);function s(f){i=f}function l(f,O,h){var I;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let d=((I=e.map.get(f))!=null?I:{})[O];if(d){n={chapterId:h,listId:f,itemId:O,...d};let T=n.player;n.subscription.add(T.info.currentQuality$.subscribe(b=>{let S=T.info.position$.getValue(),V=T.info.isAutoQualityEnabled$.getValue();if(!(!b||!S||V))for(let w of e.map)(0,ms.default)(w[1]).forEach(({player:M})=>{Ye(M,b)})})).add(T.events.started$.subscribe(()=>{y(O)})),d.container.remove(),i.setPlayer(d.player),a||(i.init(),a=!0),c.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}async function y(f){if(!i)throw Error("need to set interactive controller");if(oe(n)||f!==n.itemId)return;let O=i.getChapterBranches(),h=new Set;for(let u of O)h.has(u.media.id)||(await v({media:u.media,chapterId:u.chapter.id,setAsActive:!1,title:u.chapter.label}),h.add(u.media.id))}async function m({chapter:{id:f},manifestVideo:O}){if(oe(n)||!i)return;let h=n.player.info.muted$.getValue(),u=n.player.info.currentQuality$.getValue(),d=n.player.info.isAutoQualityEnabled$.getValue(),I=n.player.info.volume$.getValue(),T=n.player.info.currentPlaybackRate$.getValue(),b=!d,S=!1;for(let V of e.map)if(V[0]===O.id&&!i.state.isReplay$.getValue()){let w=Object.keys(V[1]);for(let M of w)M===n.itemId?(w.length<Ku||(S=!0),e.removePlayer(V[0],M)):(S=!0,l(V[0],M,f),b?Ye(n.player,u):n.player.setAutoQuality(!0),n.player.setVolume(I),n.player.setMuted(h),n.player.setPlaybackRate(T))}else e.removePlayer(V[0]);S||(await v({media:O,chapterId:f,setAsActive:!0,playbackRate:T}),b?Ye(n.player,u):n.player.setAutoQuality(!0),n.player.setVolume(I),n.player.setMuted(h))}async function v({media:f,chapterId:O,prefetch:h=!0,setAsActive:u=!0,autoplay:d=!1,preferredExt:I,title:T,playbackRate:b}){var Xr,Zr,Jr,en,tn;let S=Math.random().toString(),V=document.createElement("div");o.append(V);let w;if((Xr=i==null?void 0:i.options)!=null&&Xr.vkVideoLoader){let et=os(f);et.length&&(w=await i.options.vkVideoLoader(...et))}let M=((Zr=i==null?void 0:i.options)==null?void 0:Zr.coreConfig)||void 0,H={...M,configName:[...(Jr=M==null?void 0:M.configName)!=null?Jr:[],"interactive"]},U={container:V,...((en=w==null?void 0:w.videos)==null?void 0:en[0])||{sources:Br(f,I).sources},title:T,failoverHosts:(w==null?void 0:w.failoverHosts)||[]},G=new vs.Player(H,ne.Tracer.createRootTracer());G.initVideo(U);let Z=null;if(w!=null&&w.videos&&(i!=null&&i.options.createOneStat)){let et=w.videos[0],Dt=i.options.createOneStat(et),rn=new ne.Subscription;Dt&&(rn.add(Dt.attachTo(G)),Z={oneStat:Dt,statSubscription:rn})}let fe=new ne.Subscription,So=(tn=n==null?void 0:n.player)==null?void 0:tn.info.isAutoQualityEnabled$.getValue();fe.add(G.events.canplay$.subscribe(function(){So||Ye(G,n.player.info.currentQuality$.getValue()),b&&G.setPlaybackRate(b)}));let me=e.createPlayer({listId:f.id,itemId:S,player:G,container:V,sources:Br(f,I).sources,config:U,subscription:fe,statistics:Z});return u&&l(f.id,me.itemId,O),d&&me.player.play(),h&&!d&&me.player.prepare(),{player:me.player,config:me.config,statistics:me.statistics}}function g(){R(),i=null,o.remove()}function R(){t.unsubscribe(),e.removeAll(),n={},a=!1}async function E(){if(!i)throw Error("need to set interactive controller");R(),o=document.createElement("div");let{media:f,chapter:O}=i.getCurrentChapter();f&&O?(t.add(i.events.chapterChanged$.subscribe(m)),await v({media:f,chapterId:O.id,title:O.label})):console.error("not found")}return{...e,init:E,setInteractiveController:s,createPlayer:v,removeAll:g,getActivePlayer:function(){return n},activePlayerChanged:c}}var P={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Se={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},k={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var bs=Q(jt(),1),gs=require("@vkontakte/videoplayer-shared/es2018");var Nt=class{constructor({player:e,container:t,branches:n,selectBranches:i,interactiveEvents:a,globalEvents:o,globalEventEmitter:c,getContainerEventState:s,permanentTextControls:l,interactiveTimeOpenUri:y,disabledControls$:m,onRemove:v}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(ce(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,n,i,a;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:o}=this.getContainerEventState();if((n=(t=this.container).show)==null||n.call(t),this.interactiveTimeOpenUri&&o)return;this.emitContainerVisibilityEvent(!0,!1)}else{let o={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(s,l)=>{let{isExpectTime:y,hasOtherExpect:m,hasOpenURIEvent:v,hasOpenURIEventInCurrentContainer:g,isAllOpenURIEventsValid:R,hasShouldOpenNowEvent:E}=this.getContainerEventState(),f=this.interactiveTimeOpenUri&&!g,O=this.interactiveTimeOpenUri&&g;if((!this.interactiveTimeOpenUri||f)&&(this.isSelectedControlEvent=!0),s!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||f)){if(this.interactiveTimeOpenUri){let h=!m&&!R&&g;h&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:h})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&v&&this.gameState!==5){if(O){let u=((d,I,T,b)=>!d&&!I&&T||d&&!I&&T&&!b||d&&!I&&T&&b)(y,m,R,this.isSelectedContainerEvent);this.fakeRemoveView(u)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!y||!m||!E)&&(this.selectBranches.stopExpect(),l())}},isEOV:()=>this.gameState===4},c=Sa(this.selectBranches.onControlEvent,o);this.container.createView(c),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((a=(i=this.container).disable)==null||a.call(i))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var l,y,m;let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,i=[6,5];if(!n||(0,bs.default)(i,this.gameState)&&!this.isPermanentText)return;let a=this.player.getExactTime();if(xa(a,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Nr(a,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let v=this.gameState;this.gameState=3,v===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:v}=this.getContainerEventState(),g=this.selectBranches.state.isExpect;if(this.interactiveTimeOpenUri&&v&&!g){let E=this.container.getElement();if(E){if(E.style.visibility==="hidden")return;(y=(l=this.container).hide)==null||y.call(l),this.container.isRemoved||this.fakeRemoveView();return}}this.isPermanentText||this.removeView()}let o=Nr(a,this.container.container),c=this.container.container.startTime?[this.container.container.startTime,(m=this.container.container.endTime)!=null?m:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:c,currentTime:a,isInteractiveTime:o};this.globalEventEmitter.emit(P.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new gs.Subscription,this.player=e,this.interactiveEvents=a,this.getContainerEventState=s,this.isPermanentText=l&&le(t.container.controls),this.interactiveTimeOpenUri=y,this.disabledControls$=m,this.onRemove=v,this.globalEventEmitter=c,this.gameState=0,this.globalEvents=o,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(P.interactives,{subjectId:this.container.container.id,subjectName:"container",type:k.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(P.interactives,{subjectId:this.container.container.id,subjectName:"container",type:k.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=>{var t,n,i,a;e?(n=(t=this.container).disable)==null||n.call(t):(a=(i=this.container).enable)==null||a.call(i)}))}selectContainerEvent(e=!1){var n,i;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(n=this.container.container.endTime)!=null?n:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,t||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((i=this.container.container.endTime)!=null?i:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||t:ce(this.container.container.events)||e;(this.isSelectedControlEvent||!n)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(e=!1){var t;this.container.removeView(e),this.globalEventEmitter.emit(P.interactives,{subjectId:this.container.container.id,subjectName:"container",type:k.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,(t=this.onRemove)==null||t.call(this)}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()}destroy(){var e;this.reset(),this.removeView(!0),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var Cs=(r=[])=>r.reduce((e,t,n)=>{var a,o,c;let i=((a=t==null?void 0:t.controls)!=null?a:[]).filter(s=>!Ge(s));if(Vt(i)){let s=[(o=t.startTime)!=null?o:0,(c=t.endTime)!=null?c:1/0],l={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[l],range:s});else{let y=[],m=-1/0,v=1/0,g=[],R=[];for(let E=0;E<e.length;E++){let f=e[E];if(R.push(...f.subjects),f.range[0]<v&&(v=f.range[0]),f.range[1]>m&&(m=f.range[1]),s[0]>=f.range[0]&&s[1]<=f.range[1])return e[E].subjects.push(l),e;s[0]<f.range[0]&&s[1]>f.range[0]&&(y.push(E),g=g.concat(f.subjects)),s[0]>=f.range[0]&&s[0]<=f.range[1]&&(y.push(E),g=g.concat(f.subjects),s[0]=f.range[0]),s[1]>=f.range[0]&&s[1]<=f.range[1]&&(y.push(E),g=g.concat(f.subjects),s[1]=f.range[1])}if(R.push(l),s[0]<=v&&s[1]>=m)return[{subjects:R,range:s}];y.length&&y.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:g.concat([l]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var to=Q(jt(),1),zr=Q(Mt(),1),ro=Q(Js(),1);function eo(){let r={};function e(){for(let c in r)Object.prototype.hasOwnProperty.call(r,c)&&delete r[c]}function t(c){let s={};for(let l in r)+l<=c&&(s[l]=r[l]);return s}function n(c){let s={};for(let l in r)+l>=c&&(s[l]=r[l]);return s}function i({timestamp:c,priority:s,initiator:l}){var y;if(Ar(c)){let m=(y=r[c])!=null?y:null;if(m&&s&&De(s,!0)){let v={},g=m[s];if(g&&(v={...v,...g}),v=oe(v)?null:v,v&&De(l,!0)){let R=v[l];return R!=null?R:null}return v}return m}return null}function a({timestamp:c,priority:s,initiator:l}){if(Ar(c))if(r[c]){if(s&&De(s,!0))if(r[c][s]){if(l&&De(l,!0))if(r[c][s][l]){if(delete r[c][s][l],!oe(r[c][s]))return!0}else return!1;if(delete r[c][s],!oe(r[c]))return!0}else return!1;return delete r[c]}else return!1;return!1}function o({timestamp:c,priority:s,initiator:l,...y}){var m,v,g;(v=(m=r[c])==null?void 0:m[s])!=null&&v[l]?r[c][s][l].push({...y}):(g=r[c])!=null&&g[s]?r[c][s]={...r[c][s],[l]:[{...y}]}:r[c]?r[c]={...r[c],[s]:{[l]:[{...y}]}}:r[c]={[s]:{[l]:[{...y}]}}}return{map:r,remove:a,add:o,removeAll:e,get:i,getLte:t,getGte:n}}var $p=[C.EventActionTypes.expect,C.EventActionTypes.setNextBranch],Lp=1/0;function no(r,e){let t=r,n,i=_p(e),a=eo(),o,c=()=>{g(),h()},s=u=>{a.add.call(void 0,u),E()},l=(u=[])=>{for(let d of u)if(d.action(),(0,to.default)($p,d.actionType))break},y=(u=1/0)=>{var b,S,V;let d=Lt((b=a.get({timestamp:u,priority:"control"}))!=null?b:{}),I=Lt((S=a.get({timestamp:u,priority:"container"}))!=null?S:{}),T=Lt((V=a.get({timestamp:u,priority:"chapter"}))!=null?V:{});return[...d,...I,...T]},m=u=>{i.isReady(u)&&l(y(u))},v=()=>{var u;l([...Lt((u=a.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},g=()=>{n&&(o==null||o.unsubscribe(),n=void 0)},R=u=>{},E=()=>{n||(n=()=>setTimeout(()=>{m(1/0)}),o=t.events.ended$.subscribe(n))},f=u=>{g(),t=u},O=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),a.remove(u)},h=()=>{i.release(),a.removeAll()};return{setPlayer:f,add:s,remove:O,exec:m,execEndOfVideo:v,listen:E,unlisten:g,release:c,containersEventsCallState:i,getPreparedToExecActions:y}}function _p(r){let e=new Map;return{setCalled:({timestamp:c,id:s})=>{let l=e.get(c);l&&l[s]!==void 0&&(l[s]=!0)},setData:(c=[])=>{var s;for(let l of c){let y=(s=l.endTime)!=null?s:Lp,m=e.get(y);e.set(y,{...m,[l.id]:!1})}},resetCalled:c=>{let s=e.get(c);if(s)for(let l in s)s[l]=!1},isReady:c=>{let s=e.get(c);if(!s)return!0;let l=(0,zr.default)(s);return r?l.some(m=>m):!l.some(m=>!m)},release:()=>e.clear()}}function Lt(r){return(0,ro.default)((0,zr.default)(r)).sort(e=>e.actionType===C.EventActionTypes.expect?-1:1)}var io={videoContentHeight:0,videoContentWidth:0},ao=(r,e)=>{let{height:t,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&n))return io;let{clientHeight:i,clientWidth:a}=e.experimental.element$.getValue()||{};if(!(i&&a))return io;let o=t/n,c=i/a,s,l;return c>o?(l=a,s=a*o):c<o?(l=i/o,s=i):(l=a,s=i),{videoContentWidth:l,videoContentHeight:s}};var Fp=250;function so(r){let e=()=>{},t=new ResizeObserver(c=>{a(c),e=a.bind(null,c)});function n(c){let{parentElement:s,player:l}=r();if(s&&l){let{videoContentWidth:y,videoContentHeight:m}=ao(s,l);s.style.setProperty("--interactive-content-width",`${y}px`),s.style.setProperty("--interactive-content-height",`${m}px`),s.style.setProperty("--interactive-width",`${c[0].contentRect.width}px`),s.style.setProperty("--interactive-height",`${c[0].contentRect.height}px`)}}function i(){let{parentElement:c}=r();c.removeAttribute("style")}let a=qe(c=>{let{fns:s=[]}=r();n(c);for(let l of s)l()},Fp);function o(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var qp=r=>Math.floor(Math.random()*r),co=r=>{var i;let e=r.length,t=1/0,n=null;for(;e--;){let a=r[e],o=(i=a.weight)!=null?i:1;o<t&&(t=o,n=a)}return n},lo=r=>{var i;let e=r.length,t=-1/0,n=null;for(;e--;){let a=r[e],o=(i=a.weight)!=null?i:0;o>t&&(t=o,n=a)}return n};var uo=r=>{let e=r.length,t=qp(e);return r[t]},oo=1,po=r=>{var n,i;let e=0;for(let a=0;a<r.length;++a)e+=(n=r[a].weight)!=null?n:oo;let t=Math.random()*e;e=0;for(let a=0;a<r.length-1;++a)if(e+=(i=r[a].weight)!=null?i:oo,e>=t)return r[a];return r[r.length-1]};var ho={shouldOpenNow:!0,isDetachContainer:!0},fo="after-expect";var Wr=(r,e=!1)=>({...r,args:e?{...r.args,...ho}:{...ho,...r.args}}),yo=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},a=()=>{i.isExpect&&(i.isExpect=!1)},o=({action:h,controlType:u,controlId:d,containerId:I,branches:T=[],onEvent:b,isEOV:S=()=>!1,isDisabled:V=()=>!1})=>{let w=Wr(h,S()),M={timestamp:1/0,priority:"control",initiator:d,actionType:w.type},H=V(),U=r.emit.bind(r,P.interactives,{subjectId:d,subjectType:u,subjectName:"control",type:H?k.actionChoiceCanceled:k.actionChoice,actionType:h.type,payload:{invokeImmediately:w.args.shouldOpenNow,containerId:I,...w.args}}),G=()=>{e.interactiveActionChoice$.next({subjectId:d,subjectType:u,subjectName:"control",type:H?"action-choice-canceled":"action-choice",actionType:h.type,payload:{invokeImmediately:w.args.shouldOpenNow,containerId:I,...w.args}})};if(H){U(),G();return}switch(w.type.trim().toLowerCase()){case C.EventActionTypes.setNextBranch.trim().toLowerCase():{let Z=T.find(fe=>fe.id===w.args.branchId);if(!Z)return;b(w.args.isDetachContainer,g.bind(null,{subjectId:d,subjectName:"control"})),U(),G(),w.args.shouldOpenNow?E({subjectId:d,subjectName:"control",subjectType:u,action:w,payload:{chapterId:Z.chapterId,autoSelect:!1}}):n.add({...M,action:E.bind(null,{subjectId:d,subjectName:"control",subjectType:u,action:w,payload:{chapterId:Z.chapterId,autoSelect:!1}})});return}case C.EventActionTypes.continuePlayback.trim().toLowerCase():{b(w.args.isDetachContainer,g.bind(null,{subjectId:d,subjectName:"control"})),U(),G(),w.args.shouldOpenNow?R({subjectId:d,subjectName:"control",subjectType:u,action:h}):n.add({...M,action:R.bind(null,{subjectId:d,subjectName:"control",subjectType:u,action:h})});return}case C.EventActionTypes.openURI.trim().toLowerCase():{b(w.args.isDetachContainer,g.bind(null,{subjectId:d,subjectName:"control"})),U(),G(),w.args.shouldOpenNow?O({subjectId:d,subjectName:"control",subjectType:u,action:w,payload:{URI:h.args.uri}}):n.add({...M,action:O.bind(null,{subjectId:d,subjectName:"control",subjectType:u,action:w,payload:{URI:h.args.uri}})});return}default:{let Z="Unexpected control event",fe=new N(1,1,{message:Z});y(fe,Z);return}}},c=({action:h,container:{id:u,endTime:d},branches:I=[],isEOV:T=!1,autoSelected:b=!1})=>{let S=Wr(h,T),V={timestamp:!S.args.shouldOpenNow||T?1/0:d!=null?d:1/0,priority:"container",initiator:u,actionType:S.type},w=r.emit.bind(r,P.interactives,{subjectId:u,subjectName:"container",type:k.actionChoice,actionType:S.type,payload:{invokeImmediately:S.args.shouldOpenNow,...S.args}}),M=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"container",type:"action-choice",actionType:S.type,payload:{invokeImmediately:S.args.shouldOpenNow,...S.args}})};switch(S.type.trim().toLowerCase()){case C.EventActionTypes.setNextBranch.trim().toLowerCase():{let H=I.find(U=>U.id===S.args.branchId);if(!H)return;w(),M(),n.add({...V,action:E.bind(null,{subjectId:u,subjectName:"container",action:S,payload:{chapterId:H.chapterId,autoSelect:b}})});return}case C.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case C.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case C.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case C.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case C.EventActionTypes.continuePlayback.trim().toLowerCase():{w(),M(),n.add({...V,action:R.bind(null,{subjectId:u,subjectName:"container",action:S})});return}case C.EventActionTypes.openURI.trim().toLowerCase():{w(),M(),n.add({...V,action:O.bind(null,{subjectId:u,subjectName:"container",action:S,payload:{URI:h.args.uri}})});return}default:{let H="Unexpected container event",U=new N(1,1,{message:H});y(U,H);return}}};function s({container:h,branches:u,isEOV:d=!1}){var T,b;let I=$r(h.events);if(I){let S=Wr(I.action,d);r.emit(P.interactives,{subjectId:h.id,subjectName:"container",type:k.actionChoice,actionType:S.type,payload:{invokeImmediately:S.args.shouldOpenNow,...S.args}}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"container",type:"action-choice",actionType:S.type,payload:{invokeImmediately:S.args.shouldOpenNow,...S.args}}),n.add({timestamp:d?1/0:(T=h.endTime)!=null?T:1/0,priority:"container",initiator:h.id,actionType:C.EventActionTypes.expect,action:v.bind(null,{subjectId:h.id,subjectName:"container"})}),i.isExpect=!0}else for(let S of(b=h.events)!=null?b:[])c({action:S.action,container:h,branches:u,isEOV:d})}let l=({chapterId:h,action:u,branches:d=[]})=>{let I=r.emit.bind(r,P.interactives,{subjectId:h,subjectName:"chapter",type:k.actionChoice,actionType:u.type,payload:u.args}),T=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"chapter",type:"action-choice",actionType:u.type,payload:u.args})};switch(u.type.trim().toLowerCase()){case C.EventActionTypes.setNextBranch.trim().toLowerCase():{let b=d.find(S=>S.id===u.args.branchId);return b!=null&&b.chapterId?(I(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case C.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let b=uo(d);return b!=null&&b.chapterId?(I(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case C.EventActionTypes.setRandomBranch.trim().toLowerCase():{let b=po(d);return b!=null&&b.chapterId?(I(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case C.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let b=lo(d);return b!=null&&b.chapterId?(I(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case C.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let b=co(d);return b!=null&&b.chapterId?(I(),T(),E.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{chapterId:b.chapterId,autoSelect:!0}})):void 0}case C.EventActionTypes.continuePlayback.trim().toLowerCase():return I(),T(),R.bind(null,{subjectId:h,subjectName:"chapter",action:u});case C.EventActionTypes.openURI.trim().toLowerCase():return I(),T(),O.bind(null,{subjectId:h,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:{let b="Unexpected chapter event",S=new N(1,1,{message:b});y(S,b);return}}};function y(h,u){console.error(u),e.error$.next(h),r.emit(P.errors,h)}function m(h){var d;let u=$r(h.events);if(u){if(K(h))return;r.emit(P.interactives,{subjectId:h.id,subjectName:"chapter",type:k.actionChoice,actionType:u.action.type,payload:u.action.args}),e.interactiveActionChoice$.next({subjectId:h.id,subjectName:"chapter",type:"action-choice",actionType:u.action.type,payload:u.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:C.EventActionTypes.expect,action:v.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else(d=h.events)==null||d.forEach(I=>{let T=l({chapterId:h.id,action:I.action,branches:h.branches});T&&n.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:I.action.type,action:T})})}let v=({subjectId:h,subjectName:u})=>{t.pause(),r.emit(P.interactives,{subjectId:h,subjectName:u,type:k.actionExecution,actionType:C.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,type:"action-execution",actionType:C.EventActionTypes.expect})},g=({subjectId:h,subjectName:u})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(P.interactives,{subjectId:h,subjectName:u,type:k.actionExecution,actionType:fo}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,type:"action-execution",actionType:fo})},R=({subjectId:h,subjectName:u,subjectType:d,action:I})=>{r.emit(P.interactives,{subjectId:h,subjectName:u,subjectType:d,type:k.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:d,type:"action-execution",actionType:I.type})},E=({subjectId:h,subjectName:u,subjectType:d,action:I,payload:T})=>{T.behaviour="change-chapter",r.emit(P.interactives,{subjectId:h,subjectName:u,subjectType:d,type:k.actionExecution,actionType:I.type,payload:T}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:d,type:"action-execution",actionType:I.type,payload:T})},f=({subjectId:h,subjectName:u,subjectType:d,action:I,payload:T})=>{T.behaviour="change-manifest",r.emit(P.interactives,{subjectId:h,subjectName:u,subjectType:d,type:k.actionExecution,actionType:I.type,payload:T}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:d,type:"action-execution",actionType:I.type,payload:T})},O=({subjectId:h,subjectName:u,subjectType:d,action:I,payload:T})=>{if(!T.URI)return;let b=window.open(T.URI,"_blank","noopener,noreferrer");b&&(b.opener=null),r.emit(P.interactives,{subjectId:h,subjectName:u,subjectType:d,type:k.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:h,subjectName:u,subjectType:d,type:"action-execution",actionType:I.type})};return{onControlEvent:o,onContainerEvent:c,onChapterEvent:l,onExpectEvent:v,expectEventHandler:g,setManifestChapterEvents:m,setManifestContainerEvents:s,stopExpect:a,state:i}};var Yr=Q(wr(),1),D=require("@vkontakte/videoplayer-shared/es2018");var _t=(r,e)=>{let t={};return r.map(n=>{if(!t[n]){let i=e.chapters.find(o=>o.id===n);if(!i)return null;let a=e.media.videos.find(o=>i.videoId===o.id);if(!a)return null;t[n]=Kr(a)}return t[n]}).filter(Boolean)},bo=r=>{for(let e of r.variants)if(go(e)&&e.payload)return e.payload.id},go=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),Kr=r=>{let e=bo(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Co=(r,e)=>{for(let t of r.media.videos)if(e===Kr(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},Qr=(r,e)=>r.reduce((t,n)=>{let i=Co(e,n);return i?[...t,i]:t},[]);var ee,pe,he,B,Ft,te,re,X,de,we,Ae,Ze=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:a}){this.state={history$:new D.ValueSubject([]),hasPrevChapter$:new D.ValueSubject(!1),prevChapter$:new D.ValueSubject(null),isInitialChapter$:new D.ValueSubject(!1),isGoBackLimited$:new D.ValueSubject(!1)};_(this,ee,null);_(this,pe);_(this,he,!1);_(this,B,null);_(this,Ft,null);this.events={inited$:new D.Subject,destroyed$:new D.Subject,error$:new D.Subject};_(this,te,null);_(this,re,null);_(this,X,null);_(this,de,new D.Subscription);_(this,we,!1);_(this,Ae,0);var o;j(this,te,t),j(this,X,e),j(this,re,n),j(this,ee,i),j(this,pe,a),this.state.history$&&A(this,de)&&((o=A(this,de))==null||o.add(this.state.history$.subscribe(c=>{var s,l;this.state.prevChapter$.next((0,Yr.default)(c,-2)||null),this.state.hasPrevChapter$.next(c.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((l=(s=A(this,B))==null?void 0:s.metadata)==null?void 0:l.initChapterId)),this.state.isGoBackLimited$.next(A(this,Ae)===A(this,pe).maxLength-1)})))}async setManifest(e){if(!A(this,re)||!A(this,X))return;j(this,B,e),await this.getProjectHistory();let t=this.getInitialChapterId();await A(this,re).setChapter({chapterId:t,pushToHistory:!1}),A(this,he)||(j(this,he,!0),this.events.inited$.next({initChapterId:t}))}get inited(){return A(this,he)}async updateHistory(e,t=!0){var c;if(!A(this,B))return;A(this,we)?(j(this,we,!1),on(this,Ae)._++):j(this,Ae,0);let n=A(this,B),i=e.length-A(this,pe).maxLength,a=i>0?e.slice(i):e,o=_t(a,n);if(j(this,Ft,o),this.state.history$.next(a),!(!t||!A(this,ee)||!A(this,te)))try{await A(this,ee).save(A(this,te),o)}catch(s){let l=new N(1,5,"Unable to save interactive history");this.events.error$.next(l),(c=A(this,X))==null||c.emit(P.errors,l)}}async goBack(){var n;if(!this.state||!A(this,re)){let i=new N(1,5,"Unable to save interactive history");return this.events.error$.next(i),(n=A(this,X))==null?void 0:n.emit(P.errors,i)}j(this,we,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await A(this,re).setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){var i;if(!A(this,B)||!A(this,te))return;let e=A(this,B),t=[this.getInitialVideoId()];if(A(this,ee))try{let a=await A(this,ee).get(A(this,te));a.length&&(t=a)}catch(a){let o=new N(1,5,"Error while trying to fetch data");this.events.error$.next(o),(i=A(this,X))==null||i.emit(P.errors,o)}let n=Qr(t,e);this.state.history$.next(n)}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,Yr.default)(e,-1)||A(this,pe).initChapterId||((t=A(this,B))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(A(this,B)){let e=this.getInitialChapterId();return _t([e],A(this,B)).pop()}return null}destroy(){var e,t;j(this,te,null),j(this,ee,null),j(this,re,null),(e=A(this,de))==null||e.unsubscribe(),j(this,de,null),j(this,he,!1),(t=A(this,X))==null||t.emit(P.historyDestroyed),this.events.destroyed$.next(),j(this,X,null)}};ee=new WeakMap,pe=new WeakMap,he=new WeakMap,B=new WeakMap,Ft=new WeakMap,te=new WeakMap,re=new WeakMap,X=new WeakMap,de=new WeakMap,we=new WeakMap,Ae=new WeakMap;var qt=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var i;let e=(i=this.rootElement.getContext("2d"))==null?void 0:i.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,n=t.length;for(let a=3;a<n;a+=40)if(t[a]!==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(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}async updateCanvasDimensions(e,t=!1){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;t&&(i=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&i&&this.restore(i),this._prevSizeId=n}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var Bt=class{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
6
|
+
"use strict";var Po=Object.create;var nt=Object.defineProperty;var ko=Object.getOwnPropertyDescriptor;var Vo=Object.getOwnPropertyNames;var Mo=Object.getPrototypeOf,Lo=Object.prototype.hasOwnProperty;var sn=r=>{throw TypeError(r)};var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),No=(r,e)=>{for(var t in e)nt(r,t,{get:e[t],enumerable:!0})},an=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Vo(e))!Lo.call(r,i)&&i!==t&&nt(r,i,{get:()=>e[i],enumerable:!(n=ko(e,i))||n.enumerable});return r};var X=(r,e,t)=>(t=r!=null?Po(Mo(r)):{},an(e||!r||!r.__esModule?nt(t,"default",{value:r,enumerable:!0}):t,r)),jo=r=>an(nt({},"__esModule",{value:!0}),r);var on=(r,e,t)=>e.has(r)||sn("Cannot "+t);var w=(r,e,t)=>(on(r,e,"read from private field"),t?t.call(r):e.get(r)),_=(r,e,t)=>e.has(r)?sn("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),L=(r,e,t,n)=>(on(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t);var ln=(r,e,t,n)=>({set _(i){L(r,e,i,t)},get _(){return w(r,e,n)}});var Y=p((Zt,vn)=>{"use strict";var ke=function(r){return r&&r.Math===Math&&r};vn.exports=ke(typeof globalThis=="object"&&globalThis)||ke(typeof window=="object"&&window)||ke(typeof self=="object"&&self)||ke(typeof global=="object"&&global)||ke(typeof Zt=="object"&&Zt)||function(){return this}()||Function("return this")()});var q=p((Kh,bn)=>{"use strict";bn.exports=function(r){try{return!!r()}catch(e){return!0}}});var Ve=p((Qh,Cn)=>{"use strict";var $o=q();Cn.exports=!$o(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var Tn=p((Xh,xn)=>{"use strict";var _o=Ve(),In=Function.prototype,gn=In.apply,En=In.call;xn.exports=typeof Reflect=="object"&&Reflect.apply||(_o?En.bind(gn):function(){return En.apply(gn,arguments)})});var W=p((Yh,An)=>{"use strict";var Sn=Ve(),wn=Function.prototype,Jt=wn.call,Fo=Sn&&wn.bind.bind(Jt,Jt);An.exports=Sn?Fo:function(r){return function(){return Jt.apply(r,arguments)}}});var Me=p((Zh,Rn)=>{"use strict";var On=W(),qo=On({}.toString),Bo=On("".slice);Rn.exports=function(r){return Bo(qo(r),8,-1)}});var er=p((Jh,Pn)=>{"use strict";var Do=Me(),Ho=W();Pn.exports=function(r){if(Do(r)==="Function")return Ho(r)}});var B=p((ed,kn)=>{"use strict";var tr=typeof document=="object"&&document.all;kn.exports=typeof tr=="undefined"&&tr!==void 0?function(r){return typeof r=="function"||r===tr}:function(r){return typeof r=="function"}});var ae=p((td,Vn)=>{"use strict";var Go=q();Vn.exports=!Go(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ft=p((rd,Mn)=>{"use strict";var Uo=Ve(),dt=Function.prototype.call;Mn.exports=Uo?dt.bind(dt):function(){return dt.apply(dt,arguments)}});var rr=p(jn=>{"use strict";var Ln={}.propertyIsEnumerable,Nn=Object.getOwnPropertyDescriptor,zo=Nn&&!Ln.call({1:2},1);jn.f=zo?function(e){var t=Nn(this,e);return!!t&&t.enumerable}:Ln});var nr=p((id,$n)=>{"use strict";$n.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Fn=p((sd,_n)=>{"use strict";var Wo=W(),Ko=q(),Qo=Me(),ir=Object,Xo=Wo("".split);_n.exports=Ko(function(){return!ir("z").propertyIsEnumerable(0)})?function(r){return Qo(r)==="String"?Xo(r,""):ir(r)}:ir});var sr=p((ad,qn)=>{"use strict";qn.exports=function(r){return r==null}});var ar=p((od,Bn)=>{"use strict";var Yo=sr(),Zo=TypeError;Bn.exports=function(r){if(Yo(r))throw new Zo("Can't call method on "+r);return r}});var Le=p((ld,Dn)=>{"use strict";var Jo=Fn(),el=ar();Dn.exports=function(r){return Jo(el(r))}});var ge=p((cd,Hn)=>{"use strict";var tl=B();Hn.exports=function(r){return typeof r=="object"?r!==null:tl(r)}});var mt=p((ud,Gn)=>{"use strict";Gn.exports={}});var yt=p((pd,zn)=>{"use strict";var or=mt(),lr=Y(),rl=B(),Un=function(r){return rl(r)?r:void 0};zn.exports=function(r,e){return arguments.length<2?Un(or[r])||Un(lr[r]):or[r]&&or[r][e]||lr[r]&&lr[r][e]}});var Kn=p((hd,Wn)=>{"use strict";var nl=W();Wn.exports=nl({}.isPrototypeOf)});var Zn=p((dd,Yn)=>{"use strict";var il=Y(),Qn=il.navigator,Xn=Qn&&Qn.userAgent;Yn.exports=Xn?String(Xn):""});var si=p((fd,ii)=>{"use strict";var ni=Y(),cr=Zn(),Jn=ni.process,ei=ni.Deno,ti=Jn&&Jn.versions||ei&&ei.version,ri=ti&&ti.v8,K,vt;ri&&(K=ri.split("."),vt=K[0]>0&&K[0]<4?1:+(K[0]+K[1]));!vt&&cr&&(K=cr.match(/Edge\/(\d+)/),(!K||K[1]>=74)&&(K=cr.match(/Chrome\/(\d+)/),K&&(vt=+K[1])));ii.exports=vt});var ur=p((md,oi)=>{"use strict";var ai=si(),sl=q(),al=Y(),ol=al.String;oi.exports=!!Object.getOwnPropertySymbols&&!sl(function(){var r=Symbol("symbol detection");return!ol(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&ai&&ai<41})});var pr=p((yd,li)=>{"use strict";var ll=ur();li.exports=ll&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var hr=p((vd,ci)=>{"use strict";var cl=yt(),ul=B(),pl=Kn(),hl=pr(),dl=Object;ci.exports=hl?function(r){return typeof r=="symbol"}:function(r){var e=cl("Symbol");return ul(e)&&pl(e.prototype,dl(r))}});var pi=p((bd,ui)=>{"use strict";var fl=String;ui.exports=function(r){try{return fl(r)}catch(e){return"Object"}}});var dr=p((Cd,hi)=>{"use strict";var ml=B(),yl=pi(),vl=TypeError;hi.exports=function(r){if(ml(r))return r;throw new vl(yl(r)+" is not a function")}});var fi=p((gd,di)=>{"use strict";var bl=dr(),Cl=sr();di.exports=function(r,e){var t=r[e];return Cl(t)?void 0:bl(t)}});var yi=p((Ed,mi)=>{"use strict";var fr=ft(),mr=B(),yr=ge(),gl=TypeError;mi.exports=function(r,e){var t,n;if(e==="string"&&mr(t=r.toString)&&!yr(n=fr(t,r))||mr(t=r.valueOf)&&!yr(n=fr(t,r))||e!=="string"&&mr(t=r.toString)&&!yr(n=fr(t,r)))return n;throw new gl("Can't convert object to primitive value")}});var bi=p((Id,vi)=>{"use strict";vi.exports=!0});var Ei=p((xd,gi)=>{"use strict";var Ci=Y(),El=Object.defineProperty;gi.exports=function(r,e){try{El(Ci,r,{value:e,configurable:!0,writable:!0})}catch(t){Ci[r]=e}return e}});var bt=p((Td,Ti)=>{"use strict";var Il=bi(),xl=Y(),Tl=Ei(),Ii="__core-js_shared__",xi=Ti.exports=xl[Ii]||Tl(Ii,{});(xi.versions||(xi.versions=[])).push({version:"3.38.0",mode:Il?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var vr=p((Sd,wi)=>{"use strict";var Si=bt();wi.exports=function(r,e){return Si[r]||(Si[r]=e||{})}});var Ne=p((wd,Ai)=>{"use strict";var Sl=ar(),wl=Object;Ai.exports=function(r){return wl(Sl(r))}});var Ee=p((Ad,Oi)=>{"use strict";var Al=W(),Ol=Ne(),Rl=Al({}.hasOwnProperty);Oi.exports=Object.hasOwn||function(e,t){return Rl(Ol(e),t)}});var br=p((Od,Ri)=>{"use strict";var Pl=W(),kl=0,Vl=Math.random(),Ml=Pl(1 .toString);Ri.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Ml(++kl+Vl,36)}});var je=p((Rd,ki)=>{"use strict";var Ll=Y(),Nl=vr(),Pi=Ee(),jl=br(),$l=ur(),_l=pr(),Ie=Ll.Symbol,Cr=Nl("wks"),Fl=_l?Ie.for||Ie:Ie&&Ie.withoutSetter||jl;ki.exports=function(r){return Pi(Cr,r)||(Cr[r]=$l&&Pi(Ie,r)?Ie[r]:Fl("Symbol."+r)),Cr[r]}});var Ni=p((Pd,Li)=>{"use strict";var ql=ft(),Vi=ge(),Mi=hr(),Bl=fi(),Dl=yi(),Hl=je(),Gl=TypeError,Ul=Hl("toPrimitive");Li.exports=function(r,e){if(!Vi(r)||Mi(r))return r;var t=Bl(r,Ul),n;if(t){if(e===void 0&&(e="default"),n=ql(t,r,e),!Vi(n)||Mi(n))return n;throw new Gl("Can't convert object to primitive value")}return e===void 0&&(e="number"),Dl(r,e)}});var gr=p((kd,ji)=>{"use strict";var zl=Ni(),Wl=hr();ji.exports=function(r){var e=zl(r,"string");return Wl(e)?e:e+""}});var Fi=p((Vd,_i)=>{"use strict";var Kl=Y(),$i=ge(),Er=Kl.document,Ql=$i(Er)&&$i(Er.createElement);_i.exports=function(r){return Ql?Er.createElement(r):{}}});var Ir=p((Md,qi)=>{"use strict";var Xl=ae(),Yl=q(),Zl=Fi();qi.exports=!Xl&&!Yl(function(){return Object.defineProperty(Zl("div"),"a",{get:function(){return 7}}).a!==7})});var Hi=p(Di=>{"use strict";var Jl=ae(),ec=ft(),tc=rr(),rc=nr(),nc=Le(),ic=gr(),sc=Ee(),ac=Ir(),Bi=Object.getOwnPropertyDescriptor;Di.f=Jl?Bi:function(e,t){if(e=nc(e),t=ic(t),ac)try{return Bi(e,t)}catch(n){}if(sc(e,t))return rc(!ec(tc.f,e,t),e[t])}});var Ui=p((Nd,Gi)=>{"use strict";var oc=q(),lc=B(),cc=/#|\.prototype\./,$e=function(r,e){var t=pc[uc(r)];return t===dc?!0:t===hc?!1:lc(e)?oc(e):!!e},uc=$e.normalize=function(r){return String(r).replace(cc,".").toLowerCase()},pc=$e.data={},hc=$e.NATIVE="N",dc=$e.POLYFILL="P";Gi.exports=$e});var xr=p((jd,Wi)=>{"use strict";var zi=er(),fc=dr(),mc=Ve(),yc=zi(zi.bind);Wi.exports=function(r,e){return fc(r),e===void 0?r:mc?yc(r,e):function(){return r.apply(e,arguments)}}});var Qi=p(($d,Ki)=>{"use strict";var vc=ae(),bc=q();Ki.exports=vc&&bc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Yi=p((_d,Xi)=>{"use strict";var Cc=ge(),gc=String,Ec=TypeError;Xi.exports=function(r){if(Cc(r))return r;throw new Ec(gc(r)+" is not an object")}});var es=p(Ji=>{"use strict";var Ic=ae(),xc=Ir(),Tc=Qi(),Ct=Yi(),Zi=gr(),Sc=TypeError,Tr=Object.defineProperty,wc=Object.getOwnPropertyDescriptor,Sr="enumerable",wr="configurable",Ar="writable";Ji.f=Ic?Tc?function(e,t,n){if(Ct(e),t=Zi(t),Ct(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Ar in n&&!n[Ar]){var i=wc(e,t);i&&i[Ar]&&(e[t]=n.value,n={configurable:wr in n?n[wr]:i[wr],enumerable:Sr in n?n[Sr]:i[Sr],writable:!1})}return Tr(e,t,n)}:Tr:function(e,t,n){if(Ct(e),t=Zi(t),Ct(n),xc)try{return Tr(e,t,n)}catch(i){}if("get"in n||"set"in n)throw new Sc("Accessors not supported");return"value"in n&&(e[t]=n.value),e}});var rs=p((qd,ts)=>{"use strict";var Ac=ae(),Oc=es(),Rc=nr();ts.exports=Ac?function(r,e,t){return Oc.f(r,e,Rc(1,t))}:function(r,e,t){return r[e]=t,r}});var Fe=p((Bd,is)=>{"use strict";var _e=Y(),Pc=Tn(),kc=er(),Vc=B(),Mc=Hi().f,Lc=Ui(),xe=mt(),Nc=xr(),Te=rs(),ns=Ee();bt();var jc=function(r){var e=function(t,n,i){if(this instanceof e){switch(arguments.length){case 0:return new r;case 1:return new r(t);case 2:return new r(t,n)}return new r(t,n,i)}return Pc(r,this,arguments)};return e.prototype=r.prototype,e};is.exports=function(r,e){var t=r.target,n=r.global,i=r.stat,s=r.proto,o=n?_e:i?_e[t]:_e[t]&&_e[t].prototype,l=n?xe:xe[t]||Te(xe,t,{})[t],a=l.prototype,c,f,C,d,x,O,R,b,P;for(d in e)c=Lc(n?d:t+(i?".":"#")+d,r.forced),f=!c&&o&&ns(o,d),O=l[d],f&&(r.dontCallGetSet?(P=Mc(o,d),R=P&&P.value):R=o[d]),x=f&&R?R:e[d],!(!c&&!s&&typeof O==typeof x)&&(r.bind&&f?b=Nc(x,_e):r.wrap&&f?b=jc(x):s&&Vc(x)?b=kc(x):b=x,(r.sham||x&&x.sham||O&&O.sham)&&Te(b,"sham",!0),Te(l,d,b),s&&(C=t+"Prototype",ns(xe,C)||Te(xe,C,{}),Te(xe[C],d,x),r.real&&a&&(c||!a[d])&&Te(a,d,x)))}});var as=p((Dd,ss)=>{"use strict";var $c=Math.ceil,_c=Math.floor;ss.exports=Math.trunc||function(e){var t=+e;return(t>0?_c:$c)(t)}});var qe=p((Hd,os)=>{"use strict";var Fc=as();os.exports=function(r){var e=+r;return e!==e||e===0?0:Fc(e)}});var cs=p((Gd,ls)=>{"use strict";var qc=qe(),Bc=Math.min;ls.exports=function(r){var e=qc(r);return e>0?Bc(e,9007199254740991):0}});var Be=p((Ud,us)=>{"use strict";var Dc=cs();us.exports=function(r){return Dc(r.length)}});var gt=p((zd,ps)=>{"use strict";ps.exports=function(){}});var hs=p(()=>{"use strict";var Hc=Fe(),Gc=Ne(),Uc=Be(),zc=qe(),Wc=gt();Hc({target:"Array",proto:!0},{at:function(e){var t=Gc(this),n=Uc(t),i=zc(e),s=i>=0?i:n+i;return s<0||s>=n?void 0:t[s]}});Wc("at")});var Et=p((Qd,ds)=>{"use strict";var Kc=yt();ds.exports=Kc});var ms=p((Xd,fs)=>{"use strict";hs();var Qc=Et();fs.exports=Qc("Array","at")});var vs=p((Yd,ys)=>{"use strict";var Xc=ms();ys.exports=Xc});var Or=p((Zd,bs)=>{"use strict";var Yc=vs();bs.exports=Yc});var Ms=p((Jf,Vs)=>{"use strict";var pu=vr(),hu=br(),ks=pu("keys");Vs.exports=function(r){return ks[r]||(ks[r]=hu(r))}});var Ns=p((em,Ls)=>{"use strict";var du=q();Ls.exports=!du(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var _s=p((tm,$s)=>{"use strict";var fu=Ee(),mu=B(),yu=Ne(),vu=Ms(),bu=Ns(),js=vu("IE_PROTO"),_r=Object,Cu=_r.prototype;$s.exports=bu?_r.getPrototypeOf:function(r){var e=yu(r);if(fu(e,js))return e[js];var t=e.constructor;return mu(t)&&e instanceof t?t.prototype:e instanceof _r?Cu:null}});var qs=p((rm,Fs)=>{"use strict";var gu=qe(),Eu=Math.max,Iu=Math.min;Fs.exports=function(r,e){var t=gu(r);return t<0?Eu(t+e,0):Iu(t,e)}});var Fr=p((nm,Ds)=>{"use strict";var xu=Le(),Tu=qs(),Su=Be(),Bs=function(r){return function(e,t,n){var i=xu(e),s=Su(i);if(s===0)return!r&&-1;var o=Tu(n,s),l;if(r&&t!==t){for(;s>o;)if(l=i[o++],l!==l)return!0}else for(;s>o;o++)if((r||o in i)&&i[o]===t)return r||o||0;return!r&&-1}};Ds.exports={includes:Bs(!0),indexOf:Bs(!1)}});var Gs=p((im,Hs)=>{"use strict";Hs.exports={}});var Ws=p((sm,zs)=>{"use strict";var wu=W(),qr=Ee(),Au=Le(),Ou=Fr().indexOf,Ru=Gs(),Us=wu([].push);zs.exports=function(r,e){var t=Au(r),n=0,i=[],s;for(s in t)!qr(Ru,s)&&qr(t,s)&&Us(i,s);for(;e.length>n;)qr(t,s=e[n++])&&(~Ou(i,s)||Us(i,s));return i}});var Qs=p((am,Ks)=>{"use strict";Ks.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Ys=p((om,Xs)=>{"use strict";var Pu=Ws(),ku=Qs();Xs.exports=Object.keys||function(e){return Pu(e,ku)}});var na=p((lm,ra)=>{"use strict";var Js=ae(),Vu=q(),ea=W(),Mu=_s(),Lu=Ys(),Nu=Le(),ju=rr().f,ta=ea(ju),$u=ea([].push),_u=Js&&Vu(function(){var r=Object.create(null);return r[2]=2,!ta(r,2)}),Zs=function(r){return function(e){for(var t=Nu(e),n=Lu(t),i=_u&&Mu(t)===null,s=n.length,o=0,l=[],a;s>o;)a=n[o++],(!Js||(i?a in t:ta(t,a)))&&$u(l,r?[a,t[a]]:t[a]);return l}};ra.exports={entries:Zs(!0),values:Zs(!1)}});var ia=p(()=>{"use strict";var Fu=Fe(),qu=na().values;Fu({target:"Object",stat:!0},{values:function(e){return qu(e)}})});var aa=p((pm,sa)=>{"use strict";ia();var Bu=mt();sa.exports=Bu.Object.values});var la=p((hm,oa)=>{"use strict";var Du=aa();oa.exports=Du});var Lt=p((dm,ca)=>{"use strict";var Hu=la();ca.exports=Hu});var ha=p(()=>{"use strict";var Gu=Fe(),Uu=Fr().includes,zu=q(),Wu=gt(),Ku=zu(function(){return!Array(1).includes()});Gu({target:"Array",proto:!0,forced:Ku},{includes:function(e){return Uu(this,e,arguments.length>1?arguments[1]:void 0)}});Wu("includes")});var fa=p((bm,da)=>{"use strict";ha();var Qu=Et();da.exports=Qu("Array","includes")});var ya=p((Cm,ma)=>{"use strict";var Xu=fa();ma.exports=Xu});var Nt=p((gm,va)=>{"use strict";var Yu=ya();va.exports=Yu});var Gr=p((Nm,Ta)=>{"use strict";var Ju=Me();Ta.exports=Array.isArray||function(e){return Ju(e)==="Array"}});var wa=p((jm,Sa)=>{"use strict";var ep=TypeError,tp=9007199254740991;Sa.exports=function(r){if(r>tp)throw ep("Maximum allowed index exceeded");return r}});var Ra=p(($m,Oa)=>{"use strict";var rp=Gr(),np=Be(),ip=wa(),sp=xr(),Aa=function(r,e,t,n,i,s,o,l){for(var a=i,c=0,f=o?sp(o,l):!1,C,d;c<n;)c in t&&(C=f?f(t[c],c,e):t[c],s>0&&rp(C)?(d=np(C),a=Aa(r,e,C,d,a,s-1)-1):(ip(a+1),r[a]=C),a++),c++;return a};Oa.exports=Aa});var Va=p((_m,ka)=>{"use strict";var ap=je(),op=ap("toStringTag"),Pa={};Pa[op]="z";ka.exports=String(Pa)==="[object z]"});var La=p((Fm,Ma)=>{"use strict";var lp=Va(),cp=B(),$t=Me(),up=je(),pp=up("toStringTag"),hp=Object,dp=$t(function(){return arguments}())==="Arguments",fp=function(r,e){try{return r[e]}catch(t){}};Ma.exports=lp?$t:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=fp(e=hp(r),pp))=="string"?t:dp?$t(e):(n=$t(e))==="Object"&&cp(e.callee)?"Arguments":n}});var ja=p((qm,Na)=>{"use strict";var mp=W(),yp=B(),Ur=bt(),vp=mp(Function.toString);yp(Ur.inspectSource)||(Ur.inspectSource=function(r){return vp(r)});Na.exports=Ur.inspectSource});var Da=p((Bm,Ba)=>{"use strict";var bp=W(),Cp=q(),$a=B(),gp=La(),Ep=yt(),Ip=ja(),_a=function(){},Fa=Ep("Reflect","construct"),zr=/^\s*(?:class|function)\b/,xp=bp(zr.exec),Tp=!zr.test(_a),Je=function(e){if(!$a(e))return!1;try{return Fa(_a,[],e),!0}catch(t){return!1}},qa=function(e){if(!$a(e))return!1;switch(gp(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Tp||!!xp(zr,Ip(e))}catch(t){return!0}};qa.sham=!0;Ba.exports=!Fa||Cp(function(){var r;return Je(Je.call)||!Je(Object)||!Je(function(){r=!0})||r})?qa:Je});var za=p((Dm,Ua)=>{"use strict";var Ha=Gr(),Sp=Da(),wp=ge(),Ap=je(),Op=Ap("species"),Ga=Array;Ua.exports=function(r){var e;return Ha(r)&&(e=r.constructor,Sp(e)&&(e===Ga||Ha(e.prototype))?e=void 0:wp(e)&&(e=e[Op],e===null&&(e=void 0))),e===void 0?Ga:e}});var Ka=p((Hm,Wa)=>{"use strict";var Rp=za();Wa.exports=function(r,e){return new(Rp(r))(e===0?0:e)}});var Qa=p(()=>{"use strict";var Pp=Fe(),kp=Ra(),Vp=Ne(),Mp=Be(),Lp=qe(),Np=Ka();Pp({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Vp(this),n=Mp(t),i=Np(t,0);return i.length=kp(i,t,t,n,0,e===void 0?1:Lp(e)),i}})});var Xa=p(()=>{"use strict";var jp=gt();jp("flat")});var Za=p((Km,Ya)=>{"use strict";Qa();Xa();var $p=Et();Ya.exports=$p("Array","flat")});var eo=p((Qm,Ja)=>{"use strict";var _p=Za();Ja.exports=_p});var ro=p((Xm,to)=>{"use strict";var Fp=eo();to.exports=Fp});var Xp={};No(Xp,{ContainerTypes:()=>v.ContainerTypes,ControlTypes:()=>v.ControlTypes,CustomError:()=>j,EVENT_NAMES:()=>A,EventActionTypes:()=>v.EventActionTypes,EventTypes:()=>v.EventTypes,Interactives:()=>tt,ManifestController:()=>pe,SDKInfo:()=>Qp,chapterIdsToVKVideoIds:()=>Ft,compareVersions:()=>kt,containerTypes:()=>tu,controlTypes:()=>ru,eventActionTypes:()=>iu,eventTypes:()=>nu,getChapterIdByVkVideoId:()=>xo,getVKVideoIdByMedia:()=>Qr,getVideoRawIdByMedia:()=>Eo,graphEventTypes:()=>Ae,hasEndTemplate:()=>Ye,interactivesEventTypes:()=>k,isAreaControl:()=>eu,isButtonControl:()=>Jc,isLastChapter:()=>Q,isOneTextCtrlContainer:()=>ue,isSupportedManifest:()=>v.isSupportedManifest,isTextControl:()=>We,isVKVariantItem:()=>Io,isValidManifest:()=>kr,migrateManifestToLatestVersion:()=>v.migrateManifestToLatestVersion,utils:()=>Oo,vkVideoIdsToChapterIds:()=>Xr});module.exports=jo(Xp);var cn="1.0.31-dev.a8108f50.0";var Gt=class{constructor(e){this.layout=e}},it=class extends Gt{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};function un(r){return"features"in r}var ve=class{constructor(e,t){this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&un(this.options)&&this.options.features[e]}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){var e;return((e=this.container.controls)==null?void 0:e.reduce((t,n)=>{let i=n.type.trim().toLowerCase(),s=this.factories.get(i);if(s){let o=s(n,this.options);if(o)return[...t,o]}return[...t]},[]))||[]}};function Ut(r,e=1){let t="0",n="0",i="0";return r.length===4?(t="0x"+r[1]+r[1],n="0x"+r[2]+r[2],i="0x"+r[3]+r[3]):r.length===7&&(t="0x"+r[1]+r[2],n="0x"+r[3]+r[4],i="0x"+r[5]+r[6]),`rgba(${+t},${+n},${+i},${e})`}var pn="interactive",$={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},hn=(n=>(n.top="flex-start",n.bottom="flex-end",n.center="center",n))(hn||{}),dn=(n=>(n.start="flex-start",n.end="flex-end",n.center="center",n))(dn||{}),fn=(n=>(n.start="left",n.end="right",n.center="center",n))(fn||{}),st=({target:r,props:e})=>{var t,n,i;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&hn[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(n=(e==null?void 0:e.gravityHorizontal)&&dn[e.gravityHorizontal])!=null?n:"center",r.style.textAlign=(i=(e==null?void 0:e.alignment)&&fn[e.alignment])!=null?i:"center"},at=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,s,o,l,a,c;r.style.color=(s=(i=e==null?void 0:e.text)==null?void 0:i.color)!=null?s:t.textColor,r.style.fontSize=`calc(${n.height} * ${(l=(o=e==null?void 0:e.text)==null?void 0:o.size)!=null?l:t.textSize})`,r.textContent=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},ot=({target:r,props:e,fallback:t})=>{var n,i,s,o;r.style.backgroundColor=Ut((i=(n=e==null?void 0:e.background)==null?void 0:n.color)!=null?i:t.backgroundColor,(o=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?o:t.backgroundAlpha)},lt=({target:r,props:e,fallback:t,dependsOn:n})=>{var i,s,o,l,a,c,f,C,d,x,O;r.style.border=`calc(${n.height} * ${(o=(s=(i=e==null?void 0:e.shape)==null?void 0:i.border)==null?void 0:s.width)!=null?o:t.borderWidth}) solid ${Ut((c=(a=(l=e==null?void 0:e.shape)==null?void 0:l.border)==null?void 0:a.color)!=null?c:t.borderColor,(d=(C=(f=e==null?void 0:e.shape)==null?void 0:f.border)==null?void 0:C.alpha)!=null?d:t.borderAlpha)}`,r.style.borderRadius=`calc(${n.height} * ${(O=(x=e==null?void 0:e.shape)==null?void 0:x.roundCorners)!=null?O:t.roundCorners})`},be=({target:r,layoutParams:e,fallback:t})=>{var i;let n=(i=e.angle)!=null?i:t.angle;n=n&&n*-1,r.style.transform=`rotate(${n}rad)`};var zt="int",se=(n=>(n.AREA=`${zt}_area`,n.TEXT=`${zt}_text`,n.BUTTON=`${zt}_bttn`,n))(se||{});function mn(r){return"features"in r}var Ce="interactive-control",V={common:Ce,wrapper:`${Ce}-wrapper`,disabled:`${Ce}-disabled`,button:`${Ce}-button`,area:`${Ce}-area`,text:`${Ce}-text`};var ne=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){var i;let t=document.createElement("div");t.classList.add(V.wrapper),e.setControlLayout(t,this.control.layoutParams);let n=((i=this.control.layoutParams.innerSizesDependOn)!=null?i:$.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:n}}createClickListener(e){return t=>{t.stopPropagation(),e()}}featureIsEnabled(e){return this.options&&mn(this.options)&&this.options.features[e]}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var i;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(i=this.container)==null||i.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){var e,t;(e=this.container)!=null&&e.element&&this.clickListener&&((t=this.container)==null||t.element.removeEventListener("click",this.clickListener))}};var ct=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Wt(r,e)},Wt=class extends ne{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(V.common,V.area),n.setAttribute("data-testid",se.AREA),ot({target:n,props:this.control.props,fallback:{...$,backgroundColor:"transparent"}}),lt({target:n,props:this.control.props,fallback:{...$,borderAlpha:0},dependsOn:this.container.dimensions}),be({target:n,layoutParams:this.control.layoutParams,fallback:$}),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(V.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(V.disabled)}getElement(){return this.controlElement}};var ut=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),n={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,n),t.append(e);let i={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,i),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var pt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new Kt(r,e)},Kt=class extends ne{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var o;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("button");n.type="button",n.classList.add(V.common,V.button),n.setAttribute("data-testid",se.BUTTON),be({target:n,layoutParams:this.control.layoutParams,fallback:$}),ot({target:n,props:this.control.props,fallback:$}),lt({target:n,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),st({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=ut(this.control.type.trim().toLowerCase()),s=(o=i.firstElementChild)!=null?o:i;at({target:s,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){this.controlElement&&this.controlElement.classList.add(V.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(V.disabled)}getElement(){return this.controlElement}};var yn=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new Qt(r,e)},Qt=class extends ne{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var o;if(super.createContainerElement(t),!this.container)return;let n=document.createElement("div");n.classList.add(V.common,V.text),n.setAttribute("data-testid",se.TEXT),be({target:n,layoutParams:this.control.layoutParams,fallback:$}),st({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let i=ut(this.control.type.trim().toLowerCase()),s=(o=i.firstElementChild)!=null?o:i;at({target:s,props:this.control.props,fallback:$,dependsOn:this.container.dimensions}),n.append(i),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}disable(){}enable(){}getElement(){return this.controlElement}};var Xt="interactive-container",F={common:Xt,hidden:`${Xt}-hidden`,disabled:`${Xt}-disabled`};var ht=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new Yt(r,e,t)},Yt=class extends ve{constructor(t,n,i){super(t,i);this.containerElement=null;this.rootElement=n,this.layout=new it(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",pt),this.addControlFactory("text",yn),this.addControlFactory("area",ct)}createView({eventCallback:t}){let n=document.createElement("div");return n.classList.add(F.common,F.disabled),requestAnimationFrame(()=>{n.classList.remove(F.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(i=>{i.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout}}),i.setEvents(t)}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,n}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(n=>n.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(F.disabled),this.controls.forEach(n=>n.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(this.controls.forEach(n=>n.removeListeners()),t.remove(),this.isRemoved=!0)}getElement(){return this.containerElement}};var Ao=X(Or(),1),g=require("@vkontakte/videoplayer-shared/es2018"),Pe=require("@vkontakte/videoplayer-statistics/es2018");var xs=require("@vkontakte/videoplayer-shared/es2018");function De(r,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>r(...n),e)}}var oe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,He=r=>oe(r,"Object"),It=r=>oe(r,"String"),xt=r=>oe(r,"Array"),Tt=r=>oe(r,"Number"),Cs=r=>oe(r,"Function");var Rr=r=>Tt(r)&&!isNaN(r);var le=r=>He(r)&&Object.keys(r).length===0,Pr=r=>xt(r)&&!r.length;var Ge=(r,e)=>It(r)&&(e?r.trim():r).length;var gs="video_interactive",Es="videoint";var Is=250,Ue=class{constructor(e){this.handleZoomChange=De(e=>{this.lastZoomInfo=e},Is);this.onResize=e=>{var n;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((n=this.ngEditor)==null||n.zoomTo(t)),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,n,i;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(e.id),(n=this.ngEditor)==null||n.selectChapter(e.id),(i=this.ngEditor)==null||i.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var n;if(this.isReady=!1,!Tt(e.graph.edit.chapters[0].x)){(n=this.onError)==null||n.call(this,"Can't show graph"),console.error("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:n,lang:i,visitedChapters:s=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=t,this.onError=n,this.lang=i!=null?i:"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Zc(e),this.resizeObserver=new ResizeObserver(De(this.onResize,Is)),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){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}async show(){var e;this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)}async initNgEditor(){if(!this.manifest)return;let e;try{e=await(0,xs.loadVKLangPack)(this.lang,gs,Es)}catch(n){console.log("Unable to load graph language pack")}let{GraphEditor:t}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name:n,...i})=>{var s;n==="openPreview"&&"chapterId"in i&&((s=this.onOpenPreviewClick)==null||s.call(this,i.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Zc(r){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",r.append(e),e}var ze=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,n=!1,i=Math.round(this._player.info.position$.getValue()*1e3);for(let s of this._containers){let o=s.startTime-e;if(o<=i&&(s.endTime&&i<=s.endTime||s.endTime===null)){n=!0;break}i<o&&(t=t===-1?o:Math.min(t,o))}return!n&&t!==-1?t:null}}};var v=require("@interactiveplatform/movika-manifest");var Ts={metadata:"Object",chapters:"Array"},kr=r=>{if(!He(r))return!1;for(let e in Ts)if(!r[e]||!oe(r[e],Ts[e]))return!1;return(0,v.isSupportedManifest)(r.metadata.version)},We=r=>r.type===v.ControlTypes.Text,Jc=r=>r.type===v.ControlTypes.Button,eu=r=>r.type===v.ControlTypes.Area,tu={Choice:"Choice",TextInput:"TextInput"},ru={Button:"Button",Area:"Area",Text:"Text"},nu={onClick:"onClick",onSuspense:"onSuspense"},iu={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var j=class{constructor(e,t,...n){this.severity=e;this.category=t;this.data=n}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var St=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let n=this.listeners[e]||[];for(let i=n.length;i>0;i--)if(n[i]===t){n.splice(i,1);break}return this}emit(e,...t){let n=this.listeners[e];return n?(n.forEach(i=>{i(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var wt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Cs(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(n=>n!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var Ps=require("@vkontakte/videoplayer-shared/es2018");var At=class{constructor(e){var t,n;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!=null?t:[],manifestLoaders:(n=e==null?void 0:e.manifestLoaders)!=null?n:[]}}async exec(e,t){return su(...this.loaders[e])(t)}};function su(...r){return async function(t){let n=[...r];for(;n.length>0;)t=await n.shift()(t);return t}}function Ke(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function Ot({actions:r,errors:e,chapterId:t,...n}){if(t){let i=r.getManifest();if(i){let s=r.getChapter(i.chapters,t);if(s){let o=r.getMedia(i.media,s.videoId),l=r.getGraph(i.graph,s.id);return o?{...n,actions:r,errors:e,result:{chapter:s,media:o,graph:l}}:{...n,errors:Ke(e,Ot.name,"Could not find media"),actions:r}}}}return{...n,errors:Ke(e,Ot.name,"Could not find chapter"),actions:r}}var Rt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){if(!(e in this.listeners))return;let n=this.listeners[e];for(let i=0,s=n.length;i<s;i++)if(n[i].callback===t){n.splice(i,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let n=this.listeners[e.type].slice();for(let i=0,s=n.length;i<s;i++){let o=n[i];try{o.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}o.options&&o.options.once&&this.removeEventListener(e.type,o.callback)}return!e.defaultPrevented}},Se=class extends Rt{constructor(){super(),this.listeners||Rt.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 Se,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(i){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let n=e;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(i){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(Qe.prototype[Symbol.toStringTag]="AbortController",Se.prototype[Symbol.toStringTag]="AbortSignal");function Pt(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 Vr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=r;if(!Pt({fetch:e,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:e,Request:s};let s=t;(s&&!s.prototype.hasOwnProperty("signal")||i)&&(s=function(c,f){let C;f&&f.signal&&(C=f.signal,delete f.signal);let d=new t(c,f);return C&&Object.defineProperty(d,"signal",{writable:!1,enumerable:!1,configurable:!0,value:C}),d},s.prototype=t.prototype);let o=e;return{fetch:(a,c)=>{let f=s&&s.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(f){let C;try{C=new DOMException("Aborted","AbortError")}catch(x){C=new Error("Aborted"),C.name="AbortError"}if(f.aborted)return Promise.reject(C);let d=new Promise((x,O)=>{f.addEventListener("abort",()=>O(C),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([d,o(a,c)])}return o(a,c)},Request:s}}var Xe=Pt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ss=Xe?Vr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Mr=Xe?Ss.fetch:window.fetch,Lf=Xe?Ss.Request:window.Request,Nf=Xe?Qe:window.AbortController,jf=Xe?Se:window.AbortSignal;var kt=(r="",e="")=>{let t=r.split("."),n=e.split("."),i=0;for(let s=0;s<Math.max(t.length,n.length)&&!i;s++)t[s]>n[s]?i=1:t[s]<n[s]?i=-1:i=0;return i};var au=async r=>{try{let e={},t;if(It(r)){t=new URL(r).href;let i=await Mr(t);if(!i.ok)return{};e=await i.json()}else if(He(r))e=r;else return{};if(!kr(e))return{};let n=e.metadata.media;if(It(n)&&!("media"in e))try{let i;t?i=new URL(n,t).href:(i=new URL(n).href,t=i);let s=await Mr(i);if(!s.ok)throw new Error;e.metadata.media=await s.json()}catch(i){return cu(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function ws(r){let{manifest:e,manifestURL:t}=await au(r);if(!e)throw new Error("Failed on fetch");let n=(0,v.migrateManifestToLatestVersion)(e);return n.media=ou(n.media,t),delete n.metadata.media,n}function Vt(r,e){if(e)return r.find(t=>t.id===e)}function Lr(r,e){var t,n;return(t=r.edit)!=null&&t.chapters?r.edit.chapters.find(i=>i.id===e):(n=r.view)!=null&&n.chapters?r.view.chapters.find(i=>i.id===e):void 0}function Nr(r,e){return r.videos.find(t=>t.id===e)}function ou(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(n=>{let i="url"in n?n.url:"",s=lu(i,e);return{...n,url:s||i}})}))}}function lu(r="",e){try{return new URL(r,e).href}catch(t){return""}}function cu(r){return kt(r,"3.2.0")>=0}var Mt=r=>xt(r)&&!Pr(r),Q=r=>r.order==="end",Ye=r=>xt(r.containers)&&!Pr(r.containers)&&Q(r),As=(r,e)=>{var n;let t=r*1e3;return Mt(e.controls)&&t<((n=e.startTime)!=null?n:0)},jr=(r,e)=>{var n,i;let t=r*1e3;return Mt(e.controls)&&t>=((n=e.startTime)!=null?n:0)&&t<=((i=e.endTime)!=null?i:1/0)};var ce=(r=[])=>r.some(e=>e.action.type==="expect"),$r=(r=[])=>r.find(e=>e.action.type==="expect"),uu=r=>(r==null?void 0:r.length)===1,ue=r=>uu(r)&&We(r[0]);function Os(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r({...e[0],...t}):r(...e,...t)}var Rs=(r,e)=>ce(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&ce(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var pe=class extends At{constructor(t,n){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Ps.ValueSubject(null);this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){var i;this.release();let n=await this.exec("manifestLoaders",{actions:{addErrorMessage:Ke},result:null,errors:null,source:t});return n.errors&&this.errorHandler(n.errors),this.manifest=await ws((i=n.result)!=null?i:t),this}async setInitial(){return this.setNext()}async setNext(t=(n=>(n=this.manifest)==null?void 0:n.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let i=await this.exec("chapterLoaders",Ot({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Lr,getChapter:Vt,getMedia:Nr,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ke},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(){var n;return this.getByChapterId((n=this.manifest)==null?void 0:n.metadata.initChapterId)||null}getByChapterId(t=(n=>(n=this.manifest)==null?void 0:n.metadata.initChapterId)()){if(!t||!this.manifest)return null;let i=Vt(this.manifest.chapters,t);if(i){let s=Nr(this.manifest.media,i.videoId),o=Lr(this.manifest.graph,i.id);if(s)return{chapter:i,media:s,graph:o}}return null}getBranches(t=(n=>(n=this.chapter)==null?void 0:n.id)()){var i,s,o;if(t===((i=this.chapter)==null?void 0:i.id))return this.getByBranches((s=this.chapter)==null?void 0:s.branches);{let l=Vt(((o=this.manifest)==null?void 0:o.chapters)||[],t);return this.getByBranches(l==null?void 0:l.branches)}}getByBranches(t=[]){return t.reduce((n,i)=>{let s=this.getByChapterId(i.chapterId);return s&&n.push(s),n},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,n;return((t=this.chapter)==null?void 0:t.id)===((n=this.manifest)==null?void 0:n.metadata.initChapterId)}isEndChapter(){return this.chapter?Q(this.chapter):!1}};var ba=X(Lt(),1),Ca=require("@vkontakte/videoplayer-core/es2018"),ie=require("@vkontakte/videoplayer-shared/es2018");var ua=r=>{let e=r.variants.find(t=>{var n;return((n=t.payload)==null?void 0:n.type)==="vk"});if(e&&e.payload){let[t,n]=e.payload.id.split("_");return[t,n]}return[]};var pa=X(Lt(),1);function Br(){let r=new Map;function e({listId:s=Math.random().toString(),itemId:o=Math.random().toString(),...l}){let a=r.get(s),c={...l};return a?a[o]=c:r.set(s,{[o]:c}),{listId:s,itemId:o,...l}}function t(s){var o,l;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(o=s.statistics)==null||o.oneStat.destroy(),(l=s.statistics)==null||l.statSubscription.unsubscribe()}function n(s,o){let l=r.get(s);if(!l)throw Error("Can't remove. Not find.");if(o){let a=l[o];a&&t(a),delete l[o],Object.keys(l).length||r.delete(s)}else{for(let a of(0,pa.default)(l))t(a);r.delete(s)}}function i(){for(let s of r)n(s[0])}return{createPlayer:e,removePlayer:n,map:r,removeAll:i}}var we=X(Nt(),1);function Dr(r,e=[]){var s,o,l;let t={},n,i=!e.length;for(let a of r.variants)if(!n&&"cover"in a&&(n=a.cover),"url"in a)switch(a.type.toLowerCase()){case"mp4":(i||(0,we.default)(e,"mp4"))&&(t.MPEG={...t.MPEG,[(s=a.standard)!=null?s:"Invariant quality"]:a.url});break;case"mpeg":(i||(0,we.default)(e,"mpeg"))&&(t.MPEG={...t.MPEG,[(o=a.standard)!=null?o:"Invariant quality"]:a.url});break;case"hls":(i||(0,we.default)(e,"hls"))&&(t={...t,HLS:{type:"url",url:a.url}});break;case"dash":(i||(0,we.default)(e,"dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}});break;default:break}return{sources:t,thumbUrl:n,title:(l=r.title)!=null?l:""}}var Ze=(r,e)=>{let t=r.info.currentQuality$.getValue(),n=r.info.availableQualities$.getValue();t!==e&&(0,we.default)(n,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Zu=2;function Hr(r){let e=Br(),t=new ie.Subscription,n={},i=null,s=!1,o,l=new ie.ValueSubject(null);r&&a(r);function a(b){i=b}function c(b,P,u){var I;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let m=((I=e.map.get(b))!=null?I:{})[P];if(m){n={chapterId:u,listId:b,itemId:P,...m};let E=n.player;n.subscription.add(E.info.currentQuality$.subscribe(y=>{let T=E.info.position$.getValue(),N=E.info.isAutoQualityEnabled$.getValue();if(!(!y||!T||N))for(let S of e.map)(0,ba.default)(S[1]).forEach(({player:M})=>{Ze(M,y)})})).add(E.events.started$.subscribe(()=>{f(P)})),m.container.remove(),i.setPlayer(m.player),s||(i.init(),s=!0),l.next({player:n.player,config:n.config,statistics:n.statistics});return}throw Error("Can't set. Not find.")}async function f(b){if(!i)throw Error("need to set interactive controller");if(le(n)||b!==n.itemId)return;let P=i.getChapterBranches(),u=new Set;for(let h of P)u.has(h.media.id)||(await d({media:h.media,chapterId:h.chapter.id,setAsActive:!1,title:h.chapter.label}),u.add(h.media.id))}async function C({chapter:{id:b},manifestVideo:P}){if(le(n)||!i)return;let u=n.player.info.muted$.getValue(),h=n.player.info.currentQuality$.getValue(),m=n.player.info.isAutoQualityEnabled$.getValue(),I=n.player.info.volume$.getValue(),E=n.player.info.currentPlaybackRate$.getValue(),y=!m,T=!1;for(let N of e.map)if(N[0]===P.id&&!i.state.isReplay$.getValue()){let S=Object.keys(N[1]);for(let M of S)M===n.itemId?(S.length<Zu||(T=!0),e.removePlayer(N[0],M)):(T=!0,c(N[0],M,b),y?Ze(n.player,h):n.player.setAutoQuality(!0),n.player.setVolume(I),n.player.setMuted(u),n.player.setPlaybackRate(E))}else e.removePlayer(N[0]);T||(await d({media:P,chapterId:b,setAsActive:!0,playbackRate:E}),y?Ze(n.player,h):n.player.setAutoQuality(!0),n.player.setVolume(I),n.player.setMuted(u))}async function d({media:b,chapterId:P,prefetch:u=!0,setAsActive:h=!0,autoplay:m=!1,preferredExt:I,title:E,playbackRate:y}){var Zr,Jr,en,tn,rn;let T=Math.random().toString(),N=document.createElement("div");o.append(N);let S;if((Zr=i==null?void 0:i.options)!=null&&Zr.vkVideoLoader){let rt=ua(b);rt.length&&(S=await i.options.vkVideoLoader(...rt))}let M=((Jr=i==null?void 0:i.options)==null?void 0:Jr.coreConfig)||void 0,G={...M,configName:[...(en=M==null?void 0:M.configName)!=null?en:[],"interactive"]},U={container:N,...((tn=S==null?void 0:S.videos)==null?void 0:tn[0])||{sources:Dr(b,I).sources},title:E,failoverHosts:(S==null?void 0:S.failoverHosts)||[]},z=new Ca.Player(G,ie.Tracer.createRootTracer());z.initVideo(U);let J=null;if(S!=null&&S.videos&&(i!=null&&i.options.createOneStat)){let rt=S.videos[0],Ht=i.options.createOneStat(rt),nn=new ie.Subscription;Ht&&(nn.add(Ht.attachTo(z)),J={oneStat:Ht,statSubscription:nn})}let me=new ie.Subscription,Ro=(rn=n==null?void 0:n.player)==null?void 0:rn.info.isAutoQualityEnabled$.getValue();me.add(z.events.canplay$.subscribe(function(){Ro||Ze(z,n.player.info.currentQuality$.getValue()),y&&z.setPlaybackRate(y)}));let ye=e.createPlayer({listId:b.id,itemId:T,player:z,container:N,sources:Dr(b,I).sources,config:U,subscription:me,statistics:J});return h&&c(b.id,ye.itemId,P),m&&ye.player.play(),u&&!m&&ye.player.prepare(),{player:ye.player,config:ye.config,statistics:ye.statistics}}function x(){O(),i=null,o.remove()}function O(){t.unsubscribe(),e.removeAll(),n={},s=!1}async function R(){if(!i)throw Error("need to set interactive controller");O(),o=document.createElement("div");let{media:b,chapter:P}=i.getCurrentChapter();b&&P?(t.add(i.events.chapterChanged$.subscribe(C)),await d({media:b,chapterId:P.id,title:P.label})):console.error("not found")}return{...e,init:R,setInteractiveController:a,createPlayer:d,removeAll:x,getActivePlayer:function(){return n},activePlayerChanged:l}}var A={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Ae={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},k={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Ea=X(Nt(),1),Ia=require("@vkontakte/videoplayer-shared/es2018");var jt=class{constructor({player:e,container:t,branches:n,selectBranches:i,interactiveEvents:s,globalEvents:o,globalEventEmitter:l,ignoreContainerEvent:a,permanentTextControls:c,disabledControls$:f,onRemove:C}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(ce(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,n,i,s;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement())(n=(t=this.container).show)==null||n.call(t),this.emitContainerVisibilityEvent(!0,!1);else{let o={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(a,c)=>{this.isSelectedControlEvent=!0,a!==!1&&(this.removeView(),this.emitContainerVisibilityEvent(!1)),(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),c(),this.removeView(),this.emitContainerVisibilityEvent(!1))},isEOV:()=>this.gameState===4},l=Os(this.selectBranches.onControlEvent,o);this.container.createView({eventCallback:l}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((s=(i=this.container).disable)==null||s.call(i))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var c;let e=this.player.experimental.element$.getValue(),n=e instanceof HTMLVideoElement?e.readyState:void 0,i=[6,5];if(!n||(0,Ea.default)(i,this.gameState)&&!this.isPermanentText)return;let s=this.player.getExactTime();if(As(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(jr(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let f=this.gameState;this.gameState=3,f===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let o=jr(s,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(c=this.container.container.endTime)!=null?c:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:s,isInteractiveTime:o};this.globalEventEmitter.emit(A.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=n,this.selectBranches=i,this.subscription=new Ia.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=a,this.isPermanentText=c&&ue(t.container.controls),this.disabledControls$=f,this.onRemove=C,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=o,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(A.interactives,{subjectId:this.container.container.id,subjectName:"container",type:k.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(A.interactives,{subjectId:this.container.container.id,subjectName:"container",type:k.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=>{var t,n,i,s;e?(n=(t=this.container).disable)==null||n.call(t):(s=(i=this.container).enable)==null||s.call(i)}))}selectContainerEvent(e=!1){var t,n;this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(t=this.container.container.endTime)!=null?t:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((n=this.container.container.endTime)!=null?n:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=ce(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(A.interactives,{subjectId:this.container.container.id,subjectName:"container",type:k.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var xa=(r=[])=>r.reduce((e,t,n)=>{var s,o,l;let i=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!We(a));if(Mt(i)){let a=[(o=t.startTime)!=null?o:0,(l=t.endTime)!=null?l:1/0],c=t.id;if(!n)e.push({subjects:[c],range:a});else{let f=[],C=-1/0,d=1/0,x=[],O=[];for(let R=0;R<e.length;R++){let b=e[R];if(O.push(...b.subjects),b.range[0]<d&&(d=b.range[0]),b.range[1]>C&&(C=b.range[1]),a[0]>=b.range[0]&&a[1]<=b.range[1])return e[R].subjects.push(c),e;a[0]<b.range[0]&&a[1]>b.range[0]&&(f.push(R),x=x.concat(b.subjects)),a[0]>=b.range[0]&&a[0]<=b.range[1]&&(f.push(R),x=x.concat(b.subjects),a[0]=b.range[0]),a[1]>=b.range[0]&&a[1]<=b.range[1]&&(f.push(R),x=x.concat(b.subjects),a[1]=b.range[1])}if(O.push(c),a[0]<=d&&a[1]>=C)return[{subjects:O,range:a}];f.length&&f.reverse().forEach(R=>{e.splice(R,1)}),e.push({subjects:x.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var io=X(Nt(),1),Wr=X(Lt(),1),so=X(ro(),1);function no(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let a={};for(let c in r)+c<=l&&(a[c]=r[c]);return a}function n(l){let a={};for(let c in r)+c>=l&&(a[c]=r[c]);return a}function i({timestamp:l,priority:a,initiator:c}){var f;if(Rr(l)){let C=(f=r[l])!=null?f:null;if(C&&a&&Ge(a,!0)){let d={},x=C[a];if(x&&(d={...d,...x}),d=le(d)?null:d,d&&Ge(c,!0)){let O=d[c];return O!=null?O:null}return d}return C}return null}function s({timestamp:l,priority:a,initiator:c}){if(Rr(l))if(r[l]){if(a&&Ge(a,!0))if(r[l][a]){if(c&&Ge(c,!0))if(r[l][a][c]){if(delete r[l][a][c],!le(r[l][a]))return!0}else return!1;if(delete r[l][a],!le(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function o({timestamp:l,priority:a,initiator:c,...f}){var C,d,x;(d=(C=r[l])==null?void 0:C[a])!=null&&d[c]?r[l][a][c].push({...f}):(x=r[l])!=null&&x[a]?r[l][a]={...r[l][a],[c]:[{...f}]}:r[l]?r[l]={...r[l],[a]:{[c]:[{...f}]}}:r[l]={[a]:{[c]:[{...f}]}}}return{map:r,remove:s,add:o,removeAll:e,get:i,getLte:t,getGte:n}}var qp=[v.EventActionTypes.expect,v.EventActionTypes.setNextBranch],Bp=1/0;function ao(r){let e=r,t,n=Dp(),i=no(),s,o=()=>{d(),P()},l=u=>{i.add.call(void 0,u),O()},a=(u=[])=>{for(let h of u)if(h.action(),(0,io.default)(qp,h.actionType))break},c=(u=1/0)=>{var E,y,T;let h=_t((E=i.get({timestamp:u,priority:"control"}))!=null?E:{}),m=_t((y=i.get({timestamp:u,priority:"container"}))!=null?y:{}),I=_t((T=i.get({timestamp:u,priority:"chapter"}))!=null?T:{});return[...h,...m,...I]},f=u=>{n.isReady(u)&&a(c(u))},C=()=>{var u;a([..._t((u=i.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},d=()=>{t&&(s==null||s.unsubscribe(),t=void 0)},x=u=>{},O=()=>{t||(t=()=>setTimeout(()=>{f(1/0)}),s=e.events.ended$.subscribe(t))},R=u=>{d(),e=u},b=u=>{u.priority==="container"&&n.resetCalled(u.timestamp),i.remove(u)},P=()=>{n.release(),i.removeAll()};return{setPlayer:R,add:l,remove:b,exec:f,execEndOfVideo:C,listen:O,unlisten:d,release:o,containersEventsCallState:n,getPreparedToExecActions:c}}function Dp(){let r=new Map;return{setCalled:({timestamp:o,id:l})=>{let a=r.get(o);a&&a[l]!==void 0&&(a[l]=!0)},setData:(o=[])=>{var l;for(let a of o){let c=(l=a.endTime)!=null?l:Bp,f=r.get(c);r.set(c,{...f,[a.id]:!1})}},resetCalled:o=>{let l=r.get(o);if(l)for(let a in l)l[a]=!1},isReady:o=>{let l=r.get(o);return l?!(0,Wr.default)(l).some(a=>!a):!0},release:()=>r.clear()}}function _t(r){return(0,so.default)((0,Wr.default)(r)).sort(e=>e.actionType===v.EventActionTypes.expect?-1:1)}var oo={videoContentHeight:0,videoContentWidth:0},lo=(r,e)=>{let{height:t,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&n))return oo;let{clientHeight:i,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(i&&s))return oo;let o=t/n,l=i/s,a,c;return l>o?(c=s,a=s*o):l<o?(c=i/o,a=i):(c=s,a=i),{videoContentWidth:c,videoContentHeight:a}};var Hp=250;function co(r){let e=()=>{},t=new ResizeObserver(l=>{s(l),e=s.bind(null,l)});function n(l){let{parentElement:a,player:c}=r();if(a&&c){let{videoContentWidth:f,videoContentHeight:C}=lo(a,c);a.style.setProperty("--interactive-content-width",`${f}px`),a.style.setProperty("--interactive-content-height",`${C}px`),a.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function i(){let{parentElement:l}=r();l.removeAttribute("style")}let s=De(l=>{let{fns:a=[]}=r();n(l);for(let c of a)c()},Hp);function o(){e=void 0,t.disconnect(),i()}return{resizeObserver:t,calc:()=>{e==null||e()},release:o}}var Gp=r=>Math.floor(Math.random()*r),po=r=>{var i;let e=r.length,t=1/0,n=null;for(;e--;){let s=r[e],o=(i=s.weight)!=null?i:1;o<t&&(t=o,n=s)}return n},ho=r=>{var i;let e=r.length,t=-1/0,n=null;for(;e--;){let s=r[e],o=(i=s.weight)!=null?i:0;o>t&&(t=o,n=s)}return n};var fo=r=>{let e=r.length,t=Gp(e);return r[t]},uo=1,mo=r=>{var n,i;let e=0;for(let s=0;s<r.length;++s)e+=(n=r[s].weight)!=null?n:uo;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(i=r[s].weight)!=null?i:uo,e>=t)return r[s];return r[r.length-1]};var yo={shouldOpenNow:!0,isDetachContainer:!0},vo="after-expect";var Kr=(r,e=!1)=>({...r,args:e?{...r.args,...yo}:{...yo,...r.args}}),go=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:n})=>{let i={isExpect:!1},s=()=>{i.isExpect&&(i.isExpect=!1)},o=({action:u,controlType:h,controlId:m,containerId:I,branches:E=[],onEvent:y,isEOV:T=()=>!1,isDisabled:N=()=>!1})=>{let S=Kr(u,T()),M={timestamp:1/0,priority:"control",initiator:m,actionType:S.type},G=N(),U=r.emit.bind(r,A.interactives,{subjectId:m,subjectType:h,subjectName:"control",type:G?k.actionChoiceCanceled:k.actionChoice,actionType:u.type,payload:{invokeImmediately:S.args.shouldOpenNow,containerId:I,...S.args}}),z=()=>{e.interactiveActionChoice$.next({subjectId:m,subjectType:h,subjectName:"control",type:G?"action-choice-canceled":"action-choice",actionType:u.type,payload:{invokeImmediately:S.args.shouldOpenNow,containerId:I,...S.args}})};if(G){U(),z();return}switch(S.type.trim().toLowerCase()){case v.EventActionTypes.setNextBranch.trim().toLowerCase():{let J=E.find(me=>me.id===S.args.branchId);if(!J)return;y(S.args.isDetachContainer,x.bind(null,{subjectId:m,subjectName:"control"})),U(),z(),S.args.shouldOpenNow?R({subjectId:m,subjectName:"control",subjectType:h,action:S,payload:{chapterId:J.chapterId,autoSelect:!1}}):n.add({...M,action:R.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:S,payload:{chapterId:J.chapterId,autoSelect:!1}})});return}case v.EventActionTypes.continuePlayback.trim().toLowerCase():{y(S.args.isDetachContainer,x.bind(null,{subjectId:m,subjectName:"control"})),U(),z(),S.args.shouldOpenNow?O({subjectId:m,subjectName:"control",subjectType:h,action:u}):n.add({...M,action:O.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:u})});return}case v.EventActionTypes.openURI.trim().toLowerCase():{y(S.args.isDetachContainer,x.bind(null,{subjectId:m,subjectName:"control"})),U(),z(),S.args.shouldOpenNow?P({subjectId:m,subjectName:"control",subjectType:h,action:S,payload:{URI:u.args.uri}}):n.add({...M,action:P.bind(null,{subjectId:m,subjectName:"control",subjectType:h,action:S,payload:{URI:u.args.uri}})});return}default:{let J="Unexpected control event",me=new j(1,1,{message:J});f(me,J);return}}},l=({action:u,container:{id:h,endTime:m},branches:I=[],isEOV:E=!1,autoSelected:y=!1})=>{let T=Kr(u,E),N={timestamp:!T.args.shouldOpenNow||E?1/0:m!=null?m:1/0,priority:"container",initiator:h,actionType:T.type},S=r.emit.bind(r,A.interactives,{subjectId:h,subjectName:"container",type:k.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),M=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}})};switch(T.type.trim().toLowerCase()){case v.EventActionTypes.setNextBranch.trim().toLowerCase():{let G=I.find(U=>U.id===T.args.branchId);if(!G)return;S(),M(),n.add({...N,action:R.bind(null,{subjectId:h,subjectName:"container",action:T,payload:{chapterId:G.chapterId,autoSelect:y}})});return}case v.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case v.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case v.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case v.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case v.EventActionTypes.continuePlayback.trim().toLowerCase():{S(),M(),n.add({...N,action:O.bind(null,{subjectId:h,subjectName:"container",action:T})});return}case v.EventActionTypes.openURI.trim().toLowerCase():{S(),M(),n.add({...N,action:P.bind(null,{subjectId:h,subjectName:"container",action:T,payload:{URI:u.args.uri}})});return}default:{let G="Unexpected container event",U=new j(1,1,{message:G});f(U,G);return}}};function a({container:u,branches:h,isEOV:m=!1}){var E,y;let I=$r(u.events);if(I){let T=Kr(I.action,m);r.emit(A.interactives,{subjectId:u.id,subjectName:"container",type:k.actionChoice,actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:T.type,payload:{invokeImmediately:T.args.shouldOpenNow,...T.args}}),n.add({timestamp:m?1/0:(E=u.endTime)!=null?E:1/0,priority:"container",initiator:u.id,actionType:v.EventActionTypes.expect,action:d.bind(null,{subjectId:u.id,subjectName:"container"})}),i.isExpect=!0}else for(let T of(y=u.events)!=null?y:[])l({action:T.action,container:u,branches:h,isEOV:m})}let c=({chapterId:u,action:h,branches:m=[]})=>{let I=r.emit.bind(r,A.interactives,{subjectId:u,subjectName:"chapter",type:k.actionChoice,actionType:h.type,payload:h.args}),E=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case v.EventActionTypes.setNextBranch.trim().toLowerCase():{let y=m.find(T=>T.id===h.args.branchId);return y!=null&&y.chapterId?(I(),E(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case v.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let y=fo(m);return y!=null&&y.chapterId?(I(),E(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case v.EventActionTypes.setRandomBranch.trim().toLowerCase():{let y=mo(m);return y!=null&&y.chapterId?(I(),E(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case v.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let y=ho(m);return y!=null&&y.chapterId?(I(),E(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case v.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let y=po(m);return y!=null&&y.chapterId?(I(),E(),R.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case v.EventActionTypes.continuePlayback.trim().toLowerCase():return I(),E(),O.bind(null,{subjectId:u,subjectName:"chapter",action:h});case v.EventActionTypes.openURI.trim().toLowerCase():return I(),E(),P.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let y="Unexpected chapter event",T=new j(1,1,{message:y});f(T,y);return}}};function f(u,h){console.error(h),e.error$.next(u),r.emit(A.errors,u)}function C(u){var m;let h=$r(u.events);if(h){if(Q(u))return;r.emit(A.interactives,{subjectId:u.id,subjectName:"chapter",type:k.actionChoice,actionType:h.action.type,payload:h.action.args}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"chapter",type:"action-choice",actionType:h.action.type,payload:h.action.args}),n.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:v.EventActionTypes.expect,action:d.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else(m=u.events)==null||m.forEach(I=>{let E=c({chapterId:u.id,action:I.action,branches:u.branches});E&&n.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:I.action.type,action:E})})}let d=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(A.interactives,{subjectId:u,subjectName:h,type:k.actionExecution,actionType:v.EventActionTypes.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:v.EventActionTypes.expect})},x=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?n.execEndOfVideo():t.play(),r.emit(A.interactives,{subjectId:u,subjectName:h,type:k.actionExecution,actionType:vo}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:vo})},O=({subjectId:u,subjectName:h,subjectType:m,action:I})=>{r.emit(A.interactives,{subjectId:u,subjectName:h,subjectType:m,type:k.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:I.type})},R=({subjectId:u,subjectName:h,subjectType:m,action:I,payload:E})=>{E.behaviour="change-chapter",r.emit(A.interactives,{subjectId:u,subjectName:h,subjectType:m,type:k.actionExecution,actionType:I.type,payload:E}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:I.type,payload:E})},b=({subjectId:u,subjectName:h,subjectType:m,action:I,payload:E})=>{E.behaviour="change-manifest",r.emit(A.interactives,{subjectId:u,subjectName:h,subjectType:m,type:k.actionExecution,actionType:I.type,payload:E}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:I.type,payload:E})},P=({subjectId:u,subjectName:h,subjectType:m,action:I,payload:E})=>{if(!E.URI)return;let y=window.open(E.URI,"_blank","noopener,noreferrer");y&&(y.opener=null),r.emit(A.interactives,{subjectId:u,subjectName:h,subjectType:m,type:k.actionExecution,actionType:I.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:m,type:"action-execution",actionType:I.type})};return{onControlEvent:o,onContainerEvent:l,onChapterEvent:c,onExpectEvent:d,expectEventHandler:x,setManifestChapterEvents:C,setManifestContainerEvents:a,stopExpect:s,state:i}};var Yr=X(Or(),1),H=require("@vkontakte/videoplayer-shared/es2018");var Ft=(r,e)=>{let t={};return r.map(n=>{if(!t[n]){let i=e.chapters.find(o=>o.id===n);if(!i)return null;let s=e.media.videos.find(o=>i.videoId===o.id);if(!s)return null;t[n]=Qr(s)}return t[n]}).filter(Boolean)},Eo=r=>{for(let e of r.variants)if(Io(e)&&e.payload)return e.payload.id},Io=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),Qr=r=>{let e=Eo(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},xo=(r,e)=>{for(let t of r.media.videos)if(e===Qr(t)){for(let n of r.chapters)if(n.videoId===t.id)return n.id;return}},Xr=(r,e)=>r.reduce((t,n)=>{let i=xo(e,n);return i?[...t,i]:t},[]);var ee,he,de,D,qt,te,re,Z,fe,Oe,Re,et=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:n,historyApi:i,settings:s}){this.state={history$:new H.ValueSubject([]),hasPrevChapter$:new H.ValueSubject(!1),prevChapter$:new H.ValueSubject(null),isInitialChapter$:new H.ValueSubject(!1),isGoBackLimited$:new H.ValueSubject(!1)};_(this,ee,null);_(this,he);_(this,de,!1);_(this,D,null);_(this,qt,null);this.events={inited$:new H.Subject,destroyed$:new H.Subject,error$:new H.Subject};_(this,te,null);_(this,re,null);_(this,Z,null);_(this,fe,new H.Subscription);_(this,Oe,!1);_(this,Re,0);var o;L(this,te,t),L(this,Z,e),L(this,re,n),L(this,ee,i),L(this,he,s),this.state.history$&&w(this,fe)&&((o=w(this,fe))==null||o.add(this.state.history$.subscribe(l=>{var a,c;this.state.prevChapter$.next((0,Yr.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(a=w(this,D))==null?void 0:a.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(w(this,Re)===w(this,he).maxLength-1)})))}async setManifest(e){if(!w(this,re)||!w(this,Z))return;L(this,D,e),await this.getProjectHistory();let t=this.getInitialChapterId();await w(this,re).setChapter({chapterId:t,pushToHistory:!1}),w(this,de)||(L(this,de,!0),this.events.inited$.next({initChapterId:t}))}get inited(){return w(this,de)}async updateHistory(e,t=!0){var l;if(!w(this,D))return;w(this,Oe)?(L(this,Oe,!1),ln(this,Re)._++):L(this,Re,0);let n=w(this,D),i=e.length-w(this,he).maxLength,s=i>0?e.slice(i):e,o=Ft(s,n);if(L(this,qt,o),this.state.history$.next(s),!(!t||!w(this,ee)||!w(this,te)))try{await w(this,ee).save(w(this,te),o)}catch(a){let c=new j(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=w(this,Z))==null||l.emit(A.errors,c)}}async goBack(){var n;if(!this.state||!w(this,re)){let i=new j(1,5,"Unable to save interactive history");return this.events.error$.next(i),(n=w(this,Z))==null?void 0:n.emit(A.errors,i)}L(this,Oe,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await w(this,re).setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){var i;if(!w(this,D)||!w(this,te))return;let e=w(this,D),t=[this.getInitialVideoId()];if(w(this,ee))try{let s=await w(this,ee).get(w(this,te));s.length&&(t=s)}catch(s){let o=new j(1,5,"Error while trying to fetch data");this.events.error$.next(o),(i=w(this,Z))==null||i.emit(A.errors,o)}let n=Xr(t,e);this.state.history$.next(n)}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,Yr.default)(e,-1)||w(this,he).initChapterId||((t=w(this,D))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(w(this,D)){let e=this.getInitialChapterId();return Ft([e],w(this,D)).pop()}return null}destroy(){var e,t;L(this,te,null),L(this,ee,null),L(this,re,null),(e=w(this,fe))==null||e.unsubscribe(),L(this,fe,null),L(this,de,!1),(t=w(this,Z))==null||t.emit(A.historyDestroyed),this.events.destroyed$.next(),L(this,Z,null)}};ee=new WeakMap,he=new WeakMap,de=new WeakMap,D=new WeakMap,qt=new WeakMap,te=new WeakMap,re=new WeakMap,Z=new WeakMap,fe=new WeakMap,Oe=new WeakMap,Re=new WeakMap;var Bt=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var i;let e=(i=this.rootElement.getContext("2d"))==null?void 0:i.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,n=t.length;for(let s=3;s<n;s+=40)if(t[s]!==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(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}async updateCanvasDimensions(e,t=!1){let n=e.width+e.height;if(this._prevSizeId===n)return;let i;t&&(i=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&i&&this.restore(i),this._prevSizeId=n}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var Dt=class{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
7
7
|
position: absolute;
|
|
8
8
|
top: 0;
|
|
9
9
|
left: 0;
|
|
@@ -11,13 +11,50 @@
|
|
|
11
11
|
height: var(--interactive-height);
|
|
12
12
|
background-color: var(--black);
|
|
13
13
|
visibility: hidden;
|
|
14
|
-
`,this.lastFrameCanvas=new
|
|
14
|
+
`,this.lastFrameCanvas=new Bt,this.endOffsetMs=t,this._callbacks={onError:n},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),n={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(i){this._onError(i)}}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=>{var n,i,
|
|
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),n={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(i){this._onError(i)}}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=>{var n,i,s;return((n=t.controls)==null?void 0:n.length)&&e>=((i=t.startTime)!=null?i:0)&&e<=Math.min((s=t.endTime)!=null?s:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,n;(n=(t=this._callbacks)==null?void 0:t.onError)==null||n.call(t,e)}};function To(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var zp=`
|
|
20
|
+
.${F.common} {
|
|
21
|
+
opacity: 1;
|
|
22
|
+
visibility: visible;
|
|
23
|
+
transition: opacity var(--transition-1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.${F.disabled} {
|
|
27
|
+
opacity: 0.5;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.${F.hidden} {
|
|
31
|
+
visibility: hidden;
|
|
32
|
+
}
|
|
33
|
+
`,Wp=`
|
|
34
|
+
.interactive-chapter {
|
|
20
35
|
position: absolute;
|
|
21
36
|
top: 0;
|
|
22
37
|
left: 0;
|
|
23
|
-
`,r}var Je=class{constructor(e){this.playerSubscriptions=new x.Subscription;this.subscriptions=new x.Subscription;this.globalEventEmitter=new xt;this.animation=new St;this.seekToInteractiveController=new Ue;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Dp();this.factories=new Map([["choice",pt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new x.Subscription;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new x.ValueSubject(null),isInitialChapter$:new x.ValueSubject(!1),isFirstChapter$:new x.ValueSubject(!0),isEndChapter$:new x.ValueSubject(!1),isInteractiveExpectation$:new x.ValueSubject(!1),isReplay$:new x.ValueSubject(!1),calledByInteractive$:new x.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new x.ValueSubject(!1),disabledControls$:new x.ValueSubject(!1),interactiveRanges$:new x.ValueSubject([]),isInteractiveTime$:new x.ValueSubject(!1),statistics$:new x.ValueSubject(null),isSeekable$:new x.ValueSubject(!1)};this.events={noInteraction$:new x.Subject,graphVisibilityChanged$:new x.Subject,watchAgainIsClicked$:new x.Subject,chapterChanged$:new x.Subject,playerChanged$:new x.Subject,error$:new x.Subject,eachTick$:new x.Subject,manifestChanged$:new x.Subject,interactiveRangeEnded$:new x.Subject,interactiveContainerRemoved$:new x.Subject,interactiveContainerFakeRemoved$:new x.Subject,interactiveActionExecution$:new x.Subject,interactiveActionChoice$:new x.Subject,interactiveVisibilityChanged$:new x.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(P.errors,e)};this.clearHistoryIfEnded=()=>{var i;let e=(i=this.player)==null?void 0:i.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&K(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...n}=e;if(t){let{statSubscription:i,oneStat:a}=t;i.add(a.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(P.playerChanged,n)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.removeControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,i=t.getValue().map(a=>({...a,subjects:a.subjects.filter(o=>o.id!==e)}));t.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var t;this._options={...Io,...e,config:{...Io.config,...e.config}},this._options.parentElement.append(this.rootElement),this.historyController=new Ze({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(t=this._options.projectInfo)==null?void 0:t.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new Bt({parentElement:this._options.parentElement,onError:n=>{let i=new N(1,6,n);this.emitErrorEvent(i)}})),this.subscriptions.add((0,x.fromEvent)(this.rootElement,"mousedown").subscribe(n=>n.stopPropagation())).add((0,x.fromEvent)(this.rootElement,"mouseup").subscribe(n=>n.stopPropagation())),this.manifestController=new ue(this._options.loaders,n=>{let i=new N(1,3,n);this.emitErrorEvent(i)}),this.resizeManager=so(()=>{var n,i;return{player:this.player,parentElement:(n=this._options)==null?void 0:n.parentElement,fns:(i=this._options)!=null&&i.lastFrame?[()=>{var a;(a=this.lastFrame)==null||a.updateCanvasDimensions(!0)}]:[]}}),this._options.graph&&(this.graph=new He({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:n=>{this.setChapter({chapterId:n}),this.globalEventEmitter.emit(P.graph,{type:Se.watchAgainClicked,chapterId:n}),this.events.watchAgainIsClicked$.next(n)},onError:n=>{let i=new N(1,4,{message:n});this.emitErrorEvent(i)}})),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=>{var t,n;if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:i}=e.payload;this.setChapter({chapterId:i}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((n=e.payload)==null?void 0:n.behaviour)==="change-manifest"){let{manifestURL:i}=e.payload;i&&this.setManifest(i)}e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:n})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in n&&n.invokeImmediately||this.removeControllers(!1)}))}async initSeamless(){this.seamlessController=Dr(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,i=this.getInteractiveRanges().reverse().find(({range:a})=>t>=a[1]);if(i){let a=i.range.join("-");this.endedRanges.has(a)||(this.endedRanges.add(a),this.globalEventEmitter.emit(P.interactives,{type:k.rangeEnded,payload:i,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:i}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe((0,x.once)()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,x.combine)({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:n})=>{var s;let i;if(n)i=!0;else{let l=e*1e3;i=!!t.find(({range:[m,v],subjects:g})=>m<l&&l<v&&g.some(R=>!R.isRemoved)&&g.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let a=!!this.noInteractionTimeout,c=((s=this.player)==null?void 0:s.info.playbackState$.getValue())==="playing"||n;i&&!a&&c?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):a&&!c&&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=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,n;(t=this.lastFrame)==null||t.hide(),(n=this.lastFrame)==null||n.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,n;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.filterGameControllers(e),(n=this.interactiveEvents)==null||n.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(i=>i.container.container).filter(i=>!le(i.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var i;this.player&&((i=this.lastFrame)==null||i.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}filterGameControllers(e){let t=[];return e.containers.forEach(n=>{let i=n.type.trim().toLowerCase(),a=this.factories.get(i),o=a==null?void 0:a(n,this.rootElement);if(o&&this.selectBranches&&this.interactiveEvents&&this.player){let c=new Nt({player:this.player,container:o,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>wa(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)}});this.animation.addFn(c.whilePlaying,!0),t.push(c)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),n=!!this.seekToInteractiveController.getNextInteractiveTime();(n&&!t||!n&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){var c,s;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(c=n&&K(n)&&Qe(n))!=null?c:!1,a=((s=this.manifestController.manifest)==null?void 0:s.metadata.initChapterId)===e,o=this.historyController.state.history$.getValue();if(a||i&&t){this.historyController.updateHistory([e]);return}(0,To.default)(o,-1)!==e&&this.historyController.updateHistory([...o,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,a=n.getValue().map(o=>{let c=o.subjects.some(l=>l.id===e),s=o.subjects.map(l=>t&&c||l.id===e?{...l,isRemoved:!0}:l);return{...o,subjects:s}});n.next(a)}reset(){var e;this.appState===2&&(this.removeControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.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(P.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=no(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=yo({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){var s,l;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),x.clientChecker.isSafari&&await Eo(35);let i=!n&&this.state.isEndChapter$.getValue()&&((s=this.getCurrentManifest())==null?void 0:s.metadata.initChapterId)===e;this.state.isReplay$.next(i);let{chapter:a,media:o,graph:c}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||i)&&this.state.isFirstChapter$.next(!0),!(!a||!o)&&(t&&this.pushChapterToHistory(a.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(a),(l=this.lastFrame)==null||l.setCurrentChapter(a),this.events.chapterChanged$.next({chapter:a,manifestVideo:o}),this.globalEventEmitter.emit(P.chapterChanged,{chapter:a,media:o,graph:c}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new x.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?Re.InteractiveInterfaceClick.GRAPH_SHOW:Re.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Re.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(Re.InteractiveInterfaceClick.NEXT_BUTTON),i==="Area"&&e.next(Re.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new x.Observable(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}toggleGraphView(e=!0){this.graph&&(e?(this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(P.graph,{type:Se.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var n;return!(((n=this.interactiveEvents)==null?void 0:n.getPreparedToExecActions())||[]).some(i=>i.actionType===C.EventActionTypes.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&ce(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,C.isSupportedManifest)(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){var e;return Cs((e=this.manifestController.chapter)==null?void 0:e.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(){var e,t,n,i,a;this.clearHistoryIfEnded(),this.removeControllers(),this.gameControllers=[],(e=this.graph)==null||e.destroy(),this.seamlessControllerSubs.unsubscribe(),(t=this.seamlessController)==null||t.removeAll(),(n=this.resizeManager)==null||n.release(),this.animation.release(),(i=this.interactiveEvents)==null||i.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),(a=this.lastFrame)==null||a.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var xo={Container:ye,createChoiceContainer:pt,createAreaControl:ot,createButtonControl:lt,getRootEl:rt,classnamesPrefix:L};var Hp={version:cn};
|
|
38
|
+
font-family: inherit;
|
|
39
|
+
|
|
40
|
+
--transition-1: 100ms ease-in-out;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
${zp}
|
|
44
|
+
|
|
45
|
+
.${V.common} {
|
|
46
|
+
display: flex;
|
|
47
|
+
width: 100%;
|
|
48
|
+
height: 100%;
|
|
49
|
+
font-family: inherit;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.${V.disabled} {
|
|
53
|
+
cursor: default;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.${V.button},
|
|
57
|
+
.${V.area} {
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
}
|
|
60
|
+
`,So=r=>{let e=document.createElement("style");e.textContent=Wp,r.prepend(e)};var wo=Object.freeze({lang:g.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function Kp(){let r=document.createElement("div");return r.classList.add("interactive-chapter"),r}var tt=class{constructor(e){this.playerSubscriptions=new g.Subscription;this.subscriptions=new g.Subscription;this.globalEventEmitter=new St;this.animation=new wt;this.seekToInteractiveController=new ze;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Kp();this.factories=new Map([["choice",ht]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new g.Subscription;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new g.ValueSubject(null),isInitialChapter$:new g.ValueSubject(!1),isFirstChapter$:new g.ValueSubject(!0),isEndChapter$:new g.ValueSubject(!1),isInteractiveExpectation$:new g.ValueSubject(!1),isReplay$:new g.ValueSubject(!1),calledByInteractive$:new g.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new g.ValueSubject(!1),disabledControls$:new g.ValueSubject(!1),interactiveRanges$:new g.ValueSubject([]),isInteractiveTime$:new g.ValueSubject(!1),statistics$:new g.ValueSubject(null),isSeekable$:new g.ValueSubject(!1)};this.events={noInteraction$:new g.Subject,graphVisibilityChanged$:new g.Subject,watchAgainIsClicked$:new g.Subject,chapterChanged$:new g.Subject,playerChanged$:new g.Subject,error$:new g.Subject,eachTick$:new g.Subject,manifestChanged$:new g.Subject,interactiveRangeEnded$:new g.Subject,interactiveContainerRemoved$:new g.Subject,interactiveActionExecution$:new g.Subject,interactiveActionChoice$:new g.Subject,interactiveVisibilityChanged$:new g.Subject};this.emitErrorEvent=e=>{this.events.error$.next(e),this.globalEventEmitter.emit(A.errors,e)};this.clearHistoryIfEnded=()=>{var i;let e=(i=this.player)==null?void 0:i.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&Q(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...n}=e;if(t){let{statSubscription:i,oneStat:s}=t;i.add(s.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(A.playerChanged,n)};this.onPlaybackStarted=()=>{var e;(e=this.resizeManager)==null||e.calc(),this.animation.requestAnimation()};this.removeControllers=(e=!0)=>{this.gameControllers.forEach(t=>{!e&&t.isPermanentText||(this.animation.removeFn(t.whilePlaying),t.destroy())})};this.completeInteractiveRange=e=>{let{interactiveRanges$:t}=this.state,i=t.getValue().map(s=>({...s,subjects:s.subjects.filter(o=>o!==e)}));t.next(i)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var n;this._options={...wo,...e,config:{...wo.config,...e.config}},this._options.parentElement.append(this.rootElement),this.historyController=new et({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:(n=this._options.projectInfo)==null?void 0:n.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:i=>{let s=new j(1,6,i);this.emitErrorEvent(s)}})),So(this._options.parentElement),this.subscriptions.add((0,g.fromEvent)(this.rootElement,"mousedown").subscribe(i=>i.stopPropagation())).add((0,g.fromEvent)(this.rootElement,"mouseup").subscribe(i=>i.stopPropagation())),this.manifestController=new pe(this._options.loaders,i=>{let s=new j(1,3,i);this.emitErrorEvent(s)});let t=[];this._options.lastFrame&&t.push(()=>{var i;(i=this.lastFrame)==null||i.updateCanvasDimensions(!0)}),this.resizeManager=co(()=>({player:this.player,parentElement:this._options.parentElement,fns:t})),this._options.graph&&(this.graph=new Ue({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(A.graph,{type:Ae.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>{let s=new j(1,4,{message:i});this.emitErrorEvent(s)}})),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.interactiveActionExecution$.subscribe(e=>{var t,n;if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:i}=e.payload;this.setChapter({chapterId:i}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(((n=e.payload)==null?void 0:n.behaviour)==="change-manifest"){let{manifestURL:i}=e.payload;i&&this.setManifest(i)}e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:n})=>{e!=="action-choice"||t==="chapter"||"invokeImmediately"in n&&n.invokeImmediately||this.removeControllers(!1)}))}async initSeamless(){this.seamlessController=Hr(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,i=this.getInteractiveRanges().reverse().find(({range:s})=>t>=s[1]);if(i){let s=i.range.join("-");this.endedRanges.has(s)||(this.endedRanges.add(s),this.globalEventEmitter.emit(A.interactives,{type:k.rangeEnded,payload:i,visibility:!0}),this.events.interactiveRangeEnded$.next({type:"range-ended",payload:i}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe((0,g.once)()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,g.combine)({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:n})=>{var a;let i;if(n)i=!0;else{let c=e*1e3;i=!!t.find(({range:[C,d],subjects:x})=>C<c&&c<d&&x.length)}i!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(i);let s=!!this.noInteractionTimeout,l=((a=this.player)==null?void 0:a.info.playbackState$.getValue())==="playing"||n;i&&!s&&l?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):s&&!l&&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=>{var t;(t=this.lastFrame)==null||t.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{var t;e&&((t=this.lastFrame)==null||t.setVideoElement(e))})).add(this.player.events.firstFrame$.subscribe(()=>{var e;(e=this.lastFrame)==null||e.reset(),setTimeout(()=>{var t,n;(t=this.lastFrame)==null||t.hide(),(n=this.lastFrame)==null||n.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){var t,n;let e=this.manifestController.chapter;e&&this.appState===1&&((t=this.selectBranches)==null||t.setManifestChapterEvents(e),this.gameControllers=this.filterGameControllers(e),(n=this.interactiveEvents)==null||n.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(i=>i.container.container).filter(i=>!ue(i.controls))),this._options.lastFrame&&this.animation.addFn(()=>{var i;this.player&&((i=this.lastFrame)==null||i.onEachTick(this.player.info.position$.getValue()*1e3))},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}filterGameControllers(e){let t=[];return e.containers.forEach(n=>{let i=n.type.trim().toLowerCase(),s=this.factories.get(i),o=s==null?void 0:s(n,this.rootElement);if(o&&this.selectBranches&&this.interactiveEvents&&this.player){let l=new jt({player:this.player,container:o,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,ignoreContainerEvent:()=>Rs(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)}});this.animation.addFn(l.whilePlaying,!0),t.push(l)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let t=this.state.isSeekable$.getValue(),n=!!this.seekToInteractiveController.getNextInteractiveTime();(n&&!t||!n&&t)&&this.state.isSeekable$.next(!t)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){var l,a;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),i=(l=n&&Q(n)&&Ye(n))!=null?l:!1,s=((a=this.manifestController.manifest)==null?void 0:a.metadata.initChapterId)===e,o=this.historyController.state.history$.getValue();if(s||i&&t){this.historyController.updateHistory([e]);return}(0,Ao.default)(o,-1)!==e&&this.historyController.updateHistory([...o,e])}reset(){var e;this.appState===2&&(this.removeControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(A.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=ao(this.player),this.selectBranches=go({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){var a,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&g.clientChecker.isSafari&&await To(35);let i=!n&&this.state.isEndChapter$.getValue()&&((a=this.getCurrentManifest())==null?void 0:a.metadata.initChapterId)===e;this.state.isReplay$.next(i);let{chapter:s,media:o,graph:l}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||i)&&this.state.isFirstChapter$.next(!0),!(!s||!o)&&(t&&this.pushChapterToHistory(s.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(s),(c=this.lastFrame)==null||c.setCurrentChapter(s),this.events.chapterChanged$.next({chapter:s,manifestVideo:o}),this.globalEventEmitter.emit(A.chapterChanged,{chapter:s,media:o,graph:l}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new g.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?Pe.InteractiveInterfaceClick.GRAPH_SHOW:Pe.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(Pe.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:i})=>{t!=="action-choice"||n!=="control"||(i==="Button"&&e.next(Pe.InteractiveInterfaceClick.NEXT_BUTTON),i==="Area"&&e.next(Pe.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new g.Observable(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}toggleGraphView(e=!0){this.graph&&(e?(this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(A.graph,{type:Ae.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var n;return!(((n=this.interactiveEvents)==null?void 0:n.getPreparedToExecActions())||[]).some(i=>i.actionType===v.EventActionTypes.setNextBranch)}allControlsAreRemoved(){return!this.gameControllers.some(t=>!t.container.isRemoved)}isEndedExpectation(){if(!this.player||!this.gameControllers)return!1;let e=this.player.info.position$.getValue(),t=this.player.info.duration$.getValue();return e===t&&this.gameControllers.some(n=>{let i=n.container.container;return!n.container.isRemoved&&i.endTime===null&&ce(i.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&(0,v.isSupportedManifest)(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){var e;return xa((e=this.manifestController.chapter)==null?void 0:e.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(){var e,t,n,i,s;this.clearHistoryIfEnded(),this.removeControllers(),this.gameControllers=[],(e=this.graph)==null||e.destroy(),this.seamlessControllerSubs.unsubscribe(),(t=this.seamlessController)==null||t.removeAll(),(n=this.resizeManager)==null||n.release(),this.animation.release(),(i=this.interactiveEvents)==null||i.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),(s=this.lastFrame)==null||s.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var Oo={Container:ve,createChoiceContainer:ht,createAreaControl:ct,createButtonControl:pt,classnamesPrefix:pn};var Qp={version:cn};
|