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