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