@vkontakte/videoplayer-interactive 1.0.24-dev.d2bfe940.0 → 1.0.24
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 +3 -3
- package/es2015.esm.js +3 -3
- package/es2018.cjs.js +3 -3
- package/es2018.esm.js +3 -3
- package/esnext.cjs.js +3 -3
- package/esnext.esm.js +3 -3
- package/evergreen.esm.js +3 -3
- package/package.json +4 -4
package/es2015.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.24
|
|
3
|
-
* Sat, 02 Nov 2024
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.24
|
|
3
|
+
* Sat, 02 Nov 2024 13:45:41 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-24/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var da=Object.create;var Ae=Object.defineProperty,fa=Object.defineProperties,ma=Object.getOwnPropertyDescriptor,ya=Object.getOwnPropertyDescriptors,va=Object.getOwnPropertyNames,Je=Object.getOwnPropertySymbols,ga=Object.getPrototypeOf,Nt=Object.prototype.hasOwnProperty,Zr=Object.prototype.propertyIsEnumerable;var Xr=r=>{throw TypeError(r)};var Yr=(r,e,t)=>e in r?Ae(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,u=(r,e)=>{for(var t in e||(e={}))Nt.call(e,t)&&Yr(r,t,e[t]);if(Je)for(var t of Je(e))Zr.call(e,t)&&Yr(r,t,e[t]);return r},C=(r,e)=>fa(r,ya(e));var N=(r,e)=>{var t={};for(var i in r)Nt.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&Je)for(var i of Je(r))e.indexOf(i)<0&&Zr.call(r,i)&&(t[i]=r[i]);return t};var f=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ba=(r,e)=>{for(var t in e)Ae(r,t,{get:e[t],enumerable:!0})},Jr=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of va(e))!Nt.call(r,n)&&n!==t&&Ae(r,n,{get:()=>e[n],enumerable:!(i=ma(e,n))||i.enumerable});return r};var Ft=(r,e,t)=>(t=r!=null?da(ga(r)):{},Jr(e||!r||!r.__esModule?Ae(t,"default",{value:r,enumerable:!0}):t,r)),Ca=r=>Jr(Ae({},"__esModule",{value:!0}),r);var $t=(r,e,t)=>e.has(r)||Xr("Cannot "+t);var S=(r,e,t)=>($t(r,e,"read from private field"),t?t.call(r):e.get(r)),B=(r,e,t)=>e.has(r)?Xr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),j=(r,e,t,i)=>($t(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Re=(r,e,t)=>($t(r,e,"access private method"),t);var ei=(r,e,t,i)=>({set _(n){j(r,e,n,t)},get _(){return S(r,e,i)}});var L=(r,e,t)=>new Promise((i,n)=>{var s=a=>{try{o(t.next(a))}catch(c){n(c)}},l=a=>{try{o(t.throw(a))}catch(c){n(c)}},o=a=>a.done?i(a.value):Promise.resolve(a.value).then(s,l);o((t=t.apply(r,e)).next())});var Q=f((Wt,li)=>{"use strict";var ke=function(r){return r&&r.Math===Math&&r};li.exports=ke(typeof globalThis=="object"&&globalThis)||ke(typeof window=="object"&&window)||ke(typeof self=="object"&&self)||ke(typeof global=="object"&&global)||ke(typeof Wt=="object"&&Wt)||function(){return this}()||Function("return this")()});var re=f((Zc,ci)=>{"use strict";ci.exports=function(r){try{return!!r()}catch(e){return!0}}});var Pe=f((Xc,pi)=>{"use strict";var Ia=re();pi.exports=!Ia(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var mi=f((Jc,fi)=>{"use strict";var xa=Pe(),di=Function.prototype,hi=di.apply,ui=di.call;fi.exports=typeof Reflect=="object"&&Reflect.apply||(xa?ui.bind(hi):function(){return ui.apply(hi,arguments)})});var ae=f((ep,gi)=>{"use strict";var yi=Pe(),vi=Function.prototype,Qt=vi.call,Ta=yi&&vi.bind.bind(Qt,Qt);gi.exports=yi?Ta:function(r){return function(){return Qt.apply(r,arguments)}}});var Kt=f((tp,Ci)=>{"use strict";var bi=ae(),Sa=bi({}.toString),wa=bi("".slice);Ci.exports=function(r){return wa(Sa(r),8,-1)}});var Yt=f((rp,Ei)=>{"use strict";var La=Kt(),Ma=ae();Ei.exports=function(r){if(La(r)==="Function")return Ma(r)}});var ie=f((ip,Ii)=>{"use strict";var Zt=typeof document=="object"&&document.all;Ii.exports=typeof Zt=="undefined"&&Zt!==void 0?function(r){return typeof r=="function"||r===Zt}:function(r){return typeof r=="function"}});var Ce=f((np,xi)=>{"use strict";var _a=re();xi.exports=!_a(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ut=f((sp,Ti)=>{"use strict";var Aa=Pe(),ht=Function.prototype.call;Ti.exports=Aa?ht.bind(ht):function(){return ht.apply(ht,arguments)}});var Mi=f(Li=>{"use strict";var Si={}.propertyIsEnumerable,wi=Object.getOwnPropertyDescriptor,Ra=wi&&!Si.call({1:2},1);Li.f=Ra?function(e){var t=wi(this,e);return!!t&&t.enumerable}:Si});var Xt=f((op,_i)=>{"use strict";_i.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Ri=f((lp,Ai)=>{"use strict";var ka=ae(),Pa=re(),Va=Kt(),Jt=Object,Oa=ka("".split);Ai.exports=Pa(function(){return!Jt("z").propertyIsEnumerable(0)})?function(r){return Va(r)==="String"?Oa(r,""):Jt(r)}:Jt});var er=f((cp,ki)=>{"use strict";ki.exports=function(r){return r==null}});var tr=f((pp,Pi)=>{"use strict";var ja=er(),Na=TypeError;Pi.exports=function(r){if(ja(r))throw new Na("Can't call method on "+r);return r}});var Oi=f((hp,Vi)=>{"use strict";var Fa=Ri(),$a=tr();Vi.exports=function(r){return Fa($a(r))}});var Ve=f((up,ji)=>{"use strict";var Ba=ie();ji.exports=function(r){return typeof r=="object"?r!==null:Ba(r)}});var rr=f((dp,Ni)=>{"use strict";Ni.exports={}});var sr=f((fp,$i)=>{"use strict";var ir=rr(),nr=Q(),qa=ie(),Fi=function(r){return qa(r)?r:void 0};$i.exports=function(r,e){return arguments.length<2?Fi(ir[r])||Fi(nr[r]):ir[r]&&ir[r][e]||nr[r]&&nr[r][e]}});var qi=f((mp,Bi)=>{"use strict";var Da=ae();Bi.exports=Da({}.isPrototypeOf)});var Gi=f((yp,Ui)=>{"use strict";var Ha=Q(),Di=Ha.navigator,Hi=Di&&Di.userAgent;Ui.exports=Hi?String(Hi):""});var Xi=f((vp,Zi)=>{"use strict";var Yi=Q(),ar=Gi(),zi=Yi.process,Wi=Yi.Deno,Qi=zi&&zi.versions||Wi&&Wi.version,Ki=Qi&&Qi.v8,z,dt;Ki&&(z=Ki.split("."),dt=z[0]>0&&z[0]<4?1:+(z[0]+z[1]));!dt&&ar&&(z=ar.match(/Edge\/(\d+)/),(!z||z[1]>=74)&&(z=ar.match(/Chrome\/(\d+)/),z&&(dt=+z[1])));Zi.exports=dt});var or=f((gp,en)=>{"use strict";var Ji=Xi(),Ua=re(),Ga=Q(),za=Ga.String;en.exports=!!Object.getOwnPropertySymbols&&!Ua(function(){var r=Symbol("symbol detection");return!za(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Ji&&Ji<41})});var lr=f((bp,tn)=>{"use strict";var Wa=or();tn.exports=Wa&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var cr=f((Cp,rn)=>{"use strict";var Qa=sr(),Ka=ie(),Ya=qi(),Za=lr(),Xa=Object;rn.exports=Za?function(r){return typeof r=="symbol"}:function(r){var e=Qa("Symbol");return Ka(e)&&Ya(e.prototype,Xa(r))}});var sn=f((Ep,nn)=>{"use strict";var Ja=String;nn.exports=function(r){try{return Ja(r)}catch(e){return"Object"}}});var pr=f((Ip,an)=>{"use strict";var eo=ie(),to=sn(),ro=TypeError;an.exports=function(r){if(eo(r))return r;throw new ro(to(r)+" is not a function")}});var ln=f((xp,on)=>{"use strict";var io=pr(),no=er();on.exports=function(r,e){var t=r[e];return no(t)?void 0:io(t)}});var pn=f((Tp,cn)=>{"use strict";var hr=ut(),ur=ie(),dr=Ve(),so=TypeError;cn.exports=function(r,e){var t,i;if(e==="string"&&ur(t=r.toString)&&!dr(i=hr(t,r))||ur(t=r.valueOf)&&!dr(i=hr(t,r))||e!=="string"&&ur(t=r.toString)&&!dr(i=hr(t,r)))return i;throw new so("Can't convert object to primitive value")}});var un=f((Sp,hn)=>{"use strict";hn.exports=!0});var mn=f((wp,fn)=>{"use strict";var dn=Q(),ao=Object.defineProperty;fn.exports=function(r,e){try{ao(dn,r,{value:e,configurable:!0,writable:!0})}catch(t){dn[r]=e}return e}});var fr=f((Lp,gn)=>{"use strict";var oo=un(),lo=Q(),co=mn(),yn="__core-js_shared__",vn=gn.exports=lo[yn]||co(yn,{});(vn.versions||(vn.versions=[])).push({version:"3.38.0",mode:oo?"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 En=f((Mp,Cn)=>{"use strict";var bn=fr();Cn.exports=function(r,e){return bn[r]||(bn[r]=e||{})}});var mr=f((_p,In)=>{"use strict";var po=tr(),ho=Object;In.exports=function(r){return ho(po(r))}});var ft=f((Ap,xn)=>{"use strict";var uo=ae(),fo=mr(),mo=uo({}.hasOwnProperty);xn.exports=Object.hasOwn||function(e,t){return mo(fo(e),t)}});var Sn=f((Rp,Tn)=>{"use strict";var yo=ae(),vo=0,go=Math.random(),bo=yo(1 .toString);Tn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+bo(++vo+go,36)}});var Mn=f((kp,Ln)=>{"use strict";var Co=Q(),Eo=En(),wn=ft(),Io=Sn(),xo=or(),To=lr(),Ee=Co.Symbol,yr=Eo("wks"),So=To?Ee.for||Ee:Ee&&Ee.withoutSetter||Io;Ln.exports=function(r){return wn(yr,r)||(yr[r]=xo&&wn(Ee,r)?Ee[r]:So("Symbol."+r)),yr[r]}});var kn=f((Pp,Rn)=>{"use strict";var wo=ut(),_n=Ve(),An=cr(),Lo=ln(),Mo=pn(),_o=Mn(),Ao=TypeError,Ro=_o("toPrimitive");Rn.exports=function(r,e){if(!_n(r)||An(r))return r;var t=Lo(r,Ro),i;if(t){if(e===void 0&&(e="default"),i=wo(t,r,e),!_n(i)||An(i))return i;throw new Ao("Can't convert object to primitive value")}return e===void 0&&(e="number"),Mo(r,e)}});var vr=f((Vp,Pn)=>{"use strict";var ko=kn(),Po=cr();Pn.exports=function(r){var e=ko(r,"string");return Po(e)?e:e+""}});var jn=f((Op,On)=>{"use strict";var Vo=Q(),Vn=Ve(),gr=Vo.document,Oo=Vn(gr)&&Vn(gr.createElement);On.exports=function(r){return Oo?gr.createElement(r):{}}});var br=f((jp,Nn)=>{"use strict";var jo=Ce(),No=re(),Fo=jn();Nn.exports=!jo&&!No(function(){return Object.defineProperty(Fo("div"),"a",{get:function(){return 7}}).a!==7})});var Bn=f($n=>{"use strict";var $o=Ce(),Bo=ut(),qo=Mi(),Do=Xt(),Ho=Oi(),Uo=vr(),Go=ft(),zo=br(),Fn=Object.getOwnPropertyDescriptor;$n.f=$o?Fn:function(e,t){if(e=Ho(e),t=Uo(t),zo)try{return Fn(e,t)}catch(i){}if(Go(e,t))return Do(!Bo(qo.f,e,t),e[t])}});var Dn=f((Fp,qn)=>{"use strict";var Wo=re(),Qo=ie(),Ko=/#|\.prototype\./,Oe=function(r,e){var t=Zo[Yo(r)];return t===Jo?!0:t===Xo?!1:Qo(e)?Wo(e):!!e},Yo=Oe.normalize=function(r){return String(r).replace(Ko,".").toLowerCase()},Zo=Oe.data={},Xo=Oe.NATIVE="N",Jo=Oe.POLYFILL="P";qn.exports=Oe});var Gn=f(($p,Un)=>{"use strict";var Hn=Yt(),el=pr(),tl=Pe(),rl=Hn(Hn.bind);Un.exports=function(r,e){return el(r),e===void 0?r:tl?rl(r,e):function(){return r.apply(e,arguments)}}});var Wn=f((Bp,zn)=>{"use strict";var il=Ce(),nl=re();zn.exports=il&&nl(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Kn=f((qp,Qn)=>{"use strict";var sl=Ve(),al=String,ol=TypeError;Qn.exports=function(r){if(sl(r))return r;throw new ol(al(r)+" is not an object")}});var Xn=f(Zn=>{"use strict";var ll=Ce(),cl=br(),pl=Wn(),mt=Kn(),Yn=vr(),hl=TypeError,Cr=Object.defineProperty,ul=Object.getOwnPropertyDescriptor,Er="enumerable",Ir="configurable",xr="writable";Zn.f=ll?pl?function(e,t,i){if(mt(e),t=Yn(t),mt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&xr in i&&!i[xr]){var n=ul(e,t);n&&n[xr]&&(e[t]=i.value,i={configurable:Ir in i?i[Ir]:n[Ir],enumerable:Er in i?i[Er]:n[Er],writable:!1})}return Cr(e,t,i)}:Cr:function(e,t,i){if(mt(e),t=Yn(t),mt(i),cl)try{return Cr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new hl("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var es=f((Hp,Jn)=>{"use strict";var dl=Ce(),fl=Xn(),ml=Xt();Jn.exports=dl?function(r,e,t){return fl.f(r,e,ml(1,t))}:function(r,e,t){return r[e]=t,r}});var is=f((Up,rs)=>{"use strict";var je=Q(),yl=mi(),vl=Yt(),gl=ie(),bl=Bn().f,Cl=Dn(),Ie=rr(),El=Gn(),xe=es(),ts=ft();fr();var Il=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 yl(r,this,arguments)};return e.prototype=r.prototype,e};rs.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,s=r.proto,l=i?je:n?je[t]:je[t]&&je[t].prototype,o=i?Ie:Ie[t]||xe(Ie,t,{})[t],a=o.prototype,c,m,y,d,E,x,M,b,p;for(d in e)c=Cl(i?d:t+(n?".":"#")+d,r.forced),m=!c&&l&&ts(l,d),x=o[d],m&&(r.dontCallGetSet?(p=bl(l,d),M=p&&p.value):M=l[d]),E=m&&M?M:e[d],!(!c&&!s&&typeof x==typeof E)&&(r.bind&&m?b=El(E,je):r.wrap&&m?b=Il(E):s&&gl(E)?b=vl(E):b=E,(r.sham||E&&E.sham||x&&x.sham)&&xe(b,"sham",!0),xe(o,d,b),s&&(y=t+"Prototype",ts(Ie,y)||xe(Ie,y,{}),xe(Ie[y],d,E),r.real&&a&&(c||!a[d])&&xe(a,d,E)))}});var ss=f((Gp,ns)=>{"use strict";var xl=Math.ceil,Tl=Math.floor;ns.exports=Math.trunc||function(e){var t=+e;return(t>0?Tl:xl)(t)}});var Tr=f((zp,as)=>{"use strict";var Sl=ss();as.exports=function(r){var e=+r;return e!==e||e===0?0:Sl(e)}});var ls=f((Wp,os)=>{"use strict";var wl=Tr(),Ll=Math.min;os.exports=function(r){var e=wl(r);return e>0?Ll(e,9007199254740991):0}});var ps=f((Qp,cs)=>{"use strict";var Ml=ls();cs.exports=function(r){return Ml(r.length)}});var us=f((Kp,hs)=>{"use strict";hs.exports=function(){}});var ds=f(()=>{"use strict";var _l=is(),Al=mr(),Rl=ps(),kl=Tr(),Pl=us();_l({target:"Array",proto:!0},{at:function(e){var t=Al(this),i=Rl(t),n=kl(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:t[s]}});Pl("at")});var ms=f((Xp,fs)=>{"use strict";var Vl=sr();fs.exports=Vl});var vs=f((Jp,ys)=>{"use strict";ds();var Ol=ms();ys.exports=Ol("Array","at")});var bs=f((eh,gs)=>{"use strict";var jl=vs();gs.exports=jl});var Sr=f((th,Cs)=>{"use strict";var Nl=bs();Cs.exports=Nl});var lc={};ba(lc,{CustomError:()=>F,EVENT_NAMES:()=>I,Interactives:()=>Ye,ManifestController:()=>he,SDKInfo:()=>oc,chapterIdsToVKVideoIds:()=>At,compareVersions:()=>Z,getChapterIdByVkVideoId:()=>oa,getVKVideoIdByMedia:()=>$r,getVideoRawIdByMedia:()=>sa,graphEventTypes:()=>Se,hasEndTemplate:()=>ze,interactivesEventTypes:()=>_,isLastChapter:()=>W,isOneTextCtrlContainer:()=>pe,isSupportedManifest:()=>De,isVKVariantItem:()=>aa,utils:()=>ha,vkVideoIdsToChapterIds:()=>Br});module.exports=Ca(lc);var ti="1.0.24-dev.d2bfe940.0";function Bt(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 H="interactive",Ea="interactive-controls-container",et=()=>document.querySelector(`.${Ea}`),ri=.4,q={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},ii=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(ii||{}),ni=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(ni||{}),si=(i=>(i.start="left",i.end="right",i.center="center",i))(si||{}),tt=({target:r,props:e})=>{var t,i,n,s,l,o;r.style.alignItems=(i=((t=e.text)==null?void 0:t.gravityVertical)&&ii[e.text.gravityVertical])!=null?i:"center",r.style.justifyContent=(s=((n=e.text)==null?void 0:n.gravityHorizontal)&&ni[e.text.gravityHorizontal])!=null?s:"center",r.style.textAlign=(o=((l=e.text)==null?void 0:l.alignment)&&si[e.text.alignment])!=null?o:"left"},rt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,o,a,c;r.style.color=(s=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?s:t.textColor,r.style.fontSize=`calc(${i.height} * ${(o=(l=e==null?void 0:e.text)==null?void 0:l.size)!=null?o:t.textSize})`,r.textContent=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},it=({target:r,props:e,fallback:t})=>{var i,n,s,l;r.style.backgroundColor=Bt((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(l=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?l:t.backgroundAlpha)},nt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,o,a,c,m,y,d,E,x;r.style.border=`calc(${i.height} * ${(l=(s=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:s.width)!=null?l:t.borderWidth}) solid ${Bt((c=(a=(o=e==null?void 0:e.shape)==null?void 0:o.border)==null?void 0:a.color)!=null?c:t.borderColor,(d=(y=(m=e==null?void 0:e.shape)==null?void 0:m.border)==null?void 0:y.alpha)!=null?d:t.borderAlpha)}`,r.style.borderRadius=`calc(${i.height} * ${(x=(E=e==null?void 0:e.shape)==null?void 0:E.roundCorners)!=null?x:t.roundCorners})`},ge=({target:r,layoutParams:e,fallback:t})=>{var n;let i=(n=e.angle)!=null?n:t.angle;i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};var Y=class{constructor(e){this.control=e;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){var n;let t=document.createElement("div");t.classList.add(`${H}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:q.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:i}}createClickListener(e){return t=>{t.stopPropagation(),e()}}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var n;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(n=this.container)==null||n.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){var e,t;(e=this.container)!=null&&e.element&&this.clickListener&&((t=this.container)==null||t.element.removeEventListener("click",this.clickListener))}};var qt="int",se=(i=>(i.AREA=`${qt}_area`,i.TEXT=`${qt}_text`,i.BUTTON=`${qt}_bttn`,i))(se||{});var st=r=>{if(r.type.trim().toLowerCase()==="area")return new Dt(r)},Dt=class extends Y{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${H}-${this.control.id}`),i.setAttribute("data-testid",se.AREA),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",it({target:i,props:this.control.props,fallback:C(u({},q),{backgroundColor:"transparent"})}),nt({target:i,props:this.control.props,fallback:C(u({},q),{borderAlpha:0}),dependsOn:this.container.dimensions}),ge({target:i,layoutParams:this.control.layoutParams,fallback:q}),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var at=()=>{let r=document.createElement("span");return r.style.display="inline-block",r.style.whiteSpace="pre",r.style.overflow="hidden",r.style.textOverflow="ellipsis",r.style.maxWidth="100%",r.style.maxHeight="100%",r};var ot=r=>{if(r.type.trim().toLowerCase()==="button")return new Ht(r)},Ht=class extends Y{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${H}-${this.control.id}`),i.setAttribute("data-testid",se.BUTTON),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",i.style.fontFamily="inherit",ge({target:i,layoutParams:this.control.layoutParams,fallback:q}),it({target:i,props:this.control.props,fallback:q}),nt({target:i,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),tt({target:i,props:this.control.props});let n=at();rt({target:n,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var ai=r=>{if(r.type.trim().toLowerCase()==="text")return new Ut(r)},Ut=class extends Y{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(`${H}-${this.control.id}`),i.setAttribute("data-testid",se.TEXT),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.fontFamily="inherit",ge({target:i,layoutParams:this.control.layoutParams,fallback:q}),tt({target:i,props:this.control.props});let n=at();rt({target:n,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){}enable(){}getElement(){return this.controlElement}};var Gt=class{constructor(e){this.layout=e}},lt=class extends Gt{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var te,ct,oi,be=class{constructor(e){B(this,te);this.container=e,this.factories=new Map,Re(this,te,ct).call(this)}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),Re(this,te,ct).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),Re(this,te,ct).call(this)}};te=new WeakSet,ct=function(){this.controls=Re(this,te,oi).call(this)},oi=function(){var e;return(e=this.container.controls)==null?void 0:e.reduce((t,i)=>{let n=i.type.trim().toLowerCase(),s=this.factories.get(n);return s?[...t,s(i)]:[...t]},[])};var pt=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new zt(r,e)},zt=class extends be{constructor(e,t){super(e),this.rootElement=t!=null?t:et(),this.layout=new lt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",ot),this.addControlFactory("text",ai),this.addControlFactory("area",st)}createView(e){let t=document.createElement("div");return t.classList.add(`${H}-${this.container.id}`),this.layout.setContainerLayout(t),this.controls.forEach(i=>{i.createView({parentElement:t,layoutCallback:this.layout.setControlLayout}),i.setEvents(e)}),this.rootElement.append(t),this.isRemoved=!1,t}hide(){let e=this.getElement();e&&(e.style.visibility="hidden")}show(){let e=this.getElement();e&&(e.style.visibility="visible")}enable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.enable()),e.style.opacity=1,this.isDisabled=!1)}disable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.disable()),e.style.opacity=ri,this.isDisabled=!0)}removeView(){var e;this.isRemoved||(this.controls.forEach(t=>t.removeListeners()),(e=this.getElement())==null||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${H}-${this.container.id}`)}};var pa=Ft(Sr(),1),w=require("@vkontakte/videoplayer-shared"),Me=require("@vkontakte/videoplayer-statistics");var Ss=require("@vkontakte/videoplayer-shared");function Ne(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var oe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Fe=r=>oe(r,"Object"),yt=r=>oe(r,"String"),vt=r=>oe(r,"Array"),gt=r=>oe(r,"Number"),Es=r=>oe(r,"Function");var wr=r=>gt(r)&&!isNaN(r);var le=r=>Fe(r)&&Object.keys(r).length===0,Lr=r=>vt(r)&&!r.length;var $e=(r,e)=>yt(r)&&(e?r.trim():r).length;var Is="video_interactive",xs="videoint";var Ts=250,Be=class{constructor(e){this.handleZoomChange=Ne(e=>{this.lastZoomInfo=e},Ts);this.onResize=e=>{var i;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((i=this.ngEditor)==null||i.zoomTo(t)),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,i,n;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(e.id),(i=this.ngEditor)==null||i.selectChapter(e.id),(n=this.ngEditor)==null||n.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var i;if(this.isReady=!1,!gt(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"Can't show graph"),console.error("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:i,lang:n,visitedChapters:s=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=t,this.onError=i,this.lang=n!=null?n:"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Fl(e),this.resizeObserver=new ResizeObserver(Ne(this.onResize,Ts)),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 L(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 L(this,null,function*(){if(!this.manifest)return;let e;try{e=yield(0,Ss.loadVKLangPack)(this.lang,Is,xs)}catch(i){console.log("Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.ngEditor.on("control",s=>{var l=s,{name:i}=l,n=N(l,["name"]);var o;i==="openPreview"&&"chapterId"in n&&((o=this.onOpenPreviewClick)==null||o.call(this,n.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0})}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Fl(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 qe=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,i=!1,n=Math.round(this._player.info.position$.getValue()*1e3);for(let s of this._containers){let l=s.startTime-e;if(l<=n&&(s.endTime&&n<=s.endTime||s.endTime===null)){i=!0;break}n<l&&(t=t===-1?l:Math.min(t,l))}return!i&&t!==-1?t:null}}};var Z=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let s=0;s<Math.max(t.length,i.length)&&!n;s++)t[s]>i[s]?n=1:t[s]<i[s]?n=-1:n=0;return n};var Ls=require("uuid");var $l="3.1",ws={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},Bl={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ms=r=>{let e=[];for(let l of r.chapters){let o,a=[];for(let t of l.branches){let i=t,{isDefault:y}=i,d=N(i,["isDefault"]);y&&(o=d.id),a.push(d)}let c=[],m=[];for(let n of l.containers){let s=n,{fallbackStrategy:y}=s,d=N(s,["fallbackStrategy"]);let E=!!d.endTime,x=[Bl];switch(y){case"await":E?x=[]:c=[];break;case"default":{let M={type:"onSuspense",action:{type:ws.default,args:{branchId:o,shouldOpenNow:!E,isDetachContainer:!0}}};E?x=[M]:c=[M];break}case"random":case"weightlessRandom":case"max":case"min":{let M={type:"onSuspense",action:{type:ws[y],args:{}}};E?x=[M]:c=[M];break}}for(let M of d.controls)m.push(C(u({},d),{controls:[u({},M)],id:(0,Ls.v4)(),events:x}))}e.push(C(u({},l),{containers:m,events:c,branches:a}))}return r.metadata.version=$l,r.metadata.updated=new Date().toISOString(),C(u({},r),{chapters:e})};var ql="3.2",_s=r=>{if(!r.media){let e=r.metadata,{media:t}=e,i=N(e,["media"]);return C(u({},r),{metadata:C(u({},i),{version:ql}),media:t})}return r};var Dl="3.3",Hl=(r=[])=>({edit:{chapters:r},view:{}}),As={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Rs=r=>{var n;let e=[],t=[];for(let s of r.chapters){let i=s,{id:l,x:o,y:a}=i,c=N(i,["id","x","y"]),m=c.containers.map(y=>{var d;return C(u({},y),{controls:y.controls.map(b=>{var p=b,{subtype:E,type:x}=p,M=N(p,["subtype","type"]);return C(u({},M),{type:E!=null?E:x})}),events:(d=y.events)!=null&&d.length?y.events:[As]})});e.push(C(u({id:l},c),{containers:m,events:(n=c.events)!=null&&n.length?c.events:[As]})),t.push({id:l,x:o,y:a})}return C(u({},r),{chapters:e,graph:Hl(t),metadata:C(u({},r.metadata),{version:Dl})})};var Ul=[{version:"3.0",migrate:Ms},{version:"3.1",migrate:_s},{version:"3.2",migrate:Rs}],Mr=r=>Ul.reduce((e,t)=>Z(e.metadata.version,t.version)?e:t.migrate(e),r);var ks={Button:"Button",Area:"Area",Text:"Text"};var R={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Ps={metadata:"Object",chapters:"Array"},Gl="3.0.0",zl="3.3.0",De=r=>{let e=Z(r,Gl);return e===-1?!1:e===0?!0:Z(r,zl)!==1},Vs=r=>{if(!Fe(r))return!1;for(let e in Ps)if(!r[e]||!oe(r[e],Ps[e]))return!1;return De(r.metadata.version)},bt=r=>r.type===ks.Text;var F=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var Ct=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 Et=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Es(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var Bs=require("@vkontakte/videoplayer-shared");var It=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 L(this,null,function*(){return Wl(...this.loaders[e])(t)})}};function Wl(...r){return function(t){return L(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function He(r,e,t){return r?C(u({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function xt(n){var s=n,{actions:r,errors:e,chapterId:t}=s,i=N(s,["actions","errors","chapterId"]);if(t){let l=r.getManifest(),o=r.getChapter(l.chapters,t);if(o){let a=r.getMedia(l.media,o.videoId),c=r.getGraph(l.graph,o.id);return a?C(u({},i),{actions:r,errors:e,result:{chapter:o,media:a,graph:c}}):C(u({},i),{errors:He(e,xt.name,"Could not find media"),actions:r})}}return C(u({},i),{errors:He(e,xt.name,"Could not find chapter"),actions:r})}var Tt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let n=0,s=i.length;n<s;n++)if(i[n].callback===t){i.splice(n,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let i=this.listeners[e.type].slice();for(let n=0,s=i.length;n<s;n++){let l=i[n];try{l.callback.call(this,e)}catch(o){Promise.resolve().then(()=>{throw o})}l.options&&l.options.once&&this.removeEventListener(e.type,l.callback)}return!e.defaultPrevented}},Te=class extends Tt{constructor(){super(),this.listeners||Tt.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)}},Ue=class{constructor(){Object.defineProperty(this,"signal",{value:new Te,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&&(Ue.prototype[Symbol.toStringTag]="AbortController",Te.prototype[Symbol.toStringTag]="AbortSignal");function St(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 _r(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!St({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:s};let s=t;(s&&!s.prototype.hasOwnProperty("signal")||n)&&(s=function(c,m){let y;m&&m.signal&&(y=m.signal,delete m.signal);let d=new t(c,m);return y&&Object.defineProperty(d,"signal",{writable:!1,enumerable:!1,configurable:!0,value:y}),d},s.prototype=t.prototype);let l=e;return{fetch:(a,c)=>{let m=s&&s.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(m){let y;try{y=new DOMException("Aborted","AbortError")}catch(E){y=new Error("Aborted"),y.name="AbortError"}if(m.aborted)return Promise.reject(y);let d=new Promise((E,x)=>{m.addEventListener("abort",()=>x(y),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([d,l(a,c)])}return l(a,c)},Request:s}}var Ge=St({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Os=Ge?_r({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Ar=Ge?Os.fetch:window.fetch,tu=Ge?Os.Request:window.Request,ru=Ge?Ue:window.AbortController,iu=Ge?Te:window.AbortSignal;var Ql=r=>L(void 0,null,function*(){try{let e={},t;if(yt(r)){t=new URL(r).href;let n=yield Ar(t);if(!n.ok)return{};e=yield n.json()}else if(Fe(r))e=r;else return{};if(!Vs(e))return{};let i=e.metadata.media;if(yt(i)&&!e.media)try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let s=yield Ar(n);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(n){return Zl(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function js(r){return L(this,null,function*(){let{manifest:e,manifestURL:t}=yield Ql(r),i=Mr(e);return i.media=Kl(i.media,t),delete i.metadata.media,i})}function wt(r,e){if(e)return r.find(t=>t.id===e)}function Rr(r,e){var t,i;return(t=r.edit)!=null&&t.chapters?r.edit.chapters.find(n=>n.id===e):(i=r.view)!=null&&i.chapters?r.view.chapters.find(n=>n.id===e):void 0}function kr(r,e){return r.videos.find(t=>t.id===e)}function Kl(r,e){return C(u({},r),{videos:r.videos.map(t=>C(u({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",s=Yl(n,e);return C(u({},i),{url:s||n})})}))})}function Yl(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Zl(r){return Z(r,"3.2.0")>=0}var Lt=r=>vt(r)&&!Lr(r),W=r=>r.order==="end",ze=r=>vt(r.containers)&&!Lr(r.containers)&&W(r),Ns=(r,e)=>{var i;let t=r*1e3;return Lt(e.controls)&&t<((i=e.startTime)!=null?i:0)},Pr=(r,e)=>{var i,n;let t=r*1e3;return Lt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var ce=(r=[])=>r.some(e=>e.action.type==="expect"),Vr=(r=[])=>r.find(e=>e.action.type==="expect"),Xl=r=>(r==null?void 0:r.length)===1,pe=r=>Xl(r)&&bt(r[0]);function Fs(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(u(u({},e[0]),t)):r(...e,...t)}var $s=(r,e)=>ce(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&ce(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var he=class extends It{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Bs.ValueSubject(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(t){return L(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:He},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield js((n=i.result)!=null?n:t),this})}setInitial(){return L(this,null,function*(){return this.setNext()})}setNext(){return L(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:Rr,getChapter:wt,getMedia:kr,getByBranches:this.getByBranches.bind(this),addErrorMessage:He},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph,this})}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){var i;return this.getByChapterId((i=this.manifest)==null?void 0:i.metadata.initChapterId)||null}getByChapterId(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t||!this.manifest)return null;let n=wt(this.manifest.chapters,t);if(n){let s=kr(this.manifest.media,n.videoId),l=Rr(this.manifest.graph,n.id);if(s)return{chapter:n,media:s,graph:l}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,s,l;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((s=this.chapter)==null?void 0:s.branches);{let o=wt(((l=this.manifest)==null?void 0:l.chapters)||[],t);return this.getByBranches(o==null?void 0:o.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let s=this.getByChapterId(n.chapterId);return s&&i.push(s),i},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,i;return((t=this.chapter)==null?void 0:t.id)===((i=this.manifest)==null?void 0:i.metadata.initChapterId)}isEndChapter(){return this.chapter?W(this.chapter):!1}};var Ds=require("@vkontakte/videoplayer-core"),ne=require("@vkontakte/videoplayer-shared");var qs=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&"payload"in e){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};function Or(){let r=new Map;function e(a){var c=a,{listId:s=Math.random().toString(),itemId:l=Math.random().toString()}=c,o=N(c,["listId","itemId"]);let m=r.get(s),y=u({},o);return m?m[l]=y:r.set(s,{[l]:y}),u({listId:s,itemId:l},o)}function t(s){var l,o;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(l=s.statistics)==null||l.oneStat.destroy(),(o=s.statistics)==null||o.statSubscription.unsubscribe()}function i(s,l){let o=r.get(s);if(!o)throw Error("Can't remove. Not find.");if(l){let a=o[l];a&&t(a),delete o[l],Object.keys(o).length||r.delete(s)}else{for(let a of Object.values(o))t(a);r.delete(s)}}function n(){for(let s of r)i(s[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}function jr(r,e=[]){var s,l,o;let t={},i,n=!e.length;for(let a of r.variants)if(!i&&"cover"in a&&(i=a.cover),"url"in a)switch(a.type.toLowerCase()){case"mp4":(n||e.includes("mp4"))&&(t.MPEG=C(u({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"mpeg":(n||e.includes("mpeg"))&&(t.MPEG=C(u({},t.MPEG),{[(l=a.standard)!=null?l:"Invariant quality"]:a.url}));break;case"hls":(n||e.includes("hls"))&&(t=C(u({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(n||e.includes("dash"))&&(t=C(u({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(o=r.title)!=null?o:""}}var We=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&i.includes(e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Jl=2;function Nr(r){let e=Or(),t=new ne.Subscription,i={},n=null,s=!1,l,o=new ne.ValueSubject(null);r&&a(r);function a(b){n=b}function c(b,p,h){var v;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let T=((v=e.map.get(b))!=null?v:{})[p];if(T){i=u({chapterId:h,listId:b,itemId:p},T);let k=i.player;i.subscription.add(k.info.currentQuality$.subscribe(A=>{let D=k.info.position$.getValue(),P=k.info.isAutoQualityEnabled$.getValue();if(!(!A||!D||P))for(let O of e.map)Object.values(O[1]).forEach(({player:V})=>{We(V,A)})})).add(k.events.started$.subscribe(()=>{m(p)})),T.container.remove(),n.setPlayer(T.player),s||(n.init(),s=!0),o.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}function m(b){return L(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(le(i)||b!==i.itemId)return;let p=n.getChapterBranches(),h=new Set;for(let g of p)h.has(g.media.id)||(yield d({media:g.media,chapterId:g.chapter.id,setAsActive:!1,title:g.chapter.label}),h.add(g.media.id))})}function y(h){return L(this,arguments,function*({chapter:{id:b},manifestVideo:p}){if(le(i)||!n)return;let g=i.player.info.muted$.getValue(),T=i.player.info.currentQuality$.getValue(),v=i.player.info.isAutoQualityEnabled$.getValue(),k=i.player.info.volume$.getValue(),A=i.player.info.currentPlaybackRate$.getValue(),D=!v,P=!1;for(let O of e.map)if(O[0]===p.id&&!n.state.isReplay$.getValue()){let V=Object.keys(O[1]);for(let $ of V)$===i.itemId?(V.length<Jl||(P=!0),e.removePlayer(O[0],$)):(P=!0,c(O[0],$,b),D?We(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(k),i.player.setMuted(g),i.player.setPlaybackRate(A))}else e.removePlayer(O[0]);P||(yield d({media:p,chapterId:b,setAsActive:!0,playbackRate:A}),D?We(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(k),i.player.setMuted(g))})}function d(D){return L(this,arguments,function*({media:b,chapterId:p,prefetch:h=!0,setAsActive:g=!0,autoplay:T=!1,preferredExt:v,title:k,playbackRate:A}){var Ur,Gr,zr,Wr,Qr;let P=Math.random().toString(),O=document.createElement("div");l.append(O);let V;if((Ur=n==null?void 0:n.options)!=null&&Ur.vkVideoLoader){let Xe=qs(b);Xe.length&&(V=yield n.options.vkVideoLoader(...Xe))}let $=((Gr=n==null?void 0:n.options)==null?void 0:Gr.coreConfig)||void 0,_e=C(u({},$),{configName:[...(zr=$==null?void 0:$.configName)!=null?zr:[],"interactive"]}),Ze=C(u({container:O},((Wr=V==null?void 0:V.videos)==null?void 0:Wr[0])||{sources:jr(b,v).sources}),{title:k,failoverHosts:(V==null?void 0:V.failoverHosts)||[]}),ye=new Ds.Player(_e,ne.Tracer.createRootTracer());ye.initVideo(Ze);let Dr=null;if(V!=null&&V.videos&&(n!=null&&n.options.createOneStat)){let Xe=V.videos[0],jt=n.options.createOneStat(Xe),Kr=new ne.Subscription;jt&&(Kr.add(jt.attachTo(ye)),Dr={oneStat:jt,statSubscription:Kr})}let Hr=new ne.Subscription,ua=(Qr=i==null?void 0:i.player)==null?void 0:Qr.info.isAutoQualityEnabled$.getValue();Hr.add(ye.events.canplay$.subscribe(function(){ua||We(ye,i.player.info.currentQuality$.getValue()),A&&ye.setPlaybackRate(A)}));let ve=e.createPlayer({listId:b.id,itemId:P,player:ye,container:O,sources:jr(b,v).sources,config:Ze,subscription:Hr,statistics:Dr});return g&&c(b.id,ve.itemId,p),T&&ve.player.play(),h&&!T&&ve.player.prepare(),{player:ve.player,config:ve.config,statistics:ve.statistics}})}function E(){x(),n=null,l.remove()}function x(){t.unsubscribe(),e.removeAll(),i={},s=!1}function M(){return L(this,null,function*(){if(!n)throw Error("need to set interactive controller");x(),l=document.createElement("div");let{media:b,chapter:p}=n.getCurrentChapter();b&&p?(t.add(n.events.chapterChanged$.subscribe(y)),yield d({media:b,chapterId:p.id,title:p.label})):console.error("not found")})}return C(u({},e),{init:M,setInteractiveController:a,createPlayer:d,removeAll:E,getActivePlayer:function(){return i},activePlayerChanged:o})}var I={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Se={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},_={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Hs=require("@vkontakte/videoplayer-shared");var Mt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:s,globalEvents:l,globalEventEmitter:o,ignoreContainerEvent:a,permanentTextControls:c,disabledControls$:m,onRemove:y}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(ce(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})))})};this.show=()=>{var e,t,i,n;if(this.gameState===2&&!this.isSelectedControlEvent)if(this.container.getElement())(n=(i=this.container).show)==null||n.call(i),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!0,isFirst:!1});else{let l=Fs(this.selectBranches.onControlEvent,{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})},onEvent:(o,a)=>{this.isSelectedControlEvent=!0,o!==!1&&(this.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})),(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),a(),this.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1}))},isEOV:()=>this.gameState===4});this.container.createView(l),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((t=(e=this.container).disable)==null||t.call(e))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var c;let e=this.player.experimental.element$.getValue(),i=e instanceof HTMLVideoElement?e.readyState:void 0,n=[6,5];if(!i||n.includes(this.gameState)&&!this.isPermanentText)return;let s=this.player.getExactTime();if(Ns(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Pr(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let m=this.gameState;this.gameState=3,m===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let l=Pr(s,this.container.container),o=this.container.container.startTime?[this.container.container.startTime,(c=this.container.container.endTime)!=null?c:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:o,currentTime:s,isInteractiveTime:l};this.globalEventEmitter.emit(I.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Hs.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=a,this.isPermanentText=c&&pe(t.container.controls),this.disabledControls$=m,this.onRemove=y,this.globalEventEmitter=o,this.gameState=0,this.globalEvents=l,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{var t,i,n,s;e?(i=(t=this.container).disable)==null||i.call(t):(s=(n=this.container).enable)==null||s.call(n)}))}selectContainerEvent(e=!1){var t;this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((t=this.container.container.endTime)!=null?t:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=ce(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.containerRemoved,visibility:!1}),this.gameState=5,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var Us=(r=[])=>r.reduce((e,t,i)=>{var s,l,o;let n=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!bt(a));if(Lt(n)){let a=[(l=t.startTime)!=null?l:0,(o=t.endTime)!=null?o:1/0],c=t.id;if(!i)e.push({subjects:[c],range:a});else{let m=[],y=-1/0,d=1/0,E=[],x=[];for(let M=0;M<e.length;M++){let b=e[M];if(x.push(...b.subjects),b.range[0]<d&&(d=b.range[0]),b.range[1]>y&&(y=b.range[1]),a[0]>=b.range[0]&&a[1]<=b.range[1])return e[M].subjects.push(c),e;a[0]<b.range[0]&&a[1]>b.range[0]&&(m.push(M),E=E.concat(b.subjects)),a[0]>=b.range[0]&&a[0]<=b.range[1]&&(m.push(M),E=E.concat(b.subjects),a[0]=b.range[0]),a[1]>=b.range[0]&&a[1]<=b.range[1]&&(m.push(M),E=E.concat(b.subjects),a[1]=b.range[1])}if(x.push(c),a[0]<=d&&a[1]>=y)return[{subjects:x,range:a}];m.length&&m.reverse().forEach(M=>{e.splice(M,1)}),e.push({subjects:E.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);function Gs(){let r={};function e(){for(let o in r)Object.prototype.hasOwnProperty.call(r,o)&&delete r[o]}function t(o){let a={};for(let c in r)+c<=o&&(a[c]=r[c]);return a}function i(o){let a={};for(let c in r)+c>=o&&(a[c]=r[c]);return a}function n({timestamp:o,priority:a,initiator:c}){var m;if(wr(o)){let y=(m=r[o])!=null?m:null;if(y&&a&&$e(a,!0)){let d={},E=y[a];if(E&&(d=u(u({},d),E)),d=le(d)?null:d,d&&$e(c,!0)){let x=d[c];return x!=null?x:null}return d}return y}return null}function s({timestamp:o,priority:a,initiator:c}){if(wr(o))if(r[o]){if(a&&$e(a,!0))if(r[o][a]){if(c&&$e(c,!0))if(r[o][a][c]){if(delete r[o][a][c],!le(r[o][a]))return!0}else return!1;if(delete r[o][a],!le(r[o]))return!0}else return!1;return delete r[o]}else return!1;return!1}function l(y){var d=y,{timestamp:o,priority:a,initiator:c}=d,m=N(d,["timestamp","priority","initiator"]);var E,x,M;(x=(E=r[o])==null?void 0:E[a])!=null&&x[c]?r[o][a][c].push(u({},m)):(M=r[o])!=null&&M[a]?r[o][a]=C(u({},r[o][a]),{[c]:[u({},m)]}):r[o]?r[o]=C(u({},r[o]),{[a]:{[c]:[u({},m)]}}):r[o]={[a]:{[c]:[u({},m)]}}}return{map:r,remove:s,add:l,removeAll:e,get:n,getLte:t,getGte:i}}var ec=[R.expect,R.setNextBranch],tc=1/0;function zs(r){let e=r,t,i=rc(),n=Gs(),s,l=()=>{d(),p()},o=h=>{n.add.call(void 0,h),x()},a=(h=[])=>{for(let g of h)if(g.action(),ec.includes(g.actionType))break},c=(h=1/0)=>{var k,A,D;let g=_t((k=n.get({timestamp:h,priority:"control"}))!=null?k:{}),T=_t((A=n.get({timestamp:h,priority:"container"}))!=null?A:{}),v=_t((D=n.get({timestamp:h,priority:"chapter"}))!=null?D:{});return[...g,...T,...v]},m=h=>{i.isReady(h)&&a(c(h))},y=()=>{var h;a([..._t((h=n.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},d=()=>{t&&(s==null||s.unsubscribe(),t=void 0)},E=h=>{},x=()=>{t||(t=()=>setTimeout(()=>{m(1/0)}),s=e.events.ended$.subscribe(t))},M=h=>{d(),e=h},b=h=>{h.priority==="container"&&i.resetCalled(h.timestamp),n.remove(h)},p=()=>{i.release(),n.removeAll()};return{setPlayer:M,add:o,remove:b,exec:m,execEndOfVideo:y,listen:x,unlisten:d,release:l,containersEventsCallState:i,getPreparedToExecActions:c}}function rc(){let r=new Map;return{setCalled:({timestamp:l,id:o})=>{let a=r.get(l);a&&a[o]!==void 0&&(a[o]=!0)},setData:(l=[])=>{var o,a;for(let c of l){let m=(o=c.endTime)!=null?o:tc,y=(a=r.get(m))!=null?a:{};r.set(m,C(u({},y),{[c.id]:!1}))}},resetCalled:l=>{let o=r.get(l);if(o)for(let a in o)o[a]=!1},isReady:l=>{let o=r.get(l);return o?!Object.values(o).some(a=>!a):!0},release:()=>r.clear()}}function _t(r){return Object.values(r).flat().sort(e=>e.actionType===R.expect?-1:1)}var Ws={videoContentHeight:0,videoContentWidth:0},Qs=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return Ws;let{clientHeight:n,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(n&&s))return Ws;let l=t/i,o=n/s,a,c;return o>l?(c=s,a=s*l):o<l?(c=n/l,a=n):(c=s,a=n),{videoContentWidth:c,videoContentHeight:a}};var ic=250;function Ks(r){let e=()=>{},t=new ResizeObserver(o=>{s(o),e=s.bind(null,o)});function i(o){let{parentElement:a,player:c}=r();if(a&&c){let{videoContentWidth:m,videoContentHeight:y}=Qs(a,c);a.style.setProperty("--interactive-content-width",`${m}px`),a.style.setProperty("--interactive-content-height",`${y}px`),a.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function n(){let{parentElement:o}=r();o.removeAttribute("style")}let s=Ne(o=>{let{fns:a=[]}=r();i(o);for(let c of a)c()},ic);function l(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:l}}var Qe=class{constructor(){this.map={}}push(e,t){e in this.map?this.map[e].push(t):this.map[e]=[t]}get(e){let t=this.map[e];return t?t.slice():null}getAll(){let e=[];for(let t in this.map)e.concat(this.map[t]);return e}remove(e,t){e in this.map&&(this.map[e]=this.map[e].filter(i=>i!==t),this.map[e].length===0&&delete this.map[e])}clear(){this.map={}}keys(){return Object.keys(this.map)}size(){return this.keys().length}};var nc=r=>Math.floor(Math.random()*r),Zs=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let s=r[e],l=(n=s.weight)!=null?n:1;l<t&&(t=l,i=s)}return i},Xs=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let s=r[e],l=(n=s.weight)!=null?n:0;l>t&&(t=l,i=s)}return i};var Js=r=>{let e=r.length,t=nc(e);return r[t]},Ys=1,ea=r=>{var i,n;let e=0;for(let s=0;s<r.length;++s)e+=(i=r[s].weight)!=null?i:Ys;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(n=r[s].weight)!=null?n:Ys,e>=t)return r[s];return r[r.length-1]};var ta={shouldOpenNow:!0,isDetachContainer:!0};var Fr=(r,e=!1)=>C(u({},r),{args:e?u(u({},r.args),ta):u(u({},ta),r.args)}),na=({globalEventEmitter:r,player:e,interactiveEvents:t,removeControllers:i})=>{let n={isExpect:!1},s=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:p,controlType:h,controlId:g,containerId:T,branches:v=[],onEvent:k,isEOV:A=()=>!1,isDisabled:D=()=>!1})=>{let P=Fr(p,A()),O={timestamp:1/0,priority:"control",initiator:g,actionType:P.type},V=D(),$=r.emit.bind(r,I.interactives,{subjectId:g,subjectType:h,subjectName:"control",type:V?_.actionChoiceCanceled:_.actionChoice,actionType:p.type,payload:u({containerId:T},P.args)});if(V){$();return}switch(P.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let _e=v.find(Ze=>Ze.id===P.args.branchId);if(!_e)return;k(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),$(),P.args.shouldOpenNow?x({subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{chapterId:_e.chapterId,autoSelect:!1}}):(t.add(C(u({},O),{action:x.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{chapterId:_e.chapterId,autoSelect:!1}})})),i==null||i());return}case R.continuePlayback.trim().toLowerCase():{k(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),$(),P.args.shouldOpenNow?E({subjectId:g,subjectName:"control",subjectType:h,action:p}):t.add(C(u({},O),{action:E.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:p})}));return}case R.openURI.trim().toLowerCase():{k(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),$(),P.args.shouldOpenNow?b({subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{URI:p.args.uri}}):(t.add(C(u({},O),{action:b.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{URI:p.args.uri}})})),i==null||i());return}default:console.error("Unexpected control event"),r.emit(I.errors,new F(1,1,{message:"Unexpected control event"}));return}},o=({action:p,container:{id:h,endTime:g},branches:T=[],isEOV:v=!1,autoSelected:k=!1})=>{let A=Fr(p,v),D={timestamp:!A.args.shouldOpenNow||v?1/0:g!=null?g:1/0,priority:"container",initiator:h,actionType:A.type},P=r.emit.bind(r,I.interactives,{subjectId:h,subjectName:"container",type:_.actionChoice,actionType:A.type,payload:A.args});switch(A.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let O=T.find(V=>V.id===A.args.branchId);if(!O)return;P(),t.add(C(u({},D),{action:x.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{chapterId:O.chapterId,autoSelect:k}})})),i==null||i();return}case R.setMaxWeightBranch.trim().toLowerCase():return;case R.setMinWeightBranch.trim().toLowerCase():return;case R.setRandomBranch.trim().toLowerCase():return;case R.setWeightlessRandomBranch.trim().toLowerCase():return;case R.continuePlayback.trim().toLowerCase():{P(),t.add(C(u({},D),{action:E.bind(null,{subjectId:h,subjectName:"container",action:A})}));return}case R.openURI.trim().toLowerCase():{P(),t.add(C(u({},D),{action:b.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{URI:p.args.uri}})})),i==null||i();return}default:console.error("Unexpected container event"),r.emit(I.errors,new F(1,1,{message:"Unexpected container event"}));return}};function a({container:p,branches:h,isEOV:g=!1}){var v,k;let T=Vr(p.events);if(T){let A=Fr(T.action,g);r.emit(I.interactives,{subjectId:p.id,subjectName:"container",type:_.actionChoice,actionType:A.type,payload:A.args}),t.add({timestamp:g?1/0:(v=p.endTime)!=null?v:1/0,priority:"container",initiator:p.id,actionType:R.expect,action:y.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let A of(k=p.events)!=null?k:[])o({action:A.action,container:p,branches:h,isEOV:g})}let c=({chapterId:p,action:h,branches:g=[]})=>{let T=r.emit.bind(r,I.interactives,{subjectId:p,subjectName:"chapter",type:_.actionChoice,actionType:h.type,payload:h.args});switch(h.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let v=g.find(k=>k.id===h.args.branchId);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setWeightlessRandomBranch.trim().toLowerCase():{let v=Js(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setRandomBranch.trim().toLowerCase():{let v=ea(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setMaxWeightBranch.trim().toLowerCase():{let v=Xs(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setMinWeightBranch.trim().toLowerCase():{let v=Zs(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.continuePlayback.trim().toLowerCase():return T(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h});case R.openURI.trim().toLowerCase():return T(),b.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:console.error("Unexpected chapter event"),r.emit(I.errors,new F(1,1,{message:"Unexpected chapter event"}));return}};function m(p){var g;let h=Vr(p.events);if(h){if(W(p))return;r.emit(I.interactives,{subjectId:p.id,subjectName:"chapter",type:_.actionChoice,actionType:h.action.type,payload:h.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:R.expect,action:y.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(g=p.events)==null||g.forEach(T=>{let v=c({chapterId:p.id,action:T.action,branches:p.branches});v&&t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:T.action.type,action:v})})}let y=({subjectId:p,subjectName:h})=>{e.pause(),r.emit(I.interactives,{subjectId:p,subjectName:h,type:_.actionExecution,actionType:R.expect})},d=({subjectId:p,subjectName:h})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),r.emit(I.interactives,{subjectId:p,subjectName:h,type:_.actionExecution,actionType:"after-expect"})},E=({subjectId:p,subjectName:h,subjectType:g,action:T})=>{r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type})},x=({subjectId:p,subjectName:h,subjectType:g,action:T,payload:v})=>{v.behaviour="change-chapter",r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type,payload:v})},M=({subjectId:p,subjectName:h,subjectType:g,action:T,payload:v})=>{v.behaviour="change-manifest",r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type,payload:v})},b=({subjectId:p,subjectName:h,subjectType:g,action:T,payload:v})=>{if(!v.URI)return;let k=window.open(v.URI,"_blank","noopener,noreferrer");k&&(k.opener=null),r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type})};return{onControlEvent:l,onContainerEvent:o,onChapterEvent:c,onExpectEvent:y,expectEventHandler:d,setManifestChapterEvents:m,setManifestContainerEvents:a,stopExpect:s,state:n}};var qr=Ft(Sr(),1),G=require("@vkontakte/videoplayer-shared");var At=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(l=>l.id===i);if(!n)return null;let s=e.media.videos.find(l=>n.videoId===l.id);if(!s)return null;t[i]=$r(s)}return t[i]}).filter(Boolean)},sa=r=>{for(let e of r.variants)if(aa(e)&&"payload"in e)return e.payload.id},aa=r=>r.type==="custom"&&"payload"in r&&r.payload.type==="vk",$r=r=>{let e=sa(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},oa=(r,e)=>{for(let t of r.media.videos)if(e===$r(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},Br=(r,e)=>r.reduce((t,i)=>{let n=oa(e,i);return n?[...t,n]:t},[]);var X,ue,de,U,Rt,J,ee,K,fe,we,Le,Ke=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new G.ValueSubject([]),hasPrevChapter$:new G.ValueSubject(!1),prevChapter$:new G.ValueSubject(null),isInitialChapter$:new G.ValueSubject(!1),isGoBackLimited$:new G.ValueSubject(!1)};B(this,X,null);B(this,ue);B(this,de,!1);B(this,U,null);B(this,Rt,null);this.events={inited$:new G.Subject,destroyed$:new G.Subject,error$:new G.Subject};B(this,J,null);B(this,ee,null);B(this,K,null);B(this,fe,new G.Subscription);B(this,we,!1);B(this,Le,0);var l;j(this,J,t),j(this,K,e),j(this,ee,i),j(this,X,n),j(this,ue,s),this.state.history$&&S(this,fe)&&((l=S(this,fe))==null||l.add(this.state.history$.subscribe(o=>{var a,c;this.state.prevChapter$.next((0,qr.default)(o,-2)||null),this.state.hasPrevChapter$.next(o.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(a=S(this,U))==null?void 0:a.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(S(this,Le)===S(this,ue).maxLength-1)})))}setManifest(e){return L(this,null,function*(){if(!S(this,ee)||!S(this,K))return;j(this,U,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield S(this,ee).setChapter({chapterId:t,pushToHistory:!1}),S(this,de)||(j(this,de,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return S(this,de)}updateHistory(e,t=!0){return L(this,null,function*(){var o;if(!S(this,U))return;S(this,we)?(j(this,we,!1),ei(this,Le)._++):j(this,Le,0);let i=S(this,U),n=e.length-S(this,ue).maxLength,s=n>0?e.slice(n):e,l=At(s,i);if(j(this,Rt,l),this.state.history$.next(s),!(!t||!S(this,X)||!S(this,J)))try{yield S(this,X).save(S(this,J),l)}catch(a){let c=new F(1,5,"Unable to save interactive history");this.events.error$.next(c),(o=S(this,K))==null||o.emit(I.errors,c)}})}goBack(){return L(this,null,function*(){var i;if(!this.state||!S(this,ee)){let n=new F(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=S(this,K))==null?void 0:i.emit(I.errors,n)}j(this,we,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield S(this,ee).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return L(this,null,function*(){var n;if(!S(this,U)||!S(this,J))return;let e=S(this,U),t=[this.getInitialVideoId()];if(S(this,X))try{let s=yield S(this,X).get(S(this,J));s.length&&(t=s)}catch(s){let l=new F(1,5,"Error while trying to fetch data");this.events.error$.next(l),(n=S(this,K))==null||n.emit(I.errors,l)}let i=Br(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,qr.default)(e,-1)||S(this,ue).initChapterId||((t=S(this,U))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(S(this,U)){let e=this.getInitialChapterId();return At([e],S(this,U)).pop()}return null}destroy(){var e,t;j(this,J,null),j(this,X,null),j(this,ee,null),(e=S(this,fe))==null||e.unsubscribe(),j(this,fe,null),j(this,de,!1),(t=S(this,K))==null||t.emit(I.historyDestroyed),this.events.destroyed$.next(),j(this,K,null)}};X=new WeakMap,ue=new WeakMap,de=new WeakMap,U=new WeakMap,Rt=new WeakMap,J=new WeakMap,ee=new WeakMap,K=new WeakMap,fe=new WeakMap,we=new WeakMap,Le=new WeakMap;var me=class me{constructor(e,t,i,n){this.target=e,this.type=t,this.listener=i,this.options=me._convertOptions(e,n),this.target.addEventListener(t,i,this.options)}unlisten(){var e;this.type&&this.listener&&this.options&&((e=this.target)==null||e.removeEventListener(this.type,this.listener,this.options)),this.target=null,this.type=null,this.listener=null,this.options=!1}static _convertOptions(e,t){if(t===void 0)return!1;if(typeof t=="boolean")return t;{let i=new Set(["passive","capture"]),n=Object.keys(t).filter(l=>!i.has(l));return n.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+n.join(",")),me._doesSupportObject(e)?t:t.capture||!1}}static _doesSupportObject(e){let t=me._supportsObject;if(t===void 0){t=!1;try{let i={},n={get:()=>(t=!0,!1)};Object.defineProperty(i,"passive",n),Object.defineProperty(i,"capture",n);let s=()=>{};e.addEventListener("test",s,i),e.removeEventListener("test",s,i)}catch(i){t=!1}me._supportsObject=t}return t||!1}};me._supportsObject=void 0;var kt=me;var Pt=class{constructor(){this.bindingMap=new Qe}release(){this.removeAll(),this.bindingMap=null}listen(e,t,i,n){if(!this.bindingMap)return;let s=new kt(e,t,i,n);this.bindingMap.push(t,s)}listenOnce(e,t,i,n){let s=l=>{this.unlisten(e,t,s),i(l)};this.listen(e,t,s,n)}unlisten(e,t,i){if(!this.bindingMap)return;let n=this.bindingMap.get(t)||[];for(let s of n)s.target===e&&(i===s.listener||!i)&&(s.unlisten(),this.bindingMap.remove(t,s))}removeAll(){if(!this.bindingMap)return;let e=this.bindingMap.getAll();for(let t of e)t.unlisten();this.bindingMap.clear()}};var Vt=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var n;let e=(n=this.rootElement.getContext("2d"))==null?void 0:n.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,i=t.length;for(let s=3;s<i;s+=40)if(t[s]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(e,t=!1){return L(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 L(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 Ot=class{constructor({parentElement:e,endOffsetMs:t=250,onError:i}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let t=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,i=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(i)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
6
|
+
"use strict";var da=Object.create;var Ae=Object.defineProperty,fa=Object.defineProperties,ma=Object.getOwnPropertyDescriptor,ya=Object.getOwnPropertyDescriptors,va=Object.getOwnPropertyNames,Je=Object.getOwnPropertySymbols,ga=Object.getPrototypeOf,Nt=Object.prototype.hasOwnProperty,Zr=Object.prototype.propertyIsEnumerable;var Xr=r=>{throw TypeError(r)};var Yr=(r,e,t)=>e in r?Ae(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,u=(r,e)=>{for(var t in e||(e={}))Nt.call(e,t)&&Yr(r,t,e[t]);if(Je)for(var t of Je(e))Zr.call(e,t)&&Yr(r,t,e[t]);return r},C=(r,e)=>fa(r,ya(e));var N=(r,e)=>{var t={};for(var i in r)Nt.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&Je)for(var i of Je(r))e.indexOf(i)<0&&Zr.call(r,i)&&(t[i]=r[i]);return t};var f=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ba=(r,e)=>{for(var t in e)Ae(r,t,{get:e[t],enumerable:!0})},Jr=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of va(e))!Nt.call(r,n)&&n!==t&&Ae(r,n,{get:()=>e[n],enumerable:!(i=ma(e,n))||i.enumerable});return r};var Ft=(r,e,t)=>(t=r!=null?da(ga(r)):{},Jr(e||!r||!r.__esModule?Ae(t,"default",{value:r,enumerable:!0}):t,r)),Ca=r=>Jr(Ae({},"__esModule",{value:!0}),r);var $t=(r,e,t)=>e.has(r)||Xr("Cannot "+t);var S=(r,e,t)=>($t(r,e,"read from private field"),t?t.call(r):e.get(r)),B=(r,e,t)=>e.has(r)?Xr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),j=(r,e,t,i)=>($t(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t),Re=(r,e,t)=>($t(r,e,"access private method"),t);var ei=(r,e,t,i)=>({set _(n){j(r,e,n,t)},get _(){return S(r,e,i)}});var L=(r,e,t)=>new Promise((i,n)=>{var s=a=>{try{o(t.next(a))}catch(c){n(c)}},l=a=>{try{o(t.throw(a))}catch(c){n(c)}},o=a=>a.done?i(a.value):Promise.resolve(a.value).then(s,l);o((t=t.apply(r,e)).next())});var Q=f((Wt,li)=>{"use strict";var ke=function(r){return r&&r.Math===Math&&r};li.exports=ke(typeof globalThis=="object"&&globalThis)||ke(typeof window=="object"&&window)||ke(typeof self=="object"&&self)||ke(typeof global=="object"&&global)||ke(typeof Wt=="object"&&Wt)||function(){return this}()||Function("return this")()});var re=f((Zc,ci)=>{"use strict";ci.exports=function(r){try{return!!r()}catch(e){return!0}}});var Pe=f((Xc,pi)=>{"use strict";var Ia=re();pi.exports=!Ia(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var mi=f((Jc,fi)=>{"use strict";var xa=Pe(),di=Function.prototype,hi=di.apply,ui=di.call;fi.exports=typeof Reflect=="object"&&Reflect.apply||(xa?ui.bind(hi):function(){return ui.apply(hi,arguments)})});var ae=f((ep,gi)=>{"use strict";var yi=Pe(),vi=Function.prototype,Qt=vi.call,Ta=yi&&vi.bind.bind(Qt,Qt);gi.exports=yi?Ta:function(r){return function(){return Qt.apply(r,arguments)}}});var Kt=f((tp,Ci)=>{"use strict";var bi=ae(),Sa=bi({}.toString),wa=bi("".slice);Ci.exports=function(r){return wa(Sa(r),8,-1)}});var Yt=f((rp,Ei)=>{"use strict";var La=Kt(),Ma=ae();Ei.exports=function(r){if(La(r)==="Function")return Ma(r)}});var ie=f((ip,Ii)=>{"use strict";var Zt=typeof document=="object"&&document.all;Ii.exports=typeof Zt=="undefined"&&Zt!==void 0?function(r){return typeof r=="function"||r===Zt}:function(r){return typeof r=="function"}});var Ce=f((np,xi)=>{"use strict";var _a=re();xi.exports=!_a(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var ut=f((sp,Ti)=>{"use strict";var Aa=Pe(),ht=Function.prototype.call;Ti.exports=Aa?ht.bind(ht):function(){return ht.apply(ht,arguments)}});var Mi=f(Li=>{"use strict";var Si={}.propertyIsEnumerable,wi=Object.getOwnPropertyDescriptor,Ra=wi&&!Si.call({1:2},1);Li.f=Ra?function(e){var t=wi(this,e);return!!t&&t.enumerable}:Si});var Xt=f((op,_i)=>{"use strict";_i.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Ri=f((lp,Ai)=>{"use strict";var ka=ae(),Pa=re(),Va=Kt(),Jt=Object,Oa=ka("".split);Ai.exports=Pa(function(){return!Jt("z").propertyIsEnumerable(0)})?function(r){return Va(r)==="String"?Oa(r,""):Jt(r)}:Jt});var er=f((cp,ki)=>{"use strict";ki.exports=function(r){return r==null}});var tr=f((pp,Pi)=>{"use strict";var ja=er(),Na=TypeError;Pi.exports=function(r){if(ja(r))throw new Na("Can't call method on "+r);return r}});var Oi=f((hp,Vi)=>{"use strict";var Fa=Ri(),$a=tr();Vi.exports=function(r){return Fa($a(r))}});var Ve=f((up,ji)=>{"use strict";var Ba=ie();ji.exports=function(r){return typeof r=="object"?r!==null:Ba(r)}});var rr=f((dp,Ni)=>{"use strict";Ni.exports={}});var sr=f((fp,$i)=>{"use strict";var ir=rr(),nr=Q(),qa=ie(),Fi=function(r){return qa(r)?r:void 0};$i.exports=function(r,e){return arguments.length<2?Fi(ir[r])||Fi(nr[r]):ir[r]&&ir[r][e]||nr[r]&&nr[r][e]}});var qi=f((mp,Bi)=>{"use strict";var Da=ae();Bi.exports=Da({}.isPrototypeOf)});var Gi=f((yp,Ui)=>{"use strict";var Ha=Q(),Di=Ha.navigator,Hi=Di&&Di.userAgent;Ui.exports=Hi?String(Hi):""});var Xi=f((vp,Zi)=>{"use strict";var Yi=Q(),ar=Gi(),zi=Yi.process,Wi=Yi.Deno,Qi=zi&&zi.versions||Wi&&Wi.version,Ki=Qi&&Qi.v8,z,dt;Ki&&(z=Ki.split("."),dt=z[0]>0&&z[0]<4?1:+(z[0]+z[1]));!dt&&ar&&(z=ar.match(/Edge\/(\d+)/),(!z||z[1]>=74)&&(z=ar.match(/Chrome\/(\d+)/),z&&(dt=+z[1])));Zi.exports=dt});var or=f((gp,en)=>{"use strict";var Ji=Xi(),Ua=re(),Ga=Q(),za=Ga.String;en.exports=!!Object.getOwnPropertySymbols&&!Ua(function(){var r=Symbol("symbol detection");return!za(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Ji&&Ji<41})});var lr=f((bp,tn)=>{"use strict";var Wa=or();tn.exports=Wa&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var cr=f((Cp,rn)=>{"use strict";var Qa=sr(),Ka=ie(),Ya=qi(),Za=lr(),Xa=Object;rn.exports=Za?function(r){return typeof r=="symbol"}:function(r){var e=Qa("Symbol");return Ka(e)&&Ya(e.prototype,Xa(r))}});var sn=f((Ep,nn)=>{"use strict";var Ja=String;nn.exports=function(r){try{return Ja(r)}catch(e){return"Object"}}});var pr=f((Ip,an)=>{"use strict";var eo=ie(),to=sn(),ro=TypeError;an.exports=function(r){if(eo(r))return r;throw new ro(to(r)+" is not a function")}});var ln=f((xp,on)=>{"use strict";var io=pr(),no=er();on.exports=function(r,e){var t=r[e];return no(t)?void 0:io(t)}});var pn=f((Tp,cn)=>{"use strict";var hr=ut(),ur=ie(),dr=Ve(),so=TypeError;cn.exports=function(r,e){var t,i;if(e==="string"&&ur(t=r.toString)&&!dr(i=hr(t,r))||ur(t=r.valueOf)&&!dr(i=hr(t,r))||e!=="string"&&ur(t=r.toString)&&!dr(i=hr(t,r)))return i;throw new so("Can't convert object to primitive value")}});var un=f((Sp,hn)=>{"use strict";hn.exports=!0});var mn=f((wp,fn)=>{"use strict";var dn=Q(),ao=Object.defineProperty;fn.exports=function(r,e){try{ao(dn,r,{value:e,configurable:!0,writable:!0})}catch(t){dn[r]=e}return e}});var fr=f((Lp,gn)=>{"use strict";var oo=un(),lo=Q(),co=mn(),yn="__core-js_shared__",vn=gn.exports=lo[yn]||co(yn,{});(vn.versions||(vn.versions=[])).push({version:"3.38.0",mode:oo?"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 En=f((Mp,Cn)=>{"use strict";var bn=fr();Cn.exports=function(r,e){return bn[r]||(bn[r]=e||{})}});var mr=f((_p,In)=>{"use strict";var po=tr(),ho=Object;In.exports=function(r){return ho(po(r))}});var ft=f((Ap,xn)=>{"use strict";var uo=ae(),fo=mr(),mo=uo({}.hasOwnProperty);xn.exports=Object.hasOwn||function(e,t){return mo(fo(e),t)}});var Sn=f((Rp,Tn)=>{"use strict";var yo=ae(),vo=0,go=Math.random(),bo=yo(1 .toString);Tn.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+bo(++vo+go,36)}});var Mn=f((kp,Ln)=>{"use strict";var Co=Q(),Eo=En(),wn=ft(),Io=Sn(),xo=or(),To=lr(),Ee=Co.Symbol,yr=Eo("wks"),So=To?Ee.for||Ee:Ee&&Ee.withoutSetter||Io;Ln.exports=function(r){return wn(yr,r)||(yr[r]=xo&&wn(Ee,r)?Ee[r]:So("Symbol."+r)),yr[r]}});var kn=f((Pp,Rn)=>{"use strict";var wo=ut(),_n=Ve(),An=cr(),Lo=ln(),Mo=pn(),_o=Mn(),Ao=TypeError,Ro=_o("toPrimitive");Rn.exports=function(r,e){if(!_n(r)||An(r))return r;var t=Lo(r,Ro),i;if(t){if(e===void 0&&(e="default"),i=wo(t,r,e),!_n(i)||An(i))return i;throw new Ao("Can't convert object to primitive value")}return e===void 0&&(e="number"),Mo(r,e)}});var vr=f((Vp,Pn)=>{"use strict";var ko=kn(),Po=cr();Pn.exports=function(r){var e=ko(r,"string");return Po(e)?e:e+""}});var jn=f((Op,On)=>{"use strict";var Vo=Q(),Vn=Ve(),gr=Vo.document,Oo=Vn(gr)&&Vn(gr.createElement);On.exports=function(r){return Oo?gr.createElement(r):{}}});var br=f((jp,Nn)=>{"use strict";var jo=Ce(),No=re(),Fo=jn();Nn.exports=!jo&&!No(function(){return Object.defineProperty(Fo("div"),"a",{get:function(){return 7}}).a!==7})});var Bn=f($n=>{"use strict";var $o=Ce(),Bo=ut(),qo=Mi(),Do=Xt(),Ho=Oi(),Uo=vr(),Go=ft(),zo=br(),Fn=Object.getOwnPropertyDescriptor;$n.f=$o?Fn:function(e,t){if(e=Ho(e),t=Uo(t),zo)try{return Fn(e,t)}catch(i){}if(Go(e,t))return Do(!Bo(qo.f,e,t),e[t])}});var Dn=f((Fp,qn)=>{"use strict";var Wo=re(),Qo=ie(),Ko=/#|\.prototype\./,Oe=function(r,e){var t=Zo[Yo(r)];return t===Jo?!0:t===Xo?!1:Qo(e)?Wo(e):!!e},Yo=Oe.normalize=function(r){return String(r).replace(Ko,".").toLowerCase()},Zo=Oe.data={},Xo=Oe.NATIVE="N",Jo=Oe.POLYFILL="P";qn.exports=Oe});var Gn=f(($p,Un)=>{"use strict";var Hn=Yt(),el=pr(),tl=Pe(),rl=Hn(Hn.bind);Un.exports=function(r,e){return el(r),e===void 0?r:tl?rl(r,e):function(){return r.apply(e,arguments)}}});var Wn=f((Bp,zn)=>{"use strict";var il=Ce(),nl=re();zn.exports=il&&nl(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Kn=f((qp,Qn)=>{"use strict";var sl=Ve(),al=String,ol=TypeError;Qn.exports=function(r){if(sl(r))return r;throw new ol(al(r)+" is not an object")}});var Xn=f(Zn=>{"use strict";var ll=Ce(),cl=br(),pl=Wn(),mt=Kn(),Yn=vr(),hl=TypeError,Cr=Object.defineProperty,ul=Object.getOwnPropertyDescriptor,Er="enumerable",Ir="configurable",xr="writable";Zn.f=ll?pl?function(e,t,i){if(mt(e),t=Yn(t),mt(i),typeof e=="function"&&t==="prototype"&&"value"in i&&xr in i&&!i[xr]){var n=ul(e,t);n&&n[xr]&&(e[t]=i.value,i={configurable:Ir in i?i[Ir]:n[Ir],enumerable:Er in i?i[Er]:n[Er],writable:!1})}return Cr(e,t,i)}:Cr:function(e,t,i){if(mt(e),t=Yn(t),mt(i),cl)try{return Cr(e,t,i)}catch(n){}if("get"in i||"set"in i)throw new hl("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var es=f((Hp,Jn)=>{"use strict";var dl=Ce(),fl=Xn(),ml=Xt();Jn.exports=dl?function(r,e,t){return fl.f(r,e,ml(1,t))}:function(r,e,t){return r[e]=t,r}});var is=f((Up,rs)=>{"use strict";var je=Q(),yl=mi(),vl=Yt(),gl=ie(),bl=Bn().f,Cl=Dn(),Ie=rr(),El=Gn(),xe=es(),ts=ft();fr();var Il=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 yl(r,this,arguments)};return e.prototype=r.prototype,e};rs.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,s=r.proto,l=i?je:n?je[t]:je[t]&&je[t].prototype,o=i?Ie:Ie[t]||xe(Ie,t,{})[t],a=o.prototype,c,m,y,d,E,x,M,b,p;for(d in e)c=Cl(i?d:t+(n?".":"#")+d,r.forced),m=!c&&l&&ts(l,d),x=o[d],m&&(r.dontCallGetSet?(p=bl(l,d),M=p&&p.value):M=l[d]),E=m&&M?M:e[d],!(!c&&!s&&typeof x==typeof E)&&(r.bind&&m?b=El(E,je):r.wrap&&m?b=Il(E):s&&gl(E)?b=vl(E):b=E,(r.sham||E&&E.sham||x&&x.sham)&&xe(b,"sham",!0),xe(o,d,b),s&&(y=t+"Prototype",ts(Ie,y)||xe(Ie,y,{}),xe(Ie[y],d,E),r.real&&a&&(c||!a[d])&&xe(a,d,E)))}});var ss=f((Gp,ns)=>{"use strict";var xl=Math.ceil,Tl=Math.floor;ns.exports=Math.trunc||function(e){var t=+e;return(t>0?Tl:xl)(t)}});var Tr=f((zp,as)=>{"use strict";var Sl=ss();as.exports=function(r){var e=+r;return e!==e||e===0?0:Sl(e)}});var ls=f((Wp,os)=>{"use strict";var wl=Tr(),Ll=Math.min;os.exports=function(r){var e=wl(r);return e>0?Ll(e,9007199254740991):0}});var ps=f((Qp,cs)=>{"use strict";var Ml=ls();cs.exports=function(r){return Ml(r.length)}});var us=f((Kp,hs)=>{"use strict";hs.exports=function(){}});var ds=f(()=>{"use strict";var _l=is(),Al=mr(),Rl=ps(),kl=Tr(),Pl=us();_l({target:"Array",proto:!0},{at:function(e){var t=Al(this),i=Rl(t),n=kl(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:t[s]}});Pl("at")});var ms=f((Xp,fs)=>{"use strict";var Vl=sr();fs.exports=Vl});var vs=f((Jp,ys)=>{"use strict";ds();var Ol=ms();ys.exports=Ol("Array","at")});var bs=f((eh,gs)=>{"use strict";var jl=vs();gs.exports=jl});var Sr=f((th,Cs)=>{"use strict";var Nl=bs();Cs.exports=Nl});var lc={};ba(lc,{CustomError:()=>F,EVENT_NAMES:()=>I,Interactives:()=>Ye,ManifestController:()=>he,SDKInfo:()=>oc,chapterIdsToVKVideoIds:()=>At,compareVersions:()=>Z,getChapterIdByVkVideoId:()=>oa,getVKVideoIdByMedia:()=>$r,getVideoRawIdByMedia:()=>sa,graphEventTypes:()=>Se,hasEndTemplate:()=>ze,interactivesEventTypes:()=>_,isLastChapter:()=>W,isOneTextCtrlContainer:()=>pe,isSupportedManifest:()=>De,isVKVariantItem:()=>aa,utils:()=>ha,vkVideoIdsToChapterIds:()=>Br});module.exports=Ca(lc);var ti="1.0.24";function Bt(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 H="interactive",Ea="interactive-controls-container",et=()=>document.querySelector(`.${Ea}`),ri=.4,q={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},ii=(i=>(i.top="flex-start",i.bottom="flex-end",i.center="center",i))(ii||{}),ni=(i=>(i.start="flex-start",i.end="flex-end",i.center="center",i))(ni||{}),si=(i=>(i.start="left",i.end="right",i.center="center",i))(si||{}),tt=({target:r,props:e})=>{var t,i,n,s,l,o;r.style.alignItems=(i=((t=e.text)==null?void 0:t.gravityVertical)&&ii[e.text.gravityVertical])!=null?i:"center",r.style.justifyContent=(s=((n=e.text)==null?void 0:n.gravityHorizontal)&&ni[e.text.gravityHorizontal])!=null?s:"center",r.style.textAlign=(o=((l=e.text)==null?void 0:l.alignment)&&si[e.text.alignment])!=null?o:"left"},rt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,o,a,c;r.style.color=(s=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?s:t.textColor,r.style.fontSize=`calc(${i.height} * ${(o=(l=e==null?void 0:e.text)==null?void 0:l.size)!=null?o:t.textSize})`,r.textContent=(c=(a=e==null?void 0:e.text)==null?void 0:a.value)!=null?c:t.textContent},it=({target:r,props:e,fallback:t})=>{var i,n,s,l;r.style.backgroundColor=Bt((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:t.backgroundColor,(l=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?l:t.backgroundAlpha)},nt=({target:r,props:e,fallback:t,dependsOn:i})=>{var n,s,l,o,a,c,m,y,d,E,x;r.style.border=`calc(${i.height} * ${(l=(s=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:s.width)!=null?l:t.borderWidth}) solid ${Bt((c=(a=(o=e==null?void 0:e.shape)==null?void 0:o.border)==null?void 0:a.color)!=null?c:t.borderColor,(d=(y=(m=e==null?void 0:e.shape)==null?void 0:m.border)==null?void 0:y.alpha)!=null?d:t.borderAlpha)}`,r.style.borderRadius=`calc(${i.height} * ${(x=(E=e==null?void 0:e.shape)==null?void 0:E.roundCorners)!=null?x:t.roundCorners})`},ge=({target:r,layoutParams:e,fallback:t})=>{var n;let i=(n=e.angle)!=null?n:t.angle;i=i&&i*-1,r.style.transform=`rotate(${i}rad)`};var Y=class{constructor(e){this.control=e;this.container=null;this.controlElement=null;this.clickListener=null}createContainerElement(e){var n;let t=document.createElement("div");t.classList.add(`${H}-control-container-${this.control.id}`),e(t,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:q.innerSizesDependOn)==="self"?{height:t.style.height,width:t.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};this.container={element:t,dimensions:i}}createClickListener(e){return t=>{t.stopPropagation(),e()}}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{var n;switch(t.type.trim().toLowerCase()){case"onclick":this.clickListener=this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),(n=this.container)==null||n.element.addEventListener("click",this.clickListener);break;default:break}})}removeListeners(){var e,t;(e=this.container)!=null&&e.element&&this.clickListener&&((t=this.container)==null||t.element.removeEventListener("click",this.clickListener))}};var qt="int",se=(i=>(i.AREA=`${qt}_area`,i.TEXT=`${qt}_text`,i.BUTTON=`${qt}_bttn`,i))(se||{});var st=r=>{if(r.type.trim().toLowerCase()==="area")return new Dt(r)},Dt=class extends Y{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${H}-${this.control.id}`),i.setAttribute("data-testid",se.AREA),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",it({target:i,props:this.control.props,fallback:C(u({},q),{backgroundColor:"transparent"})}),nt({target:i,props:this.control.props,fallback:C(u({},q),{borderAlpha:0}),dependsOn:this.container.dimensions}),ge({target:i,layoutParams:this.control.layoutParams,fallback:q}),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var at=()=>{let r=document.createElement("span");return r.style.display="inline-block",r.style.whiteSpace="pre",r.style.overflow="hidden",r.style.textOverflow="ellipsis",r.style.maxWidth="100%",r.style.maxHeight="100%",r};var ot=r=>{if(r.type.trim().toLowerCase()==="button")return new Ht(r)},Ht=class extends Y{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("button");i.type="button",i.classList.add(`${H}-${this.control.id}`),i.setAttribute("data-testid",se.BUTTON),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.cursor="pointer",i.style.fontFamily="inherit",ge({target:i,layoutParams:this.control.layoutParams,fallback:q}),it({target:i,props:this.control.props,fallback:q}),nt({target:i,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),tt({target:i,props:this.control.props});let n=at();rt({target:n,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){this.controlElement&&(this.controlElement.style.cursor="default")}enable(){this.controlElement&&(this.controlElement.style.cursor="pointer")}getElement(){return this.controlElement}};var ai=r=>{if(r.type.trim().toLowerCase()==="text")return new Ut(r)},Ut=class extends Y{constructor(e){super(e)}createView({parentElement:e,layoutCallback:t}){if(super.createContainerElement(t),!this.container)return;let i=document.createElement("div");i.classList.add(`${H}-${this.control.id}`),i.setAttribute("data-testid",se.TEXT),i.style.display="flex",i.style.width="100%",i.style.height="100%",i.style.fontFamily="inherit",ge({target:i,layoutParams:this.control.layoutParams,fallback:q}),tt({target:i,props:this.control.props});let n=at();rt({target:n,props:this.control.props,fallback:q,dependsOn:this.container.dimensions}),i.append(n),this.container.element.append(i),e.append(this.container.element),this.controlElement=i}disable(){}enable(){}getElement(){return this.controlElement}};var Gt=class{constructor(e){this.layout=e}},lt=class extends Gt{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var te,ct,oi,be=class{constructor(e){B(this,te);this.container=e,this.factories=new Map,Re(this,te,ct).call(this)}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),Re(this,te,ct).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),Re(this,te,ct).call(this)}};te=new WeakSet,ct=function(){this.controls=Re(this,te,oi).call(this)},oi=function(){var e;return(e=this.container.controls)==null?void 0:e.reduce((t,i)=>{let n=i.type.trim().toLowerCase(),s=this.factories.get(n);return s?[...t,s(i)]:[...t]},[])};var pt=(r,e)=>{if(r.type.trim().toLowerCase()==="choice")return new zt(r,e)},zt=class extends be{constructor(e,t){super(e),this.rootElement=t!=null?t:et(),this.layout=new lt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",ot),this.addControlFactory("text",ai),this.addControlFactory("area",st)}createView(e){let t=document.createElement("div");return t.classList.add(`${H}-${this.container.id}`),this.layout.setContainerLayout(t),this.controls.forEach(i=>{i.createView({parentElement:t,layoutCallback:this.layout.setControlLayout}),i.setEvents(e)}),this.rootElement.append(t),this.isRemoved=!1,t}hide(){let e=this.getElement();e&&(e.style.visibility="hidden")}show(){let e=this.getElement();e&&(e.style.visibility="visible")}enable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.enable()),e.style.opacity=1,this.isDisabled=!1)}disable(){let e=this.getElement();e&&(this.controls.forEach(t=>t.disable()),e.style.opacity=ri,this.isDisabled=!0)}removeView(){var e;this.isRemoved||(this.controls.forEach(t=>t.removeListeners()),(e=this.getElement())==null||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${H}-${this.container.id}`)}};var pa=Ft(Sr(),1),w=require("@vkontakte/videoplayer-shared"),Me=require("@vkontakte/videoplayer-statistics");var Ss=require("@vkontakte/videoplayer-shared");function Ne(r,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>r(...i),e)}}var oe=(r,e)=>Object.prototype.toString.call(r)===`[object ${e}]`,Fe=r=>oe(r,"Object"),yt=r=>oe(r,"String"),vt=r=>oe(r,"Array"),gt=r=>oe(r,"Number"),Es=r=>oe(r,"Function");var wr=r=>gt(r)&&!isNaN(r);var le=r=>Fe(r)&&Object.keys(r).length===0,Lr=r=>vt(r)&&!r.length;var $e=(r,e)=>yt(r)&&(e?r.trim():r).length;var Is="video_interactive",xs="videoint";var Ts=250,Be=class{constructor(e){this.handleZoomChange=Ne(e=>{this.lastZoomInfo=e},Ts);this.onResize=e=>{var i;if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&((i=this.ngEditor)==null||i.zoomTo(t)),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}};this.handleChapterChange=e=>{var t,i,n;if(this.manifest){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(t=this.onError)==null||t.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(e.id),(i=this.ngEditor)==null||i.selectChapter(e.id),(n=this.ngEditor)==null||n.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}};this.handleManifestChange=(e,t=[])=>{var i;if(this.isReady=!1,!gt(e.graph.edit.chapters[0].x)){(i=this.onError)==null||i.call(this,"Can't show graph"),console.error("Can't show graph");return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id):this.ngEditor.setVisitedChapters(Array.from(t)),this.isReady=!0)};this.init(e)}init({root:e,onOpenPreviewClick:t,onError:i,lang:n,visitedChapters:s=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=t,this.onError=i,this.lang=n!=null?n:"ru",this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Fl(e),this.resizeObserver=new ResizeObserver(Ne(this.onResize,Ts)),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 L(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 L(this,null,function*(){if(!this.manifest)return;let e;try{e=yield(0,Ss.loadVKLangPack)(this.lang,Is,xs)}catch(i){console.log("Unable to load graph language pack")}let{GraphEditor:t}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new t(this.graphWrapperElement,{mode:"read",lang:this.lang==="ru"?"ru":"en",translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.ngEditor.on("control",s=>{var l=s,{name:i}=l,n=N(l,["name"]);var o;i==="openPreview"&&"chapterId"in n&&((o=this.onOpenPreviewClick)==null||o.call(this,n.chapterId))}),this.ngEditor.on("zoom",this.handleZoomChange),this.isReady=!0})}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.manifest=null,this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)==null||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Fl(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 qe=class{constructor(){this._containers=[];this._player=null;this.setPlayer=e=>{this._player=e};this.setContainers=e=>{this._containers=e};this.deleteContainer=e=>{this._containers=this._containers.filter(t=>t.id!==e)};this.getNextInteractiveTime=(e=3e3)=>{if(!this._containers.length||this._player===null)return null;let t=-1,i=!1,n=Math.round(this._player.info.position$.getValue()*1e3);for(let s of this._containers){let l=s.startTime-e;if(l<=n&&(s.endTime&&n<=s.endTime||s.endTime===null)){i=!0;break}n<l&&(t=t===-1?l:Math.min(t,l))}return!i&&t!==-1?t:null}}};var Z=(r="",e="")=>{let t=r.split("."),i=e.split("."),n=0;for(let s=0;s<Math.max(t.length,i.length)&&!n;s++)t[s]>i[s]?n=1:t[s]<i[s]?n=-1:n=0;return n};var Ls=require("uuid");var $l="3.1",ws={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},Bl={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ms=r=>{let e=[];for(let l of r.chapters){let o,a=[];for(let t of l.branches){let i=t,{isDefault:y}=i,d=N(i,["isDefault"]);y&&(o=d.id),a.push(d)}let c=[],m=[];for(let n of l.containers){let s=n,{fallbackStrategy:y}=s,d=N(s,["fallbackStrategy"]);let E=!!d.endTime,x=[Bl];switch(y){case"await":E?x=[]:c=[];break;case"default":{let M={type:"onSuspense",action:{type:ws.default,args:{branchId:o,shouldOpenNow:!E,isDetachContainer:!0}}};E?x=[M]:c=[M];break}case"random":case"weightlessRandom":case"max":case"min":{let M={type:"onSuspense",action:{type:ws[y],args:{}}};E?x=[M]:c=[M];break}}for(let M of d.controls)m.push(C(u({},d),{controls:[u({},M)],id:(0,Ls.v4)(),events:x}))}e.push(C(u({},l),{containers:m,events:c,branches:a}))}return r.metadata.version=$l,r.metadata.updated=new Date().toISOString(),C(u({},r),{chapters:e})};var ql="3.2",_s=r=>{if(!r.media){let e=r.metadata,{media:t}=e,i=N(e,["media"]);return C(u({},r),{metadata:C(u({},i),{version:ql}),media:t})}return r};var Dl="3.3",Hl=(r=[])=>({edit:{chapters:r},view:{}}),As={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Rs=r=>{var n;let e=[],t=[];for(let s of r.chapters){let i=s,{id:l,x:o,y:a}=i,c=N(i,["id","x","y"]),m=c.containers.map(y=>{var d;return C(u({},y),{controls:y.controls.map(b=>{var p=b,{subtype:E,type:x}=p,M=N(p,["subtype","type"]);return C(u({},M),{type:E!=null?E:x})}),events:(d=y.events)!=null&&d.length?y.events:[As]})});e.push(C(u({id:l},c),{containers:m,events:(n=c.events)!=null&&n.length?c.events:[As]})),t.push({id:l,x:o,y:a})}return C(u({},r),{chapters:e,graph:Hl(t),metadata:C(u({},r.metadata),{version:Dl})})};var Ul=[{version:"3.0",migrate:Ms},{version:"3.1",migrate:_s},{version:"3.2",migrate:Rs}],Mr=r=>Ul.reduce((e,t)=>Z(e.metadata.version,t.version)?e:t.migrate(e),r);var ks={Button:"Button",Area:"Area",Text:"Text"};var R={openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"};var Ps={metadata:"Object",chapters:"Array"},Gl="3.0.0",zl="3.3.0",De=r=>{let e=Z(r,Gl);return e===-1?!1:e===0?!0:Z(r,zl)!==1},Vs=r=>{if(!Fe(r))return!1;for(let e in Ps)if(!r[e]||!oe(r[e],Ps[e]))return!1;return De(r.metadata.version)},bt=r=>r.type===ks.Text;var F=class{constructor(e,t,...i){this.severity=e;this.category=t;this.data=i}toString(){return`Interactive SDK error ${JSON.stringify(this,null," ")}`}};var Ct=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 Et=class{constructor(e){this.fns=[];this.addFn=(e,t=!1)=>{Es(e)&&(this.fns.push(e),t&&this.updateFn())};this.removeFn=(e,t=!1)=>{this.fns=this.fns.filter(i=>i!==e),t&&this.updateFn()};this.updateFn=()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}};this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))};this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()};this.cancelAnimation=()=>{this.raf&&(cancelAnimationFrame(this.raf),this.raf=void 0)};e&&(this.fn=e,this.addFn(e))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var Bs=require("@vkontakte/videoplayer-shared");var It=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 L(this,null,function*(){return Wl(...this.loaders[e])(t)})}};function Wl(...r){return function(t){return L(this,null,function*(){let i=[...r];for(;i.length>0;)t=yield i.shift()(t);return t})}}function He(r,e,t){return r?C(u({},r),{[e]:r[e]?[t,...r[e]]:[t]}):{[e]:[t]}}function xt(n){var s=n,{actions:r,errors:e,chapterId:t}=s,i=N(s,["actions","errors","chapterId"]);if(t){let l=r.getManifest(),o=r.getChapter(l.chapters,t);if(o){let a=r.getMedia(l.media,o.videoId),c=r.getGraph(l.graph,o.id);return a?C(u({},i),{actions:r,errors:e,result:{chapter:o,media:a,graph:c}}):C(u({},i),{errors:He(e,xt.name,"Could not find media"),actions:r})}}return C(u({},i),{errors:He(e,xt.name,"Could not find chapter"),actions:r})}var Tt=class{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,i){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:i})}removeEventListener(e,t){if(!(e in this.listeners))return;let i=this.listeners[e];for(let n=0,s=i.length;n<s;n++)if(i[n].callback===t){i.splice(n,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let i=this.listeners[e.type].slice();for(let n=0,s=i.length;n<s;n++){let l=i[n];try{l.callback.call(this,e)}catch(o){Promise.resolve().then(()=>{throw o})}l.options&&l.options.once&&this.removeEventListener(e.type,l.callback)}return!e.defaultPrevented}},Te=class extends Tt{constructor(){super(),this.listeners||Tt.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)}},Ue=class{constructor(){Object.defineProperty(this,"signal",{value:new Te,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&&(Ue.prototype[Symbol.toStringTag]="AbortController",Te.prototype[Symbol.toStringTag]="AbortSignal");function St(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 _r(r){typeof r=="function"&&(r={fetch:r});let{fetch:e,Request:t=e.Request,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n=!1}=r;if(!St({fetch:e,Request:t,AbortController:i,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:n}))return{fetch:e,Request:s};let s=t;(s&&!s.prototype.hasOwnProperty("signal")||n)&&(s=function(c,m){let y;m&&m.signal&&(y=m.signal,delete m.signal);let d=new t(c,m);return y&&Object.defineProperty(d,"signal",{writable:!1,enumerable:!1,configurable:!0,value:y}),d},s.prototype=t.prototype);let l=e;return{fetch:(a,c)=>{let m=s&&s.prototype.isPrototypeOf(a)?a.signal:c?c.signal:void 0;if(m){let y;try{y=new DOMException("Aborted","AbortError")}catch(E){y=new Error("Aborted"),y.name="AbortError"}if(m.aborted)return Promise.reject(y);let d=new Promise((E,x)=>{m.addEventListener("abort",()=>x(y),{once:!0})});return c&&c.signal&&delete c.signal,Promise.race([d,l(a,c)])}return l(a,c)},Request:s}}var Ge=St({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Os=Ge?_r({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,Ar=Ge?Os.fetch:window.fetch,tu=Ge?Os.Request:window.Request,ru=Ge?Ue:window.AbortController,iu=Ge?Te:window.AbortSignal;var Ql=r=>L(void 0,null,function*(){try{let e={},t;if(yt(r)){t=new URL(r).href;let n=yield Ar(t);if(!n.ok)return{};e=yield n.json()}else if(Fe(r))e=r;else return{};if(!Vs(e))return{};let i=e.metadata.media;if(yt(i)&&!e.media)try{let n;t?n=new URL(i,t).href:(n=new URL(i).href,t=n);let s=yield Ar(n);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(n){return Zl(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}});function js(r){return L(this,null,function*(){let{manifest:e,manifestURL:t}=yield Ql(r),i=Mr(e);return i.media=Kl(i.media,t),delete i.metadata.media,i})}function wt(r,e){if(e)return r.find(t=>t.id===e)}function Rr(r,e){var t,i;return(t=r.edit)!=null&&t.chapters?r.edit.chapters.find(n=>n.id===e):(i=r.view)!=null&&i.chapters?r.view.chapters.find(n=>n.id===e):void 0}function kr(r,e){return r.videos.find(t=>t.id===e)}function Kl(r,e){return C(u({},r),{videos:r.videos.map(t=>C(u({},t),{variants:t.variants.map(i=>{let n="url"in i?i.url:"",s=Yl(n,e);return C(u({},i),{url:s||n})})}))})}function Yl(r="",e){try{return new URL(r,e).href}catch(t){return""}}function Zl(r){return Z(r,"3.2.0")>=0}var Lt=r=>vt(r)&&!Lr(r),W=r=>r.order==="end",ze=r=>vt(r.containers)&&!Lr(r.containers)&&W(r),Ns=(r,e)=>{var i;let t=r*1e3;return Lt(e.controls)&&t<((i=e.startTime)!=null?i:0)},Pr=(r,e)=>{var i,n;let t=r*1e3;return Lt(e.controls)&&t>=((i=e.startTime)!=null?i:0)&&t<=((n=e.endTime)!=null?n:1/0)};var ce=(r=[])=>r.some(e=>e.action.type==="expect"),Vr=(r=[])=>r.find(e=>e.action.type==="expect"),Xl=r=>(r==null?void 0:r.length)===1,pe=r=>Xl(r)&&bt(r[0]);function Fs(r,...e){return t=>typeof e[0]=="object"&&typeof t=="object"?r(u(u({},e[0]),t)):r(...e,...t)}var $s=(r,e)=>ce(r.events)?!1:e.some(({container:t})=>t.container.id!==r.id&&ce(t.container.events)&&t.container.endTime===r.endTime&&!t.isRemoved);var he=class extends It{constructor(t,i){super(t);this.manifest=null;this.chapter=null;this.media=null;this.graph=null;this.prevChapter$=new Bs.ValueSubject(null);this.onError=i,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(t){return L(this,null,function*(){var n;this.release();let i=yield this.exec("manifestLoaders",{actions:{addErrorMessage:He},result:null,errors:null,source:t});return i.errors&&this.errorHandler(i.errors),this.manifest=yield js((n=i.result)!=null?n:t),this})}setInitial(){return L(this,null,function*(){return this.setNext()})}setNext(){return L(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:Rr,getChapter:wt,getMedia:kr,getByBranches:this.getByBranches.bind(this),addErrorMessage:He},result:null,errors:null,chapterId:t}));return n.errors&&this.errorHandler(n.errors),this.chapter=n.result.chapter,this.media=n.result.media,this.graph=n.result.graph,this})}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){var i;return this.getByChapterId((i=this.manifest)==null?void 0:i.metadata.initChapterId)||null}getByChapterId(t=(i=>(i=this.manifest)==null?void 0:i.metadata.initChapterId)()){if(!t||!this.manifest)return null;let n=wt(this.manifest.chapters,t);if(n){let s=kr(this.manifest.media,n.videoId),l=Rr(this.manifest.graph,n.id);if(s)return{chapter:n,media:s,graph:l}}return null}getBranches(t=(i=>(i=this.chapter)==null?void 0:i.id)()){var n,s,l;if(t===((n=this.chapter)==null?void 0:n.id))return this.getByBranches((s=this.chapter)==null?void 0:s.branches);{let o=wt(((l=this.manifest)==null?void 0:l.chapters)||[],t);return this.getByBranches(o==null?void 0:o.branches)}}getByBranches(t=[]){return t.reduce((i,n)=>{let s=this.getByChapterId(n.chapterId);return s&&i.push(s),i},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){var t,i;return((t=this.chapter)==null?void 0:t.id)===((i=this.manifest)==null?void 0:i.metadata.initChapterId)}isEndChapter(){return this.chapter?W(this.chapter):!1}};var Ds=require("@vkontakte/videoplayer-core"),ne=require("@vkontakte/videoplayer-shared");var qs=r=>{let e=r.variants.find(t=>{var i;return((i=t.payload)==null?void 0:i.type)==="vk"});if(e&&"payload"in e){let[t,i]=e.payload.id.split("_");return[t,i]}return[]};function Or(){let r=new Map;function e(a){var c=a,{listId:s=Math.random().toString(),itemId:l=Math.random().toString()}=c,o=N(c,["listId","itemId"]);let m=r.get(s),y=u({},o);return m?m[l]=y:r.set(s,{[l]:y}),u({listId:s,itemId:l},o)}function t(s){var l,o;s.player.destroy(),s.container.remove(),s.subscription.unsubscribe(),(l=s.statistics)==null||l.oneStat.destroy(),(o=s.statistics)==null||o.statSubscription.unsubscribe()}function i(s,l){let o=r.get(s);if(!o)throw Error("Can't remove. Not find.");if(l){let a=o[l];a&&t(a),delete o[l],Object.keys(o).length||r.delete(s)}else{for(let a of Object.values(o))t(a);r.delete(s)}}function n(){for(let s of r)i(s[0])}return{createPlayer:e,removePlayer:i,map:r,removeAll:n}}function jr(r,e=[]){var s,l,o;let t={},i,n=!e.length;for(let a of r.variants)if(!i&&"cover"in a&&(i=a.cover),"url"in a)switch(a.type.toLowerCase()){case"mp4":(n||e.includes("mp4"))&&(t.MPEG=C(u({},t.MPEG),{[(s=a.standard)!=null?s:"Invariant quality"]:a.url}));break;case"mpeg":(n||e.includes("mpeg"))&&(t.MPEG=C(u({},t.MPEG),{[(l=a.standard)!=null?l:"Invariant quality"]:a.url}));break;case"hls":(n||e.includes("hls"))&&(t=C(u({},t),{HLS:{type:"url",url:a.url}}));break;case"dash":(n||e.includes("dash"))&&(t=C(u({},t),{DASH_SEP:{compatibilityMode:!0,type:"url",url:a.url}}));break;default:break}return{sources:t,thumbUrl:i,title:(o=r.title)!=null?o:""}}var We=(r,e)=>{let t=r.info.currentQuality$.getValue(),i=r.info.availableQualities$.getValue();t!==e&&i.includes(e)&&(r.setQuality(e),r.setAutoQuality(!1))};var Jl=2;function Nr(r){let e=Or(),t=new ne.Subscription,i={},n=null,s=!1,l,o=new ne.ValueSubject(null);r&&a(r);function a(b){n=b}function c(b,p,h){var v;if(!n)throw Error("need to set interactive controller");if(!n.options)return;let T=((v=e.map.get(b))!=null?v:{})[p];if(T){i=u({chapterId:h,listId:b,itemId:p},T);let k=i.player;i.subscription.add(k.info.currentQuality$.subscribe(A=>{let D=k.info.position$.getValue(),P=k.info.isAutoQualityEnabled$.getValue();if(!(!A||!D||P))for(let O of e.map)Object.values(O[1]).forEach(({player:V})=>{We(V,A)})})).add(k.events.started$.subscribe(()=>{m(p)})),T.container.remove(),n.setPlayer(T.player),s||(n.init(),s=!0),o.next({player:i.player,config:i.config,statistics:i.statistics});return}throw Error("Can't set. Not find.")}function m(b){return L(this,null,function*(){if(!n)throw Error("need to set interactive controller");if(le(i)||b!==i.itemId)return;let p=n.getChapterBranches(),h=new Set;for(let g of p)h.has(g.media.id)||(yield d({media:g.media,chapterId:g.chapter.id,setAsActive:!1,title:g.chapter.label}),h.add(g.media.id))})}function y(h){return L(this,arguments,function*({chapter:{id:b},manifestVideo:p}){if(le(i)||!n)return;let g=i.player.info.muted$.getValue(),T=i.player.info.currentQuality$.getValue(),v=i.player.info.isAutoQualityEnabled$.getValue(),k=i.player.info.volume$.getValue(),A=i.player.info.currentPlaybackRate$.getValue(),D=!v,P=!1;for(let O of e.map)if(O[0]===p.id&&!n.state.isReplay$.getValue()){let V=Object.keys(O[1]);for(let $ of V)$===i.itemId?(V.length<Jl||(P=!0),e.removePlayer(O[0],$)):(P=!0,c(O[0],$,b),D?We(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(k),i.player.setMuted(g),i.player.setPlaybackRate(A))}else e.removePlayer(O[0]);P||(yield d({media:p,chapterId:b,setAsActive:!0,playbackRate:A}),D?We(i.player,T):i.player.setAutoQuality(!0),i.player.setVolume(k),i.player.setMuted(g))})}function d(D){return L(this,arguments,function*({media:b,chapterId:p,prefetch:h=!0,setAsActive:g=!0,autoplay:T=!1,preferredExt:v,title:k,playbackRate:A}){var Ur,Gr,zr,Wr,Qr;let P=Math.random().toString(),O=document.createElement("div");l.append(O);let V;if((Ur=n==null?void 0:n.options)!=null&&Ur.vkVideoLoader){let Xe=qs(b);Xe.length&&(V=yield n.options.vkVideoLoader(...Xe))}let $=((Gr=n==null?void 0:n.options)==null?void 0:Gr.coreConfig)||void 0,_e=C(u({},$),{configName:[...(zr=$==null?void 0:$.configName)!=null?zr:[],"interactive"]}),Ze=C(u({container:O},((Wr=V==null?void 0:V.videos)==null?void 0:Wr[0])||{sources:jr(b,v).sources}),{title:k,failoverHosts:(V==null?void 0:V.failoverHosts)||[]}),ye=new Ds.Player(_e,ne.Tracer.createRootTracer());ye.initVideo(Ze);let Dr=null;if(V!=null&&V.videos&&(n!=null&&n.options.createOneStat)){let Xe=V.videos[0],jt=n.options.createOneStat(Xe),Kr=new ne.Subscription;jt&&(Kr.add(jt.attachTo(ye)),Dr={oneStat:jt,statSubscription:Kr})}let Hr=new ne.Subscription,ua=(Qr=i==null?void 0:i.player)==null?void 0:Qr.info.isAutoQualityEnabled$.getValue();Hr.add(ye.events.canplay$.subscribe(function(){ua||We(ye,i.player.info.currentQuality$.getValue()),A&&ye.setPlaybackRate(A)}));let ve=e.createPlayer({listId:b.id,itemId:P,player:ye,container:O,sources:jr(b,v).sources,config:Ze,subscription:Hr,statistics:Dr});return g&&c(b.id,ve.itemId,p),T&&ve.player.play(),h&&!T&&ve.player.prepare(),{player:ve.player,config:ve.config,statistics:ve.statistics}})}function E(){x(),n=null,l.remove()}function x(){t.unsubscribe(),e.removeAll(),i={},s=!1}function M(){return L(this,null,function*(){if(!n)throw Error("need to set interactive controller");x(),l=document.createElement("div");let{media:b,chapter:p}=n.getCurrentChapter();b&&p?(t.add(n.events.chapterChanged$.subscribe(y)),yield d({media:b,chapterId:p.id,title:p.label})):console.error("not found")})}return C(u({},e),{init:M,setInteractiveController:a,createPlayer:d,removeAll:E,getActivePlayer:function(){return i},activePlayerChanged:o})}var I={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Se={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},_={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};var Hs=require("@vkontakte/videoplayer-shared");var Mt=class{constructor({player:e,container:t,branches:i,selectBranches:n,interactiveEvents:s,globalEvents:l,globalEventEmitter:o,ignoreContainerEvent:a,permanentTextControls:c,disabledControls$:m,onRemove:y}){this.hide=()=>{setTimeout(()=>{var e,t;this.gameState!==4&&(ce(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect||(this.gameState!==2&&((t=(e=this.container).hide)==null||t.call(e)),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})))})};this.show=()=>{var e,t,i,n;if(this.gameState===2&&!this.isSelectedControlEvent)if(this.container.getElement())(n=(i=this.container).show)==null||n.call(i),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!0,isFirst:!1});else{let l=Fs(this.selectBranches.onControlEvent,{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})},onEvent:(o,a)=>{this.isSelectedControlEvent=!0,o!==!1&&(this.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})),(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),a(),this.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1}))},isEOV:()=>this.gameState===4});this.container.createView(l),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((t=(e=this.container).disable)==null||t.call(e))}};this.onEndOfVideo=()=>{this.gameState=4,this.selectContainerEvent(!0)};this.whilePlaying=()=>{var c;let e=this.player.experimental.element$.getValue(),i=e instanceof HTMLVideoElement?e.readyState:void 0,n=[6,5];if(!i||n.includes(this.gameState)&&!this.isPermanentText)return;let s=this.player.getExactTime();if(Ns(s,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Pr(s,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let m=this.gameState;this.gameState=3,m===2&&this.onEndTime()}else this.isPermanentText||this.removeView();let l=Pr(s,this.container.container),o=this.container.container.startTime?[this.container.container.startTime,(c=this.container.container.endTime)!=null?c:1/0]:[],a={subjectId:this.container.container.id,subjectName:"container",range:o,currentTime:s,isInteractiveTime:l};this.globalEventEmitter.emit(I.eachTick,a),this.globalEvents.eachTick$.next(a)};this.container=t,this.branches=i,this.selectBranches=n,this.subscription=new Hs.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=a,this.isPermanentText=c&&pe(t.container.controls),this.disabledControls$=m,this.onRemove=y,this.globalEventEmitter=o,this.gameState=0,this.globalEvents=l,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{var t,i,n,s;e?(i=(t=this.container).disable)==null||i.call(t):(s=(n=this.container).enable)==null||s.call(n)}))}selectContainerEvent(e=!1){var t;this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec((t=this.container.container.endTime)!=null?t:1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let e=ce(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)==null||t.call(e),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(I.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.containerRemoved,visibility:!1}),this.gameState=5,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var Us=(r=[])=>r.reduce((e,t,i)=>{var s,l,o;let n=((s=t==null?void 0:t.controls)!=null?s:[]).filter(a=>!bt(a));if(Lt(n)){let a=[(l=t.startTime)!=null?l:0,(o=t.endTime)!=null?o:1/0],c=t.id;if(!i)e.push({subjects:[c],range:a});else{let m=[],y=-1/0,d=1/0,E=[],x=[];for(let M=0;M<e.length;M++){let b=e[M];if(x.push(...b.subjects),b.range[0]<d&&(d=b.range[0]),b.range[1]>y&&(y=b.range[1]),a[0]>=b.range[0]&&a[1]<=b.range[1])return e[M].subjects.push(c),e;a[0]<b.range[0]&&a[1]>b.range[0]&&(m.push(M),E=E.concat(b.subjects)),a[0]>=b.range[0]&&a[0]<=b.range[1]&&(m.push(M),E=E.concat(b.subjects),a[0]=b.range[0]),a[1]>=b.range[0]&&a[1]<=b.range[1]&&(m.push(M),E=E.concat(b.subjects),a[1]=b.range[1])}if(x.push(c),a[0]<=d&&a[1]>=y)return[{subjects:x,range:a}];m.length&&m.reverse().forEach(M=>{e.splice(M,1)}),e.push({subjects:E.concat([c]),range:a})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]);function Gs(){let r={};function e(){for(let o in r)Object.prototype.hasOwnProperty.call(r,o)&&delete r[o]}function t(o){let a={};for(let c in r)+c<=o&&(a[c]=r[c]);return a}function i(o){let a={};for(let c in r)+c>=o&&(a[c]=r[c]);return a}function n({timestamp:o,priority:a,initiator:c}){var m;if(wr(o)){let y=(m=r[o])!=null?m:null;if(y&&a&&$e(a,!0)){let d={},E=y[a];if(E&&(d=u(u({},d),E)),d=le(d)?null:d,d&&$e(c,!0)){let x=d[c];return x!=null?x:null}return d}return y}return null}function s({timestamp:o,priority:a,initiator:c}){if(wr(o))if(r[o]){if(a&&$e(a,!0))if(r[o][a]){if(c&&$e(c,!0))if(r[o][a][c]){if(delete r[o][a][c],!le(r[o][a]))return!0}else return!1;if(delete r[o][a],!le(r[o]))return!0}else return!1;return delete r[o]}else return!1;return!1}function l(y){var d=y,{timestamp:o,priority:a,initiator:c}=d,m=N(d,["timestamp","priority","initiator"]);var E,x,M;(x=(E=r[o])==null?void 0:E[a])!=null&&x[c]?r[o][a][c].push(u({},m)):(M=r[o])!=null&&M[a]?r[o][a]=C(u({},r[o][a]),{[c]:[u({},m)]}):r[o]?r[o]=C(u({},r[o]),{[a]:{[c]:[u({},m)]}}):r[o]={[a]:{[c]:[u({},m)]}}}return{map:r,remove:s,add:l,removeAll:e,get:n,getLte:t,getGte:i}}var ec=[R.expect,R.setNextBranch],tc=1/0;function zs(r){let e=r,t,i=rc(),n=Gs(),s,l=()=>{d(),p()},o=h=>{n.add.call(void 0,h),x()},a=(h=[])=>{for(let g of h)if(g.action(),ec.includes(g.actionType))break},c=(h=1/0)=>{var k,A,D;let g=_t((k=n.get({timestamp:h,priority:"control"}))!=null?k:{}),T=_t((A=n.get({timestamp:h,priority:"container"}))!=null?A:{}),v=_t((D=n.get({timestamp:h,priority:"chapter"}))!=null?D:{});return[...g,...T,...v]},m=h=>{i.isReady(h)&&a(c(h))},y=()=>{var h;a([..._t((h=n.get({timestamp:1/0,priority:"chapter"}))!=null?h:{})])},d=()=>{t&&(s==null||s.unsubscribe(),t=void 0)},E=h=>{},x=()=>{t||(t=()=>setTimeout(()=>{m(1/0)}),s=e.events.ended$.subscribe(t))},M=h=>{d(),e=h},b=h=>{h.priority==="container"&&i.resetCalled(h.timestamp),n.remove(h)},p=()=>{i.release(),n.removeAll()};return{setPlayer:M,add:o,remove:b,exec:m,execEndOfVideo:y,listen:x,unlisten:d,release:l,containersEventsCallState:i,getPreparedToExecActions:c}}function rc(){let r=new Map;return{setCalled:({timestamp:l,id:o})=>{let a=r.get(l);a&&a[o]!==void 0&&(a[o]=!0)},setData:(l=[])=>{var o,a;for(let c of l){let m=(o=c.endTime)!=null?o:tc,y=(a=r.get(m))!=null?a:{};r.set(m,C(u({},y),{[c.id]:!1}))}},resetCalled:l=>{let o=r.get(l);if(o)for(let a in o)o[a]=!1},isReady:l=>{let o=r.get(l);return o?!Object.values(o).some(a=>!a):!0},release:()=>r.clear()}}function _t(r){return Object.values(r).flat().sort(e=>e.actionType===R.expect?-1:1)}var Ws={videoContentHeight:0,videoContentWidth:0},Qs=(r,e)=>{let{height:t,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&i))return Ws;let{clientHeight:n,clientWidth:s}=e.experimental.element$.getValue()||{};if(!(n&&s))return Ws;let l=t/i,o=n/s,a,c;return o>l?(c=s,a=s*l):o<l?(c=n/l,a=n):(c=s,a=n),{videoContentWidth:c,videoContentHeight:a}};var ic=250;function Ks(r){let e=()=>{},t=new ResizeObserver(o=>{s(o),e=s.bind(null,o)});function i(o){let{parentElement:a,player:c}=r();if(a&&c){let{videoContentWidth:m,videoContentHeight:y}=Qs(a,c);a.style.setProperty("--interactive-content-width",`${m}px`),a.style.setProperty("--interactive-content-height",`${y}px`),a.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),a.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function n(){let{parentElement:o}=r();o.removeAttribute("style")}let s=Ne(o=>{let{fns:a=[]}=r();i(o);for(let c of a)c()},ic);function l(){e=void 0,t.disconnect(),n()}return{resizeObserver:t,calc:()=>{e==null||e()},release:l}}var Qe=class{constructor(){this.map={}}push(e,t){e in this.map?this.map[e].push(t):this.map[e]=[t]}get(e){let t=this.map[e];return t?t.slice():null}getAll(){let e=[];for(let t in this.map)e.concat(this.map[t]);return e}remove(e,t){e in this.map&&(this.map[e]=this.map[e].filter(i=>i!==t),this.map[e].length===0&&delete this.map[e])}clear(){this.map={}}keys(){return Object.keys(this.map)}size(){return this.keys().length}};var nc=r=>Math.floor(Math.random()*r),Zs=r=>{var n;let e=r.length,t=1/0,i=null;for(;e--;){let s=r[e],l=(n=s.weight)!=null?n:1;l<t&&(t=l,i=s)}return i},Xs=r=>{var n;let e=r.length,t=-1/0,i=null;for(;e--;){let s=r[e],l=(n=s.weight)!=null?n:0;l>t&&(t=l,i=s)}return i};var Js=r=>{let e=r.length,t=nc(e);return r[t]},Ys=1,ea=r=>{var i,n;let e=0;for(let s=0;s<r.length;++s)e+=(i=r[s].weight)!=null?i:Ys;let t=Math.random()*e;e=0;for(let s=0;s<r.length-1;++s)if(e+=(n=r[s].weight)!=null?n:Ys,e>=t)return r[s];return r[r.length-1]};var ta={shouldOpenNow:!0,isDetachContainer:!0};var Fr=(r,e=!1)=>C(u({},r),{args:e?u(u({},r.args),ta):u(u({},ta),r.args)}),na=({globalEventEmitter:r,player:e,interactiveEvents:t,removeControllers:i})=>{let n={isExpect:!1},s=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:p,controlType:h,controlId:g,containerId:T,branches:v=[],onEvent:k,isEOV:A=()=>!1,isDisabled:D=()=>!1})=>{let P=Fr(p,A()),O={timestamp:1/0,priority:"control",initiator:g,actionType:P.type},V=D(),$=r.emit.bind(r,I.interactives,{subjectId:g,subjectType:h,subjectName:"control",type:V?_.actionChoiceCanceled:_.actionChoice,actionType:p.type,payload:u({containerId:T},P.args)});if(V){$();return}switch(P.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let _e=v.find(Ze=>Ze.id===P.args.branchId);if(!_e)return;k(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),$(),P.args.shouldOpenNow?x({subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{chapterId:_e.chapterId,autoSelect:!1}}):(t.add(C(u({},O),{action:x.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{chapterId:_e.chapterId,autoSelect:!1}})})),i==null||i());return}case R.continuePlayback.trim().toLowerCase():{k(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),$(),P.args.shouldOpenNow?E({subjectId:g,subjectName:"control",subjectType:h,action:p}):t.add(C(u({},O),{action:E.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:p})}));return}case R.openURI.trim().toLowerCase():{k(P.args.isDetachContainer,d.bind(null,{subjectId:g,subjectName:"control"})),$(),P.args.shouldOpenNow?b({subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{URI:p.args.uri}}):(t.add(C(u({},O),{action:b.bind(null,{subjectId:g,subjectName:"control",subjectType:h,action:P,payload:{URI:p.args.uri}})})),i==null||i());return}default:console.error("Unexpected control event"),r.emit(I.errors,new F(1,1,{message:"Unexpected control event"}));return}},o=({action:p,container:{id:h,endTime:g},branches:T=[],isEOV:v=!1,autoSelected:k=!1})=>{let A=Fr(p,v),D={timestamp:!A.args.shouldOpenNow||v?1/0:g!=null?g:1/0,priority:"container",initiator:h,actionType:A.type},P=r.emit.bind(r,I.interactives,{subjectId:h,subjectName:"container",type:_.actionChoice,actionType:A.type,payload:A.args});switch(A.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let O=T.find(V=>V.id===A.args.branchId);if(!O)return;P(),t.add(C(u({},D),{action:x.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{chapterId:O.chapterId,autoSelect:k}})})),i==null||i();return}case R.setMaxWeightBranch.trim().toLowerCase():return;case R.setMinWeightBranch.trim().toLowerCase():return;case R.setRandomBranch.trim().toLowerCase():return;case R.setWeightlessRandomBranch.trim().toLowerCase():return;case R.continuePlayback.trim().toLowerCase():{P(),t.add(C(u({},D),{action:E.bind(null,{subjectId:h,subjectName:"container",action:A})}));return}case R.openURI.trim().toLowerCase():{P(),t.add(C(u({},D),{action:b.bind(null,{subjectId:h,subjectName:"container",action:A,payload:{URI:p.args.uri}})})),i==null||i();return}default:console.error("Unexpected container event"),r.emit(I.errors,new F(1,1,{message:"Unexpected container event"}));return}};function a({container:p,branches:h,isEOV:g=!1}){var v,k;let T=Vr(p.events);if(T){let A=Fr(T.action,g);r.emit(I.interactives,{subjectId:p.id,subjectName:"container",type:_.actionChoice,actionType:A.type,payload:A.args}),t.add({timestamp:g?1/0:(v=p.endTime)!=null?v:1/0,priority:"container",initiator:p.id,actionType:R.expect,action:y.bind(null,{subjectId:p.id,subjectName:"container"})}),n.isExpect=!0}else for(let A of(k=p.events)!=null?k:[])o({action:A.action,container:p,branches:h,isEOV:g})}let c=({chapterId:p,action:h,branches:g=[]})=>{let T=r.emit.bind(r,I.interactives,{subjectId:p,subjectName:"chapter",type:_.actionChoice,actionType:h.type,payload:h.args});switch(h.type.trim().toLowerCase()){case R.setNextBranch.trim().toLowerCase():{let v=g.find(k=>k.id===h.args.branchId);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setWeightlessRandomBranch.trim().toLowerCase():{let v=Js(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setRandomBranch.trim().toLowerCase():{let v=ea(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setMaxWeightBranch.trim().toLowerCase():{let v=Xs(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.setMinWeightBranch.trim().toLowerCase():{let v=Zs(g);return v!=null&&v.chapterId?(T(),x.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case R.continuePlayback.trim().toLowerCase():return T(),E.bind(null,{subjectId:p,subjectName:"chapter",action:h});case R.openURI.trim().toLowerCase():return T(),b.bind(null,{subjectId:p,subjectName:"chapter",action:h,payload:{URI:h.args.uri}});default:console.error("Unexpected chapter event"),r.emit(I.errors,new F(1,1,{message:"Unexpected chapter event"}));return}};function m(p){var g;let h=Vr(p.events);if(h){if(W(p))return;r.emit(I.interactives,{subjectId:p.id,subjectName:"chapter",type:_.actionChoice,actionType:h.action.type,payload:h.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:R.expect,action:y.bind(null,{subjectId:p.id,subjectName:"chapter"})})}else(g=p.events)==null||g.forEach(T=>{let v=c({chapterId:p.id,action:T.action,branches:p.branches});v&&t.add({timestamp:1/0,priority:"chapter",initiator:p.id,actionType:T.action.type,action:v})})}let y=({subjectId:p,subjectName:h})=>{e.pause(),r.emit(I.interactives,{subjectId:p,subjectName:h,type:_.actionExecution,actionType:R.expect})},d=({subjectId:p,subjectName:h})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),r.emit(I.interactives,{subjectId:p,subjectName:h,type:_.actionExecution,actionType:"after-expect"})},E=({subjectId:p,subjectName:h,subjectType:g,action:T})=>{r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type})},x=({subjectId:p,subjectName:h,subjectType:g,action:T,payload:v})=>{v.behaviour="change-chapter",r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type,payload:v})},M=({subjectId:p,subjectName:h,subjectType:g,action:T,payload:v})=>{v.behaviour="change-manifest",r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type,payload:v})},b=({subjectId:p,subjectName:h,subjectType:g,action:T,payload:v})=>{if(!v.URI)return;let k=window.open(v.URI,"_blank","noopener,noreferrer");k&&(k.opener=null),r.emit(I.interactives,{subjectId:p,subjectName:h,subjectType:g,type:_.actionExecution,actionType:T.type})};return{onControlEvent:l,onContainerEvent:o,onChapterEvent:c,onExpectEvent:y,expectEventHandler:d,setManifestChapterEvents:m,setManifestContainerEvents:a,stopExpect:s,state:n}};var qr=Ft(Sr(),1),G=require("@vkontakte/videoplayer-shared");var At=(r,e)=>{let t={};return r.map(i=>{if(!t[i]){let n=e.chapters.find(l=>l.id===i);if(!n)return null;let s=e.media.videos.find(l=>n.videoId===l.id);if(!s)return null;t[i]=$r(s)}return t[i]}).filter(Boolean)},sa=r=>{for(let e of r.variants)if(aa(e)&&"payload"in e)return e.payload.id},aa=r=>r.type==="custom"&&"payload"in r&&r.payload.type==="vk",$r=r=>{let e=sa(r);if(!e)return null;let t=e.split("_").pop();return t?parseInt(t,10):null},oa=(r,e)=>{for(let t of r.media.videos)if(e===$r(t)){for(let i of r.chapters)if(i.videoId===t.id)return i.id;return}},Br=(r,e)=>r.reduce((t,i)=>{let n=oa(e,i);return n?[...t,n]:t},[]);var X,ue,de,U,Rt,J,ee,K,fe,we,Le,Ke=class{constructor({globalEventEmitter:e,videoId:t,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new G.ValueSubject([]),hasPrevChapter$:new G.ValueSubject(!1),prevChapter$:new G.ValueSubject(null),isInitialChapter$:new G.ValueSubject(!1),isGoBackLimited$:new G.ValueSubject(!1)};B(this,X,null);B(this,ue);B(this,de,!1);B(this,U,null);B(this,Rt,null);this.events={inited$:new G.Subject,destroyed$:new G.Subject,error$:new G.Subject};B(this,J,null);B(this,ee,null);B(this,K,null);B(this,fe,new G.Subscription);B(this,we,!1);B(this,Le,0);var l;j(this,J,t),j(this,K,e),j(this,ee,i),j(this,X,n),j(this,ue,s),this.state.history$&&S(this,fe)&&((l=S(this,fe))==null||l.add(this.state.history$.subscribe(o=>{var a,c;this.state.prevChapter$.next((0,qr.default)(o,-2)||null),this.state.hasPrevChapter$.next(o.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((c=(a=S(this,U))==null?void 0:a.metadata)==null?void 0:c.initChapterId)),this.state.isGoBackLimited$.next(S(this,Le)===S(this,ue).maxLength-1)})))}setManifest(e){return L(this,null,function*(){if(!S(this,ee)||!S(this,K))return;j(this,U,e),yield this.getProjectHistory();let t=this.getInitialChapterId();yield S(this,ee).setChapter({chapterId:t,pushToHistory:!1}),S(this,de)||(j(this,de,!0),this.events.inited$.next({initChapterId:t}))})}get inited(){return S(this,de)}updateHistory(e,t=!0){return L(this,null,function*(){var o;if(!S(this,U))return;S(this,we)?(j(this,we,!1),ei(this,Le)._++):j(this,Le,0);let i=S(this,U),n=e.length-S(this,ue).maxLength,s=n>0?e.slice(n):e,l=At(s,i);if(j(this,Rt,l),this.state.history$.next(s),!(!t||!S(this,X)||!S(this,J)))try{yield S(this,X).save(S(this,J),l)}catch(a){let c=new F(1,5,"Unable to save interactive history");this.events.error$.next(c),(o=S(this,K))==null||o.emit(I.errors,c)}})}goBack(){return L(this,null,function*(){var i;if(!this.state||!S(this,ee)){let n=new F(1,5,"Unable to save interactive history");return this.events.error$.next(n),(i=S(this,K))==null?void 0:i.emit(I.errors,n)}j(this,we,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),yield S(this,ee).setChapter({chapterId:t,playPrev:!0})})}getProjectHistory(){return L(this,null,function*(){var n;if(!S(this,U)||!S(this,J))return;let e=S(this,U),t=[this.getInitialVideoId()];if(S(this,X))try{let s=yield S(this,X).get(S(this,J));s.length&&(t=s)}catch(s){let l=new F(1,5,"Error while trying to fetch data");this.events.error$.next(l),(n=S(this,K))==null||n.emit(I.errors,l)}let i=Br(t,e);this.state.history$.next(i)})}getInitialChapterId(){var t;let e=this.state.history$.getValue();return(0,qr.default)(e,-1)||S(this,ue).initChapterId||((t=S(this,U))==null?void 0:t.metadata.initChapterId)}getInitialVideoId(){if(S(this,U)){let e=this.getInitialChapterId();return At([e],S(this,U)).pop()}return null}destroy(){var e,t;j(this,J,null),j(this,X,null),j(this,ee,null),(e=S(this,fe))==null||e.unsubscribe(),j(this,fe,null),j(this,de,!1),(t=S(this,K))==null||t.emit(I.historyDestroyed),this.events.destroyed$.next(),j(this,K,null)}};X=new WeakMap,ue=new WeakMap,de=new WeakMap,U=new WeakMap,Rt=new WeakMap,J=new WeakMap,ee=new WeakMap,K=new WeakMap,fe=new WeakMap,we=new WeakMap,Le=new WeakMap;var me=class me{constructor(e,t,i,n){this.target=e,this.type=t,this.listener=i,this.options=me._convertOptions(e,n),this.target.addEventListener(t,i,this.options)}unlisten(){var e;this.type&&this.listener&&this.options&&((e=this.target)==null||e.removeEventListener(this.type,this.listener,this.options)),this.target=null,this.type=null,this.listener=null,this.options=!1}static _convertOptions(e,t){if(t===void 0)return!1;if(typeof t=="boolean")return t;{let i=new Set(["passive","capture"]),n=Object.keys(t).filter(l=>!i.has(l));return n.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+n.join(",")),me._doesSupportObject(e)?t:t.capture||!1}}static _doesSupportObject(e){let t=me._supportsObject;if(t===void 0){t=!1;try{let i={},n={get:()=>(t=!0,!1)};Object.defineProperty(i,"passive",n),Object.defineProperty(i,"capture",n);let s=()=>{};e.addEventListener("test",s,i),e.removeEventListener("test",s,i)}catch(i){t=!1}me._supportsObject=t}return t||!1}};me._supportsObject=void 0;var kt=me;var Pt=class{constructor(){this.bindingMap=new Qe}release(){this.removeAll(),this.bindingMap=null}listen(e,t,i,n){if(!this.bindingMap)return;let s=new kt(e,t,i,n);this.bindingMap.push(t,s)}listenOnce(e,t,i,n){let s=l=>{this.unlisten(e,t,s),i(l)};this.listen(e,t,s,n)}unlisten(e,t,i){if(!this.bindingMap)return;let n=this.bindingMap.get(t)||[];for(let s of n)s.target===e&&(i===s.listener||!i)&&(s.unlisten(),this.bindingMap.remove(t,s))}removeAll(){if(!this.bindingMap)return;let e=this.bindingMap.getAll();for(let t of e)t.unlisten();this.bindingMap.clear()}};var Vt=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var n;let e=(n=this.rootElement.getContext("2d"))==null?void 0:n.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,i=t.length;for(let s=3;s<i;s+=40)if(t[s]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(e,t=!1){return L(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 L(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 Ot=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;
|