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