@vkontakte/videoplayer-interactive 1.0.19-dev.c3a364e7.0 → 1.0.19-dev.d432d6cd.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 +5 -5
- package/types/index.d.ts +3 -4
- package/types/manifest/index.d.ts +3 -0
- package/types/manifest/utils.d.ts +11 -0
- package/types/modules/Graph/Graph.d.ts +16 -12
- package/types/modules/Interactives/Interactives.d.ts +99 -83
- package/types/modules/Interactives/Layout.d.ts +11 -7
- package/types/modules/Interactives/controls/AreaControl.d.ts +2 -11
- package/types/modules/Interactives/controls/ButtonControl.d.ts +2 -11
- package/types/modules/Interactives/controls/Control.d.ts +20 -12
- package/types/modules/Interactives/controls/TextControl.d.ts +2 -11
- package/types/modules/Interactives/controls/index.d.ts +4 -3
- package/types/modules/Interactives/controls/types.d.ts +24 -0
- package/types/modules/Interactives/index.d.ts +4 -4
- package/types/modules/Interactives/types.d.ts +38 -7
- package/types/modules/Interactives/utils/GameController.d.ts +35 -16
- package/types/modules/Interactives/utils/GroupsStack.d.ts +31 -21
- package/types/modules/Interactives/utils/HistoryController.d.ts +8 -8
- package/types/modules/Interactives/utils/InteractiveEvents.d.ts +16 -10
- package/types/modules/Interactives/utils/ResizeManager.d.ts +8 -1
- package/types/modules/Interactives/utils/SelectBranches.d.ts +15 -51
- package/types/modules/Interactives/utils/SelectBranches.types.d.ts +73 -0
- package/types/modules/Interactives/utils/events.d.ts +8 -0
- package/types/modules/Interactives/utils/fallbackStrategies.d.ts +23 -6
- package/types/modules/Interactives/utils/gameUtils.d.ts +28 -26
- package/types/modules/Interactives/utils/getInteractiveRanges.d.ts +4 -4
- package/types/modules/Interactives/utils/renderingUtils.d.ts +64 -59
- package/types/modules/Loaders/vkVideoLoader/types.d.ts +2 -2
- package/types/modules/Loaders/vkVideoLoader/utils.d.ts +1 -1
- package/types/modules/ManifestController/Loadable.d.ts +4 -7
- package/types/modules/ManifestController/ManifestController.d.ts +11 -12
- package/types/modules/ManifestController/utils.d.ts +6 -6
- package/types/modules/SeamlessController/SeamlessController.d.ts +10 -12
- package/types/modules/SeamlessController/utils.d.ts +2 -2
- package/types/modules/SeekToInteractiveController/SeekToInteractiveController.d.ts +2 -2
- package/types/utils/EventManager.d.ts +3 -3
- package/types/utils/LastFrame.d.ts +1 -1
- package/types/utils/Raf.d.ts +1 -1
- package/types/utils/chapterHelpers.d.ts +1 -1
- package/types/utils/extractVkMovieId.d.ts +2 -2
- package/types/modules/Interactives/controls/constants.d.ts +0 -5
- package/types/movika.core/manifest/index.d.ts +0 -19
- package/types/movika.core/manifest/manifest_3_2/chapter.d.ts +0 -62
- package/types/movika.core/manifest/manifest_3_2/control.d.ts +0 -67
- package/types/movika.core/manifest/manifest_3_2/manifest.d.ts +0 -50
- package/types/movika.core/manifest/manifest_3_2/template.d.ts +0 -34
- package/types/movika.core/manifest/manifest_3_3/chapter.d.ts +0 -70
- package/types/movika.core/manifest/manifest_3_3/control.d.ts +0 -66
- package/types/movika.core/manifest/manifest_3_3/graph.d.ts +0 -73
- package/types/movika.core/manifest/manifest_3_3/manifest.d.ts +0 -52
- package/types/movika.core/manifest/manifest_3_3/template.d.ts +0 -34
- package/types/movika.core/manifest/migrations/index.d.ts +0 -1
- package/types/movika.core/manifest/migrations/migrateManifestToLatestVersion.d.ts +0 -1
- package/types/movika.core/manifest/migrations/migrate_from_3_0_to_3_1.d.ts +0 -21
- package/types/movika.core/manifest/migrations/migrate_from_3_1_to_3_2.d.ts +0 -2
- package/types/movika.core/manifest/migrations/migrate_from_3_2_to_3_3.d.ts +0 -8
- package/types/movika.core/manifest/types.d.ts +0 -29
- package/types/movika.core/manifest/utils.d.ts +0 -5
package/es2018.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.19-dev.
|
|
3
|
-
* Tue,
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.19-dev.d432d6cd.0
|
|
3
|
+
* Tue, 01 Oct 2024 14:51:14 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-19/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var $a=Object.create;var We=Object.defineProperty;var Ba=Object.getOwnPropertyDescriptor;var qa=Object.getOwnPropertyNames;var Da=Object.getPrototypeOf,Ha=Object.prototype.hasOwnProperty;var Ei=r=>{throw TypeError(r)};var Ga=(r,e,t)=>e in r?We(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var m=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ua=(r,e)=>{for(var t in e)We(r,t,{get:e[t],enumerable:!0})},Ci=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qa(e))!Ha.call(r,n)&&n!==t&&We(r,n,{get:()=>e[n],enumerable:!(i=Ba(e,n))||i.enumerable});return r};var Ii=(r,e,t)=>(t=r!=null?$a(Da(r)):{},Ci(e||!r||!r.__esModule?We(t,"default",{value:r,enumerable:!0}):t,r)),za=r=>Ci(We({},"__esModule",{value:!0}),r);var te=(r,e,t)=>Ga(r,typeof e!="symbol"?e+"":e,t),sr=(r,e,t)=>e.has(r)||Ei("Cannot "+t);var a=(r,e,t)=>(sr(r,e,"read from private field"),t?t.call(r):e.get(r)),S=(r,e,t)=>e.has(r)?Ei("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),b=(r,e,t,i)=>(sr(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),N=(r,e,t)=>(sr(r,e,"access private method"),t);var xi=(r,e,t,i)=>({set _(n){b(r,e,n,t)},get _(){return a(r,e,i)}});var ee=m((Rr,dn)=>{"use strict";var ot=function(r){return r&&r.Math===Math&&r};dn.exports=ot(typeof globalThis=="object"&&globalThis)||ot(typeof window=="object"&&window)||ot(typeof self=="object"&&self)||ot(typeof global=="object"&&global)||ot(typeof Rr=="object"&&Rr)||function(){return this}()||Function("return this")()});var pe=m((bp,fn)=>{"use strict";fn.exports=function(r){try{return!!r()}catch(e){return!0}}});var ct=m((Ep,mn)=>{"use strict";var go=pe();mn.exports=!go(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var En=m((Cp,bn)=>{"use strict";var bo=ct(),gn=Function.prototype,yn=gn.apply,vn=gn.call;bn.exports=typeof Reflect=="object"&&Reflect.apply||(bo?vn.bind(yn):function(){return vn.apply(yn,arguments)})});var we=m((Ip,xn)=>{"use strict";var Cn=ct(),In=Function.prototype,Vr=In.call,Eo=Cn&&In.bind.bind(Vr,Vr);xn.exports=Cn?Eo:function(r){return function(){return Vr.apply(r,arguments)}}});var Mr=m((xp,Sn)=>{"use strict";var Tn=we(),Co=Tn({}.toString),Io=Tn("".slice);Sn.exports=function(r){return Io(Co(r),8,-1)}});var Ar=m((Tp,wn)=>{"use strict";var xo=Mr(),To=we();wn.exports=function(r){if(xo(r)==="Function")return To(r)}});var de=m((Sp,_n)=>{"use strict";var Lr=typeof document=="object"&&document.all;_n.exports=typeof Lr=="undefined"&&Lr!==void 0?function(r){return typeof r=="function"||r===Lr}:function(r){return typeof r=="function"}});var $e=m((wp,Rn)=>{"use strict";var So=pe();Rn.exports=!So(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Ut=m((_p,Vn)=>{"use strict";var wo=ct(),Gt=Function.prototype.call;Vn.exports=wo?Gt.bind(Gt):function(){return Gt.apply(Gt,arguments)}});var On=m(Ln=>{"use strict";var Mn={}.propertyIsEnumerable,An=Object.getOwnPropertyDescriptor,_o=An&&!Mn.call({1:2},1);Ln.f=_o?function(e){var t=An(this,e);return!!t&&t.enumerable}:Mn});var Or=m((Vp,Nn)=>{"use strict";Nn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Pn=m((Mp,kn)=>{"use strict";var Ro=we(),Vo=pe(),Mo=Mr(),Nr=Object,Ao=Ro("".split);kn.exports=Vo(function(){return!Nr("z").propertyIsEnumerable(0)})?function(r){return Mo(r)==="String"?Ao(r,""):Nr(r)}:Nr});var kr=m((Ap,jn)=>{"use strict";jn.exports=function(r){return r==null}});var Pr=m((Lp,Fn)=>{"use strict";var Lo=kr(),Oo=TypeError;Fn.exports=function(r){if(Lo(r))throw new Oo("Can't call method on "+r);return r}});var Bn=m((Op,$n)=>{"use strict";var No=Pn(),ko=Pr();$n.exports=function(r){return No(ko(r))}});var lt=m((Np,qn)=>{"use strict";var Po=de();qn.exports=function(r){return typeof r=="object"?r!==null:Po(r)}});var jr=m((kp,Dn)=>{"use strict";Dn.exports={}});var Br=m((Pp,Gn)=>{"use strict";var Fr=jr(),$r=ee(),jo=de(),Hn=function(r){return jo(r)?r:void 0};Gn.exports=function(r,e){return arguments.length<2?Hn(Fr[r])||Hn($r[r]):Fr[r]&&Fr[r][e]||$r[r]&&$r[r][e]}});var zn=m((jp,Un)=>{"use strict";var Fo=we();Un.exports=Fo({}.isPrototypeOf)});var Yn=m((Fp,Qn)=>{"use strict";var $o=ee(),Wn=$o.navigator,Kn=Wn&&Wn.userAgent;Qn.exports=Kn?String(Kn):""});var is=m(($p,rs)=>{"use strict";var ts=ee(),qr=Yn(),Zn=ts.process,Xn=ts.Deno,Jn=Zn&&Zn.versions||Xn&&Xn.version,es=Jn&&Jn.v8,Z,zt;es&&(Z=es.split("."),zt=Z[0]>0&&Z[0]<4?1:+(Z[0]+Z[1]));!zt&&qr&&(Z=qr.match(/Edge\/(\d+)/),(!Z||Z[1]>=74)&&(Z=qr.match(/Chrome\/(\d+)/),Z&&(zt=+Z[1])));rs.exports=zt});var Dr=m((Bp,ss)=>{"use strict";var ns=is(),Bo=pe(),qo=ee(),Do=qo.String;ss.exports=!!Object.getOwnPropertySymbols&&!Bo(function(){var r=Symbol("symbol detection");return!Do(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&ns&&ns<41})});var Hr=m((qp,as)=>{"use strict";var Ho=Dr();as.exports=Ho&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Gr=m((Dp,os)=>{"use strict";var Go=Br(),Uo=de(),zo=zn(),Wo=Hr(),Ko=Object;os.exports=Wo?function(r){return typeof r=="symbol"}:function(r){var e=Go("Symbol");return Uo(e)&&zo(e.prototype,Ko(r))}});var ls=m((Hp,cs)=>{"use strict";var Qo=String;cs.exports=function(r){try{return Qo(r)}catch(e){return"Object"}}});var Ur=m((Gp,hs)=>{"use strict";var Yo=de(),Zo=ls(),Xo=TypeError;hs.exports=function(r){if(Yo(r))return r;throw new Xo(Zo(r)+" is not a function")}});var ps=m((Up,us)=>{"use strict";var Jo=Ur(),ec=kr();us.exports=function(r,e){var t=r[e];return ec(t)?void 0:Jo(t)}});var fs=m((zp,ds)=>{"use strict";var zr=Ut(),Wr=de(),Kr=lt(),tc=TypeError;ds.exports=function(r,e){var t,i;if(e==="string"&&Wr(t=r.toString)&&!Kr(i=zr(t,r))||Wr(t=r.valueOf)&&!Kr(i=zr(t,r))||e!=="string"&&Wr(t=r.toString)&&!Kr(i=zr(t,r)))return i;throw new tc("Can't convert object to primitive value")}});var ys=m((Wp,ms)=>{"use strict";ms.exports=!0});var bs=m((Kp,gs)=>{"use strict";var vs=ee(),rc=Object.defineProperty;gs.exports=function(r,e){try{rc(vs,r,{value:e,configurable:!0,writable:!0})}catch(t){vs[r]=e}return e}});var Qr=m((Qp,Is)=>{"use strict";var ic=ys(),nc=ee(),sc=bs(),Es="__core-js_shared__",Cs=Is.exports=nc[Es]||sc(Es,{});(Cs.versions||(Cs.versions=[])).push({version:"3.38.0",mode:ic?"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 Ss=m((Yp,Ts)=>{"use strict";var xs=Qr();Ts.exports=function(r,e){return xs[r]||(xs[r]=e||{})}});var Yr=m((Zp,ws)=>{"use strict";var ac=Pr(),oc=Object;ws.exports=function(r){return oc(ac(r))}});var Wt=m((Xp,_s)=>{"use strict";var cc=we(),lc=Yr(),hc=cc({}.hasOwnProperty);_s.exports=Object.hasOwn||function(e,t){return hc(lc(e),t)}});var Vs=m((Jp,Rs)=>{"use strict";var uc=we(),pc=0,dc=Math.random(),fc=uc(1 .toString);Rs.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+fc(++pc+dc,36)}});var Ls=m((ed,As)=>{"use strict";var mc=ee(),yc=Ss(),Ms=Wt(),vc=Vs(),gc=Dr(),bc=Hr(),Be=mc.Symbol,Zr=yc("wks"),Ec=bc?Be.for||Be:Be&&Be.withoutSetter||vc;As.exports=function(r){return Ms(Zr,r)||(Zr[r]=gc&&Ms(Be,r)?Be[r]:Ec("Symbol."+r)),Zr[r]}});var Ps=m((td,ks)=>{"use strict";var Cc=Ut(),Os=lt(),Ns=Gr(),Ic=ps(),xc=fs(),Tc=Ls(),Sc=TypeError,wc=Tc("toPrimitive");ks.exports=function(r,e){if(!Os(r)||Ns(r))return r;var t=Ic(r,wc),i;if(t){if(e===void 0&&(e="default"),i=Cc(t,r,e),!Os(i)||Ns(i))return i;throw new Sc("Can't convert object to primitive value")}return e===void 0&&(e="number"),xc(r,e)}});var Xr=m((rd,js)=>{"use strict";var _c=Ps(),Rc=Gr();js.exports=function(r){var e=_c(r,"string");return Rc(e)?e:e+""}});var Bs=m((id,$s)=>{"use strict";var Vc=ee(),Fs=lt(),Jr=Vc.document,Mc=Fs(Jr)&&Fs(Jr.createElement);$s.exports=function(r){return Mc?Jr.createElement(r):{}}});var ei=m((nd,qs)=>{"use strict";var Ac=$e(),Lc=pe(),Oc=Bs();qs.exports=!Ac&&!Lc(function(){return Object.defineProperty(Oc("div"),"a",{get:function(){return 7}}).a!==7})});var Gs=m(Hs=>{"use strict";var Nc=$e(),kc=Ut(),Pc=On(),jc=Or(),Fc=Bn(),$c=Xr(),Bc=Wt(),qc=ei(),Ds=Object.getOwnPropertyDescriptor;Hs.f=Nc?Ds:function(e,t){if(e=Fc(e),t=$c(t),qc)try{return Ds(e,t)}catch(i){}if(Bc(e,t))return jc(!kc(Pc.f,e,t),e[t])}});var zs=m((ad,Us)=>{"use strict";var Dc=pe(),Hc=de(),Gc=/#|\.prototype\./,ht=function(r,e){var t=zc[Uc(r)];return t===Kc?!0:t===Wc?!1:Hc(e)?Dc(e):!!e},Uc=ht.normalize=function(r){return String(r).replace(Gc,".").toLowerCase()},zc=ht.data={},Wc=ht.NATIVE="N",Kc=ht.POLYFILL="P";Us.exports=ht});var Qs=m((od,Ks)=>{"use strict";var Ws=Ar(),Qc=Ur(),Yc=ct(),Zc=Ws(Ws.bind);Ks.exports=function(r,e){return Qc(r),e===void 0?r:Yc?Zc(r,e):function(){return r.apply(e,arguments)}}});var Zs=m((cd,Ys)=>{"use strict";var Xc=$e(),Jc=pe();Ys.exports=Xc&&Jc(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Js=m((ld,Xs)=>{"use strict";var el=lt(),tl=String,rl=TypeError;Xs.exports=function(r){if(el(r))return r;throw new rl(tl(r)+" is not an object")}});var ra=m(ta=>{"use strict";var il=$e(),nl=ei(),sl=Zs(),Kt=Js(),ea=Xr(),al=TypeError,ti=Object.defineProperty,ol=Object.getOwnPropertyDescriptor,ri="enumerable",ii="configurable",ni="writable";ta.f=il?sl?function(e,t,i){if(Kt(e),t=ea(t),Kt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&ni in i&&!i[ni]){var n=ol(e,t);n&&n[ni]&&(e[t]=i.value,i={configurable:ii in i?i[ii]:n[ii],enumerable:ri in i?i[ri]:n[ri],writable:!1})}return ti(e,t,i)}:ti:function(e,t,i){if(Kt(e),t=ea(t),Kt(i),nl)try{return ti(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new al("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var na=m((ud,ia)=>{"use strict";var cl=$e(),ll=ra(),hl=Or();ia.exports=cl?function(r,e,t){return ll.f(r,e,hl(1,t))}:function(r,e,t){return r[e]=t,r}});var oa=m((pd,aa)=>{"use strict";var ut=ee(),ul=En(),pl=Ar(),dl=de(),fl=Gs().f,ml=zs(),qe=jr(),yl=Qs(),De=na(),sa=Wt();Qr();var vl=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 ul(r,this,arguments)};return e.prototype=r.prototype,e};aa.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,s=r.proto,l=i?ut:n?ut[t]:ut[t]&&ut[t].prototype,c=i?qe:qe[t]||De(qe,t,{})[t],o=c.prototype,h,d,f,y,I,w,x,C,p;for(y in e)h=ml(i?y:t+(n?".":"#")+y,r.forced),d=!h&&l&&sa(l,y),w=c[y],d&&(r.dontCallGetSet?(p=fl(l,y),x=p&&p.value):x=l[y]),I=d&&x?x:e[y],!(!h&&!s&&typeof w==typeof I)&&(r.bind&&d?C=yl(I,ut):r.wrap&&d?C=vl(I):s&&dl(I)?C=pl(I):C=I,(r.sham||I&&I.sham||w&&w.sham)&&De(C,"sham",!0),De(c,y,C),s&&(f=t+"Prototype",sa(qe,f)||De(qe,f,{}),De(qe[f],y,I),r.real&&o&&(h||!o[y])&&De(o,y,I)))}});var la=m((dd,ca)=>{"use strict";var gl=Math.ceil,bl=Math.floor;ca.exports=Math.trunc||function(e){var t=+e;return(t>0?bl:gl)(t)}});var si=m((fd,ha)=>{"use strict";var El=la();ha.exports=function(r){var e=+r;return e!==e||e===0?0:El(e)}});var pa=m((md,ua)=>{"use strict";var Cl=si(),Il=Math.min;ua.exports=function(r){var e=Cl(r);return e>0?Il(e,9007199254740991):0}});var fa=m((yd,da)=>{"use strict";var xl=pa();da.exports=function(r){return xl(r.length)}});var ya=m((vd,ma)=>{"use strict";ma.exports=function(){}});var va=m(()=>{"use strict";var Tl=oa(),Sl=Yr(),wl=fa(),_l=si(),Rl=ya();Tl({target:"Array",proto:!0},{at:function(e){var t=Sl(this),i=wl(t),n=_l(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:t[s]}});Rl("at")});var ba=m((Ed,ga)=>{"use strict";var Vl=Br();ga.exports=Vl});var Ca=m((Cd,Ea)=>{"use strict";va();var Ml=ba();Ea.exports=Ml("Array","at")});var xa=m((Id,Ia)=>{"use strict";var Al=Ca();Ia.exports=Al});var Sa=m((xd,Ta)=>{"use strict";var Ll=xa();Ta.exports=Ll});var kl={};Ua(kl,{CustomError:()=>G,EVENT_NAMES:()=>E,Interactives:()=>ft,ManifestController:()=>Se,SDKInfo:()=>Nl,chapterIdsToVKVideoIds:()=>Qt,compareVersions:()=>re,getChapterIdByVkVideoId:()=>Ra,getVKVideoIdByMedia:()=>ai,getVideoRawIdByMedia:()=>wa,graphEventTypes:()=>Fe,hasEndTemplate:()=>it,interactivesEventTypes:()=>R,isLastChapter:()=>Y,isSupportedManifest:()=>Je,isVKVariantItem:()=>_a,utils:()=>ja,vkVideoIdsToChapterIds:()=>oi});module.exports=za(kl);var Ti="1.0.19-dev.c3a364e7.0";function ar(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 B="SDK_NAME",Wa="SDK_NAME-controls-container",gt=()=>document.querySelector(`.${Wa}`),Ri=.4,z={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},Si={top:"flex-start",bottom:"flex-end",center:"center"},wi={start:"flex-start",end:"flex-end",center:"center"},_i={start:"left",end:"right",center:"center"},bt=({target:r,props:e})=>{var t,i,n,s,l,c;r.style.alignItems=(i=Si[(t=e==null?void 0:e.text)==null?void 0:t.gravityVertical])!=null?i:Si.center,r.style.justifyContent=(s=wi[(n=e==null?void 0:e.text)==null?void 0:n.gravityHorizontal])!=null?s:wi.center,r.style.textAlign=(c=_i[(l=e==null?void 0:e.text)==null?void 0:l.alignment])!=null?c:_i.start},Et=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,c,o,h;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=(l=e==null?void 0:e.text)==null?void 0:l.size)!=null?c:t.textSize})`,r.textContent=(h=(o=e==null?void 0:e.text)==null?void 0:o.value)!=null?h:t.textContent},Ct=({target:r,props:e,fallback:t})=>{var i,n,s,l;r.style.backgroundColor=ar((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(l=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?l:t.backgroundAlpha)},It=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,c,o,h,d,f,y,I,w;r.style.border=`calc(${i.height} * ${(l=(s=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:s.width)!=null?l:t.borderWidth}) solid ${ar((h=(o=(c=e==null?void 0:e.shape)==null?void 0:c.border)==null?void 0:o.color)!=null?h:t.borderColor,(y=(f=(d=e==null?void 0:e.shape)==null?void 0:d.border)==null?void 0:f.alpha)!=null?y:t.borderAlpha)}`,r.style.borderRadius=`calc(${i.height} * ${(w=(I=e==null?void 0:e.shape)==null?void 0:I.roundCorners)!=null?w:t.roundCorners})`},Oe=({target:r,layoutParams:e,fallback:t})=>{r.style.transform=`rotate(${-e.angle}rad)`};var or="int",Ne={AREA:`${or}_area`,TEXT:`${or}_text`,BUTTON:`${or}_bttn`};var he=class{constructor(e){this.control=e}createView(e){var n;let t=document.createElement("div");t.classList.add(`${B}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:z.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:t,dependsOn:i}}setEvents(e,t){e&&this.control.events.forEach(i=>{switch(i.type.trim().toLowerCase()){case"onclick":e.addEventListener("click",s=>{s.stopPropagation(),t&&t({action:i.action,controlId:this.control.id,controlType:this.control.type})});break;default:break}})}getElement(){return document.querySelector(`.${B}-control-container-${this.control.id}`)}};var xt=r=>{if(r.type.trim().toLowerCase()==="area")return new cr(r)},cr=class extends he{constructor(e){super(e)}createView({parent:e,layoutFn:t}){let{dependsOn:i,controlContainerEl:n}=super.createView(t),s=document.createElement("button");return s.classList.add(`${B}-${this.control.id}`),s.setAttribute("data-testid",Ne.AREA),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.type="button",Ct({target:s,props:this.control.props,fallback:{...z,backgroundColor:"transparent"}}),It({target:s,props:this.control.props,fallback:{...z,borderAlpha:0},dependsOn:i}),Oe({target:s,layoutParams:this.control.layoutParams,fallback:z}),n.append(s),e.append(n),this.controlEl=s,n}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${B}-${this.control.id}`)}};var Tt=()=>{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 St=r=>{if(r.type.trim().toLowerCase()==="button")return new lr(r)},lr=class extends he{constructor(e){super(e)}createView({parent:e,layoutFn:t}){let{dependsOn:i,controlContainerEl:n}=super.createView(t),s=document.createElement("button");s.type="button",s.classList.add(`${B}-${this.control.id}`),s.setAttribute("data-testid",Ne.BUTTON),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.style.fontFamily="inherit";let l=Tt();return Oe({target:s,layoutParams:this.control.layoutParams,fallback:z}),Ct({target:s,props:this.control.props,fallback:z}),It({target:s,props:this.control.props,fallback:z,dependsOn:i}),bt({target:s,props:this.control.props}),Et({target:l,props:this.control.props,fallback:z,dependsOn:i}),s.append(l),n.append(s),e.append(n),this.controlEl=s,n}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${B}-${this.control.id}`)}};var Vi=r=>{if(r.type.trim().toLowerCase()==="text")return new hr(r)},hr=class extends he{constructor(e){super(e)}createView({parent:e,layoutFn:t}){let{dependsOn:i,controlContainerEl:n}=super.createView(t),s=document.createElement("div");s.classList.add(`${B}-${this.control.id}`),s.setAttribute("data-testid",Ne.TEXT),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.fontFamily="inherit";let l=Tt();return Oe({target:s,layoutParams:this.control.layoutParams,fallback:z}),bt({target:s,props:this.control.props}),Et({target:l,props:this.control.props,fallback:z,dependsOn:i}),s.append(l),n.append(s),e.append(n),this.controlEl=s,n}disable(){}enable(){}getElement(){return document.querySelector(`.${B}-${this.control.id}`)}};var ur=class{constructor(e){this.layout=e}},Mi=r=>{if(r.type.trim().toLowerCase()==="relative")return new Ke(r)},Ke=class extends ur{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 ue,wt,Ai,ke=class{constructor(e){S(this,ue);this.container=e,this.factories=new Map,N(this,ue,wt).call(this)}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),N(this,ue,wt).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),N(this,ue,wt).call(this)}};ue=new WeakSet,wt=function(){this.controls=N(this,ue,Ai).call(this)},Ai=function(){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);return s?[...t,s(i)]:[...t]},[])};var _t=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new pr(r,e)},pr=class extends ke{constructor(e,t){super(e),this.rootElement=t!=null?t:gt(),this.layout=new Ke(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",St),this.addControlFactory("text",Vi),this.addControlFactory("area",xt)}createView(e){let t=document.createElement("div");return t.classList.add(`${B}-${this.container.id}`),this.layout.setContainerLayout(t),this.controls.forEach(i=>{let n=i.createView({parent:t,layoutFn:this.layout.setControlLayout});i.setEvents(n,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=Ri,this.isDisabled=!0)}removeView(){var e;this.isRemoved||((e=this.getElement())==null||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${B}-${this.container.id}`)}};var L=require("@vkontakte/videoplayer-shared"),Ue=require("@vkontakte/videoplayer-statistics");var ki=require("@vkontakte/videoplayer-shared");function Rt(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var Ie=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Qe=r=>Ie(r,"Object"),Vt=r=>Ie(r,"String"),Mt=r=>Ie(r,"Array"),At=r=>Ie(r,"Number"),Li=r=>Ie(r,"Function");var dr=r=>At(r)&&!isNaN(r);var xe=r=>Qe(r)&&Object.keys(r).length===0,fr=r=>Mt(r)&&!r.length;var Ye=(r,e)=>Vt(r)&&(e?r.trim():r).length;var Oi="video_interactive",Ni="videoint";var Ka=250,Ze=class{constructor(e){this.onResize=e=>{var t;this.isReady&&(!e[0].contentRect.width||!e[0].contentRect.height||(this.lastZoomInfo&&((t=this.ngEditor)==null||t.zoomTo(this.getNextPoint())),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}))};this.handleChapterChange=e=>{var t,i,n;if(this.isReady){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=async(e,t=[])=>{var i;if(!At(e.graph.edit.chapters[0].x)){this.isReady=!1,(i=this.onError)==null||i.call(this,"Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=null,!this.ngEditor){let n;try{n=await(0,ki.loadVKLangPack)(this.lang,Oi,Ni)}catch(l){console.log("Unable to load graph language pack")}let{GraphEditor:s}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new s(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:n}),this.ngEditor.on("control",({name:l,...c})=>{var o;l==="openPreview"&&"chapterId"in c&&((o=this.onOpenPreviewClick)==null||o.call(this,c.chapterId))}),this.ngEditor.on("zoom",l=>{this.lastZoomInfo={...l}})}this.visitedChapterIds=new Set(t),e.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=e.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:i,lang:n,visitedChapters:s=[]}){this.isReady=!1,this.isHidden=!0,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=Qa(e),this.resizeObserver=new ResizeObserver(Rt(this.onResize,Ka)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?[0,0]:[(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(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),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 Qa(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 l=s.startTime-e;if(l<=n&&(s.endTime&&n<=s.endTime||s.endTime===null)){i=!0;break}n<l&&(t=t===-1?l:Math.min(t,l))}return!i&&t!==-1?t:null}}};var re=(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 ji=require("uuid"),Ya="3.1",Pi={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},Za={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Fi=r=>{let e=[];for(let t of r.chapters){let i,n=[];for(let{isDefault:c,...o}of t.branches)c&&(i=o.id),n.push(o);let s=[],l=[];for(let{fallbackStrategy:c,...o}of t.containers){let h=!!o.endTime,d=[Za];switch(c){case"await":h?d=[]:s=[];break;case"default":{let f={type:"onSuspense",action:{type:Pi.default,args:{branchId:i,shouldOpenNow:!h,isDetachContainer:!0}}};h?d=[f]:s=[f];break}case"random":case"weightlessRandom":case"max":case"min":{let f={type:"onSuspense",action:{type:Pi[c],args:{}}};h?d=[f]:s=[f];break}}for(let f of o.controls)l.push({...o,controls:[{...f}],id:(0,ji.v4)(),events:d})}e.push({...t,containers:l,events:s,branches:n})}return r.metadata.version=Ya,r.metadata.updated=new Date().toISOString(),{...r,chapters:e}};var Xa="3.2",$i=r=>{if(!r.media){let{media:e,...t}=r.metadata;return{...r,metadata:{...t,version:Xa},media:e}}return r};var Ja="3.3",eo=(r=[])=>({edit:{chapters:r},view:{}}),Bi={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},qi=r=>{var i;let e=[],t=[];for(let n of r.chapters){let{id:s,x:l,y:c,...o}=n,h=o.containers.map(d=>{var f;return{...d,controls:d.controls.map(({subtype:y,type:I,...w})=>({...w,type:y!=null?y:I})),events:(f=d.events)!=null&&f.length?d.events:[Bi]}});e.push({id:s,...o,containers:h,events:(i=o.events)!=null&&i.length?o.events:[Bi]}),t.push({id:s,x:l,y:c})}return{...r,chapters:e,graph:eo(t),metadata:{...r.metadata,version:Ja}}};var to=[{version:"3.0",migrate:Fi},{version:"3.1",migrate:$i},{version:"3.2",migrate:qi}],mr=r=>to.reduce((e,t)=>re(e.metadata.version,t.version)?e:t.migrate(e),r);var Uh=Object.freeze({Choice:"Choice",TextInput:"TextInput"}),Di=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),zh=Object.freeze({onClick:"onClick",onSuspense:"onSuspense"}),A=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"});var Hi={metadata:"Object",chapters:"Array"},ro="3.0.0",io="3.3.0",Je=r=>{let e=re(r,ro);return e===-1?!1:e===0?!0:re(r,io)!==1},Gi=r=>{if(!Qe(r))return!1;for(let e in Hi)if(!r[e]||!Ie(r[e],Hi[e]))return!1;return Je(r.metadata.version)},Lt=r=>r.type===Di.Text;var G=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var Pe=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)=>{Li(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)};this.fn=e,this.addFn(e)}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var Yi=require("@vkontakte/videoplayer-shared");var Nt=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:[]}}async exec(e,t){return no(...this.loaders[e])(t)}};function no(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function et(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function kt({actions:r,errors:e,chapterId:t,...i}){if(t){let n=r.getManifest(),s=r.getChapter(n.chapters,t);if(s){let l=r.getMedia(n.media,s.videoId),c=r.getGraph(n.graph,s.id);return l?{...i,actions:r,errors:e,result:{chapter:s,media:l,graph:c}}:{...i,errors:et(e,kt.name,"Could not find media"),actions:r}}}return{...i,errors:et(e,kt.name,"Could not find chapter"),actions:r}}var Pt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let n=0,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 l=i[n];try{l.callback.call(this,e)}catch(c){Promise.resolve().then(()=>{throw c})}l.options&&l.options.once&&this.removeEventListener(e.type,l.callback)}return!e.defaultPrevented}},je=class extends Pt{constructor(){super(),this.listeners||Pt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},tt=class{constructor(){Object.defineProperty(this,"signal",{value:new je,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&&(tt.prototype[Symbol.toStringTag]="AbortController",je.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 yr(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:s};let s=t;(s&&!s.prototype.hasOwnProperty("signal")||n)&&(s=function(h,d){let f;d&&d.signal&&(f=d.signal,delete d.signal);let y=new t(h,d);return f&&Object.defineProperty(y,"signal",{writable:!1,enumerable:!1,configurable:!0,value:f}),y},s.prototype=t.prototype);let l=e;return{fetch:(o,h)=>{let d=s&&s.prototype.isPrototypeOf(o)?o.signal:h?h.signal:void 0;if(d){let f;try{f=new DOMException("Aborted","AbortError")}catch(I){f=new Error("Aborted"),f.name="AbortError"}if(d.aborted)return Promise.reject(f);let y=new Promise((I,w)=>{d.addEventListener("abort",()=>w(f),{once:!0})});return h&&h.signal&&delete h.signal,Promise.race([y,l(o,h)])}return l(o,h)},Request:s}}var rt=jt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ui=rt?yr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,vr=rt?Ui.fetch:window.fetch,gu=rt?Ui.Request:window.Request,bu=rt?tt:window.AbortController,Eu=rt?je:window.AbortSignal;var so=async r=>{try{let e={},t;if(Vt(r)){t=new URL(r).href;let n=await vr(t);if(!n.ok)return{};e=await n.json()}else if(Qe(r))e=r;else return{};if(!Gi(e))return{};let i=e.metadata.media;if(Vt(i)&&!e.media)try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let s=await vr(n);if(!s.ok)throw new Error;e.metadata.media=await s.json()}catch(n){return co(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function zi(r){let{manifest:e,manifestURL:t}=await so(r),i=mr(e);return i.media=ao(i.media,t),delete i.metadata.media,i}function Ft(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 br(r,e){return r.videos.find(t=>t.id===e)}function ao(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",s=oo(n,e);return{...i,url:s||n}})}))}}function oo(r="",e){try{return new URL(r,e).href}catch(t){return""}}function co(r){return re(r,"3.2.0")>=0}var k=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),$t=r=>Mt(r)&&!fr(r),Y=r=>r.order==="end",it=r=>Mt(r.containers)&&!fr(r.containers)&&Y(r),Wi=(r,e)=>{var i;let t=r*1e3;return $t(e.controls)&&t<((i=e.startTime)!=null?i:0)},Er=(r,e)=>{var i,n;let t=r*1e3;return $t(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var Te=r=>r.some(e=>e.action.type==="expect"),Cr=r=>r.find(e=>e.action.type==="expect"),lo=r=>(r==null?void 0:r.length)===1,Bt=r=>lo(r)&&Lt(r[0]);var Ki=({fn:r,type:e=1},...t)=>(...i)=>e?r(...i,...t):r({...i[e],...t[e]}),Qi=(r,e)=>Te(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&Te(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var Se=class extends Nt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Yi.ValueSubject(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){var n;this.release();let i=await this.exec("manifestLoaders",{actions:{addErrorMessage:et},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await zi((n=i.result)!=null?n:t),this}async setInitial(){return this.setNext()}async setNext(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",kt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:gr,getChapter:Ft,getMedia:br,getByBranches:this.getByBranches.bind(this),addErrorMessage:et},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=Ft(this.manifest.chapters,t);if(n){let s=br(this.manifest.media,n.videoId),l=gr(this.manifest.graph,n.id);if(s)return{chapter:n,media:s,graph:l}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,s,l;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((s=this.chapter)==null?void 0:s.branches);{let c=Ft(((l=this.manifest)==null?void 0:l.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 Y(this.chapter)}};var Xi=require("@vkontakte/videoplayer-core"),st=require("@vkontakte/videoplayer-shared");var Zi=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&"payload"in e){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var E={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Fe={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},R={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function Ir(){let r=new Map;function e({listId:s=Math.random().toString(),itemId:l=Math.random().toString(),...c}){let o=r.get(s),h={...c};return o?o[l]=h:r.set(s,{[l]:h}),{listId:s,itemId:l,...c}}function t(s){var l,c;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(l=s.statistics)==null||l.oneStat.destroy(),(c=s.statistics)==null||c.statSubscription.unsubscribe()}function i(s,l){let c=r.get(s);if(!c)throw Error("Can't remove. Not find.");if(l){let o=c[l];o&&t(o),delete c[l],Object.keys(c).length||r.delete(s)}else{for(let o of Object.values(c))t(o);r.delete(s)}}function n(){for(let s of r)i(s[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}function xr(r,e=[]){var s,l,c;let t={},i,n=!e.length;for(let o of r.variants)if(!i&&"cover"in o&&(i=o.cover),"url"in o)switch(o.type.toLowerCase()){case"mp4":(n||e.includes("mp4"))&&(t.MPEG={...t.MPEG,[(s=o.standard)!=null?s:"Invariant quality"]:o.url});break;case"mpeg":(n||e.includes("mpeg"))&&(t.MPEG={...t.MPEG,[(l=o.standard)!=null?l:"Invariant quality"]:o.url});break;case"hls":(n||e.includes("hls"))&&(t={...t,HLS:{type:"url",url:o.url}});break;case"dash":(n||e.includes("dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:o.url}});break;default:break}return{sources:t,thumbUrl:i,title:(c=r.title)!=null?c:""}}var nt=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&i.includes(e)&&(r.setQuality(e),r.setAutoQuality(!1))};var qt={activePlayerChanged:"sc-active-player-changed",playerCreated:"sc-player-created"},ho=2;function Tr(r){let e=Ir(),t=new Pe,i={},n=null,s=!1,l;r&&c(r);function c(x){n=x}function o(x,C,p){var T;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let g=((T=e.map.get(x))!=null?T:{})[C];if(g){i={chapterId:p,listId:x,itemId:C,...g};let v=i.player;i.subscription.add(v.info.currentQuality$.subscribe(P=>{let j=v.info.position$.getValue(),F=v.info.isAutoQualityEnabled$.getValue();if(!(!P||!j||F))for(let _ of e.map)Object.values(_[1]).forEach(({player:H})=>{nt(H,P)})})).add(v.events.started$.subscribe(()=>{h(C)})),g.container.remove(),n.setPlayer(g.player),s||(n.init(),s=!0),t.emit(qt.activePlayerChanged,{player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}async function h(x){if(!n)throw Error("need to set interactive controller");if(xe(i)||x!==i.itemId)return;let C=n.getChapterBranches(),p=new Set;for(let u of C)p.has(u.media.id)||(await f({media:u.media,chapterId:u.chapter.id,setAsActive:!1,title:u.chapter.label}),p.add(u.media.id))}async function d({chapter:{id:x},media:C}){if(xe(i))return;let p=i.player.info.muted$.getValue(),u=i.player.info.currentQuality$.getValue(),g=i.player.info.isAutoQualityEnabled$.getValue(),T=i.player.info.volume$.getValue(),v=i.player.info.currentPlaybackRate$.getValue(),P=!g,j=!1;for(let F of e.map)if(F[0]===C.id){let _=Object.keys(F[1]);for(let H of _)H===i.itemId?(_.length<ho||(j=!0),e.removePlayer(F[0],H)):(j=!0,o(F[0],H,x),P?nt(i.player,u):i.player.setAutoQuality(!0),i.player.setVolume(T),i.player.setMuted(p),i.player.setPlaybackRate(v))}else e.removePlayer(F[0]);j||(await f({media:C,chapterId:x,setAsActive:!0,playbackRate:v}),P?nt(i.player,u):i.player.setAutoQuality(!0),i.player.setVolume(T),i.player.setMuted(p))}async function f({media:x,chapterId:C,prefetch:p=!0,setAsActive:u=!0,autoplay:g=!1,preferredExt:T,title:v,playbackRate:P}){var di,fi,mi,yi,vi;let j=Math.random().toString(),F=document.createElement("div");l.append(F);let _;if((di=n==null?void 0:n.options)!=null&&di.vkVideoLoader){let vt=Zi(x);vt.length&&(_=await n.options.vkVideoLoader(...vt))}let H=((fi=n==null?void 0:n.options)==null?void 0:fi.coreConfig)||{},Le={...H,configName:[...(mi=H.configName)!=null?mi:[],"interactive"]},Ee={container:F,...((yi=_==null?void 0:_.videos)==null?void 0:yi[0])||{sources:xr(x,T).sources},title:v,failoverHosts:(_==null?void 0:_.failoverHosts)||[]},J=new Xi.Player(Le,st.Tracer.createRootTracer());J.initVideo(Ee);let yt=null;if(n!=null&&n.options.createOneStat){let vt=_.videos[0],gi=n.options.createOneStat(vt),bi=new st.Subscription;bi.add(gi.attachTo(J)),yt={oneStat:gi,statSubscription:bi}}let pi=new st.Subscription,Fa=(vi=i==null?void 0:i.player)==null?void 0:vi.info.isAutoQualityEnabled$.getValue();pi.add(J.events.canplay$.subscribe(function(){Fa||nt(J,i.player.info.currentQuality$.getValue()),P&&J.setPlaybackRate(P)}));let Ce=e.createPlayer({listId:x.id,itemId:j,player:J,container:F,sources:xr(x,T).sources,config:Ee,subscription:pi,statistics:yt});return u&&o(x.id,Ce.itemId,C),g&&Ce.player.play(),p&&!g&&Ce.player.prepare(),t.emit(qt.playerCreated,Ce.player),{player:Ce.player,config:Ce.config,statistics:Ce.statistics}}function y(){I(),n=null,l.remove()}function I(){n==null||n.off(E.chapterChanged,d),e.removeAll(),i={},s=!1}async function w(){if(!n)throw Error("need to set interactive controller");I(),l=document.createElement("div");let{media:x,chapter:C}=n.getCurrentChapter();x?(n.on(E.chapterChanged,d),await f({media:x,chapterId:C.id,title:C.label})):console.error("not found")}return{...e,on:t.on.bind(t),off:t.off.bind(t),init:w,setInteractiveController:c,createPlayer:f,removeAll:y,getActivePlayer:function(){return i}}}var Ji=require("@vkontakte/videoplayer-shared");var Dt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:s,globalEventEmitter:l,ignoreContainerEvent:c,permanentTextControls:o,disabledControls$:h,onRemove:d}){te(this,"hide",()=>{setTimeout(()=>{var e,t;this.gameState!==k.end&&(Te(this.container.container.events)&&this.gameState===k.afterInteractive||this.selectBranches.state.isExpect||(this.gameState!==k.interactive&&((t=(e=this.container).hide)==null||t.call(e)),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:R.visibility,visibility:!1})))})});te(this,"show",()=>{var e,t,i,n;if(this.gameState===k.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())(n=(i=this.container).show)==null||n.call(i),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:R.visibility,visibility:!0,isFirst:!1});else{let l=Ki({fn:this.selectBranches.onControlEvent,type:0},{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:R.visibility,visibility:!1})},onEvent:(c,o)=>{this.isSelectedControlEvent=!0,c!==!1&&(this.removeView(),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:R.visibility,visibility:!1})),(this.gameState===k.end||this.gameState===k.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),o(),this.removeView(),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:R.visibility,visibility:!1}))},isEOV:()=>this.gameState===k.end});this.container.createView(l),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:R.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((t=(e=this.container).disable)==null||t.call(e))}});te(this,"onEndOfVideo",()=>{this.gameState=k.end,this.selectContainerEvent(!0)});te(this,"whilePlaying",()=>{var s,l;if(((s=this.player.experimental.element$.getValue())==null?void 0:s.readyState)<1||[k.destroyed,k.removed].includes(this.gameState)&&!this.isPermanentText)return;let t=this.player.getExactTime();if(Wi(t,this.container.container))this.gameState!==k.beforeInteractive&&(this.gameState=k.beforeInteractive,this.onBeforeStartTime());else if(Er(t,this.container.container))this.gameState!==k.interactive&&(this.gameState=k.interactive,this.onStartTime());else if(this.gameState!==k.afterInteractive){let c=this.gameState;this.gameState=k.afterInteractive,c===k.interactive&&this.onEndTime()}else this.gameState!==k.destroyed&&!this.isPermanentText&&this.removeView();let i=Er(t,this.container.container),n=this.container.container.startTime?[this.container.container.startTime,(l=this.container.container.endTime)!=null?l:1/0]:[];this.globalEventEmitter.emit(E.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:n,currentTime:t,isInteractiveTime:i})});this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Ji.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=c,this.isPermanentText=o&&Bt(t.container.controls),this.disabledControls$=h,this.onRemove=d,this.globalEventEmitter=l,this.gameState=k.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}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){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,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(this.container.container.endTime))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=Te(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.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:R.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=k.beforeInteractive}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(E.interactives,{subjectId:this.container.container.id,subjectName:"container",type:R.containerRemoved,visibility:!1}),this.gameState=k.removed,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=k.destroyed,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 en=(r=[])=>r.reduce((e,t,i)=>{var s,l,c;let n=((s=t==null?void 0:t.controls)!=null?s:[]).filter(o=>!Lt(o));if($t(n)){let o=[(l=t.startTime)!=null?l:0,(c=t.endTime)!=null?c:1/0],h=t.id;if(!i)e.push({subjects:[h],range:o});else{let d=[],f=-1/0,y=1/0,I=[],w=[];for(let x=0;x<e.length;x++){let C=e[x];if(w.push(...C.subjects),C.range[0]<y&&(y=C.range[0]),C.range[1]>f&&(f=C.range[1]),o[0]>=C.range[0]&&o[1]<=C.range[1])return e[x].subjects.push(h),e;o[0]<C.range[0]&&o[1]>C.range[0]&&(d.push(x),I=I.concat(C.subjects)),o[0]>=C.range[0]&&o[0]<=C.range[1]&&(d.push(x),I=I.concat(C.subjects),o[0]=C.range[0]),o[1]>=C.range[0]&&o[1]<=C.range[1]&&(d.push(x),I=I.concat(C.subjects),o[1]=C.range[1])}if(w.push(h),o[0]<=y&&o[1]>=f)return[{subjects:w,range:o}];d.length&&d.reverse().forEach(x=>{e.splice(x,1)}),e.push({subjects:I.concat([h]),range:o})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);function tn(){let r={};function e(){for(let c in r)Object.prototype.hasOwnProperty.call(r,c)&&delete r[c];return!0}function t(c){let o={};for(let h in r)+h<=c&&(o[h]=r[h]);return o}function i(c){let o={};for(let h in r)+h>=c&&(o[h]=r[h]);return o}function n({timestamp:c,priority:o,initiator:h}){var d;if(dr(c)){let f=(d=r[c])!=null?d:null;if(f&&Ye(o,!0)){let y={},I=f[o];if(I&&(y={...y,...I}),y=xe(y)?null:y,y&&Ye(h,!0)){let w=y[h];return w!=null?w:null}return y}return f}return null}function s({timestamp:c,priority:o,initiator:h}){if(dr(c))if(r[c]){if(Ye(o,!0))if(r[c][o]){if(Ye(h,!0))if(r[c][o][h]){if(delete r[c][o][h],!xe(r[c][o]))return!0}else return!1;if(delete r[c][o],!xe(r[c]))return!0}else return!1;return delete r[c]}else return!1}function l({timestamp:c,priority:o,initiator:h,...d}){var f,y,I;(y=(f=r[c])==null?void 0:f[o])!=null&&y[h]?r[c][o][h].push({...d}):(I=r[c])!=null&&I[o]?r[c][o]={...r[c][o],[h]:[{...d}]}:r[c]?r[c]={...r[c],[o]:{[h]:[{...d}]}}:r[c]={[o]:{[h]:[{...d}]}}}return{map:r,remove:s,add:l,removeAll:e,get:n,getLte:t,getGte:i}}var uo=[A.expect,A.setNextBranch],po=1/0;function Sr(r){let e=r,t,i=fo(),n=new tn,s,l=()=>{y(),p()},c=u=>{n.add.call(void 0,u),w()},o=(u=[])=>{for(let g of u)if(g.action(),uo.includes(g.actionType))break},h=(u=1/0)=>{var P,j,F;let g=Ht((P=n.get({timestamp:u,priority:"control"}))!=null?P:{}),T=Ht((j=n.get({timestamp:u,priority:"container"}))!=null?j:{}),v=Ht((F=n.get({timestamp:u,priority:"chapter"}))!=null?F:{});return[...g,...T,...v]},d=u=>{i.isReady(u)&&o(h(u))},f=()=>{var u;o([...Ht((u=n.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},y=()=>{t&&(s==null||s.unsubscribe(),t=void 0)},I=u=>{},w=()=>{t||(t=()=>setTimeout(()=>{d(1/0)}),s=e.events.ended$.subscribe(t))},x=u=>{y(),e=u},C=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),n.remove(u)},p=()=>{i.release(),n.removeAll()};return{setPlayer:x,add:c,remove:C,exec:d,execEndOfVideo:f,listen:w,unlisten:y,release:l,containersEventsCallState:i,getPreparedToExecActions:h}}function fo(){let r=new Map;return{setCalled:({timestamp:l,id:c})=>{let o=r.get(l);o&&o[c]!==void 0&&(o[c]=!0)},setData:(l=[])=>{var c,o;for(let h of l){let d=(c=h.endTime)!=null?c:po,f=(o=r.get(d))!=null?o:{};r.set(d,{...f,[h.id]:!1})}},resetCalled:l=>{let c=r.get(l);if(c)for(let o in c)c[o]=!1},isReady:l=>{let c=r.get(l);return c?!Object.values(c).some(o=>!o):!0},release:()=>r.clear()}}function Ht(r){return Object.values(r).flat().sort(e=>e.actionType===A.expect?-1:1)}var rn={videoContentHeight:0,videoContentWidth:0},nn=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return rn;let{clientHeight:n,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(n&&s))return rn;let l=t/i,c=n/s,o,h;return c>l?(h=s,o=s*l):c<l?(h=n/l,o=n):(h=s,o=n),{videoContentWidth:h,videoContentHeight:o}};var mo=250;function sn(r){let e=()=>{},t=new ResizeObserver(c=>{s(c),e=s.bind(null,c)});function i(c){let{parentElement:o,player:h}=r();if(o&&h){let{videoContentWidth:d,videoContentHeight:f}=nn(o,h);o.style.setProperty("--interactive-content-width",`${d}px`),o.style.setProperty("--interactive-content-height",`${f}px`),o.style.setProperty("--interactive-width",`${c[0].contentRect.width}px`),o.style.setProperty("--interactive-height",`${c[0].contentRect.height}px`)}}function n(){let{parentElement:c}=r();c.removeAttribute("style")}let s=Rt(c=>{let{fns:o=[]}=r();i(c);for(let h of o)h()},mo);function l(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e()},release:l}}var at=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 yo=r=>Math.floor(Math.random()*r),an=r=>{let e=r.length,t=1/0,i=null;for(;e--;)r[e].weight<t&&(t=r[e].weight,i=r[e]);return i},on=r=>{let e=r.length,t=-1/0,i=null;for(;e--;)r[e].weight>t&&(t=r[e].weight,i=r[e]);return i};var cn=r=>{let e=r.length,t=yo(e);return r[t]};var ln=r=>{var i,n;let e=0;for(let s=0;s<r.length;++s)e+=(i=r[s].weight)!=null?i:1;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(n=r[s].weight)!=null?n:1,e>=t)return r[s];return r[r.length-1]};var hn=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0});var wr=(r,e=!1)=>({...r,args:e?{...r.args,...hn}:{...hn,...r.args}}),_r=({globalEventEmitter:r,player:e,interactiveEvents:t,removeControllers:i})=>{let n={isExpect:!1},s=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:p,controlType:u,controlId:g,containerId:T,branches:v=[],onEvent:P,isEOV:j=()=>!1,isDisabled:F=()=>!1})=>{let _=wr(p,j()),H={timestamp:1/0,priority:"control",initiator:g,actionType:_.type},Le=F(),Ee=r.emit.bind(r,E.interactives,{subjectId:g,subjectType:u,subjectName:"control",type:Le?R.actionChoiceCanceled:R.actionChoice,actionType:p.type,payload:{containerId:T,..._.args}});if(Le){Ee();return}switch(_.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{let J=v.find(yt=>yt.id===_.args.branchId);if(!J)return;P(_.args.isDetachContainer,y.bind(null,{subjectId:g,subjectName:"control"})),Ee(),_.args.shouldOpenNow?w({subjectId:g,subjectName:"control",subjectType:u,action:_,payload:{chapterId:J.chapterId,autoSelect:!1}}):(t.add({...H,action:w.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:_,payload:{chapterId:J.chapterId,autoSelect:!1}})}),i==null||i());return}case A.continuePlayback.trim().toLowerCase():{P(_.args.isDetachContainer,y.bind(null,{subjectId:g,subjectName:"control"})),Ee(),_.args.shouldOpenNow?I({subjectId:g,subjectName:"control",subjectType:u,action:p}):t.add({...H,action:I.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:p})});return}case A.openURI.trim().toLowerCase():{P(_.args.isDetachContainer,y.bind(null,{subjectId:g,subjectName:"control"})),Ee(),_.args.shouldOpenNow?C({subjectId:g,subjectName:"control",subjectType:u,action:_,payload:{URI:p.args.uri}}):(t.add({...H,action:C.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:_,payload:{URI:p.args.uri}})}),i==null||i());return}default:console.error("Unexpected control event"),r.emit(E.errors,new G(1,1,{message:"Unexpected control event"}));return}},c=({action:p,container:{id:u,endTime:g},branches:T=[],isEOV:v=!1,autoSelected:P=!1})=>{let j=wr(p,v),F={timestamp:!j.args.shouldOpenNow||v?1/0:g,priority:"container",initiator:u,actionType:j.type},_=r.emit.bind(r,E.interactives,{subjectId:u,subjectName:"container",type:R.actionChoice,actionType:j.type,payload:j.args});switch(j.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{let H=T.find(Le=>Le.id===j.args.branchId);if(!H)return;_(),t.add({...F,action:w.bind(null,{subjectId:u,subjectName:"container",action:j,payload:{chapterId:H.chapterId,autoSelect:P}})}),i==null||i();return}case A.setMaxWeightBranch.trim().toLowerCase():return;case A.setMinWeightBranch.trim().toLowerCase():return;case A.setRandomBranch.trim().toLowerCase():return;case A.setWeightlessRandomBranch.trim().toLowerCase():return;case A.continuePlayback.trim().toLowerCase():{_(),t.add({...F,action:I.bind(null,{subjectId:u,subjectName:"container",action:j})});return}case A.openURI.trim().toLowerCase():{_(),t.add({...F,action:C.bind(null,{subjectId:u,subjectName:"container",action:j,payload:{URI:p.args.uri}})}),i==null||i();return}default:console.error("Unexpected container event"),r.emit(E.errors,new G(1,1,{message:"Unexpected container event"}));return}};function o({container:p,branches:u,isEOV:g=!1}){let T=Cr(p.events);if(T){let v=wr(T.action,g);r.emit(E.interactives,{subjectId:p.id,subjectName:"container",type:R.actionChoice,actionType:v.type,payload:v.args}),t.add({timestamp:g?1/0:p.endTime,priority:"container",initiator:p.id,actionType:A.expect,action:f.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let v of p.events)c({action:v.action,container:p,branches:u,isEOV:g})}let h=({chapterId:p,action:u,branches:g=[]})=>{let T=r.emit.bind(r,E.interactives,{subjectId:p,subjectName:"chapter",type:R.actionChoice,actionType:u.type,payload:u.args});switch(u.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{let v=g.find(P=>P.id===u.args.branchId);return v!=null&&v.chapterId?(T(),w.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.setWeightlessRandomBranch.trim().toLowerCase():{let v=cn(g);return v!=null&&v.chapterId?(T(),w.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.setRandomBranch.trim().toLowerCase():{let v=ln(g);return v!=null&&v.chapterId?(T(),w.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.setMaxWeightBranch.trim().toLowerCase():{let v=on(g);return v!=null&&v.chapterId?(T(),w.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.setMinWeightBranch.trim().toLowerCase():{let v=an(g);return v!=null&&v.chapterId?(T(),w.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.continuePlayback.trim().toLowerCase():return T(),I.bind(null,{subjectId:p,subjectName:"chapter",action:u});case A.openURI.trim().toLowerCase():return T(),C.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:console.error("Unexpected chapter event"),r.emit(E.errors,new G(1,1,{message:"Unexpected chapter event"}));return}};function d(p){let u=Cr(p.events);if(u){if(Y(p))return;r.emit(E.interactives,{subjectId:p.id,subjectName:"chapter",type:R.actionChoice,actionType:u.action.type,payload:u.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:A.expect,action:f.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else p.events.forEach(g=>{let T=h({chapterId:p.id,action:g.action,branches:p.branches});T&&t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:g.action.type,action:T})})}let f=({subjectId:p,subjectName:u,action:g})=>{var T;e.pause(),r.emit(E.interactives,{subjectId:p,subjectName:u,type:R.actionExecution,actionType:(T=g==null?void 0:g.type)!=null?T:A.expect})},y=({subjectId:p,subjectName:u})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),r.emit(E.interactives,{subjectId:p,subjectName:u,type:R.actionExecution,actionType:"after-expect"})},I=({subjectId:p,subjectName:u,subjectType:g,action:T})=>{r.emit(E.interactives,{subjectId:p,subjectName:u,subjectType:g,type:R.actionExecution,actionType:T.type})},w=({subjectId:p,subjectName:u,subjectType:g,action:T,payload:v})=>{v.behaviour="change-chapter",r.emit(E.interactives,{subjectId:p,subjectName:u,subjectType:g,type:R.actionExecution,actionType:T.type,payload:v})},x=({subjectId:p,subjectName:u,subjectType:g,action:T,payload:v})=>{v.behaviour="change-manifest",r.emit(E.interactives,{subjectId:p,subjectName:u,subjectType:g,type:R.actionExecution,actionType:T.type,payload:v})},C=({subjectId:p,subjectName:u,subjectType:g,action:T,payload:v})=>{if(!v.URI)return;let P=window.open(v.URI,"_blank","noopener,noreferrer");P&&(P.opener=null),r.emit(E.interactives,{subjectId:p,subjectName:u,subjectType:g,type:R.actionExecution,actionType:T.type})};return{onControlEvent:l,onContainerEvent:c,onChapterEvent:h,onExpectEvent:f,expectEventHandler:y,setManifestChapterEvents:d,setManifestContainerEvents:o,stopExpect:s,state:n}};var ci=Ii(Sa(),1),fe=require("@vkontakte/videoplayer-shared");var Qt=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(l=>l.id===i);if(!n)return null;let s=e.media.videos.find(l=>n.videoId===l.id);if(!s)return null;t[i]=ai(s)}return t[i]}).filter(Boolean)},wa=r=>{for(let e of r.variants)if(_a(e)&&"payload"in e)return e.payload.id},_a=r=>r.type==="custom"&&"payload"in r&&r.payload.type==="vk",ai=r=>{let e=wa(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Ra=(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=Ra(e,i);return n?[...t,n]:t},[]);var ie,_e,Re,Q,Yt,ne,se,X,Ve,He,Ge,pt=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new fe.ValueSubject([]),hasPrevChapter$:new fe.ValueSubject(!1),prevChapter$:new fe.ValueSubject(null),isInitialChapter$:new fe.ValueSubject(!1),isGoBackLimited$:new fe.ValueSubject(!1)};S(this,ie,null);S(this,_e);S(this,Re,!1);S(this,Q,null);S(this,Yt,null);S(this,ne,null);S(this,se,null);S(this,X,null);S(this,Ve,new fe.Subscription);S(this,He,!1);S(this,Ge,0);var l,c,o;b(this,ne,t),b(this,X,e),b(this,se,i),b(this,ie,n),b(this,_e,s),(l=this.state)!=null&&l.history$&&a(this,Ve)&&((o=a(this,Ve))==null||o.add((c=this.state)==null?void 0:c.history$.subscribe(h=>{var d,f,y,I,w,x;(d=this.state)==null||d.prevChapter$.next((0,ci.default)(h,-2)||null),(f=this.state)==null||f.hasPrevChapter$.next(h.length>1),(w=this.state)==null||w.isInitialChapter$.next(this.getInitialChapterId()===((I=(y=a(this,Q))==null?void 0:y.metadata)==null?void 0:I.initChapterId)),(x=this.state)==null||x.isGoBackLimited$.next(a(this,Ge)===a(this,_e).maxLength-1)})))}async setManifest(e){!a(this,se)||!a(this,X)||(b(this,Q,e),await this.getProjectHistory(),await a(this,se).setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),a(this,Re)||(b(this,Re,!0),a(this,X).emit(E.historyInited,{initChapterId:this.getInitialChapterId()})))}get inited(){return a(this,Re)}async updateHistory(e,t=!0){var c,o;if(!a(this,Q))return;a(this,He)?(b(this,He,!1),xi(this,Ge)._++):b(this,Ge,0);let i=a(this,Q),n=e.length-a(this,_e).maxLength,s=n>0?e.slice(n):e,l=Qt(s,i);if(b(this,Yt,l),(c=this==null?void 0:this.state)==null||c.history$.next(s),!(!t||!a(this,ie)||!a(this,ne)))try{await a(this,ie).save(a(this,ne),l)}catch(h){(o=a(this,X))==null||o.emit(E.errors,new G(1,5,"Unable to save interactive history"))}}async goBack(){var i;if(!this.state||!a(this,se))return(i=a(this,X))==null?void 0:i.emit(E.errors,new G(1,5,"Cannot go back because HistoryController has not been initialized"));b(this,He,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await a(this,se).setChapter({chapterId:t})}async getProjectHistory(){var n,s;if(!a(this,Q)||!a(this,ne))return;let e=a(this,Q),t=[this.getInitialVideoId()];if(a(this,ie))try{let l=await a(this,ie).get(a(this,ne));l.length&&(t=l)}catch(l){(n=a(this,X))==null||n.emit(E.errors,new G(1,5,"Error while trying to fetch data"))}let i=oi(t,e);(s=this==null?void 0:this.state)==null||s.history$.next(i)}getInitialChapterId(){var t,i;let e=(t=this.state)==null?void 0:t.history$.getValue();return(0,ci.default)(e,-1)||a(this,_e).initChapterId||((i=a(this,Q))==null?void 0:i.metadata.initChapterId)}getInitialVideoId(){if(a(this,Q)){let e=this.getInitialChapterId();return Qt([e],a(this,Q)).pop()}return null}destroy(){var e,t;this.state=null,b(this,ne,null),b(this,ie,null),b(this,se,null),(e=a(this,Ve))==null||e.unsubscribe(),b(this,Ve,null),b(this,Re,!1),(t=a(this,X))==null||t.emit(E.historyDestroyed),b(this,X,null)}};ie=new WeakMap,_e=new WeakMap,Re=new WeakMap,Q=new WeakMap,Yt=new WeakMap,ne=new WeakMap,se=new WeakMap,X=new WeakMap,Ve=new WeakMap,He=new WeakMap,Ge=new WeakMap;var Me=class Me{constructor(e,t,i,n){this.target=e,this.type=t,this.listener=i,this.options=Me._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(l=>!i.has(l));return n.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+n.join(",")),Me._doesSupportObject(e)?t:t.capture||!1}}static _doesSupportObject(e){let t=Me._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}Me._supportsObject=t}return t||!1}};Me._supportsObject=void 0;var Zt=Me;var Xt=class{constructor(){this.bindingMap=new at}release(){this.removeAll(),this.bindingMap=null}listen(e,t,i,n){if(!this.bindingMap)return;let s=new Zt(e,t,i,n);this.bindingMap.push(t,s)}listenOnce(e,t,i,n){let s=l=>{this.unlisten(e,t,s),i(l)};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 Jt=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))}async updateCanvasDimensions(e,t=!1){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var er=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 Ks=Object.create;var Ge=Object.defineProperty;var Qs=Object.getOwnPropertyDescriptor;var Ys=Object.getOwnPropertyNames;var Zs=Object.getPrototypeOf,Xs=Object.prototype.hasOwnProperty;var qr=r=>{throw TypeError(r)};var h=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Js=(r,e)=>{for(var t in e)Ge(r,t,{get:e[t],enumerable:!0})},Hr=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ys(e))!Xs.call(r,n)&&n!==t&&Ge(r,n,{get:()=>e[n],enumerable:!(i=Qs(e,n))||i.enumerable});return r};var Mt=(r,e,t)=>(t=r!=null?Ks(Zs(r)):{},Hr(e||!r||!r.__esModule?Ge(t,"default",{value:r,enumerable:!0}):t,r)),ea=r=>Hr(Ge({},"__esModule",{value:!0}),r);var kt=(r,e,t)=>e.has(r)||qr("Cannot "+t);var I=(r,e,t)=>(kt(r,e,"read from private field"),t?t.call(r):e.get(r)),j=(r,e,t)=>e.has(r)?qr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),V=(r,e,t,i)=>(kt(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),xe=(r,e,t)=>(kt(r,e,"access private method"),t);var Dr=(r,e,t,i)=>({set _(n){V(r,e,n,t)},get _(){return I(r,e,i)}});var D=h((_t,Zr)=>{"use strict";var Te=function(r){return r&&r.Math===Math&&r};Zr.exports=Te(typeof globalThis=="object"&&globalThis)||Te(typeof window=="object"&&window)||Te(typeof self=="object"&&self)||Te(typeof global=="object"&&global)||Te(typeof _t=="object"&&_t)||function(){return this}()||Function("return this")()});var Q=h((Tc,Xr)=>{"use strict";Xr.exports=function(r){try{return!!r()}catch(e){return!0}}});var Se=h((Sc,Jr)=>{"use strict";var ra=Q();Jr.exports=!ra(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var ni=h((wc,ii)=>{"use strict";var ia=Se(),ri=Function.prototype,ei=ri.apply,ti=ri.call;ii.exports=typeof Reflect=="object"&&Reflect.apply||(ia?ti.bind(ei):function(){return ti.apply(ei,arguments)})});var ee=h((Ac,oi)=>{"use strict";var si=Se(),ai=Function.prototype,Bt=ai.call,na=si&&ai.bind.bind(Bt,Bt);oi.exports=si?na:function(r){return function(){return Bt.apply(r,arguments)}}});var qt=h((Pc,ci)=>{"use strict";var li=ee(),sa=li({}.toString),aa=li("".slice);ci.exports=function(r){return aa(sa(r),8,-1)}});var Ht=h((Rc,pi)=>{"use strict";var oa=qt(),la=ee();pi.exports=function(r){if(oa(r)==="Function")return la(r)}});var Y=h((Mc,ui)=>{"use strict";var Dt=typeof document=="object"&&document.all;ui.exports=typeof Dt=="undefined"&&Dt!==void 0?function(r){return typeof r=="function"||r===Dt}:function(r){return typeof r=="function"}});var fe=h((kc,hi)=>{"use strict";var ca=Q();hi.exports=!ca(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var nt=h((Vc,di)=>{"use strict";var pa=Se(),it=Function.prototype.call;di.exports=pa?it.bind(it):function(){return it.apply(it,arguments)}});var vi=h(yi=>{"use strict";var fi={}.propertyIsEnumerable,mi=Object.getOwnPropertyDescriptor,ua=mi&&!fi.call({1:2},1);yi.f=ua?function(e){var t=mi(this,e);return!!t&&t.enumerable}:fi});var Ut=h((Lc,gi)=>{"use strict";gi.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Ci=h((jc,bi)=>{"use strict";var ha=ee(),da=Q(),fa=qt(),Gt=Object,ma=ha("".split);bi.exports=da(function(){return!Gt("z").propertyIsEnumerable(0)})?function(r){return fa(r)==="String"?ma(r,""):Gt(r)}:Gt});var zt=h((Fc,Ei)=>{"use strict";Ei.exports=function(r){return r==null}});var Wt=h((Nc,Ii)=>{"use strict";var ya=zt(),va=TypeError;Ii.exports=function(r){if(ya(r))throw new va("Can't call method on "+r);return r}});var Ti=h(($c,xi)=>{"use strict";var ga=Ci(),ba=Wt();xi.exports=function(r){return ga(ba(r))}});var we=h((_c,Si)=>{"use strict";var Ca=Y();Si.exports=function(r){return typeof r=="object"?r!==null:Ca(r)}});var Kt=h((Bc,wi)=>{"use strict";wi.exports={}});var Zt=h((qc,Pi)=>{"use strict";var Qt=Kt(),Yt=D(),Ea=Y(),Ai=function(r){return Ea(r)?r:void 0};Pi.exports=function(r,e){return arguments.length<2?Ai(Qt[r])||Ai(Yt[r]):Qt[r]&&Qt[r][e]||Yt[r]&&Yt[r][e]}});var Mi=h((Hc,Ri)=>{"use strict";var Ia=ee();Ri.exports=Ia({}.isPrototypeOf)});var Li=h((Dc,Oi)=>{"use strict";var xa=D(),ki=xa.navigator,Vi=ki&&ki.userAgent;Oi.exports=Vi?String(Vi):""});var qi=h((Uc,Bi)=>{"use strict";var _i=D(),Xt=Li(),ji=_i.process,Fi=_i.Deno,Ni=ji&&ji.versions||Fi&&Fi.version,$i=Ni&&Ni.v8,_,st;$i&&(_=$i.split("."),st=_[0]>0&&_[0]<4?1:+(_[0]+_[1]));!st&&Xt&&(_=Xt.match(/Edge\/(\d+)/),(!_||_[1]>=74)&&(_=Xt.match(/Chrome\/(\d+)/),_&&(st=+_[1])));Bi.exports=st});var Jt=h((Gc,Di)=>{"use strict";var Hi=qi(),Ta=Q(),Sa=D(),wa=Sa.String;Di.exports=!!Object.getOwnPropertySymbols&&!Ta(function(){var r=Symbol("symbol detection");return!wa(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Hi&&Hi<41})});var er=h((zc,Ui)=>{"use strict";var Aa=Jt();Ui.exports=Aa&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var tr=h((Wc,Gi)=>{"use strict";var Pa=Zt(),Ra=Y(),Ma=Mi(),ka=er(),Va=Object;Gi.exports=ka?function(r){return typeof r=="symbol"}:function(r){var e=Pa("Symbol");return Ra(e)&&Ma(e.prototype,Va(r))}});var Wi=h((Kc,zi)=>{"use strict";var Oa=String;zi.exports=function(r){try{return Oa(r)}catch(e){return"Object"}}});var rr=h((Qc,Ki)=>{"use strict";var La=Y(),ja=Wi(),Fa=TypeError;Ki.exports=function(r){if(La(r))return r;throw new Fa(ja(r)+" is not a function")}});var Yi=h((Yc,Qi)=>{"use strict";var Na=rr(),$a=zt();Qi.exports=function(r,e){var t=r[e];return $a(t)?void 0:Na(t)}});var Xi=h((Zc,Zi)=>{"use strict";var ir=nt(),nr=Y(),sr=we(),_a=TypeError;Zi.exports=function(r,e){var t,i;if(e==="string"&&nr(t=r.toString)&&!sr(i=ir(t,r))||nr(t=r.valueOf)&&!sr(i=ir(t,r))||e!=="string"&&nr(t=r.toString)&&!sr(i=ir(t,r)))return i;throw new _a("Can't convert object to primitive value")}});var en=h((Xc,Ji)=>{"use strict";Ji.exports=!0});var nn=h((Jc,rn)=>{"use strict";var tn=D(),Ba=Object.defineProperty;rn.exports=function(r,e){try{Ba(tn,r,{value:e,configurable:!0,writable:!0})}catch(t){tn[r]=e}return e}});var ar=h((ep,on)=>{"use strict";var qa=en(),Ha=D(),Da=nn(),sn="__core-js_shared__",an=on.exports=Ha[sn]||Da(sn,{});(an.versions||(an.versions=[])).push({version:"3.38.0",mode:qa?"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 pn=h((tp,cn)=>{"use strict";var ln=ar();cn.exports=function(r,e){return ln[r]||(ln[r]=e||{})}});var or=h((rp,un)=>{"use strict";var Ua=Wt(),Ga=Object;un.exports=function(r){return Ga(Ua(r))}});var at=h((ip,hn)=>{"use strict";var za=ee(),Wa=or(),Ka=za({}.hasOwnProperty);hn.exports=Object.hasOwn||function(e,t){return Ka(Wa(e),t)}});var fn=h((np,dn)=>{"use strict";var Qa=ee(),Ya=0,Za=Math.random(),Xa=Qa(1 .toString);dn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Xa(++Ya+Za,36)}});var vn=h((sp,yn)=>{"use strict";var Ja=D(),eo=pn(),mn=at(),to=fn(),ro=Jt(),io=er(),me=Ja.Symbol,lr=eo("wks"),no=io?me.for||me:me&&me.withoutSetter||to;yn.exports=function(r){return mn(lr,r)||(lr[r]=ro&&mn(me,r)?me[r]:no("Symbol."+r)),lr[r]}});var En=h((ap,Cn)=>{"use strict";var so=nt(),gn=we(),bn=tr(),ao=Yi(),oo=Xi(),lo=vn(),co=TypeError,po=lo("toPrimitive");Cn.exports=function(r,e){if(!gn(r)||bn(r))return r;var t=ao(r,po),i;if(t){if(e===void 0&&(e="default"),i=so(t,r,e),!gn(i)||bn(i))return i;throw new co("Can't convert object to primitive value")}return e===void 0&&(e="number"),oo(r,e)}});var cr=h((op,In)=>{"use strict";var uo=En(),ho=tr();In.exports=function(r){var e=uo(r,"string");return ho(e)?e:e+""}});var Sn=h((lp,Tn)=>{"use strict";var fo=D(),xn=we(),pr=fo.document,mo=xn(pr)&&xn(pr.createElement);Tn.exports=function(r){return mo?pr.createElement(r):{}}});var ur=h((cp,wn)=>{"use strict";var yo=fe(),vo=Q(),go=Sn();wn.exports=!yo&&!vo(function(){return Object.defineProperty(go("div"),"a",{get:function(){return 7}}).a!==7})});var Rn=h(Pn=>{"use strict";var bo=fe(),Co=nt(),Eo=vi(),Io=Ut(),xo=Ti(),To=cr(),So=at(),wo=ur(),An=Object.getOwnPropertyDescriptor;Pn.f=bo?An:function(e,t){if(e=xo(e),t=To(t),wo)try{return An(e,t)}catch(i){}if(So(e,t))return Io(!Co(Eo.f,e,t),e[t])}});var kn=h((up,Mn)=>{"use strict";var Ao=Q(),Po=Y(),Ro=/#|\.prototype\./,Ae=function(r,e){var t=ko[Mo(r)];return t===Oo?!0:t===Vo?!1:Po(e)?Ao(e):!!e},Mo=Ae.normalize=function(r){return String(r).replace(Ro,".").toLowerCase()},ko=Ae.data={},Vo=Ae.NATIVE="N",Oo=Ae.POLYFILL="P";Mn.exports=Ae});var Ln=h((hp,On)=>{"use strict";var Vn=Ht(),Lo=rr(),jo=Se(),Fo=Vn(Vn.bind);On.exports=function(r,e){return Lo(r),e===void 0?r:jo?Fo(r,e):function(){return r.apply(e,arguments)}}});var Fn=h((dp,jn)=>{"use strict";var No=fe(),$o=Q();jn.exports=No&&$o(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var $n=h((fp,Nn)=>{"use strict";var _o=we(),Bo=String,qo=TypeError;Nn.exports=function(r){if(_o(r))return r;throw new qo(Bo(r)+" is not an object")}});var qn=h(Bn=>{"use strict";var Ho=fe(),Do=ur(),Uo=Fn(),ot=$n(),_n=cr(),Go=TypeError,hr=Object.defineProperty,zo=Object.getOwnPropertyDescriptor,dr="enumerable",fr="configurable",mr="writable";Bn.f=Ho?Uo?function(e,t,i){if(ot(e),t=_n(t),ot(i),typeof e=="function"&&t==="prototype"&&"value"in i&&mr in i&&!i[mr]){var n=zo(e,t);n&&n[mr]&&(e[t]=i.value,i={configurable:fr in i?i[fr]:n[fr],enumerable:dr in i?i[dr]:n[dr],writable:!1})}return hr(e,t,i)}:hr:function(e,t,i){if(ot(e),t=_n(t),ot(i),Do)try{return hr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new Go("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Dn=h((yp,Hn)=>{"use strict";var Wo=fe(),Ko=qn(),Qo=Ut();Hn.exports=Wo?function(r,e,t){return Ko.f(r,e,Qo(1,t))}:function(r,e,t){return r[e]=t,r}});var zn=h((vp,Gn)=>{"use strict";var Pe=D(),Yo=ni(),Zo=Ht(),Xo=Y(),Jo=Rn().f,el=kn(),ye=Kt(),tl=Ln(),ve=Dn(),Un=at();ar();var rl=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 Yo(r,this,arguments)};return e.prototype=r.prototype,e};Gn.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,s=r.proto,l=i?Pe:n?Pe[t]:Pe[t]&&Pe[t].prototype,o=i?ye:ye[t]||ve(ye,t,{})[t],a=o.prototype,c,v,C,y,E,w,x,g,u;for(y in e)c=el(i?y:t+(n?".":"#")+y,r.forced),v=!c&&l&&Un(l,y),w=o[y],v&&(r.dontCallGetSet?(u=Jo(l,y),x=u&&u.value):x=l[y]),E=v&&x?x:e[y],!(!c&&!s&&typeof w==typeof E)&&(r.bind&&v?g=tl(E,Pe):r.wrap&&v?g=rl(E):s&&Xo(E)?g=Zo(E):g=E,(r.sham||E&&E.sham||w&&w.sham)&&ve(g,"sham",!0),ve(o,y,g),s&&(C=t+"Prototype",Un(ye,C)||ve(ye,C,{}),ve(ye[C],y,E),r.real&&a&&(c||!a[y])&&ve(a,y,E)))}});var Kn=h((gp,Wn)=>{"use strict";var il=Math.ceil,nl=Math.floor;Wn.exports=Math.trunc||function(e){var t=+e;return(t>0?nl:il)(t)}});var yr=h((bp,Qn)=>{"use strict";var sl=Kn();Qn.exports=function(r){var e=+r;return e!==e||e===0?0:sl(e)}});var Zn=h((Cp,Yn)=>{"use strict";var al=yr(),ol=Math.min;Yn.exports=function(r){var e=al(r);return e>0?ol(e,9007199254740991):0}});var Jn=h((Ep,Xn)=>{"use strict";var ll=Zn();Xn.exports=function(r){return ll(r.length)}});var ts=h((Ip,es)=>{"use strict";es.exports=function(){}});var rs=h(()=>{"use strict";var cl=zn(),pl=or(),ul=Jn(),hl=yr(),dl=ts();cl({target:"Array",proto:!0},{at:function(e){var t=pl(this),i=ul(t),n=hl(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:t[s]}});dl("at")});var ns=h((Sp,is)=>{"use strict";var fl=Zt();is.exports=fl});var as=h((wp,ss)=>{"use strict";rs();var ml=ns();ss.exports=ml("Array","at")});var ls=h((Ap,os)=>{"use strict";var yl=as();os.exports=yl});var vr=h((Pp,cs)=>{"use strict";var vl=ls();cs.exports=vl});var Fl={};Js(Fl,{ControlTypes:()=>b.ControlTypes,CustomError:()=>L,EVENT_NAMES:()=>f,EventActionTypes:()=>b.EventActionTypes,Interactives:()=>He,ManifestController:()=>ne,SDKInfo:()=>jl,chapterIdsToVKVideoIds:()=>xt,compareVersions:()=>vt,getChapterIdByVkVideoId:()=>Hs,getVKVideoIdByMedia:()=>kr,getVideoRawIdByMedia:()=>Bs,graphEventTypes:()=>be,hasEndTemplate:()=>$e,interactivesEventTypes:()=>P,isAreaControl:()=>Cl,isButtonControl:()=>bl,isLastChapter:()=>B,isSupportedManifest:()=>b.isSupportedManifest,isTextControl:()=>Le,isVKVariantItem:()=>qs,isValidManifest:()=>Cr,migrateManifestToLatestVersion:()=>b.migrateManifestToLatestVersion,utils:()=>zs,vkVideoIdsToChapterIds:()=>Vr});module.exports=ea(Fl);var Ur="1.0.19-dev.d432d6cd.0";function Vt(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 N="interactive",ta="interactive-controls-container",ze=()=>document.querySelector(`.${ta}`),Gr=.4,F={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},zr=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(zr||{}),Wr=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(Wr||{}),Kr=(i=>(i.start="left",i.end="right",i.center="center",i))(Kr||{}),We=({target:r,props:e})=>{var t,i,n,s,l,o;r.style.alignItems=(i=((t=e.text)==null?void 0:t.gravityVertical)&&zr[e.text.gravityVertical])!=null?i:"center",r.style.justifyContent=(s=((n=e.text)==null?void 0:n.gravityHorizontal)&&Wr[e.text.gravityHorizontal])!=null?s:"center",r.style.textAlign=(o=((l=e.text)==null?void 0:l.alignment)&&Kr[e.text.alignment])!=null?o:"left"},Ke=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,o,a,c;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} * ${(o=(l=e==null?void 0:e.text)==null?void 0:l.size)!=null?o:t.textSize})`,r.textContent=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},Qe=({target:r,props:e,fallback:t})=>{var i,n,s,l;r.style.backgroundColor=Vt((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(l=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?l:t.backgroundAlpha)},Ye=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,o,a,c,v,C,y,E,w;r.style.border=`calc(${i.height} * ${(l=(s=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:s.width)!=null?l:t.borderWidth}) solid ${Vt((c=(a=(o=e==null?void 0:e.shape)==null?void 0:o.border)==null?void 0:a.color)!=null?c:t.borderColor,(y=(C=(v=e==null?void 0:e.shape)==null?void 0:v.border)==null?void 0:C.alpha)!=null?y:t.borderAlpha)}`,r.style.borderRadius=`calc(${i.height} * ${(w=(E=e==null?void 0:e.shape)==null?void 0:E.roundCorners)!=null?w:t.roundCorners})`},he=({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 U=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(`${N}-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 Ot="int",J=(i=>(i.AREA=`${Ot}_area`,i.TEXT=`${Ot}_text`,i.BUTTON=`${Ot}_bttn`,i))(J||{});var Ze=r=>{if(r.type.trim().toLowerCase()==="area")return new Lt(r)},Lt=class extends U{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(`${N}-${this.control.id}`),i.setAttribute("data-testid",J.AREA),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",Qe({target:i,props:this.control.props,fallback:{...F,backgroundColor:"transparent"}}),Ye({target:i,props:this.control.props,fallback:{...F,borderAlpha:0},dependsOn:this.container.dimensions}),he({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 Xe=()=>{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 Je=r=>{if(r.type.trim().toLowerCase()==="button")return new jt(r)},jt=class extends U{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(`${N}-${this.control.id}`),i.setAttribute("data-testid",J.BUTTON),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",i.style.fontFamily="inherit",he({target:i,layoutParams:this.control.layoutParams,fallback:F}),Qe({target:i,props:this.control.props,fallback:F}),Ye({target:i,props:this.control.props,fallback:F,dependsOn:this.container.dimensions}),We({target:i,props:this.control.props});let n=Xe();Ke({target:n,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 Qr=r=>{if(r.type.trim().toLowerCase()==="text")return new Ft(r)},Ft=class extends U{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(`${N}-${this.control.id}`),i.setAttribute("data-testid",J.TEXT),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.fontFamily="inherit",he({target:i,layoutParams:this.control.layoutParams,fallback:F}),We({target:i,props:this.control.props});let n=Xe();Ke({target:n,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 Nt=class{constructor(e){this.layout=e}},et=class extends Nt{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 K,tt,Yr,de=class{constructor(e){j(this,K);this.container=e,this.factories=new Map,xe(this,K,tt).call(this)}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),xe(this,K,tt).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),xe(this,K,tt).call(this)}};K=new WeakSet,tt=function(){this.controls=xe(this,K,Yr).call(this)},Yr=function(){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);return s?[...t,s(i)]:[...t]},[])};var rt=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new $t(r,e)},$t=class extends de{constructor(e,t){super(e),this.rootElement=t!=null?t:ze(),this.layout=new et(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Je),this.addControlFactory("text",Qr),this.addControlFactory("area",Ze)}createView(e){let t=document.createElement("div");return t.classList.add(`${N}-${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=Gr,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(`.${N}-${this.container.id}`)}};var Gs=Mt(vr(),1),A=require("@vkontakte/videoplayer-shared"),Ie=require("@vkontakte/videoplayer-statistics");var fs=require("@vkontakte/videoplayer-shared");function Re(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var te=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Me=r=>te(r,"Object"),lt=r=>te(r,"String"),ct=r=>te(r,"Array"),pt=r=>te(r,"Number"),ps=r=>te(r,"Function");var gr=r=>pt(r)&&!isNaN(r);var re=r=>Me(r)&&Object.keys(r).length===0,br=r=>ct(r)&&!r.length;var ke=(r,e)=>lt(r)&&(e?r.trim():r).length;var us="video_interactive",hs="videoint";var ds=250,Ve=class{constructor(e){this.handleZoomChange=Re(e=>{this.lastZoomInfo=e},ds);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,!pt(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=gl(e),this.resizeObserver=new ResizeObserver(Re(this.onResize,ds)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){var t;this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),(t=this.ngEditor)==null||t.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){var t;(t=this.ngEditor)==null||t.updateVideosInfo(e)}async show(){var e;this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display="block",!this.lastZoomInfo&&this.currentChapterId&&((e=this.ngEditor)==null||e.focusChapter(this.currentChapterId)),this.isHidden=!1)}async initNgEditor(){if(!this.manifest)return;let e;try{e=await(0,fs.loadVKLangPack)(this.lang,us,hs)}catch(i){console.log("Unable to load graph language pack")}let{GraphEditor:t}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",({name:i,...n})=>{var s;i==="openPreview"&&"chapterId"in n&&((s=this.onOpenPreviewClick)==null||s.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 gl(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 Oe=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 l=s.startTime-e;if(l<=n&&(s.endTime&&n<=s.endTime||s.endTime===null)){i=!0;break}n<l&&(t=t===-1?l:Math.min(t,l))}return!i&&t!==-1?t:null}}};var b=require("@interactiveplatform/movika-graph-editor");var ms={metadata:"Object",chapters:"Array"},Cr=r=>{if(!Me(r))return!1;for(let e in ms)if(!r[e]||!te(r[e],ms[e]))return!1;return(0,b.isSupportedManifest)(r.metadata.version)},Le=r=>r.type===b.ControlTypes.Text,bl=r=>r.type===b.ControlTypes.Button,Cl=r=>r.type===b.ControlTypes.Area;var L=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var ut=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 ht=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 Es=require("@vkontakte/videoplayer-shared");var dt=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:[]}}async exec(e,t){return El(...this.loaders[e])(t)}};function El(...r){return async function(t){let i=[...r];for(;i.length>0;)t=await i.shift()(t);return t}}function je(r,e,t){return r?{...r,[e]:r[e]?[t,...r[e]]:[t]}:{[e]:[t]}}function ft({actions:r,errors:e,chapterId:t,...i}){if(t){let n=r.getManifest(),s=r.getChapter(n.chapters,t);if(s){let l=r.getMedia(n.media,s.videoId),o=r.getGraph(n.graph,s.id);return l?{...i,actions:r,errors:e,result:{chapter:s,media:l,graph:o}}:{...i,errors:je(e,ft.name,"Could not find media"),actions:r}}}return{...i,errors:je(e,ft.name,"Could not find chapter"),actions:r}}var mt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let n=0,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 l=i[n];try{l.callback.call(this,e)}catch(o){Promise.resolve().then(()=>{throw o})}l.options&&l.options.once&&this.removeEventListener(e.type,l.callback)}return!e.defaultPrevented}},ge=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)}},Fe=class{constructor(){Object.defineProperty(this,"signal",{value:new ge,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&&(Fe.prototype[Symbol.toStringTag]="AbortController",ge.prototype[Symbol.toStringTag]="AbortSignal");function yt(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 Er(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!yt({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(c,v){let C;v&&v.signal&&(C=v.signal,delete v.signal);let y=new t(c,v);return C&&Object.defineProperty(y,"signal",{writable:!1,enumerable:!1,configurable:!0,value:C}),y},s.prototype=t.prototype);let l=e;return{fetch:(a,c)=>{let v=s&&s.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(v){let C;try{C=new DOMException("Aborted","AbortError")}catch(E){C=new Error("Aborted"),C.name="AbortError"}if(v.aborted)return Promise.reject(C);let y=new Promise((E,w)=>{v.addEventListener("abort",()=>w(C),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([y,l(a,c)])}return l(a,c)},Request:s}}var Ne=yt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),ys=Ne?Er({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Ir=Ne?ys.fetch:window.fetch,cu=Ne?ys.Request:window.Request,pu=Ne?Fe:window.AbortController,uu=Ne?ge:window.AbortSignal;var vt=(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 Il=async r=>{try{let e={},t;if(lt(r)){t=new URL(r).href;let n=await Ir(t);if(!n.ok)return{};e=await n.json()}else if(Me(r))e=r;else return{};if(!Cr(e))return{};let i=e.metadata.media;if(lt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let s=await Ir(n);if(!s.ok)throw new Error;e.metadata.media=await s.json()}catch(n){return Sl(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function vs(r){let{manifest:e,manifestURL:t}=await Il(r);if(!e)throw new Error("Failed on fetch");let i=(0,b.migrateManifestToLatestVersion)(e);return i.media=xl(i.media,t),delete i.metadata.media,i}function gt(r,e){if(e)return r.find(t=>t.id===e)}function xr(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 Tr(r,e){return r.videos.find(t=>t.id===e)}function xl(r,e){return{...r,videos:r.videos.map(t=>({...t,variants:t.variants.map(i=>{let n="url"in i?i.url:"",s=Tl(n,e);return{...i,url:s||n}})}))}}function Tl(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Sl(r){return vt(r,"3.2.0")>=0}var bt=r=>ct(r)&&!br(r),B=r=>r.order==="end",$e=r=>ct(r.containers)&&!br(r.containers)&&B(r),gs=(r,e)=>{var i;let t=r*1e3;return bt(e.controls)&&t<((i=e.startTime)!=null?i:0)},Sr=(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 ie=(r=[])=>r.some(e=>e.action.type==="expect"),wr=(r=[])=>r.find(e=>e.action.type==="expect"),wl=r=>(r==null?void 0:r.length)===1,Ct=r=>wl(r)&&Le(r[0]);function bs(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r({...e[0],...t}):r(...e,...t)}var Cs=(r,e)=>ie(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&ie(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var ne=class extends dt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Es.ValueSubject(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(t){var n;this.release();let i=await this.exec("manifestLoaders",{actions:{addErrorMessage:je},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=await vs((n=i.result)!=null?n:t),this}async setInitial(){return this.setNext()}async setNext(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t)return this;this.prevChapter$.next(this.chapter);let n=await this.exec("chapterLoaders",ft({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:xr,getChapter:gt,getMedia:Tr,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=gt(this.manifest.chapters,t);if(n){let s=Tr(this.manifest.media,n.videoId),l=xr(this.manifest.graph,n.id);if(s)return{chapter:n,media:s,graph:l}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,s,l;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((s=this.chapter)==null?void 0:s.branches);{let o=gt(((l=this.manifest)==null?void 0:l.chapters)||[],t);return this.getByBranches(o==null?void 0:o.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?B(this.chapter):!1}};var xs=require("@vkontakte/videoplayer-core"),se=require("@vkontakte/videoplayer-shared");var Is=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&"payload"in e){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};function Ar(){let r=new Map;function e({listId:s=Math.random().toString(),itemId:l=Math.random().toString(),...o}){let a=r.get(s),c={...o};return a?a[l]=c:r.set(s,{[l]:c}),{listId:s,itemId:l,...o}}function t(s){var l,o;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(l=s.statistics)==null||l.oneStat.destroy(),(o=s.statistics)==null||o.statSubscription.unsubscribe()}function i(s,l){let o=r.get(s);if(!o)throw Error("Can't remove. Not find.");if(l){let a=o[l];a&&t(a),delete o[l],Object.keys(o).length||r.delete(s)}else{for(let a of Object.values(o))t(a);r.delete(s)}}function n(){for(let s of r)i(s[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}function Pr(r,e=[]){var s,l,o;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||e.includes("mp4"))&&(t.MPEG={...t.MPEG,[(s=a.standard)!=null?s:"Invariant quality"]:a.url});break;case"mpeg":(n||e.includes("mpeg"))&&(t.MPEG={...t.MPEG,[(l=a.standard)!=null?l:"Invariant quality"]:a.url});break;case"hls":(n||e.includes("hls"))&&(t={...t,HLS:{type:"url",url:a.url}});break;case"dash":(n||e.includes("dash"))&&(t={...t,DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}});break;default:break}return{sources:t,thumbUrl:i,title:(o=r.title)!=null?o:""}}var _e=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&i.includes(e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Al=2;function Rr(r){let e=Ar(),t={},i=null,n=!1,s,l=new se.ValueSubject(null);r&&o(r);function o(x){i=x}function a(x,g,u){var T;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let m=((T=e.map.get(x))!=null?T:{})[g];if(m){t={chapterId:u,listId:x,itemId:g,...m};let d=t.player;t.subscription.add(d.info.currentQuality$.subscribe(M=>{let R=d.info.position$.getValue(),k=d.info.isAutoQualityEnabled$.getValue();if(!(!M||!R||k))for(let S of e.map)Object.values(S[1]).forEach(({player:O})=>{_e(O,M)})})).add(d.events.started$.subscribe(()=>{c(g)})),m.container.remove(),i.setPlayer(m.player),n||(i.init(),n=!0),l.next({player:t.player,config:t.config,statistics:t.statistics});return}throw Error("Can't set. Not find.")}async function c(x){if(!i)throw Error("need to set interactive controller");if(re(t)||x!==t.itemId)return;let g=i.getChapterBranches(),u=new Set;for(let p of g)u.has(p.media.id)||(await C({media:p.media,chapterId:p.chapter.id,setAsActive:!1,title:p.chapter.label}),u.add(p.media.id))}async function v({chapter:{id:x},media:g}){if(re(t))return;let u=t.player.info.muted$.getValue(),p=t.player.info.currentQuality$.getValue(),m=t.player.info.isAutoQualityEnabled$.getValue(),T=t.player.info.volume$.getValue(),d=t.player.info.currentPlaybackRate$.getValue(),M=!m,R=!1;for(let k of e.map)if(k[0]===g.id){let S=Object.keys(k[1]);for(let O of S)O===t.itemId?(S.length<Al||(R=!0),e.removePlayer(k[0],O)):(R=!0,a(k[0],O,x),M?_e(t.player,p):t.player.setAutoQuality(!0),t.player.setVolume(T),t.player.setMuted(u),t.player.setPlaybackRate(d))}else e.removePlayer(k[0]);R||(await C({media:g,chapterId:x,setAsActive:!0,playbackRate:d}),M?_e(t.player,p):t.player.setAutoQuality(!0),t.player.setVolume(T),t.player.setMuted(u))}async function C({media:x,chapterId:g,prefetch:u=!0,setAsActive:p=!0,autoplay:m=!1,preferredExt:T,title:d,playbackRate:M}){var jr,Fr,Nr,$r,_r;let R=Math.random().toString(),k=document.createElement("div");s.append(k);let S;if((jr=i==null?void 0:i.options)!=null&&jr.vkVideoLoader){let Ue=Is(x);Ue.length&&(S=await i.options.vkVideoLoader(...Ue))}let O=((Fr=i==null?void 0:i.options)==null?void 0:Fr.coreConfig)||void 0,pe={...O,configName:[...(Nr=O==null?void 0:O.configName)!=null?Nr:[],"interactive"]},X={container:k,...(($r=S==null?void 0:S.videos)==null?void 0:$r[0])||{sources:Pr(x,T).sources},title:d,failoverHosts:(S==null?void 0:S.failoverHosts)||[]},H=new xs.Player(pe,se.Tracer.createRootTracer());H.initVideo(X);let De=null;if(S!=null&&S.videos&&(i!=null&&i.options.createOneStat)){let Ue=S.videos[0],Rt=i.options.createOneStat(Ue),Br=new se.Subscription;Rt&&(Br.add(Rt.attachTo(H)),De={oneStat:Rt,statSubscription:Br})}let Lr=new se.Subscription,Ws=(_r=t==null?void 0:t.player)==null?void 0:_r.info.isAutoQualityEnabled$.getValue();Lr.add(H.events.canplay$.subscribe(function(){Ws||_e(H,t.player.info.currentQuality$.getValue()),M&&H.setPlaybackRate(M)}));let ue=e.createPlayer({listId:x.id,itemId:R,player:H,container:k,sources:Pr(x,T).sources,config:X,subscription:Lr,statistics:De});return p&&a(x.id,ue.itemId,g),m&&ue.player.play(),u&&!m&&ue.player.prepare(),{player:ue.player,config:ue.config,statistics:ue.statistics}}function y(){E(),i=null,s.remove()}function E(){i==null||i.off(f.chapterChanged,v),e.removeAll(),t={},n=!1}async function w(){if(!i)throw Error("need to set interactive controller");E(),s=document.createElement("div");let{media:x,chapter:g}=i.getCurrentChapter();x&&g?(i.on(f.chapterChanged,v),await C({media:x,chapterId:g.id,title:g.label})):console.error("not found")}return{...e,init:w,setInteractiveController:o,createPlayer:C,removeAll:y,getActivePlayer:function(){return t},activePlayerChanged:l}}var f={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},be={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},P={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Ts=require("@vkontakte/videoplayer-shared");var Et=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:s,globalEventEmitter:l,ignoreContainerEvent:o,permanentTextControls:a,disabledControls$:c,onRemove:v}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(ie(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.globalEventEmitter.emit(f.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:!1})))})};this.show=()=>{var e,t,i,n;if(this.gameState===2&&!this.isSelectedControlEvent)if(this.container.getElement())(n=(i=this.container).show)==null||n.call(i),this.globalEventEmitter.emit(f.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:!0,isFirst:!1});else{let l=bs(this.selectBranches.onControlEvent,{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(f.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:!1})},onEvent:(o,a)=>{this.isSelectedControlEvent=!0,o!==!1&&(this.removeView(),this.globalEventEmitter.emit(f.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:!1})),(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),a(),this.removeView(),this.globalEventEmitter.emit(f.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:!1}))},isEOV:()=>this.gameState===4});this.container.createView(l),this.globalEventEmitter.emit(f.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((t=(e=this.container).disable)==null||t.call(e))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var a;let e=this.player.experimental.element$.getValue(),i=e instanceof HTMLVideoElement?e.readyState:void 0,n=[6,5];if(!i||n.includes(this.gameState)&&!this.isPermanentText)return;let s=this.player.getExactTime();if(gs(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Sr(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let c=this.gameState;this.gameState=3,c===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let l=Sr(s,this.container.container),o=this.container.container.startTime?[this.container.container.startTime,(a=this.container.container.endTime)!=null?a:1/0]:[];this.globalEventEmitter.emit(f.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:o,currentTime:s,isInteractiveTime:l})};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Ts.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=o,this.isPermanentText=a&&Ct(t.container.controls),this.disabledControls$=c,this.onRemove=v,this.globalEventEmitter=l,this.gameState=0,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}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 t;this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,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((t=this.container.container.endTime)!=null?t:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=ie(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.globalEventEmitter.emit(f.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(f.interactives,{subjectId:this.container.container.id,subjectName:"container",type:P.containerRemoved,visibility:!1}),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 Ss=(r=[])=>r.reduce((e,t,i)=>{var s,l,o;let n=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!Le(a));if(bt(n)){let a=[(l=t.startTime)!=null?l:0,(o=t.endTime)!=null?o:1/0],c=t.id;if(!i)e.push({subjects:[c],range:a});else{let v=[],C=-1/0,y=1/0,E=[],w=[];for(let x=0;x<e.length;x++){let g=e[x];if(w.push(...g.subjects),g.range[0]<y&&(y=g.range[0]),g.range[1]>C&&(C=g.range[1]),a[0]>=g.range[0]&&a[1]<=g.range[1])return e[x].subjects.push(c),e;a[0]<g.range[0]&&a[1]>g.range[0]&&(v.push(x),E=E.concat(g.subjects)),a[0]>=g.range[0]&&a[0]<=g.range[1]&&(v.push(x),E=E.concat(g.subjects),a[0]=g.range[0]),a[1]>=g.range[0]&&a[1]<=g.range[1]&&(v.push(x),E=E.concat(g.subjects),a[1]=g.range[1])}if(w.push(c),a[0]<=y&&a[1]>=C)return[{subjects:w,range:a}];v.length&&v.reverse().forEach(x=>{e.splice(x,1)}),e.push({subjects:E.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);function ws(){let r={};function e(){for(let o in r)Object.prototype.hasOwnProperty.call(r,o)&&delete r[o]}function t(o){let a={};for(let c in r)+c<=o&&(a[c]=r[c]);return a}function i(o){let a={};for(let c in r)+c>=o&&(a[c]=r[c]);return a}function n({timestamp:o,priority:a,initiator:c}){var v;if(gr(o)){let C=(v=r[o])!=null?v:null;if(C&&a&&ke(a,!0)){let y={},E=C[a];if(E&&(y={...y,...E}),y=re(y)?null:y,y&&ke(c,!0)){let w=y[c];return w!=null?w:null}return y}return C}return null}function s({timestamp:o,priority:a,initiator:c}){if(gr(o))if(r[o]){if(a&&ke(a,!0))if(r[o][a]){if(c&&ke(c,!0))if(r[o][a][c]){if(delete r[o][a][c],!re(r[o][a]))return!0}else return!1;if(delete r[o][a],!re(r[o]))return!0}else return!1;return delete r[o]}else return!1;return!1}function l({timestamp:o,priority:a,initiator:c,...v}){var C,y,E;(y=(C=r[o])==null?void 0:C[a])!=null&&y[c]?r[o][a][c].push({...v}):(E=r[o])!=null&&E[a]?r[o][a]={...r[o][a],[c]:[{...v}]}:r[o]?r[o]={...r[o],[a]:{[c]:[{...v}]}}:r[o]={[a]:{[c]:[{...v}]}}}return{map:r,remove:s,add:l,removeAll:e,get:n,getLte:t,getGte:i}}var Pl=[b.EventActionTypes.expect,b.EventActionTypes.setNextBranch],Rl=1/0;function As(r){let e=r,t,i=Ml(),n=ws(),s,l=()=>{y(),u()},o=p=>{n.add.call(void 0,p),w()},a=(p=[])=>{for(let m of p)if(m.action(),Pl.includes(m.actionType))break},c=(p=1/0)=>{var M,R,k;let m=It((M=n.get({timestamp:p,priority:"control"}))!=null?M:{}),T=It((R=n.get({timestamp:p,priority:"container"}))!=null?R:{}),d=It((k=n.get({timestamp:p,priority:"chapter"}))!=null?k:{});return[...m,...T,...d]},v=p=>{i.isReady(p)&&a(c(p))},C=()=>{var p;a([...It((p=n.get({timestamp:1/0,priority:"chapter"}))!=null?p:{})])},y=()=>{t&&(s==null||s.unsubscribe(),t=void 0)},E=p=>{},w=()=>{t||(t=()=>setTimeout(()=>{v(1/0)}),s=e.events.ended$.subscribe(t))},x=p=>{y(),e=p},g=p=>{p.priority==="container"&&i.resetCalled(p.timestamp),n.remove(p)},u=()=>{i.release(),n.removeAll()};return{setPlayer:x,add:o,remove:g,exec:v,execEndOfVideo:C,listen:w,unlisten:y,release:l,containersEventsCallState:i,getPreparedToExecActions:c}}function Ml(){let r=new Map;return{setCalled:({timestamp:l,id:o})=>{let a=r.get(l);a&&a[o]!==void 0&&(a[o]=!0)},setData:(l=[])=>{var o,a;for(let c of l){let v=(o=c.endTime)!=null?o:Rl,C=(a=r.get(v))!=null?a:{};r.set(v,{...C,[c.id]:!1})}},resetCalled:l=>{let o=r.get(l);if(o)for(let a in o)o[a]=!1},isReady:l=>{let o=r.get(l);return o?!Object.values(o).some(a=>!a):!0},release:()=>r.clear()}}function It(r){return Object.values(r).flat().sort(e=>e.actionType===b.EventActionTypes.expect?-1:1)}var Ps={videoContentHeight:0,videoContentWidth:0},Rs=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return Ps;let{clientHeight:n,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(n&&s))return Ps;let l=t/i,o=n/s,a,c;return o>l?(c=s,a=s*l):o<l?(c=n/l,a=n):(c=s,a=n),{videoContentWidth:c,videoContentHeight:a}};var kl=250;function Ms(r){let e=()=>{},t=new ResizeObserver(o=>{s(o),e=s.bind(null,o)});function i(o){let{parentElement:a,player:c}=r();if(a&&c){let{videoContentWidth:v,videoContentHeight:C}=Rs(a,c);a.style.setProperty("--interactive-content-width",`${v}px`),a.style.setProperty("--interactive-content-height",`${C}px`),a.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function n(){let{parentElement:o}=r();o.removeAttribute("style")}let s=Re(o=>{let{fns:a=[]}=r();i(o);for(let c of a)c()},kl);function l(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:l}}var Be=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 Vl=r=>Math.floor(Math.random()*r),Vs=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let s=r[e],l=(n=s.weight)!=null?n:1;l<t&&(t=l,i=s)}return i},Os=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let s=r[e],l=(n=s.weight)!=null?n:0;l>t&&(t=l,i=s)}return i};var Ls=r=>{let e=r.length,t=Vl(e);return r[t]},ks=1,js=r=>{var i,n;let e=0;for(let s=0;s<r.length;++s)e+=(i=r[s].weight)!=null?i:ks;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(n=r[s].weight)!=null?n:ks,e>=t)return r[s];return r[r.length-1]};var Fs={shouldOpenNow:!0,isDetachContainer:!0};var Mr=(r,e=!1)=>({...r,args:e?{...r.args,...Fs}:{...Fs,...r.args}}),_s=({globalEventEmitter:r,player:e,interactiveEvents:t,removeControllers:i})=>{let n={isExpect:!1},s=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:u,controlType:p,controlId:m,containerId:T,branches:d=[],onEvent:M,isEOV:R=()=>!1,isDisabled:k=()=>!1})=>{let S=Mr(u,R()),O={timestamp:1/0,priority:"control",initiator:m,actionType:S.type},pe=k(),X=r.emit.bind(r,f.interactives,{subjectId:m,subjectType:p,subjectName:"control",type:pe?P.actionChoiceCanceled:P.actionChoice,actionType:u.type,payload:{containerId:T,...S.args}});if(pe){X();return}switch(S.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let H=d.find(De=>De.id===S.args.branchId);if(!H)return;M(S.args.isDetachContainer,y.bind(null,{subjectId:m,subjectName:"control"})),X(),S.args.shouldOpenNow?w({subjectId:m,subjectName:"control",subjectType:p,action:S,payload:{chapterId:H.chapterId,autoSelect:!1}}):(t.add({...O,action:w.bind(null,{subjectId:m,subjectName:"control",subjectType:p,action:S,payload:{chapterId:H.chapterId,autoSelect:!1}})}),i==null||i());return}case b.EventActionTypes.continuePlayback.trim().toLowerCase():{M(S.args.isDetachContainer,y.bind(null,{subjectId:m,subjectName:"control"})),X(),S.args.shouldOpenNow?E({subjectId:m,subjectName:"control",subjectType:p,action:u}):t.add({...O,action:E.bind(null,{subjectId:m,subjectName:"control",subjectType:p,action:u})});return}case b.EventActionTypes.openURI.trim().toLowerCase():{M(S.args.isDetachContainer,y.bind(null,{subjectId:m,subjectName:"control"})),X(),S.args.shouldOpenNow?g({subjectId:m,subjectName:"control",subjectType:p,action:S,payload:{URI:u.args.uri}}):(t.add({...O,action:g.bind(null,{subjectId:m,subjectName:"control",subjectType:p,action:S,payload:{URI:u.args.uri}})}),i==null||i());return}default:console.error("Unexpected control event"),r.emit(f.errors,new L(1,1,{message:"Unexpected control event"}));return}},o=({action:u,container:{id:p,endTime:m},branches:T=[],isEOV:d=!1,autoSelected:M=!1})=>{let R=Mr(u,d),k={timestamp:!R.args.shouldOpenNow||d?1/0:m!=null?m:1/0,priority:"container",initiator:p,actionType:R.type},S=r.emit.bind(r,f.interactives,{subjectId:p,subjectName:"container",type:P.actionChoice,actionType:R.type,payload:R.args});switch(R.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let O=T.find(pe=>pe.id===R.args.branchId);if(!O)return;S(),t.add({...k,action:w.bind(null,{subjectId:p,subjectName:"container",action:R,payload:{chapterId:O.chapterId,autoSelect:M}})}),i==null||i();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():{S(),t.add({...k,action:E.bind(null,{subjectId:p,subjectName:"container",action:R})});return}case b.EventActionTypes.openURI.trim().toLowerCase():{S(),t.add({...k,action:g.bind(null,{subjectId:p,subjectName:"container",action:R,payload:{URI:u.args.uri}})}),i==null||i();return}default:console.error("Unexpected container event"),r.emit(f.errors,new L(1,1,{message:"Unexpected container event"}));return}};function a({container:u,branches:p,isEOV:m=!1}){var d,M;let T=wr(u.events);if(T){let R=Mr(T.action,m);r.emit(f.interactives,{subjectId:u.id,subjectName:"container",type:P.actionChoice,actionType:R.type,payload:R.args}),t.add({timestamp:m?1/0:(d=u.endTime)!=null?d:1/0,priority:"container",initiator:u.id,actionType:b.EventActionTypes.expect,action:C.bind(null,{subjectId:u.id,subjectName:"container"})}),n.isExpect=!0}else for(let R of(M=u.events)!=null?M:[])o({action:R.action,container:u,branches:p,isEOV:m})}let c=({chapterId:u,action:p,branches:m=[]})=>{let T=r.emit.bind(r,f.interactives,{subjectId:u,subjectName:"chapter",type:P.actionChoice,actionType:p.type,payload:p.args});switch(p.type.trim().toLowerCase()){case b.EventActionTypes.setNextBranch.trim().toLowerCase():{let d=m.find(M=>M.id===p.args.branchId);return d!=null&&d.chapterId?(T(),w.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:d.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let d=Ls(m);return d!=null&&d.chapterId?(T(),w.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:d.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setRandomBranch.trim().toLowerCase():{let d=js(m);return d!=null&&d.chapterId?(T(),w.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:d.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let d=Os(m);return d!=null&&d.chapterId?(T(),w.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:d.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let d=Vs(m);return d!=null&&d.chapterId?(T(),w.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{chapterId:d.chapterId,autoSelect:!0}})):void 0}case b.EventActionTypes.continuePlayback.trim().toLowerCase():return T(),E.bind(null,{subjectId:u,subjectName:"chapter",action:p});case b.EventActionTypes.openURI.trim().toLowerCase():return T(),g.bind(null,{subjectId:u,subjectName:"chapter",action:p,payload:{URI:p.args.uri}});default:console.error("Unexpected chapter event"),r.emit(f.errors,new L(1,1,{message:"Unexpected chapter event"}));return}};function v(u){var m;let p=wr(u.events);if(p){if(B(u))return;r.emit(f.interactives,{subjectId:u.id,subjectName:"chapter",type:P.actionChoice,actionType:p.action.type,payload:p.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:b.EventActionTypes.expect,action:C.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else(m=u.events)==null||m.forEach(T=>{let d=c({chapterId:u.id,action:T.action,branches:u.branches});d&&t.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:T.action.type,action:d})})}let C=({subjectId:u,subjectName:p})=>{e.pause(),r.emit(f.interactives,{subjectId:u,subjectName:p,type:P.actionExecution,actionType:b.EventActionTypes.expect})},y=({subjectId:u,subjectName:p})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),r.emit(f.interactives,{subjectId:u,subjectName:p,type:P.actionExecution,actionType:"after-expect"})},E=({subjectId:u,subjectName:p,subjectType:m,action:T})=>{r.emit(f.interactives,{subjectId:u,subjectName:p,subjectType:m,type:P.actionExecution,actionType:T.type})},w=({subjectId:u,subjectName:p,subjectType:m,action:T,payload:d})=>{d.behaviour="change-chapter",r.emit(f.interactives,{subjectId:u,subjectName:p,subjectType:m,type:P.actionExecution,actionType:T.type,payload:d})},x=({subjectId:u,subjectName:p,subjectType:m,action:T,payload:d})=>{d.behaviour="change-manifest",r.emit(f.interactives,{subjectId:u,subjectName:p,subjectType:m,type:P.actionExecution,actionType:T.type,payload:d})},g=({subjectId:u,subjectName:p,subjectType:m,action:T,payload:d})=>{if(!d.URI)return;let M=window.open(d.URI,"_blank","noopener,noreferrer");M&&(M.opener=null),r.emit(f.interactives,{subjectId:u,subjectName:p,subjectType:m,type:P.actionExecution,actionType:T.type})};return{onControlEvent:l,onContainerEvent:o,onChapterEvent:c,onExpectEvent:C,expectEventHandler:y,setManifestChapterEvents:v,setManifestContainerEvents:a,stopExpect:s,state:n}};var Or=Mt(vr(),1),Z=require("@vkontakte/videoplayer-shared");var xt=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(l=>l.id===i);if(!n)return null;let s=e.media.videos.find(l=>n.videoId===l.id);if(!s)return null;t[i]=kr(s)}return t[i]}).filter(Boolean)},Bs=r=>{for(let e of r.variants)if(qs(e)&&"payload"in e)return e.payload.id},qs=r=>r.type==="custom"&&"payload"in r&&r.payload.type==="vk",kr=r=>{let e=Bs(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},Hs=(r,e)=>{for(let t of r.media.videos)if(e===kr(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},Vr=(r,e)=>r.reduce((t,i)=>{let n=Hs(e,i);return n?[...t,n]:t},[]);var G,ae,oe,$,Tt,z,W,q,le,Ce,Ee,qe=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new Z.ValueSubject([]),hasPrevChapter$:new Z.ValueSubject(!1),prevChapter$:new Z.ValueSubject(null),isInitialChapter$:new Z.ValueSubject(!1),isGoBackLimited$:new Z.ValueSubject(!1)};j(this,G,null);j(this,ae);j(this,oe,!1);j(this,$,null);j(this,Tt,null);j(this,z,null);j(this,W,null);j(this,q,null);j(this,le,new Z.Subscription);j(this,Ce,!1);j(this,Ee,0);var l;V(this,z,t),V(this,q,e),V(this,W,i),V(this,G,n),V(this,ae,s),this.state.history$&&I(this,le)&&((l=I(this,le))==null||l.add(this.state.history$.subscribe(o=>{var a,c;this.state.prevChapter$.next((0,Or.default)(o,-2)||null),this.state.hasPrevChapter$.next(o.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(a=I(this,$))==null?void 0:a.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(I(this,Ee)===I(this,ae).maxLength-1)})))}async setManifest(e){!I(this,W)||!I(this,q)||(V(this,$,e),await this.getProjectHistory(),await I(this,W).setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),I(this,oe)||(V(this,oe,!0),I(this,q).emit(f.historyInited,{initChapterId:this.getInitialChapterId()})))}get inited(){return I(this,oe)}async updateHistory(e,t=!0){var o;if(!I(this,$))return;I(this,Ce)?(V(this,Ce,!1),Dr(this,Ee)._++):V(this,Ee,0);let i=I(this,$),n=e.length-I(this,ae).maxLength,s=n>0?e.slice(n):e,l=xt(s,i);if(V(this,Tt,l),this.state.history$.next(s),!(!t||!I(this,G)||!I(this,z)))try{await I(this,G).save(I(this,z),l)}catch(a){(o=I(this,q))==null||o.emit(f.errors,new L(1,5,"Unable to save interactive history"))}}async goBack(){var i;if(!this.state||!I(this,W))return(i=I(this,q))==null?void 0:i.emit(f.errors,new L(1,5,"Cannot go back because HistoryController has not been initialized"));V(this,Ce,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await I(this,W).setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){var n;if(!I(this,$)||!I(this,z))return;let e=I(this,$),t=[this.getInitialVideoId()];if(I(this,G))try{let s=await I(this,G).get(I(this,z));s.length&&(t=s)}catch(s){(n=I(this,q))==null||n.emit(f.errors,new L(1,5,"Error while trying to fetch data"))}let i=Vr(t,e);this.state.history$.next(i)}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,Or.default)(e,-1)||I(this,ae).initChapterId||((t=I(this,$))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(I(this,$)){let e=this.getInitialChapterId();return xt([e],I(this,$)).pop()}return null}destroy(){var e,t;V(this,z,null),V(this,G,null),V(this,W,null),(e=I(this,le))==null||e.unsubscribe(),V(this,le,null),V(this,oe,!1),(t=I(this,q))==null||t.emit(f.historyDestroyed),V(this,q,null)}};G=new WeakMap,ae=new WeakMap,oe=new WeakMap,$=new WeakMap,Tt=new WeakMap,z=new WeakMap,W=new WeakMap,q=new WeakMap,le=new WeakMap,Ce=new WeakMap,Ee=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(l=>!i.has(l));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 St=ce;var wt=class{constructor(){this.bindingMap=new Be}release(){this.removeAll(),this.bindingMap=null}listen(e,t,i,n){if(!this.bindingMap)return;let s=new St(e,t,i,n);this.bindingMap.push(t,s)}listenOnce(e,t,i,n){let s=l=>{this.unlisten(e,t,s),i(l)};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 At=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))}async updateCanvasDimensions(e,t=!1){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;t&&(n=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&n&&this.restore(n),this._prevSizeId=i}async save(){let e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var Pt=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 At,this.endOffsetMs=t,this._callbacks={onError:i},this.lastFrameCanvas.rootElement.style.cssText=`
|
|
15
15
|
position: absolute;
|
|
16
16
|
top: 50%;
|
|
17
17
|
left: 50%;
|
|
18
18
|
transform: translate(-50%, -50%);
|
|
19
|
-
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),i={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(i,e)}catch(n){this._onError(n)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var i,n,s;return((i=t.controls)==null?void 0:i.length)&&e>=((n=t.startTime)!=null?n:0)&&e<=Math.min((s=t.endTime)!=null?s:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,i;(i=(t=this._callbacks)==null?void 0:t.onError)==null||i.call(t,e)}};function
|
|
19
|
+
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),i={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(i,e)}catch(n){this._onError(n)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var i,n,s;return((i=t.controls)==null?void 0:i.length)&&e>=((n=t.startTime)!=null?n:0)&&e<=Math.min((s=t.endTime)!=null?s:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,i;(i=(t=this._callbacks)==null?void 0:t.onError)==null||i.call(t,e)}};function Ds(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var Us=Object.freeze({lang:A.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function Ll(){let r=document.createElement("div");return r.style.cssText=`
|
|
20
20
|
position: absolute;
|
|
21
21
|
top: 0;
|
|
22
22
|
left: 0;
|
|
23
|
-
`,r}var me,W,ye,U,oe,q,K,ce,O,le,ze,D,ve,$,M,ge,be,V,Aa,rr,La,tr,ui,ir,Oa,li,Ae,dt,Na,hi,ka,Pa,nr,mt,ft=class{constructor(e){S(this,V);S(this,me,null);S(this,W,null);S(this,ye,null);S(this,U,null);S(this,oe,null);S(this,q,null);S(this,K,null);S(this,ce,null);S(this,O,null);S(this,le,new L.ValueSubject(!1));S(this,ze,new Set);S(this,D,null);S(this,ve,null);S(this,$,null);S(this,M,null);S(this,ge,new Xe);S(this,be,null);te(this,"state",{prevChapter$:new L.ValueSubject(null),isInitialChapter$:new L.ValueSubject(!1),isFirstChapter$:new L.ValueSubject(!0),isEndChapter$:new L.ValueSubject(!1),isInteractiveExpectation$:new L.ValueSubject(!1),calledByInteractive$:new L.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new L.ValueSubject(!1),disabledControls$:new L.ValueSubject(!1),interactiveRanges$:new L.ValueSubject([]),isInteractiveTime$:new L.ValueSubject(!1),statistics$:new L.ValueSubject(null)});te(this,"events",{noInteraction$:new L.Subject});te(this,"clearHistoryIfEnded",()=>{var n;let e=(n=this.options.player)==null?void 0:n.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:i}=this.getCurrentChapter();e&&Y(i)&&!t&&a(this,U).updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)});S(this,rr,({statistics:e,...t})=>{if(e){let{statSubscription:i,oneStat:n}=e;i.add(n.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(e)}a(this,M).emit(E.playerChanged,t)});S(this,ui,()=>{a(this,K).fns.forEach(i=>i());let e=this.options.player.info.position$.getValue()*1e3,t=(a(this,O).chapter.containers||[]).filter(i=>i.startTime>=Math.floor(e));for(let i of t){a(this,q).remove({timestamp:1/0,priority:"container",initiator:i.id});for(let n of i.controls)a(this,q).remove({timestamp:1/0,priority:"control",initiator:n.id});a(this,W).find(n=>n.container.container.id===i.id).reset()}});S(this,ir,()=>{a(this,me).calc(),a(this,K).requestAnimation()});S(this,Ae,(e=!0)=>{a(this,W).forEach(t=>{!e&&t.isPermanentText||(a(this,K).removeFn(t.whilePlaying),t.destroy())})});S(this,nr,e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(s=>({...s,subjects:s.subjects.filter(l=>l!==e)}));t.next(n)});S(this,mt,()=>{a(this,be)&&(clearTimeout(a(this,be)),b(this,be,null))});var t;this.options={...Ma,...e,config:{...Ma.config,...e.config}},b(this,W,[]),this.factories=new Map([["choice",_t]]),this.rootElement=Ol(),this.options.parentElement.append(this.rootElement),b(this,M,new Pe),b(this,oe,new L.Subscription),b(this,ye,new Xt),b(this,U,new pt({interactiveController:this,globalEventEmitter:a(this,M),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&&b(this,$,new er({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:i=>a(this,M).emit(E.errors,new G(1,6,i))})),a(this,ye).listen(this.rootElement,"mousedown",i=>i.stopPropagation()),a(this,ye).listen(this.rootElement,"mouseup",i=>i.stopPropagation()),b(this,O,new Se(this.options.loaders,i=>a(this,M).emit(E.errors,new G(1,3,i)))),b(this,q,Sr(this.options.player)),b(this,K,new Ot),b(this,ce,_r({player:this.options.player,interactiveEvents:a(this,q),globalEventEmitter:a(this,M),removeControllers:a(this,Ae)})),b(this,me,sn(()=>{var i,n,s;return{player:(i=this.options)==null?void 0:i.player,parentElement:(n=this.options)==null?void 0:n.parentElement,fns:(s=this.options)!=null&&s.lastFrame?[()=>{a(this,$).updateCanvasDimensions(!0)}]:[]}})),this.options.graph&&b(this,D,new Ze({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),a(this,M).emit(E.graph,{type:Fe.watchAgainClicked,chapterId:i})},onError:i=>a(this,M).emit(E.errors,new G(1,4,{message:i}))})),N(this,V,Aa).call(this),this.isFirstChapterFetched=!1,this.appState=ae.created}getStatEvents(){return{click$:new L.Observable(e=>{a(this,M).on(E.graph,({type:t,visibility:i})=>{t==="visibility"&&e.next(i?Ue.InteractiveInterfaceClick.GRAPH_SHOW:Ue.InteractiveInterfaceClick.GRAPH_HIDE),t==="watchAgainClicked"&&e.next(Ue.InteractiveInterfaceClick.WATCH_AGAIN)}),a(this,M).on(E.interactives,({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(Ue.InteractiveInterfaceClick.NEXT_BUTTON),n==="Area"&&e.next(Ue.InteractiveInterfaceClick.NEXT_AREA))})}),nextMovie$:new L.Observable(e=>{a(this,M).on(E.playerChanged,({config:t})=>{t!=null&&t.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}setPlayer(e){N(this,V,tr).call(this),this.options.player=e,a(this,ge).setPlayer(this.options.player),a(this,q)?a(this,q).setPlayer(this.options.player):b(this,q,Sr(this.options.player)),b(this,ce,_r({player:this.options.player,interactiveEvents:a(this,q),globalEventEmitter:a(this,M),removeControllers:()=>a(this,Ae).call(this,!1)})),this.appState===ae.initiated&&(N(this,V,li).call(this),N(this,V,dt).call(this,a(this,O).chapter))}async setManifest(e){N(this,V,tr).call(this),this.isFirstChapterFetched=!1;let t=await a(this,O).setManifest(e);return a(this,D)&&await a(this,D).handleManifestChange(t.manifest),await a(this,U).setManifest(t.manifest),a(this,M).emit(E.manifestChanged,{manifest:t.manifest}),N(this,V,dt).call(this,a(this,O).chapter),t.manifest}setVisitedChapters(e){var t;Array.isArray(e)&&((t=a(this,D))==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=a(this,D))==null||t.updateVideosInfo(e))}async setChapter({chapterId:e,pushToHistory:t=!0}={}){var c;N(this,V,tr).call(this),a(this,$)&&this.isFirstChapterFetched&&(a(this,$).draw(),a(this,$).show()),L.clientChecker.isSafari&&await Va(35);let i=this.state.isEndChapter$.getValue()&&this.getCurrentManifest().metadata.initChapterId===e,{chapter:n,media:s,graph:l}=await(e?a(this,O).setNext(e):a(this,O).setInitial());return(!e||i)&&this.state.isFirstChapter$.next(!0),t&&N(this,V,Pa).call(this,n.id),this.state.isInitialChapter$.next(a(this,O).isInitialChapter()),this.state.isEndChapter$.next(a(this,O).isEndChapter()),a(this,D)&&a(this,D).handleChapterChange(l),(c=a(this,$))==null||c.setCurrentChapter(this.getCurrentChapter().chapter),a(this,M).emit(E.chapterChanged,{chapter:n,media:s,graph:l}),N(this,V,dt).call(this,a(this,O).chapter),b(this,ze,new Set),this.isFirstChapterFetched=!0,{chapter:n,media:s,graph:l}}toggleGraphView(e=!0){a(this,D)&&(e?(a(this,D).show(),a(this,le).next(!1)):(a(this,D).hide(),N(this,V,hi).call(this)),a(this,M).emit(E.graph,{type:Fe.visibility,visibility:e}))}init(){a(this,O).chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.appState===ae.created&&(a(this,me).resizeObserver.observe(this.options.fullscreenTargetElement),N(this,V,li).call(this),this.appState=ae.initiated,N(this,V,dt).call(this,a(this,O).chapter))}deadEndCheck(){var i,n;return!((n=(i=a(this,q))==null?void 0:i.getPreparedToExecActions())!=null?n:[]).some(s=>s.actionType===A.setNextBranch)}allControlsAreRemoved(){return!a(this,W).some(t=>!t.container.isRemoved)}isEndedExpectation(){var i;if(!((i=this.options)!=null&&i.player)||!a(this,W))return!1;let e=this.options.player.info.position$.getValue(),t=this.options.player.info.duration$.getValue();return e===t&&a(this,W).some(n=>{let s=n.container.container;return!s.isRemoved&&s.endTime===null&&Te(s.events)})}playPrevChapter(){var e;(e=a(this,U))==null||e.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=a(this,O).manifest){return Je(e.metadata.version)}getInitialVideoInfo(){return{videoId:a(this,U).getInitialVideoId(),chapterId:a(this,U).getInitialChapterId()}}getHistoryState(){return a(this,U).state}getIsSeekable(){return a(this,le)}getInteractiveRanges(){var e;return en((e=a(this,O).chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return a(this,ge).getNextInteractiveTime(e)}getChapterBranches(e){return a(this,O).getBranches(e)}getCurrentChapter(){return a(this,O).getCurrent()}getCurrentManifest(){return a(this,O).manifest}addFactory(e,t){this.factories.set(e.trim().toLowerCase(),t)}removeFactory(e){this.factories.delete(e.trim().toLowerCase())}on(...e){return a(this,M).on(...e),this}off(...e){return a(this,M).off(...e),this}once(...e){return a(this,M).once(...e),this}destroy(){var e,t,i;this.clearHistoryIfEnded(),a(this,Ae).call(this),b(this,W,void 0),this.state=void 0,(e=a(this,D))==null||e.destroy(),b(this,D,void 0),(t=a(this,ve))==null||t.removeAll(),b(this,ve,void 0),a(this,me).release(),b(this,me,void 0),b(this,ce,void 0),a(this,K).release(),b(this,K,void 0),a(this,q).release(),b(this,q,void 0),a(this,O).release(),b(this,ce,void 0),a(this,ye).release(),b(this,ye,void 0),a(this,oe).unsubscribe(),b(this,oe,void 0),a(this,M).reset(),b(this,M,void 0),(i=a(this,$))==null||i.destroy(),b(this,$,void 0),this.rootElement.remove(),this.rootElement=void 0,a(this,U).destroy(),b(this,U,void 0),this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.appState=ae.destroyed}};me=new WeakMap,W=new WeakMap,ye=new WeakMap,U=new WeakMap,oe=new WeakMap,q=new WeakMap,K=new WeakMap,ce=new WeakMap,O=new WeakMap,le=new WeakMap,ze=new WeakMap,D=new WeakMap,ve=new WeakMap,$=new WeakMap,M=new WeakMap,ge=new WeakMap,be=new WeakMap,V=new WeakSet,Aa=function(){a(this,M).on(E.historyInited,async({videosInfo:e=[]})=>{this.options.initSeamless&&(await N(this,V,La).call(this),this.updateGraphVideosInfo(e))}),a(this,M).on(E.interactives,async e=>{var t,i;if(e.type===R.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:s}=e.payload;this.setChapter({chapterId:s}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:s}=e.payload;this.setManifest(s)}let n=e.type==="action-execution";n&&e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):n&&e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)}e.type===R.containerRemoved&&a(this,nr).call(this,e.subjectId)}),a(this,M).on(E.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})},rr=new WeakMap,La=async function(){b(this,ve,Tr(this)),a(this,ve).on(qt.activePlayerChanged,a(this,rr)),a(this,ve).init()},tr=function(){var e;this.appState===ae.ready&&(a(this,Ae).call(this),b(this,W,[]),a(this,K).release(),(e=a(this,q))==null||e.release(),this.appState=ae.initiated,a(this,le).next(!1),a(this,mt).call(this))},ui=new WeakMap,ir=new WeakMap,Oa=function(e){(!a(this,D)||a(this,D).isHidden)&&N(this,V,hi).call(this);let t=e*1e3,n=this.getInteractiveRanges().findLast(({range:s})=>t>=s[1]);if(n){let s=n.range.join("-");a(this,ze).has(s)||(a(this,ze).add(s),a(this,M).emit(E.interactives,{type:R.rangeEnded,payload:n,visibility:!0}))}},li=function(){window.removeEventListener("beforeunload",this.clearHistoryIfEnded),a(this,oe).unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),a(this,oe).add(this.options.player.events.started$.pipe((0,L.once)()).subscribe(a(this,ir))).add(this.options.player.events.playing$.subscribe(a(this,K).requestAnimation)).add(this.options.player.events.willPause$.subscribe(a(this,K).cancelAnimation)).add(this.options.player.info.position$.subscribe(N(this,V,Oa).bind(this))).add(a(this,O).prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,L.combine)({position:this.options.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:i})=>{let n;if(i)n=!0;else{let o=e*1e3;n=!!(t==null?void 0:t.find(({range:[d,f],subjects:y})=>d<o&&o<f&&y.length))}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let s=a(this,be)!==null,c=this.options.player.info.playbackState$.getValue()==="playing"||i;n&&!s&&c?b(this,be,setTimeout(()=>{this.events.noInteraction$.next()},this.options.config.noInteractionEventTimeout)):s&&!c&&a(this,mt).call(this)})),this.options.lastFrame&&a(this,oe).add(this.options.player.info.duration$.subscribe(e=>{a(this,$).setVideoDuration(e*1e3)})).add(this.options.player.experimental.element$.subscribe(e=>{e&&a(this,$).setVideoElement(e)})).add(this.options.player.events.firstFrame$.subscribe(()=>{a(this,$).reset(),setTimeout(()=>{a(this,$).hide(),a(this,$).lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(a(this,$).onSeek))},Ae=new WeakMap,dt=function(e){a(this,O).chapter&&this.appState===ae.initiated&&(a(this,ce).setManifestChapterEvents(e),b(this,W,N(this,V,Na).call(this,e)),a(this,q).containersEventsCallState.setData(e.containers),a(this,ge).setContainers(a(this,W).map(t=>t.container.container).filter(t=>!Bt(t.controls))),this.options.lastFrame&&a(this,K).addFn(()=>{a(this,$).onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=ae.ready)},Na=function(e){var t,i;return(i=(t=e==null?void 0:e.containers)==null?void 0:t.reduce((n,s)=>{let l=s.type.trim().toLowerCase(),c=this.factories.get(l);if(c){let o=new Dt({player:this.options.player,container:c(s,this.rootElement),branches:a(this,O).chapter.branches,selectBranches:a(this,ce),interactiveEvents:a(this,q),globalEventEmitter:a(this,M),ignoreContainerEvent:()=>Qi(s,a(this,W)),permanentTextControls:this.options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{a(this,ge).deleteContainer(s.id)}});return a(this,K).addFn(o.whilePlaying,!0),[...n,o]}return[...n]},[]))!=null?i:[]},hi=function(){if(this.state.isInteractiveExpectation$.getValue()){a(this,le).next(!1);return}let t=a(this,le).getValue(),i=!!a(this,ge).getNextInteractiveTime();(i&&!t||!i&&t)&&a(this,le).next(!t)},ka=function(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)},Pa=function(e){var c;if(N(this,V,ka).call(this),!a(this,U).inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(c=i&&Y(i)&&it(i))!=null?c:!1,s=a(this,O).manifest.metadata.initChapterId===e,l=a(this,U).state.history$.getValue();if(s||n&&t){a(this,U).updateHistory([e]);return}l.at(-1)!==e&&a(this,U).updateHistory([...l,e])},nr=new WeakMap,mt=new WeakMap;var ja={Container:ke,createChoiceContainer:_t,createAreaControl:xt,createButtonControl:St,createRelativeLayout:Mi,getRootEl:gt,classnamesPrefix:B};var Nl={version:Ti};
|
|
23
|
+
`,r}var He=class{constructor(e){this.subscription=new A.Subscription;this.globalEventEmitter=new ut;this.animation=new ht;this.eventManager=new wt;this.seekToInteractiveController=new Oe;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=Ll();this.factories=new Map([["choice",rt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new A.Subscription;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new A.ValueSubject(null),isInitialChapter$:new A.ValueSubject(!1),isFirstChapter$:new A.ValueSubject(!0),isEndChapter$:new A.ValueSubject(!1),isInteractiveExpectation$:new A.ValueSubject(!1),calledByInteractive$:new A.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new A.ValueSubject(!1),disabledControls$:new A.ValueSubject(!1),interactiveRanges$:new A.ValueSubject([]),isInteractiveTime$:new A.ValueSubject(!1),statistics$:new A.ValueSubject(null),isSeekable$:new A.ValueSubject(!1)};this.events={noInteraction$:new A.Subject,graphVisibilityChanged$:new A.Subject,watchAgainIsClicked$:new A.Subject};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&&B(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let{statistics:t,...i}=e;if(t){let{statSubscription:n,oneStat:s}=t;n.add(s.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.globalEventEmitter.emit(f.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=>({...s,subjects:s.subjects.filter(l=>l!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var t;this._options={...Us,...e,config:{...Us.config,...e.config}},this._options.parentElement.append(this.rootElement),this.historyController=new qe({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 Pt({parentElement:this._options.parentElement,onError:i=>this.globalEventEmitter.emit(f.errors,new L(1,6,i))})),this.eventManager.listen(this.rootElement,"mousedown",i=>i.stopPropagation()),this.eventManager.listen(this.rootElement,"mouseup",i=>i.stopPropagation()),this.manifestController=new ne(this._options.loaders,i=>this.globalEventEmitter.emit(f.errors,new L(1,3,i))),this.resizeManager=Ms(()=>{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 Ve({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(f.graph,{type:be.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>this.globalEventEmitter.emit(f.errors,new L(1,4,{message:i}))})),this.initSubscriptions()}initSubscriptions(){this.globalEventEmitter.on(f.historyInited,async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))}),this.globalEventEmitter.on(f.interactives,async e=>{var t,i;if(e.type===P.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:s}=e.payload;this.setChapter({chapterId:s}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:s}=e.payload;this.setManifest(s)}let n=e.type==="action-execution";n&&e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):n&&e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)}e.type===P.containerRemoved&&this.completeInteractiveRange(e.subjectId)}),this.globalEventEmitter.on(f.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})}async initSeamless(){this.seamlessController=Rr(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:s})=>t>=s[1]);if(n){let s=n.range.join("-");this.endedRanges.has(s)||(this.endedRanges.add(s),this.globalEventEmitter.emit(f.interactives,{type:P.rangeEnded,payload:n,visibility:!0}))}}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,A.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,A.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 c=e*1e3;n=!!t.find(({range:[C,y],subjects:E})=>C<c&&c<y&&E.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let s=!!this.noInteractionTimeout,o=((a=this.player)==null?void 0:a.info.playbackState$.getValue())==="playing"||i;n&&!s&&o?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):s&&!o&&this.clearNoInteractionTimeout()})),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=>!Ct(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);if(s){let l=new Et({player:this.player,container:s(i,this.rootElement),branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEventEmitter:this.globalEventEmitter,ignoreContainerEvent:()=>Cs(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 o,a;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(o=i&&B(i)&&$e(i))!=null?o:!1,s=((a=this.manifestController.manifest)==null?void 0:a.metadata.initChapterId)===e,l=this.historyController.state.history$.getValue();if(s||n&&t){this.historyController.updateHistory([e]);return}(0,Gs.default)(l,-1)!==e&&this.historyController.updateHistory([...l,e])}reset(){var e;this.appState===2&&(this.removeControllers(),this.gameControllers=[],this.animation.release(),(e=this.interactiveEvents)==null||e.release(),this.appState=1,this.state.isSeekable$.next(!1),this.clearNoInteractionTimeout())}get options(){return this._options}init(){var e;this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&((e=this.resizeManager)==null||e.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.globalEventEmitter.emit(f.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=As(this.player),this.selectBranches=_s({player:this.player,interactiveEvents:this.interactiveEvents,globalEventEmitter:this.globalEventEmitter,removeControllers:()=>this.removeControllers(!1)}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:i=!1}={}){var a,c;this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),A.clientChecker.isSafari&&await Ds(35);let n=!i&&this.state.isEndChapter$.getValue()&&((a=this.getCurrentManifest())==null?void 0:a.metadata.initChapterId)===e,{chapter:s,media:l,graph:o}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||n)&&this.state.isFirstChapter$.next(!0),s&&(t&&this.pushChapterToHistory(s.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(s),(c=this.lastFrame)==null||c.setCurrentChapter(s),this.globalEventEmitter.emit(f.chapterChanged,{chapter:s,media:l,graph:o}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new A.Observable(e=>{this.globalEventEmitter.on(f.graph,({type:t,visibility:i})=>{t==="visibility"&&e.next(i?Ie.InteractiveInterfaceClick.GRAPH_SHOW:Ie.InteractiveInterfaceClick.GRAPH_HIDE),t==="watchAgainClicked"&&e.next(Ie.InteractiveInterfaceClick.WATCH_AGAIN)}),this.globalEventEmitter.on(f.interactives,({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(Ie.InteractiveInterfaceClick.NEXT_BUTTON),n==="Area"&&e.next(Ie.InteractiveInterfaceClick.NEXT_AREA))})}),nextMovie$:new A.Observable(e=>{this.globalEventEmitter.on(f.playerChanged,({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(f.graph,{type:be.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&&ie(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 Ss((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.globalEventEmitter.reset(),(s=this.lastFrame)==null||s.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var zs={Container:de,createChoiceContainer:rt,createAreaControl:Ze,createButtonControl:Je,getRootEl:ze,classnamesPrefix:N};var jl={version:Ur};
|