@vkontakte/videoplayer-interactive 1.0.7-beta.0 → 1.0.7-dev.6643328a.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +3 -3
- package/es2015.esm.js +4 -4
- 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 +3 -3
package/es2018.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.7-
|
|
3
|
-
* Thu, 15 Feb 2024
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.7-dev.6643328a.0
|
|
3
|
+
* Thu, 15 Feb 2024 18:13:27 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-7/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var bn=Object.create;var St=Object.defineProperty;var En=Object.getOwnPropertyDescriptor;var Cn=Object.getOwnPropertyNames;var wn=Object.getPrototypeOf,_n=Object.prototype.hasOwnProperty;var In=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Cn(e))!_n.call(t,r)&&r!==i&&St(t,r,{get:()=>e[r],enumerable:!(n=En(e,r))||n.enumerable});return t};var Sn=(t,e,i)=>(i=t!=null?bn(wn(t)):{},In(e||!t||!t.__esModule?St(i,"default",{value:t,enumerable:!0}):i,t));var k=require("@vkontakte/videoplayer-shared/es2018.cjs.js"),Tn=require("uuid"),$n=require("@vkontakte/videoplayer-core/es2018.cjs.js");const On="1.0.7-beta.0";function pi(t,e=1){let i="0",n="0",r="0";return t.length===4?(i="0x"+t[1]+t[1],n="0x"+t[2]+t[2],r="0x"+t[3]+t[3]):t.length===7&&(i="0x"+t[1]+t[2],n="0x"+t[3]+t[4],r="0x"+t[5]+t[6]),`rgba(${+i},${+n},${+r},${e})`}const G="SDK_NAME",Rn="SDK_NAME-controls-container",mi=()=>document.querySelector(`.${Rn}`),An=.4,q={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},Tt={top:"flex-start",bottom:"flex-end",center:"center"},$t={start:"flex-start",end:"flex-end",center:"center"},Ot={start:"left",end:"right",center:"center"},yi=({target:t,props:e})=>{var i,n,r,s,c,a;t.style.alignItems=(n=Tt[(i=e==null?void 0:e.text)===null||i===void 0?void 0:i.gravityVertical])!==null&&n!==void 0?n:Tt.center,t.style.justifyContent=(s=$t[(r=e==null?void 0:e.text)===null||r===void 0?void 0:r.gravityHorizontal])!==null&&s!==void 0?s:$t.center,t.style.textAlign=(a=Ot[(c=e==null?void 0:e.text)===null||c===void 0?void 0:c.alignment])!==null&&a!==void 0?a:Ot.start},gi=({target:t,props:e,fallback:i,dependsOn:n})=>{var r,s,c,a,l,h;t.style.color=(s=(r=e==null?void 0:e.text)===null||r===void 0?void 0:r.color)!==null&&s!==void 0?s:i.textColor,t.style.fontSize=`calc(${n.height} * ${(a=(c=e==null?void 0:e.text)===null||c===void 0?void 0:c.size)!==null&&a!==void 0?a:i.textSize})`,t.textContent=(h=(l=e==null?void 0:e.text)===null||l===void 0?void 0:l.value)!==null&&h!==void 0?h:i.textContent},bi=({target:t,props:e,fallback:i})=>{var n,r,s,c;t.style.backgroundColor=pi((r=(n=e==null?void 0:e.background)===null||n===void 0?void 0:n.color)!==null&&r!==void 0?r:i.backgroundColor,(c=(s=e==null?void 0:e.background)===null||s===void 0?void 0:s.alpha)!==null&&c!==void 0?c:i.backgroundAlpha)},Ei=({target:t,props:e,fallback:i,dependsOn:n})=>{var r,s,c,a,l,h,u,f,v,g,b;t.style.border=`calc(${n.height} * ${(c=(s=(r=e==null?void 0:e.shape)===null||r===void 0?void 0:r.border)===null||s===void 0?void 0:s.width)!==null&&c!==void 0?c:i.borderWidth}) solid ${pi((h=(l=(a=e==null?void 0:e.shape)===null||a===void 0?void 0:a.border)===null||l===void 0?void 0:l.color)!==null&&h!==void 0?h:i.borderColor,(v=(f=(u=e==null?void 0:e.shape)===null||u===void 0?void 0:u.border)===null||f===void 0?void 0:f.alpha)!==null&&v!==void 0?v:i.borderAlpha)}`,t.style.borderRadius=`calc(${n.height} * ${(b=(g=e==null?void 0:e.shape)===null||g===void 0?void 0:g.roundCorners)!==null&&b!==void 0?b:i.roundCorners})`},ft=({target:t,layoutParams:e,fallback:i})=>{var n;t.style.transform=`rotate(${(n=-e.angle)!==null&&n!==void 0?n:i.angle}rad)`};class vt{constructor(e){this.control=e}createView(e){var i;const n=document.createElement("div");n.classList.add(`${G}-control-container-${this.control.id}`),e(n,this.control.layoutParams);const r=((i=this.control.layoutParams.innerSizesDependOn)!==null&&i!==void 0?i:q.innerSizesDependOn)==="self"?{height:n.style.height,width:n.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:n,dependsOn:r}}setEvents(e,i){e&&this.control.events.forEach(n=>{switch(n.type.trim().toLowerCase()){case"onclick":e.addEventListener("click",s=>{s.stopPropagation(),i&&i({action:n.action,controlId:this.control.id,controlType:this.control.type})});break}})}getElement(){return document.querySelector(`.${G}-control-container-${this.control.id}`)}}const Ci=t=>{if(t.type.trim().toLowerCase()==="area")return new jn(t)};class jn extends vt{constructor(e){super(e)}createView({parent:e,layoutFn:i}){const{dependsOn:n,controlContainerEl:r}=super.createView(i),s=document.createElement("button");return s.classList.add(`${G}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.type="button",bi({target:s,props:this.control.props,fallback:{...q,backgroundColor:"transparent"}}),Ei({target:s,props:this.control.props,fallback:{...q,borderAlpha:0},dependsOn:n}),ft({target:s,layoutParams:this.control.layoutParams,fallback:q}),r.append(s),e.append(r),r}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}}const wi=t=>{if(t.type.trim().toLowerCase()==="button")return new xn(t)};class xn extends vt{constructor(e){super(e)}createView({parent:e,layoutFn:i}){const{dependsOn:n,controlContainerEl:r}=super.createView(i),s=document.createElement("button");s.type="button",s.classList.add(`${G}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.style.fontFamily="inherit";const c=document.createElement("span");return c.style.display="inline-block",c.style.whiteSpace="pre",c.style.overflow="hidden",c.style.textOverflow="ellipsis",ft({target:s,layoutParams:this.control.layoutParams,fallback:q}),bi({target:s,props:this.control.props,fallback:q}),Ei({target:s,props:this.control.props,fallback:q,dependsOn:n}),yi({target:s,props:this.control.props}),gi({target:c,props:this.control.props,fallback:q,dependsOn:n}),s.append(c),r.append(s),e.append(r),r}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}}const Pn=t=>{if(t.type.trim().toLowerCase()==="text")return new Ln(t)};class Ln extends vt{constructor(e){super(e)}createView({parent:e,layoutFn:i}){const{dependsOn:n,controlContainerEl:r}=super.createView(i),s=document.createElement("div");s.classList.add(`${G}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.fontFamily="inherit";const c=document.createElement("span");return c.style.whiteSpace="pre",ft({target:s,layoutParams:this.control.layoutParams,fallback:q}),yi({target:s,props:this.control.props}),gi({target:c,props:this.control.props,fallback:q,dependsOn:n}),s.append(c),r.append(s),e.append(r),r}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}}class Nn{constructor(e){this.layout=e}}const Mn=t=>{if(t.type.trim().toLowerCase()==="relative")return new _i(t)};class _i extends Nn{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,i){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${i.width})`,e.style.height=`calc(var(--interactive-content-height) * ${i.height})`,e.style.left=`calc(var(--interactive-content-width) * ${i.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${i.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}}function o(t,e,i,n){if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?n:i==="a"?n.call(t):n?n.value:e.get(t)}function _(t,e,i,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(t,i):r?r.value=i:e.set(t,i),i}var he,Le,Rt;class Ii{constructor(e){he.add(this),this.container=e,this.factories=new Map,o(this,he,"m",Le).call(this)}addControlFactory(e,i){this.factories.set(e.trim().toLowerCase(),i),o(this,he,"m",Le).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),o(this,he,"m",Le).call(this)}}he=new WeakSet,Le=function(){this.controls=o(this,he,"m",Rt).call(this)},Rt=function(){var e;return(e=this.container.controls)===null||e===void 0?void 0:e.reduce((i,n)=>{const r=n.type.trim().toLowerCase(),s=this.factories.get(r);return s?[...i,s(n)]:[...i]},[])};const Si=(t,e)=>{if(t.type.trim().toLowerCase()==="choice")return new Vn(t,e)};class Vn extends Ii{constructor(e,i){super(e),this.rootElement=i!=null?i:mi(),this.layout=new _i(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",wi),this.addControlFactory("text",Pn),this.addControlFactory("area",Ci)}createView(e){const i=document.createElement("div");return i.classList.add(`${G}-${this.container.id}`),this.layout.setContainerLayout(i),this.controls.forEach(n=>{const r=n.createView({parent:i,layoutFn:this.layout.setControlLayout});n.setEvents(r,e)}),this.rootElement.append(i),this.isRemoved=!1,i}hide(){const e=this.getElement();e&&(e.style.visibility="hidden")}show(){const e=this.getElement();e&&(e.style.visibility="visible")}enable(){const e=this.getElement();e&&(e.style.opacity=1,this.isDisabled=!1)}disable(){const e=this.getElement();e&&(e.style.opacity=An,this.isDisabled=!0)}removeView(){var e;this.isRemoved||((e=this.getElement())===null||e===void 0||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${G}-${this.container.id}`)}}var We=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Fn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var $e=function(t){return t&&t.Math==Math&&t},J=$e(typeof globalThis=="object"&&globalThis)||$e(typeof window=="object"&&window)||$e(typeof self=="object"&&self)||$e(typeof We=="object"&&We)||function(){return this}()||We||Function("return this")(),re=function(t){try{return!!t()}catch(e){return!0}},kn=re,Be=!kn(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")}),Bn=Be,Ti=Function.prototype,At=Ti.apply,jt=Ti.call,Dn=typeof Reflect=="object"&&Reflect.apply||(Bn?jt.bind(At):function(){return jt.apply(At,arguments)}),$i=Be,Oi=Function.prototype,nt=Oi.call,Wn=$i&&Oi.bind.bind(nt,nt),ve=$i?Wn:function(t){return function(){return nt.apply(t,arguments)}},Ri=ve,Un=Ri({}.toString),Gn=Ri("".slice),Ai=function(t){return Gn(Un(t),8,-1)},zn=Ai,Hn=ve,ji=function(t){if(zn(t)==="Function")return Hn(t)},rt=typeof document=="object"&&document.all,qn=typeof rt=="undefined"&&rt!==void 0,xi={all:rt,IS_HTMLDDA:qn},Pi=xi,Kn=Pi.all,se=Pi.IS_HTMLDDA?function(t){return typeof t=="function"||t===Kn}:function(t){return typeof t=="function"},Li={},Qn=re,we=!Qn(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Yn=Be,Oe=Function.prototype.call,pt=Yn?Oe.bind(Oe):function(){return Oe.apply(Oe,arguments)},Ni={},Mi={}.propertyIsEnumerable,Vi=Object.getOwnPropertyDescriptor,Xn=Vi&&!Mi.call({1:2},1);Ni.f=Xn?function(e){var i=Vi(this,e);return!!i&&i.enumerable}:Mi;var Fi=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}},Zn=ve,Jn=re,er=Ai,Ue=Object,tr=Zn("".split),ir=Jn(function(){return!Ue("z").propertyIsEnumerable(0)})?function(t){return er(t)=="String"?tr(t,""):Ue(t)}:Ue,ki=function(t){return t==null},nr=ki,rr=TypeError,Bi=function(t){if(nr(t))throw rr("Can't call method on "+t);return t},sr=ir,ar=Bi,or=function(t){return sr(ar(t))},xt=se,Di=xi,lr=Di.all,De=Di.IS_HTMLDDA?function(t){return typeof t=="object"?t!==null:xt(t)||t===lr}:function(t){return typeof t=="object"?t!==null:xt(t)},Wi={},Ge=Wi,ze=J,cr=se,Pt=function(t){return cr(t)?t:void 0},Ui=function(t,e){return arguments.length<2?Pt(Ge[t])||Pt(ze[t]):Ge[t]&&Ge[t][e]||ze[t]&&ze[t][e]},hr=ve,dr=hr({}.isPrototypeOf),ur=typeof navigator!="undefined"&&String(navigator.userAgent)||"",Gi=J,He=ur,Lt=Gi.process,Nt=Gi.Deno,Mt=Lt&&Lt.versions||Nt&&Nt.version,Vt=Mt&&Mt.v8,U,Ve;Vt&&(U=Vt.split("."),Ve=U[0]>0&&U[0]<4?1:+(U[0]+U[1]));!Ve&&He&&(U=He.match(/Edge\/(\d+)/),(!U||U[1]>=74)&&(U=He.match(/Chrome\/(\d+)/),U&&(Ve=+U[1])));var fr=Ve,Ft=fr,vr=re,pr=J,mr=pr.String,zi=!!Object.getOwnPropertySymbols&&!vr(function(){var t=Symbol();return!mr(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&Ft&&Ft<41}),yr=zi,Hi=yr&&!Symbol.sham&&typeof Symbol.iterator=="symbol",gr=Ui,br=se,Er=dr,Cr=Hi,wr=Object,qi=Cr?function(t){return typeof t=="symbol"}:function(t){var e=gr("Symbol");return br(e)&&Er(e.prototype,wr(t))},_r=String,Ir=function(t){try{return _r(t)}catch(e){return"Object"}},Sr=se,Tr=Ir,$r=TypeError,Ki=function(t){if(Sr(t))return t;throw $r(Tr(t)+" is not a function")},Or=Ki,Rr=ki,Ar=function(t,e){var i=t[e];return Rr(i)?void 0:Or(i)},qe=pt,Ke=se,Qe=De,jr=TypeError,xr=function(t,e){var i,n;if(e==="string"&&Ke(i=t.toString)&&!Qe(n=qe(i,t))||Ke(i=t.valueOf)&&!Qe(n=qe(i,t))||e!=="string"&&Ke(i=t.toString)&&!Qe(n=qe(i,t)))return n;throw jr("Can't convert object to primitive value")},Qi={exports:{}},kt=J,Pr=Object.defineProperty,Lr=function(t,e){try{Pr(kt,t,{value:e,configurable:!0,writable:!0})}catch(i){kt[t]=e}return e},Nr=J,Mr=Lr,Bt="__core-js_shared__",Vr=Nr[Bt]||Mr(Bt,{}),Fr=Vr,Dt=Fr;(Qi.exports=function(t,e){return Dt[t]||(Dt[t]=e!==void 0?e:{})})("versions",[]).push({version:"3.31.0",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"});var kr=Qi.exports,Br=Bi,Dr=Object,Yi=function(t){return Dr(Br(t))},Wr=ve,Ur=Yi,Gr=Wr({}.hasOwnProperty),mt=Object.hasOwn||function(e,i){return Gr(Ur(e),i)},zr=ve,Hr=0,qr=Math.random(),Kr=zr(1 .toString),Qr=function(t){return"Symbol("+(t===void 0?"":t)+")_"+Kr(++Hr+qr,36)},Yr=J,Xr=kr,Wt=mt,Zr=Qr,Jr=zi,es=Hi,de=Yr.Symbol,Ye=Xr("wks"),ts=es?de.for||de:de&&de.withoutSetter||Zr,is=function(t){return Wt(Ye,t)||(Ye[t]=Jr&&Wt(de,t)?de[t]:ts("Symbol."+t)),Ye[t]},ns=pt,Ut=De,Gt=qi,rs=Ar,ss=xr,as=is,os=TypeError,ls=as("toPrimitive"),cs=function(t,e){if(!Ut(t)||Gt(t))return t;var i=rs(t,ls),n;if(i){if(e===void 0&&(e="default"),n=ns(i,t,e),!Ut(n)||Gt(n))return n;throw os("Can't convert object to primitive value")}return e===void 0&&(e="number"),ss(t,e)},hs=cs,ds=qi,Xi=function(t){var e=hs(t,"string");return ds(e)?e:e+""},us=J,zt=De,st=us.document,fs=zt(st)&&zt(st.createElement),vs=function(t){return fs?st.createElement(t):{}},ps=we,ms=re,ys=vs,Zi=!ps&&!ms(function(){return Object.defineProperty(ys("div"),"a",{get:function(){return 7}}).a!=7}),gs=we,bs=pt,Es=Ni,Cs=Fi,ws=or,_s=Xi,Is=mt,Ss=Zi,Ht=Object.getOwnPropertyDescriptor;Li.f=gs?Ht:function(e,i){if(e=ws(e),i=_s(i),Ss)try{return Ht(e,i)}catch(n){}if(Is(e,i))return Cs(!bs(Es.f,e,i),e[i])};var Ts=re,$s=se,Os=/#|\.prototype\./,_e=function(t,e){var i=As[Rs(t)];return i==xs?!0:i==js?!1:$s(e)?Ts(e):!!e},Rs=_e.normalize=function(t){return String(t).replace(Os,".").toLowerCase()},As=_e.data={},js=_e.NATIVE="N",xs=_e.POLYFILL="P",Ps=_e,qt=ji,Ls=Ki,Ns=Be,Ms=qt(qt.bind),Vs=function(t,e){return Ls(t),e===void 0?t:Ns?Ms(t,e):function(){return t.apply(e,arguments)}},Ji={},Fs=we,ks=re,Bs=Fs&&ks(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),Ds=De,Ws=String,Us=TypeError,Gs=function(t){if(Ds(t))return t;throw Us(Ws(t)+" is not an object")},zs=we,Hs=Zi,qs=Bs,Re=Gs,Kt=Xi,Ks=TypeError,Xe=Object.defineProperty,Qs=Object.getOwnPropertyDescriptor,Ze="enumerable",Je="configurable",et="writable";Ji.f=zs?qs?function(e,i,n){if(Re(e),i=Kt(i),Re(n),typeof e=="function"&&i==="prototype"&&"value"in n&&et in n&&!n[et]){var r=Qs(e,i);r&&r[et]&&(e[i]=n.value,n={configurable:Je in n?n[Je]:r[Je],enumerable:Ze in n?n[Ze]:r[Ze],writable:!1})}return Xe(e,i,n)}:Xe:function(e,i,n){if(Re(e),i=Kt(i),Re(n),Hs)try{return Xe(e,i,n)}catch(r){}if("get"in n||"set"in n)throw Ks("Accessors not supported");return"value"in n&&(e[i]=n.value),e};var Ys=we,Xs=Ji,Zs=Fi,Js=Ys?function(t,e,i){return Xs.f(t,e,Zs(1,i))}:function(t,e,i){return t[e]=i,t},Ae=J,ea=Dn,ta=ji,ia=se,na=Li.f,ra=Ps,le=Wi,sa=Vs,ce=Js,Qt=mt,aa=function(t){var e=function(i,n,r){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(i);case 2:return new t(i,n)}return new t(i,n,r)}return ea(t,this,arguments)};return e.prototype=t.prototype,e},oa=function(t,e){var i=t.target,n=t.global,r=t.stat,s=t.proto,c=n?Ae:r?Ae[i]:(Ae[i]||{}).prototype,a=n?le:le[i]||ce(le,i,{})[i],l=a.prototype,h,u,f,v,g,b,I,d,m;for(v in e)h=ra(n?v:i+(r?".":"#")+v,t.forced),u=!h&&c&&Qt(c,v),b=a[v],u&&(t.dontCallGetSet?(m=na(c,v),I=m&&m.value):I=c[v]),g=u&&I?I:e[v],!(u&&typeof b==typeof g)&&(t.bind&&u?d=sa(g,Ae):t.wrap&&u?d=aa(g):s&&ia(g)?d=ta(g):d=g,(t.sham||g&&g.sham||b&&b.sham)&&ce(d,"sham",!0),ce(a,v,d),s&&(f=i+"Prototype",Qt(le,f)||ce(le,f,{}),ce(le[f],v,g),t.real&&l&&(h||!l[v])&&ce(l,v,g)))},la=Math.ceil,ca=Math.floor,ha=Math.trunc||function(e){var i=+e;return(i>0?ca:la)(i)},da=ha,en=function(t){var e=+t;return e!==e||e===0?0:da(e)},ua=en,fa=Math.min,va=function(t){return t>0?fa(ua(t),9007199254740991):0},pa=va,ma=function(t){return pa(t.length)},ya=oa,ga=Yi,ba=ma,Ea=en;ya({target:"Array",proto:!0},{at:function(e){var i=ga(this),n=ba(i),r=Ea(e),s=r>=0?r:n+r;return s<0||s>=n?void 0:i[s]}});var Ca=Ui,wa=Ca,_a=wa,Ia=_a("Array","at"),Sa=Ia,Ta=Sa,$a=Ta,Oa=$a,tn=Fn(Oa);function nn(t,e){let i;return(...n)=>{clearTimeout(i),i=setTimeout(()=>t(...n),e)}}const Ie={Object:"Object",String:"String",Array:"Array",Number:"Number",Function:"Function",Boolean:"Boolean"},pe=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,yt=t=>pe(t,Ie.Object),at=t=>pe(t,Ie.String),gt=t=>pe(t,Ie.Array),rn=t=>pe(t,Ie.Number),Ra=t=>pe(t,Ie.Function),Yt=t=>rn(t)&&!isNaN(t),be=t=>yt(t)&&Object.keys(t).length===0,bt=t=>gt(t)&&!t.length,je=(t,e)=>at(t)&&(e?t.trim():t).length,sn=window.navigator.userAgent.toLowerCase(),Aa=/mobi/i.test(sn);sn.indexOf("android")>-1;const ja="video_interactive",xa="videoint",Pa=250;class La{constructor(e){this.onResize=i=>{this.isReady&&(!i[0].contentRect.width||!i[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:i[0].contentRect.width,height:i[0].contentRect.height}))},this.handleChapterChange=i=>{var n;if(this.isReady){if(this.isHidden||this.hide(),!(i!=null&&i.id)){(n=this.onError)===null||n===void 0||n.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(i.id),this.ngEditor.selectChapter(i.id),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=i.id,this.lastZoomInfo=void 0}},this.handleManifestChange=async(i,n=[])=>{var r;if(!rn(i.graph.edit.chapters[0].x)){this.isReady=!1,(r=this.onError)===null||r===void 0||r.call(this,"Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=void 0,!this.ngEditor){let s;try{s=await k.loadVKLangPack(this.lang,ja,xa)}catch(a){console.log("Unable to load graph language pack")}const{GraphEditor:c}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new c(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:s}),this.ngEditor.on("control",({name:a,chapterId:l})=>{a==="openPreview"&&this.onOpenPreviewClick(l)}),this.ngEditor.on("zoomEnd",a=>{this.lastZoomInfo={...a}})}this.visitedChapterIds=new Set(n),i.metadata.id!==this.currentManifestId?(this.ngEditor.update(i),this.currentManifestId=i.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0},this.init(e)}init({root:e,onOpenPreviewClick:i,onError:n,lang:r,visitedChapters:s=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=i,this.onError=n,this.lang=r!=null?r:"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=Na(e),this.resizeObserver=new ResizeObserver(nn(this.onResize,Pa)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor.updateVideosInfo(e)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,i;this.hide(),this.resizeObserver.disconnect(),(e=this.ngEditor)===null||e===void 0||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(i=this.ngEditor)===null||i===void 0||i.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}}function Na(t){const 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",t.append(e),e}const Ce=(t="",e="")=>{t=t.split("."),e=e.split(".");let i=0;for(let n=0;n<Math.max(t.length,e.length)&&!i;n++)t[n]>e[n]?i=1:t[n]<e[n]?i=-1:i=0;return i},Ma="3.1",Xt={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},Va={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Fa=t=>{const e=[];for(const i of t.chapters){let n;const r=[];for(const{isDefault:a,...l}of i.branches)a&&(n=l.id),r.push(l);let s=[];const c=[];for(const{fallbackStrategy:a,...l}of i.containers){const h=!!l.endTime;let u=[Va];switch(a){case"await":h?u=[]:s=[];break;case"default":{const f={type:"onSuspense",action:{type:Xt.default,args:{branchId:n,shouldOpenNow:!h,isDetachContainer:!0}}};h?u=[f]:s=[f];break}case"random":case"weightlessRandom":case"max":case"min":{const f={type:"onSuspense",action:{type:Xt[a],args:{}}};h?u=[f]:s=[f];break}}for(const f of l.controls)c.push({...l,controls:[{...f}],id:Tn.v4(),events:u})}e.push({...i,containers:c,events:s,branches:r})}return t.metadata.version=Ma,t.metadata.updated=new Date().toISOString(),{...t,chapters:e}},ka="3.2",Ba=t=>{if(!t.media){const{media:e,...i}=t.metadata;return{...t,metadata:{...i,version:ka},media:e}}return t},Da="3.3",Wa=(t=[])=>({edit:{chapters:t},view:{}}),Zt={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ua=t=>{var e;const i=[],n=[];for(const r of t.chapters){const{id:s,x:c,y:a,...l}=r,h=l.containers.map(u=>{var f;return{...u,controls:u.controls.map(({subtype:v,type:g,...b})=>({...b,type:v!=null?v:g})),events:!((f=u.events)===null||f===void 0)&&f.length?u.events:[Zt]}});i.push({id:s,...l,containers:h,events:!((e=l.events)===null||e===void 0)&&e.length?l.events:[Zt]}),n.push({id:s,x:c,y:a})}return{...t,chapters:i,graph:Wa(n),metadata:{...t.metadata,version:Da}}},Ga=[{version:"3.0",migrate:Fa},{version:"3.1",migrate:Ba},{version:"3.2",migrate:Ua}],za=t=>Ga.reduce((e,i)=>Ce(e.metadata.version,i.version)?e:i.migrate(e),t),Ha=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),O=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"});exports.INTERACTIVE_CLICK_ACTIONS=void 0;(function(t){t.GO_NEXT_BUTTON="GO_NEXT_BUTTON",t.GO_NEXT_AREA="GO_NEXT_AREA",t.WATCH_AGAIN="WATCH_AGAIN",t.OPEN_GRAPH="OPEN_GRAPH",t.CLOSE_GRAPH="CLOSE_GRAPH"})(exports.INTERACTIVE_CLICK_ACTIONS||(exports.INTERACTIVE_CLICK_ACTIONS={}));const Jt={metadata:"Object",chapters:"Array"},qa="3.0.0",Ka="3.3.0",Et=t=>{const e=Ce(t,qa);return e===-1?!1:e===0?!0:Ce(t,Ka)!==1},Qa=t=>{if(!yt(t))return!1;for(const e in Jt)if(!t[e]||!pe(t[e],Jt[e]))return!1;return Et(t.metadata.version)},an=t=>t.type===Ha.Text;class P{constructor(e,i,...n){this.severity=e,this.category=i,this.data=n}toString(){return`SDK_NAME ERROR ${JSON.stringify(this,null," ")}`}}P.Severity={RECOVERABLE:1,CRITICAL:2};P.Category={VIDEO:0,INTERACTIVES:1,GRAPH:2,MANIFEST:3,LOADERS:4,HISTORY:5,SEAMLESS:6};class on{constructor(){this.listeners={}}addListener(e,i){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(i),this}on(e,i){return this.addListener(e,i)}once(e,i){this.listeners[e]=this.listeners[e]||[];const n=()=>{i(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,i){return this.removeListener(e,i)}reset(){this.listeners={}}removeListener(e,i){const n=this.listeners[e];if(!n)return this;for(let r=n.length;r>0;r--)if(n[r]===i){n.splice(r,1);break}return this}emit(e,...i){const n=this.listeners[e];return n?(n.forEach(r=>{r(...i)}),!0):!1}listenerCount(e){return(this.listeners[e]||[]).length}rawListeners(e){return this.listeners[e]}}class Ya{constructor(e){this.addFn=(i,n=!1)=>{Ra(i)&&(this.fns.push(i),n&&this.updateFn())},this.removeFn=(i,n=!1)=>{this.fns=this.fns.filter(r=>r!==i),n&&this.updateFn()},this.updateFn=()=>{this.fn=()=>{this.fns.forEach(i=>i()),this.raf&&this.forceRequestAnimation()}},this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))},this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()},this.cancelAnimation=()=>{cancelAnimationFrame(this.raf),this.raf=void 0},this.raf,this.fn,this.fns=[],this.addFn(e)}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}}class Xa{constructor(e){var i,n;this.loaders={chapterLoaders:(i=e==null?void 0:e.chapterLoaders)!==null&&i!==void 0?i:[],manifestLoaders:(n=e==null?void 0:e.manifestLoaders)!==null&&n!==void 0?n:[]}}async exec(e,i){return Za(...this.loaders[e])(i)}}function Za(...t){return async function(i){const n=[...t];for(;n.length>0;)i=await n.shift()(i);return i}}function Fe(t,e,i){return t?{...t,[e]:t[e]?[i,...t[e]]:[i]}:{[e]:[i]}}function ot({actions:t,errors:e,chapterId:i,...n}){if(i){const r=t.getManifest(),s=t.getChapter(r.chapters,i);if(s){const c=t.getMedia(r.media,s.videoId),a=t.getGraph(r.graph,s.id);return c?{...n,actions:t,errors:e,result:{chapter:s,media:c,graph:a}}:{...n,errors:Fe(e,ot.name,"Could not find media"),actions:t}}}return{...n,errors:Fe(e,ot.name,"Could not find chapter"),actions:t}}class ei{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,i,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:i,options:n})}removeEventListener(e,i){if(!(e in this.listeners))return;const n=this.listeners[e];for(let r=0,s=n.length;r<s;r++)if(n[r].callback===i){n.splice(r,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;const n=this.listeners[e.type].slice();for(let r=0,s=n.length;r<s;r++){const c=n[r];try{c.callback.call(this,e)}catch(a){Promise.resolve().then(()=>{throw a})}c.options&&c.options.once&&this.removeEventListener(e.type,c.callback)}return!e.defaultPrevented}}class ln extends ei{constructor(){super(),this.listeners||ei.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)}}class Ja{constructor(){Object.defineProperty(this,"signal",{value:new ln,writable:!0,configurable:!0})}abort(e){let i;try{i=new Event("abort")}catch(r){typeof document!="undefined"?document.createEvent?(i=document.createEvent("Event"),i.initEvent("abort",!1,!1)):(i=document.createEventObject(),i.type="abort"):i={type:"abort",bubbles:!1,cancelable:!1}}let n=e;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(r){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(i)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(Ja.prototype[Symbol.toStringTag]="AbortController",ln.prototype[Symbol.toStringTag]="AbortSignal");function cn(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof t.Request=="function"&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}function eo(t){typeof t=="function"&&(t={fetch:t});const{fetch:e,Request:i=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r=!1}=t;if(!cn({fetch:e,Request:i,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r}))return{fetch:e,Request:s};let s=i;(s&&!s.prototype.hasOwnProperty("signal")||r)&&(s=function(h,u){let f;u&&u.signal&&(f=u.signal,delete u.signal);const v=new i(h,u);return f&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:f}),v},s.prototype=i.prototype);const c=e;return{fetch:(l,h)=>{const u=s&&s.prototype.isPrototypeOf(l)?l.signal:h?h.signal:void 0;if(u){let f;try{f=new DOMException("Aborted","AbortError")}catch(g){f=new Error("Aborted"),f.name="AbortError"}if(u.aborted)return Promise.reject(f);const v=new Promise((g,b)=>{u.addEventListener("abort",()=>b(f),{once:!0})});return h&&h.signal&&delete h.signal,Promise.race([v,c(l,h)])}return c(l,h)},Request:s}}const Ct=cn({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),hn=Ct?eo({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,ti=Ct?hn.fetch:window.fetch;Ct?hn.Request:window.Request;const to=async t=>{try{let e,i;if(yt(t))e=t;else if(at(t)){i=new URL(t).href;const r=await ti(i);if(!r.ok)return{};e=await r.json()}else return{};if(!Qa(e))return{};const n=e.metadata.media;if(at(n)&&!e.media)try{let r;i?r=new URL(n,i).href:(r=new URL(n).href,i=r);const s=await ti(r);if(!s.ok)throw new Error;e.metadata.media=await s.json()}catch(r){return so(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:i}}catch(e){return{}}};async function io(t){const{manifest:e,manifestURL:i}=await to(t),n=za(e);return n.media=no(n.media,i),delete n.metadata.media,n}function tt(t,e){return t.find(i=>i.id===e)}function ii(t,e){var i,n;return!((i=t.edit)===null||i===void 0)&&i.chapters?t.edit.chapters.find(r=>r.id===e):!((n=t.view)===null||n===void 0)&&n.chapters?t.view.chapters.find(r=>r.id===e):void 0}function ni(t,e){return t.videos.find(i=>i.id===e)}function no(t,e){return{...t,videos:t.videos.map(i=>({...i,variants:i.variants.map(n=>{const r=ro(n.url,e);return{...n,url:r||n.url}})}))}}function ro(t,e){try{return new URL(t,e).href}catch(i){return""}}function so(t){return Ce(t,"3.2.0")>=0}class dn extends Xa{constructor(e,i){super(e),this.onError=i,this.prevChapter$=new k.ValueSubject(null),this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(e){var i;this.release();const n=await this.exec("manifestLoaders",{actions:{addErrorMessage:Fe},result:null,errors:null,source:e});n.errors&&this.errorHandler(n.errors);const r=await io((i=n.result)!==null&&i!==void 0?i:e);return this.manifest=r,this}async setInitial(){return this.setNext()}async setNext(e=this.manifest.metadata.initChapterId){this.prevChapter$.next(this.chapter);const i=await this.exec("chapterLoaders",ot({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:ii,getChapter:tt,getMedia:ni,getByBranches:this.getByBranches.bind(this),addErrorMessage:Fe},result:null,errors:null,chapterId:e}));return i.errors&&this.errorHandler(i.errors),this.chapter=i.result.chapter,this.media=i.result.media,this.graph=i.result.graph,this}errorHandler(e){this.onError(e),console.error("Something went wrong with loaders",{errors:e})}getInitial(){return this.getByChapterId(this.manifest.metadata.initChapterId)||null}getByChapterId(e=this.manifest.metadata.initChapterId){const i=tt(this.manifest.chapters,e);if(i){const n=ni(this.manifest.media,i.videoId),r=ii(this.manifest.graph,i.id);if(n)return{chapter:i,media:n,graph:r}}return null}getBranches(e=this.chapter.id){if(e===this.chapter.id)return this.getByBranches(this.chapter.branches);{const i=tt(this.manifest.chapters,e);return this.getByBranches(i==null?void 0:i.branches)}}getByBranches(e=[]){return e.reduce((i,n)=>{const r=this.getByChapterId(n.chapterId);return r&&i.push(r),i},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}}const C={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyChanged:"history-changed"},lt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},j={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function ao(){const t=new Map;function e({listId:r=Math.random().toString(),itemId:s=Math.random().toString(),...c}){const a=t.get(r),l={...c};return a?a[s]=l:t.set(r,{[s]:l}),{listId:r,itemId:s,...c}}function i(r,s){var c,a,l;const h=t.get(r);if(h){if(s)return(c=h[s])===null||c===void 0||c.player.destroy(),(a=h[s])===null||a===void 0||a.container.remove(),(l=h[s])===null||l===void 0||l.subscription.unsubscribe(),delete h[s],Object.keys(h).length||t.delete(r),!0;for(const u of Object.values(h))u.player.destroy(),u.container.remove();return t.delete(r),!0}else throw Error("Can't remove. Not find.")}function n(){for(const r of t)i(r[0])}return{createPlayer:e,removePlayer:i,map:t,removeAll:n}}function ri(t,e=[]){var i,n,r;let s={},c;const a=!e.length;for(const l of t.variants)if(!c&&"cover"in l&&(c=l.cover),"url"in l)switch(l.type.toLowerCase()){case"mp4":(a||e.includes("mp4"))&&(s.MPEG={...s.MPEG,[(i=l.standard)!==null&&i!==void 0?i:"Invariant quality"]:l.url});break;case"mpeg":(a||e.includes("mpeg"))&&(s.MPEG={...s.MPEG,[(n=l.standard)!==null&&n!==void 0?n:"Invariant quality"]:l.url});break;case"hls":(a||e.includes("hls"))&&(s={...s,HLS:{type:"url",url:l.url}});break;case"dash":(a||e.includes("dash"))&&(s={...s,DASH_SEP:{compatibilityMode:!0,type:"url",url:l.url}});break}return{sources:s,thumbUrl:c,title:(r=t.title)!==null&&r!==void 0?r:""}}const xe=(t,e)=>{const i=t.info.currentQuality$.getValue(),n=t.info.availableQualities$.getValue();i!==e&&n.includes(e)&&(t.setQuality(e),t.setAutoQuality(!1))},oo=t=>{const e=t.variants.find(i=>{var n;return((n=i.payload)===null||n===void 0?void 0:n.type)==="vk"});if(e&&"payload"in e){const[i,n]=e.payload.id.split("_");return[i,n]}return[]},Ne={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},lo=2;function co(t){const e=ao();let i,n;const r=new on;let s={},c=!1,a=null,l=!1,h;t&&u(t);function u(p){a=p}function f(p,E,y){var S;if(!a)throw Error("need to set interactive controller");const x=((S=e.map.get(p))!==null&&S!==void 0?S:{})[E];if(x){s={chapterId:y,listId:p,itemId:E,...x};const w=s.player;n=w.info.currentQuality$.subscribe(V=>{if(!(!V||!w.info.position$.getValue())){i=V;for(const D of e.map)Object.values(D[1]).forEach(({player:L})=>{w.info.isAutoQualityEnabled$.getValue()||xe(L,V)})}}),x.container.remove(),c=!1,a.setPlayer(x.player),l||(a.init(),l=!0),r.emit(Ne.activePlayerChanged,{player:s.player,config:s.config});return}throw Error("Can't set. Not find.")}async function v(p,E,y){if(!a)throw Error("need to set interactive controller");if(be(s)||p!==s.itemId)return;if(y>=0&&!c){const T=a.getChapterBranches();c=!0;const x=new Set;for(const w of T)x.has(w.media.id)||(await b({media:w.media,chapterId:w.chapter.id,setAsActive:!1,title:w.chapter.label}),x.add(w.media.id))}}async function g({chapter:{id:p},media:E}){if(be(s))return;n==null||n.unsubscribe();const y=s.player.info.muted$.getValue(),S=s.player.info.currentQuality$.getValue(),T=s.player.info.isAutoQualityEnabled$.getValue(),x=s.player.info.volume$.getValue(),w=s.player.info.currentPlaybackRate$.getValue(),V=!T;let D=!1;for(const L of e.map)if(L[0]===E.id){const z=Object.keys(L[1]);for(const K of z)K===s.itemId?(z.length<lo||(D=!0),e.removePlayer(L[0],K)):(D=!0,f(L[0],K,p),V?xe(s.player,S):s.player.setAutoQuality(!0),s.player.setVolume(x),s.player.setMuted(y),s.player.setPlaybackRate(w))}else e.removePlayer(L[0]);D||(await b({media:E,chapterId:p,setAsActive:!0,playbackRate:w}),V?xe(s.player,S):s.player.setAutoQuality(!0),s.player.setVolume(x),s.player.setMuted(y))}async function b({media:p,chapterId:E,prefetch:y=!0,setAsActive:S=!0,autoplay:T=!1,preferredExt:x,title:w,playbackRate:V}){var D,L,z;const K=Math.random().toString(),ae=document.createElement("div");h.append(ae);const yn=(D=s==null?void 0:s.player)===null||D===void 0?void 0:D.info.isAutoQualityEnabled$.getValue();let Se;if(!((L=a==null?void 0:a.options)===null||L===void 0)&&L.vkVideoLoader){const Te=oo(p);Te.length&&(Se=await a.options.vkVideoLoader(...Te))}const _t={container:ae,...((z=Se==null?void 0:Se.videos)===null||z===void 0?void 0:z[0])||{sources:ri(p,x).sources},title:w},ee=new $n.Player;ee.initVideo(_t);const gn=ae.lastChild,It=new k.Subscription;It.add(ee.info.position$.subscribe(function(Te){v(K,ee.info.duration$.getValue(),Te)})).add(ee.events.canplay$.subscribe(function(){yn||xe(ee,i),V&&ee.setPlaybackRate(V)})),gn&&(ae.style.display="none",ae.classList.add(E));const oe=e.createPlayer({listId:p.id,itemId:K,player:ee,container:ae,sources:ri(p,x).sources,config:_t,subscription:It});return S&&f(p.id,oe.itemId,E),T&&oe.player.play(),y&&!T&&oe.player.prepare(),r.emit(Ne.playerCreated,oe.player),{player:oe.player,config:oe.config}}function I(){d(),a=null}function d(){a==null||a.off(C.chapterChanged,g),e.removeAll(),s={},l=!1,c=!1}async function m({source:p,initialChapter:E,container:y}){if(!a)throw Error("need to set interactive controller");await a.setManifest(p),d(),h=y;const{media:S,chapter:T}=await a.setChapter({chapterId:E});if(S){a.on(C.chapterChanged,g);const{player:x,config:w}=await b({media:S,chapterId:T.id,title:T.label});return r.emit(Ne.initiated,{container:y,media:S,chapterId:T.id}),{player:x,config:w}}else console.error("not found")}return{...e,on:r.on.bind(r),off:r.off.bind(r),init:m,setInteractiveController:u,createPlayer:b,removeAll:I,getActivePlayer:function(){return s}}}const ho=3e3,uo=()=>{let t=[],e=null;return{setPlayer:c=>{e=c},setContainers:c=>{t=c},deleteContainer:c=>{t=t.filter(a=>a.id!==c)},getNextInteractiveTime:(c=ho)=>{if(!t.length||e===null)return null;let a=-1,l=!1;const h=e.info.position$.getValue()*1e3;for(const u of t){const f=u.startTime-c;if(f<=h&&(h<=u.endTime||u.endTime===null)){l=!0;break}h<f&&(a=a===-1?f:Math.min(a,f))}return!l&&a!==-1?a:null}}},fe=uo(),R=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),wt=t=>gt(t)&&!bt(t),un=t=>bt(t.branches)||t.order==="end",fo=t=>gt(t.branches)&&!bt(t.branches),vo=(t,e)=>{var i;const n=t*1e3;return wt(e.controls)&&n<((i=e.startTime)!==null&&i!==void 0?i:0)},si=(t,e)=>{var i,n;const r=t*1e3;return wt(e.controls)&&r>=((i=e.startTime)!==null&&i!==void 0?i:0)&&r<=((n=e.endTime)!==null&&n!==void 0?n:1/0)},ke=t=>t.some(e=>e.action.type==="expect"),ai=t=>t.find(e=>e.action.type==="expect"),po=t=>(t==null?void 0:t.length)===1,fn=t=>po(t)&&an(t[0]),mo=({fn:t,type:e=1},...i)=>(...n)=>e?t(...n,...i):t({...n[e],...i[e]}),yo=(t=[])=>t.reduce((e,i,n)=>{var r,s,c;const a=((r=i==null?void 0:i.controls)!==null&&r!==void 0?r:[]).filter(l=>!an(l));if(wt(a)){const l=[(s=i.startTime)!==null&&s!==void 0?s:0,(c=i.endTime)!==null&&c!==void 0?c:1/0],h=i.id;if(!n)e.push({subjects:[h],range:l});else{const u=[];let f=-1/0,v=1/0,g=[];const b=[];for(let I=0;I<e.length;I++){const d=e[I];if(b.push(...d.subjects),d.range[0]<v&&(v=d.range[0]),d.range[1]>f&&(f=d.range[1]),d.range[0]<=l[0]&&d.range[1]>=l[1])return e[I].subjects.push(h),e;l[0]>=d.range[0]&&l[0]<=d.range[1]&&(u.push(I),g=g.concat(d.subjects),l[0]=d.range[0]),l[1]>=d.range[0]&&l[1]<=d.range[1]&&(u.push(I),g=g.concat(d.subjects),l[1]=d.range[1])}if(b.push(h),l[0]<=v&&l[1]>=f)return[{subjects:b,range:l}];u.length&&u.reverse().forEach(I=>{e.splice(I,1)}),e.push({subjects:g.concat([h]),range:l})}}return e},[]).sort((e,i)=>e.range[0]-i.range[0]),go=(t,e)=>ke(t.events)?!1:e.some(({container:i})=>i.container.id!==t.id&&ke(i.container.events)&&i.container.endTime===t.endTime&&!i.isRemoved);class bo{constructor({player:e,container:i,branches:n,selectBranches:r,interactiveEvents:s,globalEventEmitter:c,ignoreContainerEvent:a,permanentTextControls:l}){this.hide=()=>{setTimeout(()=>{var h,u,f,v;this.gameState!==R.end&&(ke(this.container.container.events)&&this.gameState===R.afterInteractive||this.selectBranches.state.isExpect||(this.gameState===R.interactive?(u=(h=this.container).disable)===null||u===void 0||u.call(h):(v=(f=this.container).hide)===null||v===void 0||v.call(f),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.visibility,visibility:!1})))})},this.show=()=>{var h,u,f,v;if(this.gameState===R.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())(u=(h=this.container).show)===null||u===void 0||u.call(h),(v=(f=this.container).enable)===null||v===void 0||v.call(f),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.visibility,visibility:!0,isFirst:!1});else{const b=mo({fn:this.selectBranches.onControlEvent,type:0},{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.visibility,visibility:!1})},onEvent:(I,d)=>{this.isSelectedControlEvent=!0,I!==!1&&(this.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.visibility,visibility:!1})),(this.gameState===R.end||this.gameState===R.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),d(),this.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.visibility,visibility:!1})),fe.deleteContainer(this.container.container.id)},isEOV:()=>this.gameState===R.end});this.container.createView(b),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.visibility,visibility:!0,isFirst:!0})}},this.onEndOfVideo=()=>{this.gameState=R.end,this.selectContainerEvent(!0)},this.whilePlaying=()=>{var h,u,f,v;if(((h=this.player.experimental.element$.getValue())===null||h===void 0?void 0:h.readyState)<1||[R.destroyed,R.removed].includes(this.gameState)&&!this.isPermanentText)return;const b=this.player.getExactTime();if(vo(b,this.container.container))this.gameState!==R.beforeInteractive&&(this.gameState=R.beforeInteractive,this.onBeforeStartTime());else if(si(b,this.container.container))this.gameState!==R.interactive&&(this.gameState=R.interactive,this.onStartTime());else if(this.gameState!==R.afterInteractive){const m=this.gameState;this.gameState=R.afterInteractive,m===R.interactive&&this.onEndTime()}else this.gameState!==R.destroyed&&this.removeView();const I=si(b,this.container.container),d=this.container.container.startTime?[this.container.container.startTime,(u=this.container.container.endTime)!==null&&u!==void 0?u:1/0]:[];(v=(f=this.container).onProgress)===null||v===void 0||v.call(f,b,I),this.globalEventEmitter.emit(C.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:d,currentTime:b,isInteractiveTime:I})},this.container=i,this.branches=n,this.selectBranches=r,this.subscription=new k.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=a,this.isPermanentText=l&&fn(i.container.controls),this.globalEventEmitter=c,this.gameState=R.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo))}selectContainerEvent(e=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);const e=ke(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,i;(i=(e=this.container).hide)===null||i===void 0||i.call(e),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=R.beforeInteractive}removeView(){this.container.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.containerRemoved,visibility:!1}),this.gameState=R.removed}destroy(){var e;this.reset(),this.removeView(),this.gameState=R.destroyed,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!==null&&e!==void 0?e:1/0,id:this.container.container.id}),fe.deleteContainer(this.container.container.id)}}function Eo(){const t={};function e(){for(const a in t)Object.prototype.hasOwnProperty.call(t,a)&&delete t[a];return!0}function i(a){const l={};for(const h in t)+h<=a&&(l[h]=t[h]);return l}function n(a){const l={};for(const h in t)+h>=a&&(l[h]=t[h]);return l}function r({timestamp:a,priority:l,initiator:h}){var u;if(Yt(a)){const f=(u=t[a])!==null&&u!==void 0?u:null;if(f&&je(l,!0)){let v={};const g=f[l];if(g&&(v={...v,...g}),v=be(v)?null:v,v&&je(h,!0)){const b=v[h];return b!=null?b:null}return v}return f}return null}function s({timestamp:a,priority:l,initiator:h}){if(Yt(a))if(t[a]){if(je(l,!0))if(t[a][l]){if(je(h,!0))if(t[a][l][h]){if(delete t[a][l][h],!be(t[a][l]))return!0}else return!1;if(delete t[a][l],!be(t[a]))return!0}else return!1;return delete t[a]}else return!1}function c({timestamp:a,priority:l,initiator:h,...u}){var f,v,g;!((v=(f=t[a])===null||f===void 0?void 0:f[l])===null||v===void 0)&&v[h]?t[a][l][h].push({...u}):!((g=t[a])===null||g===void 0)&&g[l]?t[a][l]={...t[a][l],[h]:[{...u}]}:t[a]?t[a]={...t[a],[l]:{[h]:[{...u}]}}:t[a]={[l]:{[h]:[{...u}]}}}return{map:t,remove:s,add:c,removeAll:e,get:r,getLte:i,getGte:n}}const Co=[O.expect,O.setNextBranch],wo=1/0;function oi(t){let e=t,i;const n=_o(),r=new Eo;let s;const c=()=>{f(),I()},a=d=>{r.add.call(void 0,d),v()},l=(d=[])=>{for(const m of d)if(m.action(),Co.includes(m.actionType))break},h=d=>{var m,p,E;if(!n.isReady(d))return;const y=Pe((m=r.get({timestamp:d,priority:"control"}))!==null&&m!==void 0?m:{}),S=Pe((p=r.get({timestamp:d,priority:"container"}))!==null&&p!==void 0?p:{}),T=Pe((E=r.get({timestamp:d,priority:"chapter"}))!==null&&E!==void 0?E:{});l([...y,...S,...T])},u=()=>{var d;l([...Pe((d=r.get({timestamp:1/0,priority:"chapter"}))!==null&&d!==void 0?d:{})])},f=()=>{i&&(s==null||s.unsubscribe(),i=void 0)},v=()=>{i||(i=()=>setTimeout(()=>{h(1/0)}),s=e.events.ended$.subscribe(i))},g=d=>{f(),e=d},b=d=>{d.priority==="container"&&n.resetCalled(d.timestamp),r.remove(d)},I=()=>{n.release(),r.removeAll()};return{setPlayer:g,add:a,remove:b,exec:h,execEndOfVideo:u,listen:v,unlisten:f,release:c,containersEventsCallState:n}}function _o(){const t=new Map;return{setCalled:({timestamp:c,id:a})=>{const l=t.get(c);l&&l[a]!==void 0&&(l[a]=!0)},setData:(c=[])=>{var a,l;for(const h of c){const u=(a=h.endTime)!==null&&a!==void 0?a:wo,f=(l=t.get(u))!==null&&l!==void 0?l:{};t.set(u,{...f,[h.id]:!1})}},resetCalled:c=>{const a=t.get(c);if(a)for(const l in a)a[l]=!1},isReady:c=>{const a=t.get(c);return a?!Object.values(a).some(l=>!l):!0},release:()=>t.clear()}}function Pe(t){return Object.values(t).flat().sort(e=>e.actionType===O.expect?-1:1)}const Io=(t,e)=>{const{height:i,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(i&&n))return{videoContentHeight:0,videoContentWidth:0};const{clientHeight:r,clientWidth:s}=e.experimental.element$.value||{};if(!(r&&s))return{videoContentHeight:0,videoContentWidth:0};const c=i/n,a=r/s;let l,h;return a>c?(h=s,l=s*c):a<c?(h=r/c,l=r):(h=s,l=r),{videoContentWidth:h,videoContentHeight:l}},So=250;function To(t){let e=()=>{};const i=new ResizeObserver(a=>{s(a),e=s.bind(null,a)});function n(a){const{parentElement:l,player:h}=t();if(l&&h){const{videoContentWidth:u,videoContentHeight:f}=Io(l,h);l.style.setProperty("--interactive-content-width",`${u}px`),l.style.setProperty("--interactive-content-height",`${f}px`),l.style.setProperty("--interactive-width",`${a[0].contentRect.width}px`),l.style.setProperty("--interactive-height",`${a[0].contentRect.height}px`)}}function r(){const{parentElement:a}=t();a.removeAttribute("style")}const s=nn(a=>{const{fns:l=[]}=t();n(a);for(const h of l)h()},So);function c(){e=void 0,i.disconnect(),r()}return{resizeObserver:i,calc:()=>{e()},release:c}}class $o{constructor(){this.map={}}push(e,i){e in this.map?this.map[e].push(i):this.map[e]=[i]}get(e){const i=this.map[e];return i?i.slice():null}getAll(){const e=[];for(const i in this.map)e.push(...this.map[i]);return e}remove(e,i){e in this.map&&(this.map[e]=this.map[e].filter(n=>n!==i),this.map[e].length===0&&delete this.map[e])}clear(){this.map={}}size(){return Object.keys(this.map).length}keys(){return Object.keys(this.map)}}const Oo=t=>Math.floor(Math.random()*t),Ro=t=>{let e=t.length,i=1/0,n=null;for(;e--;)t[e].weight<i&&(i=t[e].weight,n=t[e]);return n},Ao=t=>{let e=t.length,i=-1/0,n=null;for(;e--;)t[e].weight>i&&(i=t[e].weight,n=t[e]);return n},jo=t=>{const e=t.length,i=Oo(e);return t[i]},li=1,xo=t=>{var e,i;let n=0;for(let s=0;s<t.length;++s)n+=(e=t[s].weight)!==null&&e!==void 0?e:li;const r=Math.random()*n;n=0;for(let s=0;s<t.length-1;++s)if(n+=(i=t[s].weight)!==null&&i!==void 0?i:li,n>=r)return t[s];return t[t.length-1]},ci=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0}),it=(t,e=!1)=>({...t,args:e?{...t.args,...ci}:{...ci,...t.args}}),hi=({globalEventEmitter:t,player:e,interactiveEvents:i,removeControllers:n})=>{const r={isExpect:!1},s=()=>{r.isExpect&&(r.isExpect=!1)},c=({action:d,controlType:m,controlId:p,containerId:E,branches:y=[],onEvent:S,isEOV:T=()=>!1,isDisabled:x=()=>!1})=>{const w=it(d,T()),V={timestamp:1/0,priority:"control",initiator:p,actionType:w.type},D=x(),L=t.emit.bind(t,C.interactives,{subjectId:p,subjectType:m,subjectName:"control",type:D?j.actionChoiceCanceled:j.actionChoice,actionType:d.type,payload:{containerId:E,...w.args}});if(D){L();return}switch(w.type.trim().toLowerCase()){case O.setNextBranch.trim().toLowerCase():{const z=y.find(K=>K.id===w.args.branchId);if(!z)return;S(w.args.isDetachContainer,v.bind(null,{subjectId:p,subjectName:"control"})),L(),w.args.shouldOpenNow?b({subjectId:p,subjectName:"control",subjectType:m,action:w,payload:{chapterId:z.chapterId,autoSelect:!1}}):(i.add({...V,action:b.bind(null,{subjectId:p,subjectName:"control",subjectType:m,action:w,payload:{chapterId:z.chapterId,autoSelect:!1}})}),n==null||n());return}case O.continuePlayback.trim().toLowerCase():{S(w.args.isDetachContainer,v.bind(null,{subjectId:p,subjectName:"control"})),L(),w.args.shouldOpenNow?g({subjectId:p,subjectName:"control",subjectType:m,action:d}):i.add({...V,action:g.bind(null,{subjectId:p,subjectName:"control",subjectType:m,action:d})});return}case O.openURI.trim().toLowerCase():{S(w.args.isDetachContainer,v.bind(null,{subjectId:p,subjectName:"control"})),L(),w.args.shouldOpenNow?I({subjectId:p,subjectName:"control",subjectType:m,action:w,payload:{URI:d.args.uri}}):(i.add({...V,action:I.bind(null,{subjectId:p,subjectName:"control",subjectType:m,action:w,payload:{URI:d.args.uri}})}),n==null||n());return}default:console.error("Unexpected control event"),t.emit(C.errors,new P(P.Severity.RECOVERABLE,P.Category.INTERACTIVES,{message:"Unexpected control event"}));return}},a=({action:d,container:{id:m,endTime:p},branches:E=[],isEOV:y=!1,autoSelected:S=!1})=>{const T=it(d,y),x={timestamp:!T.args.shouldOpenNow||y?1/0:p,priority:"container",initiator:m,actionType:T.type},w=t.emit.bind(t,C.interactives,{subjectId:m,subjectName:"container",type:j.actionChoice,actionType:T.type,payload:T.args});switch(T.type.trim().toLowerCase()){case O.setNextBranch.trim().toLowerCase():{const V=E.find(D=>D.id===T.args.branchId);if(!V)return;w(),i.add({...x,action:b.bind(null,{subjectId:m,subjectName:"container",action:T,payload:{chapterId:V.chapterId,autoSelect:S}})}),n==null||n();return}case O.setMaxWeightBranch.trim().toLowerCase():return;case O.setMinWeightBranch.trim().toLowerCase():return;case O.setRandomBranch.trim().toLowerCase():return;case O.setWeightlessRandomBranch.trim().toLowerCase():return;case O.continuePlayback.trim().toLowerCase():{w(),i.add({...x,action:g.bind(null,{subjectId:m,subjectName:"container",action:T})});return}case O.openURI.trim().toLowerCase():{w(),i.add({...x,action:I.bind(null,{subjectId:m,subjectName:"container",action:T,payload:{URI:d.args.uri}})}),n==null||n();return}default:console.error("Unexpected container event"),t.emit(C.errors,new P(P.Severity.RECOVERABLE,P.Category.INTERACTIVES,{message:"Unexpected container event"}));return}};function l({container:d,branches:m,isEOV:p=!1}){const E=ai(d.events);if(E){const y=it(E.action,p);t.emit(C.interactives,{subjectId:d.id,subjectName:"container",type:j.actionChoice,actionType:y.type,payload:y.args}),i.add({timestamp:p?1/0:d.endTime,priority:"container",initiator:d.id,actionType:O.expect,action:f.bind(null,{subjectId:d.id,subjectName:"container"})}),r.isExpect=!0}else for(const y of d.events)a({action:y.action,container:d,branches:m,isEOV:p})}const h=({chapterId:d,action:m,branches:p=[]})=>{const E=t.emit.bind(t,C.interactives,{subjectId:d,subjectName:"chapter",type:j.actionChoice,actionType:m.type,payload:m.args});switch(m.type.trim().toLowerCase()){case O.setNextBranch.trim().toLowerCase():{const y=p.find(S=>S.id===m.args.branchId);return y!=null&&y.chapterId?(E(),b.bind(null,{subjectId:d,subjectName:"chapter",action:m,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case O.setWeightlessRandomBranch.trim().toLowerCase():{const y=jo(p);return y!=null&&y.chapterId?(E(),b.bind(null,{subjectId:d,subjectName:"chapter",action:m,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case O.setRandomBranch.trim().toLowerCase():{const y=xo(p);return y!=null&&y.chapterId?(E(),b.bind(null,{subjectId:d,subjectName:"chapter",action:m,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case O.setMaxWeightBranch.trim().toLowerCase():{const y=Ao(p);return y!=null&&y.chapterId?(E(),b.bind(null,{subjectId:d,subjectName:"chapter",action:m,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case O.setMinWeightBranch.trim().toLowerCase():{const y=Ro(p);return y!=null&&y.chapterId?(E(),b.bind(null,{subjectId:d,subjectName:"chapter",action:m,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case O.continuePlayback.trim().toLowerCase():return E(),g.bind(null,{subjectId:d,subjectName:"chapter",action:m});case O.openURI.trim().toLowerCase():return E(),I.bind(null,{subjectId:d,subjectName:"chapter",action:m,payload:{URI:m.args.uri}});default:console.error("Unexpected chapter event"),t.emit(C.errors,new P(P.Severity.RECOVERABLE,P.Category.INTERACTIVES,{message:"Unexpected chapter event"}));return}};function u(d){const m=ai(d.events);if(m){if(un(d))return;t.emit(C.interactives,{subjectId:d.id,subjectName:"chapter",type:j.actionChoice,actionType:m.action.type,payload:m.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:d.id,actionType:O.expect,action:f.bind(null,{subjectId:d.id,subjectName:"chapter"})})}else d.events.forEach(p=>{const E=h({chapterId:d.id,action:p.action,branches:d.branches});E&&i.add({timestamp:1/0,priority:"chapter",initiator:d.id,actionType:p.action.type,action:E})})}const f=({subjectId:d,subjectName:m,action:p})=>{var E;e.pause(),t.emit(C.interactives,{subjectId:d,subjectName:m,type:j.actionExecution,actionType:(E=p==null?void 0:p.type)!==null&&E!==void 0?E:O.expect})},v=({subjectId:d,subjectName:m})=>{e.info.isEnded$.getValue()?i.execEndOfVideo():e.play(),t.emit(C.interactives,{subjectId:d,subjectName:m,type:j.actionExecution,actionType:"after-expect"})},g=({subjectId:d,subjectName:m,subjectType:p,action:E})=>{t.emit(C.interactives,{subjectId:d,subjectName:m,subjectType:p,type:j.actionExecution,actionType:E.type})},b=({subjectId:d,subjectName:m,subjectType:p,action:E,payload:y})=>{y.behaviour="change-chapter",t.emit(C.interactives,{subjectId:d,subjectName:m,subjectType:p,type:j.actionExecution,actionType:E.type,payload:y})},I=({subjectId:d,subjectName:m,subjectType:p,action:E,payload:y})=>{if(!y.URI)return;const S=window.open(y.URI,"_blank","noopener,noreferrer");S&&(S.opener=null),t.emit(C.interactives,{subjectId:d,subjectName:m,subjectType:p,type:j.actionExecution,actionType:E.type})};return{onControlEvent:c,onContainerEvent:a,onChapterEvent:h,onExpectEvent:f,expectEventHandler:v,setManifestChapterEvents:u,setManifestContainerEvents:l,stopExpect:s,state:r}};var me,vn,ct,di;class Q{constructor(e,i,n,r){this.target=e,this.type=i,this.listener=n,this.options=o(Q,me,"m",vn).call(Q,e,r),this.target.addEventListener(i,n,this.options)}unlisten(){this.target.removeEventListener(this.type,this.listener,this.options),this.target=null,this.listener=null,this.options=!1}}me=Q,vn=function(e,i){if(i===void 0)return!1;if(typeof i=="boolean")return i;{const n=new Set(["passive","capture"]),r=Object.keys(i).filter(c=>!n.has(c));return r.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+r.join(",")),o(Q,me,"m",di).call(Q,e)?i:i.capture||!1}},di=function(e){let i=o(Q,me,"f",ct);if(i===void 0){i=!1;try{const n={},r={get:()=>(i=!0,!1)};Object.defineProperty(n,"passive",r),Object.defineProperty(n,"capture",r);const s=()=>{};e.addEventListener("test",s,n),e.removeEventListener("test",s,n)}catch(n){i=!1}_(Q,me,i,"f",ct)}return i||!1};ct={value:void 0};class Po{constructor(){this.bindingMap=new $o}release(){this.removeAll(),this.bindingMap=null}listen(e,i,n,r){if(!this.bindingMap)return;const s=new Q(e,i,n,r);this.bindingMap.push(i,s)}listenOnce(e,i,n,r){const s=c=>{this.unlisten(e,i,s),n(c)};this.listen(e,i,s,r)}unlisten(e,i,n){if(!this.bindingMap)return;const r=this.bindingMap.get(i)||[];for(const s of r)s.target===e&&(n===s.listener||!n)&&(s.unlisten(),this.bindingMap.remove(i,s))}removeAll(){if(!this.bindingMap)return;const e=this.bindingMap.getAll();for(const i of e)i.unlisten();this.bindingMap.clear()}}class Lo{constructor(){this._prevSizeId=0,this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))===null||e===void 0||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var e;const i=(e=this.rootElement.getContext("2d"))===null||e===void 0?void 0:e.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!i)return!1;const n=i.data,r=n.length;for(let s=3;s<r;s+=40)if(n[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===void 0||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}async updateCanvasDimensions(e,i=!1){const n=e.width+e.height;if(this._prevSizeId===n)return;let r;i&&(r=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,i&&r&&this.restore(r),this._prevSizeId=n}async save(){const e=this.rootElement.toDataURL("image/jpeg",1),i=new Image;return i.crossOrigin="anonymous",i.src=e,await i.decode(),i}restore(e){var i;this.rootElement&&((i=this.rootElement.getContext("2d"))===null||i===void 0||i.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}}class No{constructor({parentElement:e,endOffsetMs:i=250,onError:n}){this.currentVideoDurationMs=1/0,this._containerTimeFrameShouldReceived=!1,this._endTimeFrameReceived=!1,this._shouldCallSkip=!1,this.onEachTick=r=>{const s=r!=null?r:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,c=this.isChapterEndTime(s);if(this.isContainerTime(s))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(c)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 bn=Object.create;var St=Object.defineProperty;var En=Object.getOwnPropertyDescriptor;var Cn=Object.getOwnPropertyNames;var wn=Object.getPrototypeOf,_n=Object.prototype.hasOwnProperty;var In=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Cn(e))!_n.call(t,r)&&r!==i&&St(t,r,{get:()=>e[r],enumerable:!(n=En(e,r))||n.enumerable});return t};var Sn=(t,e,i)=>(i=t!=null?bn(wn(t)):{},In(e||!t||!t.__esModule?St(i,"default",{value:t,enumerable:!0}):i,t));var k=require("@vkontakte/videoplayer-shared/es2018.cjs.js"),Tn=require("uuid"),$n=require("@vkontakte/videoplayer-core/es2018.cjs.js");const On="1.0.7-dev.6643328a.0";function pi(t,e=1){let i="0",n="0",r="0";return t.length===4?(i="0x"+t[1]+t[1],n="0x"+t[2]+t[2],r="0x"+t[3]+t[3]):t.length===7&&(i="0x"+t[1]+t[2],n="0x"+t[3]+t[4],r="0x"+t[5]+t[6]),`rgba(${+i},${+n},${+r},${e})`}const G="SDK_NAME",Rn="SDK_NAME-controls-container",mi=()=>document.querySelector(`.${Rn}`),An=.4,q={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},Tt={top:"flex-start",bottom:"flex-end",center:"center"},$t={start:"flex-start",end:"flex-end",center:"center"},Ot={start:"left",end:"right",center:"center"},yi=({target:t,props:e})=>{var i,n,r,s,c,a;t.style.alignItems=(n=Tt[(i=e==null?void 0:e.text)===null||i===void 0?void 0:i.gravityVertical])!==null&&n!==void 0?n:Tt.center,t.style.justifyContent=(s=$t[(r=e==null?void 0:e.text)===null||r===void 0?void 0:r.gravityHorizontal])!==null&&s!==void 0?s:$t.center,t.style.textAlign=(a=Ot[(c=e==null?void 0:e.text)===null||c===void 0?void 0:c.alignment])!==null&&a!==void 0?a:Ot.start},gi=({target:t,props:e,fallback:i,dependsOn:n})=>{var r,s,c,a,l,h;t.style.color=(s=(r=e==null?void 0:e.text)===null||r===void 0?void 0:r.color)!==null&&s!==void 0?s:i.textColor,t.style.fontSize=`calc(${n.height} * ${(a=(c=e==null?void 0:e.text)===null||c===void 0?void 0:c.size)!==null&&a!==void 0?a:i.textSize})`,t.textContent=(h=(l=e==null?void 0:e.text)===null||l===void 0?void 0:l.value)!==null&&h!==void 0?h:i.textContent},bi=({target:t,props:e,fallback:i})=>{var n,r,s,c;t.style.backgroundColor=pi((r=(n=e==null?void 0:e.background)===null||n===void 0?void 0:n.color)!==null&&r!==void 0?r:i.backgroundColor,(c=(s=e==null?void 0:e.background)===null||s===void 0?void 0:s.alpha)!==null&&c!==void 0?c:i.backgroundAlpha)},Ei=({target:t,props:e,fallback:i,dependsOn:n})=>{var r,s,c,a,l,h,u,f,v,g,b;t.style.border=`calc(${n.height} * ${(c=(s=(r=e==null?void 0:e.shape)===null||r===void 0?void 0:r.border)===null||s===void 0?void 0:s.width)!==null&&c!==void 0?c:i.borderWidth}) solid ${pi((h=(l=(a=e==null?void 0:e.shape)===null||a===void 0?void 0:a.border)===null||l===void 0?void 0:l.color)!==null&&h!==void 0?h:i.borderColor,(v=(f=(u=e==null?void 0:e.shape)===null||u===void 0?void 0:u.border)===null||f===void 0?void 0:f.alpha)!==null&&v!==void 0?v:i.borderAlpha)}`,t.style.borderRadius=`calc(${n.height} * ${(b=(g=e==null?void 0:e.shape)===null||g===void 0?void 0:g.roundCorners)!==null&&b!==void 0?b:i.roundCorners})`},ft=({target:t,layoutParams:e,fallback:i})=>{var n;t.style.transform=`rotate(${(n=-e.angle)!==null&&n!==void 0?n:i.angle}rad)`};class vt{constructor(e){this.control=e}createView(e){var i;const n=document.createElement("div");n.classList.add(`${G}-control-container-${this.control.id}`),e(n,this.control.layoutParams);const r=((i=this.control.layoutParams.innerSizesDependOn)!==null&&i!==void 0?i:q.innerSizesDependOn)==="self"?{height:n.style.height,width:n.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:n,dependsOn:r}}setEvents(e,i){e&&this.control.events.forEach(n=>{switch(n.type.trim().toLowerCase()){case"onclick":e.addEventListener("click",s=>{s.stopPropagation(),i&&i({action:n.action,controlId:this.control.id,controlType:this.control.type})});break}})}getElement(){return document.querySelector(`.${G}-control-container-${this.control.id}`)}}const Ci=t=>{if(t.type.trim().toLowerCase()==="area")return new jn(t)};class jn extends vt{constructor(e){super(e)}createView({parent:e,layoutFn:i}){const{dependsOn:n,controlContainerEl:r}=super.createView(i),s=document.createElement("button");return s.classList.add(`${G}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.type="button",bi({target:s,props:this.control.props,fallback:{...q,backgroundColor:"transparent"}}),Ei({target:s,props:this.control.props,fallback:{...q,borderAlpha:0},dependsOn:n}),ft({target:s,layoutParams:this.control.layoutParams,fallback:q}),r.append(s),e.append(r),r}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}}const wi=t=>{if(t.type.trim().toLowerCase()==="button")return new xn(t)};class xn extends vt{constructor(e){super(e)}createView({parent:e,layoutFn:i}){const{dependsOn:n,controlContainerEl:r}=super.createView(i),s=document.createElement("button");s.type="button",s.classList.add(`${G}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.style.fontFamily="inherit";const c=document.createElement("span");return c.style.display="inline-block",c.style.whiteSpace="pre",c.style.overflow="hidden",c.style.textOverflow="ellipsis",ft({target:s,layoutParams:this.control.layoutParams,fallback:q}),bi({target:s,props:this.control.props,fallback:q}),Ei({target:s,props:this.control.props,fallback:q,dependsOn:n}),yi({target:s,props:this.control.props}),gi({target:c,props:this.control.props,fallback:q,dependsOn:n}),s.append(c),r.append(s),e.append(r),r}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}}const Pn=t=>{if(t.type.trim().toLowerCase()==="text")return new Ln(t)};class Ln extends vt{constructor(e){super(e)}createView({parent:e,layoutFn:i}){const{dependsOn:n,controlContainerEl:r}=super.createView(i),s=document.createElement("div");s.classList.add(`${G}-${this.control.id}`),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.fontFamily="inherit";const c=document.createElement("span");return c.style.whiteSpace="pre",ft({target:s,layoutParams:this.control.layoutParams,fallback:q}),yi({target:s,props:this.control.props}),gi({target:c,props:this.control.props,fallback:q,dependsOn:n}),s.append(c),r.append(s),e.append(r),r}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}}class Nn{constructor(e){this.layout=e}}const Mn=t=>{if(t.type.trim().toLowerCase()==="relative")return new _i(t)};class _i extends Nn{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,i){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${i.width})`,e.style.height=`calc(var(--interactive-content-height) * ${i.height})`,e.style.left=`calc(var(--interactive-content-width) * ${i.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${i.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}}function o(t,e,i,n){if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?n:i==="a"?n.call(t):n?n.value:e.get(t)}function _(t,e,i,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(t,i):r?r.value=i:e.set(t,i),i}var he,Le,Rt;class Ii{constructor(e){he.add(this),this.container=e,this.factories=new Map,o(this,he,"m",Le).call(this)}addControlFactory(e,i){this.factories.set(e.trim().toLowerCase(),i),o(this,he,"m",Le).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),o(this,he,"m",Le).call(this)}}he=new WeakSet,Le=function(){this.controls=o(this,he,"m",Rt).call(this)},Rt=function(){var e;return(e=this.container.controls)===null||e===void 0?void 0:e.reduce((i,n)=>{const r=n.type.trim().toLowerCase(),s=this.factories.get(r);return s?[...i,s(n)]:[...i]},[])};const Si=(t,e)=>{if(t.type.trim().toLowerCase()==="choice")return new Vn(t,e)};class Vn extends Ii{constructor(e,i){super(e),this.rootElement=i!=null?i:mi(),this.layout=new _i(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",wi),this.addControlFactory("text",Pn),this.addControlFactory("area",Ci)}createView(e){const i=document.createElement("div");return i.classList.add(`${G}-${this.container.id}`),this.layout.setContainerLayout(i),this.controls.forEach(n=>{const r=n.createView({parent:i,layoutFn:this.layout.setControlLayout});n.setEvents(r,e)}),this.rootElement.append(i),this.isRemoved=!1,i}hide(){const e=this.getElement();e&&(e.style.visibility="hidden")}show(){const e=this.getElement();e&&(e.style.visibility="visible")}enable(){const e=this.getElement();e&&(e.style.opacity=1,this.isDisabled=!1)}disable(){const e=this.getElement();e&&(e.style.opacity=An,this.isDisabled=!0)}removeView(){var e;this.isRemoved||((e=this.getElement())===null||e===void 0||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${G}-${this.container.id}`)}}var We=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Fn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var $e=function(t){return t&&t.Math==Math&&t},J=$e(typeof globalThis=="object"&&globalThis)||$e(typeof window=="object"&&window)||$e(typeof self=="object"&&self)||$e(typeof We=="object"&&We)||function(){return this}()||We||Function("return this")(),re=function(t){try{return!!t()}catch(e){return!0}},kn=re,Be=!kn(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")}),Bn=Be,Ti=Function.prototype,At=Ti.apply,jt=Ti.call,Dn=typeof Reflect=="object"&&Reflect.apply||(Bn?jt.bind(At):function(){return jt.apply(At,arguments)}),$i=Be,Oi=Function.prototype,nt=Oi.call,Wn=$i&&Oi.bind.bind(nt,nt),ve=$i?Wn:function(t){return function(){return nt.apply(t,arguments)}},Ri=ve,Un=Ri({}.toString),Gn=Ri("".slice),Ai=function(t){return Gn(Un(t),8,-1)},zn=Ai,Hn=ve,ji=function(t){if(zn(t)==="Function")return Hn(t)},rt=typeof document=="object"&&document.all,qn=typeof rt=="undefined"&&rt!==void 0,xi={all:rt,IS_HTMLDDA:qn},Pi=xi,Kn=Pi.all,se=Pi.IS_HTMLDDA?function(t){return typeof t=="function"||t===Kn}:function(t){return typeof t=="function"},Li={},Qn=re,we=!Qn(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Yn=Be,Oe=Function.prototype.call,pt=Yn?Oe.bind(Oe):function(){return Oe.apply(Oe,arguments)},Ni={},Mi={}.propertyIsEnumerable,Vi=Object.getOwnPropertyDescriptor,Xn=Vi&&!Mi.call({1:2},1);Ni.f=Xn?function(e){var i=Vi(this,e);return!!i&&i.enumerable}:Mi;var Fi=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}},Zn=ve,Jn=re,er=Ai,Ue=Object,tr=Zn("".split),ir=Jn(function(){return!Ue("z").propertyIsEnumerable(0)})?function(t){return er(t)=="String"?tr(t,""):Ue(t)}:Ue,ki=function(t){return t==null},nr=ki,rr=TypeError,Bi=function(t){if(nr(t))throw rr("Can't call method on "+t);return t},sr=ir,ar=Bi,or=function(t){return sr(ar(t))},xt=se,Di=xi,lr=Di.all,De=Di.IS_HTMLDDA?function(t){return typeof t=="object"?t!==null:xt(t)||t===lr}:function(t){return typeof t=="object"?t!==null:xt(t)},Wi={},Ge=Wi,ze=J,cr=se,Pt=function(t){return cr(t)?t:void 0},Ui=function(t,e){return arguments.length<2?Pt(Ge[t])||Pt(ze[t]):Ge[t]&&Ge[t][e]||ze[t]&&ze[t][e]},hr=ve,dr=hr({}.isPrototypeOf),ur=typeof navigator!="undefined"&&String(navigator.userAgent)||"",Gi=J,He=ur,Lt=Gi.process,Nt=Gi.Deno,Mt=Lt&&Lt.versions||Nt&&Nt.version,Vt=Mt&&Mt.v8,U,Ve;Vt&&(U=Vt.split("."),Ve=U[0]>0&&U[0]<4?1:+(U[0]+U[1]));!Ve&&He&&(U=He.match(/Edge\/(\d+)/),(!U||U[1]>=74)&&(U=He.match(/Chrome\/(\d+)/),U&&(Ve=+U[1])));var fr=Ve,Ft=fr,vr=re,pr=J,mr=pr.String,zi=!!Object.getOwnPropertySymbols&&!vr(function(){var t=Symbol();return!mr(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&Ft&&Ft<41}),yr=zi,Hi=yr&&!Symbol.sham&&typeof Symbol.iterator=="symbol",gr=Ui,br=se,Er=dr,Cr=Hi,wr=Object,qi=Cr?function(t){return typeof t=="symbol"}:function(t){var e=gr("Symbol");return br(e)&&Er(e.prototype,wr(t))},_r=String,Ir=function(t){try{return _r(t)}catch(e){return"Object"}},Sr=se,Tr=Ir,$r=TypeError,Ki=function(t){if(Sr(t))return t;throw $r(Tr(t)+" is not a function")},Or=Ki,Rr=ki,Ar=function(t,e){var i=t[e];return Rr(i)?void 0:Or(i)},qe=pt,Ke=se,Qe=De,jr=TypeError,xr=function(t,e){var i,n;if(e==="string"&&Ke(i=t.toString)&&!Qe(n=qe(i,t))||Ke(i=t.valueOf)&&!Qe(n=qe(i,t))||e!=="string"&&Ke(i=t.toString)&&!Qe(n=qe(i,t)))return n;throw jr("Can't convert object to primitive value")},Qi={exports:{}},kt=J,Pr=Object.defineProperty,Lr=function(t,e){try{Pr(kt,t,{value:e,configurable:!0,writable:!0})}catch(i){kt[t]=e}return e},Nr=J,Mr=Lr,Bt="__core-js_shared__",Vr=Nr[Bt]||Mr(Bt,{}),Fr=Vr,Dt=Fr;(Qi.exports=function(t,e){return Dt[t]||(Dt[t]=e!==void 0?e:{})})("versions",[]).push({version:"3.31.0",mode:"pure",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"});var kr=Qi.exports,Br=Bi,Dr=Object,Yi=function(t){return Dr(Br(t))},Wr=ve,Ur=Yi,Gr=Wr({}.hasOwnProperty),mt=Object.hasOwn||function(e,i){return Gr(Ur(e),i)},zr=ve,Hr=0,qr=Math.random(),Kr=zr(1 .toString),Qr=function(t){return"Symbol("+(t===void 0?"":t)+")_"+Kr(++Hr+qr,36)},Yr=J,Xr=kr,Wt=mt,Zr=Qr,Jr=zi,es=Hi,de=Yr.Symbol,Ye=Xr("wks"),ts=es?de.for||de:de&&de.withoutSetter||Zr,is=function(t){return Wt(Ye,t)||(Ye[t]=Jr&&Wt(de,t)?de[t]:ts("Symbol."+t)),Ye[t]},ns=pt,Ut=De,Gt=qi,rs=Ar,ss=xr,as=is,os=TypeError,ls=as("toPrimitive"),cs=function(t,e){if(!Ut(t)||Gt(t))return t;var i=rs(t,ls),n;if(i){if(e===void 0&&(e="default"),n=ns(i,t,e),!Ut(n)||Gt(n))return n;throw os("Can't convert object to primitive value")}return e===void 0&&(e="number"),ss(t,e)},hs=cs,ds=qi,Xi=function(t){var e=hs(t,"string");return ds(e)?e:e+""},us=J,zt=De,st=us.document,fs=zt(st)&&zt(st.createElement),vs=function(t){return fs?st.createElement(t):{}},ps=we,ms=re,ys=vs,Zi=!ps&&!ms(function(){return Object.defineProperty(ys("div"),"a",{get:function(){return 7}}).a!=7}),gs=we,bs=pt,Es=Ni,Cs=Fi,ws=or,_s=Xi,Is=mt,Ss=Zi,Ht=Object.getOwnPropertyDescriptor;Li.f=gs?Ht:function(e,i){if(e=ws(e),i=_s(i),Ss)try{return Ht(e,i)}catch(n){}if(Is(e,i))return Cs(!bs(Es.f,e,i),e[i])};var Ts=re,$s=se,Os=/#|\.prototype\./,_e=function(t,e){var i=As[Rs(t)];return i==xs?!0:i==js?!1:$s(e)?Ts(e):!!e},Rs=_e.normalize=function(t){return String(t).replace(Os,".").toLowerCase()},As=_e.data={},js=_e.NATIVE="N",xs=_e.POLYFILL="P",Ps=_e,qt=ji,Ls=Ki,Ns=Be,Ms=qt(qt.bind),Vs=function(t,e){return Ls(t),e===void 0?t:Ns?Ms(t,e):function(){return t.apply(e,arguments)}},Ji={},Fs=we,ks=re,Bs=Fs&&ks(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),Ds=De,Ws=String,Us=TypeError,Gs=function(t){if(Ds(t))return t;throw Us(Ws(t)+" is not an object")},zs=we,Hs=Zi,qs=Bs,Re=Gs,Kt=Xi,Ks=TypeError,Xe=Object.defineProperty,Qs=Object.getOwnPropertyDescriptor,Ze="enumerable",Je="configurable",et="writable";Ji.f=zs?qs?function(e,i,n){if(Re(e),i=Kt(i),Re(n),typeof e=="function"&&i==="prototype"&&"value"in n&&et in n&&!n[et]){var r=Qs(e,i);r&&r[et]&&(e[i]=n.value,n={configurable:Je in n?n[Je]:r[Je],enumerable:Ze in n?n[Ze]:r[Ze],writable:!1})}return Xe(e,i,n)}:Xe:function(e,i,n){if(Re(e),i=Kt(i),Re(n),Hs)try{return Xe(e,i,n)}catch(r){}if("get"in n||"set"in n)throw Ks("Accessors not supported");return"value"in n&&(e[i]=n.value),e};var Ys=we,Xs=Ji,Zs=Fi,Js=Ys?function(t,e,i){return Xs.f(t,e,Zs(1,i))}:function(t,e,i){return t[e]=i,t},Ae=J,ea=Dn,ta=ji,ia=se,na=Li.f,ra=Ps,le=Wi,sa=Vs,ce=Js,Qt=mt,aa=function(t){var e=function(i,n,r){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(i);case 2:return new t(i,n)}return new t(i,n,r)}return ea(t,this,arguments)};return e.prototype=t.prototype,e},oa=function(t,e){var i=t.target,n=t.global,r=t.stat,s=t.proto,c=n?Ae:r?Ae[i]:(Ae[i]||{}).prototype,a=n?le:le[i]||ce(le,i,{})[i],l=a.prototype,h,u,f,v,g,b,I,d,m;for(v in e)h=ra(n?v:i+(r?".":"#")+v,t.forced),u=!h&&c&&Qt(c,v),b=a[v],u&&(t.dontCallGetSet?(m=na(c,v),I=m&&m.value):I=c[v]),g=u&&I?I:e[v],!(u&&typeof b==typeof g)&&(t.bind&&u?d=sa(g,Ae):t.wrap&&u?d=aa(g):s&&ia(g)?d=ta(g):d=g,(t.sham||g&&g.sham||b&&b.sham)&&ce(d,"sham",!0),ce(a,v,d),s&&(f=i+"Prototype",Qt(le,f)||ce(le,f,{}),ce(le[f],v,g),t.real&&l&&(h||!l[v])&&ce(l,v,g)))},la=Math.ceil,ca=Math.floor,ha=Math.trunc||function(e){var i=+e;return(i>0?ca:la)(i)},da=ha,en=function(t){var e=+t;return e!==e||e===0?0:da(e)},ua=en,fa=Math.min,va=function(t){return t>0?fa(ua(t),9007199254740991):0},pa=va,ma=function(t){return pa(t.length)},ya=oa,ga=Yi,ba=ma,Ea=en;ya({target:"Array",proto:!0},{at:function(e){var i=ga(this),n=ba(i),r=Ea(e),s=r>=0?r:n+r;return s<0||s>=n?void 0:i[s]}});var Ca=Ui,wa=Ca,_a=wa,Ia=_a("Array","at"),Sa=Ia,Ta=Sa,$a=Ta,Oa=$a,tn=Fn(Oa);function nn(t,e){let i;return(...n)=>{clearTimeout(i),i=setTimeout(()=>t(...n),e)}}const Ie={Object:"Object",String:"String",Array:"Array",Number:"Number",Function:"Function",Boolean:"Boolean"},pe=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,yt=t=>pe(t,Ie.Object),at=t=>pe(t,Ie.String),gt=t=>pe(t,Ie.Array),rn=t=>pe(t,Ie.Number),Ra=t=>pe(t,Ie.Function),Yt=t=>rn(t)&&!isNaN(t),be=t=>yt(t)&&Object.keys(t).length===0,bt=t=>gt(t)&&!t.length,je=(t,e)=>at(t)&&(e?t.trim():t).length,sn=window.navigator.userAgent.toLowerCase(),Aa=/mobi/i.test(sn);sn.indexOf("android")>-1;const ja="video_interactive",xa="videoint",Pa=250;class La{constructor(e){this.onResize=i=>{this.isReady&&(!i[0].contentRect.width||!i[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:i[0].contentRect.width,height:i[0].contentRect.height}))},this.handleChapterChange=i=>{var n;if(this.isReady){if(this.isHidden||this.hide(),!(i!=null&&i.id)){(n=this.onError)===null||n===void 0||n.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(i.id),this.ngEditor.selectChapter(i.id),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=i.id,this.lastZoomInfo=void 0}},this.handleManifestChange=async(i,n=[])=>{var r;if(!rn(i.graph.edit.chapters[0].x)){this.isReady=!1,(r=this.onError)===null||r===void 0||r.call(this,"Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=void 0,!this.ngEditor){let s;try{s=await k.loadVKLangPack(this.lang,ja,xa)}catch(a){console.log("Unable to load graph language pack")}const{GraphEditor:c}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new c(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:s}),this.ngEditor.on("control",({name:a,chapterId:l})=>{a==="openPreview"&&this.onOpenPreviewClick(l)}),this.ngEditor.on("zoomEnd",a=>{this.lastZoomInfo={...a}})}this.visitedChapterIds=new Set(n),i.metadata.id!==this.currentManifestId?(this.ngEditor.update(i),this.currentManifestId=i.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0},this.init(e)}init({root:e,onOpenPreviewClick:i,onError:n,lang:r,visitedChapters:s=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=i,this.onError=n,this.lang=r!=null?r:"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=Na(e),this.resizeObserver=new ResizeObserver(nn(this.onResize,Pa)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor.updateVideosInfo(e)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,i;this.hide(),this.resizeObserver.disconnect(),(e=this.ngEditor)===null||e===void 0||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(i=this.ngEditor)===null||i===void 0||i.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}}function Na(t){const 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",t.append(e),e}const Ce=(t="",e="")=>{t=t.split("."),e=e.split(".");let i=0;for(let n=0;n<Math.max(t.length,e.length)&&!i;n++)t[n]>e[n]?i=1:t[n]<e[n]?i=-1:i=0;return i},Ma="3.1",Xt={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},Va={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Fa=t=>{const e=[];for(const i of t.chapters){let n;const r=[];for(const{isDefault:a,...l}of i.branches)a&&(n=l.id),r.push(l);let s=[];const c=[];for(const{fallbackStrategy:a,...l}of i.containers){const h=!!l.endTime;let u=[Va];switch(a){case"await":h?u=[]:s=[];break;case"default":{const f={type:"onSuspense",action:{type:Xt.default,args:{branchId:n,shouldOpenNow:!h,isDetachContainer:!0}}};h?u=[f]:s=[f];break}case"random":case"weightlessRandom":case"max":case"min":{const f={type:"onSuspense",action:{type:Xt[a],args:{}}};h?u=[f]:s=[f];break}}for(const f of l.controls)c.push({...l,controls:[{...f}],id:Tn.v4(),events:u})}e.push({...i,containers:c,events:s,branches:r})}return t.metadata.version=Ma,t.metadata.updated=new Date().toISOString(),{...t,chapters:e}},ka="3.2",Ba=t=>{if(!t.media){const{media:e,...i}=t.metadata;return{...t,metadata:{...i,version:ka},media:e}}return t},Da="3.3",Wa=(t=[])=>({edit:{chapters:t},view:{}}),Zt={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ua=t=>{var e;const i=[],n=[];for(const r of t.chapters){const{id:s,x:c,y:a,...l}=r,h=l.containers.map(u=>{var f;return{...u,controls:u.controls.map(({subtype:v,type:g,...b})=>({...b,type:v!=null?v:g})),events:!((f=u.events)===null||f===void 0)&&f.length?u.events:[Zt]}});i.push({id:s,...l,containers:h,events:!((e=l.events)===null||e===void 0)&&e.length?l.events:[Zt]}),n.push({id:s,x:c,y:a})}return{...t,chapters:i,graph:Wa(n),metadata:{...t.metadata,version:Da}}},Ga=[{version:"3.0",migrate:Fa},{version:"3.1",migrate:Ba},{version:"3.2",migrate:Ua}],za=t=>Ga.reduce((e,i)=>Ce(e.metadata.version,i.version)?e:i.migrate(e),t),Ha=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),O=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"});exports.INTERACTIVE_CLICK_ACTIONS=void 0;(function(t){t.GO_NEXT_BUTTON="GO_NEXT_BUTTON",t.GO_NEXT_AREA="GO_NEXT_AREA",t.WATCH_AGAIN="WATCH_AGAIN",t.OPEN_GRAPH="OPEN_GRAPH",t.CLOSE_GRAPH="CLOSE_GRAPH"})(exports.INTERACTIVE_CLICK_ACTIONS||(exports.INTERACTIVE_CLICK_ACTIONS={}));const Jt={metadata:"Object",chapters:"Array"},qa="3.0.0",Ka="3.3.0",Et=t=>{const e=Ce(t,qa);return e===-1?!1:e===0?!0:Ce(t,Ka)!==1},Qa=t=>{if(!yt(t))return!1;for(const e in Jt)if(!t[e]||!pe(t[e],Jt[e]))return!1;return Et(t.metadata.version)},an=t=>t.type===Ha.Text;class P{constructor(e,i,...n){this.severity=e,this.category=i,this.data=n}toString(){return`SDK_NAME ERROR ${JSON.stringify(this,null," ")}`}}P.Severity={RECOVERABLE:1,CRITICAL:2};P.Category={VIDEO:0,INTERACTIVES:1,GRAPH:2,MANIFEST:3,LOADERS:4,HISTORY:5,SEAMLESS:6};class on{constructor(){this.listeners={}}addListener(e,i){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(i),this}on(e,i){return this.addListener(e,i)}once(e,i){this.listeners[e]=this.listeners[e]||[];const n=()=>{i(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,i){return this.removeListener(e,i)}reset(){this.listeners={}}removeListener(e,i){const n=this.listeners[e];if(!n)return this;for(let r=n.length;r>0;r--)if(n[r]===i){n.splice(r,1);break}return this}emit(e,...i){const n=this.listeners[e];return n?(n.forEach(r=>{r(...i)}),!0):!1}listenerCount(e){return(this.listeners[e]||[]).length}rawListeners(e){return this.listeners[e]}}class Ya{constructor(e){this.addFn=(i,n=!1)=>{Ra(i)&&(this.fns.push(i),n&&this.updateFn())},this.removeFn=(i,n=!1)=>{this.fns=this.fns.filter(r=>r!==i),n&&this.updateFn()},this.updateFn=()=>{this.fn=()=>{this.fns.forEach(i=>i()),this.raf&&this.forceRequestAnimation()}},this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))},this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()},this.cancelAnimation=()=>{cancelAnimationFrame(this.raf),this.raf=void 0},this.raf,this.fn,this.fns=[],this.addFn(e)}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}}class Xa{constructor(e){var i,n;this.loaders={chapterLoaders:(i=e==null?void 0:e.chapterLoaders)!==null&&i!==void 0?i:[],manifestLoaders:(n=e==null?void 0:e.manifestLoaders)!==null&&n!==void 0?n:[]}}async exec(e,i){return Za(...this.loaders[e])(i)}}function Za(...t){return async function(i){const n=[...t];for(;n.length>0;)i=await n.shift()(i);return i}}function Fe(t,e,i){return t?{...t,[e]:t[e]?[i,...t[e]]:[i]}:{[e]:[i]}}function ot({actions:t,errors:e,chapterId:i,...n}){if(i){const r=t.getManifest(),s=t.getChapter(r.chapters,i);if(s){const c=t.getMedia(r.media,s.videoId),a=t.getGraph(r.graph,s.id);return c?{...n,actions:t,errors:e,result:{chapter:s,media:c,graph:a}}:{...n,errors:Fe(e,ot.name,"Could not find media"),actions:t}}}return{...n,errors:Fe(e,ot.name,"Could not find chapter"),actions:t}}class ei{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,i,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:i,options:n})}removeEventListener(e,i){if(!(e in this.listeners))return;const n=this.listeners[e];for(let r=0,s=n.length;r<s;r++)if(n[r].callback===i){n.splice(r,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;const n=this.listeners[e.type].slice();for(let r=0,s=n.length;r<s;r++){const c=n[r];try{c.callback.call(this,e)}catch(a){Promise.resolve().then(()=>{throw a})}c.options&&c.options.once&&this.removeEventListener(e.type,c.callback)}return!e.defaultPrevented}}class ln extends ei{constructor(){super(),this.listeners||ei.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)}}class Ja{constructor(){Object.defineProperty(this,"signal",{value:new ln,writable:!0,configurable:!0})}abort(e){let i;try{i=new Event("abort")}catch(r){typeof document!="undefined"?document.createEvent?(i=document.createEvent("Event"),i.initEvent("abort",!1,!1)):(i=document.createEventObject(),i.type="abort"):i={type:"abort",bubbles:!1,cancelable:!1}}let n=e;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(r){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(i)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(Ja.prototype[Symbol.toStringTag]="AbortController",ln.prototype[Symbol.toStringTag]="AbortSignal");function cn(t){return t.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL?(console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill"),!0):typeof t.Request=="function"&&!t.Request.prototype.hasOwnProperty("signal")||!t.AbortController}function eo(t){typeof t=="function"&&(t={fetch:t});const{fetch:e,Request:i=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r=!1}=t;if(!cn({fetch:e,Request:i,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:r}))return{fetch:e,Request:s};let s=i;(s&&!s.prototype.hasOwnProperty("signal")||r)&&(s=function(h,u){let f;u&&u.signal&&(f=u.signal,delete u.signal);const v=new i(h,u);return f&&Object.defineProperty(v,"signal",{writable:!1,enumerable:!1,configurable:!0,value:f}),v},s.prototype=i.prototype);const c=e;return{fetch:(l,h)=>{const u=s&&s.prototype.isPrototypeOf(l)?l.signal:h?h.signal:void 0;if(u){let f;try{f=new DOMException("Aborted","AbortError")}catch(g){f=new Error("Aborted"),f.name="AbortError"}if(u.aborted)return Promise.reject(f);const v=new Promise((g,b)=>{u.addEventListener("abort",()=>b(f),{once:!0})});return h&&h.signal&&delete h.signal,Promise.race([v,c(l,h)])}return c(l,h)},Request:s}}const Ct=cn({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),hn=Ct?eo({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,ti=Ct?hn.fetch:window.fetch;Ct?hn.Request:window.Request;const to=async t=>{try{let e,i;if(yt(t))e=t;else if(at(t)){i=new URL(t).href;const r=await ti(i);if(!r.ok)return{};e=await r.json()}else return{};if(!Qa(e))return{};const n=e.metadata.media;if(at(n)&&!e.media)try{let r;i?r=new URL(n,i).href:(r=new URL(n).href,i=r);const s=await ti(r);if(!s.ok)throw new Error;e.metadata.media=await s.json()}catch(r){return so(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:i}}catch(e){return{}}};async function io(t){const{manifest:e,manifestURL:i}=await to(t),n=za(e);return n.media=no(n.media,i),delete n.metadata.media,n}function tt(t,e){return t.find(i=>i.id===e)}function ii(t,e){var i,n;return!((i=t.edit)===null||i===void 0)&&i.chapters?t.edit.chapters.find(r=>r.id===e):!((n=t.view)===null||n===void 0)&&n.chapters?t.view.chapters.find(r=>r.id===e):void 0}function ni(t,e){return t.videos.find(i=>i.id===e)}function no(t,e){return{...t,videos:t.videos.map(i=>({...i,variants:i.variants.map(n=>{const r=ro(n.url,e);return{...n,url:r||n.url}})}))}}function ro(t,e){try{return new URL(t,e).href}catch(i){return""}}function so(t){return Ce(t,"3.2.0")>=0}class dn extends Xa{constructor(e,i){super(e),this.onError=i,this.prevChapter$=new k.ValueSubject(null),this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(e){var i;this.release();const n=await this.exec("manifestLoaders",{actions:{addErrorMessage:Fe},result:null,errors:null,source:e});n.errors&&this.errorHandler(n.errors);const r=await io((i=n.result)!==null&&i!==void 0?i:e);return this.manifest=r,this}async setInitial(){return this.setNext()}async setNext(e=this.manifest.metadata.initChapterId){this.prevChapter$.next(this.chapter);const i=await this.exec("chapterLoaders",ot({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:ii,getChapter:tt,getMedia:ni,getByBranches:this.getByBranches.bind(this),addErrorMessage:Fe},result:null,errors:null,chapterId:e}));return i.errors&&this.errorHandler(i.errors),this.chapter=i.result.chapter,this.media=i.result.media,this.graph=i.result.graph,this}errorHandler(e){this.onError(e),console.error("Something went wrong with loaders",{errors:e})}getInitial(){return this.getByChapterId(this.manifest.metadata.initChapterId)||null}getByChapterId(e=this.manifest.metadata.initChapterId){const i=tt(this.manifest.chapters,e);if(i){const n=ni(this.manifest.media,i.videoId),r=ii(this.manifest.graph,i.id);if(n)return{chapter:i,media:n,graph:r}}return null}getBranches(e=this.chapter.id){if(e===this.chapter.id)return this.getByBranches(this.chapter.branches);{const i=tt(this.manifest.chapters,e);return this.getByBranches(i==null?void 0:i.branches)}}getByBranches(e=[]){return e.reduce((i,n)=>{const r=this.getByChapterId(n.chapterId);return r&&i.push(r),i},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}}const C={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyChanged:"history-changed"},lt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},j={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function ao(){const t=new Map;function e({listId:r=Math.random().toString(),itemId:s=Math.random().toString(),...c}){const a=t.get(r),l={...c};return a?a[s]=l:t.set(r,{[s]:l}),{listId:r,itemId:s,...c}}function i(r,s){var c,a,l;const h=t.get(r);if(h){if(s)return(c=h[s])===null||c===void 0||c.player.destroy(),(a=h[s])===null||a===void 0||a.container.remove(),(l=h[s])===null||l===void 0||l.subscription.unsubscribe(),delete h[s],Object.keys(h).length||t.delete(r),!0;for(const u of Object.values(h))u.player.destroy(),u.container.remove();return t.delete(r),!0}else throw Error("Can't remove. Not find.")}function n(){for(const r of t)i(r[0])}return{createPlayer:e,removePlayer:i,map:t,removeAll:n}}function ri(t,e=[]){var i,n,r;let s={},c;const a=!e.length;for(const l of t.variants)if(!c&&"cover"in l&&(c=l.cover),"url"in l)switch(l.type.toLowerCase()){case"mp4":(a||e.includes("mp4"))&&(s.MPEG={...s.MPEG,[(i=l.standard)!==null&&i!==void 0?i:"Invariant quality"]:l.url});break;case"mpeg":(a||e.includes("mpeg"))&&(s.MPEG={...s.MPEG,[(n=l.standard)!==null&&n!==void 0?n:"Invariant quality"]:l.url});break;case"hls":(a||e.includes("hls"))&&(s={...s,HLS:{type:"url",url:l.url}});break;case"dash":(a||e.includes("dash"))&&(s={...s,DASH_SEP:{compatibilityMode:!0,type:"url",url:l.url}});break}return{sources:s,thumbUrl:c,title:(r=t.title)!==null&&r!==void 0?r:""}}const xe=(t,e)=>{const i=t.info.currentQuality$.getValue(),n=t.info.availableQualities$.getValue();i!==e&&n.includes(e)&&(t.setQuality(e),t.setAutoQuality(!1))},oo=t=>{const e=t.variants.find(i=>{var n;return((n=i.payload)===null||n===void 0?void 0:n.type)==="vk"});if(e&&"payload"in e){const[i,n]=e.payload.id.split("_");return[i,n]}return[]},Ne={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},lo=2;function co(t){const e=ao();let i,n;const r=new on;let s={},c=!1,a=null,l=!1,h;t&&u(t);function u(p){a=p}function f(p,E,y){var S;if(!a)throw Error("need to set interactive controller");const x=((S=e.map.get(p))!==null&&S!==void 0?S:{})[E];if(x){s={chapterId:y,listId:p,itemId:E,...x};const w=s.player;n=w.info.currentQuality$.subscribe(V=>{if(!(!V||!w.info.position$.getValue())){i=V;for(const D of e.map)Object.values(D[1]).forEach(({player:L})=>{w.info.isAutoQualityEnabled$.getValue()||xe(L,V)})}}),x.container.remove(),c=!1,a.setPlayer(x.player),l||(a.init(),l=!0),r.emit(Ne.activePlayerChanged,{player:s.player,config:s.config});return}throw Error("Can't set. Not find.")}async function v(p,E,y){if(!a)throw Error("need to set interactive controller");if(be(s)||p!==s.itemId)return;if(y>=0&&!c){const T=a.getChapterBranches();c=!0;const x=new Set;for(const w of T)x.has(w.media.id)||(await b({media:w.media,chapterId:w.chapter.id,setAsActive:!1,title:w.chapter.label}),x.add(w.media.id))}}async function g({chapter:{id:p},media:E}){if(be(s))return;n==null||n.unsubscribe();const y=s.player.info.muted$.getValue(),S=s.player.info.currentQuality$.getValue(),T=s.player.info.isAutoQualityEnabled$.getValue(),x=s.player.info.volume$.getValue(),w=s.player.info.currentPlaybackRate$.getValue(),V=!T;let D=!1;for(const L of e.map)if(L[0]===E.id){const z=Object.keys(L[1]);for(const K of z)K===s.itemId?(z.length<lo||(D=!0),e.removePlayer(L[0],K)):(D=!0,f(L[0],K,p),V?xe(s.player,S):s.player.setAutoQuality(!0),s.player.setVolume(x),s.player.setMuted(y),s.player.setPlaybackRate(w))}else e.removePlayer(L[0]);D||(await b({media:E,chapterId:p,setAsActive:!0,playbackRate:w}),V?xe(s.player,S):s.player.setAutoQuality(!0),s.player.setVolume(x),s.player.setMuted(y))}async function b({media:p,chapterId:E,prefetch:y=!0,setAsActive:S=!0,autoplay:T=!1,preferredExt:x,title:w,playbackRate:V}){var D,L,z;const K=Math.random().toString(),ae=document.createElement("div");h.append(ae);const yn=(D=s==null?void 0:s.player)===null||D===void 0?void 0:D.info.isAutoQualityEnabled$.getValue();let Se;if(!((L=a==null?void 0:a.options)===null||L===void 0)&&L.vkVideoLoader){const Te=oo(p);Te.length&&(Se=await a.options.vkVideoLoader(...Te))}const _t={container:ae,...((z=Se==null?void 0:Se.videos)===null||z===void 0?void 0:z[0])||{sources:ri(p,x).sources},title:w},ee=new $n.Player;ee.initVideo(_t);const gn=ae.lastChild,It=new k.Subscription;It.add(ee.info.position$.subscribe(function(Te){v(K,ee.info.duration$.getValue(),Te)})).add(ee.events.canplay$.subscribe(function(){yn||xe(ee,i),V&&ee.setPlaybackRate(V)})),gn&&(ae.style.display="none",ae.classList.add(E));const oe=e.createPlayer({listId:p.id,itemId:K,player:ee,container:ae,sources:ri(p,x).sources,config:_t,subscription:It});return S&&f(p.id,oe.itemId,E),T&&oe.player.play(),y&&!T&&oe.player.prepare(),r.emit(Ne.playerCreated,oe.player),{player:oe.player,config:oe.config}}function I(){d(),a=null}function d(){a==null||a.off(C.chapterChanged,g),e.removeAll(),s={},l=!1,c=!1}async function m({source:p,initialChapter:E,container:y}){if(!a)throw Error("need to set interactive controller");await a.setManifest(p),d(),h=y;const{media:S,chapter:T}=await a.setChapter({chapterId:E});if(S){a.on(C.chapterChanged,g);const{player:x,config:w}=await b({media:S,chapterId:T.id,title:T.label});return r.emit(Ne.initiated,{container:y,media:S,chapterId:T.id}),{player:x,config:w}}else console.error("not found")}return{...e,on:r.on.bind(r),off:r.off.bind(r),init:m,setInteractiveController:u,createPlayer:b,removeAll:I,getActivePlayer:function(){return s}}}const ho=3e3,uo=()=>{let t=[],e=null;return{setPlayer:c=>{e=c},setContainers:c=>{t=c},deleteContainer:c=>{t=t.filter(a=>a.id!==c)},getNextInteractiveTime:(c=ho)=>{if(!t.length||e===null)return null;let a=-1,l=!1;const h=e.info.position$.getValue()*1e3;for(const u of t){const f=u.startTime-c;if(f<=h&&(h<=u.endTime||u.endTime===null)){l=!0;break}h<f&&(a=a===-1?f:Math.min(a,f))}return!l&&a!==-1?a:null}}},fe=uo(),R=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),wt=t=>gt(t)&&!bt(t),un=t=>bt(t.branches)||t.order==="end",fo=t=>gt(t.branches)&&!bt(t.branches),vo=(t,e)=>{var i;const n=t*1e3;return wt(e.controls)&&n<((i=e.startTime)!==null&&i!==void 0?i:0)},si=(t,e)=>{var i,n;const r=t*1e3;return wt(e.controls)&&r>=((i=e.startTime)!==null&&i!==void 0?i:0)&&r<=((n=e.endTime)!==null&&n!==void 0?n:1/0)},ke=t=>t.some(e=>e.action.type==="expect"),ai=t=>t.find(e=>e.action.type==="expect"),po=t=>(t==null?void 0:t.length)===1,fn=t=>po(t)&&an(t[0]),mo=({fn:t,type:e=1},...i)=>(...n)=>e?t(...n,...i):t({...n[e],...i[e]}),yo=(t=[])=>t.reduce((e,i,n)=>{var r,s,c;const a=((r=i==null?void 0:i.controls)!==null&&r!==void 0?r:[]).filter(l=>!an(l));if(wt(a)){const l=[(s=i.startTime)!==null&&s!==void 0?s:0,(c=i.endTime)!==null&&c!==void 0?c:1/0],h=i.id;if(!n)e.push({subjects:[h],range:l});else{const u=[];let f=-1/0,v=1/0,g=[];const b=[];for(let I=0;I<e.length;I++){const d=e[I];if(b.push(...d.subjects),d.range[0]<v&&(v=d.range[0]),d.range[1]>f&&(f=d.range[1]),d.range[0]<=l[0]&&d.range[1]>=l[1])return e[I].subjects.push(h),e;l[0]>=d.range[0]&&l[0]<=d.range[1]&&(u.push(I),g=g.concat(d.subjects),l[0]=d.range[0]),l[1]>=d.range[0]&&l[1]<=d.range[1]&&(u.push(I),g=g.concat(d.subjects),l[1]=d.range[1])}if(b.push(h),l[0]<=v&&l[1]>=f)return[{subjects:b,range:l}];u.length&&u.reverse().forEach(I=>{e.splice(I,1)}),e.push({subjects:g.concat([h]),range:l})}}return e},[]).sort((e,i)=>e.range[0]-i.range[0]),go=(t,e)=>ke(t.events)?!1:e.some(({container:i})=>i.container.id!==t.id&&ke(i.container.events)&&i.container.endTime===t.endTime&&!i.isRemoved);class bo{constructor({player:e,container:i,branches:n,selectBranches:r,interactiveEvents:s,globalEventEmitter:c,ignoreContainerEvent:a,permanentTextControls:l}){this.hide=()=>{setTimeout(()=>{var h,u,f,v;this.gameState!==R.end&&(ke(this.container.container.events)&&this.gameState===R.afterInteractive||this.selectBranches.state.isExpect||(this.gameState===R.interactive?(u=(h=this.container).disable)===null||u===void 0||u.call(h):(v=(f=this.container).hide)===null||v===void 0||v.call(f),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.visibility,visibility:!1})))})},this.show=()=>{var h,u,f,v;if(this.gameState===R.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())(u=(h=this.container).show)===null||u===void 0||u.call(h),(v=(f=this.container).enable)===null||v===void 0||v.call(f),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.visibility,visibility:!0,isFirst:!1});else{const b=mo({fn:this.selectBranches.onControlEvent,type:0},{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.visibility,visibility:!1})},onEvent:(I,d)=>{this.isSelectedControlEvent=!0,I!==!1&&(this.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.visibility,visibility:!1})),(this.gameState===R.end||this.gameState===R.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),d(),this.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.visibility,visibility:!1})),fe.deleteContainer(this.container.container.id)},isEOV:()=>this.gameState===R.end});this.container.createView(b),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.visibility,visibility:!0,isFirst:!0})}},this.onEndOfVideo=()=>{this.gameState=R.end,this.selectContainerEvent(!0)},this.whilePlaying=()=>{var h,u,f,v;if(((h=this.player.experimental.element$.getValue())===null||h===void 0?void 0:h.readyState)<1||[R.destroyed,R.removed].includes(this.gameState)&&!this.isPermanentText)return;const b=this.player.getExactTime();if(vo(b,this.container.container))this.gameState!==R.beforeInteractive&&(this.gameState=R.beforeInteractive,this.onBeforeStartTime());else if(si(b,this.container.container))this.gameState!==R.interactive&&(this.gameState=R.interactive,this.onStartTime());else if(this.gameState!==R.afterInteractive){const m=this.gameState;this.gameState=R.afterInteractive,m===R.interactive&&this.onEndTime()}else this.gameState!==R.destroyed&&this.removeView();const I=si(b,this.container.container),d=this.container.container.startTime?[this.container.container.startTime,(u=this.container.container.endTime)!==null&&u!==void 0?u:1/0]:[];(v=(f=this.container).onProgress)===null||v===void 0||v.call(f,b,I),this.globalEventEmitter.emit(C.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:d,currentTime:b,isInteractiveTime:I})},this.container=i,this.branches=n,this.selectBranches=r,this.subscription=new k.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=a,this.isPermanentText=l&&fn(i.container.controls),this.globalEventEmitter=c,this.gameState=R.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo))}selectContainerEvent(e=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);const e=ke(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,i;(i=(e=this.container).hide)===null||i===void 0||i.call(e),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=R.beforeInteractive}removeView(){this.container.removeView(),this.globalEventEmitter.emit(C.interactives,{subjectId:this.container.container.id,subjectName:"container",type:j.containerRemoved,visibility:!1}),this.gameState=R.removed}destroy(){var e;this.reset(),this.removeView(),this.gameState=R.destroyed,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!==null&&e!==void 0?e:1/0,id:this.container.container.id}),fe.deleteContainer(this.container.container.id)}}function Eo(){const t={};function e(){for(const a in t)Object.prototype.hasOwnProperty.call(t,a)&&delete t[a];return!0}function i(a){const l={};for(const h in t)+h<=a&&(l[h]=t[h]);return l}function n(a){const l={};for(const h in t)+h>=a&&(l[h]=t[h]);return l}function r({timestamp:a,priority:l,initiator:h}){var u;if(Yt(a)){const f=(u=t[a])!==null&&u!==void 0?u:null;if(f&&je(l,!0)){let v={};const g=f[l];if(g&&(v={...v,...g}),v=be(v)?null:v,v&&je(h,!0)){const b=v[h];return b!=null?b:null}return v}return f}return null}function s({timestamp:a,priority:l,initiator:h}){if(Yt(a))if(t[a]){if(je(l,!0))if(t[a][l]){if(je(h,!0))if(t[a][l][h]){if(delete t[a][l][h],!be(t[a][l]))return!0}else return!1;if(delete t[a][l],!be(t[a]))return!0}else return!1;return delete t[a]}else return!1}function c({timestamp:a,priority:l,initiator:h,...u}){var f,v,g;!((v=(f=t[a])===null||f===void 0?void 0:f[l])===null||v===void 0)&&v[h]?t[a][l][h].push({...u}):!((g=t[a])===null||g===void 0)&&g[l]?t[a][l]={...t[a][l],[h]:[{...u}]}:t[a]?t[a]={...t[a],[l]:{[h]:[{...u}]}}:t[a]={[l]:{[h]:[{...u}]}}}return{map:t,remove:s,add:c,removeAll:e,get:r,getLte:i,getGte:n}}const Co=[O.expect,O.setNextBranch],wo=1/0;function oi(t){let e=t,i;const n=_o(),r=new Eo;let s;const c=()=>{f(),I()},a=d=>{r.add.call(void 0,d),v()},l=(d=[])=>{for(const m of d)if(m.action(),Co.includes(m.actionType))break},h=d=>{var m,p,E;if(!n.isReady(d))return;const y=Pe((m=r.get({timestamp:d,priority:"control"}))!==null&&m!==void 0?m:{}),S=Pe((p=r.get({timestamp:d,priority:"container"}))!==null&&p!==void 0?p:{}),T=Pe((E=r.get({timestamp:d,priority:"chapter"}))!==null&&E!==void 0?E:{});l([...y,...S,...T])},u=()=>{var d;l([...Pe((d=r.get({timestamp:1/0,priority:"chapter"}))!==null&&d!==void 0?d:{})])},f=()=>{i&&(s==null||s.unsubscribe(),i=void 0)},v=()=>{i||(i=()=>setTimeout(()=>{h(1/0)}),s=e.events.ended$.subscribe(i))},g=d=>{f(),e=d},b=d=>{d.priority==="container"&&n.resetCalled(d.timestamp),r.remove(d)},I=()=>{n.release(),r.removeAll()};return{setPlayer:g,add:a,remove:b,exec:h,execEndOfVideo:u,listen:v,unlisten:f,release:c,containersEventsCallState:n}}function _o(){const t=new Map;return{setCalled:({timestamp:c,id:a})=>{const l=t.get(c);l&&l[a]!==void 0&&(l[a]=!0)},setData:(c=[])=>{var a,l;for(const h of c){const u=(a=h.endTime)!==null&&a!==void 0?a:wo,f=(l=t.get(u))!==null&&l!==void 0?l:{};t.set(u,{...f,[h.id]:!1})}},resetCalled:c=>{const a=t.get(c);if(a)for(const l in a)a[l]=!1},isReady:c=>{const a=t.get(c);return a?!Object.values(a).some(l=>!l):!0},release:()=>t.clear()}}function Pe(t){return Object.values(t).flat().sort(e=>e.actionType===O.expect?-1:1)}const Io=(t,e)=>{const{height:i,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(i&&n))return{videoContentHeight:0,videoContentWidth:0};const{clientHeight:r,clientWidth:s}=e.experimental.element$.value||{};if(!(r&&s))return{videoContentHeight:0,videoContentWidth:0};const c=i/n,a=r/s;let l,h;return a>c?(h=s,l=s*c):a<c?(h=r/c,l=r):(h=s,l=r),{videoContentWidth:h,videoContentHeight:l}},So=250;function To(t){let e=()=>{};const i=new ResizeObserver(a=>{s(a),e=s.bind(null,a)});function n(a){const{parentElement:l,player:h}=t();if(l&&h){const{videoContentWidth:u,videoContentHeight:f}=Io(l,h);l.style.setProperty("--interactive-content-width",`${u}px`),l.style.setProperty("--interactive-content-height",`${f}px`),l.style.setProperty("--interactive-width",`${a[0].contentRect.width}px`),l.style.setProperty("--interactive-height",`${a[0].contentRect.height}px`)}}function r(){const{parentElement:a}=t();a.removeAttribute("style")}const s=nn(a=>{const{fns:l=[]}=t();n(a);for(const h of l)h()},So);function c(){e=void 0,i.disconnect(),r()}return{resizeObserver:i,calc:()=>{e()},release:c}}class $o{constructor(){this.map={}}push(e,i){e in this.map?this.map[e].push(i):this.map[e]=[i]}get(e){const i=this.map[e];return i?i.slice():null}getAll(){const e=[];for(const i in this.map)e.push(...this.map[i]);return e}remove(e,i){e in this.map&&(this.map[e]=this.map[e].filter(n=>n!==i),this.map[e].length===0&&delete this.map[e])}clear(){this.map={}}size(){return Object.keys(this.map).length}keys(){return Object.keys(this.map)}}const Oo=t=>Math.floor(Math.random()*t),Ro=t=>{let e=t.length,i=1/0,n=null;for(;e--;)t[e].weight<i&&(i=t[e].weight,n=t[e]);return n},Ao=t=>{let e=t.length,i=-1/0,n=null;for(;e--;)t[e].weight>i&&(i=t[e].weight,n=t[e]);return n},jo=t=>{const e=t.length,i=Oo(e);return t[i]},li=1,xo=t=>{var e,i;let n=0;for(let s=0;s<t.length;++s)n+=(e=t[s].weight)!==null&&e!==void 0?e:li;const r=Math.random()*n;n=0;for(let s=0;s<t.length-1;++s)if(n+=(i=t[s].weight)!==null&&i!==void 0?i:li,n>=r)return t[s];return t[t.length-1]},ci=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0}),it=(t,e=!1)=>({...t,args:e?{...t.args,...ci}:{...ci,...t.args}}),hi=({globalEventEmitter:t,player:e,interactiveEvents:i,removeControllers:n})=>{const r={isExpect:!1},s=()=>{r.isExpect&&(r.isExpect=!1)},c=({action:d,controlType:m,controlId:p,containerId:E,branches:y=[],onEvent:S,isEOV:T=()=>!1,isDisabled:x=()=>!1})=>{const w=it(d,T()),V={timestamp:1/0,priority:"control",initiator:p,actionType:w.type},D=x(),L=t.emit.bind(t,C.interactives,{subjectId:p,subjectType:m,subjectName:"control",type:D?j.actionChoiceCanceled:j.actionChoice,actionType:d.type,payload:{containerId:E,...w.args}});if(D){L();return}switch(w.type.trim().toLowerCase()){case O.setNextBranch.trim().toLowerCase():{const z=y.find(K=>K.id===w.args.branchId);if(!z)return;S(w.args.isDetachContainer,v.bind(null,{subjectId:p,subjectName:"control"})),L(),w.args.shouldOpenNow?b({subjectId:p,subjectName:"control",subjectType:m,action:w,payload:{chapterId:z.chapterId,autoSelect:!1}}):(i.add({...V,action:b.bind(null,{subjectId:p,subjectName:"control",subjectType:m,action:w,payload:{chapterId:z.chapterId,autoSelect:!1}})}),n==null||n());return}case O.continuePlayback.trim().toLowerCase():{S(w.args.isDetachContainer,v.bind(null,{subjectId:p,subjectName:"control"})),L(),w.args.shouldOpenNow?g({subjectId:p,subjectName:"control",subjectType:m,action:d}):i.add({...V,action:g.bind(null,{subjectId:p,subjectName:"control",subjectType:m,action:d})});return}case O.openURI.trim().toLowerCase():{S(w.args.isDetachContainer,v.bind(null,{subjectId:p,subjectName:"control"})),L(),w.args.shouldOpenNow?I({subjectId:p,subjectName:"control",subjectType:m,action:w,payload:{URI:d.args.uri}}):(i.add({...V,action:I.bind(null,{subjectId:p,subjectName:"control",subjectType:m,action:w,payload:{URI:d.args.uri}})}),n==null||n());return}default:console.error("Unexpected control event"),t.emit(C.errors,new P(P.Severity.RECOVERABLE,P.Category.INTERACTIVES,{message:"Unexpected control event"}));return}},a=({action:d,container:{id:m,endTime:p},branches:E=[],isEOV:y=!1,autoSelected:S=!1})=>{const T=it(d,y),x={timestamp:!T.args.shouldOpenNow||y?1/0:p,priority:"container",initiator:m,actionType:T.type},w=t.emit.bind(t,C.interactives,{subjectId:m,subjectName:"container",type:j.actionChoice,actionType:T.type,payload:T.args});switch(T.type.trim().toLowerCase()){case O.setNextBranch.trim().toLowerCase():{const V=E.find(D=>D.id===T.args.branchId);if(!V)return;w(),i.add({...x,action:b.bind(null,{subjectId:m,subjectName:"container",action:T,payload:{chapterId:V.chapterId,autoSelect:S}})}),n==null||n();return}case O.setMaxWeightBranch.trim().toLowerCase():return;case O.setMinWeightBranch.trim().toLowerCase():return;case O.setRandomBranch.trim().toLowerCase():return;case O.setWeightlessRandomBranch.trim().toLowerCase():return;case O.continuePlayback.trim().toLowerCase():{w(),i.add({...x,action:g.bind(null,{subjectId:m,subjectName:"container",action:T})});return}case O.openURI.trim().toLowerCase():{w(),i.add({...x,action:I.bind(null,{subjectId:m,subjectName:"container",action:T,payload:{URI:d.args.uri}})}),n==null||n();return}default:console.error("Unexpected container event"),t.emit(C.errors,new P(P.Severity.RECOVERABLE,P.Category.INTERACTIVES,{message:"Unexpected container event"}));return}};function l({container:d,branches:m,isEOV:p=!1}){const E=ai(d.events);if(E){const y=it(E.action,p);t.emit(C.interactives,{subjectId:d.id,subjectName:"container",type:j.actionChoice,actionType:y.type,payload:y.args}),i.add({timestamp:p?1/0:d.endTime,priority:"container",initiator:d.id,actionType:O.expect,action:f.bind(null,{subjectId:d.id,subjectName:"container"})}),r.isExpect=!0}else for(const y of d.events)a({action:y.action,container:d,branches:m,isEOV:p})}const h=({chapterId:d,action:m,branches:p=[]})=>{const E=t.emit.bind(t,C.interactives,{subjectId:d,subjectName:"chapter",type:j.actionChoice,actionType:m.type,payload:m.args});switch(m.type.trim().toLowerCase()){case O.setNextBranch.trim().toLowerCase():{const y=p.find(S=>S.id===m.args.branchId);return y!=null&&y.chapterId?(E(),b.bind(null,{subjectId:d,subjectName:"chapter",action:m,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case O.setWeightlessRandomBranch.trim().toLowerCase():{const y=jo(p);return y!=null&&y.chapterId?(E(),b.bind(null,{subjectId:d,subjectName:"chapter",action:m,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case O.setRandomBranch.trim().toLowerCase():{const y=xo(p);return y!=null&&y.chapterId?(E(),b.bind(null,{subjectId:d,subjectName:"chapter",action:m,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case O.setMaxWeightBranch.trim().toLowerCase():{const y=Ao(p);return y!=null&&y.chapterId?(E(),b.bind(null,{subjectId:d,subjectName:"chapter",action:m,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case O.setMinWeightBranch.trim().toLowerCase():{const y=Ro(p);return y!=null&&y.chapterId?(E(),b.bind(null,{subjectId:d,subjectName:"chapter",action:m,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case O.continuePlayback.trim().toLowerCase():return E(),g.bind(null,{subjectId:d,subjectName:"chapter",action:m});case O.openURI.trim().toLowerCase():return E(),I.bind(null,{subjectId:d,subjectName:"chapter",action:m,payload:{URI:m.args.uri}});default:console.error("Unexpected chapter event"),t.emit(C.errors,new P(P.Severity.RECOVERABLE,P.Category.INTERACTIVES,{message:"Unexpected chapter event"}));return}};function u(d){const m=ai(d.events);if(m){if(un(d))return;t.emit(C.interactives,{subjectId:d.id,subjectName:"chapter",type:j.actionChoice,actionType:m.action.type,payload:m.action.args}),i.add({timestamp:1/0,priority:"chapter",initiator:d.id,actionType:O.expect,action:f.bind(null,{subjectId:d.id,subjectName:"chapter"})})}else d.events.forEach(p=>{const E=h({chapterId:d.id,action:p.action,branches:d.branches});E&&i.add({timestamp:1/0,priority:"chapter",initiator:d.id,actionType:p.action.type,action:E})})}const f=({subjectId:d,subjectName:m,action:p})=>{var E;e.pause(),t.emit(C.interactives,{subjectId:d,subjectName:m,type:j.actionExecution,actionType:(E=p==null?void 0:p.type)!==null&&E!==void 0?E:O.expect})},v=({subjectId:d,subjectName:m})=>{e.info.isEnded$.getValue()?i.execEndOfVideo():e.play(),t.emit(C.interactives,{subjectId:d,subjectName:m,type:j.actionExecution,actionType:"after-expect"})},g=({subjectId:d,subjectName:m,subjectType:p,action:E})=>{t.emit(C.interactives,{subjectId:d,subjectName:m,subjectType:p,type:j.actionExecution,actionType:E.type})},b=({subjectId:d,subjectName:m,subjectType:p,action:E,payload:y})=>{y.behaviour="change-chapter",t.emit(C.interactives,{subjectId:d,subjectName:m,subjectType:p,type:j.actionExecution,actionType:E.type,payload:y})},I=({subjectId:d,subjectName:m,subjectType:p,action:E,payload:y})=>{if(!y.URI)return;const S=window.open(y.URI,"_blank","noopener,noreferrer");S&&(S.opener=null),t.emit(C.interactives,{subjectId:d,subjectName:m,subjectType:p,type:j.actionExecution,actionType:E.type})};return{onControlEvent:c,onContainerEvent:a,onChapterEvent:h,onExpectEvent:f,expectEventHandler:v,setManifestChapterEvents:u,setManifestContainerEvents:l,stopExpect:s,state:r}};var me,vn,ct,di;class Q{constructor(e,i,n,r){this.target=e,this.type=i,this.listener=n,this.options=o(Q,me,"m",vn).call(Q,e,r),this.target.addEventListener(i,n,this.options)}unlisten(){this.target.removeEventListener(this.type,this.listener,this.options),this.target=null,this.listener=null,this.options=!1}}me=Q,vn=function(e,i){if(i===void 0)return!1;if(typeof i=="boolean")return i;{const n=new Set(["passive","capture"]),r=Object.keys(i).filter(c=>!n.has(c));return r.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+r.join(",")),o(Q,me,"m",di).call(Q,e)?i:i.capture||!1}},di=function(e){let i=o(Q,me,"f",ct);if(i===void 0){i=!1;try{const n={},r={get:()=>(i=!0,!1)};Object.defineProperty(n,"passive",r),Object.defineProperty(n,"capture",r);const s=()=>{};e.addEventListener("test",s,n),e.removeEventListener("test",s,n)}catch(n){i=!1}_(Q,me,i,"f",ct)}return i||!1};ct={value:void 0};class Po{constructor(){this.bindingMap=new $o}release(){this.removeAll(),this.bindingMap=null}listen(e,i,n,r){if(!this.bindingMap)return;const s=new Q(e,i,n,r);this.bindingMap.push(i,s)}listenOnce(e,i,n,r){const s=c=>{this.unlisten(e,i,s),n(c)};this.listen(e,i,s,r)}unlisten(e,i,n){if(!this.bindingMap)return;const r=this.bindingMap.get(i)||[];for(const s of r)s.target===e&&(n===s.listener||!n)&&(s.unlisten(),this.bindingMap.remove(i,s))}removeAll(){if(!this.bindingMap)return;const e=this.bindingMap.getAll();for(const i of e)i.unlisten();this.bindingMap.clear()}}class Lo{constructor(){this._prevSizeId=0,this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))===null||e===void 0||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var e;const i=(e=this.rootElement.getContext("2d"))===null||e===void 0?void 0:e.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!i)return!1;const n=i.data,r=n.length;for(let s=3;s<r;s+=40)if(n[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===void 0||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}async updateCanvasDimensions(e,i=!1){const n=e.width+e.height;if(this._prevSizeId===n)return;let r;i&&(r=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,i&&r&&this.restore(r),this._prevSizeId=n}async save(){const e=this.rootElement.toDataURL("image/jpeg",1),i=new Image;return i.crossOrigin="anonymous",i.src=e,await i.decode(),i}restore(e){var i;this.rootElement&&((i=this.rootElement.getContext("2d"))===null||i===void 0||i.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}}class No{constructor({parentElement:e,endOffsetMs:i=250,onError:n}){this.currentVideoDurationMs=1/0,this._containerTimeFrameShouldReceived=!1,this._endTimeFrameReceived=!1,this._shouldCallSkip=!1,this.onEachTick=r=>{const s=r!=null?r:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,c=this.isChapterEndTime(s);if(this.isContainerTime(s))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(c)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;
|