@vkontakte/videoplayer-interactive 1.0.39-dev.25a92534.0 → 1.0.39-dev.3ba6f931.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.39-dev.25a92534.0
3
- * Mon, 09 Jun 2025 04:02:40 GMT
2
+ * @vkontakte/videoplayer-interactive v1.0.39-dev.3ba6f931.0
3
+ * Mon, 09 Jun 2025 09:41:10 GMT
4
4
  * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-39/doc/
5
5
  */
6
- var fl=Object.create;var sr=Object.defineProperty,vl=Object.defineProperties,bl=Object.getOwnPropertyDescriptor,yl=Object.getOwnPropertyDescriptors,gl=Object.getOwnPropertyNames,pt=Object.getOwnPropertySymbols,Cl=Object.getPrototypeOf,lr=Object.prototype.hasOwnProperty,Vi=Object.prototype.propertyIsEnumerable;var Ni=r=>{throw TypeError(r)};var Fi=(r,e,t)=>e in r?sr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,f=(r,e)=>{for(var t in e||(e={}))lr.call(e,t)&&Fi(r,t,e[t]);if(pt)for(var t of pt(e))Vi.call(e,t)&&Fi(r,t,e[t]);return r},x=(r,e)=>vl(r,yl(e));var J=(r,e)=>{var t={};for(var i in r)lr.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&pt)for(var i of pt(r))e.indexOf(i)<0&&Vi.call(r,i)&&(t[i]=r[i]);return t};var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var El=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of gl(e))!lr.call(r,n)&&n!==t&&sr(r,n,{get:()=>e[n],enumerable:!(i=bl(e,n))||i.enumerable});return r};var ee=(r,e,t)=>(t=r!=null?fl(Cl(r)):{},El(e||!r||!r.__esModule?sr(t,"default",{value:r,enumerable:!0}):t,r));var _i=(r,e,t)=>e.has(r)||Ni("Cannot "+t);var w=(r,e,t)=>(_i(r,e,"read from private field"),t?t.call(r):e.get(r)),z=(r,e,t)=>e.has(r)?Ni("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),_=(r,e,t,i)=>(_i(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var $i=(r,e,t,i)=>({set _(n){_(r,e,n,t)},get _(){return w(r,e,i)}});var R=(r,e,t)=>new Promise((i,n)=>{var o=s=>{try{l(t.next(s))}catch(c){n(c)}},a=s=>{try{l(t.throw(s))}catch(c){n(c)}},l=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,a);l((t=t.apply(r,e)).next())});var re=p((Sr,nn)=>{"use strict";var je=function(r){return r&&r.Math===Math&&r};nn.exports=je(typeof globalThis=="object"&&globalThis)||je(typeof window=="object"&&window)||je(typeof self=="object"&&self)||je(typeof global=="object"&&global)||je(typeof Sr=="object"&&Sr)||function(){return this}()||Function("return this")()});var W=p((Mm,on)=>{"use strict";on.exports=function(r){try{return!!r()}catch(e){return!0}}});var Be=p((Fm,an)=>{"use strict";var Fl=W();an.exports=!Fl(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var pn=p((Vm,un)=>{"use strict";var Vl=Be(),cn=Function.prototype,sn=cn.apply,ln=cn.call;un.exports=typeof Reflect=="object"&&Reflect.apply||(Vl?ln.bind(sn):function(){return ln.apply(sn,arguments)})});var X=p((Nm,mn)=>{"use strict";var hn=Be(),dn=Function.prototype,Ar=dn.call,Nl=hn&&dn.bind.bind(Ar,Ar);mn.exports=hn?Nl:function(r){return function(){return Ar.apply(r,arguments)}}});var qe=p((_m,vn)=>{"use strict";var fn=X(),_l=fn({}.toString),$l=fn("".slice);vn.exports=function(r){return $l(_l(r),8,-1)}});var wr=p(($m,bn)=>{"use strict";var jl=qe(),Bl=X();bn.exports=function(r){if(jl(r)==="Function")return Bl(r)}});var K=p((jm,yn)=>{"use strict";var Rr=typeof document=="object"&&document.all;yn.exports=typeof Rr=="undefined"&&Rr!==void 0?function(r){return typeof r=="function"||r===Rr}:function(r){return typeof r=="function"}});var fe=p((Bm,gn)=>{"use strict";var ql=W();gn.exports=!ql(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Pt=p((qm,Cn)=>{"use strict";var Dl=Be(),Ot=Function.prototype.call;Cn.exports=Dl?Ot.bind(Ot):function(){return Ot.apply(Ot,arguments)}});var kr=p(In=>{"use strict";var En={}.propertyIsEnumerable,Tn=Object.getOwnPropertyDescriptor,Hl=Tn&&!En.call({1:2},1);In.f=Hl?function(e){var t=Tn(this,e);return!!t&&t.enumerable}:En});var Or=p((Hm,xn)=>{"use strict";xn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var An=p((Um,Sn)=>{"use strict";var Ul=X(),Gl=W(),zl=qe(),Pr=Object,Wl=Ul("".split);Sn.exports=Gl(function(){return!Pr("z").propertyIsEnumerable(0)})?function(r){return zl(r)==="String"?Wl(r,""):Pr(r)}:Pr});var Lr=p((Gm,wn)=>{"use strict";wn.exports=function(r){return r==null}});var Mr=p((zm,Rn)=>{"use strict";var Kl=Lr(),Ql=TypeError;Rn.exports=function(r){if(Kl(r))throw new Ql("Can't call method on "+r);return r}});var De=p((Wm,kn)=>{"use strict";var Xl=An(),Yl=Mr();kn.exports=function(r){return Xl(Yl(r))}});var Se=p((Km,On)=>{"use strict";var Zl=K();On.exports=function(r){return typeof r=="object"?r!==null:Zl(r)}});var Lt=p((Qm,Pn)=>{"use strict";Pn.exports={}});var Mt=p((Xm,Mn)=>{"use strict";var Fr=Lt(),Vr=re(),Jl=K(),Ln=function(r){return Jl(r)?r:void 0};Mn.exports=function(r,e){return arguments.length<2?Ln(Fr[r])||Ln(Vr[r]):Fr[r]&&Fr[r][e]||Vr[r]&&Vr[r][e]}});var Vn=p((Ym,Fn)=>{"use strict";var ec=X();Fn.exports=ec({}.isPrototypeOf)});var jn=p((Zm,$n)=>{"use strict";var tc=re(),Nn=tc.navigator,_n=Nn&&Nn.userAgent;$n.exports=_n?String(_n):""});var zn=p((Jm,Gn)=>{"use strict";var Un=re(),Nr=jn(),Bn=Un.process,qn=Un.Deno,Dn=Bn&&Bn.versions||qn&&qn.version,Hn=Dn&&Dn.v8,Y,Ft;Hn&&(Y=Hn.split("."),Ft=Y[0]>0&&Y[0]<4?1:+(Y[0]+Y[1]));!Ft&&Nr&&(Y=Nr.match(/Edge\/(\d+)/),(!Y||Y[1]>=74)&&(Y=Nr.match(/Chrome\/(\d+)/),Y&&(Ft=+Y[1])));Gn.exports=Ft});var _r=p((ef,Kn)=>{"use strict";var Wn=zn(),rc=W(),ic=re(),nc=ic.String;Kn.exports=!!Object.getOwnPropertySymbols&&!rc(function(){var r=Symbol("symbol detection");return!nc(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Wn&&Wn<41})});var $r=p((tf,Qn)=>{"use strict";var oc=_r();Qn.exports=oc&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var jr=p((rf,Xn)=>{"use strict";var ac=Mt(),sc=K(),lc=Vn(),cc=$r(),uc=Object;Xn.exports=cc?function(r){return typeof r=="symbol"}:function(r){var e=ac("Symbol");return sc(e)&&lc(e.prototype,uc(r))}});var Zn=p((nf,Yn)=>{"use strict";var pc=String;Yn.exports=function(r){try{return pc(r)}catch(e){return"Object"}}});var Br=p((of,Jn)=>{"use strict";var hc=K(),dc=Zn(),mc=TypeError;Jn.exports=function(r){if(hc(r))return r;throw new mc(dc(r)+" is not a function")}});var to=p((af,eo)=>{"use strict";var fc=Br(),vc=Lr();eo.exports=function(r,e){var t=r[e];return vc(t)?void 0:fc(t)}});var io=p((sf,ro)=>{"use strict";var qr=Pt(),Dr=K(),Hr=Se(),bc=TypeError;ro.exports=function(r,e){var t,i;if(e==="string"&&Dr(t=r.toString)&&!Hr(i=qr(t,r))||Dr(t=r.valueOf)&&!Hr(i=qr(t,r))||e!=="string"&&Dr(t=r.toString)&&!Hr(i=qr(t,r)))return i;throw new bc("Can't convert object to primitive value")}});var oo=p((lf,no)=>{"use strict";no.exports=!0});var lo=p((cf,so)=>{"use strict";var ao=re(),yc=Object.defineProperty;so.exports=function(r,e){try{yc(ao,r,{value:e,configurable:!0,writable:!0})}catch(t){ao[r]=e}return e}});var Vt=p((uf,po)=>{"use strict";var gc=oo(),Cc=re(),Ec=lo(),co="__core-js_shared__",uo=po.exports=Cc[co]||Ec(co,{});(uo.versions||(uo.versions=[])).push({version:"3.38.0",mode:gc?"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 Ur=p((pf,mo)=>{"use strict";var ho=Vt();mo.exports=function(r,e){return ho[r]||(ho[r]=e||{})}});var He=p((hf,fo)=>{"use strict";var Tc=Mr(),Ic=Object;fo.exports=function(r){return Ic(Tc(r))}});var Ae=p((df,vo)=>{"use strict";var xc=X(),Sc=He(),Ac=xc({}.hasOwnProperty);vo.exports=Object.hasOwn||function(e,t){return Ac(Sc(e),t)}});var Gr=p((mf,bo)=>{"use strict";var wc=X(),Rc=0,kc=Math.random(),Oc=wc(1 .toString);bo.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Oc(++Rc+kc,36)}});var Ue=p((ff,go)=>{"use strict";var Pc=re(),Lc=Ur(),yo=Ae(),Mc=Gr(),Fc=_r(),Vc=$r(),we=Pc.Symbol,zr=Lc("wks"),Nc=Vc?we.for||we:we&&we.withoutSetter||Mc;go.exports=function(r){return yo(zr,r)||(zr[r]=Fc&&yo(we,r)?we[r]:Nc("Symbol."+r)),zr[r]}});var Io=p((vf,To)=>{"use strict";var _c=Pt(),Co=Se(),Eo=jr(),$c=to(),jc=io(),Bc=Ue(),qc=TypeError,Dc=Bc("toPrimitive");To.exports=function(r,e){if(!Co(r)||Eo(r))return r;var t=$c(r,Dc),i;if(t){if(e===void 0&&(e="default"),i=_c(t,r,e),!Co(i)||Eo(i))return i;throw new qc("Can't convert object to primitive value")}return e===void 0&&(e="number"),jc(r,e)}});var Wr=p((bf,xo)=>{"use strict";var Hc=Io(),Uc=jr();xo.exports=function(r){var e=Hc(r,"string");return Uc(e)?e:e+""}});var wo=p((yf,Ao)=>{"use strict";var Gc=re(),So=Se(),Kr=Gc.document,zc=So(Kr)&&So(Kr.createElement);Ao.exports=function(r){return zc?Kr.createElement(r):{}}});var Qr=p((gf,Ro)=>{"use strict";var Wc=fe(),Kc=W(),Qc=wo();Ro.exports=!Wc&&!Kc(function(){return Object.defineProperty(Qc("div"),"a",{get:function(){return 7}}).a!==7})});var Po=p(Oo=>{"use strict";var Xc=fe(),Yc=Pt(),Zc=kr(),Jc=Or(),eu=De(),tu=Wr(),ru=Ae(),iu=Qr(),ko=Object.getOwnPropertyDescriptor;Oo.f=Xc?ko:function(e,t){if(e=eu(e),t=tu(t),iu)try{return ko(e,t)}catch(i){}if(ru(e,t))return Jc(!Yc(Zc.f,e,t),e[t])}});var Mo=p((Ef,Lo)=>{"use strict";var nu=W(),ou=K(),au=/#|\.prototype\./,Ge=function(r,e){var t=lu[su(r)];return t===uu?!0:t===cu?!1:ou(e)?nu(e):!!e},su=Ge.normalize=function(r){return String(r).replace(au,".").toLowerCase()},lu=Ge.data={},cu=Ge.NATIVE="N",uu=Ge.POLYFILL="P";Lo.exports=Ge});var Xr=p((Tf,Vo)=>{"use strict";var Fo=wr(),pu=Br(),hu=Be(),du=Fo(Fo.bind);Vo.exports=function(r,e){return pu(r),e===void 0?r:hu?du(r,e):function(){return r.apply(e,arguments)}}});var _o=p((If,No)=>{"use strict";var mu=fe(),fu=W();No.exports=mu&&fu(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var jo=p((xf,$o)=>{"use strict";var vu=Se(),bu=String,yu=TypeError;$o.exports=function(r){if(vu(r))return r;throw new yu(bu(r)+" is not an object")}});var Do=p(qo=>{"use strict";var gu=fe(),Cu=Qr(),Eu=_o(),Nt=jo(),Bo=Wr(),Tu=TypeError,Yr=Object.defineProperty,Iu=Object.getOwnPropertyDescriptor,Zr="enumerable",Jr="configurable",ei="writable";qo.f=gu?Eu?function(e,t,i){if(Nt(e),t=Bo(t),Nt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&ei in i&&!i[ei]){var n=Iu(e,t);n&&n[ei]&&(e[t]=i.value,i={configurable:Jr in i?i[Jr]:n[Jr],enumerable:Zr in i?i[Zr]:n[Zr],writable:!1})}return Yr(e,t,i)}:Yr:function(e,t,i){if(Nt(e),t=Bo(t),Nt(i),Cu)try{return Yr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new Tu("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Uo=p((Af,Ho)=>{"use strict";var xu=fe(),Su=Do(),Au=Or();Ho.exports=xu?function(r,e,t){return Su.f(r,e,Au(1,t))}:function(r,e,t){return r[e]=t,r}});var We=p((wf,zo)=>{"use strict";var ze=re(),wu=pn(),Ru=wr(),ku=K(),Ou=Po().f,Pu=Mo(),Re=Lt(),Lu=Xr(),ke=Uo(),Go=Ae();Vt();var Mu=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 wu(r,this,arguments)};return e.prototype=r.prototype,e};zo.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,a=i?ze:n?ze[t]:ze[t]&&ze[t].prototype,l=i?Re:Re[t]||ke(Re,t,{})[t],s=l.prototype,c,d,v,b,g,S,E,m,u;for(b in e)c=Pu(i?b:t+(n?".":"#")+b,r.forced),d=!c&&a&&Go(a,b),S=l[b],d&&(r.dontCallGetSet?(u=Ou(a,b),E=u&&u.value):E=a[b]),g=d&&E?E:e[b],!(!c&&!o&&typeof S==typeof g)&&(r.bind&&d?m=Lu(g,ze):r.wrap&&d?m=Mu(g):o&&ku(g)?m=Ru(g):m=g,(r.sham||g&&g.sham||S&&S.sham)&&ke(m,"sham",!0),ke(l,b,m),o&&(v=t+"Prototype",Go(Re,v)||ke(Re,v,{}),ke(Re[v],b,g),r.real&&s&&(c||!s[b])&&ke(s,b,g)))}});var Ko=p((Rf,Wo)=>{"use strict";var Fu=Math.ceil,Vu=Math.floor;Wo.exports=Math.trunc||function(e){var t=+e;return(t>0?Vu:Fu)(t)}});var Ke=p((kf,Qo)=>{"use strict";var Nu=Ko();Qo.exports=function(r){var e=+r;return e!==e||e===0?0:Nu(e)}});var Yo=p((Of,Xo)=>{"use strict";var _u=Ke(),$u=Math.min;Xo.exports=function(r){var e=_u(r);return e>0?$u(e,9007199254740991):0}});var Qe=p((Pf,Zo)=>{"use strict";var ju=Yo();Zo.exports=function(r){return ju(r.length)}});var _t=p((Lf,Jo)=>{"use strict";Jo.exports=function(){}});var ea=p(()=>{"use strict";var Bu=We(),qu=He(),Du=Qe(),Hu=Ke(),Uu=_t();Bu({target:"Array",proto:!0},{at:function(e){var t=qu(this),i=Du(t),n=Hu(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});Uu("at")});var $t=p((Vf,ta)=>{"use strict";var Gu=Mt();ta.exports=Gu});var ia=p((Nf,ra)=>{"use strict";ea();var zu=$t();ra.exports=zu("Array","at")});var oa=p((_f,na)=>{"use strict";var Wu=ia();na.exports=Wu});var ti=p(($f,aa)=>{"use strict";var Ku=oa();aa.exports=Ku});var ba=p((_v,va)=>{"use strict";var ip=Ke(),np=Math.max,op=Math.min;va.exports=function(r,e){var t=ip(r);return t<0?np(t+e,0):op(t,e)}});var si=p(($v,ga)=>{"use strict";var ap=De(),sp=ba(),lp=Qe(),ya=function(r){return function(e,t,i){var n=ap(e),o=lp(n);if(o===0)return!r&&-1;var a=sp(i,o),l;if(r&&t!==t){for(;o>a;)if(l=n[a++],l!==l)return!0}else for(;o>a;a++)if((r||a in n)&&n[a]===t)return r||a||0;return!r&&-1}};ga.exports={includes:ya(!0),indexOf:ya(!1)}});var Ca=p(()=>{"use strict";var cp=We(),up=si().includes,pp=W(),hp=_t(),dp=pp(function(){return!Array(1).includes()});cp({target:"Array",proto:!0,forced:dp},{includes:function(e){return up(this,e,arguments.length>1?arguments[1]:void 0)}});hp("includes")});var Ta=p((qv,Ea)=>{"use strict";Ca();var mp=$t();Ea.exports=mp("Array","includes")});var xa=p((Dv,Ia)=>{"use strict";var fp=Ta();Ia.exports=fp});var rt=p((Hv,Sa)=>{"use strict";var vp=xa();Sa.exports=vp});var La=p((tb,Pa)=>{"use strict";var gp=Ur(),Cp=Gr(),Oa=gp("keys");Pa.exports=function(r){return Oa[r]||(Oa[r]=Cp(r))}});var Fa=p((rb,Ma)=>{"use strict";var Ep=W();Ma.exports=!Ep(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var _a=p((ib,Na)=>{"use strict";var Tp=Ae(),Ip=K(),xp=He(),Sp=La(),Ap=Fa(),Va=Sp("IE_PROTO"),ui=Object,wp=ui.prototype;Na.exports=Ap?ui.getPrototypeOf:function(r){var e=xp(r);if(Tp(e,Va))return e[Va];var t=e.constructor;return Ip(t)&&e instanceof t?t.prototype:e instanceof ui?wp:null}});var ja=p((nb,$a)=>{"use strict";$a.exports={}});var Da=p((ob,qa)=>{"use strict";var Rp=X(),pi=Ae(),kp=De(),Op=si().indexOf,Pp=ja(),Ba=Rp([].push);qa.exports=function(r,e){var t=kp(r),i=0,n=[],o;for(o in t)!pi(Pp,o)&&pi(t,o)&&Ba(n,o);for(;e.length>i;)pi(t,o=e[i++])&&(~Op(n,o)||Ba(n,o));return n}});var Ua=p((ab,Ha)=>{"use strict";Ha.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var za=p((sb,Ga)=>{"use strict";var Lp=Da(),Mp=Ua();Ga.exports=Object.keys||function(e){return Lp(e,Mp)}});var Za=p((lb,Ya)=>{"use strict";var Ka=fe(),Fp=W(),Qa=X(),Vp=_a(),Np=za(),_p=De(),$p=kr().f,Xa=Qa($p),jp=Qa([].push),Bp=Ka&&Fp(function(){var r=Object.create(null);return r[2]=2,!Xa(r,2)}),Wa=function(r){return function(e){for(var t=_p(e),i=Np(t),n=Bp&&Vp(t)===null,o=i.length,a=0,l=[],s;o>a;)s=i[a++],(!Ka||(n?s in t:Xa(t,s)))&&jp(l,r?[s,t[s]]:t[s]);return l}};Ya.exports={entries:Wa(!0),values:Wa(!1)}});var Ja=p(()=>{"use strict";var qp=We(),Dp=Za().values;qp({target:"Object",stat:!0},{values:function(e){return Dp(e)}})});var ts=p((pb,es)=>{"use strict";Ja();var Hp=Lt();es.exports=Hp.Object.values});var is=p((hb,rs)=>{"use strict";var Up=ts();rs.exports=Up});var Zt=p((db,ns)=>{"use strict";var Gp=is();ns.exports=Gp});var bi=p((qb,ps)=>{"use strict";var Yp=qe();ps.exports=Array.isArray||function(e){return Yp(e)==="Array"}});var ds=p((Db,hs)=>{"use strict";var Zp=TypeError,Jp=9007199254740991;hs.exports=function(r){if(r>Jp)throw Zp("Maximum allowed index exceeded");return r}});var vs=p((Hb,fs)=>{"use strict";var eh=bi(),th=Qe(),rh=ds(),ih=Xr(),ms=function(r,e,t,i,n,o,a,l){for(var s=n,c=0,d=a?ih(a,l):!1,v,b;c<i;)c in t&&(v=d?d(t[c],c,e):t[c],o>0&&eh(v)?(b=th(v),s=ms(r,e,v,b,s,o-1)-1):(rh(s+1),r[s]=v),s++),c++;return s};fs.exports=ms});var gs=p((Ub,ys)=>{"use strict";var nh=Ue(),oh=nh("toStringTag"),bs={};bs[oh]="z";ys.exports=String(bs)==="[object z]"});var Es=p((Gb,Cs)=>{"use strict";var ah=gs(),sh=K(),er=qe(),lh=Ue(),ch=lh("toStringTag"),uh=Object,ph=er(function(){return arguments}())==="Arguments",hh=function(r,e){try{return r[e]}catch(t){}};Cs.exports=ah?er:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=hh(e=uh(r),ch))=="string"?t:ph?er(e):(i=er(e))==="Object"&&sh(e.callee)?"Arguments":i}});var Is=p((zb,Ts)=>{"use strict";var dh=X(),mh=K(),yi=Vt(),fh=dh(Function.toString);mh(yi.inspectSource)||(yi.inspectSource=function(r){return fh(r)});Ts.exports=yi.inspectSource});var ks=p((Wb,Rs)=>{"use strict";var vh=X(),bh=W(),xs=K(),yh=Es(),gh=Mt(),Ch=Is(),Ss=function(){},As=gh("Reflect","construct"),gi=/^\s*(?:class|function)\b/,Eh=vh(gi.exec),Th=!gi.test(Ss),at=function(e){if(!xs(e))return!1;try{return As(Ss,[],e),!0}catch(t){return!1}},ws=function(e){if(!xs(e))return!1;switch(yh(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Th||!!Eh(gi,Ch(e))}catch(t){return!0}};ws.sham=!0;Rs.exports=!As||bh(function(){var r;return at(at.call)||!at(Object)||!at(function(){r=!0})||r})?ws:at});var Ms=p((Kb,Ls)=>{"use strict";var Os=bi(),Ih=ks(),xh=Se(),Sh=Ue(),Ah=Sh("species"),Ps=Array;Ls.exports=function(r){var e;return Os(r)&&(e=r.constructor,Ih(e)&&(e===Ps||Os(e.prototype))?e=void 0:xh(e)&&(e=e[Ah],e===null&&(e=void 0))),e===void 0?Ps:e}});var Vs=p((Qb,Fs)=>{"use strict";var wh=Ms();Fs.exports=function(r,e){return new(wh(r))(e===0?0:e)}});var Ns=p(()=>{"use strict";var Rh=We(),kh=vs(),Oh=He(),Ph=Qe(),Lh=Ke(),Mh=Vs();Rh({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Oh(this),i=Ph(t),n=Mh(t,0);return n.length=kh(n,t,t,i,0,e===void 0?1:Lh(e)),n}})});var _s=p(()=>{"use strict";var Fh=_t();Fh("flat")});var js=p((ey,$s)=>{"use strict";Ns();_s();var Vh=$t();$s.exports=Vh("Array","flat")});var qs=p((ty,Bs)=>{"use strict";var Nh=js();Bs.exports=Nh});var Hs=p((ry,Ds)=>{"use strict";var _h=qs();Ds.exports=_h});var ji="1.0.39-dev.25a92534.0";import{Subject as Ll,Subscription as Ml}from"@vkontakte/videoplayer-shared/es2015";var cr=class{constructor(e){this.layout=e}},ht=class extends cr{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} + ${2e-4}))`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};function Bi(r){return"features"in r}var Te=class{constructor(e,t){this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&Bi(this.options)&&this.options.features[e]}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){var e;return((e=this.container.controls)==null?void 0:e.reduce((t,i)=>{let n=i.type.trim().toLowerCase(),o=this.factories.get(n);if(o){let a=o(i,this.options);if(a)return[...t,a]}return[...t]},[]))||[]}};import{fromEvent as Et,once as wl}from"@vkontakte/videoplayer-shared/es2015";var ue=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,pe=r=>ue(r,"Object"),dt=r=>ue(r,"String"),mt=r=>ue(r,"Array"),ft=r=>ue(r,"Number"),qi=r=>ue(r,"Function"),Di=r=>ue(r,"Boolean"),ur=r=>ft(r)&&!isNaN(r);var de=r=>pe(r)&&Object.keys(r).length===0,pr=r=>mt(r)&&!r.length;var Ne=(r,e)=>dt(r)&&(e?r.trim():r).length;function _e(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 Hi="interactive",V={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},Ui=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(Ui||{}),Gi=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(Gi||{}),zi=(i=>(i.start="left",i.end="right",i.center="center",i))(zi||{}),vt=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&Ui[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&Gi[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&zi[e.alignment])!=null?n:"center"},bt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,o,a,l,s,c;r.style.color=(o=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?o:t.textColor,r.style.fontSize=`calc(${i.height} * ${(l=(a=e==null?void 0:e.text)==null?void 0:a.size)!=null?l:t.textSize})`,r.textContent=(c=(s=e==null?void 0:e.text)==null?void 0:s.value)!=null?c:t.textContent},yt=({target:r,props:e,fallback:t})=>{var i,n,o,a;r.style.backgroundColor=_e((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(a=(o=e==null?void 0:e.background)==null?void 0:o.alpha)!=null?a:t.backgroundAlpha)},$e=({target:r,props:e,fallback:t,dependsOn:i,useRawValues:n=!1})=>{var l,s,c,d,v,b,g,S,E,m,u;let o=n?t.borderWidthRawValue:`calc(${i.height} * ${(c=(s=(l=e==null?void 0:e.shape)==null?void 0:l.border)==null?void 0:s.width)!=null?c:t.borderWidth})`,a=n?t.roundCornersRawValue:`calc(${i.height} * ${(v=(d=e==null?void 0:e.shape)==null?void 0:d.roundCorners)!=null?v:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=_e(n?t.borderColor:(S=(g=(b=e==null?void 0:e.shape)==null?void 0:b.border)==null?void 0:g.color)!=null?S:t.borderColor,n?t.borderAlpha:(u=(m=(E=e==null?void 0:e.shape)==null?void 0:E.border)==null?void 0:m.alpha)!=null?u:t.borderAlpha),r.style.borderRadius=a},Wi=({target:r,isDark:e,baseDimension:t,fallback:i})=>{let a=_e(i.shadowColorLight,i.shadowColorAlpha),l=_e(i.shadowColorDark,i.shadowColorAlpha),s=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${s} ${c} ${e?l:a}`;r.style.boxShadow=d},Ie=({target:r,layoutParams:e,fallback:t})=>{var n;let i=(n=e.angle)!=null?n:t.angle;i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};import{fromEvent as fr,Subject as xl,Subscription as Sl,ValueSubject as Al}from"@vkontakte/videoplayer-shared/es2015";var hr="interactive-control-tap",xe={common:hr,animation:`${hr}-animation`,visible:`${hr}-visible`};var Tl=60,gt=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=Tl,useDimensionsBasedSize:n=!1}){this.onElementClick=e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let i=t.getBoundingClientRect(),n={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},o=Math.min(n.width,n.height),a=i.left+i.width/2,l=i.top+i.height/2,s=e.clientX-a,c=e.clientY-l,d=Il(s,c,this.controlRotateAngleRad);this.element.style.width=o+"px",this.element.style.left=d.x+i.width/2-o/2+"px",this.element.style.top=d.y+i.height/2-o/2+"px",this.element.classList.add(xe.visible,xe.animation)};this.onAnimationEnd=e=>{!e.target||!e.currentTarget||e.target===e.currentTarget&&this.element.classList.remove(xe.visible,xe.animation)};let o=document.createElement("div");o.classList.add(xe.common),this.controlRotateAngleRad=e,this.element=o,this.clickCancelCondition=t,this.circleDiameterPx=i,this.useDimensionsBasedSize=n}};function Il(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var dr="int",me=(i=>(i.AREA=`${dr}_area`,i.TEXT=`${dr}_text`,i.BUTTON=`${dr}_bttn`,i))(me||{});function mr(r){return"features"in r}var te="interactive-control",L={common:te,selected:`${te}-selected`,wrapper:`${te}-wrapper`,disabled:`${te}-disabled`,button:`${te}-button`,area:`${te}-area`,text:`${te}-text`,blinkAnim:`${te}-blink-anim`,blinkAnimButton:`${te}-blink-anim-button`,blinkAnimArea:`${te}-blink-anim-area`},Ki=40;var B=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var he=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new Sl;this.error$=new xl;this.isInteracted$=new Al(!1)}onError(e="",t){let i=new B(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(i)}addControlTap(e){var t;if(this.featureIsEnabled("controlsTapPlace")&&this.container){let i=(t=this.control.layoutParams.angle)!=null?t:V.angle;this.controlTap=new gt({controlRotateAngleRad:i,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?Ki:void 0}),this.subscriptions.add(fr(e,"click").subscribe(this.controlTap.onElementClick,n=>this.onError("Control click tap animation error",n))).add(fr(this.controlTap.element,"animationend").subscribe(this.controlTap.onAnimationEnd,n=>this.onError("Tap animationend error",n))),this.container.element.append(this.controlTap.element)}}createContainerElement(e){var o;let t=document.createElement("div");t.classList.add(L.wrapper),e.setControlLayout(t,this.control.layoutParams);let i=((o=this.control.layoutParams.innerSizesDependOn)!=null?o:V.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"},n=()=>{var a,l;return(l=(a=e.isContainerDisabled)==null?void 0:a.call(e))!=null?l:!1};this.container={element:t,dimensions:i,isManifestContainerDisabled:n}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted$.next(!0),e()}}featureIsEnabled(e){return this.options&&mr(this.options)&&this.options.features[e]}isTouch(){return this.options&&mr(this.options)&&this.options.isTouch}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add(fr(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),n=>this.onError("Error happened on control interaction",n)));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var yr="interactive-blink-anim-reference",q={common:yr,animation:`${yr}-animation`,disabled:`${yr}-disabled`},Ct=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(q.common,q.animation),this._element=e}restart(){this._element&&(this._element.classList.add(q.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(q.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var gr="interactive-container",D={common:gr,hidden:`${gr}-hidden`,disabled:`${gr}-disabled`};var Tt=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Cr(r,e)},Cr=class extends he{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(L.common,L.area),i.setAttribute("data-testid",me.AREA),yt({target:i,props:this.control.props,fallback:x(f({},V),{backgroundColor:"transparent"})}),Ie({target:i,layoutParams:this.control.layoutParams,fallback:V}),this.addControlTap(i),this.container.element.append(i),e.append(this.container.element),this.controlElement=i,this.updateShadowStyles(),this.registerEvents()}registerEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(Et(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(D.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${q.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(Et(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(D.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(Et(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(L.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(L.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){var t,i,n;if(!(!this.container||!this.controlElement))if(Di(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";Wi({target:this.controlElement,props:this.control.props,fallback:V,isDark:e,baseDimension:o}),$e({target:this.controlElement,props:this.control.props,fallback:x(f({},V),{borderColor:e?V.shadowColorDark:V.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${(n=(i=(t=this.control.props)==null?void 0:t.shape)==null?void 0:i.roundCorners)!=null?n:V.roundCorners})`}),dependsOn:this.container.dimensions,useRawValues:!0})}else $e({target:this.controlElement,props:this.control.props,fallback:x(f({},V),{borderAlpha:0}),dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(L.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(L.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${L.blinkAnimArea}`)||this.controlElement.classList.contains(L.selected)||this.controlElement.classList.contains(q.disabled)||(this.controlElement.classList.add(q.disabled),this.subscriptions.add(Et(e,"animationiteration").pipe(wl()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(q.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${L.blinkAnimArea}`)||this.controlElement.classList.contains(L.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}};import{fromEvent as wt,once as Pl}from"@vkontakte/videoplayer-shared/es2015";var It=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),i={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,i),t.append(e);let n={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,n),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var xt=Math.PI,Er=2*xt,St=xt/2,Qi=3*St,Rl=0,kl=[Rl,St,xt,Qi];function Xi(r){return r===St}function Yi(r){return r===xt}function Zi(r){return r===Qi}function Ji(r){return(r%Er+Er)%Er}function Ol(r){for(let e of kl)if(r===e)return e}function en(r){if(Ol(r))return null;let t=Math.floor(r/St)+1;return[1,2,3,4][t-1]}function tn(r){return r*180/Math.PI}var ae="interactive-control-fill-animation",H={common:ae,fillerWrapper:`${ae}-filler-wrapper`,filler:`${ae}-filler`,fillHeight:`${ae}-fill-height`,fillWidth:`${ae}-fill-width`,fromTop:`${ae}-from-top`,fromBottom:`${ae}-from-bottom`,fromLeft:`${ae}-from-left`,fromRight:`${ae}-from-right`};var At=class r{constructor(e){this.widthExpansionCoef=0;var m;let t=document.createElement("div");t.classList.add(H.common);let i=document.createElement("div");i.classList.add(H.fillerWrapper);let n=document.createElement("div");n.classList.add(H.filler),i.append(n),t.append(i);let o=Ji(e.rotateAngle),a=en(o),l=a!==null,c=a===2||!l&&Yi(o)||a===3,d=!l&&Xi(o),v=!l&&Zi(o),b=!c&&!d&&!v,g=d||v,S=l&&!g,E=S?o:0;t.style.borderRadius=e.borderRadius,i.style.transform=`skew(${E*-1}rad)`,g?(n.classList.add(H.fillHeight,d?H.fromTop:H.fromBottom),i.classList.add(H.fillHeight,d?H.fromTop:H.fromBottom)):(n.classList.add(H.fillWidth,b?H.fromLeft:H.fromRight),i.classList.add(H.fillWidth)),e.debug&&console.log(`[interactive ${r.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:g,rotateAngleRad:o,rotateAngelDeg:tn(o),rotateAngleRaw:e.rotateAngle,fromRight:c,fromTop:d,fromBottom:v,fromLeft:b}),this.useSkew=S,this.fromLeft=b,this.rotateAngle=o,this.fillAnimationElement=t,this.fillAnimationFillerElement=n,this.fillAnimationFillerWrapperElement=i,this.startTime=e.startTime,this.endTime=e.endTime,this.shouldFillHeight=g,this.isDebug=(m=e.debug)!=null?m:!1}updateDimension(e){this.fillAnimationElement.style.top=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.left=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.width=`${e.width}px`,this.fillAnimationElement.style.height=`${e.height}px`;let t=this.calcWidthExpansionCoef({rotateAngle:this.rotateAngle,isSkewed:this.useSkew,initWidth:e.width,initHeight:e.height});!this.shouldFillHeight&&(this.fillAnimationFillerWrapperElement.style.width=100*t+100+"%",this.fillAnimationFillerWrapperElement.style[`${this.fromLeft?"left":"right"}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((o=>o<this.startTime||o>this.endTime)(e))return;let i=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/i,0),1);this.shouldFillHeight?this.fillAnimationFillerElement.style.transform=`scaleY(${n})`:this.fillAnimationFillerElement.style.transform=`scaleX(${n})`}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:i,initHeight:n}){return t?(i+n*Math.abs(Math.tan(e)))/i-1:0}};var Rt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new Tr(r,e)},Tr=class extends he{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a,l,s,c,d,v;if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(L.common,L.button),i.setAttribute("data-testid",me.BUTTON),Ie({target:i,layoutParams:this.control.layoutParams,fallback:V}),yt({target:i,props:this.control.props,fallback:V}),$e({target:i,props:this.control.props,fallback:V,dependsOn:this.container.dimensions}),vt({target:i,props:x(f({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let n=It(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;bt({target:o,props:this.control.props,fallback:V,dependsOn:this.container.dimensions}),this.addControlTap(i),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled("controlsFillAnimation")&&(this.controlFillAnimation=new At({startTime:this.startTime,endTime:this.endTime,rotateAngle:(l=this.control.layoutParams.angle)!=null?l:V.angle,borderRadius:i.style.borderRadius})),i.append(n,(c=(s=this.controlFillAnimation)==null?void 0:s.fillAnimationElement)!=null?c:""),this.container.element.append((v=(d=this.controlTap)==null?void 0:d.element)!=null?v:"",i),e.append(this.container.element),this.controlElement=i,this.registerEvents()}registerEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(wt(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(D.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${q.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(wt(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(D.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(wt(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(L.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(L.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(L.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(L.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${L.blinkAnimButton}`)||this.controlElement.classList.contains(L.selected)||this.controlElement.classList.contains(q.disabled)||(this.controlElement.classList.add(q.disabled),this.subscriptions.add(wt(e,"animationiteration").pipe(Pl()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(q.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${L.blinkAnimButton}`)||this.controlElement.classList.contains(L.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}updateFillAnimationDimensions(){if(!this.container||!this.controlElement||!this.controlFillAnimation)return;let e=getComputedStyle(this.controlElement),t={width:parseFloat(e.width),height:parseFloat(e.height),borderWidth:parseFloat(e.borderWidth)||0};this.controlFillAnimation.updateDimension(t)}setShowTimeRange(e,t){this.startTime=e,this.endTime=t}onProgress(e){var t;(t=this.controlFillAnimation)==null||t.updateAnimation(e)}onResize(){this.updateFillAnimationDimensions()}updateShadowStyles(){}};var rn=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new Ir(r,e)},Ir=class extends he{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a;if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(L.common,L.text),i.setAttribute("data-testid",me.TEXT),Ie({target:i,layoutParams:this.control.layoutParams,fallback:V}),vt({target:i,props:x(f({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let n=It(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;bt({target:o,props:this.control.props,fallback:V,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}setShowTimeRange(){}updateFillAnimationDimensions(){}onError(){}};var kt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new xr(r,e,t)},xr=class extends Te{constructor(t,i,n){super(t,n);this.containerElement=null;this.controlSubscriptions=new Ml;this.error$=new Ll;this.rootElement=i,this.layout=new ht(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Rt),this.addControlFactory("text",rn),this.addControlFactory("area",Tt)}createView({eventCallback:t,videoDurationMs:i}){let n=document.createElement("div");return n.classList.add(D.common,D.disabled),requestAnimationFrame(()=>{n.classList.remove(D.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(o=>{var a;o.setShowTimeRange(this.container.startTime,(a=this.container.endTime)!=null?a:i),o.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout,isContainerDisabled:()=>this.isDisabled}}),o.setEvents(t),this.controlSubscriptions.add(o.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,this.updateControlsFillAnimationDimensions(),n}updateControlsFillAnimationDimensions(){for(let t of this.controls)t.updateFillAnimationDimensions()}hide(){let t=this.getElement();t&&t.classList.add(D.hidden)}show(){let t=this.getElement();t&&t.classList.remove(D.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(D.disabled),this.controls.forEach(i=>i.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(D.disabled),this.controls.forEach(i=>i.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(this.controlSubscriptions.unsubscribe(),this.controls.forEach(i=>i.removeListeners()),t.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,i){i&&this.controls.forEach(n=>{n.onProgress(t)})}onResize(t){t&&this.controls.forEach(i=>{i.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(i=>i.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(i=>i.toggleBlinkAnimation(t))}};var dl=ee(ti(),1);import{combine as Qh,InterfaceLanguage as Xh,Observable as ul,once as Yh,Subject as U,Subscription as Si,ValueSubject as G,fromEvent as pl}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as ct}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as Qu}from"@vkontakte/videoplayer-shared/es2015";function Xe(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var sa="video_interactive",la="videoint";var ca=250,Ye=class{constructor(e){this.handleZoomChange=Xe(e=>{this.lastZoomInfo=e},ca);this.onResize=e=>{var i;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((i=this.ngEditor)==null||i.zoomTo(t,void 0,{isFromCenter:!0})),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,i,n;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Chapter id is not found");return}this.visitedChapterIds.add(e.id),(i=this.ngEditor)==null||i.selectChapter(e.id),(n=this.ngEditor)==null||n.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var i;if(this.isReady=!1,!ft(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:i,lang:n,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,this.onError=i,this.lang=n!=null?n:"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Xu(e),this.resizeObserver=new ResizeObserver(Xe(this.onResize,ca)),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 R(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 R(this,null,function*(){var i;if(!this.manifest)return;let e;try{e=yield Qu(this.lang,sa,la)}catch(n){(i=this.onError)==null||i.call(this,"Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",a=>{var l=a,{name:n}=l,o=J(l,["name"]);var s;n==="openPreview"&&"chapterId"in o&&((s=this.onOpenPreviewClick)==null||s.call(this,o.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0})}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Xu(r){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",r.append(e),e}var Ze=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,i=!1,n=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let a=o.startTime-e;if(a<=n&&(o.endTime&&n<=o.endTime||o.endTime===null)){i=!0;break}n<a&&(t=t===-1?a:Math.min(t,a))}return!i&&t!==-1?t:null}}};import{isSupportedManifest as Bt,ContainerTypes as uv,ControlTypes as qt,EventActionTypes as P,EventTypes as pv,migrateManifestToLatestVersion as da,compareVersions as hv}from"@interactiveplatform/movika-manifest";var ua={metadata:"Object",chapters:"Array"},pa=r=>{if(!pe(r))return!1;for(let e in ua)if(!r[e]||!ue(r[e],ua[e]))return!1;return Bt(r.metadata.version)},jt=r=>r.type===qt.Text,rv=r=>r.type===qt.Button,iv=r=>r.type===qt.Area,nv={Choice:"Choice",TextInput:"TextInput"},ov={Button:"Button",Area:"Area",Text:"Text"},av={onClick:"onClick",onSuspense:"onSuspense"},ha={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Dt=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 Ht=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{qi(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 yp}from"@vkontakte/videoplayer-shared/es2015";var Ut=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 R(this,null,function*(){return Yu(...this.loaders[e])(t)})}};function Yu(...r){return function(t){return R(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function Je(r,e,t){return r?x(f({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Gt(n){var o=n,{actions:r,errors:e,chapterId:t}=o,i=J(o,["actions","errors","chapterId"]);if(t){let a=r.getManifest();if(a){let l=r.getChapter(a.chapters,t);if(l){let s=r.getMedia(a.media,l.videoId),c=r.getGraph(a.graph,l.id);return s?x(f({},i),{actions:r,errors:e,result:{chapter:l,media:s,graph:c}}):x(f({},i),{errors:Je(e,Gt.name,"Could not find media"),actions:r})}}}return x(f({},i),{errors:Je(e,Gt.name,"Could not find chapter"),actions:r})}var zt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let n=0,o=i.length;n<o;n++)if(i[n].callback===t){i.splice(n,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let i=this.listeners[e.type].slice();for(let n=0,o=i.length;n<o;n++){let a=i[n];try{a.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}a.options&&a.options.once&&this.removeEventListener(e.type,a.callback)}return!e.defaultPrevented}},Oe=class extends zt{constructor(){super(),this.listeners||zt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},et=class{constructor(){Object.defineProperty(this,"signal",{value:new Oe,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(n){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let i=e;if(i===void 0)if(typeof document=="undefined")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch(n){i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(et.prototype[Symbol.toStringTag]="AbortController",Oe.prototype[Symbol.toStringTag]="AbortSignal");function Wt(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 ri(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Wt({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||n)&&(o=function(c,d){let v;d&&d.signal&&(v=d.signal,delete d.signal);let b=new t(c,d);return v&&Object.defineProperty(b,"signal",{writable:!1,enumerable:!1,configurable:!0,value:v}),b},o.prototype=t.prototype);let a=e;return{fetch:(s,c)=>{let d=o&&o.prototype.isPrototypeOf(s)?s.signal:c?c.signal:void 0;if(d){let v;try{v=new DOMException("Aborted","AbortError")}catch(g){v=new Error("Aborted"),v.name="AbortError"}if(d.aborted)return Promise.reject(v);let b=new Promise((g,S)=>{d.addEventListener("abort",()=>S(v),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([b,a(s,c)])}return a(s,c)},Request:o}}var Zu=()=>"fetch"in window,tt=Zu()&&Wt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),ma=tt?ri({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,ii=tt?ma.fetch:window.fetch,Av=tt?ma.Request:window.Request,wv=tt?et:window.AbortController,Rv=tt?Oe:window.AbortSignal;var ni=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let o=0;o<Math.max(t.length,i.length)&&!n;o++)t[o]>i[o]?n=1:t[o]<i[o]?n=-1:n=0;return n};var Ju=r=>R(void 0,null,function*(){try{let e={},t;if(dt(r)){t=new URL(r).href;let n=yield ii(t);if(!n.ok)return{};e=yield n.json()}else if(pe(r))e=r;else return{};if(!pa(e))return{};let i=e.metadata.media;if(dt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=yield ii(n);if(!o.ok)throw new Error;e.metadata.media=yield o.json()}catch(n){return rp(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function fa(r){return R(this,null,function*(){let{manifest:e,manifestURL:t}=yield Ju(r);if(!e)throw new Error("Failed on fetch");let i=da(e);return i.media=ep(i.media,t),delete i.metadata.media,i})}function Kt(r,e){if(e)return r.find(t=>t.id===e)}function oi(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 ai(r,e){return r.videos.find(t=>t.id===e)}function ep(r,e){return x(f({},r),{videos:r.videos.map(t=>x(f({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=tp(n,e);return x(f({},i),{url:o||n})})}))})}function tp(r="",e){try{return new URL(r,e).href}catch(t){return""}}function rp(r){return ni(r,"3.2.0")>=0}var Aa=ee(rt(),1);var Qt=r=>mt(r)&&!pr(r),ie=r=>r.order==="end",Xt=r=>mt(r.containers)&&!pr(r.containers)&&ie(r),wa=(r,e)=>{var i;let t=r*1e3;return Qt(e.controls)&&t<((i=e.startTime)!=null?i:0)},li=(r,e)=>{var i,n;let t=r*1e3;return Qt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var ve=(r=[])=>r.some(e=>e.action.type==="expect"),ci=(r=[])=>r.find(e=>e.action.type==="expect"),bp=r=>(r==null?void 0:r.length)===1,Pe=r=>bp(r)&&jt(r[0]);function Ra(r=[],e=1/0,t=[]){return r.filter(({container:i})=>!(0,Aa.default)(t,i.container.id)&&ve(i.container.events)&&i.container.endTime===e&&!i.isRemoved)}function Yt({gameControllers:r=[],subjectName:e,subjectId:t,execFn:i}){for(let n of r)if(e==="container"&&n.container.container.id===t){i(n),Ra(r,n.container.container.endTime,[n.container.container.id]).forEach(a=>{i(a)});break}}var ka=(r,e)=>{let t=E=>{let m=e.find(({container:u})=>u.container.id===E);return m==null?void 0:m.container.isRemoved},i=ve(r.events)&&!t(r.id),n=(E,m=!1,u=!1)=>{let h=u?"every":"some";return E.controls[h](y=>{var A;let T=m?E.endTime===r.endTime:!0;return((A=y.events)==null?void 0:A[h](C=>{var I;return((I=C.action)==null?void 0:I.type)===ha.openURI}))&&T})},o=E=>E.some(({container:m})=>n(m.container,!0,!1)&&!m.isRemoved),a=E=>E.every(({container:m})=>m.isRemoved?!0:n(m.container,!0,!0)),l=Ra(e,r.endTime,[r.id]).length,s=E=>E.controls.some(m=>{var u;return(u=m.events)==null?void 0:u.some(h=>{var y,T;return(T=(y=h.action)==null?void 0:y.args)==null?void 0:T.shouldOpenNow})}),c=i||l>0,d=o(e),v=n(r),b=a(e),g=i?!1:l>0,S=s(r);return{isExpectTime:c,hasOtherExpect:l>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:v,isAllOpenURIEventsValid:b,isExpectEventForCurrentContainer:g,hasShouldOpenNowEvent:S}};var Le=class extends Ut{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new yp(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 R(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Je},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield fa((n=i.result)!=null?n:t),this})}setInitial(){return R(this,null,function*(){return this.setNext()})}setNext(){return R(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:oi,getChapter:Kt,getMedia:ai,getByBranches:this.getByBranches.bind(this),addErrorMessage:Je},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),n.result&&(this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph),this})}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){var i;return this.getByChapterId((i=this.manifest)==null?void 0:i.metadata.initChapterId)||null}getByChapterId(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t||!this.manifest)return null;let n=Kt(this.manifest.chapters,t);if(n){let o=ai(this.manifest.media,n.videoId),a=oi(this.manifest.graph,n.id);if(o)return{chapter:n,media:o,graph:a}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,o,a;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let l=Kt(((a=this.manifest)==null?void 0:a.chapters)||[],t);return this.getByBranches(l==null?void 0:l.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let o=this.getByChapterId(n.chapterId);return o&&i.push(o),i},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,i;return((t=this.chapter)==null?void 0:t.id)===((i=this.manifest)==null?void 0:i.metadata.initChapterId)}isEndChapter(){return this.chapter?ie(this.chapter):!1}};var ss=ee(Zt(),1);import{Player as zp}from"@vkontakte/videoplayer-core/es2015";import{Subscription as mi,Tracer as Wp,ValueSubject as Kp}from"@vkontakte/videoplayer-shared/es2015";var os=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&e.payload){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var as=ee(Zt(),1);function hi(){let r=new Map;function e(s){var c=s,{listId:o=Math.random().toString(),itemId:a=Math.random().toString()}=c,l=J(c,["listId","itemId"]);let d=r.get(o),v=f({},l);return d?d[a]=v:r.set(o,{[a]:v}),f({listId:o,itemId:a},l)}function t(o){var a,l;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(a=o.statistics)==null||a.oneStat.destroy(),(l=o.statistics)==null||l.statSubscription.unsubscribe()}function i(o,a){let l=r.get(o);if(!l)throw Error("Can't remove. Not find.");if(a){let s=l[a];s&&t(s),delete l[a],Object.keys(l).length||r.delete(o)}else{for(let s of(0,as.default)(l))t(s);r.delete(o)}}function n(){for(let o of r)i(o[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var Me=ee(rt(),1);function di(r,e=[]){var o,a,l;let t={},i,n=!e.length;for(let s of r.variants)if(!i&&"cover"in s&&(i=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(n||(0,Me.default)(e,"mp4"))&&(t.MPEG=x(f({},t.MPEG),{[(o=s.standard)!=null?o:"Invariant quality"]:s.url}));break;case"mpeg":(n||(0,Me.default)(e,"mpeg"))&&(t.MPEG=x(f({},t.MPEG),{[(a=s.standard)!=null?a:"Invariant quality"]:s.url}));break;case"hls":(n||(0,Me.default)(e,"hls"))&&(t=x(f({},t),{HLS:{type:"url",url:s.url}}));break;case"dash":(n||(0,Me.default)(e,"dash"))&&(t=x(f({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(l=r.title)!=null?l:""}}var it=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,Me.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Qp=2;function fi(r){let e=hi(),t=new mi,i={},n=null,o=!1,a,l=new Kp(null);r&&s(r);function s(m){n=m}function c(m,u,h){var A;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let T=((A=e.map.get(m))!=null?A:{})[u];if(T){i=f({chapterId:h,listId:m,itemId:u},T);let C=i.player;i.subscription.add(C.info.currentQuality$.subscribe(I=>{let j=C.info.position$.getValue(),k=C.info.isAutoQualityEnabled$.getValue();if(!(!I||!j||k))for(let F of e.map)(0,ss.default)(F[1]).forEach(({player:M})=>{it(M,I)})})).add(C.events.started$.subscribe(()=>{d(u)})),T.container.remove(),n.setPlayer(T.player),o||(n.init(),o=!0),l.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}function d(m){return R(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(de(i)||m!==i.itemId)return;let u=n.getChapterBranches(),h=new Set;for(let y of u)h.has(y.media.id)||(yield b({media:y.media,chapterId:y.chapter.id,setAsActive:!1,title:y.chapter.label}),h.add(y.media.id))})}function v(h){return R(this,arguments,function*({chapter:{id:m},manifestVideo:u}){if(de(i)||!n)return;let y=i.player.info.muted$.getValue(),T=i.player.info.currentQuality$.getValue(),A=i.player.info.isAutoQualityEnabled$.getValue(),C=i.player.info.volume$.getValue(),I=i.player.info.currentPlaybackRate$.getValue(),j=!A,k=!1;for(let F of e.map)if(F[0]===u.id&&!n.state.isReplay$.getValue()){let M=Object.keys(F[1]);for(let $ of M)$===i.itemId?(M.length<Qp||(k=!0),e.removePlayer(F[0],$)):(k=!0,c(F[0],$,m),j?it(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(C),i.player.setMuted(y),i.player.setPlaybackRate(I))}else e.removePlayer(F[0]);k||(yield b({media:u,chapterId:m,setAsActive:!0,playbackRate:I}),j?it(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(C),i.player.setMuted(y))})}function b(j){return R(this,arguments,function*({media:m,chapterId:u,prefetch:h=!0,setAsActive:y=!0,autoplay:T=!1,preferredExt:A,title:C,playbackRate:I}){var Ri,ki,Oi,Pi,Li;let k=Math.random().toString(),F=document.createElement("div");a.append(F);let M;if((Ri=n==null?void 0:n.options)!=null&&Ri.vkVideoLoader){let ut=os(m);ut.length&&(M=yield n.options.vkVideoLoader(...ut))}let $=((ki=n==null?void 0:n.options)==null?void 0:ki.coreConfig)||void 0,Ce=x(f({},$),{configName:[...(Oi=$==null?void 0:$.configName)!=null?Oi:[],"interactive"]}),oe=x(f({container:F},((Pi=M==null?void 0:M.videos)==null?void 0:Pi[0])||{sources:di(m,A).sources}),{title:C,failoverHosts:(M==null?void 0:M.failoverHosts)||[]}),Z=new zp(Ce,Wp.createRootTracer());Z.initVideo(oe);let Ai=null;if(M!=null&&M.videos&&(n!=null&&n.options.createOneStat)){let ut=M.videos[0],ar=n.options.createOneStat(ut),Mi=new mi;ar&&(Mi.add(ar.attachTo(Z)),Ai={oneStat:ar,statSubscription:Mi})}let wi=new mi,ml=(Li=i==null?void 0:i.player)==null?void 0:Li.info.isAutoQualityEnabled$.getValue();wi.add(Z.events.canplay$.subscribe(function(){ml||it(Z,i.player.info.currentQuality$.getValue()),I&&Z.setPlaybackRate(I)}));let Ee=e.createPlayer({listId:m.id,itemId:k,player:Z,container:F,sources:di(m,A).sources,config:oe,subscription:wi,statistics:Ai});return y&&c(m.id,Ee.itemId,u),T&&Ee.player.play(),h&&!T&&Ee.player.prepare(),{player:Ee.player,config:Ee.config,statistics:Ee.statistics}})}function g(){S(),n=null,a.remove()}function S(){t.unsubscribe(),e.removeAll(),i={},o=!1}function E(){return R(this,null,function*(){if(!n)throw Error("need to set interactive controller");S(),a=document.createElement("div");let{media:m,chapter:u}=n.getCurrentChapter();m&&u?(t.add(n.events.chapterChanged$.subscribe(v)),yield b({media:m,chapterId:u.id,title:u.label})):console.error("not found")})}return x(f({},e),{init:E,setInteractiveController:s,createPlayer:b,removeAll:g,getActivePlayer:function(){return i},activePlayerChanged:l})}var O={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},nt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},N={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var cs=ee(rt(),1);import{Subscription as Xp}from"@vkontakte/videoplayer-shared/es2015";function vi(r){return function(...t){return r(...t.reverse())}}function ot(r,...e){return(...t)=>pe(e[0])&&pe(t[0])?r(f(f({},e[0]),t[0])):r(...e,...t)}var Jt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:a,globalEventEmitter:l,getContainerEventState:s,permanentTextControls:c,interactiveTimeOpenUri:d,disabledControls$:v,onRemove:b,onError:g}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(ve(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,i,n,o,a,l;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:s}=this.getContainerEventState();if((i=(t=this.container).show)==null||i.call(t),this.interactiveTimeOpenUri&&s)return;this.emitContainerVisibilityEvent(!0,!1)}else{let s={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(v,b)=>{let{isExpectTime:g,hasOtherExpect:S,hasOpenURIEvent:E,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:u,hasShouldOpenNowEvent:h}=this.getContainerEventState(),y=this.interactiveTimeOpenUri&&!m,T=this.interactiveTimeOpenUri&&m;if((!this.interactiveTimeOpenUri||y)&&(this.isSelectedControlEvent=!0),v!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||y)){if(this.interactiveTimeOpenUri){let A=!S&&!u&&m;A&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:A})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&E&&this.gameState!==5){if(T){let C=((I,j,k,F)=>!I&&!j&&k||I&&!j&&k&&!F||I&&!j&&k&&F)(g,S,u,this.isSelectedContainerEvent);this.fakeRemoveView(C)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!g||!S||!h)&&(this.selectBranches.stopExpect(),b())}},isEOV:()=>this.gameState===4},c=ot(this.selectBranches.onControlEvent,s),d=((o=(n=this.player)==null?void 0:n.info.duration$.getValue())!=null?o:1/0)*1e3;this.container.createView({eventCallback:c,videoDurationMs:d}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((l=(a=this.container).disable)==null||l.call(a))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var c,d,v;let e=this.player.experimental.element$.getValue(),i=e instanceof HTMLVideoElement?e.readyState:void 0,n=[6,5];if(!i||(0,cs.default)(n,this.gameState)&&!this.isPermanentText)return;let o=this.player.getExactTime();if(wa(o,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(li(o,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let b=this.gameState;this.gameState=3,b===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:b}=this.getContainerEventState(),g=this.selectBranches.state.isExpect,S=this.interactiveTimeOpenUri&&b;if(S&&!g){let E=this.container.getElement();E&&(E.style.visibility!=="hidden"&&((d=(c=this.container).hide)==null||d.call(c)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!S&&this.removeView()}let a=li(o,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(v=this.container.container.endTime)!=null?v:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:o,isInteractiveTime:a};this.container.onProgress(o*1e3,a),this.globalEventEmitter.emit(O.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Xp,this.player=e,this.interactiveEvents=o,this.getContainerEventState=s,this.isPermanentText=c&&Pe(t.container.controls),this.interactiveTimeOpenUri=d,this.disabledControls$=v,this.onRemove=b,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=a,this.onError=g,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{var t,i,n,o;e?(i=(t=this.container).disable)==null||i.call(t):(o=(n=this.container).enable)==null||o.call(n)})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){var i,n;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(i=this.container.container.endTime)!=null?i:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((n=this.container.container.endTime)!=null?n:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),i=this.interactiveTimeOpenUri?e||t:ve(this.container.container.events)||e;(this.isSelectedControlEvent||!i)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,(e=this.onRemove)==null||e.call(this)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}destroy(){var e;this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var us=(r=[])=>r.reduce((e,t,i)=>{var o,a,l;let n=((o=t==null?void 0:t.controls)!=null?o:[]).filter(s=>!jt(s));if(Qt(n)){let s=[(a=t.startTime)!=null?a:0,(l=t.endTime)!=null?l:1/0],c={id:t.id,isRemoved:!1};if(!i)e.push({subjects:[c],range:s});else{let d=[],v=-1/0,b=1/0,g=[],S=[];for(let E=0;E<e.length;E++){let m=e[E];if(S.push(...m.subjects),m.range[0]<b&&(b=m.range[0]),m.range[1]>v&&(v=m.range[1]),s[0]>=m.range[0]&&s[1]<=m.range[1])return e[E].subjects.push(c),e;s[0]<m.range[0]&&s[1]>m.range[0]&&(d.push(E),g=g.concat(m.subjects)),s[0]>=m.range[0]&&s[0]<=m.range[1]&&(d.push(E),g=g.concat(m.subjects),s[0]=m.range[0]),s[1]>=m.range[0]&&s[1]<=m.range[1]&&(d.push(E),g=g.concat(m.subjects),s[1]=m.range[1])}if(S.push(c),s[0]<=b&&s[1]>=v)return[{subjects:S,range:s}];d.length&&d.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:g.concat([c]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var Gs=ee(rt(),1),Ci=ee(Zt(),1),zs=ee(Hs(),1);function Us(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let s={};for(let c in r)+c<=l&&(s[c]=r[c]);return s}function i(l){let s={};for(let c in r)+c>=l&&(s[c]=r[c]);return s}function n({timestamp:l,priority:s,initiator:c}){var d;if(ur(l)){let v=(d=r[l])!=null?d:null;if(v&&s&&Ne(s,!0)){let b={},g=v[s];if(g&&(b=f(f({},b),g)),b=de(b)?null:b,b&&Ne(c,!0)){let S=b[c];return S!=null?S:null}return b}return v}return null}function o({timestamp:l,priority:s,initiator:c}){if(ur(l))if(r[l]){if(s&&Ne(s,!0))if(r[l][s]){if(c&&Ne(c,!0))if(r[l][s][c]){if(delete r[l][s][c],!de(r[l][s]))return!0}else return!1;if(delete r[l][s],!de(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function a(v){var b=v,{timestamp:l,priority:s,initiator:c}=b,d=J(b,["timestamp","priority","initiator"]);var g,S,E;(S=(g=r[l])==null?void 0:g[s])!=null&&S[c]?r[l][s][c].push(f({},d)):(E=r[l])!=null&&E[s]?r[l][s]=x(f({},r[l][s]),{[c]:[f({},d)]}):r[l]?r[l]=x(f({},r[l]),{[s]:{[c]:[f({},d)]}}):r[l]={[s]:{[c]:[f({},d)]}}}return{map:r,remove:o,add:a,removeAll:e,get:n,getLte:t,getGte:i}}var $h=[P.expect,P.setNextBranch],jh=1/0;function Ws(r,e){let t=r,i,n=Bh(e),o=Us(),a,l=()=>{g(),u()},s=h=>{o.add.call(void 0,h),S()},c=(h=[])=>{for(let y of h)if(y.action(),(0,Gs.default)($h,y.actionType))break},d=(h=1/0)=>{var C,I,j;let y=tr((C=o.get({timestamp:h,priority:"control"}))!=null?C:{}),T=tr((I=o.get({timestamp:h,priority:"container"}))!=null?I:{}),A=tr((j=o.get({timestamp:h,priority:"chapter"}))!=null?j:{});return[...y,...T,...A]},v=h=>{n.isReady(h)&&c(d(h))},b=()=>{var h;c([...tr((h=o.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},g=()=>{i&&(a==null||a.unsubscribe(),i=void 0)},S=()=>{i||(i=()=>setTimeout(()=>{v(1/0)}),a=t.events.ended$.subscribe(i))},E=h=>{g(),t=h},m=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),o.remove(h)},u=()=>{n.release(),o.removeAll()};return{setPlayer:E,add:s,remove:m,exec:v,execEndOfVideo:b,listen:S,unlisten:g,release:l,containersEventsCallState:n,getPreparedToExecActions:d}}function Bh(r){let e=new Map;return{setCalled:({timestamp:l,id:s})=>{let c=e.get(l);c&&c[s]!==void 0&&(c[s]=!0)},setData:(l=[])=>{var s;for(let c of l){let d=(s=c.endTime)!=null?s:jh,v=e.get(d);e.set(d,x(f({},v),{[c.id]:!1}))}},resetCalled:l=>{let s=e.get(l);if(s)for(let c in s)s[c]=!1},isReady:l=>{let s=e.get(l);if(!s)return!0;let c=(0,Ci.default)(s);return r?c.some(v=>v):!c.some(v=>!v)},release:()=>e.clear()}}function tr(r){return(0,zs.default)((0,Ci.default)(r)).sort(e=>e.actionType===P.expect?-1:1)}var Ks={videoContentHeight:0,videoContentWidth:0},Qs=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Ks;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return Ks;let o=e/t,a=i/n,l,s;return a>o?(s=n,l=n*o):a<o?(s=i/o,l=i):(s=n,l=i),{videoContentWidth:s,videoContentHeight:l}};var qh=250;function Xs(r){let e,t=new ResizeObserver(l=>{o(l),e=o.bind(null,l)});function i(l){let{parentElement:s,player:c}=r();if(s&&c){let{videoContentWidth:d,videoContentHeight:v}=Qs(c);s.style.setProperty("--interactive-content-width",`${d}px`),s.style.setProperty("--interactive-content-height",`${v}px`),s.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),s.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function n(){let{parentElement:l}=r();l.removeAttribute("style")}let o=Xe(l=>{let{fns:s=[]}=r();i(l);for(let c of s)c()},qh);function a(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:a}}var Dh=r=>Math.floor(Math.random()*r),Zs=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let o=r[e],a=(n=o.weight)!=null?n:1;a<t&&(t=a,i=o)}return i},Js=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let o=r[e],a=(n=o.weight)!=null?n:0;a>t&&(t=a,i=o)}return i};var el=r=>{let e=r.length,t=Dh(e);return r[t]},Ys=1,tl=r=>{var i,n;let e=0;for(let o=0;o<r.length;++o)e+=(i=r[o].weight)!=null?i:Ys;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(n=r[o].weight)!=null?n:Ys,e>=t)return r[o];return r[r.length-1]};var rl={shouldOpenNow:!0,isDetachContainer:!0},il="after-expect",Ei=(r,e=!1)=>x(f({},r),{args:e?f(f({},r.args),rl):f(f({},rl),r.args)}),nl=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},a=({action:u,controlType:h,controlId:y,containerId:T,branches:A=[],onEvent:C,isEOV:I=()=>!1,isDisabled:j=()=>!1})=>{let k=Ei(u,I()),F={timestamp:1/0,priority:"control",initiator:y,actionType:k.type},M=j(),$=r.emit.bind(r,O.interactives,{subjectId:y,subjectType:h,subjectName:"control",type:M?N.actionChoiceCanceled:N.actionChoice,actionType:u.type,payload:f({invokeImmediately:k.args.shouldOpenNow,containerId:T},k.args)}),Ce=()=>{e.interactiveActionChoice$.next({subjectId:y,subjectType:h,subjectName:"control",type:M?"action-choice-canceled":"action-choice",actionType:u.type,payload:f({invokeImmediately:k.args.shouldOpenNow,containerId:T},k.args)})};if(M){$(),Ce();return}switch(k.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let oe=A.find(Z=>Z.id===k.args.branchId);if(!oe)return;C(k.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),$(),Ce(),k.args.shouldOpenNow?E({subjectId:y,subjectName:"control",subjectType:h,action:k,payload:{chapterId:oe.chapterId,autoSelect:!1}}):i.add(x(f({},F),{action:E.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:k,payload:{chapterId:oe.chapterId,autoSelect:!1}})}));return}case P.continuePlayback.trim().toLowerCase():{C(k.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),$(),Ce(),k.args.shouldOpenNow?S({subjectId:y,subjectName:"control",subjectType:h,action:u}):i.add(x(f({},F),{action:S.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:u})}));return}case P.openURI.trim().toLowerCase():{C(k.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),$(),Ce(),k.args.shouldOpenNow?m({subjectId:y,subjectName:"control",subjectType:h,action:k,payload:{URI:u.args.uri}}):i.add(x(f({},F),{action:m.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:k,payload:{URI:u.args.uri}})}));return}default:{let oe="Unexpected control event",Z=new B(1,1,{message:oe});d(Z,oe);return}}},l=({action:u,container:{id:h,endTime:y},branches:T=[],isEOV:A=!1,autoSelected:C=!1})=>{let I=Ei(u,A),j={timestamp:!I.args.shouldOpenNow||A?1/0:y!=null?y:1/0,priority:"container",initiator:h,actionType:I.type},k=r.emit.bind(r,O.interactives,{subjectId:h,subjectName:"container",type:N.actionChoice,actionType:I.type,payload:f({invokeImmediately:I.args.shouldOpenNow},I.args)}),F=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:I.type,payload:f({invokeImmediately:I.args.shouldOpenNow},I.args)})};switch(I.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let M=T.find($=>$.id===I.args.branchId);if(!M)return;k(),F(),i.add(x(f({},j),{action:E.bind(null,{subjectId:h,subjectName:"container",action:I,payload:{chapterId:M.chapterId,autoSelect:C}})}));return}case P.setMaxWeightBranch.trim().toLowerCase():return;case P.setMinWeightBranch.trim().toLowerCase():return;case P.setRandomBranch.trim().toLowerCase():return;case P.setWeightlessRandomBranch.trim().toLowerCase():return;case P.continuePlayback.trim().toLowerCase():{k(),F(),i.add(x(f({},j),{action:S.bind(null,{subjectId:h,subjectName:"container",action:I})}));return}case P.openURI.trim().toLowerCase():{k(),F(),i.add(x(f({},j),{action:m.bind(null,{subjectId:h,subjectName:"container",action:I,payload:{URI:u.args.uri}})}));return}default:{let M="Unexpected container event",$=new B(1,1,{message:M});d($,M);return}}};function s({container:u,branches:h,isEOV:y=!1}){var A,C;let T=ci(u.events);if(T){let I=Ei(T.action,y);r.emit(O.interactives,{subjectId:u.id,subjectName:"container",type:N.actionChoice,actionType:I.type,payload:f({invokeImmediately:I.args.shouldOpenNow},I.args)}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:I.type,payload:f({invokeImmediately:I.args.shouldOpenNow},I.args)}),i.add({timestamp:y?1/0:(A=u.endTime)!=null?A:1/0,priority:"container",initiator:u.id,actionType:P.expect,action:b.bind(null,{subjectId:u.id,subjectName:"container"})}),n.isExpect=!0}else for(let I of(C=u.events)!=null?C:[])l({action:I.action,container:u,branches:h,isEOV:y})}let c=({chapterId:u,action:h,branches:y=[]})=>{let T=r.emit.bind(r,O.interactives,{subjectId:u,subjectName:"chapter",type:N.actionChoice,actionType:h.type,payload:h.args}),A=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let C=y.find(I=>I.id===h.args.branchId);return C!=null&&C.chapterId?(T(),A(),E.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setWeightlessRandomBranch.trim().toLowerCase():{let C=el(y);return C!=null&&C.chapterId?(T(),A(),E.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setRandomBranch.trim().toLowerCase():{let C=tl(y);return C!=null&&C.chapterId?(T(),A(),E.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setMaxWeightBranch.trim().toLowerCase():{let C=Js(y);return C!=null&&C.chapterId?(T(),A(),E.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setMinWeightBranch.trim().toLowerCase():{let C=Zs(y);return C!=null&&C.chapterId?(T(),A(),E.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.continuePlayback.trim().toLowerCase():return T(),A(),S.bind(null,{subjectId:u,subjectName:"chapter",action:h});case P.openURI.trim().toLowerCase():return T(),A(),m.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let C="Unexpected chapter event",I=new B(1,1,{message:C});d(I,C);return}}};function d(u,h){console.error(h),e.error$.next(u),r.emit(O.errors,u)}function v(u){var y;let h=ci(u.events);if(h){if(ie(u))return;r.emit(O.interactives,{subjectId:u.id,subjectName:"chapter",type:N.actionChoice,actionType:h.action.type,payload:h.action.args}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"chapter",type:"action-choice",actionType:h.action.type,payload:h.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:P.expect,action:b.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else(y=u.events)==null||y.forEach(T=>{let A=c({chapterId:u.id,action:T.action,branches:u.branches});A&&i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:T.action.type,action:A})})}let b=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(O.interactives,{subjectId:u,subjectName:h,type:N.actionExecution,actionType:P.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:P.expect})},g=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(O.interactives,{subjectId:u,subjectName:h,type:N.actionExecution,actionType:il}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:il})},S=({subjectId:u,subjectName:h,subjectType:y,action:T})=>{r.emit(O.interactives,{subjectId:u,subjectName:h,subjectType:y,type:N.actionExecution,actionType:T.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:y,type:"action-execution",actionType:T.type})},E=({subjectId:u,subjectName:h,subjectType:y,action:T,payload:A})=>{A.behaviour="change-chapter",r.emit(O.interactives,{subjectId:u,subjectName:h,subjectType:y,type:N.actionExecution,actionType:T.type,payload:A}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:y,type:"action-execution",actionType:T.type,payload:A})},m=({subjectId:u,subjectName:h,subjectType:y,action:T,payload:A})=>{if(!A.URI)return;let C=window.open(A.URI,"_blank","noopener,noreferrer");C&&(C.opener=null),r.emit(O.interactives,{subjectId:u,subjectName:h,subjectType:y,type:N.actionExecution,actionType:T.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:y,type:"action-execution",actionType:T.type})};return{onControlEvent:a,onContainerEvent:l,onChapterEvent:c,onExpectEvent:b,expectEventHandler:g,setManifestChapterEvents:v,setManifestContainerEvents:s,stopExpect:o,state:n}};var xi=ee(ti(),1);import{Subscription as Wh,Subject as Ii,ValueSubject as st}from"@vkontakte/videoplayer-shared/es2015";var Ti=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(a=>a.id===i);if(!n)return null;let o=e.media.videos.find(a=>n.videoId===a.id);if(!o)return null;t[i]=ol(o)}return t[i]}).filter(Boolean)},Uh=r=>{for(let e of r.variants)if(Gh(e)&&e.payload)return e.payload.id},Gh=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),ol=r=>{let e=Uh(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},zh=(r,e)=>{for(let t of r.media.videos)if(e===ol(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},al=(r,e)=>r.reduce((t,i)=>{let n=zh(e,i);return n?[...t,n]:t},[]);var se,be,ye,Q,rr,le,ce,ne,ge,Fe,Ve,lt=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new st([]),hasPrevChapter$:new st(!1),prevChapter$:new st(null),isInitialChapter$:new st(!1),isGoBackLimited$:new st(!1)};z(this,se,null);z(this,be);z(this,ye,!1);z(this,Q,null);z(this,rr,null);this.events={inited$:new Ii,destroyed$:new Ii,error$:new Ii};z(this,le,null);z(this,ce,null);z(this,ne,null);z(this,ge,new Wh);z(this,Fe,!1);z(this,Ve,0);var a;_(this,le,t),_(this,ne,e),_(this,ce,i),_(this,se,n),_(this,be,o),this.state.history$&&w(this,ge)&&((a=w(this,ge))==null||a.add(this.state.history$.subscribe(l=>{var s,c;this.state.prevChapter$.next((0,xi.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(s=w(this,Q))==null?void 0:s.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(w(this,Ve)===w(this,be).maxLength-1)})))}setManifest(e){return R(this,null,function*(){if(!w(this,ce)||!w(this,ne))return;_(this,Q,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield w(this,ce).setChapter({chapterId:t,pushToHistory:!1}),w(this,ye)||(_(this,ye,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return w(this,ye)}updateHistory(e,t=!0){return R(this,null,function*(){var l;if(!w(this,Q))return;w(this,Fe)?(_(this,Fe,!1),$i(this,Ve)._++):_(this,Ve,0);let i=w(this,Q),n=e.length-w(this,be).maxLength,o=n>0?e.slice(n):e,a=Ti(o,i);if(_(this,rr,a),this.state.history$.next(o),!(!t||!w(this,se)||!w(this,le)))try{yield w(this,se).save(w(this,le),a)}catch(s){let c=new B(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=w(this,ne))==null||l.emit(O.errors,c)}})}goBack(){return R(this,null,function*(){var i;if(!this.state||!w(this,ce)){let n=new B(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=w(this,ne))==null?void 0:i.emit(O.errors,n)}_(this,Fe,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield w(this,ce).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return R(this,null,function*(){var n;if(!w(this,Q)||!w(this,le))return;let e=w(this,Q),t=[this.getInitialVideoId()];if(w(this,se))try{let o=yield w(this,se).get(w(this,le));o.length&&(t=o)}catch(o){let a=new B(1,5,"Error while trying to fetch data");this.events.error$.next(a),(n=w(this,ne))==null||n.emit(O.errors,a)}let i=al(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,xi.default)(e,-1)||w(this,be).initChapterId||((t=w(this,Q))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(w(this,Q)){let e=this.getInitialChapterId();return Ti([e],w(this,Q)).pop()}return null}destroy(){var e,t;_(this,le,null),_(this,se,null),_(this,ce,null),(e=w(this,ge))==null||e.unsubscribe(),_(this,ge,null),_(this,ye,!1),(t=w(this,ne))==null||t.emit(O.historyDestroyed),this.events.destroyed$.next(),_(this,ne,null)}};se=new WeakMap,be=new WeakMap,ye=new WeakMap,Q=new WeakMap,rr=new WeakMap,le=new WeakMap,ce=new WeakMap,ne=new WeakMap,ge=new WeakMap,Fe=new WeakMap,Ve=new WeakMap;var ir=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var n;let e=(n=this.rootElement.getContext("2d"))==null?void 0:n.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,i=t.length;for(let o=3;o<i;o+=40)if(t[o]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(e,t=!1){return R(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 R(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 nr=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 fl=Object.create;var sr=Object.defineProperty,vl=Object.defineProperties,bl=Object.getOwnPropertyDescriptor,yl=Object.getOwnPropertyDescriptors,gl=Object.getOwnPropertyNames,pt=Object.getOwnPropertySymbols,Cl=Object.getPrototypeOf,lr=Object.prototype.hasOwnProperty,Vi=Object.prototype.propertyIsEnumerable;var Ni=r=>{throw TypeError(r)};var Fi=(r,e,t)=>e in r?sr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,f=(r,e)=>{for(var t in e||(e={}))lr.call(e,t)&&Fi(r,t,e[t]);if(pt)for(var t of pt(e))Vi.call(e,t)&&Fi(r,t,e[t]);return r},x=(r,e)=>vl(r,yl(e));var J=(r,e)=>{var t={};for(var i in r)lr.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&pt)for(var i of pt(r))e.indexOf(i)<0&&Vi.call(r,i)&&(t[i]=r[i]);return t};var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var El=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of gl(e))!lr.call(r,n)&&n!==t&&sr(r,n,{get:()=>e[n],enumerable:!(i=bl(e,n))||i.enumerable});return r};var ee=(r,e,t)=>(t=r!=null?fl(Cl(r)):{},El(e||!r||!r.__esModule?sr(t,"default",{value:r,enumerable:!0}):t,r));var _i=(r,e,t)=>e.has(r)||Ni("Cannot "+t);var w=(r,e,t)=>(_i(r,e,"read from private field"),t?t.call(r):e.get(r)),z=(r,e,t)=>e.has(r)?Ni("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),_=(r,e,t,i)=>(_i(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var $i=(r,e,t,i)=>({set _(n){_(r,e,n,t)},get _(){return w(r,e,i)}});var R=(r,e,t)=>new Promise((i,n)=>{var o=s=>{try{l(t.next(s))}catch(c){n(c)}},a=s=>{try{l(t.throw(s))}catch(c){n(c)}},l=s=>s.done?i(s.value):Promise.resolve(s.value).then(o,a);l((t=t.apply(r,e)).next())});var re=p((Sr,nn)=>{"use strict";var je=function(r){return r&&r.Math===Math&&r};nn.exports=je(typeof globalThis=="object"&&globalThis)||je(typeof window=="object"&&window)||je(typeof self=="object"&&self)||je(typeof global=="object"&&global)||je(typeof Sr=="object"&&Sr)||function(){return this}()||Function("return this")()});var W=p((Mm,on)=>{"use strict";on.exports=function(r){try{return!!r()}catch(e){return!0}}});var Be=p((Fm,an)=>{"use strict";var Fl=W();an.exports=!Fl(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var pn=p((Vm,un)=>{"use strict";var Vl=Be(),cn=Function.prototype,sn=cn.apply,ln=cn.call;un.exports=typeof Reflect=="object"&&Reflect.apply||(Vl?ln.bind(sn):function(){return ln.apply(sn,arguments)})});var X=p((Nm,mn)=>{"use strict";var hn=Be(),dn=Function.prototype,Ar=dn.call,Nl=hn&&dn.bind.bind(Ar,Ar);mn.exports=hn?Nl:function(r){return function(){return Ar.apply(r,arguments)}}});var qe=p((_m,vn)=>{"use strict";var fn=X(),_l=fn({}.toString),$l=fn("".slice);vn.exports=function(r){return $l(_l(r),8,-1)}});var wr=p(($m,bn)=>{"use strict";var jl=qe(),Bl=X();bn.exports=function(r){if(jl(r)==="Function")return Bl(r)}});var K=p((jm,yn)=>{"use strict";var Rr=typeof document=="object"&&document.all;yn.exports=typeof Rr=="undefined"&&Rr!==void 0?function(r){return typeof r=="function"||r===Rr}:function(r){return typeof r=="function"}});var fe=p((Bm,gn)=>{"use strict";var ql=W();gn.exports=!ql(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Pt=p((qm,Cn)=>{"use strict";var Dl=Be(),Ot=Function.prototype.call;Cn.exports=Dl?Ot.bind(Ot):function(){return Ot.apply(Ot,arguments)}});var kr=p(In=>{"use strict";var En={}.propertyIsEnumerable,Tn=Object.getOwnPropertyDescriptor,Hl=Tn&&!En.call({1:2},1);In.f=Hl?function(e){var t=Tn(this,e);return!!t&&t.enumerable}:En});var Or=p((Hm,xn)=>{"use strict";xn.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var An=p((Um,Sn)=>{"use strict";var Ul=X(),Gl=W(),zl=qe(),Pr=Object,Wl=Ul("".split);Sn.exports=Gl(function(){return!Pr("z").propertyIsEnumerable(0)})?function(r){return zl(r)==="String"?Wl(r,""):Pr(r)}:Pr});var Lr=p((Gm,wn)=>{"use strict";wn.exports=function(r){return r==null}});var Mr=p((zm,Rn)=>{"use strict";var Kl=Lr(),Ql=TypeError;Rn.exports=function(r){if(Kl(r))throw new Ql("Can't call method on "+r);return r}});var De=p((Wm,kn)=>{"use strict";var Xl=An(),Yl=Mr();kn.exports=function(r){return Xl(Yl(r))}});var Se=p((Km,On)=>{"use strict";var Zl=K();On.exports=function(r){return typeof r=="object"?r!==null:Zl(r)}});var Lt=p((Qm,Pn)=>{"use strict";Pn.exports={}});var Mt=p((Xm,Mn)=>{"use strict";var Fr=Lt(),Vr=re(),Jl=K(),Ln=function(r){return Jl(r)?r:void 0};Mn.exports=function(r,e){return arguments.length<2?Ln(Fr[r])||Ln(Vr[r]):Fr[r]&&Fr[r][e]||Vr[r]&&Vr[r][e]}});var Vn=p((Ym,Fn)=>{"use strict";var ec=X();Fn.exports=ec({}.isPrototypeOf)});var jn=p((Zm,$n)=>{"use strict";var tc=re(),Nn=tc.navigator,_n=Nn&&Nn.userAgent;$n.exports=_n?String(_n):""});var zn=p((Jm,Gn)=>{"use strict";var Un=re(),Nr=jn(),Bn=Un.process,qn=Un.Deno,Dn=Bn&&Bn.versions||qn&&qn.version,Hn=Dn&&Dn.v8,Y,Ft;Hn&&(Y=Hn.split("."),Ft=Y[0]>0&&Y[0]<4?1:+(Y[0]+Y[1]));!Ft&&Nr&&(Y=Nr.match(/Edge\/(\d+)/),(!Y||Y[1]>=74)&&(Y=Nr.match(/Chrome\/(\d+)/),Y&&(Ft=+Y[1])));Gn.exports=Ft});var _r=p((ef,Kn)=>{"use strict";var Wn=zn(),rc=W(),ic=re(),nc=ic.String;Kn.exports=!!Object.getOwnPropertySymbols&&!rc(function(){var r=Symbol("symbol detection");return!nc(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Wn&&Wn<41})});var $r=p((tf,Qn)=>{"use strict";var oc=_r();Qn.exports=oc&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var jr=p((rf,Xn)=>{"use strict";var ac=Mt(),sc=K(),lc=Vn(),cc=$r(),uc=Object;Xn.exports=cc?function(r){return typeof r=="symbol"}:function(r){var e=ac("Symbol");return sc(e)&&lc(e.prototype,uc(r))}});var Zn=p((nf,Yn)=>{"use strict";var pc=String;Yn.exports=function(r){try{return pc(r)}catch(e){return"Object"}}});var Br=p((of,Jn)=>{"use strict";var hc=K(),dc=Zn(),mc=TypeError;Jn.exports=function(r){if(hc(r))return r;throw new mc(dc(r)+" is not a function")}});var to=p((af,eo)=>{"use strict";var fc=Br(),vc=Lr();eo.exports=function(r,e){var t=r[e];return vc(t)?void 0:fc(t)}});var io=p((sf,ro)=>{"use strict";var qr=Pt(),Dr=K(),Hr=Se(),bc=TypeError;ro.exports=function(r,e){var t,i;if(e==="string"&&Dr(t=r.toString)&&!Hr(i=qr(t,r))||Dr(t=r.valueOf)&&!Hr(i=qr(t,r))||e!=="string"&&Dr(t=r.toString)&&!Hr(i=qr(t,r)))return i;throw new bc("Can't convert object to primitive value")}});var oo=p((lf,no)=>{"use strict";no.exports=!0});var lo=p((cf,so)=>{"use strict";var ao=re(),yc=Object.defineProperty;so.exports=function(r,e){try{yc(ao,r,{value:e,configurable:!0,writable:!0})}catch(t){ao[r]=e}return e}});var Vt=p((uf,po)=>{"use strict";var gc=oo(),Cc=re(),Ec=lo(),co="__core-js_shared__",uo=po.exports=Cc[co]||Ec(co,{});(uo.versions||(uo.versions=[])).push({version:"3.38.0",mode:gc?"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 Ur=p((pf,mo)=>{"use strict";var ho=Vt();mo.exports=function(r,e){return ho[r]||(ho[r]=e||{})}});var He=p((hf,fo)=>{"use strict";var Tc=Mr(),Ic=Object;fo.exports=function(r){return Ic(Tc(r))}});var Ae=p((df,vo)=>{"use strict";var xc=X(),Sc=He(),Ac=xc({}.hasOwnProperty);vo.exports=Object.hasOwn||function(e,t){return Ac(Sc(e),t)}});var Gr=p((mf,bo)=>{"use strict";var wc=X(),Rc=0,kc=Math.random(),Oc=wc(1 .toString);bo.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Oc(++Rc+kc,36)}});var Ue=p((ff,go)=>{"use strict";var Pc=re(),Lc=Ur(),yo=Ae(),Mc=Gr(),Fc=_r(),Vc=$r(),we=Pc.Symbol,zr=Lc("wks"),Nc=Vc?we.for||we:we&&we.withoutSetter||Mc;go.exports=function(r){return yo(zr,r)||(zr[r]=Fc&&yo(we,r)?we[r]:Nc("Symbol."+r)),zr[r]}});var Io=p((vf,To)=>{"use strict";var _c=Pt(),Co=Se(),Eo=jr(),$c=to(),jc=io(),Bc=Ue(),qc=TypeError,Dc=Bc("toPrimitive");To.exports=function(r,e){if(!Co(r)||Eo(r))return r;var t=$c(r,Dc),i;if(t){if(e===void 0&&(e="default"),i=_c(t,r,e),!Co(i)||Eo(i))return i;throw new qc("Can't convert object to primitive value")}return e===void 0&&(e="number"),jc(r,e)}});var Wr=p((bf,xo)=>{"use strict";var Hc=Io(),Uc=jr();xo.exports=function(r){var e=Hc(r,"string");return Uc(e)?e:e+""}});var wo=p((yf,Ao)=>{"use strict";var Gc=re(),So=Se(),Kr=Gc.document,zc=So(Kr)&&So(Kr.createElement);Ao.exports=function(r){return zc?Kr.createElement(r):{}}});var Qr=p((gf,Ro)=>{"use strict";var Wc=fe(),Kc=W(),Qc=wo();Ro.exports=!Wc&&!Kc(function(){return Object.defineProperty(Qc("div"),"a",{get:function(){return 7}}).a!==7})});var Po=p(Oo=>{"use strict";var Xc=fe(),Yc=Pt(),Zc=kr(),Jc=Or(),eu=De(),tu=Wr(),ru=Ae(),iu=Qr(),ko=Object.getOwnPropertyDescriptor;Oo.f=Xc?ko:function(e,t){if(e=eu(e),t=tu(t),iu)try{return ko(e,t)}catch(i){}if(ru(e,t))return Jc(!Yc(Zc.f,e,t),e[t])}});var Mo=p((Ef,Lo)=>{"use strict";var nu=W(),ou=K(),au=/#|\.prototype\./,Ge=function(r,e){var t=lu[su(r)];return t===uu?!0:t===cu?!1:ou(e)?nu(e):!!e},su=Ge.normalize=function(r){return String(r).replace(au,".").toLowerCase()},lu=Ge.data={},cu=Ge.NATIVE="N",uu=Ge.POLYFILL="P";Lo.exports=Ge});var Xr=p((Tf,Vo)=>{"use strict";var Fo=wr(),pu=Br(),hu=Be(),du=Fo(Fo.bind);Vo.exports=function(r,e){return pu(r),e===void 0?r:hu?du(r,e):function(){return r.apply(e,arguments)}}});var _o=p((If,No)=>{"use strict";var mu=fe(),fu=W();No.exports=mu&&fu(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var jo=p((xf,$o)=>{"use strict";var vu=Se(),bu=String,yu=TypeError;$o.exports=function(r){if(vu(r))return r;throw new yu(bu(r)+" is not an object")}});var Do=p(qo=>{"use strict";var gu=fe(),Cu=Qr(),Eu=_o(),Nt=jo(),Bo=Wr(),Tu=TypeError,Yr=Object.defineProperty,Iu=Object.getOwnPropertyDescriptor,Zr="enumerable",Jr="configurable",ei="writable";qo.f=gu?Eu?function(e,t,i){if(Nt(e),t=Bo(t),Nt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&ei in i&&!i[ei]){var n=Iu(e,t);n&&n[ei]&&(e[t]=i.value,i={configurable:Jr in i?i[Jr]:n[Jr],enumerable:Zr in i?i[Zr]:n[Zr],writable:!1})}return Yr(e,t,i)}:Yr:function(e,t,i){if(Nt(e),t=Bo(t),Nt(i),Cu)try{return Yr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new Tu("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var Uo=p((Af,Ho)=>{"use strict";var xu=fe(),Su=Do(),Au=Or();Ho.exports=xu?function(r,e,t){return Su.f(r,e,Au(1,t))}:function(r,e,t){return r[e]=t,r}});var We=p((wf,zo)=>{"use strict";var ze=re(),wu=pn(),Ru=wr(),ku=K(),Ou=Po().f,Pu=Mo(),Re=Lt(),Lu=Xr(),ke=Uo(),Go=Ae();Vt();var Mu=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 wu(r,this,arguments)};return e.prototype=r.prototype,e};zo.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o=r.proto,a=i?ze:n?ze[t]:ze[t]&&ze[t].prototype,l=i?Re:Re[t]||ke(Re,t,{})[t],s=l.prototype,c,d,v,b,g,S,E,m,u;for(b in e)c=Pu(i?b:t+(n?".":"#")+b,r.forced),d=!c&&a&&Go(a,b),S=l[b],d&&(r.dontCallGetSet?(u=Ou(a,b),E=u&&u.value):E=a[b]),g=d&&E?E:e[b],!(!c&&!o&&typeof S==typeof g)&&(r.bind&&d?m=Lu(g,ze):r.wrap&&d?m=Mu(g):o&&ku(g)?m=Ru(g):m=g,(r.sham||g&&g.sham||S&&S.sham)&&ke(m,"sham",!0),ke(l,b,m),o&&(v=t+"Prototype",Go(Re,v)||ke(Re,v,{}),ke(Re[v],b,g),r.real&&s&&(c||!s[b])&&ke(s,b,g)))}});var Ko=p((Rf,Wo)=>{"use strict";var Fu=Math.ceil,Vu=Math.floor;Wo.exports=Math.trunc||function(e){var t=+e;return(t>0?Vu:Fu)(t)}});var Ke=p((kf,Qo)=>{"use strict";var Nu=Ko();Qo.exports=function(r){var e=+r;return e!==e||e===0?0:Nu(e)}});var Yo=p((Of,Xo)=>{"use strict";var _u=Ke(),$u=Math.min;Xo.exports=function(r){var e=_u(r);return e>0?$u(e,9007199254740991):0}});var Qe=p((Pf,Zo)=>{"use strict";var ju=Yo();Zo.exports=function(r){return ju(r.length)}});var _t=p((Lf,Jo)=>{"use strict";Jo.exports=function(){}});var ea=p(()=>{"use strict";var Bu=We(),qu=He(),Du=Qe(),Hu=Ke(),Uu=_t();Bu({target:"Array",proto:!0},{at:function(e){var t=qu(this),i=Du(t),n=Hu(e),o=n>=0?n:i+n;return o<0||o>=i?void 0:t[o]}});Uu("at")});var $t=p((Vf,ta)=>{"use strict";var Gu=Mt();ta.exports=Gu});var ia=p((Nf,ra)=>{"use strict";ea();var zu=$t();ra.exports=zu("Array","at")});var oa=p((_f,na)=>{"use strict";var Wu=ia();na.exports=Wu});var ti=p(($f,aa)=>{"use strict";var Ku=oa();aa.exports=Ku});var ba=p((_v,va)=>{"use strict";var ip=Ke(),np=Math.max,op=Math.min;va.exports=function(r,e){var t=ip(r);return t<0?np(t+e,0):op(t,e)}});var si=p(($v,ga)=>{"use strict";var ap=De(),sp=ba(),lp=Qe(),ya=function(r){return function(e,t,i){var n=ap(e),o=lp(n);if(o===0)return!r&&-1;var a=sp(i,o),l;if(r&&t!==t){for(;o>a;)if(l=n[a++],l!==l)return!0}else for(;o>a;a++)if((r||a in n)&&n[a]===t)return r||a||0;return!r&&-1}};ga.exports={includes:ya(!0),indexOf:ya(!1)}});var Ca=p(()=>{"use strict";var cp=We(),up=si().includes,pp=W(),hp=_t(),dp=pp(function(){return!Array(1).includes()});cp({target:"Array",proto:!0,forced:dp},{includes:function(e){return up(this,e,arguments.length>1?arguments[1]:void 0)}});hp("includes")});var Ta=p((qv,Ea)=>{"use strict";Ca();var mp=$t();Ea.exports=mp("Array","includes")});var xa=p((Dv,Ia)=>{"use strict";var fp=Ta();Ia.exports=fp});var rt=p((Hv,Sa)=>{"use strict";var vp=xa();Sa.exports=vp});var La=p((tb,Pa)=>{"use strict";var gp=Ur(),Cp=Gr(),Oa=gp("keys");Pa.exports=function(r){return Oa[r]||(Oa[r]=Cp(r))}});var Fa=p((rb,Ma)=>{"use strict";var Ep=W();Ma.exports=!Ep(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var _a=p((ib,Na)=>{"use strict";var Tp=Ae(),Ip=K(),xp=He(),Sp=La(),Ap=Fa(),Va=Sp("IE_PROTO"),ui=Object,wp=ui.prototype;Na.exports=Ap?ui.getPrototypeOf:function(r){var e=xp(r);if(Tp(e,Va))return e[Va];var t=e.constructor;return Ip(t)&&e instanceof t?t.prototype:e instanceof ui?wp:null}});var ja=p((nb,$a)=>{"use strict";$a.exports={}});var Da=p((ob,qa)=>{"use strict";var Rp=X(),pi=Ae(),kp=De(),Op=si().indexOf,Pp=ja(),Ba=Rp([].push);qa.exports=function(r,e){var t=kp(r),i=0,n=[],o;for(o in t)!pi(Pp,o)&&pi(t,o)&&Ba(n,o);for(;e.length>i;)pi(t,o=e[i++])&&(~Op(n,o)||Ba(n,o));return n}});var Ua=p((ab,Ha)=>{"use strict";Ha.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var za=p((sb,Ga)=>{"use strict";var Lp=Da(),Mp=Ua();Ga.exports=Object.keys||function(e){return Lp(e,Mp)}});var Za=p((lb,Ya)=>{"use strict";var Ka=fe(),Fp=W(),Qa=X(),Vp=_a(),Np=za(),_p=De(),$p=kr().f,Xa=Qa($p),jp=Qa([].push),Bp=Ka&&Fp(function(){var r=Object.create(null);return r[2]=2,!Xa(r,2)}),Wa=function(r){return function(e){for(var t=_p(e),i=Np(t),n=Bp&&Vp(t)===null,o=i.length,a=0,l=[],s;o>a;)s=i[a++],(!Ka||(n?s in t:Xa(t,s)))&&jp(l,r?[s,t[s]]:t[s]);return l}};Ya.exports={entries:Wa(!0),values:Wa(!1)}});var Ja=p(()=>{"use strict";var qp=We(),Dp=Za().values;qp({target:"Object",stat:!0},{values:function(e){return Dp(e)}})});var ts=p((pb,es)=>{"use strict";Ja();var Hp=Lt();es.exports=Hp.Object.values});var is=p((hb,rs)=>{"use strict";var Up=ts();rs.exports=Up});var Zt=p((db,ns)=>{"use strict";var Gp=is();ns.exports=Gp});var bi=p((qb,ps)=>{"use strict";var Yp=qe();ps.exports=Array.isArray||function(e){return Yp(e)==="Array"}});var ds=p((Db,hs)=>{"use strict";var Zp=TypeError,Jp=9007199254740991;hs.exports=function(r){if(r>Jp)throw Zp("Maximum allowed index exceeded");return r}});var vs=p((Hb,fs)=>{"use strict";var eh=bi(),th=Qe(),rh=ds(),ih=Xr(),ms=function(r,e,t,i,n,o,a,l){for(var s=n,c=0,d=a?ih(a,l):!1,v,b;c<i;)c in t&&(v=d?d(t[c],c,e):t[c],o>0&&eh(v)?(b=th(v),s=ms(r,e,v,b,s,o-1)-1):(rh(s+1),r[s]=v),s++),c++;return s};fs.exports=ms});var gs=p((Ub,ys)=>{"use strict";var nh=Ue(),oh=nh("toStringTag"),bs={};bs[oh]="z";ys.exports=String(bs)==="[object z]"});var Es=p((Gb,Cs)=>{"use strict";var ah=gs(),sh=K(),er=qe(),lh=Ue(),ch=lh("toStringTag"),uh=Object,ph=er(function(){return arguments}())==="Arguments",hh=function(r,e){try{return r[e]}catch(t){}};Cs.exports=ah?er:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=hh(e=uh(r),ch))=="string"?t:ph?er(e):(i=er(e))==="Object"&&sh(e.callee)?"Arguments":i}});var Is=p((zb,Ts)=>{"use strict";var dh=X(),mh=K(),yi=Vt(),fh=dh(Function.toString);mh(yi.inspectSource)||(yi.inspectSource=function(r){return fh(r)});Ts.exports=yi.inspectSource});var ks=p((Wb,Rs)=>{"use strict";var vh=X(),bh=W(),xs=K(),yh=Es(),gh=Mt(),Ch=Is(),Ss=function(){},As=gh("Reflect","construct"),gi=/^\s*(?:class|function)\b/,Eh=vh(gi.exec),Th=!gi.test(Ss),at=function(e){if(!xs(e))return!1;try{return As(Ss,[],e),!0}catch(t){return!1}},ws=function(e){if(!xs(e))return!1;switch(yh(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Th||!!Eh(gi,Ch(e))}catch(t){return!0}};ws.sham=!0;Rs.exports=!As||bh(function(){var r;return at(at.call)||!at(Object)||!at(function(){r=!0})||r})?ws:at});var Ms=p((Kb,Ls)=>{"use strict";var Os=bi(),Ih=ks(),xh=Se(),Sh=Ue(),Ah=Sh("species"),Ps=Array;Ls.exports=function(r){var e;return Os(r)&&(e=r.constructor,Ih(e)&&(e===Ps||Os(e.prototype))?e=void 0:xh(e)&&(e=e[Ah],e===null&&(e=void 0))),e===void 0?Ps:e}});var Vs=p((Qb,Fs)=>{"use strict";var wh=Ms();Fs.exports=function(r,e){return new(wh(r))(e===0?0:e)}});var Ns=p(()=>{"use strict";var Rh=We(),kh=vs(),Oh=He(),Ph=Qe(),Lh=Ke(),Mh=Vs();Rh({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Oh(this),i=Ph(t),n=Mh(t,0);return n.length=kh(n,t,t,i,0,e===void 0?1:Lh(e)),n}})});var _s=p(()=>{"use strict";var Fh=_t();Fh("flat")});var js=p((ey,$s)=>{"use strict";Ns();_s();var Vh=$t();$s.exports=Vh("Array","flat")});var qs=p((ty,Bs)=>{"use strict";var Nh=js();Bs.exports=Nh});var Hs=p((ry,Ds)=>{"use strict";var _h=qs();Ds.exports=_h});var ji="1.0.39-dev.3ba6f931.0";import{Subject as Ll,Subscription as Ml}from"@vkontakte/videoplayer-shared/es2015";var cr=class{constructor(e){this.layout=e}},ht=class extends cr{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} + ${2e-4}))`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};function Bi(r){return"features"in r}var Te=class{constructor(e,t){this.container=e,this.options=t,this.factories=new Map,this.controls=[],this.setControls()}featureIsEnabled(e){return this.options&&Bi(this.options)&&this.options.features[e]}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){var e;return((e=this.container.controls)==null?void 0:e.reduce((t,i)=>{let n=i.type.trim().toLowerCase(),o=this.factories.get(n);if(o){let a=o(i,this.options);if(a)return[...t,a]}return[...t]},[]))||[]}};import{fromEvent as Et,once as wl}from"@vkontakte/videoplayer-shared/es2015";var ue=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,pe=r=>ue(r,"Object"),dt=r=>ue(r,"String"),mt=r=>ue(r,"Array"),ft=r=>ue(r,"Number"),qi=r=>ue(r,"Function"),Di=r=>ue(r,"Boolean"),ur=r=>ft(r)&&!isNaN(r);var de=r=>pe(r)&&Object.keys(r).length===0,pr=r=>mt(r)&&!r.length;var Ne=(r,e)=>dt(r)&&(e?r.trim():r).length;function _e(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 Hi="interactive",V={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderWidthRawValue:"1px",roundCornersRawValue:"0",borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0,shadowColorLight:"#fff",shadowColorDark:"#000",shadowColorAlpha:.24},Ui=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(Ui||{}),Gi=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(Gi||{}),zi=(i=>(i.start="left",i.end="right",i.center="center",i))(zi||{}),vt=({target:r,props:e})=>{var t,i,n;r.style.alignItems=(t=(e==null?void 0:e.gravityVertical)&&Ui[e.gravityVertical])!=null?t:"center",r.style.justifyContent=(i=(e==null?void 0:e.gravityHorizontal)&&Gi[e.gravityHorizontal])!=null?i:"center",r.style.textAlign=(n=(e==null?void 0:e.alignment)&&zi[e.alignment])!=null?n:"center"},bt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,o,a,l,s,c;r.style.color=(o=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?o:t.textColor,r.style.fontSize=`calc(${i.height} * ${(l=(a=e==null?void 0:e.text)==null?void 0:a.size)!=null?l:t.textSize})`,r.textContent=(c=(s=e==null?void 0:e.text)==null?void 0:s.value)!=null?c:t.textContent},yt=({target:r,props:e,fallback:t})=>{var i,n,o,a;r.style.backgroundColor=_e((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(a=(o=e==null?void 0:e.background)==null?void 0:o.alpha)!=null?a:t.backgroundAlpha)},$e=({target:r,props:e,fallback:t,dependsOn:i,useRawValues:n=!1})=>{var l,s,c,d,v,b,g,S,E,m,u;let o=n?t.borderWidthRawValue:`calc(${i.height} * ${(c=(s=(l=e==null?void 0:e.shape)==null?void 0:l.border)==null?void 0:s.width)!=null?c:t.borderWidth})`,a=n?t.roundCornersRawValue:`calc(${i.height} * ${(v=(d=e==null?void 0:e.shape)==null?void 0:d.roundCorners)!=null?v:t.roundCorners})`;r.style.borderWidth=o,r.style.borderStyle="solid",r.style.borderColor=_e(n?t.borderColor:(S=(g=(b=e==null?void 0:e.shape)==null?void 0:b.border)==null?void 0:g.color)!=null?S:t.borderColor,n?t.borderAlpha:(u=(m=(E=e==null?void 0:e.shape)==null?void 0:E.border)==null?void 0:m.alpha)!=null?u:t.borderAlpha),r.style.borderRadius=a},Wi=({target:r,isDark:e,baseDimension:t,fallback:i})=>{let a=_e(i.shadowColorLight,i.shadowColorAlpha),l=_e(i.shadowColorDark,i.shadowColorAlpha),s=`calc(${t} * ${.25})`,c=`calc(${t} * ${.11})`,d=`0px 0px ${s} ${c} ${e?l:a}`;r.style.boxShadow=d},Ie=({target:r,layoutParams:e,fallback:t})=>{var n;let i=(n=e.angle)!=null?n:t.angle;i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};import{fromEvent as fr,Subject as xl,Subscription as Sl,ValueSubject as Al}from"@vkontakte/videoplayer-shared/es2015";var hr="interactive-control-tap",xe={common:hr,animation:`${hr}-animation`,visible:`${hr}-visible`};var Tl=60,gt=class{constructor({controlRotateAngleRad:e,clickCancelCondition:t,circleDiameterPx:i=Tl,useDimensionsBasedSize:n=!1}){this.onElementClick=e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let i=t.getBoundingClientRect(),n={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},o=Math.min(n.width,n.height),a=i.left+i.width/2,l=i.top+i.height/2,s=e.clientX-a,c=e.clientY-l,d=Il(s,c,this.controlRotateAngleRad);this.element.style.width=o+"px",this.element.style.left=d.x+i.width/2-o/2+"px",this.element.style.top=d.y+i.height/2-o/2+"px",this.element.classList.add(xe.visible,xe.animation)};this.onAnimationEnd=e=>{!e.target||!e.currentTarget||e.target===e.currentTarget&&this.element.classList.remove(xe.visible,xe.animation)};let o=document.createElement("div");o.classList.add(xe.common),this.controlRotateAngleRad=e,this.element=o,this.clickCancelCondition=t,this.circleDiameterPx=i,this.useDimensionsBasedSize=n}};function Il(r,e,t){return{x:r*Math.cos(t)-e*Math.sin(t),y:r*Math.sin(t)+e*Math.cos(t)}}var dr="int",me=(i=>(i.AREA=`${dr}_area`,i.TEXT=`${dr}_text`,i.BUTTON=`${dr}_bttn`,i))(me||{});function mr(r){return"features"in r}var te="interactive-control",L={common:te,selected:`${te}-selected`,wrapper:`${te}-wrapper`,disabled:`${te}-disabled`,button:`${te}-button`,area:`${te}-area`,text:`${te}-text`,blinkAnim:`${te}-blink-anim`,blinkAnimButton:`${te}-blink-anim-button`,blinkAnimArea:`${te}-blink-anim-area`},Ki=40;var B=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var he=class{constructor(e,t){this.control=e;this.options=t;this.container=null;this.controlElement=null;this.subscriptions=new Sl;this.error$=new xl;this.isInteracted$=new Al(!1)}onError(e="",t){let i=new B(1,1,{message:e,error:t,details:{id:this.control.id}});this.error$.next(i)}addControlTap(e){var t;if(this.featureIsEnabled("controlsTapPlace")&&this.container){let i=(t=this.control.layoutParams.angle)!=null?t:V.angle;this.controlTap=new gt({controlRotateAngleRad:i,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?Ki:void 0}),this.subscriptions.add(fr(e,"click").subscribe(this.controlTap.onElementClick,n=>this.onError("Control click tap animation error",n))).add(fr(this.controlTap.element,"animationend").subscribe(this.controlTap.onAnimationEnd,n=>this.onError("Tap animationend error",n))),this.container.element.append(this.controlTap.element)}}createContainerElement(e){var o;let t=document.createElement("div");t.classList.add(L.wrapper),e.setControlLayout(t,this.control.layoutParams);let i=((o=this.control.layoutParams.innerSizesDependOn)!=null?o:V.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"},n=()=>{var a,l;return(l=(a=e.isContainerDisabled)==null?void 0:a.call(e))!=null?l:!1};this.container={element:t,dimensions:i,isManifestContainerDisabled:n}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted$.next(!0),e()}}featureIsEnabled(e){return this.options&&mr(this.options)&&this.options.features[e]}isTouch(){return this.options&&mr(this.options)&&this.options.isTouch}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case"onclick":{if(!this.container)break;this.subscriptions.add(fr(this.container.element,"click").subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),n=>this.onError("Error happened on control interaction",n)));break}default:break}})}removeListeners(){this.subscriptions.unsubscribe()}};var yr="interactive-blink-anim-reference",q={common:yr,animation:`${yr}-animation`,disabled:`${yr}-disabled`},Ct=class{constructor(){this._RAFId=0;this._element=void 0}get element(){return this._element}create(){if(this._element)return;let e=document.createElement("div");e.classList.add(q.common,q.animation),this._element=e}restart(){this._element&&(this._element.classList.add(q.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(q.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&(cancelAnimationFrame(this._RAFId),this._RAFId=0)}destroy(){this.cleanupRAF(),this._element=void 0}};var gr="interactive-container",D={common:gr,hidden:`${gr}-hidden`,disabled:`${gr}-disabled`};var Tt=(r,e)=>{if(r.type.trim().toLowerCase()==="area")return new Cr(r,e)},Cr=class extends he{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(L.common,L.area),i.setAttribute("data-testid",me.AREA),yt({target:i,props:this.control.props,fallback:x(f({},V),{backgroundColor:"transparent"})}),Ie({target:i,layoutParams:this.control.layoutParams,fallback:V}),this.addControlTap(i),this.container.element.append(i),e.append(this.container.element),this.controlElement=i,this.updateShadowStyles(),this.registerEvents()}registerEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(Et(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(D.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${q.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(Et(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(D.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(Et(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(L.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(L.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){var t,i,n;if(!(!this.container||!this.controlElement))if(Di(e)){let o=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+"px";Wi({target:this.controlElement,props:this.control.props,fallback:V,isDark:e,baseDimension:o}),$e({target:this.controlElement,props:this.control.props,fallback:x(f({},V),{borderColor:e?V.shadowColorDark:V.shadowColorLight,borderAlpha:1,borderWidthRawValue:"0.1px",roundCornersRawValue:`calc(${this.container.dimensions.height} * ${(n=(i=(t=this.control.props)==null?void 0:t.shape)==null?void 0:i.roundCorners)!=null?n:V.roundCorners})`}),dependsOn:this.container.dimensions,useRawValues:!0})}else $e({target:this.controlElement,props:this.control.props,fallback:x(f({},V),{borderAlpha:0}),dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(L.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(L.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${L.blinkAnimArea}`)||this.controlElement.classList.contains(L.selected)||this.controlElement.classList.contains(q.disabled)||(this.controlElement.classList.add(q.disabled),this.subscriptions.add(Et(e,"animationiteration").pipe(wl()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(q.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${L.blinkAnimArea}`)||this.controlElement.classList.contains(L.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-area-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}};import{fromEvent as wt,once as Pl}from"@vkontakte/videoplayer-shared/es2015";var It=r=>{let e=document.createElement("span");switch(r){case"Button":case"button":{let t=document.createElement("div"),i={overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"};Object.assign(t.style,i),t.append(e);let n={display:"inline-block",whiteSpace:"pre",textOverflow:"ellipsis",maxWidth:"initial",maxHeight:"100%",wordBreak:"normal"};return Object.assign(e.style,n),t}default:{let t={display:"inline-block",whiteSpace:"break-spaces",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",maxHeight:"100%",wordBreak:"break-all"};return Object.assign(e.style,t),e}}};var xt=Math.PI,Er=2*xt,St=xt/2,Qi=3*St,Rl=0,kl=[Rl,St,xt,Qi];function Xi(r){return r===St}function Yi(r){return r===xt}function Zi(r){return r===Qi}function Ji(r){return(r%Er+Er)%Er}function Ol(r){for(let e of kl)if(r===e)return e}function en(r){if(Ol(r))return null;let t=Math.floor(r/St)+1;return[1,2,3,4][t-1]}function tn(r){return r*180/Math.PI}var ae="interactive-control-fill-animation",H={common:ae,fillerWrapper:`${ae}-filler-wrapper`,filler:`${ae}-filler`,fillHeight:`${ae}-fill-height`,fillWidth:`${ae}-fill-width`,fromTop:`${ae}-from-top`,fromBottom:`${ae}-from-bottom`,fromLeft:`${ae}-from-left`,fromRight:`${ae}-from-right`};var At=class r{constructor(e){this.widthExpansionCoef=0;var m;let t=document.createElement("div");t.classList.add(H.common);let i=document.createElement("div");i.classList.add(H.fillerWrapper);let n=document.createElement("div");n.classList.add(H.filler),i.append(n),t.append(i);let o=Ji(e.rotateAngle),a=en(o),l=a!==null,c=a===2||!l&&Yi(o)||a===3,d=!l&&Xi(o),v=!l&&Zi(o),b=!c&&!d&&!v,g=d||v,S=l&&!g,E=S?o:0;t.style.borderRadius=e.borderRadius,i.style.transform=`skew(${E*-1}rad)`,g?(n.classList.add(H.fillHeight,d?H.fromTop:H.fromBottom),i.classList.add(H.fillHeight,d?H.fromTop:H.fromBottom)):(n.classList.add(H.fillWidth,b?H.fromLeft:H.fromRight),i.classList.add(H.fillWidth)),e.debug&&console.log(`[interactive ${r.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:e,shouldFillHeight:g,rotateAngleRad:o,rotateAngelDeg:tn(o),rotateAngleRaw:e.rotateAngle,fromRight:c,fromTop:d,fromBottom:v,fromLeft:b}),this.useSkew=S,this.fromLeft=b,this.rotateAngle=o,this.fillAnimationElement=t,this.fillAnimationFillerElement=n,this.fillAnimationFillerWrapperElement=i,this.startTime=e.startTime,this.endTime=e.endTime,this.shouldFillHeight=g,this.isDebug=(m=e.debug)!=null?m:!1}updateDimension(e){this.fillAnimationElement.style.top=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.left=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.width=`${e.width}px`,this.fillAnimationElement.style.height=`${e.height}px`;let t=this.calcWidthExpansionCoef({rotateAngle:this.rotateAngle,isSkewed:this.useSkew,initWidth:e.width,initHeight:e.height});!this.shouldFillHeight&&(this.fillAnimationFillerWrapperElement.style.width=100*t+100+"%",this.fillAnimationFillerWrapperElement.style[`${this.fromLeft?"left":"right"}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((o=>o<this.startTime||o>this.endTime)(e))return;let i=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/i,0),1);this.shouldFillHeight?this.fillAnimationFillerElement.style.transform=`scaleY(${n})`:this.fillAnimationFillerElement.style.transform=`scaleX(${n})`}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:i,initHeight:n}){return t?(i+n*Math.abs(Math.tan(e)))/i-1:0}};var Rt=(r,e)=>{if(r.type.trim().toLowerCase()==="button")return new Tr(r,e)},Tr=class extends he{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a,l,s,c,d,v;if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(L.common,L.button),i.setAttribute("data-testid",me.BUTTON),Ie({target:i,layoutParams:this.control.layoutParams,fallback:V}),yt({target:i,props:this.control.props,fallback:V}),$e({target:i,props:this.control.props,fallback:V,dependsOn:this.container.dimensions}),vt({target:i,props:x(f({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let n=It(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;bt({target:o,props:this.control.props,fallback:V,dependsOn:this.container.dimensions}),this.addControlTap(i),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled("controlsFillAnimation")&&(this.controlFillAnimation=new At({startTime:this.startTime,endTime:this.endTime,rotateAngle:(l=this.control.layoutParams.angle)!=null?l:V.angle,borderRadius:i.style.borderRadius})),i.append(n,(c=(s=this.controlFillAnimation)==null?void 0:s.fillAnimationElement)!=null?c:""),this.container.element.append((v=(d=this.controlTap)==null?void 0:d.element)!=null?v:"",i),e.append(this.container.element),this.controlElement=i,this.registerEvents()}registerEvents(){var t;if(!this.featureIsEnabled("controlsExpectTimeBlinkAnimation"))return;let e=(t=this.container)==null?void 0:t.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(wt(this.controlElement,"mouseleave").subscribe(()=>{if(e.classList.contains(D.disabled))return;let i=e.parentElement;if(i){let n=i.querySelector(`.${q.common}`);n&&this.syncBlinkAnimation(n)}},i=>this.onError("Error happened in mouseleave callback",i))),this.subscriptions.add(wt(this.controlElement,"mouseenter").subscribe(()=>{e.classList.contains(D.disabled)||this.onBlinkHovering()},i=>this.onError("Error happened in mouseenter callback",i))).add(wt(this.controlElement,"mouseleave").subscribe(()=>{this.controlElement&&(this.controlElement.style.animation="")},i=>this.onError("Error happened in mouseleave callback",i))))}disable(){this.controlElement&&this.controlElement.classList.add(L.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(L.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){var t,i;(t=this.controlElement)==null||t.classList.toggle(L.blinkAnim,e),(i=this.controlElement)==null||i.classList.toggle(L.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${L.blinkAnimButton}`)||this.controlElement.classList.contains(L.selected)||this.controlElement.classList.contains(q.disabled)||(this.controlElement.classList.add(q.disabled),this.subscriptions.add(wt(e,"animationiteration").pipe(Pl()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(q.disabled)},t=>this.onError("Error happened in animationiteration callback",t)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${L.blinkAnimButton}`)||this.controlElement.classList.contains(L.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue("--interactive-button-hover-opacity").trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation="none",requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}updateFillAnimationDimensions(){if(!this.container||!this.controlElement||!this.controlFillAnimation)return;let e=getComputedStyle(this.controlElement),t={width:parseFloat(e.width),height:parseFloat(e.height),borderWidth:parseFloat(e.borderWidth)||0};this.controlFillAnimation.updateDimension(t)}setShowTimeRange(e,t){this.startTime=e,this.endTime=t}onProgress(e){var t;(t=this.controlFillAnimation)==null||t.updateAnimation(e)}onResize(){this.updateFillAnimationDimensions()}updateShadowStyles(){}};var rn=(r,e)=>{if(r.type.trim().toLowerCase()==="text")return new Ir(r,e)},Ir=class extends he{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){var a;if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(L.common,L.text),i.setAttribute("data-testid",me.TEXT),Ie({target:i,layoutParams:this.control.layoutParams,fallback:V}),vt({target:i,props:x(f({},this.control.props.text),{alignment:this.control.layoutParams.alignment})});let n=It(this.control.type.trim().toLowerCase()),o=(a=n.firstElementChild)!=null?a:n;bt({target:o,props:this.control.props,fallback:V,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}setShowTimeRange(){}updateFillAnimationDimensions(){}onError(){}};var kt=(r,e,t)=>{if(r.type.trim().toLowerCase()==="choice")return new xr(r,e,t)},xr=class extends Te{constructor(t,i,n){super(t,n);this.containerElement=null;this.controlSubscriptions=new Ml;this.error$=new Ll;this.rootElement=i,this.layout=new ht(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Rt),this.addControlFactory("text",rn),this.addControlFactory("area",Tt)}createView({eventCallback:t,videoDurationMs:i}){let n=document.createElement("div");return n.classList.add(D.common,D.disabled),requestAnimationFrame(()=>{n.classList.remove(D.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(o=>{var a;o.setShowTimeRange(this.container.startTime,(a=this.container.endTime)!=null?a:i),o.createView({parentElement:n,callbacks:{setControlLayout:this.layout.setControlLayout,isContainerDisabled:()=>this.isDisabled}}),o.setEvents(t),this.controlSubscriptions.add(o.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.containerElement=n,this.updateControlsFillAnimationDimensions(),n}updateControlsFillAnimationDimensions(){for(let t of this.controls)t.updateFillAnimationDimensions()}hide(){let t=this.getElement();t&&t.classList.add(D.hidden)}show(){let t=this.getElement();t&&t.classList.remove(D.hidden)}enable(){let t=this.getElement();t&&(t.classList.remove(D.disabled),this.controls.forEach(i=>i.enable()),this.isDisabled=!1)}disable(){let t=this.getElement();t&&(t.classList.add(D.disabled),this.controls.forEach(i=>i.disable()),this.isDisabled=!0)}removeView(){let t=this.getElement();t&&(this.controlSubscriptions.unsubscribe(),this.controls.forEach(i=>i.removeListeners()),t.remove(),this.isRemoved=!0,this.containerElement=null)}fakeRemove(){this.isRemoved||(this.isRemoved=!0)}getElement(){return this.containerElement}onProgress(t,i){i&&this.controls.forEach(n=>{n.onProgress(t)})}onResize(t){t&&this.controls.forEach(i=>{i.onResize()})}updateControlsShadowStyles(t){this.controls.forEach(i=>i.updateShadowStyles(t))}toggleBlinkAnimation(t){this.controls.forEach(i=>i.toggleBlinkAnimation(t))}};var dl=ee(ti(),1);import{combine as Qh,InterfaceLanguage as Xh,Observable as ul,once as Yh,Subject as U,Subscription as Si,ValueSubject as G,fromEvent as pl}from"@vkontakte/videoplayer-shared/es2015";import{InteractiveInterfaceClick as ct}from"@vkontakte/videoplayer-statistics/es2015";import{loadVKLangPack as Qu}from"@vkontakte/videoplayer-shared/es2015";function Xe(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var sa="video_interactive",la="videoint";var ca=250,Ye=class{constructor(e){this.handleZoomChange=Xe(e=>{this.lastZoomInfo=e},ca);this.onResize=e=>{var i;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((i=this.ngEditor)==null||i.zoomTo(t,void 0,{isFromCenter:!0})),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,i,n;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Chapter id is not found");return}this.visitedChapterIds.add(e.id),(i=this.ngEditor)==null||i.selectChapter(e.id),(n=this.ngEditor)==null||n.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var i;if(this.isReady=!1,!ft(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:i,lang:n,visitedChapters:o=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(o),this.onOpenPreviewClick=t,this.onError=i,this.lang=n!=null?n:"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Xu(e),this.resizeObserver=new ResizeObserver(Xe(this.onResize,ca)),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 R(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 R(this,null,function*(){var i;if(!this.manifest)return;let e;try{e=yield Qu(this.lang,sa,la)}catch(n){(i=this.onError)==null||i.call(this,"Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"view",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on("control",a=>{var l=a,{name:n}=l,o=J(l,["name"]);var s;n==="openPreview"&&"chapterId"in o&&((s=this.onOpenPreviewClick)==null||s.call(this,o.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0})}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Xu(r){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",r.append(e),e}var Ze=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,i=!1,n=Math.round(this._player.info.position$.getValue()*1e3);for(let o of this._containers){let a=o.startTime-e;if(a<=n&&(o.endTime&&n<=o.endTime||o.endTime===null)){i=!0;break}n<a&&(t=t===-1?a:Math.min(t,a))}return!i&&t!==-1?t:null}}};import{isSupportedManifest as Bt,ContainerTypes as uv,ControlTypes as qt,EventActionTypes as P,EventTypes as pv,migrateManifestToLatestVersion as da,compareVersions as hv}from"@interactiveplatform/movika-manifest";var ua={metadata:"Object",chapters:"Array"},pa=r=>{if(!pe(r))return!1;for(let e in ua)if(!r[e]||!ue(r[e],ua[e]))return!1;return Bt(r.metadata.version)},jt=r=>r.type===qt.Text,rv=r=>r.type===qt.Button,iv=r=>r.type===qt.Area,nv={Choice:"Choice",TextInput:"TextInput"},ov={Button:"Button",Area:"Area",Text:"Text"},av={onClick:"onClick",onSuspense:"onSuspense"},ha={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Dt=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 Ht=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{qi(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 yp}from"@vkontakte/videoplayer-shared/es2015";var Ut=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 R(this,null,function*(){return Yu(...this.loaders[e])(t)})}};function Yu(...r){return function(t){return R(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function Je(r,e,t){return r?x(f({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function Gt(n){var o=n,{actions:r,errors:e,chapterId:t}=o,i=J(o,["actions","errors","chapterId"]);if(t){let a=r.getManifest();if(a){let l=r.getChapter(a.chapters,t);if(l){let s=r.getMedia(a.media,l.videoId),c=r.getGraph(a.graph,l.id);return s?x(f({},i),{actions:r,errors:e,result:{chapter:l,media:s,graph:c}}):x(f({},i),{errors:Je(e,Gt.name,"Could not find media"),actions:r})}}}return x(f({},i),{errors:Je(e,Gt.name,"Could not find chapter"),actions:r})}var zt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let n=0,o=i.length;n<o;n++)if(i[n].callback===t){i.splice(n,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let i=this.listeners[e.type].slice();for(let n=0,o=i.length;n<o;n++){let a=i[n];try{a.callback.call(this,e)}catch(l){Promise.resolve().then(()=>{throw l})}a.options&&a.options.once&&this.removeEventListener(e.type,a.callback)}return!e.defaultPrevented}},Oe=class extends zt{constructor(){super(),this.listeners||zt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}},et=class{constructor(){Object.defineProperty(this,"signal",{value:new Oe,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(n){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let i=e;if(i===void 0)if(typeof document=="undefined")i=new Error("This operation was aborted"),i.name="AbortError";else try{i=new DOMException("signal is aborted without reason")}catch(n){i=new Error("This operation was aborted"),i.name="AbortError"}this.signal.reason=i,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}};typeof Symbol!="undefined"&&Symbol.toStringTag&&(et.prototype[Symbol.toStringTag]="AbortController",Oe.prototype[Symbol.toStringTag]="AbortSignal");function Wt(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 ri(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!Wt({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:o};let o=t;(o&&!o.prototype.hasOwnProperty("signal")||n)&&(o=function(c,d){let v;d&&d.signal&&(v=d.signal,delete d.signal);let b=new t(c,d);return v&&Object.defineProperty(b,"signal",{writable:!1,enumerable:!1,configurable:!0,value:v}),b},o.prototype=t.prototype);let a=e;return{fetch:(s,c)=>{let d=o&&o.prototype.isPrototypeOf(s)?s.signal:c?c.signal:void 0;if(d){let v;try{v=new DOMException("Aborted","AbortError")}catch(g){v=new Error("Aborted"),v.name="AbortError"}if(d.aborted)return Promise.reject(v);let b=new Promise((g,S)=>{d.addEventListener("abort",()=>S(v),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([b,a(s,c)])}return a(s,c)},Request:o}}var Zu=()=>"fetch"in window,tt=Zu()&&Wt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),ma=tt?ri({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,ii=tt?ma.fetch:window.fetch,Av=tt?ma.Request:window.Request,wv=tt?et:window.AbortController,Rv=tt?Oe:window.AbortSignal;var ni=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let o=0;o<Math.max(t.length,i.length)&&!n;o++)t[o]>i[o]?n=1:t[o]<i[o]?n=-1:n=0;return n};var Ju=r=>R(void 0,null,function*(){try{let e={},t;if(dt(r)){t=new URL(r).href;let n=yield ii(t);if(!n.ok)return{};e=yield n.json()}else if(pe(r))e=r;else return{};if(!pa(e))return{};let i=e.metadata.media;if(dt(i)&&!("media"in e))try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let o=yield ii(n);if(!o.ok)throw new Error;e.metadata.media=yield o.json()}catch(n){return rp(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function fa(r){return R(this,null,function*(){let{manifest:e,manifestURL:t}=yield Ju(r);if(!e)throw new Error("Failed on fetch");let i=da(e);return i.media=ep(i.media,t),delete i.metadata.media,i})}function Kt(r,e){if(e)return r.find(t=>t.id===e)}function oi(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 ai(r,e){return r.videos.find(t=>t.id===e)}function ep(r,e){return x(f({},r),{videos:r.videos.map(t=>x(f({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",o=tp(n,e);return x(f({},i),{url:o||n})})}))})}function tp(r="",e){try{return new URL(r,e).href}catch(t){return""}}function rp(r){return ni(r,"3.2.0")>=0}var Aa=ee(rt(),1);var Qt=r=>mt(r)&&!pr(r),ie=r=>r.order==="end",Xt=r=>mt(r.containers)&&!pr(r.containers)&&ie(r),wa=(r,e)=>{var i;let t=r*1e3;return Qt(e.controls)&&t<((i=e.startTime)!=null?i:0)},li=(r,e)=>{var i,n;let t=r*1e3;return Qt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var ve=(r=[])=>r.some(e=>e.action.type==="expect"),ci=(r=[])=>r.find(e=>e.action.type==="expect"),bp=r=>(r==null?void 0:r.length)===1,Pe=r=>bp(r)&&jt(r[0]);function Ra(r=[],e=1/0,t=[]){return r.filter(({container:i})=>!(0,Aa.default)(t,i.container.id)&&ve(i.container.events)&&i.container.endTime===e&&!i.isRemoved)}function Yt({gameControllers:r=[],subjectName:e,subjectId:t,execFn:i}){for(let n of r)if(e==="container"&&n.container.container.id===t){i(n),Ra(r,n.container.container.endTime,[n.container.container.id]).forEach(a=>{i(a)});break}}var ka=(r,e)=>{let t=E=>{let m=e.find(({container:u})=>u.container.id===E);return m==null?void 0:m.container.isRemoved},i=ve(r.events)&&!t(r.id),n=(E,m=!1,u=!1)=>{let h=u?"every":"some";return E.controls[h](y=>{var A;let T=m?E.endTime===r.endTime:!0;return((A=y.events)==null?void 0:A[h](C=>{var I;return((I=C.action)==null?void 0:I.type)===ha.openURI}))&&T})},o=E=>E.some(({container:m})=>n(m.container,!0,!1)&&!m.isRemoved),a=E=>E.every(({container:m})=>m.isRemoved?!0:n(m.container,!0,!0)),l=Ra(e,r.endTime,[r.id]).length,s=E=>E.controls.some(m=>{var u;return(u=m.events)==null?void 0:u.some(h=>{var y,T;return(T=(y=h.action)==null?void 0:y.args)==null?void 0:T.shouldOpenNow})}),c=i||l>0,d=o(e),v=n(r),b=a(e),g=i?!1:l>0,S=s(r);return{isExpectTime:c,hasOtherExpect:l>0,hasOpenURIEvent:d,hasOpenURIEventInCurrentContainer:v,isAllOpenURIEventsValid:b,isExpectEventForCurrentContainer:g,hasShouldOpenNowEvent:S}};var Le=class extends Ut{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new yp(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 R(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Je},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield fa((n=i.result)!=null?n:t),this})}setInitial(){return R(this,null,function*(){return this.setNext()})}setNext(){return R(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:oi,getChapter:Kt,getMedia:ai,getByBranches:this.getByBranches.bind(this),addErrorMessage:Je},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),n.result&&(this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph),this})}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){var i;return this.getByChapterId((i=this.manifest)==null?void 0:i.metadata.initChapterId)||null}getByChapterId(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t||!this.manifest)return null;let n=Kt(this.manifest.chapters,t);if(n){let o=ai(this.manifest.media,n.videoId),a=oi(this.manifest.graph,n.id);if(o)return{chapter:n,media:o,graph:a}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,o,a;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((o=this.chapter)==null?void 0:o.branches);{let l=Kt(((a=this.manifest)==null?void 0:a.chapters)||[],t);return this.getByBranches(l==null?void 0:l.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let o=this.getByChapterId(n.chapterId);return o&&i.push(o),i},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,i;return((t=this.chapter)==null?void 0:t.id)===((i=this.manifest)==null?void 0:i.metadata.initChapterId)}isEndChapter(){return this.chapter?ie(this.chapter):!1}};var ss=ee(Zt(),1);import{Player as zp}from"@vkontakte/videoplayer-core/es2015";import{Subscription as mi,Tracer as Wp,ValueSubject as Kp}from"@vkontakte/videoplayer-shared/es2015";var os=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&e.payload){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};var as=ee(Zt(),1);function hi(){let r=new Map;function e(s){var c=s,{listId:o=Math.random().toString(),itemId:a=Math.random().toString()}=c,l=J(c,["listId","itemId"]);let d=r.get(o),v=f({},l);return d?d[a]=v:r.set(o,{[a]:v}),f({listId:o,itemId:a},l)}function t(o){var a,l;o.player.destroy(),o.container.remove(),o.subscription.unsubscribe(),(a=o.statistics)==null||a.oneStat.destroy(),(l=o.statistics)==null||l.statSubscription.unsubscribe()}function i(o,a){let l=r.get(o);if(!l)throw Error("Can't remove. Not find.");if(a){let s=l[a];s&&t(s),delete l[a],Object.keys(l).length||r.delete(o)}else{for(let s of(0,as.default)(l))t(s);r.delete(o)}}function n(){for(let o of r)i(o[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}var Me=ee(rt(),1);function di(r,e=[]){var o,a,l;let t={},i,n=!e.length;for(let s of r.variants)if(!i&&"cover"in s&&(i=s.cover),"url"in s)switch(s.type.toLowerCase()){case"mp4":(n||(0,Me.default)(e,"mp4"))&&(t.MPEG=x(f({},t.MPEG),{[(o=s.standard)!=null?o:"Invariant quality"]:s.url}));break;case"mpeg":(n||(0,Me.default)(e,"mpeg"))&&(t.MPEG=x(f({},t.MPEG),{[(a=s.standard)!=null?a:"Invariant quality"]:s.url}));break;case"hls":(n||(0,Me.default)(e,"hls"))&&(t=x(f({},t),{HLS:{type:"url",url:s.url}}));break;case"dash":(n||(0,Me.default)(e,"dash"))&&(t=x(f({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:s.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(l=r.title)!=null?l:""}}var it=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&(0,Me.default)(i,e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Qp=2;function fi(r){let e=hi(),t=new mi,i={},n=null,o=!1,a,l=new Kp(null);r&&s(r);function s(m){n=m}function c(m,u,h){var A;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let T=((A=e.map.get(m))!=null?A:{})[u];if(T){i=f({chapterId:h,listId:m,itemId:u},T);let C=i.player;i.subscription.add(C.info.currentQuality$.subscribe(I=>{let j=C.info.position$.getValue(),k=C.info.isAutoQualityEnabled$.getValue();if(!(!I||!j||k))for(let F of e.map)(0,ss.default)(F[1]).forEach(({player:M})=>{it(M,I)})})).add(C.events.started$.subscribe(()=>{d(u)})),T.container.remove(),n.setPlayer(T.player),o||(n.init(),o=!0),l.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}function d(m){return R(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(de(i)||m!==i.itemId)return;let u=n.getChapterBranches(),h=new Set;for(let y of u)h.has(y.media.id)||(yield b({media:y.media,chapterId:y.chapter.id,setAsActive:!1,title:y.chapter.label}),h.add(y.media.id))})}function v(h){return R(this,arguments,function*({chapter:{id:m},manifestVideo:u}){if(de(i)||!n)return;let y=i.player.info.muted$.getValue(),T=i.player.info.currentQuality$.getValue(),A=i.player.info.isAutoQualityEnabled$.getValue(),C=i.player.info.volume$.getValue(),I=i.player.info.currentPlaybackRate$.getValue(),j=!A,k=!1;for(let F of e.map)if(F[0]===u.id&&!n.state.isReplay$.getValue()){let M=Object.keys(F[1]);for(let $ of M)$===i.itemId?(M.length<Qp||(k=!0),e.removePlayer(F[0],$)):(k=!0,c(F[0],$,m),j?it(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(C),i.player.setMuted(y),i.player.setPlaybackRate(I))}else e.removePlayer(F[0]);k||(yield b({media:u,chapterId:m,setAsActive:!0,playbackRate:I}),j?it(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(C),i.player.setMuted(y))})}function b(j){return R(this,arguments,function*({media:m,chapterId:u,prefetch:h=!0,setAsActive:y=!0,autoplay:T=!1,preferredExt:A,title:C,playbackRate:I}){var Ri,ki,Oi,Pi,Li;let k=Math.random().toString(),F=document.createElement("div");a.append(F);let M;if((Ri=n==null?void 0:n.options)!=null&&Ri.vkVideoLoader){let ut=os(m);ut.length&&(M=yield n.options.vkVideoLoader(...ut))}let $=((ki=n==null?void 0:n.options)==null?void 0:ki.coreConfig)||void 0,Ce=x(f({},$),{configName:[...(Oi=$==null?void 0:$.configName)!=null?Oi:[],"interactive"]}),oe=x(f({container:F},((Pi=M==null?void 0:M.videos)==null?void 0:Pi[0])||{sources:di(m,A).sources}),{title:C,failoverHosts:(M==null?void 0:M.failoverHosts)||[]}),Z=new zp(Ce,Wp.createRootTracer());Z.initVideo(oe);let Ai=null;if(M!=null&&M.videos&&(n!=null&&n.options.createOneStat)){let ut=M.videos[0],ar=n.options.createOneStat(ut),Mi=new mi;ar&&(Mi.add(ar.attachTo(Z)),Ai={oneStat:ar,statSubscription:Mi})}let wi=new mi,ml=(Li=i==null?void 0:i.player)==null?void 0:Li.info.isAutoQualityEnabled$.getValue();wi.add(Z.events.canplay$.subscribe(function(){ml||it(Z,i.player.info.currentQuality$.getValue()),I&&Z.setPlaybackRate(I)}));let Ee=e.createPlayer({listId:m.id,itemId:k,player:Z,container:F,sources:di(m,A).sources,config:oe,subscription:wi,statistics:Ai});return y&&c(m.id,Ee.itemId,u),T&&Ee.player.play(),h&&!T&&Ee.player.prepare(),{player:Ee.player,config:Ee.config,statistics:Ee.statistics}})}function g(){S(),n=null,a.remove()}function S(){t.unsubscribe(),e.removeAll(),i={},o=!1}function E(){return R(this,null,function*(){if(!n)throw Error("need to set interactive controller");S(),a=document.createElement("div");let{media:m,chapter:u}=n.getCurrentChapter();m&&u?(t.add(n.events.chapterChanged$.subscribe(v)),yield b({media:m,chapterId:u.id,title:u.label})):console.error("not found")})}return x(f({},e),{init:E,setInteractiveController:s,createPlayer:b,removeAll:g,getActivePlayer:function(){return i},activePlayerChanged:l})}var O={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},nt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},N={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var cs=ee(rt(),1);import{Subscription as Xp}from"@vkontakte/videoplayer-shared/es2015";function vi(r){return function(...t){return r(...t.reverse())}}function ot(r,...e){return(...t)=>pe(e[0])&&pe(t[0])?r(f(f({},e[0]),t[0])):r(...e,...t)}var Jt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:o,globalEvents:a,globalEventEmitter:l,getContainerEventState:s,permanentTextControls:c,interactiveTimeOpenUri:d,disabledControls$:v,onRemove:b,onError:g}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(ve(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.emitContainerVisibilityEvent(!1)))})};this.show=()=>{var t,i,n,o,a,l;if(this.gameState!==2||this.isSelectedControlEvent)return;if(this.container.getElement()){let{hasOpenURIEventInCurrentContainer:s}=this.getContainerEventState();if((i=(t=this.container).show)==null||i.call(t),this.interactiveTimeOpenUri&&s)return;this.emitContainerVisibilityEvent(!0,!1)}else{let s={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(v,b)=>{let{isExpectTime:g,hasOtherExpect:S,hasOpenURIEvent:E,hasOpenURIEventInCurrentContainer:m,isAllOpenURIEventsValid:u,hasShouldOpenNowEvent:h}=this.getContainerEventState(),y=this.interactiveTimeOpenUri&&!m,T=this.interactiveTimeOpenUri&&m;if((!this.interactiveTimeOpenUri||y)&&(this.isSelectedControlEvent=!0),v!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||y)){if(this.interactiveTimeOpenUri){let A=!S&&!u&&m;A&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:A})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&E&&this.gameState!==5){if(T){let C=((I,j,k,F)=>!I&&!j&&k||I&&!j&&k&&!F||I&&!j&&k&&F)(g,S,u,this.isSelectedContainerEvent);this.fakeRemoveView(C)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!g||!S||!h)&&(this.selectBranches.stopExpect(),b())}},isEOV:()=>this.gameState===4},c=ot(this.selectBranches.onControlEvent,s),d=((o=(n=this.player)==null?void 0:n.info.duration$.getValue())!=null?o:1/0)*1e3;this.container.createView({eventCallback:c,videoDurationMs:d}),this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()&&((l=(a=this.container).disable)==null||l.call(a))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var c,d,v;let e=this.player.experimental.element$.getValue(),i=e instanceof HTMLVideoElement?e.readyState:void 0,n=[6,5];if(!i||(0,cs.default)(n,this.gameState)&&!this.isPermanentText)return;let o=this.player.getExactTime();if(wa(o,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(li(o,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let b=this.gameState;this.gameState=3,b===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:b}=this.getContainerEventState(),g=this.selectBranches.state.isExpect,S=this.interactiveTimeOpenUri&&b;if(S&&!g){let E=this.container.getElement();E&&(E.style.visibility!=="hidden"&&((d=(c=this.container).hide)==null||d.call(c)),this.container.isRemoved||this.fakeRemoveView())}!this.isPermanentText&&!S&&this.removeView()}let a=li(o,this.container.container),l=this.container.container.startTime?[this.container.container.startTime,(v=this.container.container.endTime)!=null?v:1/0]:[],s={subjectId:this.container.container.id,subjectName:"container",range:l,currentTime:o,isInteractiveTime:a};this.container.onProgress(o*1e3,a),this.globalEventEmitter.emit(O.eachTick,s),this.globalEvents.eachTick$.next(s)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Xp,this.player=e,this.interactiveEvents=o,this.getContainerEventState=s,this.isPermanentText=c&&Pe(t.container.controls),this.interactiveTimeOpenUri=d,this.disabledControls$=v,this.onRemove=b,this.globalEventEmitter=l,this.gameState=0,this.globalEvents=a,this.onError=g,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e,isFirst:t})):(this.globalEventEmitter.emit(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:"container",type:"visibility",visibility:e}))}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{var t,i,n,o;e?(i=(t=this.container).disable)==null||i.call(t):(o=(n=this.container).enable)==null||o.call(n)})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){var i,n;let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:(i=this.container.container.endTime)!=null?i:1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((n=this.container.container.endTime)!=null?n:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),i=this.interactiveTimeOpenUri?e||t:ve(this.container.container.events)||e;(this.isSelectedControlEvent||!i)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(O.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-removed"}),this.gameState=5,(e=this.onRemove)==null||e.call(this)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:"container",type:"container-fake-removed",removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}destroy(){var e;this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var us=(r=[])=>r.reduce((e,t,i)=>{var o,a,l;let n=((o=t==null?void 0:t.controls)!=null?o:[]).filter(s=>!jt(s));if(Qt(n)){let s=[(a=t.startTime)!=null?a:0,(l=t.endTime)!=null?l:1/0],c={id:t.id,isRemoved:!1};if(!i)e.push({subjects:[c],range:s});else{let d=[],v=-1/0,b=1/0,g=[],S=[];for(let E=0;E<e.length;E++){let m=e[E];if(S.push(...m.subjects),m.range[0]<b&&(b=m.range[0]),m.range[1]>v&&(v=m.range[1]),s[0]>=m.range[0]&&s[1]<=m.range[1])return e[E].subjects.push(c),e;s[0]<m.range[0]&&s[1]>m.range[0]&&(d.push(E),g=g.concat(m.subjects)),s[0]>=m.range[0]&&s[0]<=m.range[1]&&(d.push(E),g=g.concat(m.subjects),s[0]=m.range[0]),s[1]>=m.range[0]&&s[1]<=m.range[1]&&(d.push(E),g=g.concat(m.subjects),s[1]=m.range[1])}if(S.push(c),s[0]<=b&&s[1]>=v)return[{subjects:S,range:s}];d.length&&d.reverse().forEach(E=>{e.splice(E,1)}),e.push({subjects:g.concat([c]),range:s})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);var Gs=ee(rt(),1),Ci=ee(Zt(),1),zs=ee(Hs(),1);function Us(){let r={};function e(){for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&delete r[l]}function t(l){let s={};for(let c in r)+c<=l&&(s[c]=r[c]);return s}function i(l){let s={};for(let c in r)+c>=l&&(s[c]=r[c]);return s}function n({timestamp:l,priority:s,initiator:c}){var d;if(ur(l)){let v=(d=r[l])!=null?d:null;if(v&&s&&Ne(s,!0)){let b={},g=v[s];if(g&&(b=f(f({},b),g)),b=de(b)?null:b,b&&Ne(c,!0)){let S=b[c];return S!=null?S:null}return b}return v}return null}function o({timestamp:l,priority:s,initiator:c}){if(ur(l))if(r[l]){if(s&&Ne(s,!0))if(r[l][s]){if(c&&Ne(c,!0))if(r[l][s][c]){if(delete r[l][s][c],!de(r[l][s]))return!0}else return!1;if(delete r[l][s],!de(r[l]))return!0}else return!1;return delete r[l]}else return!1;return!1}function a(v){var b=v,{timestamp:l,priority:s,initiator:c}=b,d=J(b,["timestamp","priority","initiator"]);var g,S,E;(S=(g=r[l])==null?void 0:g[s])!=null&&S[c]?r[l][s][c].push(f({},d)):(E=r[l])!=null&&E[s]?r[l][s]=x(f({},r[l][s]),{[c]:[f({},d)]}):r[l]?r[l]=x(f({},r[l]),{[s]:{[c]:[f({},d)]}}):r[l]={[s]:{[c]:[f({},d)]}}}return{map:r,remove:o,add:a,removeAll:e,get:n,getLte:t,getGte:i}}var $h=[P.expect,P.setNextBranch],jh=1/0;function Ws(r,e){let t=r,i,n=Bh(e),o=Us(),a,l=()=>{g(),u()},s=h=>{o.add.call(void 0,h),S()},c=(h=[])=>{for(let y of h)if(y.action(),(0,Gs.default)($h,y.actionType))break},d=(h=1/0)=>{var C,I,j;let y=tr((C=o.get({timestamp:h,priority:"control"}))!=null?C:{}),T=tr((I=o.get({timestamp:h,priority:"container"}))!=null?I:{}),A=tr((j=o.get({timestamp:h,priority:"chapter"}))!=null?j:{});return[...y,...T,...A]},v=h=>{n.isReady(h)&&c(d(h))},b=()=>{var h;c([...tr((h=o.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},g=()=>{i&&(a==null||a.unsubscribe(),i=void 0)},S=()=>{i||(i=()=>setTimeout(()=>{v(1/0)}),a=t.events.ended$.subscribe(i))},E=h=>{g(),t=h},m=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),o.remove(h)},u=()=>{n.release(),o.removeAll()};return{setPlayer:E,add:s,remove:m,exec:v,execEndOfVideo:b,listen:S,unlisten:g,release:l,containersEventsCallState:n,getPreparedToExecActions:d}}function Bh(r){let e=new Map;return{setCalled:({timestamp:l,id:s})=>{let c=e.get(l);c&&c[s]!==void 0&&(c[s]=!0)},setData:(l=[])=>{var s;for(let c of l){let d=(s=c.endTime)!=null?s:jh,v=e.get(d);e.set(d,x(f({},v),{[c.id]:!1}))}},resetCalled:l=>{let s=e.get(l);if(s)for(let c in s)s[c]=!1},isReady:l=>{let s=e.get(l);if(!s)return!0;let c=(0,Ci.default)(s);return r?c.some(v=>v):!c.some(v=>!v)},release:()=>e.clear()}}function tr(r){return(0,zs.default)((0,Ci.default)(r)).sort(e=>e.actionType===P.expect?-1:1)}var Ks={videoContentHeight:0,videoContentWidth:0},Qs=r=>{let{height:e,width:t}=r.info.intrinsicVideoSize$.getValue()||{};if(!(e&&t))return Ks;let{clientHeight:i,clientWidth:n}=r.experimental.element$.getValue()||{};if(!(i&&n))return Ks;let o=e/t,a=i/n,l,s;return a>o?(s=n,l=n*o):a<o?(s=i/o,l=i):(s=n,l=i),{videoContentWidth:s,videoContentHeight:l}};var qh=250;function Xs(r){let e,t=new ResizeObserver(l=>{o(l),e=o.bind(null,l)});function i(l){let{parentElement:s,player:c}=r();if(s&&c){let{videoContentWidth:d,videoContentHeight:v}=Qs(c);s.style.setProperty("--interactive-content-width",`${d}px`),s.style.setProperty("--interactive-content-height",`${v}px`),s.style.setProperty("--interactive-width",`${l[0].contentRect.width}px`),s.style.setProperty("--interactive-height",`${l[0].contentRect.height}px`)}}function n(){let{parentElement:l}=r();l.removeAttribute("style")}let o=Xe(l=>{let{fns:s=[]}=r();i(l);for(let c of s)c()},qh);function a(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:a}}var Dh=r=>Math.floor(Math.random()*r),Zs=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let o=r[e],a=(n=o.weight)!=null?n:1;a<t&&(t=a,i=o)}return i},Js=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let o=r[e],a=(n=o.weight)!=null?n:0;a>t&&(t=a,i=o)}return i};var el=r=>{let e=r.length,t=Dh(e);return r[t]},Ys=1,tl=r=>{var i,n;let e=0;for(let o=0;o<r.length;++o)e+=(i=r[o].weight)!=null?i:Ys;let t=Math.random()*e;e=0;for(let o=0;o<r.length-1;++o)if(e+=(n=r[o].weight)!=null?n:Ys,e>=t)return r[o];return r[r.length-1]};var rl={shouldOpenNow:!0,isDetachContainer:!0},il="after-expect",Ei=(r,e=!1)=>x(f({},r),{args:e?f(f({},r.args),rl):f(f({},rl),r.args)}),nl=({globalEventEmitter:r,globalEvents:e,player:t,interactiveEvents:i})=>{let n={isExpect:!1},o=()=>{n.isExpect&&(n.isExpect=!1)},a=({action:u,controlType:h,controlId:y,containerId:T,branches:A=[],onEvent:C,isEOV:I=()=>!1,isDisabled:j=()=>!1})=>{let k=Ei(u,I()),F={timestamp:1/0,priority:"control",initiator:y,actionType:k.type},M=j(),$=r.emit.bind(r,O.interactives,{subjectId:y,subjectType:h,subjectName:"control",type:M?N.actionChoiceCanceled:N.actionChoice,actionType:u.type,payload:f({invokeImmediately:k.args.shouldOpenNow,containerId:T},k.args)}),Ce=()=>{e.interactiveActionChoice$.next({subjectId:y,subjectType:h,subjectName:"control",type:M?"action-choice-canceled":"action-choice",actionType:u.type,payload:f({invokeImmediately:k.args.shouldOpenNow,containerId:T},k.args)})};if(M){$(),Ce();return}switch(k.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let oe=A.find(Z=>Z.id===k.args.branchId);if(!oe)return;C(k.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),$(),Ce(),k.args.shouldOpenNow?E({subjectId:y,subjectName:"control",subjectType:h,action:k,payload:{chapterId:oe.chapterId,autoSelect:!1}}):i.add(x(f({},F),{action:E.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:k,payload:{chapterId:oe.chapterId,autoSelect:!1}})}));return}case P.continuePlayback.trim().toLowerCase():{C(k.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),$(),Ce(),k.args.shouldOpenNow?S({subjectId:y,subjectName:"control",subjectType:h,action:u}):i.add(x(f({},F),{action:S.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:u})}));return}case P.openURI.trim().toLowerCase():{C(k.args.isDetachContainer,g.bind(null,{subjectId:y,subjectName:"control"})),$(),Ce(),k.args.shouldOpenNow?m({subjectId:y,subjectName:"control",subjectType:h,action:k,payload:{URI:u.args.uri}}):i.add(x(f({},F),{action:m.bind(null,{subjectId:y,subjectName:"control",subjectType:h,action:k,payload:{URI:u.args.uri}})}));return}default:{let oe="Unexpected control event",Z=new B(1,1,{message:oe});d(Z,oe);return}}},l=({action:u,container:{id:h,endTime:y},branches:T=[],isEOV:A=!1,autoSelected:C=!1})=>{let I=Ei(u,A),j={timestamp:!I.args.shouldOpenNow||A?1/0:y!=null?y:1/0,priority:"container",initiator:h,actionType:I.type},k=r.emit.bind(r,O.interactives,{subjectId:h,subjectName:"container",type:N.actionChoice,actionType:I.type,payload:f({invokeImmediately:I.args.shouldOpenNow},I.args)}),F=()=>{e.interactiveActionChoice$.next({subjectId:h,subjectName:"container",type:"action-choice",actionType:I.type,payload:f({invokeImmediately:I.args.shouldOpenNow},I.args)})};switch(I.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let M=T.find($=>$.id===I.args.branchId);if(!M)return;k(),F(),i.add(x(f({},j),{action:E.bind(null,{subjectId:h,subjectName:"container",action:I,payload:{chapterId:M.chapterId,autoSelect:C}})}));return}case P.setMaxWeightBranch.trim().toLowerCase():return;case P.setMinWeightBranch.trim().toLowerCase():return;case P.setRandomBranch.trim().toLowerCase():return;case P.setWeightlessRandomBranch.trim().toLowerCase():return;case P.continuePlayback.trim().toLowerCase():{k(),F(),i.add(x(f({},j),{action:S.bind(null,{subjectId:h,subjectName:"container",action:I})}));return}case P.openURI.trim().toLowerCase():{k(),F(),i.add(x(f({},j),{action:m.bind(null,{subjectId:h,subjectName:"container",action:I,payload:{URI:u.args.uri}})}));return}default:{let M="Unexpected container event",$=new B(1,1,{message:M});d($,M);return}}};function s({container:u,branches:h,isEOV:y=!1}){var A,C;let T=ci(u.events);if(T){let I=Ei(T.action,y);r.emit(O.interactives,{subjectId:u.id,subjectName:"container",type:N.actionChoice,actionType:I.type,payload:f({invokeImmediately:I.args.shouldOpenNow},I.args)}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"container",type:"action-choice",actionType:I.type,payload:f({invokeImmediately:I.args.shouldOpenNow},I.args)}),i.add({timestamp:y?1/0:(A=u.endTime)!=null?A:1/0,priority:"container",initiator:u.id,actionType:P.expect,action:b.bind(null,{subjectId:u.id,subjectName:"container"})}),n.isExpect=!0}else for(let I of(C=u.events)!=null?C:[])l({action:I.action,container:u,branches:h,isEOV:y})}let c=({chapterId:u,action:h,branches:y=[]})=>{let T=r.emit.bind(r,O.interactives,{subjectId:u,subjectName:"chapter",type:N.actionChoice,actionType:h.type,payload:h.args}),A=()=>{e.interactiveActionChoice$.next({subjectId:u,subjectName:"chapter",type:"action-choice",actionType:h.type,payload:h.args})};switch(h.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let C=y.find(I=>I.id===h.args.branchId);return C!=null&&C.chapterId?(T(),A(),E.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setWeightlessRandomBranch.trim().toLowerCase():{let C=el(y);return C!=null&&C.chapterId?(T(),A(),E.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setRandomBranch.trim().toLowerCase():{let C=tl(y);return C!=null&&C.chapterId?(T(),A(),E.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setMaxWeightBranch.trim().toLowerCase():{let C=Js(y);return C!=null&&C.chapterId?(T(),A(),E.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.setMinWeightBranch.trim().toLowerCase():{let C=Zs(y);return C!=null&&C.chapterId?(T(),A(),E.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{chapterId:C.chapterId,autoSelect:!0}})):void 0}case P.continuePlayback.trim().toLowerCase():return T(),A(),S.bind(null,{subjectId:u,subjectName:"chapter",action:h});case P.openURI.trim().toLowerCase():return T(),A(),m.bind(null,{subjectId:u,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:{let C="Unexpected chapter event",I=new B(1,1,{message:C});d(I,C);return}}};function d(u,h){console.error(h),e.error$.next(u),r.emit(O.errors,u)}function v(u){var y;let h=ci(u.events);if(h){if(ie(u))return;r.emit(O.interactives,{subjectId:u.id,subjectName:"chapter",type:N.actionChoice,actionType:h.action.type,payload:h.action.args}),e.interactiveActionChoice$.next({subjectId:u.id,subjectName:"chapter",type:"action-choice",actionType:h.action.type,payload:h.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:P.expect,action:b.bind(null,{subjectId:u.id,subjectName:"chapter"})})}else(y=u.events)==null||y.forEach(T=>{let A=c({chapterId:u.id,action:T.action,branches:u.branches});A&&i.add({timestamp:1/0,priority:"chapter",initiator:u.id,actionType:T.action.type,action:A})})}let b=({subjectId:u,subjectName:h})=>{t.pause(),r.emit(O.interactives,{subjectId:u,subjectName:h,type:N.actionExecution,actionType:P.expect}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:P.expect})},g=({subjectId:u,subjectName:h})=>{t.info.isEnded$.getValue()?i.execEndOfVideo():t.play(),r.emit(O.interactives,{subjectId:u,subjectName:h,type:N.actionExecution,actionType:il}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,type:"action-execution",actionType:il})},S=({subjectId:u,subjectName:h,subjectType:y,action:T})=>{r.emit(O.interactives,{subjectId:u,subjectName:h,subjectType:y,type:N.actionExecution,actionType:T.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:y,type:"action-execution",actionType:T.type})},E=({subjectId:u,subjectName:h,subjectType:y,action:T,payload:A})=>{A.behaviour="change-chapter",r.emit(O.interactives,{subjectId:u,subjectName:h,subjectType:y,type:N.actionExecution,actionType:T.type,payload:A}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:y,type:"action-execution",actionType:T.type,payload:A})},m=({subjectId:u,subjectName:h,subjectType:y,action:T,payload:A})=>{if(!A.URI)return;let C=window.open(A.URI,"_blank","noopener,noreferrer");C&&(C.opener=null),r.emit(O.interactives,{subjectId:u,subjectName:h,subjectType:y,type:N.actionExecution,actionType:T.type}),e.interactiveActionExecution$.next({subjectId:u,subjectName:h,subjectType:y,type:"action-execution",actionType:T.type})};return{onControlEvent:a,onContainerEvent:l,onChapterEvent:c,onExpectEvent:b,expectEventHandler:g,setManifestChapterEvents:v,setManifestContainerEvents:s,stopExpect:o,state:n}};var xi=ee(ti(),1);import{Subscription as Wh,Subject as Ii,ValueSubject as st}from"@vkontakte/videoplayer-shared/es2015";var Ti=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(a=>a.id===i);if(!n)return null;let o=e.media.videos.find(a=>n.videoId===a.id);if(!o)return null;t[i]=ol(o)}return t[i]}).filter(Boolean)},Uh=r=>{for(let e of r.variants)if(Gh(e)&&e.payload)return e.payload.id},Gh=r=>!!(r.type==="custom"&&r.payload&&r.payload.type==="vk"),ol=r=>{let e=Uh(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},zh=(r,e)=>{for(let t of r.media.videos)if(e===ol(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},al=(r,e)=>r.reduce((t,i)=>{let n=zh(e,i);return n?[...t,n]:t},[]);var se,be,ye,Q,rr,le,ce,ne,ge,Fe,Ve,lt=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:o}){this.state={history$:new st([]),hasPrevChapter$:new st(!1),prevChapter$:new st(null),isInitialChapter$:new st(!1),isGoBackLimited$:new st(!1)};z(this,se,null);z(this,be);z(this,ye,!1);z(this,Q,null);z(this,rr,null);this.events={inited$:new Ii,destroyed$:new Ii,error$:new Ii};z(this,le,null);z(this,ce,null);z(this,ne,null);z(this,ge,new Wh);z(this,Fe,!1);z(this,Ve,0);var a;_(this,le,t),_(this,ne,e),_(this,ce,i),_(this,se,n),_(this,be,o),this.state.history$&&w(this,ge)&&((a=w(this,ge))==null||a.add(this.state.history$.subscribe(l=>{var s,c;this.state.prevChapter$.next((0,xi.default)(l,-2)||null),this.state.hasPrevChapter$.next(l.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(s=w(this,Q))==null?void 0:s.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(w(this,Ve)===w(this,be).maxLength-1)})))}setManifest(e){return R(this,null,function*(){if(!w(this,ce)||!w(this,ne))return;_(this,Q,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield w(this,ce).setChapter({chapterId:t,pushToHistory:!1}),w(this,ye)||(_(this,ye,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return w(this,ye)}updateHistory(e,t=!0){return R(this,null,function*(){var l;if(!w(this,Q))return;w(this,Fe)?(_(this,Fe,!1),$i(this,Ve)._++):_(this,Ve,0);let i=w(this,Q),n=e.length-w(this,be).maxLength,o=n>0?e.slice(n):e,a=Ti(o,i);if(_(this,rr,a),this.state.history$.next(o),!(!t||!w(this,se)||!w(this,le)))try{yield w(this,se).save(w(this,le),a)}catch(s){let c=new B(1,5,"Unable to save interactive history");this.events.error$.next(c),(l=w(this,ne))==null||l.emit(O.errors,c)}})}goBack(){return R(this,null,function*(){var i;if(!this.state||!w(this,ce)){let n=new B(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=w(this,ne))==null?void 0:i.emit(O.errors,n)}_(this,Fe,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield w(this,ce).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return R(this,null,function*(){var n;if(!w(this,Q)||!w(this,le))return;let e=w(this,Q),t=[this.getInitialVideoId()];if(w(this,se))try{let o=yield w(this,se).get(w(this,le));o.length&&(t=o)}catch(o){let a=new B(1,5,"Error while trying to fetch data");this.events.error$.next(a),(n=w(this,ne))==null||n.emit(O.errors,a)}let i=al(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,xi.default)(e,-1)||w(this,be).initChapterId||((t=w(this,Q))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(w(this,Q)){let e=this.getInitialChapterId();return Ti([e],w(this,Q)).pop()}return null}destroy(){var e,t;_(this,le,null),_(this,se,null),_(this,ce,null),(e=w(this,ge))==null||e.unsubscribe(),_(this,ge,null),_(this,ye,!1),(t=w(this,ne))==null||t.emit(O.historyDestroyed),this.events.destroyed$.next(),_(this,ne,null)}};se=new WeakMap,be=new WeakMap,ye=new WeakMap,Q=new WeakMap,rr=new WeakMap,le=new WeakMap,ce=new WeakMap,ne=new WeakMap,ge=new WeakMap,Fe=new WeakMap,Ve=new WeakMap;var ir=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var n;let e=(n=this.rootElement.getContext("2d"))==null?void 0:n.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,i=t.length;for(let o=3;o<i;o+=40)if(t[o]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(e,t=!1){return R(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 R(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 nr=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;