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