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