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