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