@vkontakte/videoplayer-interactive 1.0.21 → 1.0.22-dev.71ddf25e.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.esm.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vkontakte/videoplayer-interactive v1.0.21
3
- * Fri, 04 Oct 2024 14:28:56 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-21/doc/
2
+ * @vkontakte/videoplayer-interactive v1.0.22-dev.71ddf25e.0
3
+ * Mon, 14 Oct 2024 11:34:11 GMT
4
+ * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-22/doc/
5
5
  */
6
- var aa=Object.create;var Nt=Object.defineProperty,oa=Object.defineProperties,la=Object.getOwnPropertyDescriptor,ca=Object.getOwnPropertyDescriptors,ua=Object.getOwnPropertyNames,Ke=Object.getOwnPropertySymbols,ha=Object.getPrototypeOf,jt=Object.prototype.hasOwnProperty,Qr=Object.prototype.propertyIsEnumerable;var Yr=r=>{throw TypeError(r)};var Ot=(r,e,t)=>e in r?Nt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,h=(r,e)=>{for(var t in e||(e={}))jt.call(e,t)&&Ot(r,t,e[t]);if(Ke)for(var t of Ke(e))Qr.call(e,t)&&Ot(r,t,e[t]);return r},E=(r,e)=>oa(r,ca(e));var N=(r,e)=>{var t={};for(var i in r)jt.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&Ke)for(var i of Ke(r))e.indexOf(i)<0&&Qr.call(r,i)&&(t[i]=r[i]);return t};var f=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var pa=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ua(e))!jt.call(r,n)&&n!==t&&Nt(r,n,{get:()=>e[n],enumerable:!(i=la(e,n))||i.enumerable});return r};var Zr=(r,e,t)=>(t=r!=null?aa(ha(r)):{},pa(e||!r||!r.__esModule?Nt(t,"default",{value:r,enumerable:!0}):t,r));var Se=(r,e,t)=>Ot(r,typeof e!="symbol"?e+"":e,t),Ft=(r,e,t)=>e.has(r)||Yr("Cannot "+t);var S=(r,e,t)=>(Ft(r,e,"read from private field"),t?t.call(r):e.get(r)),B=(r,e,t)=>e.has(r)?Yr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),O=(r,e,t,i)=>(Ft(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),_e=(r,e,t)=>(Ft(r,e,"access private method"),t);var Xr=(r,e,t,i)=>({set _(n){O(r,e,n,t)},get _(){return S(r,e,i)}});var _=(r,e,t)=>new Promise((i,n)=>{var s=a=>{try{o(t.next(a))}catch(c){n(c)}},l=a=>{try{o(t.throw(a))}catch(c){n(c)}},o=a=>a.done?i(a.value):Promise.resolve(a.value).then(s,l);o((t=t.apply(r,e)).next())});var W=f((zt,ai)=>{"use strict";var Le=function(r){return r&&r.Math===Math&&r};ai.exports=Le(typeof globalThis=="object"&&globalThis)||Le(typeof window=="object"&&window)||Le(typeof self=="object"&&self)||Le(typeof global=="object"&&global)||Le(typeof zt=="object"&&zt)||function(){return this}()||Function("return this")()});var te=f((iu,oi)=>{"use strict";oi.exports=function(r){try{return!!r()}catch(e){return!0}}});var Me=f((nu,li)=>{"use strict";var fa=te();li.exports=!fa(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var di=f((su,pi)=>{"use strict";var ma=Me(),hi=Function.prototype,ci=hi.apply,ui=hi.call;pi.exports=typeof Reflect=="object"&&Reflect.apply||(ma?ui.bind(ci):function(){return ui.apply(ci,arguments)})});var se=f((au,yi)=>{"use strict";var fi=Me(),mi=Function.prototype,Wt=mi.call,ya=fi&&mi.bind.bind(Wt,Wt);yi.exports=fi?ya:function(r){return function(){return Wt.apply(r,arguments)}}});var Kt=f((ou,gi)=>{"use strict";var vi=se(),va=vi({}.toString),ga=vi("".slice);gi.exports=function(r){return ga(va(r),8,-1)}});var Qt=f((lu,bi)=>{"use strict";var ba=Kt(),Ca=se();bi.exports=function(r){if(ba(r)==="Function")return Ca(r)}});var re=f((cu,Ci)=>{"use strict";var Yt=typeof document=="object"&&document.all;Ci.exports=typeof Yt=="undefined"&&Yt!==void 0?function(r){return typeof r=="function"||r===Yt}:function(r){return typeof r=="function"}});var ge=f((uu,Ei)=>{"use strict";var Ea=te();Ei.exports=!Ea(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ot=f((hu,Ii)=>{"use strict";var Ia=Me(),at=Function.prototype.call;Ii.exports=Ia?at.bind(at):function(){return at.apply(at,arguments)}});var Si=f(wi=>{"use strict";var xi={}.propertyIsEnumerable,Ti=Object.getOwnPropertyDescriptor,xa=Ti&&!xi.call({1:2},1);wi.f=xa?function(e){var t=Ti(this,e);return!!t&&t.enumerable}:xi});var Zt=f((du,_i)=>{"use strict";_i.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Mi=f((fu,Li)=>{"use strict";var Ta=se(),wa=te(),Sa=Kt(),Xt=Object,_a=Ta("".split);Li.exports=wa(function(){return!Xt("z").propertyIsEnumerable(0)})?function(r){return Sa(r)==="String"?_a(r,""):Xt(r)}:Xt});var Jt=f((mu,Ri)=>{"use strict";Ri.exports=function(r){return r==null}});var er=f((yu,Vi)=>{"use strict";var La=Jt(),Ma=TypeError;Vi.exports=function(r){if(La(r))throw new Ma("Can't call method on "+r);return r}});var ki=f((vu,Ai)=>{"use strict";var Ra=Mi(),Va=er();Ai.exports=function(r){return Ra(Va(r))}});var Re=f((gu,Pi)=>{"use strict";var Aa=re();Pi.exports=function(r){return typeof r=="object"?r!==null:Aa(r)}});var tr=f((bu,Oi)=>{"use strict";Oi.exports={}});var nr=f((Cu,ji)=>{"use strict";var rr=tr(),ir=W(),ka=re(),Ni=function(r){return ka(r)?r:void 0};ji.exports=function(r,e){return arguments.length<2?Ni(rr[r])||Ni(ir[r]):rr[r]&&rr[r][e]||ir[r]&&ir[r][e]}});var $i=f((Eu,Fi)=>{"use strict";var Pa=se();Fi.exports=Pa({}.isPrototypeOf)});var Hi=f((Iu,Di)=>{"use strict";var Oa=W(),Bi=Oa.navigator,qi=Bi&&Bi.userAgent;Di.exports=qi?String(qi):""});var Yi=f((xu,Qi)=>{"use strict";var Ki=W(),sr=Hi(),Gi=Ki.process,Ui=Ki.Deno,zi=Gi&&Gi.versions||Ui&&Ui.version,Wi=zi&&zi.v8,U,lt;Wi&&(U=Wi.split("."),lt=U[0]>0&&U[0]<4?1:+(U[0]+U[1]));!lt&&sr&&(U=sr.match(/Edge\/(\d+)/),(!U||U[1]>=74)&&(U=sr.match(/Chrome\/(\d+)/),U&&(lt=+U[1])));Qi.exports=lt});var ar=f((Tu,Xi)=>{"use strict";var Zi=Yi(),Na=te(),ja=W(),Fa=ja.String;Xi.exports=!!Object.getOwnPropertySymbols&&!Na(function(){var r=Symbol("symbol detection");return!Fa(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Zi&&Zi<41})});var or=f((wu,Ji)=>{"use strict";var $a=ar();Ji.exports=$a&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var lr=f((Su,en)=>{"use strict";var Ba=nr(),qa=re(),Da=$i(),Ha=or(),Ga=Object;en.exports=Ha?function(r){return typeof r=="symbol"}:function(r){var e=Ba("Symbol");return qa(e)&&Da(e.prototype,Ga(r))}});var rn=f((_u,tn)=>{"use strict";var Ua=String;tn.exports=function(r){try{return Ua(r)}catch(e){return"Object"}}});var cr=f((Lu,nn)=>{"use strict";var za=re(),Wa=rn(),Ka=TypeError;nn.exports=function(r){if(za(r))return r;throw new Ka(Wa(r)+" is not a function")}});var an=f((Mu,sn)=>{"use strict";var Qa=cr(),Ya=Jt();sn.exports=function(r,e){var t=r[e];return Ya(t)?void 0:Qa(t)}});var ln=f((Ru,on)=>{"use strict";var ur=ot(),hr=re(),pr=Re(),Za=TypeError;on.exports=function(r,e){var t,i;if(e==="string"&&hr(t=r.toString)&&!pr(i=ur(t,r))||hr(t=r.valueOf)&&!pr(i=ur(t,r))||e!=="string"&&hr(t=r.toString)&&!pr(i=ur(t,r)))return i;throw new Za("Can't convert object to primitive value")}});var un=f((Vu,cn)=>{"use strict";cn.exports=!0});var dn=f((Au,pn)=>{"use strict";var hn=W(),Xa=Object.defineProperty;pn.exports=function(r,e){try{Xa(hn,r,{value:e,configurable:!0,writable:!0})}catch(t){hn[r]=e}return e}});var dr=f((ku,yn)=>{"use strict";var Ja=un(),eo=W(),to=dn(),fn="__core-js_shared__",mn=yn.exports=eo[fn]||to(fn,{});(mn.versions||(mn.versions=[])).push({version:"3.38.0",mode:Ja?"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 bn=f((Pu,gn)=>{"use strict";var vn=dr();gn.exports=function(r,e){return vn[r]||(vn[r]=e||{})}});var fr=f((Ou,Cn)=>{"use strict";var ro=er(),io=Object;Cn.exports=function(r){return io(ro(r))}});var ct=f((Nu,En)=>{"use strict";var no=se(),so=fr(),ao=no({}.hasOwnProperty);En.exports=Object.hasOwn||function(e,t){return ao(so(e),t)}});var xn=f((ju,In)=>{"use strict";var oo=se(),lo=0,co=Math.random(),uo=oo(1 .toString);In.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+uo(++lo+co,36)}});var Sn=f((Fu,wn)=>{"use strict";var ho=W(),po=bn(),Tn=ct(),fo=xn(),mo=ar(),yo=or(),be=ho.Symbol,mr=po("wks"),vo=yo?be.for||be:be&&be.withoutSetter||fo;wn.exports=function(r){return Tn(mr,r)||(mr[r]=mo&&Tn(be,r)?be[r]:vo("Symbol."+r)),mr[r]}});var Rn=f(($u,Mn)=>{"use strict";var go=ot(),_n=Re(),Ln=lr(),bo=an(),Co=ln(),Eo=Sn(),Io=TypeError,xo=Eo("toPrimitive");Mn.exports=function(r,e){if(!_n(r)||Ln(r))return r;var t=bo(r,xo),i;if(t){if(e===void 0&&(e="default"),i=go(t,r,e),!_n(i)||Ln(i))return i;throw new Io("Can't convert object to primitive value")}return e===void 0&&(e="number"),Co(r,e)}});var yr=f((Bu,Vn)=>{"use strict";var To=Rn(),wo=lr();Vn.exports=function(r){var e=To(r,"string");return wo(e)?e:e+""}});var Pn=f((qu,kn)=>{"use strict";var So=W(),An=Re(),vr=So.document,_o=An(vr)&&An(vr.createElement);kn.exports=function(r){return _o?vr.createElement(r):{}}});var gr=f((Du,On)=>{"use strict";var Lo=ge(),Mo=te(),Ro=Pn();On.exports=!Lo&&!Mo(function(){return Object.defineProperty(Ro("div"),"a",{get:function(){return 7}}).a!==7})});var Fn=f(jn=>{"use strict";var Vo=ge(),Ao=ot(),ko=Si(),Po=Zt(),Oo=ki(),No=yr(),jo=ct(),Fo=gr(),Nn=Object.getOwnPropertyDescriptor;jn.f=Vo?Nn:function(e,t){if(e=Oo(e),t=No(t),Fo)try{return Nn(e,t)}catch(i){}if(jo(e,t))return Po(!Ao(ko.f,e,t),e[t])}});var Bn=f((Gu,$n)=>{"use strict";var $o=te(),Bo=re(),qo=/#|\.prototype\./,Ve=function(r,e){var t=Ho[Do(r)];return t===Uo?!0:t===Go?!1:Bo(e)?$o(e):!!e},Do=Ve.normalize=function(r){return String(r).replace(qo,".").toLowerCase()},Ho=Ve.data={},Go=Ve.NATIVE="N",Uo=Ve.POLYFILL="P";$n.exports=Ve});var Hn=f((Uu,Dn)=>{"use strict";var qn=Qt(),zo=cr(),Wo=Me(),Ko=qn(qn.bind);Dn.exports=function(r,e){return zo(r),e===void 0?r:Wo?Ko(r,e):function(){return r.apply(e,arguments)}}});var Un=f((zu,Gn)=>{"use strict";var Qo=ge(),Yo=te();Gn.exports=Qo&&Yo(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Wn=f((Wu,zn)=>{"use strict";var Zo=Re(),Xo=String,Jo=TypeError;zn.exports=function(r){if(Zo(r))return r;throw new Jo(Xo(r)+" is not an object")}});var Yn=f(Qn=>{"use strict";var el=ge(),tl=gr(),rl=Un(),ut=Wn(),Kn=yr(),il=TypeError,br=Object.defineProperty,nl=Object.getOwnPropertyDescriptor,Cr="enumerable",Er="configurable",Ir="writable";Qn.f=el?rl?function(e,t,i){if(ut(e),t=Kn(t),ut(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Ir in i&&!i[Ir]){var n=nl(e,t);n&&n[Ir]&&(e[t]=i.value,i={configurable:Er in i?i[Er]:n[Er],enumerable:Cr in i?i[Cr]:n[Cr],writable:!1})}return br(e,t,i)}:br:function(e,t,i){if(ut(e),t=Kn(t),ut(i),tl)try{return br(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new il("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Xn=f((Qu,Zn)=>{"use strict";var sl=ge(),al=Yn(),ol=Zt();Zn.exports=sl?function(r,e,t){return al.f(r,e,ol(1,t))}:function(r,e,t){return r[e]=t,r}});var ts=f((Yu,es)=>{"use strict";var Ae=W(),ll=di(),cl=Qt(),ul=re(),hl=Fn().f,pl=Bn(),Ce=tr(),dl=Hn(),Ee=Xn(),Jn=ct();dr();var fl=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 ll(r,this,arguments)};return e.prototype=r.prototype,e};es.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,s=r.proto,l=i?Ae:n?Ae[t]:Ae[t]&&Ae[t].prototype,o=i?Ce:Ce[t]||Ee(Ce,t,{})[t],a=o.prototype,c,m,y,d,C,T,I,x,p;for(d in e)c=pl(i?d:t+(n?".":"#")+d,r.forced),m=!c&&l&&Jn(l,d),T=o[d],m&&(r.dontCallGetSet?(p=hl(l,d),I=p&&p.value):I=l[d]),C=m&&I?I:e[d],!(!c&&!s&&typeof T==typeof C)&&(r.bind&&m?x=dl(C,Ae):r.wrap&&m?x=fl(C):s&&ul(C)?x=cl(C):x=C,(r.sham||C&&C.sham||T&&T.sham)&&Ee(x,"sham",!0),Ee(o,d,x),s&&(y=t+"Prototype",Jn(Ce,y)||Ee(Ce,y,{}),Ee(Ce[y],d,C),r.real&&a&&(c||!a[d])&&Ee(a,d,C)))}});var is=f((Zu,rs)=>{"use strict";var ml=Math.ceil,yl=Math.floor;rs.exports=Math.trunc||function(e){var t=+e;return(t>0?yl:ml)(t)}});var xr=f((Xu,ns)=>{"use strict";var vl=is();ns.exports=function(r){var e=+r;return e!==e||e===0?0:vl(e)}});var as=f((Ju,ss)=>{"use strict";var gl=xr(),bl=Math.min;ss.exports=function(r){var e=gl(r);return e>0?bl(e,9007199254740991):0}});var ls=f((eh,os)=>{"use strict";var Cl=as();os.exports=function(r){return Cl(r.length)}});var us=f((th,cs)=>{"use strict";cs.exports=function(){}});var hs=f(()=>{"use strict";var El=ts(),Il=fr(),xl=ls(),Tl=xr(),wl=us();El({target:"Array",proto:!0},{at:function(e){var t=Il(this),i=xl(t),n=Tl(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:t[s]}});wl("at")});var ds=f((nh,ps)=>{"use strict";var Sl=nr();ps.exports=Sl});var ms=f((sh,fs)=>{"use strict";hs();var _l=ds();fs.exports=_l("Array","at")});var vs=f((ah,ys)=>{"use strict";var Ll=ms();ys.exports=Ll});var Tr=f((oh,gs)=>{"use strict";var Ml=vs();gs.exports=Ml});var Jr="1.0.21";function $t(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",da="interactive-controls-container",Qe=()=>document.querySelector(`.${da}`),ii=.4,q={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},ei={top:"flex-start",bottom:"flex-end",center:"center"},ti={start:"flex-start",end:"flex-end",center:"center"},ri={start:"left",end:"right",center:"center"},Ye=({target:r,props:e})=>{var t,i,n,s,l,o;r.style.alignItems=(i=ei[(t=e==null?void 0:e.text)==null?void 0:t.gravityVertical])!=null?i:ei.center,r.style.justifyContent=(s=ti[(n=e==null?void 0:e.text)==null?void 0:n.gravityHorizontal])!=null?s:ti.center,r.style.textAlign=(o=ri[(l=e==null?void 0:e.text)==null?void 0:l.alignment])!=null?o:ri.start},Ze=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,o,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} * ${(o=(l=e==null?void 0:e.text)==null?void 0:l.size)!=null?o:t.textSize})`,r.textContent=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},Xe=({target:r,props:e,fallback:t})=>{var i,n,s,l;r.style.backgroundColor=$t((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(l=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?l:t.backgroundAlpha)},Je=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,o,a,c,m,y,d,C,T;r.style.border=`calc(${i.height} * ${(l=(s=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:s.width)!=null?l:t.borderWidth}) solid ${$t((c=(a=(o=e==null?void 0:e.shape)==null?void 0:o.border)==null?void 0:a.color)!=null?c:t.borderColor,(d=(y=(m=e==null?void 0:e.shape)==null?void 0:m.border)==null?void 0:y.alpha)!=null?d:t.borderAlpha)}`,r.style.borderRadius=`calc(${i.height} * ${(T=(C=e==null?void 0:e.shape)==null?void 0:C.roundCorners)!=null?T:t.roundCorners})`},ye=({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 Q=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:q.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions: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 Bt="int",ne=(i=>(i.AREA=`${Bt}_area`,i.TEXT=`${Bt}_text`,i.BUTTON=`${Bt}_bttn`,i))(ne||{});var et=r=>{if(r.type.trim().toLowerCase()==="area")return new qt(r)},qt=class extends Q{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",ne.AREA),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",Xe({target:i,props:this.control.props,fallback:E(h({},q),{backgroundColor:"transparent"})}),Je({target:i,props:this.control.props,fallback:E(h({},q),{borderAlpha:0}),dependsOn:this.container.dimensions}),ye({target:i,layoutParams:this.control.layoutParams,fallback:q}),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 tt=()=>{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 rt=r=>{if(r.type.trim().toLowerCase()==="button")return new Dt(r)},Dt=class extends Q{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",ne.BUTTON),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",i.style.fontFamily="inherit",ye({target:i,layoutParams:this.control.layoutParams,fallback:q}),Xe({target:i,props:this.control.props,fallback:q}),Je({target:i,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),Ye({target:i,props:this.control.props});let n=tt();Ze({target:n,props:this.control.props,fallback:q,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 ni=r=>{if(r.type.trim().toLowerCase()==="text")return new Ht(r)},Ht=class extends Q{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",ne.TEXT),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.fontFamily="inherit",ye({target:i,layoutParams:this.control.layoutParams,fallback:q}),Ye({target:i,props:this.control.props});let n=tt();Ze({target:n,props:this.control.props,fallback:q,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 Gt=class{constructor(e){this.layout=e}},it=class extends Gt{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 ee,nt,si,ve=class{constructor(e){B(this,ee);this.container=e,this.factories=new Map,_e(this,ee,nt).call(this)}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),_e(this,ee,nt).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),_e(this,ee,nt).call(this)}};ee=new WeakSet,nt=function(){this.controls=_e(this,ee,si).call(this)},si=function(){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);return s?[...t,s(i)]:[...t]},[])};var st=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new Ut(r,e)},Ut=class extends ve{constructor(e,t){super(e),this.rootElement=t!=null?t:Qe(),this.layout=new it(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",rt),this.addControlFactory("text",ni),this.addControlFactory("area",et)}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=ii,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 na=Zr(Tr(),1);import{clientChecker as cc,combine as uc,InterfaceLanguage as hc,Observable as ta,once as pc,Subject as Br,Subscription as ra,ValueSubject as G}from"@vkontakte/videoplayer-shared";import{InteractiveInterfaceClick as ze}from"@vkontakte/videoplayer-statistics";import{loadVKLangPack as Rl}from"@vkontakte/videoplayer-shared";function ke(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var ae=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Pe=r=>ae(r,"Object"),ht=r=>ae(r,"String"),pt=r=>ae(r,"Array"),dt=r=>ae(r,"Number"),bs=r=>ae(r,"Function");var wr=r=>dt(r)&&!isNaN(r);var oe=r=>Pe(r)&&Object.keys(r).length===0,Sr=r=>pt(r)&&!r.length;var Oe=(r,e)=>ht(r)&&(e?r.trim():r).length;var Cs="video_interactive",Es="videoint";var Is=250,Ne=class{constructor(e){this.handleZoomChange=ke(e=>{this.lastZoomInfo=e},Is);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,!dt(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=Vl(e),this.resizeObserver=new ResizeObserver(ke(this.onResize,Is)),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 _(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 _(this,null,function*(){if(!this.manifest)return;let e;try{e=yield Rl(this.lang,Cs,Es)}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.ngEditor.on("control",s=>{var l=s,{name:i}=l,n=N(l,["name"]);var o;i==="openPreview"&&"chapterId"in n&&((o=this.onOpenPreviewClick)==null||o.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 Vl(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 je=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 l=s.startTime-e;if(l<=n&&(s.endTime&&n<=s.endTime||s.endTime===null)){i=!0;break}n<l&&(t=t===-1?l:Math.min(t,l))}return!i&&t!==-1?t:null}}};var ie=(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};import{v4 as Al}from"uuid";var kl="3.1",xs={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},Pl={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ts=r=>{let e=[];for(let l of r.chapters){let o,a=[];for(let t of l.branches){let i=t,{isDefault:y}=i,d=N(i,["isDefault"]);y&&(o=d.id),a.push(d)}let c=[],m=[];for(let n of l.containers){let s=n,{fallbackStrategy:y}=s,d=N(s,["fallbackStrategy"]);let C=!!d.endTime,T=[Pl];switch(y){case"await":C?T=[]:c=[];break;case"default":{let I={type:"onSuspense",action:{type:xs.default,args:{branchId:o,shouldOpenNow:!C,isDetachContainer:!0}}};C?T=[I]:c=[I];break}case"random":case"weightlessRandom":case"max":case"min":{let I={type:"onSuspense",action:{type:xs[y],args:{}}};C?T=[I]:c=[I];break}}for(let I of d.controls)m.push(E(h({},d),{controls:[h({},I)],id:Al(),events:T}))}e.push(E(h({},l),{containers:m,events:c,branches:a}))}return r.metadata.version=kl,r.metadata.updated=new Date().toISOString(),E(h({},r),{chapters:e})};var Ol="3.2",ws=r=>{if(!r.media){let e=r.metadata,{media:t}=e,i=N(e,["media"]);return E(h({},r),{metadata:E(h({},i),{version:Ol}),media:t})}return r};var Nl="3.3",jl=(r=[])=>({edit:{chapters:r},view:{}}),Ss={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},_s=r=>{var n;let e=[],t=[];for(let s of r.chapters){let i=s,{id:l,x:o,y:a}=i,c=N(i,["id","x","y"]),m=c.containers.map(y=>{var d;return E(h({},y),{controls:y.controls.map(x=>{var p=x,{subtype:C,type:T}=p,I=N(p,["subtype","type"]);return E(h({},I),{type:C!=null?C:T})}),events:(d=y.events)!=null&&d.length?y.events:[Ss]})});e.push(E(h({id:l},c),{containers:m,events:(n=c.events)!=null&&n.length?c.events:[Ss]})),t.push({id:l,x:o,y:a})}return E(h({},r),{chapters:e,graph:jl(t),metadata:E(h({},r.metadata),{version:Nl})})};var Fl=[{version:"3.0",migrate:Ts},{version:"3.1",migrate:ws},{version:"3.2",migrate:_s}],_r=r=>Fl.reduce((e,t)=>ie(e.metadata.version,t.version)?e:t.migrate(e),r);var jh=Object.freeze({Choice:"Choice",TextInput:"TextInput"}),Ls=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),Fh=Object.freeze({onClick:"onClick",onSuspense:"onSuspense"}),R=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"});var Ms={metadata:"Object",chapters:"Array"},$l="3.0.0",Bl="3.3.0",ft=r=>{let e=ie(r,$l);return e===-1?!1:e===0?!0:ie(r,Bl)!==1},Rs=r=>{if(!Pe(r))return!1;for(let e in Ms)if(!r[e]||!ae(r[e],Ms[e]))return!1;return ft(r.metadata.version)},mt=r=>r.type===Ls.Text;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 yt=class{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let i=()=>{t(),this.off(e,i)};return this.listeners[e].push(i),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let i=this.listeners[e]||[];for(let n=i.length;n>0;n--)if(i[n]===t){i.splice(n,1);break}return this}emit(e,...t){let i=this.listeners[e];return i?(i.forEach(n=>{n(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}};var vt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{bs(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=[]}};import{ValueSubject as Wl}from"@vkontakte/videoplayer-shared";var gt=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 _(this,null,function*(){return ql(...this.loaders[e])(t)})}};function ql(...r){return function(t){return _(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function Fe(r,e,t){return r?E(h({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function bt(n){var s=n,{actions:r,errors:e,chapterId:t}=s,i=N(s,["actions","errors","chapterId"]);if(t){let l=r.getManifest(),o=r.getChapter(l.chapters,t);if(o){let a=r.getMedia(l.media,o.videoId),c=r.getGraph(l.graph,o.id);return a?E(h({},i),{actions:r,errors:e,result:{chapter:o,media:a,graph:c}}):E(h({},i),{errors:Fe(e,bt.name,"Could not find media"),actions:r})}}return E(h({},i),{errors:Fe(e,bt.name,"Could not find chapter"),actions:r})}var Ct=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 l=i[n];try{l.callback.call(this,e)}catch(o){Promise.resolve().then(()=>{throw o})}l.options&&l.options.once&&this.removeEventListener(e.type,l.callback)}return!e.defaultPrevented}},Ie=class extends Ct{constructor(){super(),this.listeners||Ct.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)}},$e=class{constructor(){Object.defineProperty(this,"signal",{value:new Ie,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&&($e.prototype[Symbol.toStringTag]="AbortController",Ie.prototype[Symbol.toStringTag]="AbortSignal");function Et(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 Lr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Et({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,m){let y;m&&m.signal&&(y=m.signal,delete m.signal);let d=new t(c,m);return y&&Object.defineProperty(d,"signal",{writable:!1,enumerable:!1,configurable:!0,value:y}),d},s.prototype=t.prototype);let l=e;return{fetch:(a,c)=>{let m=s&&s.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(m){let y;try{y=new DOMException("Aborted","AbortError")}catch(C){y=new Error("Aborted"),y.name="AbortError"}if(m.aborted)return Promise.reject(y);let d=new Promise((C,T)=>{m.addEventListener("abort",()=>T(y),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([d,l(a,c)])}return l(a,c)},Request:s}}var Be=Et({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Vs=Be?Lr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Mr=Be?Vs.fetch:window.fetch,hp=Be?Vs.Request:window.Request,pp=Be?$e:window.AbortController,dp=Be?Ie:window.AbortSignal;var Dl=r=>_(void 0,null,function*(){try{let e={},t;if(ht(r)){t=new URL(r).href;let n=yield Mr(t);if(!n.ok)return{};e=yield n.json()}else if(Pe(r))e=r;else return{};if(!Rs(e))return{};let i=e.metadata.media;if(ht(i)&&!e.media)try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let s=yield Mr(n);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(n){return Ul(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function As(r){return _(this,null,function*(){let{manifest:e,manifestURL:t}=yield Dl(r),i=_r(e);return i.media=Hl(i.media,t),delete i.metadata.media,i})}function It(r,e){if(e)return r.find(t=>t.id===e)}function Rr(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 Vr(r,e){return r.videos.find(t=>t.id===e)}function Hl(r,e){return E(h({},r),{videos:r.videos.map(t=>E(h({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",s=Gl(n,e);return E(h({},i),{url:s||n})})}))})}function Gl(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Ul(r){return ie(r,"3.2.0")>=0}var A=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),xt=r=>pt(r)&&!Sr(r),K=r=>r.order==="end",Tt=r=>pt(r.containers)&&!Sr(r.containers)&&K(r),ks=(r,e)=>{var i;let t=r*1e3;return xt(e.controls)&&t<((i=e.startTime)!=null?i:0)},Ar=(r,e)=>{var i,n;let t=r*1e3;return xt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var le=r=>r.some(e=>e.action.type==="expect"),kr=r=>r.find(e=>e.action.type==="expect"),zl=r=>(r==null?void 0:r.length)===1,wt=r=>zl(r)&&mt(r[0]);var Ps=({fn:r,type:e=1},...t)=>(...i)=>e?r(...i,...t):r(h(h({},i[e]),t[e])),Os=(r,e)=>le(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&le(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var xe=class extends gt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Wl(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 _(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Fe},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield As((n=i.result)!=null?n:t),this})}setInitial(){return _(this,null,function*(){return this.setNext()})}setNext(){return _(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",bt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Rr,getChapter:It,getMedia:Vr,getByBranches:this.getByBranches.bind(this),addErrorMessage:Fe},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=It(this.manifest.chapters,t);if(n){let s=Vr(this.manifest.media,n.videoId),l=Rr(this.manifest.graph,n.id);if(s)return{chapter:n,media:s,graph:l}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,s,l;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((s=this.chapter)==null?void 0:s.branches);{let o=It(((l=this.manifest)==null?void 0:l.chapters)||[],t);return this.getByBranches(o==null?void 0:o.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 K(this.chapter)}};import{Player as Kl}from"@vkontakte/videoplayer-core";import{Subscription as js,Tracer as Ql,ValueSubject as Yl}from"@vkontakte/videoplayer-shared";var Ns=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&"payload"in e){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};function Pr(){let r=new Map;function e(a){var c=a,{listId:s=Math.random().toString(),itemId:l=Math.random().toString()}=c,o=N(c,["listId","itemId"]);let m=r.get(s),y=h({},o);return m?m[l]=y:r.set(s,{[l]:y}),h({listId:s,itemId:l},o)}function t(s){var l,o;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(l=s.statistics)==null||l.oneStat.destroy(),(o=s.statistics)==null||o.statSubscription.unsubscribe()}function i(s,l){let o=r.get(s);if(!o)throw Error("Can't remove. Not find.");if(l){let a=o[l];a&&t(a),delete o[l],Object.keys(o).length||r.delete(s)}else{for(let a of Object.values(o))t(a);r.delete(s)}}function n(){for(let s of r)i(s[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}function Or(r,e=[]){var s,l,o;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||e.includes("mp4"))&&(t.MPEG=E(h({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"mpeg":(n||e.includes("mpeg"))&&(t.MPEG=E(h({},t.MPEG),{[(l=a.standard)!=null?l:"Invariant quality"]:a.url}));break;case"hls":(n||e.includes("hls"))&&(t=E(h({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(n||e.includes("dash"))&&(t=E(h({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(o=r.title)!=null?o:""}}var qe=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&i.includes(e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Zl=2;function Nr(r){let e=Pr(),t={},i=null,n=!1,s,l=new Yl(null);r&&o(r);function o(I){i=I}function a(I,x,p){var w;if(!i)throw Error("need to set interactive controller");if(!i.options)return;let g=((w=e.map.get(I))!=null?w:{})[x];if(g){t=h({chapterId:p,listId:I,itemId:x},g);let v=t.player;t.subscription.add(v.info.currentQuality$.subscribe(k=>{let P=v.info.position$.getValue(),j=v.info.isAutoQualityEnabled$.getValue();if(!(!k||!P||j))for(let L of e.map)Object.values(L[1]).forEach(({player:V})=>{qe(V,k)})})).add(v.events.started$.subscribe(()=>{c(x)})),g.container.remove(),i.setPlayer(g.player),n||(i.init(),n=!0),l.next({player:t.player,config:t.config,statistics:t.statistics});return}throw Error("Can't set. Not find.")}function c(I){return _(this,null,function*(){if(!i)throw Error("need to set interactive controller");if(oe(t)||I!==t.itemId)return;let x=i.getChapterBranches(),p=new Set;for(let u of x)p.has(u.media.id)||(yield y({media:u.media,chapterId:u.chapter.id,setAsActive:!1,title:u.chapter.label}),p.add(u.media.id))})}function m(p){return _(this,arguments,function*({chapter:{id:I},media:x}){if(oe(t))return;let u=t.player.info.muted$.getValue(),g=t.player.info.currentQuality$.getValue(),w=t.player.info.isAutoQualityEnabled$.getValue(),v=t.player.info.volume$.getValue(),k=t.player.info.currentPlaybackRate$.getValue(),P=!w,j=!1;for(let L of e.map)if(L[0]===x.id){let V=Object.keys(L[1]);for(let $ of V)$===t.itemId?(V.length<Zl||(j=!0),e.removePlayer(L[0],$)):(j=!0,a(L[0],$,I),P?qe(t.player,g):t.player.setAutoQuality(!0),t.player.setVolume(v),t.player.setMuted(u),t.player.setPlaybackRate(k))}else e.removePlayer(L[0]);j||(yield y({media:x,chapterId:I,setAsActive:!0,playbackRate:k}),P?qe(t.player,g):t.player.setAutoQuality(!0),t.player.setVolume(v),t.player.setMuted(u))})}function y(P){return _(this,arguments,function*({media:I,chapterId:x,prefetch:p=!0,setAsActive:u=!0,autoplay:g=!1,preferredExt:w,title:v,playbackRate:k}){var Hr,Gr,Ur,zr,Wr;let j=Math.random().toString(),L=document.createElement("div");s.append(L);let V;if((Hr=i==null?void 0:i.options)!=null&&Hr.vkVideoLoader){let We=Ns(I);We.length&&(V=yield i.options.vkVideoLoader(...We))}let $=((Gr=i==null?void 0:i.options)==null?void 0:Gr.coreConfig)||void 0,de=E(h({},$),{configName:[...(Ur=$==null?void 0:$.configName)!=null?Ur:[],"interactive"]}),fe=E(h({container:L},((zr=V==null?void 0:V.videos)==null?void 0:zr[0])||{sources:Or(I,w).sources}),{title:v,failoverHosts:(V==null?void 0:V.failoverHosts)||[]}),J=new Kl(de,Ql.createRootTracer());J.initVideo(fe);let qr=null;if(V!=null&&V.videos&&(i!=null&&i.options.createOneStat)){let We=V.videos[0],Pt=i.options.createOneStat(We),Kr=new js;Pt&&(Kr.add(Pt.attachTo(J)),qr={oneStat:Pt,statSubscription:Kr})}let Dr=new js,sa=(Wr=t==null?void 0:t.player)==null?void 0:Wr.info.isAutoQualityEnabled$.getValue();Dr.add(J.events.canplay$.subscribe(function(){sa||qe(J,t.player.info.currentQuality$.getValue()),k&&J.setPlaybackRate(k)}));let me=e.createPlayer({listId:I.id,itemId:j,player:J,container:L,sources:Or(I,w).sources,config:fe,subscription:Dr,statistics:qr});return u&&a(I.id,me.itemId,x),g&&me.player.play(),p&&!g&&me.player.prepare(),{player:me.player,config:me.config,statistics:me.statistics}})}function d(){C(),i=null,s.remove()}function C(){i==null||i.off(b.chapterChanged,m),e.removeAll(),t={},n=!1}function T(){return _(this,null,function*(){if(!i)throw Error("need to set interactive controller");C(),s=document.createElement("div");let{media:I,chapter:x}=i.getCurrentChapter();I&&x?(i.on(b.chapterChanged,m),yield y({media:I,chapterId:x.id,title:x.label})):console.error("not found")})}return E(h({},e),{init:T,setInteractiveController:o,createPlayer:y,removeAll:d,getActivePlayer:function(){return t},activePlayerChanged:l})}var b={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},De={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},M={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};import{Subscription as Xl}from"@vkontakte/videoplayer-shared";var St=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:s,globalEventEmitter:l,ignoreContainerEvent:o,permanentTextControls:a,disabledControls$:c,onRemove:m}){Se(this,"hide",()=>{setTimeout(()=>{var e,t;this.gameState!==A.end&&(le(this.container.container.events)&&this.gameState===A.afterInteractive||this.selectBranches.state.isExpect||(this.gameState!==A.interactive&&((t=(e=this.container).hide)==null||t.call(e)),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1})))})});Se(this,"show",()=>{var e,t,i,n;if(this.gameState===A.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())(n=(i=this.container).show)==null||n.call(i),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!0,isFirst:!1});else{let l=Ps({fn:this.selectBranches.onControlEvent,type:0},{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1})},onEvent:(o,a)=>{this.isSelectedControlEvent=!0,o!==!1&&(this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1})),(this.gameState===A.end||this.gameState===A.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),a(),this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1}))},isEOV:()=>this.gameState===A.end});this.container.createView(l),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((t=(e=this.container).disable)==null||t.call(e))}});Se(this,"onEndOfVideo",()=>{this.gameState=A.end,this.selectContainerEvent(!0)});Se(this,"whilePlaying",()=>{var s,l;if(((s=this.player.experimental.element$.getValue())==null?void 0:s.readyState)<1||[A.destroyed,A.removed].includes(this.gameState)&&!this.isPermanentText)return;let t=this.player.getExactTime();if(ks(t,this.container.container))this.gameState!==A.beforeInteractive&&(this.gameState=A.beforeInteractive,this.onBeforeStartTime());else if(Ar(t,this.container.container))this.gameState!==A.interactive&&(this.gameState=A.interactive,this.onStartTime());else if(this.gameState!==A.afterInteractive){let o=this.gameState;this.gameState=A.afterInteractive,o===A.interactive&&this.onEndTime()}else this.gameState!==A.destroyed&&!this.isPermanentText&&this.removeView();let i=Ar(t,this.container.container),n=this.container.container.startTime?[this.container.container.startTime,(l=this.container.container.endTime)!=null?l:1/0]:[];this.globalEventEmitter.emit(b.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:n,currentTime:t,isInteractiveTime:i})});this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Xl,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=o,this.isPermanentText=a&&wt(t.container.controls),this.disabledControls$=c,this.onRemove=m,this.globalEventEmitter=l,this.gameState=A.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}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){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(this.container.container.endTime))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=le(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.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=A.beforeInteractive}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.containerRemoved,visibility:!1}),this.gameState=A.removed,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=A.destroyed,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 Fs=(r=[])=>r.reduce((e,t,i)=>{var s,l,o;let n=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!mt(a));if(xt(n)){let a=[(l=t.startTime)!=null?l:0,(o=t.endTime)!=null?o:1/0],c=t.id;if(!i)e.push({subjects:[c],range:a});else{let m=[],y=-1/0,d=1/0,C=[],T=[];for(let I=0;I<e.length;I++){let x=e[I];if(T.push(...x.subjects),x.range[0]<d&&(d=x.range[0]),x.range[1]>y&&(y=x.range[1]),a[0]>=x.range[0]&&a[1]<=x.range[1])return e[I].subjects.push(c),e;a[0]<x.range[0]&&a[1]>x.range[0]&&(m.push(I),C=C.concat(x.subjects)),a[0]>=x.range[0]&&a[0]<=x.range[1]&&(m.push(I),C=C.concat(x.subjects),a[0]=x.range[0]),a[1]>=x.range[0]&&a[1]<=x.range[1]&&(m.push(I),C=C.concat(x.subjects),a[1]=x.range[1])}if(T.push(c),a[0]<=d&&a[1]>=y)return[{subjects:T,range:a}];m.length&&m.reverse().forEach(I=>{e.splice(I,1)}),e.push({subjects:C.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);function $s(){let r={};function e(){for(let o in r)Object.prototype.hasOwnProperty.call(r,o)&&delete r[o];return!0}function t(o){let a={};for(let c in r)+c<=o&&(a[c]=r[c]);return a}function i(o){let a={};for(let c in r)+c>=o&&(a[c]=r[c]);return a}function n({timestamp:o,priority:a,initiator:c}){var m;if(wr(o)){let y=(m=r[o])!=null?m:null;if(y&&Oe(a,!0)){let d={},C=y[a];if(C&&(d=h(h({},d),C)),d=oe(d)?null:d,d&&Oe(c,!0)){let T=d[c];return T!=null?T:null}return d}return y}return null}function s({timestamp:o,priority:a,initiator:c}){if(wr(o))if(r[o]){if(Oe(a,!0))if(r[o][a]){if(Oe(c,!0))if(r[o][a][c]){if(delete r[o][a][c],!oe(r[o][a]))return!0}else return!1;if(delete r[o][a],!oe(r[o]))return!0}else return!1;return delete r[o]}else return!1}function l(y){var d=y,{timestamp:o,priority:a,initiator:c}=d,m=N(d,["timestamp","priority","initiator"]);var C,T,I;(T=(C=r[o])==null?void 0:C[a])!=null&&T[c]?r[o][a][c].push(h({},m)):(I=r[o])!=null&&I[a]?r[o][a]=E(h({},r[o][a]),{[c]:[h({},m)]}):r[o]?r[o]=E(h({},r[o]),{[a]:{[c]:[h({},m)]}}):r[o]={[a]:{[c]:[h({},m)]}}}return{map:r,remove:s,add:l,removeAll:e,get:n,getLte:t,getGte:i}}var Jl=[R.expect,R.setNextBranch],ec=1/0;function Bs(r){let e=r,t,i=tc(),n=new $s,s,l=()=>{d(),p()},o=u=>{n.add.call(void 0,u),T()},a=(u=[])=>{for(let g of u)if(g.action(),Jl.includes(g.actionType))break},c=(u=1/0)=>{var k,P,j;let g=_t((k=n.get({timestamp:u,priority:"control"}))!=null?k:{}),w=_t((P=n.get({timestamp:u,priority:"container"}))!=null?P:{}),v=_t((j=n.get({timestamp:u,priority:"chapter"}))!=null?j:{});return[...g,...w,...v]},m=u=>{i.isReady(u)&&a(c(u))},y=()=>{var u;a([..._t((u=n.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},d=()=>{t&&(s==null||s.unsubscribe(),t=void 0)},C=u=>{},T=()=>{t||(t=()=>setTimeout(()=>{m(1/0)}),s=e.events.ended$.subscribe(t))},I=u=>{d(),e=u},x=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),n.remove(u)},p=()=>{i.release(),n.removeAll()};return{setPlayer:I,add:o,remove:x,exec:m,execEndOfVideo:y,listen:T,unlisten:d,release:l,containersEventsCallState:i,getPreparedToExecActions:c}}function tc(){let r=new Map;return{setCalled:({timestamp:l,id:o})=>{let a=r.get(l);a&&a[o]!==void 0&&(a[o]=!0)},setData:(l=[])=>{var o,a;for(let c of l){let m=(o=c.endTime)!=null?o:ec,y=(a=r.get(m))!=null?a:{};r.set(m,E(h({},y),{[c.id]:!1}))}},resetCalled:l=>{let o=r.get(l);if(o)for(let a in o)o[a]=!1},isReady:l=>{let o=r.get(l);return o?!Object.values(o).some(a=>!a):!0},release:()=>r.clear()}}function _t(r){return Object.values(r).flat().sort(e=>e.actionType===R.expect?-1:1)}var qs={videoContentHeight:0,videoContentWidth:0},Ds=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return qs;let{clientHeight:n,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(n&&s))return qs;let l=t/i,o=n/s,a,c;return o>l?(c=s,a=s*l):o<l?(c=n/l,a=n):(c=s,a=n),{videoContentWidth:c,videoContentHeight:a}};var rc=250;function Hs(r){let e=()=>{},t=new ResizeObserver(o=>{s(o),e=s.bind(null,o)});function i(o){let{parentElement:a,player:c}=r();if(a&&c){let{videoContentWidth:m,videoContentHeight:y}=Ds(a,c);a.style.setProperty("--interactive-content-width",`${m}px`),a.style.setProperty("--interactive-content-height",`${y}px`),a.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function n(){let{parentElement:o}=r();o.removeAttribute("style")}let s=ke(o=>{let{fns:a=[]}=r();i(o);for(let c of a)c()},rc);function l(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e()},release:l}}var He=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 ic=r=>Math.floor(Math.random()*r),Gs=r=>{let e=r.length,t=1/0,i=null;for(;e--;)r[e].weight<t&&(t=r[e].weight,i=r[e]);return i},Us=r=>{let e=r.length,t=-1/0,i=null;for(;e--;)r[e].weight>t&&(t=r[e].weight,i=r[e]);return i};var zs=r=>{let e=r.length,t=ic(e);return r[t]};var Ws=r=>{var i,n;let e=0;for(let s=0;s<r.length;++s)e+=(i=r[s].weight)!=null?i:1;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(n=r[s].weight)!=null?n:1,e>=t)return r[s];return r[r.length-1]};var Ks=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0});var jr=(r,e=!1)=>E(h({},r),{args:e?h(h({},r.args),Ks):h(h({},Ks),r.args)}),Zs=({globalEventEmitter:r,player:e,interactiveEvents:t,removeControllers:i})=>{let n={isExpect:!1},s=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:p,controlType:u,controlId:g,containerId:w,branches:v=[],onEvent:k,isEOV:P=()=>!1,isDisabled:j=()=>!1})=>{let L=jr(p,P()),V={timestamp:1/0,priority:"control",initiator:g,actionType:L.type},$=j(),de=r.emit.bind(r,b.interactives,{subjectId:g,subjectType:u,subjectName:"control",type:$?M.actionChoiceCanceled:M.actionChoice,actionType:p.type,payload:h({containerId:w},L.args)});if($){de();return}switch(L.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let fe=v.find(J=>J.id===L.args.branchId);if(!fe)return;k(L.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),de(),L.args.shouldOpenNow?T({subjectId:g,subjectName:"control",subjectType:u,action:L,payload:{chapterId:fe.chapterId,autoSelect:!1}}):(t.add(E(h({},V),{action:T.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:L,payload:{chapterId:fe.chapterId,autoSelect:!1}})})),i==null||i());return}case R.continuePlayback.trim().toLowerCase():{k(L.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),de(),L.args.shouldOpenNow?C({subjectId:g,subjectName:"control",subjectType:u,action:p}):t.add(E(h({},V),{action:C.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:p})}));return}case R.openURI.trim().toLowerCase():{k(L.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),de(),L.args.shouldOpenNow?x({subjectId:g,subjectName:"control",subjectType:u,action:L,payload:{URI:p.args.uri}}):(t.add(E(h({},V),{action:x.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:L,payload:{URI:p.args.uri}})})),i==null||i());return}default:console.error("Unexpected control event"),r.emit(b.errors,new F(1,1,{message:"Unexpected control event"}));return}},o=({action:p,container:{id:u,endTime:g},branches:w=[],isEOV:v=!1,autoSelected:k=!1})=>{let P=jr(p,v),j={timestamp:!P.args.shouldOpenNow||v?1/0:g,priority:"container",initiator:u,actionType:P.type},L=r.emit.bind(r,b.interactives,{subjectId:u,subjectName:"container",type:M.actionChoice,actionType:P.type,payload:P.args});switch(P.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let V=w.find($=>$.id===P.args.branchId);if(!V)return;L(),t.add(E(h({},j),{action:T.bind(null,{subjectId:u,subjectName:"container",action:P,payload:{chapterId:V.chapterId,autoSelect:k}})})),i==null||i();return}case R.setMaxWeightBranch.trim().toLowerCase():return;case R.setMinWeightBranch.trim().toLowerCase():return;case R.setRandomBranch.trim().toLowerCase():return;case R.setWeightlessRandomBranch.trim().toLowerCase():return;case R.continuePlayback.trim().toLowerCase():{L(),t.add(E(h({},j),{action:C.bind(null,{subjectId:u,subjectName:"container",action:P})}));return}case R.openURI.trim().toLowerCase():{L(),t.add(E(h({},j),{action:x.bind(null,{subjectId:u,subjectName:"container",action:P,payload:{URI:p.args.uri}})})),i==null||i();return}default:console.error("Unexpected container event"),r.emit(b.errors,new F(1,1,{message:"Unexpected container event"}));return}};function a({container:p,branches:u,isEOV:g=!1}){let w=kr(p.events);if(w){let v=jr(w.action,g);r.emit(b.interactives,{subjectId:p.id,subjectName:"container",type:M.actionChoice,actionType:v.type,payload:v.args}),t.add({timestamp:g?1/0:p.endTime,priority:"container",initiator:p.id,actionType:R.expect,action:y.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let v of p.events)o({action:v.action,container:p,branches:u,isEOV:g})}let c=({chapterId:p,action:u,branches:g=[]})=>{let w=r.emit.bind(r,b.interactives,{subjectId:p,subjectName:"chapter",type:M.actionChoice,actionType:u.type,payload:u.args});switch(u.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let v=g.find(k=>k.id===u.args.branchId);return v!=null&&v.chapterId?(w(),T.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setWeightlessRandomBranch.trim().toLowerCase():{let v=zs(g);return v!=null&&v.chapterId?(w(),T.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setRandomBranch.trim().toLowerCase():{let v=Ws(g);return v!=null&&v.chapterId?(w(),T.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setMaxWeightBranch.trim().toLowerCase():{let v=Us(g);return v!=null&&v.chapterId?(w(),T.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setMinWeightBranch.trim().toLowerCase():{let v=Gs(g);return v!=null&&v.chapterId?(w(),T.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.continuePlayback.trim().toLowerCase():return w(),C.bind(null,{subjectId:p,subjectName:"chapter",action:u});case R.openURI.trim().toLowerCase():return w(),x.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:console.error("Unexpected chapter event"),r.emit(b.errors,new F(1,1,{message:"Unexpected chapter event"}));return}};function m(p){let u=kr(p.events);if(u){if(K(p))return;r.emit(b.interactives,{subjectId:p.id,subjectName:"chapter",type:M.actionChoice,actionType:u.action.type,payload:u.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:R.expect,action:y.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else p.events.forEach(g=>{let w=c({chapterId:p.id,action:g.action,branches:p.branches});w&&t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:g.action.type,action:w})})}let y=({subjectId:p,subjectName:u,action:g})=>{var w;e.pause(),r.emit(b.interactives,{subjectId:p,subjectName:u,type:M.actionExecution,actionType:(w=g==null?void 0:g.type)!=null?w:R.expect})},d=({subjectId:p,subjectName:u})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),r.emit(b.interactives,{subjectId:p,subjectName:u,type:M.actionExecution,actionType:"after-expect"})},C=({subjectId:p,subjectName:u,subjectType:g,action:w})=>{r.emit(b.interactives,{subjectId:p,subjectName:u,subjectType:g,type:M.actionExecution,actionType:w.type})},T=({subjectId:p,subjectName:u,subjectType:g,action:w,payload:v})=>{v.behaviour="change-chapter",r.emit(b.interactives,{subjectId:p,subjectName:u,subjectType:g,type:M.actionExecution,actionType:w.type,payload:v})},I=({subjectId:p,subjectName:u,subjectType:g,action:w,payload:v})=>{v.behaviour="change-manifest",r.emit(b.interactives,{subjectId:p,subjectName:u,subjectType:g,type:M.actionExecution,actionType:w.type,payload:v})},x=({subjectId:p,subjectName:u,subjectType:g,action:w,payload:v})=>{if(!v.URI)return;let k=window.open(v.URI,"_blank","noopener,noreferrer");k&&(k.opener=null),r.emit(b.interactives,{subjectId:p,subjectName:u,subjectType:g,type:M.actionExecution,actionType:w.type})};return{onControlEvent:l,onContainerEvent:o,onChapterEvent:c,onExpectEvent:y,expectEventHandler:d,setManifestChapterEvents:m,setManifestContainerEvents:a,stopExpect:s,state:n}};var $r=Zr(Tr(),1);import{Subscription as lc,ValueSubject as Ge}from"@vkontakte/videoplayer-shared";var Fr=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(l=>l.id===i);if(!n)return null;let s=e.media.videos.find(l=>n.videoId===l.id);if(!s)return null;t[i]=Xs(s)}return t[i]}).filter(Boolean)},sc=r=>{for(let e of r.variants)if(ac(e)&&"payload"in e)return e.payload.id},ac=r=>r.type==="custom"&&"payload"in r&&r.payload.type==="vk",Xs=r=>{let e=sc(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},oc=(r,e)=>{for(let t of r.media.videos)if(e===Xs(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},Js=(r,e)=>r.reduce((t,i)=>{let n=oc(e,i);return n?[...t,n]:t},[]);var Y,ce,ue,H,Lt,Z,X,z,he,Te,we,Ue=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new Ge([]),hasPrevChapter$:new Ge(!1),prevChapter$:new Ge(null),isInitialChapter$:new Ge(!1),isGoBackLimited$:new Ge(!1)};B(this,Y,null);B(this,ce);B(this,ue,!1);B(this,H,null);B(this,Lt,null);B(this,Z,null);B(this,X,null);B(this,z,null);B(this,he,new lc);B(this,Te,!1);B(this,we,0);var l;O(this,Z,t),O(this,z,e),O(this,X,i),O(this,Y,n),O(this,ce,s),this.state.history$&&S(this,he)&&((l=S(this,he))==null||l.add(this.state.history$.subscribe(o=>{var a,c;this.state.prevChapter$.next((0,$r.default)(o,-2)||null),this.state.hasPrevChapter$.next(o.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(a=S(this,H))==null?void 0:a.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(S(this,we)===S(this,ce).maxLength-1)})))}setManifest(e){return _(this,null,function*(){!S(this,X)||!S(this,z)||(O(this,H,e),yield this.getProjectHistory(),yield S(this,X).setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),S(this,ue)||(O(this,ue,!0),S(this,z).emit(b.historyInited,{initChapterId:this.getInitialChapterId()})))})}get inited(){return S(this,ue)}updateHistory(e,t=!0){return _(this,null,function*(){var o;if(!S(this,H))return;S(this,Te)?(O(this,Te,!1),Xr(this,we)._++):O(this,we,0);let i=S(this,H),n=e.length-S(this,ce).maxLength,s=n>0?e.slice(n):e,l=Fr(s,i);if(O(this,Lt,l),this.state.history$.next(s),!(!t||!S(this,Y)||!S(this,Z)))try{yield S(this,Y).save(S(this,Z),l)}catch(a){(o=S(this,z))==null||o.emit(b.errors,new F(1,5,"Unable to save interactive history"))}})}goBack(){return _(this,null,function*(){var i;if(!this.state||!S(this,X))return(i=S(this,z))==null?void 0:i.emit(b.errors,new F(1,5,"Cannot go back because HistoryController has not been initialized"));O(this,Te,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield S(this,X).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return _(this,null,function*(){var n;if(!S(this,H)||!S(this,Z))return;let e=S(this,H),t=[this.getInitialVideoId()];if(S(this,Y))try{let s=yield S(this,Y).get(S(this,Z));s.length&&(t=s)}catch(s){(n=S(this,z))==null||n.emit(b.errors,new F(1,5,"Error while trying to fetch data"))}let i=Js(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,$r.default)(e,-1)||S(this,ce).initChapterId||((t=S(this,H))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(S(this,H)){let e=this.getInitialChapterId();return Fr([e],S(this,H)).pop()}return null}destroy(){var e,t;O(this,Z,null),O(this,Y,null),O(this,X,null),(e=S(this,he))==null||e.unsubscribe(),O(this,he,null),O(this,ue,!1),(t=S(this,z))==null||t.emit(b.historyDestroyed),O(this,z,null)}};Y=new WeakMap,ce=new WeakMap,ue=new WeakMap,H=new WeakMap,Lt=new WeakMap,Z=new WeakMap,X=new WeakMap,z=new WeakMap,he=new WeakMap,Te=new WeakMap,we=new WeakMap;var pe=class pe{constructor(e,t,i,n){this.target=e,this.type=t,this.listener=i,this.options=pe._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(l=>!i.has(l));return n.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+n.join(",")),pe._doesSupportObject(e)?t:t.capture||!1}}static _doesSupportObject(e){let t=pe._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}pe._supportsObject=t}return t||!1}};pe._supportsObject=void 0;var Mt=pe;var Rt=class{constructor(){this.bindingMap=new He}release(){this.removeAll(),this.bindingMap=null}listen(e,t,i,n){if(!this.bindingMap)return;let s=new Mt(e,t,i,n);this.bindingMap.push(t,s)}listenOnce(e,t,i,n){let s=l=>{this.unlisten(e,t,s),i(l)};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 Vt=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 _(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 _(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 At=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
+ var aa=Object.create;var Ot=Object.defineProperty,oa=Object.defineProperties,la=Object.getOwnPropertyDescriptor,ca=Object.getOwnPropertyDescriptors,pa=Object.getOwnPropertyNames,We=Object.getOwnPropertySymbols,ua=Object.getPrototypeOf,Nt=Object.prototype.hasOwnProperty,Kr=Object.prototype.propertyIsEnumerable;var Yr=r=>{throw TypeError(r)};var Qr=(r,e,t)=>e in r?Ot(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,h=(r,e)=>{for(var t in e||(e={}))Nt.call(e,t)&&Qr(r,t,e[t]);if(We)for(var t of We(e))Kr.call(e,t)&&Qr(r,t,e[t]);return r},C=(r,e)=>oa(r,ca(e));var N=(r,e)=>{var t={};for(var i in r)Nt.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&We)for(var i of We(r))e.indexOf(i)<0&&Kr.call(r,i)&&(t[i]=r[i]);return t};var f=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var ha=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of pa(e))!Nt.call(r,n)&&n!==t&&Ot(r,n,{get:()=>e[n],enumerable:!(i=la(e,n))||i.enumerable});return r};var Zr=(r,e,t)=>(t=r!=null?aa(ua(r)):{},ha(e||!r||!r.__esModule?Ot(t,"default",{value:r,enumerable:!0}):t,r));var jt=(r,e,t)=>e.has(r)||Yr("Cannot "+t);var S=(r,e,t)=>(jt(r,e,"read from private field"),t?t.call(r):e.get(r)),$=(r,e,t)=>e.has(r)?Yr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),O=(r,e,t,i)=>(jt(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Se=(r,e,t)=>(jt(r,e,"access private method"),t);var Xr=(r,e,t,i)=>({set _(n){O(r,e,n,t)},get _(){return S(r,e,i)}});var w=(r,e,t)=>new Promise((i,n)=>{var s=a=>{try{o(t.next(a))}catch(c){n(c)}},l=a=>{try{o(t.throw(a))}catch(c){n(c)}},o=a=>a.done?i(a.value):Promise.resolve(a.value).then(s,l);o((t=t.apply(r,e)).next())});var W=f((Gt,ai)=>{"use strict";var we=function(r){return r&&r.Math===Math&&r};ai.exports=we(typeof globalThis=="object"&&globalThis)||we(typeof window=="object"&&window)||we(typeof self=="object"&&self)||we(typeof global=="object"&&global)||we(typeof Gt=="object"&&Gt)||function(){return this}()||Function("return this")()});var ee=f((ip,oi)=>{"use strict";oi.exports=function(r){try{return!!r()}catch(e){return!0}}});var Le=f((np,li)=>{"use strict";var fa=ee();li.exports=!fa(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var di=f((sp,hi)=>{"use strict";var ma=Le(),ui=Function.prototype,ci=ui.apply,pi=ui.call;hi.exports=typeof Reflect=="object"&&Reflect.apply||(ma?pi.bind(ci):function(){return pi.apply(ci,arguments)})});var ne=f((ap,yi)=>{"use strict";var fi=Le(),mi=Function.prototype,zt=mi.call,ya=fi&&mi.bind.bind(zt,zt);yi.exports=fi?ya:function(r){return function(){return zt.apply(r,arguments)}}});var Wt=f((op,gi)=>{"use strict";var vi=ne(),va=vi({}.toString),ga=vi("".slice);gi.exports=function(r){return ga(va(r),8,-1)}});var Qt=f((lp,bi)=>{"use strict";var ba=Wt(),Ca=ne();bi.exports=function(r){if(ba(r)==="Function")return Ca(r)}});var te=f((cp,Ci)=>{"use strict";var Kt=typeof document=="object"&&document.all;Ci.exports=typeof Kt=="undefined"&&Kt!==void 0?function(r){return typeof r=="function"||r===Kt}:function(r){return typeof r=="function"}});var ye=f((pp,Ei)=>{"use strict";var Ea=ee();Ei.exports=!Ea(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var at=f((up,Ii)=>{"use strict";var Ia=Le(),st=Function.prototype.call;Ii.exports=Ia?st.bind(st):function(){return st.apply(st,arguments)}});var wi=f(Si=>{"use strict";var xi={}.propertyIsEnumerable,Ti=Object.getOwnPropertyDescriptor,xa=Ti&&!xi.call({1:2},1);Si.f=xa?function(e){var t=Ti(this,e);return!!t&&t.enumerable}:xi});var Yt=f((dp,Li)=>{"use strict";Li.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var _i=f((fp,Mi)=>{"use strict";var Ta=ne(),Sa=ee(),wa=Wt(),Zt=Object,La=Ta("".split);Mi.exports=Sa(function(){return!Zt("z").propertyIsEnumerable(0)})?function(r){return wa(r)==="String"?La(r,""):Zt(r)}:Zt});var Xt=f((mp,Ai)=>{"use strict";Ai.exports=function(r){return r==null}});var Jt=f((yp,Ri)=>{"use strict";var Ma=Xt(),_a=TypeError;Ri.exports=function(r){if(Ma(r))throw new _a("Can't call method on "+r);return r}});var ki=f((vp,Pi)=>{"use strict";var Aa=_i(),Ra=Jt();Pi.exports=function(r){return Aa(Ra(r))}});var Me=f((gp,Vi)=>{"use strict";var Pa=te();Vi.exports=function(r){return typeof r=="object"?r!==null:Pa(r)}});var er=f((bp,Oi)=>{"use strict";Oi.exports={}});var ir=f((Cp,ji)=>{"use strict";var tr=er(),rr=W(),ka=te(),Ni=function(r){return ka(r)?r:void 0};ji.exports=function(r,e){return arguments.length<2?Ni(tr[r])||Ni(rr[r]):tr[r]&&tr[r][e]||rr[r]&&rr[r][e]}});var $i=f((Ep,Fi)=>{"use strict";var Va=ne();Fi.exports=Va({}.isPrototypeOf)});var Hi=f((Ip,Di)=>{"use strict";var Oa=W(),Bi=Oa.navigator,qi=Bi&&Bi.userAgent;Di.exports=qi?String(qi):""});var Yi=f((xp,Ki)=>{"use strict";var Qi=W(),nr=Hi(),Ui=Qi.process,Gi=Qi.Deno,zi=Ui&&Ui.versions||Gi&&Gi.version,Wi=zi&&zi.v8,G,ot;Wi&&(G=Wi.split("."),ot=G[0]>0&&G[0]<4?1:+(G[0]+G[1]));!ot&&nr&&(G=nr.match(/Edge\/(\d+)/),(!G||G[1]>=74)&&(G=nr.match(/Chrome\/(\d+)/),G&&(ot=+G[1])));Ki.exports=ot});var sr=f((Tp,Xi)=>{"use strict";var Zi=Yi(),Na=ee(),ja=W(),Fa=ja.String;Xi.exports=!!Object.getOwnPropertySymbols&&!Na(function(){var r=Symbol("symbol detection");return!Fa(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Zi&&Zi<41})});var ar=f((Sp,Ji)=>{"use strict";var $a=sr();Ji.exports=$a&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var or=f((wp,en)=>{"use strict";var Ba=ir(),qa=te(),Da=$i(),Ha=ar(),Ua=Object;en.exports=Ha?function(r){return typeof r=="symbol"}:function(r){var e=Ba("Symbol");return qa(e)&&Da(e.prototype,Ua(r))}});var rn=f((Lp,tn)=>{"use strict";var Ga=String;tn.exports=function(r){try{return Ga(r)}catch(e){return"Object"}}});var lr=f((Mp,nn)=>{"use strict";var za=te(),Wa=rn(),Qa=TypeError;nn.exports=function(r){if(za(r))return r;throw new Qa(Wa(r)+" is not a function")}});var an=f((_p,sn)=>{"use strict";var Ka=lr(),Ya=Xt();sn.exports=function(r,e){var t=r[e];return Ya(t)?void 0:Ka(t)}});var ln=f((Ap,on)=>{"use strict";var cr=at(),pr=te(),ur=Me(),Za=TypeError;on.exports=function(r,e){var t,i;if(e==="string"&&pr(t=r.toString)&&!ur(i=cr(t,r))||pr(t=r.valueOf)&&!ur(i=cr(t,r))||e!=="string"&&pr(t=r.toString)&&!ur(i=cr(t,r)))return i;throw new Za("Can't convert object to primitive value")}});var pn=f((Rp,cn)=>{"use strict";cn.exports=!0});var dn=f((Pp,hn)=>{"use strict";var un=W(),Xa=Object.defineProperty;hn.exports=function(r,e){try{Xa(un,r,{value:e,configurable:!0,writable:!0})}catch(t){un[r]=e}return e}});var hr=f((kp,yn)=>{"use strict";var Ja=pn(),eo=W(),to=dn(),fn="__core-js_shared__",mn=yn.exports=eo[fn]||to(fn,{});(mn.versions||(mn.versions=[])).push({version:"3.38.0",mode:Ja?"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 bn=f((Vp,gn)=>{"use strict";var vn=hr();gn.exports=function(r,e){return vn[r]||(vn[r]=e||{})}});var dr=f((Op,Cn)=>{"use strict";var ro=Jt(),io=Object;Cn.exports=function(r){return io(ro(r))}});var lt=f((Np,En)=>{"use strict";var no=ne(),so=dr(),ao=no({}.hasOwnProperty);En.exports=Object.hasOwn||function(e,t){return ao(so(e),t)}});var xn=f((jp,In)=>{"use strict";var oo=ne(),lo=0,co=Math.random(),po=oo(1 .toString);In.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+po(++lo+co,36)}});var wn=f((Fp,Sn)=>{"use strict";var uo=W(),ho=bn(),Tn=lt(),fo=xn(),mo=sr(),yo=ar(),ve=uo.Symbol,fr=ho("wks"),vo=yo?ve.for||ve:ve&&ve.withoutSetter||fo;Sn.exports=function(r){return Tn(fr,r)||(fr[r]=mo&&Tn(ve,r)?ve[r]:vo("Symbol."+r)),fr[r]}});var An=f(($p,_n)=>{"use strict";var go=at(),Ln=Me(),Mn=or(),bo=an(),Co=ln(),Eo=wn(),Io=TypeError,xo=Eo("toPrimitive");_n.exports=function(r,e){if(!Ln(r)||Mn(r))return r;var t=bo(r,xo),i;if(t){if(e===void 0&&(e="default"),i=go(t,r,e),!Ln(i)||Mn(i))return i;throw new Io("Can't convert object to primitive value")}return e===void 0&&(e="number"),Co(r,e)}});var mr=f((Bp,Rn)=>{"use strict";var To=An(),So=or();Rn.exports=function(r){var e=To(r,"string");return So(e)?e:e+""}});var Vn=f((qp,kn)=>{"use strict";var wo=W(),Pn=Me(),yr=wo.document,Lo=Pn(yr)&&Pn(yr.createElement);kn.exports=function(r){return Lo?yr.createElement(r):{}}});var vr=f((Dp,On)=>{"use strict";var Mo=ye(),_o=ee(),Ao=Vn();On.exports=!Mo&&!_o(function(){return Object.defineProperty(Ao("div"),"a",{get:function(){return 7}}).a!==7})});var Fn=f(jn=>{"use strict";var Ro=ye(),Po=at(),ko=wi(),Vo=Yt(),Oo=ki(),No=mr(),jo=lt(),Fo=vr(),Nn=Object.getOwnPropertyDescriptor;jn.f=Ro?Nn:function(e,t){if(e=Oo(e),t=No(t),Fo)try{return Nn(e,t)}catch(i){}if(jo(e,t))return Vo(!Po(ko.f,e,t),e[t])}});var Bn=f((Up,$n)=>{"use strict";var $o=ee(),Bo=te(),qo=/#|\.prototype\./,_e=function(r,e){var t=Ho[Do(r)];return t===Go?!0:t===Uo?!1:Bo(e)?$o(e):!!e},Do=_e.normalize=function(r){return String(r).replace(qo,".").toLowerCase()},Ho=_e.data={},Uo=_e.NATIVE="N",Go=_e.POLYFILL="P";$n.exports=_e});var Hn=f((Gp,Dn)=>{"use strict";var qn=Qt(),zo=lr(),Wo=Le(),Qo=qn(qn.bind);Dn.exports=function(r,e){return zo(r),e===void 0?r:Wo?Qo(r,e):function(){return r.apply(e,arguments)}}});var Gn=f((zp,Un)=>{"use strict";var Ko=ye(),Yo=ee();Un.exports=Ko&&Yo(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Wn=f((Wp,zn)=>{"use strict";var Zo=Me(),Xo=String,Jo=TypeError;zn.exports=function(r){if(Zo(r))return r;throw new Jo(Xo(r)+" is not an object")}});var Yn=f(Kn=>{"use strict";var el=ye(),tl=vr(),rl=Gn(),ct=Wn(),Qn=mr(),il=TypeError,gr=Object.defineProperty,nl=Object.getOwnPropertyDescriptor,br="enumerable",Cr="configurable",Er="writable";Kn.f=el?rl?function(e,t,i){if(ct(e),t=Qn(t),ct(i),typeof e=="function"&&t==="prototype"&&"value"in i&&Er in i&&!i[Er]){var n=nl(e,t);n&&n[Er]&&(e[t]=i.value,i={configurable:Cr in i?i[Cr]:n[Cr],enumerable:br in i?i[br]:n[br],writable:!1})}return gr(e,t,i)}:gr:function(e,t,i){if(ct(e),t=Qn(t),ct(i),tl)try{return gr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new il("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Xn=f((Kp,Zn)=>{"use strict";var sl=ye(),al=Yn(),ol=Yt();Zn.exports=sl?function(r,e,t){return al.f(r,e,ol(1,t))}:function(r,e,t){return r[e]=t,r}});var ts=f((Yp,es)=>{"use strict";var Ae=W(),ll=di(),cl=Qt(),pl=te(),ul=Fn().f,hl=Bn(),ge=er(),dl=Hn(),be=Xn(),Jn=lt();hr();var fl=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 ll(r,this,arguments)};return e.prototype=r.prototype,e};es.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,s=r.proto,l=i?Ae:n?Ae[t]:Ae[t]&&Ae[t].prototype,o=i?ge:ge[t]||be(ge,t,{})[t],a=o.prototype,c,m,v,d,E,x,L,b,p;for(d in e)c=hl(i?d:t+(n?".":"#")+d,r.forced),m=!c&&l&&Jn(l,d),x=o[d],m&&(r.dontCallGetSet?(p=ul(l,d),L=p&&p.value):L=l[d]),E=m&&L?L:e[d],!(!c&&!s&&typeof x==typeof E)&&(r.bind&&m?b=dl(E,Ae):r.wrap&&m?b=fl(E):s&&pl(E)?b=cl(E):b=E,(r.sham||E&&E.sham||x&&x.sham)&&be(b,"sham",!0),be(o,d,b),s&&(v=t+"Prototype",Jn(ge,v)||be(ge,v,{}),be(ge[v],d,E),r.real&&a&&(c||!a[d])&&be(a,d,E)))}});var is=f((Zp,rs)=>{"use strict";var ml=Math.ceil,yl=Math.floor;rs.exports=Math.trunc||function(e){var t=+e;return(t>0?yl:ml)(t)}});var Ir=f((Xp,ns)=>{"use strict";var vl=is();ns.exports=function(r){var e=+r;return e!==e||e===0?0:vl(e)}});var as=f((Jp,ss)=>{"use strict";var gl=Ir(),bl=Math.min;ss.exports=function(r){var e=gl(r);return e>0?bl(e,9007199254740991):0}});var ls=f((eu,os)=>{"use strict";var Cl=as();os.exports=function(r){return Cl(r.length)}});var ps=f((tu,cs)=>{"use strict";cs.exports=function(){}});var us=f(()=>{"use strict";var El=ts(),Il=dr(),xl=ls(),Tl=Ir(),Sl=ps();El({target:"Array",proto:!0},{at:function(e){var t=Il(this),i=xl(t),n=Tl(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:t[s]}});Sl("at")});var ds=f((nu,hs)=>{"use strict";var wl=ir();hs.exports=wl});var ms=f((su,fs)=>{"use strict";us();var Ll=ds();fs.exports=Ll("Array","at")});var vs=f((au,ys)=>{"use strict";var Ml=ms();ys.exports=Ml});var xr=f((ou,gs)=>{"use strict";var _l=vs();gs.exports=_l});var Jr="1.0.22-dev.71ddf25e.0";function Ft(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",da="interactive-controls-container",Qe=()=>document.querySelector(`.${da}`),ei=.4,B={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},ti=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(ti||{}),ri=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(ri||{}),ii=(i=>(i.start="left",i.end="right",i.center="center",i))(ii||{}),Ke=({target:r,props:e})=>{var t,i,n,s,l,o;r.style.alignItems=(i=((t=e.text)==null?void 0:t.gravityVertical)&&ti[e.text.gravityVertical])!=null?i:"center",r.style.justifyContent=(s=((n=e.text)==null?void 0:n.gravityHorizontal)&&ri[e.text.gravityHorizontal])!=null?s:"center",r.style.textAlign=(o=((l=e.text)==null?void 0:l.alignment)&&ii[e.text.alignment])!=null?o:"left"},Ye=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,o,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} * ${(o=(l=e==null?void 0:e.text)==null?void 0:l.size)!=null?o:t.textSize})`,r.textContent=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},Ze=({target:r,props:e,fallback:t})=>{var i,n,s,l;r.style.backgroundColor=Ft((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(l=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?l:t.backgroundAlpha)},Xe=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,o,a,c,m,v,d,E,x;r.style.border=`calc(${i.height} * ${(l=(s=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:s.width)!=null?l:t.borderWidth}) solid ${Ft((c=(a=(o=e==null?void 0:e.shape)==null?void 0:o.border)==null?void 0:a.color)!=null?c:t.borderColor,(d=(v=(m=e==null?void 0:e.shape)==null?void 0:m.border)==null?void 0:v.alpha)!=null?d:t.borderAlpha)}`,r.style.borderRadius=`calc(${i.height} * ${(x=(E=e==null?void 0:e.shape)==null?void 0:E.roundCorners)!=null?x:t.roundCorners})`},fe=({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 K=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 $t="int",ie=(i=>(i.AREA=`${$t}_area`,i.TEXT=`${$t}_text`,i.BUTTON=`${$t}_bttn`,i))(ie||{});var Je=r=>{if(r.type.trim().toLowerCase()==="area")return new Bt(r)},Bt=class extends K{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",ie.AREA),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",Ze({target:i,props:this.control.props,fallback:C(h({},B),{backgroundColor:"transparent"})}),Xe({target:i,props:this.control.props,fallback:C(h({},B),{borderAlpha:0}),dependsOn:this.container.dimensions}),fe({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 et=()=>{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 tt=r=>{if(r.type.trim().toLowerCase()==="button")return new qt(r)},qt=class extends K{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",ie.BUTTON),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",i.style.fontFamily="inherit",fe({target:i,layoutParams:this.control.layoutParams,fallback:B}),Ze({target:i,props:this.control.props,fallback:B}),Xe({target:i,props:this.control.props,fallback:B,dependsOn:this.container.dimensions}),Ke({target:i,props:this.control.props});let n=et();Ye({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 ni=r=>{if(r.type.trim().toLowerCase()==="text")return new Dt(r)},Dt=class extends K{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",ie.TEXT),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.fontFamily="inherit",fe({target:i,layoutParams:this.control.layoutParams,fallback:B}),Ke({target:i,props:this.control.props});let n=et();Ye({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 Ht=class{constructor(e){this.layout=e}},rt=class extends Ht{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 J,it,si,me=class{constructor(e){$(this,J);this.container=e,this.factories=new Map,Se(this,J,it).call(this)}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),Se(this,J,it).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),Se(this,J,it).call(this)}};J=new WeakSet,it=function(){this.controls=Se(this,J,si).call(this)},si=function(){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);return s?[...t,s(i)]:[...t]},[])};var nt=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new Ut(r,e)},Ut=class extends me{constructor(e,t){super(e),this.rootElement=t!=null?t:Qe(),this.layout=new rt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",tt),this.addControlFactory("text",ni),this.addControlFactory("area",Je)}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 na=Zr(xr(),1);import{clientChecker as cc,combine as pc,InterfaceLanguage as uc,Observable as ta,once as hc,Subject as Pt,Subscription as ra,ValueSubject as H}from"@vkontakte/videoplayer-shared";import{InteractiveInterfaceClick as Ue}from"@vkontakte/videoplayer-statistics";import{loadVKLangPack as Al}from"@vkontakte/videoplayer-shared";function Re(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var se=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Pe=r=>se(r,"Object"),pt=r=>se(r,"String"),ut=r=>se(r,"Array"),ht=r=>se(r,"Number"),bs=r=>se(r,"Function");var Tr=r=>ht(r)&&!isNaN(r);var ae=r=>Pe(r)&&Object.keys(r).length===0,Sr=r=>ut(r)&&!r.length;var ke=(r,e)=>pt(r)&&(e?r.trim():r).length;var Cs="video_interactive",Es="videoint";var Is=250,Ve=class{constructor(e){this.handleZoomChange=Re(e=>{this.lastZoomInfo=e},Is);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,!ht(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=Rl(e),this.resizeObserver=new ResizeObserver(Re(this.onResize,Is)),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 w(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 w(this,null,function*(){if(!this.manifest)return;let e;try{e=yield Al(this.lang,Cs,Es)}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.ngEditor.on("control",s=>{var l=s,{name:i}=l,n=N(l,["name"]);var o;i==="openPreview"&&"chapterId"in n&&((o=this.onOpenPreviewClick)==null||o.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 Rl(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 Oe=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 l=s.startTime-e;if(l<=n&&(s.endTime&&n<=s.endTime||s.endTime===null)){i=!0;break}n<l&&(t=t===-1?l:Math.min(t,l))}return!i&&t!==-1?t:null}}};var re=(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};import{v4 as Pl}from"uuid";var kl="3.1",xs={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},Vl={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ts=r=>{let e=[];for(let l of r.chapters){let o,a=[];for(let t of l.branches){let i=t,{isDefault:v}=i,d=N(i,["isDefault"]);v&&(o=d.id),a.push(d)}let c=[],m=[];for(let n of l.containers){let s=n,{fallbackStrategy:v}=s,d=N(s,["fallbackStrategy"]);let E=!!d.endTime,x=[Vl];switch(v){case"await":E?x=[]:c=[];break;case"default":{let L={type:"onSuspense",action:{type:xs.default,args:{branchId:o,shouldOpenNow:!E,isDetachContainer:!0}}};E?x=[L]:c=[L];break}case"random":case"weightlessRandom":case"max":case"min":{let L={type:"onSuspense",action:{type:xs[v],args:{}}};E?x=[L]:c=[L];break}}for(let L of d.controls)m.push(C(h({},d),{controls:[h({},L)],id:Pl(),events:x}))}e.push(C(h({},l),{containers:m,events:c,branches:a}))}return r.metadata.version=kl,r.metadata.updated=new Date().toISOString(),C(h({},r),{chapters:e})};var Ol="3.2",Ss=r=>{if(!r.media){let e=r.metadata,{media:t}=e,i=N(e,["media"]);return C(h({},r),{metadata:C(h({},i),{version:Ol}),media:t})}return r};var Nl="3.3",jl=(r=[])=>({edit:{chapters:r},view:{}}),ws={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ls=r=>{var n;let e=[],t=[];for(let s of r.chapters){let i=s,{id:l,x:o,y:a}=i,c=N(i,["id","x","y"]),m=c.containers.map(v=>{var d;return C(h({},v),{controls:v.controls.map(b=>{var p=b,{subtype:E,type:x}=p,L=N(p,["subtype","type"]);return C(h({},L),{type:E!=null?E:x})}),events:(d=v.events)!=null&&d.length?v.events:[ws]})});e.push(C(h({id:l},c),{containers:m,events:(n=c.events)!=null&&n.length?c.events:[ws]})),t.push({id:l,x:o,y:a})}return C(h({},r),{chapters:e,graph:jl(t),metadata:C(h({},r.metadata),{version:Nl})})};var Fl=[{version:"3.0",migrate:Ts},{version:"3.1",migrate:Ss},{version:"3.2",migrate:Ls}],wr=r=>Fl.reduce((e,t)=>re(e.metadata.version,t.version)?e:t.migrate(e),r);var Ms={Button:"Button",Area:"Area",Text:"Text"};var A={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var _s={metadata:"Object",chapters:"Array"},$l="3.0.0",Bl="3.3.0",dt=r=>{let e=re(r,$l);return e===-1?!1:e===0?!0:re(r,Bl)!==1},As=r=>{if(!Pe(r))return!1;for(let e in _s)if(!r[e]||!se(r[e],_s[e]))return!1;return dt(r.metadata.version)},ft=r=>r.type===Ms.Text;var j=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var mt=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 yt=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{bs(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=[]}};import{ValueSubject as Wl}from"@vkontakte/videoplayer-shared";var vt=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 w(this,null,function*(){return ql(...this.loaders[e])(t)})}};function ql(...r){return function(t){return w(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function Ne(r,e,t){return r?C(h({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function gt(n){var s=n,{actions:r,errors:e,chapterId:t}=s,i=N(s,["actions","errors","chapterId"]);if(t){let l=r.getManifest(),o=r.getChapter(l.chapters,t);if(o){let a=r.getMedia(l.media,o.videoId),c=r.getGraph(l.graph,o.id);return a?C(h({},i),{actions:r,errors:e,result:{chapter:o,media:a,graph:c}}):C(h({},i),{errors:Ne(e,gt.name,"Could not find media"),actions:r})}}return C(h({},i),{errors:Ne(e,gt.name,"Could not find chapter"),actions:r})}var bt=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 l=i[n];try{l.callback.call(this,e)}catch(o){Promise.resolve().then(()=>{throw o})}l.options&&l.options.once&&this.removeEventListener(e.type,l.callback)}return!e.defaultPrevented}},Ce=class extends bt{constructor(){super(),this.listeners||bt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},je=class{constructor(){Object.defineProperty(this,"signal",{value:new Ce,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&&(je.prototype[Symbol.toStringTag]="AbortController",Ce.prototype[Symbol.toStringTag]="AbortSignal");function Ct(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 Lr(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Ct({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,m){let v;m&&m.signal&&(v=m.signal,delete m.signal);let d=new t(c,m);return v&&Object.defineProperty(d,"signal",{writable:!1,enumerable:!1,configurable:!0,value:v}),d},s.prototype=t.prototype);let l=e;return{fetch:(a,c)=>{let m=s&&s.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(m){let v;try{v=new DOMException("Aborted","AbortError")}catch(E){v=new Error("Aborted"),v.name="AbortError"}if(m.aborted)return Promise.reject(v);let d=new Promise((E,x)=>{m.addEventListener("abort",()=>x(v),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([d,l(a,c)])}return l(a,c)},Request:s}}var Fe=Ct({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Rs=Fe?Lr({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Mr=Fe?Rs.fetch:window.fetch,ch=Fe?Rs.Request:window.Request,ph=Fe?je:window.AbortController,uh=Fe?Ce:window.AbortSignal;var Dl=r=>w(void 0,null,function*(){try{let e={},t;if(pt(r)){t=new URL(r).href;let n=yield Mr(t);if(!n.ok)return{};e=yield n.json()}else if(Pe(r))e=r;else return{};if(!As(e))return{};let i=e.metadata.media;if(pt(i)&&!e.media)try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let s=yield Mr(n);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(n){return Gl(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function Ps(r){return w(this,null,function*(){let{manifest:e,manifestURL:t}=yield Dl(r),i=wr(e);return i.media=Hl(i.media,t),delete i.metadata.media,i})}function Et(r,e){if(e)return r.find(t=>t.id===e)}function _r(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 Ar(r,e){return r.videos.find(t=>t.id===e)}function Hl(r,e){return C(h({},r),{videos:r.videos.map(t=>C(h({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",s=Ul(n,e);return C(h({},i),{url:s||n})})}))})}function Ul(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Gl(r){return re(r,"3.2.0")>=0}var It=r=>ut(r)&&!Sr(r),Q=r=>r.order==="end",xt=r=>ut(r.containers)&&!Sr(r.containers)&&Q(r),ks=(r,e)=>{var i;let t=r*1e3;return It(e.controls)&&t<((i=e.startTime)!=null?i:0)},Rr=(r,e)=>{var i,n;let t=r*1e3;return It(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var oe=(r=[])=>r.some(e=>e.action.type==="expect"),Pr=(r=[])=>r.find(e=>e.action.type==="expect"),zl=r=>(r==null?void 0:r.length)===1,Tt=r=>zl(r)&&ft(r[0]);function Vs(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(h(h({},e[0]),t)):r(...e,...t)}var Os=(r,e)=>oe(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&oe(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var Ee=class extends vt{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Wl(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 w(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Ne},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield Ps((n=i.result)!=null?n:t),this})}setInitial(){return w(this,null,function*(){return this.setNext()})}setNext(){return w(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",gt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:_r,getChapter:Et,getMedia:Ar,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ne},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=Et(this.manifest.chapters,t);if(n){let s=Ar(this.manifest.media,n.videoId),l=_r(this.manifest.graph,n.id);if(s)return{chapter:n,media:s,graph:l}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,s,l;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((s=this.chapter)==null?void 0:s.branches);{let o=Et(((l=this.manifest)==null?void 0:l.chapters)||[],t);return this.getByBranches(o==null?void 0:o.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?Q(this.chapter):!1}};import{Player as Ql}from"@vkontakte/videoplayer-core";import{Subscription as Or,Tracer as Kl,ValueSubject as Yl}from"@vkontakte/videoplayer-shared";var Ns=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&"payload"in e){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};function kr(){let r=new Map;function e(a){var c=a,{listId:s=Math.random().toString(),itemId:l=Math.random().toString()}=c,o=N(c,["listId","itemId"]);let m=r.get(s),v=h({},o);return m?m[l]=v:r.set(s,{[l]:v}),h({listId:s,itemId:l},o)}function t(s){var l,o;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(l=s.statistics)==null||l.oneStat.destroy(),(o=s.statistics)==null||o.statSubscription.unsubscribe()}function i(s,l){let o=r.get(s);if(!o)throw Error("Can't remove. Not find.");if(l){let a=o[l];a&&t(a),delete o[l],Object.keys(o).length||r.delete(s)}else{for(let a of Object.values(o))t(a);r.delete(s)}}function n(){for(let s of r)i(s[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}function Vr(r,e=[]){var s,l,o;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||e.includes("mp4"))&&(t.MPEG=C(h({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"mpeg":(n||e.includes("mpeg"))&&(t.MPEG=C(h({},t.MPEG),{[(l=a.standard)!=null?l:"Invariant quality"]:a.url}));break;case"hls":(n||e.includes("hls"))&&(t=C(h({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(n||e.includes("dash"))&&(t=C(h({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(o=r.title)!=null?o:""}}var $e=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&i.includes(e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Zl=2;function Nr(r){let e=kr(),t=new Or,i={},n=null,s=!1,l,o=new Yl(null);r&&a(r);function a(b){n=b}function c(b,p,u){var y;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let T=((y=e.map.get(b))!=null?y:{})[p];if(T){i=h({chapterId:u,listId:b,itemId:p},T);let R=i.player;i.subscription.add(R.info.currentQuality$.subscribe(M=>{let q=R.info.position$.getValue(),P=R.info.isAutoQualityEnabled$.getValue();if(!(!M||!q||P))for(let V of e.map)Object.values(V[1]).forEach(({player:k})=>{$e(k,M)})})).add(R.events.started$.subscribe(()=>{m(p)})),T.container.remove(),n.setPlayer(T.player),s||(n.init(),s=!0),o.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}function m(b){return w(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(ae(i)||b!==i.itemId)return;let p=n.getChapterBranches(),u=new Set;for(let g of p)u.has(g.media.id)||(yield d({media:g.media,chapterId:g.chapter.id,setAsActive:!1,title:g.chapter.label}),u.add(g.media.id))})}function v(u){return w(this,arguments,function*({chapter:{id:b},manifestVideo:p}){if(ae(i)||!n)return;let g=i.player.info.muted$.getValue(),T=i.player.info.currentQuality$.getValue(),y=i.player.info.isAutoQualityEnabled$.getValue(),R=i.player.info.volume$.getValue(),M=i.player.info.currentPlaybackRate$.getValue(),q=!y,P=!1;for(let V of e.map)if(V[0]===p.id&&!n.state.isReplay$.getValue()){let k=Object.keys(V[1]);for(let F of k)F===i.itemId?(k.length<Zl||(P=!0),e.removePlayer(V[0],F)):(P=!0,c(V[0],F,b),q?$e(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(R),i.player.setMuted(g),i.player.setPlaybackRate(M))}else e.removePlayer(V[0]);P||(yield d({media:p,chapterId:b,setAsActive:!0,playbackRate:M}),q?$e(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(R),i.player.setMuted(g))})}function d(q){return w(this,arguments,function*({media:b,chapterId:p,prefetch:u=!0,setAsActive:g=!0,autoplay:T=!1,preferredExt:y,title:R,playbackRate:M}){var Dr,Hr,Ur,Gr,zr;let P=Math.random().toString(),V=document.createElement("div");l.append(V);let k;if((Dr=n==null?void 0:n.options)!=null&&Dr.vkVideoLoader){let ze=Ns(b);ze.length&&(k=yield n.options.vkVideoLoader(...ze))}let F=((Hr=n==null?void 0:n.options)==null?void 0:Hr.coreConfig)||void 0,Te=C(h({},F),{configName:[...(Ur=F==null?void 0:F.configName)!=null?Ur:[],"interactive"]}),Ge=C(h({container:V},((Gr=k==null?void 0:k.videos)==null?void 0:Gr[0])||{sources:Vr(b,y).sources}),{title:R,failoverHosts:(k==null?void 0:k.failoverHosts)||[]}),he=new Ql(Te,Kl.createRootTracer());he.initVideo(Ge);let Br=null;if(k!=null&&k.videos&&(n!=null&&n.options.createOneStat)){let ze=k.videos[0],Vt=n.options.createOneStat(ze),Wr=new Or;Vt&&(Wr.add(Vt.attachTo(he)),Br={oneStat:Vt,statSubscription:Wr})}let qr=new Or,sa=(zr=i==null?void 0:i.player)==null?void 0:zr.info.isAutoQualityEnabled$.getValue();qr.add(he.events.canplay$.subscribe(function(){sa||$e(he,i.player.info.currentQuality$.getValue()),M&&he.setPlaybackRate(M)}));let de=e.createPlayer({listId:b.id,itemId:P,player:he,container:V,sources:Vr(b,y).sources,config:Ge,subscription:qr,statistics:Br});return g&&c(b.id,de.itemId,p),T&&de.player.play(),u&&!T&&de.player.prepare(),{player:de.player,config:de.config,statistics:de.statistics}})}function E(){x(),n=null,l.remove()}function x(){t.unsubscribe(),e.removeAll(),i={},s=!1}function L(){return w(this,null,function*(){if(!n)throw Error("need to set interactive controller");x(),l=document.createElement("div");let{media:b,chapter:p}=n.getCurrentChapter();b&&p?(t.add(n.events.chapterChanged$.subscribe(v)),yield d({media:b,chapterId:p.id,title:p.label})):console.error("not found")})}return C(h({},e),{init:L,setInteractiveController:a,createPlayer:d,removeAll:E,getActivePlayer:function(){return i},activePlayerChanged:o})}var I={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Be={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},_={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};import{Subscription as Xl}from"@vkontakte/videoplayer-shared";var St=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:s,globalEventEmitter:l,ignoreContainerEvent:o,permanentTextControls:a,disabledControls$:c,onRemove:m}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(oe(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!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.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!0,isFirst:!1});else{let l=Vs(this.selectBranches.onControlEvent,{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})},onEvent:(o,a)=>{this.isSelectedControlEvent=!0,o!==!1&&(this.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})),(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),a(),this.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1}))},isEOV:()=>this.gameState===4});this.container.createView(l),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((t=(e=this.container).disable)==null||t.call(e))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var a;let e=this.player.experimental.element$.getValue(),i=e instanceof HTMLVideoElement?e.readyState:void 0,n=[6,5];if(!i||n.includes(this.gameState)&&!this.isPermanentText)return;let s=this.player.getExactTime();if(ks(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Rr(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let c=this.gameState;this.gameState=3,c===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let l=Rr(s,this.container.container),o=this.container.container.startTime?[this.container.container.startTime,(a=this.container.container.endTime)!=null?a:1/0]:[];this.globalEventEmitter.emit(I.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:o,currentTime:s,isInteractiveTime:l})};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Xl,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=o,this.isPermanentText=a&&Tt(t.container.controls),this.disabledControls$=c,this.onRemove=m,this.globalEventEmitter=l,this.gameState=0,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}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=oe(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.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.containerRemoved,visibility:!1}),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 js=(r=[])=>r.reduce((e,t,i)=>{var s,l,o;let n=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!ft(a));if(It(n)){let a=[(l=t.startTime)!=null?l:0,(o=t.endTime)!=null?o:1/0],c=t.id;if(!i)e.push({subjects:[c],range:a});else{let m=[],v=-1/0,d=1/0,E=[],x=[];for(let L=0;L<e.length;L++){let b=e[L];if(x.push(...b.subjects),b.range[0]<d&&(d=b.range[0]),b.range[1]>v&&(v=b.range[1]),a[0]>=b.range[0]&&a[1]<=b.range[1])return e[L].subjects.push(c),e;a[0]<b.range[0]&&a[1]>b.range[0]&&(m.push(L),E=E.concat(b.subjects)),a[0]>=b.range[0]&&a[0]<=b.range[1]&&(m.push(L),E=E.concat(b.subjects),a[0]=b.range[0]),a[1]>=b.range[0]&&a[1]<=b.range[1]&&(m.push(L),E=E.concat(b.subjects),a[1]=b.range[1])}if(x.push(c),a[0]<=d&&a[1]>=v)return[{subjects:x,range:a}];m.length&&m.reverse().forEach(L=>{e.splice(L,1)}),e.push({subjects:E.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);function Fs(){let r={};function e(){for(let o in r)Object.prototype.hasOwnProperty.call(r,o)&&delete r[o]}function t(o){let a={};for(let c in r)+c<=o&&(a[c]=r[c]);return a}function i(o){let a={};for(let c in r)+c>=o&&(a[c]=r[c]);return a}function n({timestamp:o,priority:a,initiator:c}){var m;if(Tr(o)){let v=(m=r[o])!=null?m:null;if(v&&a&&ke(a,!0)){let d={},E=v[a];if(E&&(d=h(h({},d),E)),d=ae(d)?null:d,d&&ke(c,!0)){let x=d[c];return x!=null?x:null}return d}return v}return null}function s({timestamp:o,priority:a,initiator:c}){if(Tr(o))if(r[o]){if(a&&ke(a,!0))if(r[o][a]){if(c&&ke(c,!0))if(r[o][a][c]){if(delete r[o][a][c],!ae(r[o][a]))return!0}else return!1;if(delete r[o][a],!ae(r[o]))return!0}else return!1;return delete r[o]}else return!1;return!1}function l(v){var d=v,{timestamp:o,priority:a,initiator:c}=d,m=N(d,["timestamp","priority","initiator"]);var E,x,L;(x=(E=r[o])==null?void 0:E[a])!=null&&x[c]?r[o][a][c].push(h({},m)):(L=r[o])!=null&&L[a]?r[o][a]=C(h({},r[o][a]),{[c]:[h({},m)]}):r[o]?r[o]=C(h({},r[o]),{[a]:{[c]:[h({},m)]}}):r[o]={[a]:{[c]:[h({},m)]}}}return{map:r,remove:s,add:l,removeAll:e,get:n,getLte:t,getGte:i}}var Jl=[A.expect,A.setNextBranch],ec=1/0;function $s(r){let e=r,t,i=tc(),n=Fs(),s,l=()=>{d(),p()},o=u=>{n.add.call(void 0,u),x()},a=(u=[])=>{for(let g of u)if(g.action(),Jl.includes(g.actionType))break},c=(u=1/0)=>{var R,M,q;let g=wt((R=n.get({timestamp:u,priority:"control"}))!=null?R:{}),T=wt((M=n.get({timestamp:u,priority:"container"}))!=null?M:{}),y=wt((q=n.get({timestamp:u,priority:"chapter"}))!=null?q:{});return[...g,...T,...y]},m=u=>{i.isReady(u)&&a(c(u))},v=()=>{var u;a([...wt((u=n.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},d=()=>{t&&(s==null||s.unsubscribe(),t=void 0)},E=u=>{},x=()=>{t||(t=()=>setTimeout(()=>{m(1/0)}),s=e.events.ended$.subscribe(t))},L=u=>{d(),e=u},b=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),n.remove(u)},p=()=>{i.release(),n.removeAll()};return{setPlayer:L,add:o,remove:b,exec:m,execEndOfVideo:v,listen:x,unlisten:d,release:l,containersEventsCallState:i,getPreparedToExecActions:c}}function tc(){let r=new Map;return{setCalled:({timestamp:l,id:o})=>{let a=r.get(l);a&&a[o]!==void 0&&(a[o]=!0)},setData:(l=[])=>{var o,a;for(let c of l){let m=(o=c.endTime)!=null?o:ec,v=(a=r.get(m))!=null?a:{};r.set(m,C(h({},v),{[c.id]:!1}))}},resetCalled:l=>{let o=r.get(l);if(o)for(let a in o)o[a]=!1},isReady:l=>{let o=r.get(l);return o?!Object.values(o).some(a=>!a):!0},release:()=>r.clear()}}function wt(r){return Object.values(r).flat().sort(e=>e.actionType===A.expect?-1:1)}var Bs={videoContentHeight:0,videoContentWidth:0},qs=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return Bs;let{clientHeight:n,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(n&&s))return Bs;let l=t/i,o=n/s,a,c;return o>l?(c=s,a=s*l):o<l?(c=n/l,a=n):(c=s,a=n),{videoContentWidth:c,videoContentHeight:a}};var rc=250;function Ds(r){let e=()=>{},t=new ResizeObserver(o=>{s(o),e=s.bind(null,o)});function i(o){let{parentElement:a,player:c}=r();if(a&&c){let{videoContentWidth:m,videoContentHeight:v}=qs(a,c);a.style.setProperty("--interactive-content-width",`${m}px`),a.style.setProperty("--interactive-content-height",`${v}px`),a.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function n(){let{parentElement:o}=r();o.removeAttribute("style")}let s=Re(o=>{let{fns:a=[]}=r();i(o);for(let c of a)c()},rc);function l(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:l}}var qe=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 ic=r=>Math.floor(Math.random()*r),Us=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let s=r[e],l=(n=s.weight)!=null?n:1;l<t&&(t=l,i=s)}return i},Gs=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let s=r[e],l=(n=s.weight)!=null?n:0;l>t&&(t=l,i=s)}return i};var zs=r=>{let e=r.length,t=ic(e);return r[t]},Hs=1,Ws=r=>{var i,n;let e=0;for(let s=0;s<r.length;++s)e+=(i=r[s].weight)!=null?i:Hs;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(n=r[s].weight)!=null?n:Hs,e>=t)return r[s];return r[r.length-1]};var Qs={shouldOpenNow:!0,isDetachContainer:!0};var jr=(r,e=!1)=>C(h({},r),{args:e?h(h({},r.args),Qs):h(h({},Qs),r.args)}),Zs=({globalEventEmitter:r,player:e,interactiveEvents:t,removeControllers:i})=>{let n={isExpect:!1},s=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:p,controlType:u,controlId:g,containerId:T,branches:y=[],onEvent:R,isEOV:M=()=>!1,isDisabled:q=()=>!1})=>{let P=jr(p,M()),V={timestamp:1/0,priority:"control",initiator:g,actionType:P.type},k=q(),F=r.emit.bind(r,I.interactives,{subjectId:g,subjectType:u,subjectName:"control",type:k?_.actionChoiceCanceled:_.actionChoice,actionType:p.type,payload:h({containerId:T},P.args)});if(k){F();return}switch(P.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{let Te=y.find(Ge=>Ge.id===P.args.branchId);if(!Te)return;R(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),F(),P.args.shouldOpenNow?x({subjectId:g,subjectName:"control",subjectType:u,action:P,payload:{chapterId:Te.chapterId,autoSelect:!1}}):(t.add(C(h({},V),{action:x.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:P,payload:{chapterId:Te.chapterId,autoSelect:!1}})})),i==null||i());return}case A.continuePlayback.trim().toLowerCase():{R(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),F(),P.args.shouldOpenNow?E({subjectId:g,subjectName:"control",subjectType:u,action:p}):t.add(C(h({},V),{action:E.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:p})}));return}case A.openURI.trim().toLowerCase():{R(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),F(),P.args.shouldOpenNow?b({subjectId:g,subjectName:"control",subjectType:u,action:P,payload:{URI:p.args.uri}}):(t.add(C(h({},V),{action:b.bind(null,{subjectId:g,subjectName:"control",subjectType:u,action:P,payload:{URI:p.args.uri}})})),i==null||i());return}default:console.error("Unexpected control event"),r.emit(I.errors,new j(1,1,{message:"Unexpected control event"}));return}},o=({action:p,container:{id:u,endTime:g},branches:T=[],isEOV:y=!1,autoSelected:R=!1})=>{let M=jr(p,y),q={timestamp:!M.args.shouldOpenNow||y?1/0:g!=null?g:1/0,priority:"container",initiator:u,actionType:M.type},P=r.emit.bind(r,I.interactives,{subjectId:u,subjectName:"container",type:_.actionChoice,actionType:M.type,payload:M.args});switch(M.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{let V=T.find(k=>k.id===M.args.branchId);if(!V)return;P(),t.add(C(h({},q),{action:x.bind(null,{subjectId:u,subjectName:"container",action:M,payload:{chapterId:V.chapterId,autoSelect:R}})})),i==null||i();return}case A.setMaxWeightBranch.trim().toLowerCase():return;case A.setMinWeightBranch.trim().toLowerCase():return;case A.setRandomBranch.trim().toLowerCase():return;case A.setWeightlessRandomBranch.trim().toLowerCase():return;case A.continuePlayback.trim().toLowerCase():{P(),t.add(C(h({},q),{action:E.bind(null,{subjectId:u,subjectName:"container",action:M})}));return}case A.openURI.trim().toLowerCase():{P(),t.add(C(h({},q),{action:b.bind(null,{subjectId:u,subjectName:"container",action:M,payload:{URI:p.args.uri}})})),i==null||i();return}default:console.error("Unexpected container event"),r.emit(I.errors,new j(1,1,{message:"Unexpected container event"}));return}};function a({container:p,branches:u,isEOV:g=!1}){var y,R;let T=Pr(p.events);if(T){let M=jr(T.action,g);r.emit(I.interactives,{subjectId:p.id,subjectName:"container",type:_.actionChoice,actionType:M.type,payload:M.args}),t.add({timestamp:g?1/0:(y=p.endTime)!=null?y:1/0,priority:"container",initiator:p.id,actionType:A.expect,action:v.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let M of(R=p.events)!=null?R:[])o({action:M.action,container:p,branches:u,isEOV:g})}let c=({chapterId:p,action:u,branches:g=[]})=>{let T=r.emit.bind(r,I.interactives,{subjectId:p,subjectName:"chapter",type:_.actionChoice,actionType:u.type,payload:u.args});switch(u.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{let y=g.find(R=>R.id===u.args.branchId);return y!=null&&y.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.setWeightlessRandomBranch.trim().toLowerCase():{let y=zs(g);return y!=null&&y.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.setRandomBranch.trim().toLowerCase():{let y=Ws(g);return y!=null&&y.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.setMaxWeightBranch.trim().toLowerCase():{let y=Gs(g);return y!=null&&y.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.setMinWeightBranch.trim().toLowerCase():{let y=Us(g);return y!=null&&y.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case A.continuePlayback.trim().toLowerCase():return T(),E.bind(null,{subjectId:p,subjectName:"chapter",action:u});case A.openURI.trim().toLowerCase():return T(),b.bind(null,{subjectId:p,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:console.error("Unexpected chapter event"),r.emit(I.errors,new j(1,1,{message:"Unexpected chapter event"}));return}};function m(p){var g;let u=Pr(p.events);if(u){if(Q(p))return;r.emit(I.interactives,{subjectId:p.id,subjectName:"chapter",type:_.actionChoice,actionType:u.action.type,payload:u.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:A.expect,action:v.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(g=p.events)==null||g.forEach(T=>{let y=c({chapterId:p.id,action:T.action,branches:p.branches});y&&t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:T.action.type,action:y})})}let v=({subjectId:p,subjectName:u})=>{e.pause(),r.emit(I.interactives,{subjectId:p,subjectName:u,type:_.actionExecution,actionType:A.expect})},d=({subjectId:p,subjectName:u})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),r.emit(I.interactives,{subjectId:p,subjectName:u,type:_.actionExecution,actionType:"after-expect"})},E=({subjectId:p,subjectName:u,subjectType:g,action:T})=>{r.emit(I.interactives,{subjectId:p,subjectName:u,subjectType:g,type:_.actionExecution,actionType:T.type})},x=({subjectId:p,subjectName:u,subjectType:g,action:T,payload:y})=>{y.behaviour="change-chapter",r.emit(I.interactives,{subjectId:p,subjectName:u,subjectType:g,type:_.actionExecution,actionType:T.type,payload:y})},L=({subjectId:p,subjectName:u,subjectType:g,action:T,payload:y})=>{y.behaviour="change-manifest",r.emit(I.interactives,{subjectId:p,subjectName:u,subjectType:g,type:_.actionExecution,actionType:T.type,payload:y})},b=({subjectId:p,subjectName:u,subjectType:g,action:T,payload:y})=>{if(!y.URI)return;let R=window.open(y.URI,"_blank","noopener,noreferrer");R&&(R.opener=null),r.emit(I.interactives,{subjectId:p,subjectName:u,subjectType:g,type:_.actionExecution,actionType:T.type})};return{onControlEvent:l,onContainerEvent:o,onChapterEvent:c,onExpectEvent:v,expectEventHandler:d,setManifestChapterEvents:m,setManifestContainerEvents:a,stopExpect:s,state:n}};var $r=Zr(xr(),1);import{Subscription as lc,ValueSubject as De}from"@vkontakte/videoplayer-shared";var Fr=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(l=>l.id===i);if(!n)return null;let s=e.media.videos.find(l=>n.videoId===l.id);if(!s)return null;t[i]=Xs(s)}return t[i]}).filter(Boolean)},sc=r=>{for(let e of r.variants)if(ac(e)&&"payload"in e)return e.payload.id},ac=r=>r.type==="custom"&&"payload"in r&&r.payload.type==="vk",Xs=r=>{let e=sc(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},oc=(r,e)=>{for(let t of r.media.videos)if(e===Xs(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},Js=(r,e)=>r.reduce((t,i)=>{let n=oc(e,i);return n?[...t,n]:t},[]);var Y,le,ce,U,Lt,Z,X,z,pe,Ie,xe,He=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new De([]),hasPrevChapter$:new De(!1),prevChapter$:new De(null),isInitialChapter$:new De(!1),isGoBackLimited$:new De(!1)};$(this,Y,null);$(this,le);$(this,ce,!1);$(this,U,null);$(this,Lt,null);$(this,Z,null);$(this,X,null);$(this,z,null);$(this,pe,new lc);$(this,Ie,!1);$(this,xe,0);var l;O(this,Z,t),O(this,z,e),O(this,X,i),O(this,Y,n),O(this,le,s),this.state.history$&&S(this,pe)&&((l=S(this,pe))==null||l.add(this.state.history$.subscribe(o=>{var a,c;this.state.prevChapter$.next((0,$r.default)(o,-2)||null),this.state.hasPrevChapter$.next(o.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(a=S(this,U))==null?void 0:a.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(S(this,xe)===S(this,le).maxLength-1)})))}setManifest(e){return w(this,null,function*(){!S(this,X)||!S(this,z)||(O(this,U,e),yield this.getProjectHistory(),yield S(this,X).setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),S(this,ce)||(O(this,ce,!0),S(this,z).emit(I.historyInited,{initChapterId:this.getInitialChapterId()})))})}get inited(){return S(this,ce)}updateHistory(e,t=!0){return w(this,null,function*(){var o;if(!S(this,U))return;S(this,Ie)?(O(this,Ie,!1),Xr(this,xe)._++):O(this,xe,0);let i=S(this,U),n=e.length-S(this,le).maxLength,s=n>0?e.slice(n):e,l=Fr(s,i);if(O(this,Lt,l),this.state.history$.next(s),!(!t||!S(this,Y)||!S(this,Z)))try{yield S(this,Y).save(S(this,Z),l)}catch(a){(o=S(this,z))==null||o.emit(I.errors,new j(1,5,"Unable to save interactive history"))}})}goBack(){return w(this,null,function*(){var i;if(!this.state||!S(this,X))return(i=S(this,z))==null?void 0:i.emit(I.errors,new j(1,5,"Cannot go back because HistoryController has not been initialized"));O(this,Ie,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield S(this,X).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return w(this,null,function*(){var n;if(!S(this,U)||!S(this,Z))return;let e=S(this,U),t=[this.getInitialVideoId()];if(S(this,Y))try{let s=yield S(this,Y).get(S(this,Z));s.length&&(t=s)}catch(s){(n=S(this,z))==null||n.emit(I.errors,new j(1,5,"Error while trying to fetch data"))}let i=Js(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,$r.default)(e,-1)||S(this,le).initChapterId||((t=S(this,U))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(S(this,U)){let e=this.getInitialChapterId();return Fr([e],S(this,U)).pop()}return null}destroy(){var e,t;O(this,Z,null),O(this,Y,null),O(this,X,null),(e=S(this,pe))==null||e.unsubscribe(),O(this,pe,null),O(this,ce,!1),(t=S(this,z))==null||t.emit(I.historyDestroyed),O(this,z,null)}};Y=new WeakMap,le=new WeakMap,ce=new WeakMap,U=new WeakMap,Lt=new WeakMap,Z=new WeakMap,X=new WeakMap,z=new WeakMap,pe=new WeakMap,Ie=new WeakMap,xe=new WeakMap;var ue=class ue{constructor(e,t,i,n){this.target=e,this.type=t,this.listener=i,this.options=ue._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(l=>!i.has(l));return n.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+n.join(",")),ue._doesSupportObject(e)?t:t.capture||!1}}static _doesSupportObject(e){let t=ue._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}ue._supportsObject=t}return t||!1}};ue._supportsObject=void 0;var Mt=ue;var _t=class{constructor(){this.bindingMap=new qe}release(){this.removeAll(),this.bindingMap=null}listen(e,t,i,n){if(!this.bindingMap)return;let s=new Mt(e,t,i,n);this.bindingMap.push(t,s)}listenOnce(e,t,i,n){let s=l=>{this.unlisten(e,t,s),i(l)};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 At=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 w(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 w(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 Rt=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;
@@ -11,13 +11,13 @@ var aa=Object.create;var Nt=Object.defineProperty,oa=Object.defineProperties,la=
11
11
  height: var(--interactive-height);
12
12
  background-color: var(--black);
13
13
  visibility: hidden;
14
- `,this.lastFrameCanvas=new Vt,this.endOffsetMs=t,this._callbacks={onError:i},this.lastFrameCanvas.rootElement.style.cssText=`
14
+ `,this.lastFrameCanvas=new At,this.endOffsetMs=t,this._callbacks={onError:i},this.lastFrameCanvas.rootElement.style.cssText=`
15
15
  position: absolute;
16
16
  top: 50%;
17
17
  left: 50%;
18
18
  transform: translate(-50%, -50%);
19
- `,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}updateCanvasDimensions(e=!1){return _(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 ea(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var ia=Object.freeze({lang:hc.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function dc(){let r=document.createElement("div");return r.style.cssText=`
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 w(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 ea(r=0){return new Promise(e=>{setTimeout(()=>{e(0)},r)})}var ia=Object.freeze({lang:uc.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}});function dc(){let r=document.createElement("div");return r.style.cssText=`
20
20
  position: absolute;
21
21
  top: 0;
22
22
  left: 0;
23
- `,r}var kt=class{constructor(e){this.subscription=new ra;this.globalEventEmitter=new yt;this.animation=new vt;this.eventManager=new Rt;this.seekToInteractiveController=new je;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=dc();this.factories=new Map([["choice",st]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new ra;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new G(null),isInitialChapter$:new G(!1),isFirstChapter$:new G(!0),isEndChapter$:new G(!1),isInteractiveExpectation$:new G(!1),calledByInteractive$:new G(!1),lastChapterChangeWasInitiatedByInteractive$:new G(!1),disabledControls$:new G(!1),interactiveRanges$:new G([]),isInteractiveTime$:new G(!1),statistics$:new G(null),isSeekable$:new G(!1)};this.events={noInteraction$:new Br,graphVisibilityChanged$:new Br,watchAgainIsClicked$:new Br};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&&K(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let n=e,{statistics:t}=n,i=N(n,["statistics"]);if(t){let{statSubscription:s,oneStat:l}=t;s.add(l.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.globalEventEmitter.emit(b.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=>E(h({},s),{subjects:s.subjects.filter(l=>l!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var t;this._options=E(h(h({},ia),e),{config:h(h({},ia.config),e.config)}),this._options.parentElement.append(this.rootElement),this.historyController=new Ue({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 At({parentElement:this._options.parentElement,onError:i=>this.globalEventEmitter.emit(b.errors,new F(1,6,i))})),this.eventManager.listen(this.rootElement,"mousedown",i=>i.stopPropagation()),this.eventManager.listen(this.rootElement,"mouseup",i=>i.stopPropagation()),this.manifestController=new xe(this._options.loaders,i=>this.globalEventEmitter.emit(b.errors,new F(1,3,i))),this.resizeManager=Hs(()=>{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 Ne({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(b.graph,{type:De.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>this.globalEventEmitter.emit(b.errors,new F(1,4,{message:i}))})),this.initSubscriptions()}initSubscriptions(){this.globalEventEmitter.on(b.historyInited,t=>_(this,[t],function*({videosInfo:e=[]}){this._options.initSeamless&&(yield this.initSeamless(),this.updateGraphVideosInfo(e))})),this.globalEventEmitter.on(b.interactives,e=>_(this,null,function*(){var t,i;if(e.type===M.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:s}=e.payload;this.setChapter({chapterId:s}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:s}=e.payload;this.setManifest(s)}let n=e.type==="action-execution";n&&e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):n&&e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)}e.type===M.containerRemoved&&this.completeInteractiveRange(e.subjectId)})),this.globalEventEmitter.on(b.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})}initSeamless(){return _(this,null,function*(){this.seamlessController=Nr(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(b.interactives,{type:M.rangeEnded,payload:n,visibility:!0}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.subscription.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.subscription.add(this.player.events.started$.pipe(pc()).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(uc({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:[y,d],subjects:C})=>y<c&&c<d&&C.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let s=!!this.noInteractionTimeout,o=((a=this.player)==null?void 0:a.info.playbackState$.getValue())==="playing"||i;n&&!s&&o?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):s&&!o&&this.clearNoInteractionTimeout()})),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=>!wt(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);if(s){let l=new St({player:this.player,container:s(i,this.rootElement),branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEventEmitter:this.globalEventEmitter,ignoreContainerEvent:()=>Os(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 o,a;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(o=i&&K(i)&&Tt(i))!=null?o:!1,s=((a=this.manifestController.manifest)==null?void 0:a.metadata.initChapterId)===e,l=this.historyController.state.history$.getValue();if(s||n&&t){this.historyController.updateHistory([e]);return}(0,na.default)(l,-1)!==e&&this.historyController.updateHistory([...l,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 _(this,null,function*(){this.reset(),this.isFirstChapterFetched=!1;let t=yield this.manifestController.setManifest(e);if(t.manifest)return this.graph&&(yield this.graph.handleManifestChange(t.manifest)),yield this.historyController.setManifest(t.manifest),this.globalEventEmitter.emit(b.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=Bs(this.player),this.selectBranches=Zs({player:this.player,interactiveEvents:this.interactiveEvents,globalEventEmitter:this.globalEventEmitter,removeControllers:()=>this.removeControllers(!1)}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){return _(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()),cc.isSafari&&(yield ea(35));let n=!i&&this.state.isEndChapter$.getValue()&&((a=this.getCurrentManifest())==null?void 0:a.metadata.initChapterId)===e,{chapter:s,media:l,graph:o}=yield e?this.manifestController.setNext(e):this.manifestController.setInitial();(!e||n)&&this.state.isFirstChapter$.next(!0),s&&(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.globalEventEmitter.emit(b.chapterChanged,{chapter:s,media:l,graph:o}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new ta(e=>{this.globalEventEmitter.on(b.graph,({type:t,visibility:i})=>{t==="visibility"&&e.next(i?ze.GRAPH_SHOW:ze.GRAPH_HIDE),t==="watchAgainClicked"&&e.next(ze.WATCH_AGAIN)}),this.globalEventEmitter.on(b.interactives,({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(ze.NEXT_BUTTON),n==="Area"&&e.next(ze.NEXT_AREA))})}),nextMovie$:new ta(e=>{this.globalEventEmitter.on(b.playerChanged,({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(b.graph,{type:De.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=this.graph)==null||t.updateVideosInfo(e))}deadEndCheck(){var i;return!(((i=this.interactiveEvents)==null?void 0:i.getPreparedToExecActions())||[]).some(n=>n.actionType===R.setNextBranch)}allControlsAreRemoved(){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!n.isRemoved&&n.endTime===null&&le(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&ft(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 Fs((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.globalEventEmitter.reset(),(s=this.lastFrame)==null||s.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var fc={Container:ve,createChoiceContainer:st,createAreaControl:et,createButtonControl:rt,getRootEl:Qe,classnamesPrefix:D};var Tf={version:Jr};export{F as CustomError,b as EVENT_NAMES,kt as Interactives,xe as ManifestController,Tf as SDKInfo,Fr as chapterIdsToVKVideoIds,ie as compareVersions,oc as getChapterIdByVkVideoId,Xs as getVKVideoIdByMedia,sc as getVideoRawIdByMedia,De as graphEventTypes,Tt as hasEndTemplate,M as interactivesEventTypes,K as isLastChapter,ft as isSupportedManifest,ac as isVKVariantItem,fc as utils,Js as vkVideoIdsToChapterIds};
23
+ `,r}var kt=class{constructor(e){this.subscription=new ra;this.globalEventEmitter=new mt;this.animation=new yt;this.eventManager=new _t;this.seekToInteractiveController=new Oe;this.endedRanges=new Set;this.gameControllers=[];this.rootElement=dc();this.factories=new Map([["choice",nt]]);this.isFirstChapterFetched=!1;this.player=null;this.interactiveEvents=null;this.selectBranches=null;this.seamlessController=null;this.seamlessControllerSubs=new ra;this.graph=null;this.lastFrame=null;this.appState=0;this.state={prevChapter$:new H(null),isInitialChapter$:new H(!1),isFirstChapter$:new H(!0),isEndChapter$:new H(!1),isInteractiveExpectation$:new H(!1),isReplay$:new H(!1),calledByInteractive$:new H(!1),lastChapterChangeWasInitiatedByInteractive$:new H(!1),disabledControls$:new H(!1),interactiveRanges$:new H([]),isInteractiveTime$:new H(!1),statistics$:new H(null),isSeekable$:new H(!1)};this.events={noInteraction$:new Pt,graphVisibilityChanged$:new Pt,watchAgainIsClicked$:new Pt,chapterChanged$:new Pt};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&&Q(i)&&!t&&this.historyController.updateHistory([]),window.removeEventListener("beforeunload",this.clearHistoryIfEnded)};this.handleSeamlessPlayerChanged=e=>{if(!e)return;let n=e,{statistics:t}=n,i=N(n,["statistics"]);if(t){let{statSubscription:s,oneStat:l}=t;s.add(l.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.globalEventEmitter.emit(I.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=>C(h({},s),{subjects:s.subjects.filter(l=>l!==e)}));t.next(n)};this.clearNoInteractionTimeout=()=>{this.noInteractionTimeout&&(clearTimeout(this.noInteractionTimeout),this.noInteractionTimeout=void 0)};var t;this._options=C(h(h({},ia),e),{config:h(h({},ia.config),e.config)}),this._options.parentElement.append(this.rootElement),this.historyController=new He({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 Rt({parentElement:this._options.parentElement,onError:i=>this.globalEventEmitter.emit(I.errors,new j(1,6,i))})),this.eventManager.listen(this.rootElement,"mousedown",i=>i.stopPropagation()),this.eventManager.listen(this.rootElement,"mouseup",i=>i.stopPropagation()),this.manifestController=new Ee(this._options.loaders,i=>this.globalEventEmitter.emit(I.errors,new j(1,3,i))),this.resizeManager=Ds(()=>{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 Ve({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),this.globalEventEmitter.emit(I.graph,{type:Be.watchAgainClicked,chapterId:i}),this.events.watchAgainIsClicked$.next(i)},onError:i=>this.globalEventEmitter.emit(I.errors,new j(1,4,{message:i}))})),this.initSubscriptions()}initSubscriptions(){this.globalEventEmitter.on(I.historyInited,t=>w(this,[t],function*({videosInfo:e=[]}){this._options.initSeamless&&(yield this.initSeamless(),this.updateGraphVideosInfo(e))})),this.globalEventEmitter.on(I.interactives,e=>w(this,null,function*(){var t,i;if(e.type===_.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((t=e.payload)==null?void 0:t.behaviour)==="change-chapter"){let{chapterId:s}=e.payload;this.setChapter({chapterId:s}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}if(((i=e.payload)==null?void 0:i.behaviour)==="change-manifest"){let{manifestURL:s}=e.payload;this.setManifest(s)}let n=e.type==="action-execution";n&&e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):n&&e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)}e.type===_.containerRemoved&&this.completeInteractiveRange(e.subjectId)})),this.globalEventEmitter.on(I.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})}initSeamless(){return w(this,null,function*(){this.seamlessController=Nr(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(I.interactives,{type:_.rangeEnded,payload:n,visibility:!0}))}}registerVideoEvents(){this.player&&(window.removeEventListener("beforeunload",this.clearHistoryIfEnded),this.subscription.unsubscribe(),window.addEventListener("beforeunload",this.clearHistoryIfEnded),this.subscription.add(this.player.events.started$.pipe(hc()).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(pc({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,d],subjects:E})=>v<c&&c<d&&E.length)}n!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(n);let s=!!this.noInteractionTimeout,o=((a=this.player)==null?void 0:a.info.playbackState$.getValue())==="playing"||i;n&&!s&&o?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):s&&!o&&this.clearNoInteractionTimeout()})),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=>!Tt(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);if(s){let l=new St({player:this.player,container:s(i,this.rootElement),branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEventEmitter:this.globalEventEmitter,ignoreContainerEvent:()=>Os(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 o,a;if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(o=i&&Q(i)&&xt(i))!=null?o:!1,s=((a=this.manifestController.manifest)==null?void 0:a.metadata.initChapterId)===e,l=this.historyController.state.history$.getValue();if(s||n&&t){this.historyController.updateHistory([e]);return}(0,na.default)(l,-1)!==e&&this.historyController.updateHistory([...l,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 w(this,null,function*(){this.reset(),this.isFirstChapterFetched=!1;let t=yield this.manifestController.setManifest(e);if(t.manifest)return this.graph&&(yield this.graph.handleManifestChange(t.manifest)),yield this.historyController.setManifest(t.manifest),this.globalEventEmitter.emit(I.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=$s(this.player),this.selectBranches=Zs({player:this.player,interactiveEvents:this.interactiveEvents,globalEventEmitter:this.globalEventEmitter,removeControllers:()=>this.removeControllers(!1)}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}setChapter(){return w(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()),cc.isSafari&&(yield ea(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:l,graph:o}=yield e?this.manifestController.setNext(e):this.manifestController.setInitial();(!e||n)&&this.state.isFirstChapter$.next(!0),!(!s||!l)&&(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:l}),this.globalEventEmitter.emit(I.chapterChanged,{chapter:s,media:l,graph:o}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)})}getStatEvents(){return{click$:new ta(e=>{this.globalEventEmitter.on(I.graph,({type:t,visibility:i})=>{t==="visibility"&&e.next(i?Ue.GRAPH_SHOW:Ue.GRAPH_HIDE),t==="watchAgainClicked"&&e.next(Ue.WATCH_AGAIN)}),this.globalEventEmitter.on(I.interactives,({type:t,subjectName:i,subjectType:n})=>{t!=="action-choice"||i!=="control"||(n==="Button"&&e.next(Ue.NEXT_BUTTON),n==="Area"&&e.next(Ue.NEXT_AREA))})}),nextMovie$:new ta(e=>{this.globalEventEmitter.on(I.playerChanged,({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(I.graph,{type:Be.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===A.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&&oe(n.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&dt(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 js((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.globalEventEmitter.reset(),(s=this.lastFrame)==null||s.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}};var fc={Container:me,createChoiceContainer:nt,createAreaControl:Je,createButtonControl:tt,getRootEl:Qe,classnamesPrefix:D};var Ef={version:Jr};export{j as CustomError,I as EVENT_NAMES,kt as Interactives,Ee as ManifestController,Ef as SDKInfo,Fr as chapterIdsToVKVideoIds,re as compareVersions,oc as getChapterIdByVkVideoId,Xs as getVKVideoIdByMedia,sc as getVideoRawIdByMedia,Be as graphEventTypes,xt as hasEndTemplate,_ as interactivesEventTypes,Q as isLastChapter,dt as isSupportedManifest,ac as isVKVariantItem,fc as utils,Js as vkVideoIdsToChapterIds};