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