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