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