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