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