@vkontakte/videoplayer-interactive 1.0.6-beta.0 → 1.0.6-dev.5a11a96.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +5 -5
- package/es2015.esm.js +5 -5
- package/es2015.umd.js +31071 -0
- package/es2018.cjs.js +5 -5
- package/es2018.esm.js +5 -5
- package/esnext.cjs.js +5 -5
- package/esnext.esm.js +5 -5
- package/evergreen.esm.js +5 -5
- package/index.d.ts +4 -6
- package/package.json +7 -5
package/es2018.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.6-
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.6-dev.5a11a96.0
|
|
3
|
+
* Tue, 12 Dec 2023 11:20:59 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-6/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var Ut=Object.create;var Qe=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var qt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Kt=Object.prototype.hasOwnProperty;var Xt=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of qt(e))!Kt.call(i,s)&&s!==t&&Qe(i,s,{get:()=>e[s],enumerable:!(n=zt(e,s))||n.enumerable});return i};var Zt=(i,e,t)=>(t=i!=null?Ut(Qt(i)):{},Xt(e||!i||!i.__esModule?Qe(t,"default",{value:i,enumerable:!0}):t,i));var H=require("@vkontakte/videoplayer-shared/es2018.cjs.js"),Be=require("uuid"),Yt=require("@vkontakte/videoplayer-core/es2018.cjs.js");const Jt="1.0.6-beta.0";function Ct(i,e=1){let t="0",n="0",s="0";return i.length===4?(t="0x"+i[1]+i[1],n="0x"+i[2]+i[2],s="0x"+i[3]+i[3]):i.length===7&&(t="0x"+i[1]+i[2],n="0x"+i[3]+i[4],s="0x"+i[5]+i[6]),`rgba(${+t},${+n},${+s},${e})`}const W="SDK_NAME",ei="SDK_NAME-controls-container",Et=()=>document.querySelector(`.${ei}`),z={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"},Xe={start:"flex-start",end:"flex-end",center:"center"},Ze={start:"left",end:"right",center:"center"},_t=({target:i,props:e})=>{var t,n,s,r,c,a;i.style.alignItems=(n=Ke[(t=e==null?void 0:e.text)===null||t===void 0?void 0:t.gravityVertical])!==null&&n!==void 0?n:Ke.center,i.style.justifyContent=(r=Xe[(s=e==null?void 0:e.text)===null||s===void 0?void 0:s.gravityHorizontal])!==null&&r!==void 0?r:Xe.center,i.style.textAlign=(a=Ze[(c=e==null?void 0:e.text)===null||c===void 0?void 0:c.alignment])!==null&&a!==void 0?a:Ze.start},wt=({target:i,props:e,fallback:t,dependsOn:n})=>{var s,r,c,a,l,d;i.style.color=(r=(s=e==null?void 0:e.text)===null||s===void 0?void 0:s.color)!==null&&r!==void 0?r:t.textColor,i.style.fontSize=`calc(${n.height} * ${(a=(c=e==null?void 0:e.text)===null||c===void 0?void 0:c.size)!==null&&a!==void 0?a:t.textSize})`,i.textContent=(d=(l=e==null?void 0:e.text)===null||l===void 0?void 0:l.value)!==null&&d!==void 0?d:t.textContent},It=({target:i,props:e,fallback:t})=>{var n,s,r,c;i.style.backgroundColor=Ct((s=(n=e==null?void 0:e.background)===null||n===void 0?void 0:n.color)!==null&&s!==void 0?s:t.backgroundColor,(c=(r=e==null?void 0:e.background)===null||r===void 0?void 0:r.alpha)!==null&&c!==void 0?c:t.backgroundAlpha)},St=({target:i,props:e,fallback:t,dependsOn:n})=>{var s,r,c,a,l,d,f,u,y,C,E;i.style.border=`calc(${n.height} * ${(c=(r=(s=e==null?void 0:e.shape)===null||s===void 0?void 0:s.border)===null||r===void 0?void 0:r.width)!==null&&c!==void 0?c:t.borderWidth}) solid ${Ct((d=(l=(a=e==null?void 0:e.shape)===null||a===void 0?void 0:a.border)===null||l===void 0?void 0:l.color)!==null&&d!==void 0?d:t.borderColor,(y=(u=(f=e==null?void 0:e.shape)===null||f===void 0?void 0:f.border)===null||u===void 0?void 0:u.alpha)!==null&&y!==void 0?y:t.borderAlpha)}`,i.style.borderRadius=`calc(${n.height} * ${(E=(C=e==null?void 0:e.shape)===null||C===void 0?void 0:C.roundCorners)!==null&&E!==void 0?E:t.roundCorners})`},$e=({target:i,layoutParams:e,fallback:t})=>{var n;i.style.transform=`rotate(${(n=-e.angle)!==null&&n!==void 0?n:t.angle}rad)`};class De{constructor(e){this.control=e}createView(e){var t;const n=document.createElement("div");n.classList.add(`${W}-control-container-${this.control.id}`),e(n,this.control.layoutParams);const s=((t=this.control.layoutParams.innerSizesDependOn)!==null&&t!==void 0?t:z.innerSizesDependOn)==="self"?{height:n.style.height,width:n.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:n,dependsOn:s}}setEvents(e,t){e&&this.control.events.forEach(n=>{switch(n.type.trim().toLowerCase()){case"onclick":e.addEventListener("click",r=>{r.stopPropagation(),t&&t({action:n.action,controlId:this.control.id,controlType:this.control.type})});break}})}getElement(){return document.querySelector(`.${W}-control-container-${this.control.id}`)}}const Tt=i=>{if(i.type.trim().toLowerCase()==="area")return new ti(i)};class ti extends De{constructor(e){super(e)}createView({parent:e,layoutFn:t}){const{dependsOn:n,controlContainerEl:s}=super.createView(t),r=document.createElement("button");return r.classList.add(`${W}-${this.control.id}`),r.style.display="flex",r.style.width="100%",r.style.height="100%",r.style.cursor="pointer",r.type="button",It({target:r,props:this.control.props,fallback:{...z,backgroundColor:"transparent"}}),St({target:r,props:this.control.props,fallback:{...z,borderAlpha:0},dependsOn:n}),$e({target:r,layoutParams:this.control.layoutParams,fallback:z}),s.append(r),e.append(s),s}getElement(){return document.querySelector(`.${W}-${this.control.id}`)}}const Rt=i=>{if(i.type.trim().toLowerCase()==="button")return new ii(i)};class ii extends De{constructor(e){super(e)}createView({parent:e,layoutFn:t}){const{dependsOn:n,controlContainerEl:s}=super.createView(t),r=document.createElement("button");r.type="button",r.classList.add(`${W}-${this.control.id}`),r.style.display="flex",r.style.width="100%",r.style.height="100%",r.style.cursor="pointer",r.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",$e({target:r,layoutParams:this.control.layoutParams,fallback:z}),It({target:r,props:this.control.props,fallback:z}),St({target:r,props:this.control.props,fallback:z,dependsOn:n}),_t({target:r,props:this.control.props}),wt({target:c,props:this.control.props,fallback:z,dependsOn:n}),r.append(c),s.append(r),e.append(s),s}getElement(){return document.querySelector(`.${W}-${this.control.id}`)}}const ni=i=>{if(i.type.trim().toLowerCase()==="text")return new si(i)};class si extends De{constructor(e){super(e)}createView({parent:e,layoutFn:t}){const{dependsOn:n,controlContainerEl:s}=super.createView(t),r=document.createElement("div");r.classList.add(`${W}-${this.control.id}`),r.style.display="flex",r.style.width="100%",r.style.height="100%",r.style.fontFamily="inherit";const c=document.createElement("span");return c.style.whiteSpace="pre",$e({target:r,layoutParams:this.control.layoutParams,fallback:z}),_t({target:r,props:this.control.props}),wt({target:c,props:this.control.props,fallback:z,dependsOn:n}),r.append(c),s.append(r),e.append(s),s}getElement(){return document.querySelector(`.${W}-${this.control.id}`)}}class ri{constructor(e){this.layout=e}}const ai=i=>{if(i.type.trim().toLowerCase()==="relative")return new At(i)};class At extends ri{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}}function o(i,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(i):n?n.value:e.get(i)}function w(i,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!s:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(i,t):s?s.value=t:e.set(i,t),t}var re,Ie,Ye;class xt{constructor(e){re.add(this),this.container=e,this.factories=new Map,o(this,re,"m",Ie).call(this)}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),o(this,re,"m",Ie).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),o(this,re,"m",Ie).call(this)}}re=new WeakSet,Ie=function(){this.controls=o(this,re,"m",Ye).call(this)},Ye=function(){var e;return(e=this.container.controls)===null||e===void 0?void 0:e.reduce((t,n)=>{const s=n.type.trim().toLowerCase(),r=this.factories.get(s);return r?[...t,r(n)]:[...t]},[])};const Ot=(i,e)=>{if(i.type.trim().toLowerCase()==="choice")return new oi(i,e)};class oi extends xt{constructor(e,t){super(e),this.rootElement=t!=null?t:Et(),this.layout=new At(this.container.layout),this.isRemoved=!1,this.addControlFactory("button",Rt),this.addControlFactory("text",ni),this.addControlFactory("area",Tt)}createView(e){const t=document.createElement("div");return t.classList.add(`${W}-${this.container.id}`),this.layout.setContainerLayout(t),this.controls.forEach(n=>{const s=n.createView({parent:t,layoutFn:this.layout.setControlLayout});n.setEvents(s,e)}),this.rootElement.append(t),t}hide(){const e=this.getElement();e&&(e.style.visibility="hidden")}show(){const e=this.getElement();e&&(e.style.visibility="visible")}removeView(){var e;this.isRemoved||((e=this.getElement())===null||e===void 0||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${W}-${this.container.id}`)}}function Lt(i,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>i(...n),e)}}const ge={Object:"Object",String:"String",Array:"Array",Number:"Number",Function:"Function",Boolean:"Boolean"},de=(i,e)=>Object.prototype.toString.call(i)===`[object ${e}]`,We=i=>de(i,ge.Object),Ne=i=>de(i,ge.String),le=i=>de(i,ge.Array),Nt=i=>de(i,ge.Number),li=i=>de(i,ge.Function),Je=i=>Nt(i)&&!isNaN(i),ci=i=>i==null,pe=i=>We(i)&&Object.keys(i).length===0,jt=i=>le(i)&&!i.length,Ce=(i,e)=>Ne(i)&&(e?i.trim():i).length,Mt=window.navigator.userAgent.toLowerCase(),di=/mobi/i.test(Mt);Mt.indexOf("android")>-1;const hi="video_interactive",ui="videoint",fi=250;class pi{constructor(e){this.onResize=t=>{this.isReady&&(!t[0].contentRect.width||!t[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:t[0].contentRect.width,height:t[0].contentRect.height}))},this.handleChapterChange=t=>{var n;if(this.isReady){if(this.isHidden||this.hide(),!(t!=null&&t.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(t.id),this.ngEditor.selectChapter(t.id),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=t.id,this.lastZoomInfo=void 0}},this.handleManifestChange=async(t,n=[])=>{var s;if(!Nt(t.graph.edit.chapters[0].x)){this.isReady=!1,(s=this.onError)===null||s===void 0||s.call(this,"Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=void 0,!this.ngEditor){let r;try{r=await H.loadVKLangPack(this.lang,hi,ui)}catch(a){console.log("Unable to load graph language pack")}const{GraphEditor:c}=await import("@interactiveplatform/movika-graph-editor");this.ngEditor=new c(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:r}),this.ngEditor.on("control",({name:a,chapterId:l})=>{a==="openPreview"&&this.onOpenPreviewClick(l)}),this.ngEditor.on("zoomEnd",a=>{this.lastZoomInfo={...a}})}this.visitedChapterIds=new Set(n),t.metadata.id!==this.currentManifestId?(this.ngEditor.update(t),this.currentManifestId=t.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0},this.init(e)}init({root:e,onOpenPreviewClick:t,onError:n,lang:s,visitedChapters:r=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(r),this.onOpenPreviewClick=t,this.onError=n,this.lang=s!=null?s:"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=vi(e),this.resizeObserver=new ResizeObserver(Lt(this.onResize,fi)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor.updateVideosInfo(e)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.resizeObserver.disconnect(),(e=this.ngEditor)===null||e===void 0||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)===null||t===void 0||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}}function vi(i){const e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",i.append(e),e}const mi=(i={})=>{var e;return Array.from(new Set((e=i.sessions)===null||e===void 0?void 0:e.map(t=>{var n;return(n=t.visitedChapters.map(s=>s.chapterId))!==null&&n!==void 0?n:[]}).flat()))},et=(i=[],e="")=>i.reduce((t,n)=>(t.find(s=>s[e]===n[e])||t.push(n),t),[]),tt="chapterId";class ae{constructor(e){var t;this.id=(t=e==null?void 0:e.id)!==null&&t!==void 0?t:Be.v4(),this.startDate=e!=null&&e.startDate?new Date(e.startDate).toISOString():new Date(Date.now()).toISOString(),this.updateOn=e!=null&&e.updateOn?new Date(e.updateOn).toISOString():null,this.visitedChapters=e!=null&&e.visitedChapters?et(Array.from(e.visitedChapters),tt):[],this.branches=le(e==null?void 0:e.branches)?e.branches:[]}update(e){e!=null&&e.startDate&&(this.startDate=new Date(e.startDate).toISOString()),e!=null&&e.updateOn&&(this.updateOn=new Date(e.updateOn).toISOString()),le(e==null?void 0:e.visitedChapters)&&(this.visitedChapters=et([...this.visitedChapters,...e.visitedChapters],tt)),le(e==null?void 0:e.branches)&&(this.branches=this.branches.concat(e.branches))}getSession(){return{...this}}static createVisitedChapter(e){return[{chapterId:e}]}static createBranch(e,t,n){return[{chapterId:e,branchId:t,autoSelect:n}]}}class Ee{constructor(e){var t,n;this.id=(t=e==null?void 0:e.id)!==null&&t!==void 0?t:Be.v4(),this.manifestId=e==null?void 0:e.manifestId,this.manifestVersion=e==null?void 0:e.manifestVersion,this.manifestBuild=e==null?void 0:e.manifestBuild,this.sessions=le(e==null?void 0:e.sessions)?e==null?void 0:e.sessions.map(s=>new ae(s)):[],this.isCompleted=(n=e==null?void 0:e.isCompleted)!==null&&n!==void 0?n:!1}update(e){var t,n,s,r,c;this.id=(t=e==null?void 0:e.id)!==null&&t!==void 0?t:this.id,this.manifestId=(n=e==null?void 0:e.manifestId)!==null&&n!==void 0?n:this.manifestId,this.manifestVersion=(s=e==null?void 0:e.manifestVersion)!==null&&s!==void 0?s:this.manifestVersion,this.manifestBuild=(r=e==null?void 0:e.manifestBuild)!==null&&r!==void 0?r:this.manifestBuild,this.isCompleted=(c=e==null?void 0:e.isCompleted)!==null&&c!==void 0?c:this.isCompleted}addSession(e){this.sessions.push(new ae(e))}updateSession(e,t){let n;ci(e)?n=this.sessions[this.sessions.length-1]:n=this.sessions.find(s=>s.id===e),n&&n.update(t)}resetSession(){this.sessions=[]}getHistory(){return{...this,sessions:this.sessions.map(e=>e.getSession())}}}const je="SDK_NAME-history-changed";class gi extends EventTarget{constructor(){super(),this.history=new Ee,this.sendEvent()}onChapterChange({chapterId:e,mediaId:t,autoSelect:n=!1,isLastChapter:s=!1}){this.history.isCompleted?this.history=new Ee({manifestId:this.history.manifestId,manifestVersion:this.history.manifestVersion,manifestBuild:this.history.manifestBuild}):s&&this.history.update({isCompleted:!0}),this.history.sessions.length?this.history.updateSession(null,{updateOn:Date.now(),visitedChapters:ae.createVisitedChapter(e),branches:ae.createBranch(e,t,n)}):this.history.addSession({updateOn:Date.now(),visitedChapters:ae.createVisitedChapter(e),branches:ae.createBranch(e,t,!1)}),this.sendEvent()}onManifestChange(e,t){t?this.history=new Ee(t):this.history=new Ee({manifestId:e.id,manifestVersion:e.version,manifestBuild:e.build}),this.history.addSession({updateOn:Date.now()}),this.sendEvent()}getHistory(){if(history)return this.history.getHistory()}sendEvent(){this.dispatchEvent(new CustomEvent(je,{bubbles:!1,detail:this.getHistory()}))}destroy(){this.history=void 0}}function yi(i,e){var t;if(!e||!i||!e.sessions.length)return;const n=e.sessions.reverse().find(s=>s.branches.length);return(t=n.branches[n.branches.length-1].chapterId)!==null&&t!==void 0?t:void 0}const me=(i="",e="")=>{i=i.split("."),e=e.split(".");let t=0;for(let n=0;n<Math.max(i.length,e.length)&&!t;n++)i[n]>e[n]?t=1:i[n]<e[n]?t=-1:t=0;return t},bi="3.1",it={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},Ci={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ei=i=>{const e=[];for(const t of i.chapters){let n;const s=[];for(const{isDefault:a,...l}of t.branches)a&&(n=l.id),s.push(l);let r=[];const c=[];for(const{fallbackStrategy:a,...l}of t.containers){const d=!!l.endTime;let f=[Ci];switch(a){case"await":d?f=[]:r=[];break;case"default":{const u={type:"onSuspense",action:{type:it.default,args:{branchId:n,shouldOpenNow:!d,isDetachContainer:!0}}};d?f=[u]:r=[u];break}case"random":case"weightlessRandom":case"max":case"min":{const u={type:"onSuspense",action:{type:it[a],args:{}}};d?f=[u]:r=[u];break}}for(const u of l.controls)c.push({...l,controls:[{...u}],id:Be.v4(),events:f})}e.push({...t,containers:c,events:r,branches:s})}return i.metadata.version=bi,i.metadata.updated=new Date().toISOString(),{...i,chapters:e}},_i="3.2",wi=i=>{if(!i.media){const{media:e,...t}=i.metadata;return{...i,metadata:{...t,version:_i},media:e}}return i},Ii="3.3",Si=(i=[])=>({edit:{chapters:i},view:{}}),nt={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ti=i=>{var e;const t=[],n=[];for(const s of i.chapters){const{id:r,x:c,y:a,...l}=s,d=l.containers.map(f=>{var u;return{...f,controls:f.controls.map(({subtype:y,type:C,...E})=>({...E,type:y!=null?y:C})),events:!((u=f.events)===null||u===void 0)&&u.length?f.events:[nt]}});t.push({id:r,...l,containers:d,events:!((e=l.events)===null||e===void 0)&&e.length?l.events:[nt]}),n.push({id:r,x:c,y:a})}return{...i,chapters:t,graph:Si(n),metadata:{...i.metadata,version:Ii}}},Ri=[{version:"3.0",migrate:Ei},{version:"3.1",migrate:wi},{version:"3.2",migrate:Ti}],Ai=i=>Ri.reduce((e,t)=>me(e.metadata.version,t.version)?e:t.migrate(e),i),xi=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),A=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 st={metadata:"Object",chapters:"Array"},Oi="3.0.0",Li="3.3.0",Ge=i=>{const e=me(i,Oi);return e===-1?!1:e===0?!0:me(i,Li)!==1},Ni=i=>{if(!We(i))return!1;for(const e in st)if(!i[e]||!de(i[e],st[e]))return!1;return Ge(i.metadata.version)},ji=i=>i.type===xi.Text;class L{constructor(e,t,...n){this.severity=e,this.category=t,this.data=n}toString(){return`SDK_NAME ERROR ${JSON.stringify(this,null," ")}`}}L.Severity={RECOVERABLE:1,CRITICAL:2};L.Category={VIDEO:0,INTERACTIVES:1,GRAPH:2,MANIFEST:3,LOADERS:4,HISTORY:5,SEAMLESS:6};class Vt{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];const n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){const n=this.listeners[e];if(!n)return this;for(let s=n.length;s>0;s--)if(n[s]===t){n.splice(s,1);break}return this}emit(e,...t){const n=this.listeners[e];return n?(n.forEach(s=>{s(...t)}),!0):!1}listenerCount(e){return(this.listeners[e]||[]).length}rawListeners(e){return this.listeners[e]}}class Mi{constructor(e){this.addFn=(t,n=!1)=>{li(t)&&(this.fns.push(t),n&&this.updateFn())},this.removeFn=(t,n=!1)=>{this.fns=this.fns.filter(s=>s!==t),n&&this.updateFn()},this.updateFn=()=>{this.fn=()=>{this.fns.forEach(t=>t()),this.raf&&this.forceRequestAnimation()}},this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))},this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()},this.cancelAnimation=()=>{cancelAnimationFrame(this.raf),this.raf=void 0},this.raf,this.fn,this.fns=[],this.addFn(e)}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}}class Vi{constructor(e){var t,n;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!==null&&t!==void 0?t:[],manifestLoaders:(n=e==null?void 0:e.manifestLoaders)!==null&&n!==void 0?n:[]}}async exec(e,t){return ki(...this.loaders[e])(t)}}function ki(...i){return async function(t){const n=[...i];for(;n.length>0;)t=await n.shift()(t);return t}}function Ae(i,e,t){return i?{...i,[e]:i[e]?[t,...i[e]]:[t]}:{[e]:[t]}}function Me({actions:i,errors:e,chapterId:t,...n}){if(t){const s=i.getManifest(),r=i.getChapter(s.chapters,t);if(r){const c=i.getMedia(s.media,r.videoId),a=i.getGraph(s.graph,r.id);return c?{...n,actions:i,errors:e,result:{chapter:r,media:c,graph:a}}:{...n,errors:Ae(e,Me.name,"Could not find media"),actions:i}}}return{...n,errors:Ae(e,Me.name,"Could not find chapter"),actions:i}}class rt{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){if(!(e in this.listeners))return;const n=this.listeners[e];for(let s=0,r=n.length;s<r;s++)if(n[s].callback===t){n.splice(s,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;const n=this.listeners[e.type].slice();for(let s=0,r=n.length;s<r;s++){const c=n[s];try{c.callback.call(this,e)}catch(a){Promise.resolve().then(()=>{throw a})}c.options&&c.options.once&&this.removeEventListener(e.type,c.callback)}return!e.defaultPrevented}}class kt extends rt{constructor(){super(),this.listeners||rt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}}class Pi{constructor(){Object.defineProperty(this,"signal",{value:new kt,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(s){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let n=e;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(s){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(Pi.prototype[Symbol.toStringTag]="AbortController",kt.prototype[Symbol.toStringTag]="AbortSignal");function Pt(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 Fi(i){typeof i=="function"&&(i={fetch:i});const{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:s=!1}=i;if(!Pt({fetch:e,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:s}))return{fetch:e,Request:r};let r=t;(r&&!r.prototype.hasOwnProperty("signal")||s)&&(r=function(d,f){let u;f&&f.signal&&(u=f.signal,delete f.signal);const y=new t(d,f);return u&&Object.defineProperty(y,"signal",{writable:!1,enumerable:!1,configurable:!0,value:u}),y},r.prototype=t.prototype);const c=e;return{fetch:(l,d)=>{const f=r&&r.prototype.isPrototypeOf(l)?l.signal:d?d.signal:void 0;if(f){let u;try{u=new DOMException("Aborted","AbortError")}catch(C){u=new Error("Aborted"),u.name="AbortError"}if(f.aborted)return Promise.reject(u);const y=new Promise((C,E)=>{f.addEventListener("abort",()=>E(u),{once:!0})});return d&&d.signal&&delete d.signal,Promise.race([y,c(l,d)])}return c(l,d)},Request:r}}const He=Pt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ft=He?Fi({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,at=He?Ft.fetch:window.fetch;He?Ft.Request:window.Request;const Bi=async i=>{try{let e,t;if(We(i))e=i;else if(Ne(i)){t=new URL(i).href;const s=await at(t);if(!s.ok)return{};e=await s.json()}else return{};if(!Ni(e))return{};const n=e.metadata.media;if(Ne(n)&&!e.media)try{let s;t?s=new URL(n,t).href:(s=new URL(n).href,t=s);const r=await at(s);if(!r.ok)throw new Error;e.metadata.media=await r.json()}catch(s){return Gi(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function $i(i){const{manifest:e,manifestURL:t}=await Bi(i),n=Ai(e);return n.media=Di(n.media,t),delete n.metadata.media,n}function Oe(i,e){return i.find(t=>t.id===e)}function ot(i,e){var t,n;return!((t=i.edit)===null||t===void 0)&&t.chapters?i.edit.chapters.find(s=>s.id===e):!((n=i.view)===null||n===void 0)&&n.chapters?i.view.chapters.find(s=>s.id===e):void 0}function lt(i,e){return i.videos.find(t=>t.id===e)}function Di(i,e){return{...i,videos:i.videos.map(t=>({...t,variants:t.variants.map(n=>{const s=Wi(n.url,e);return{...n,url:s||n.url}})}))}}function Wi(i,e){try{return new URL(i,e).href}catch(t){return""}}function Gi(i){return me(i,"3.2.0")>=0}class Bt extends Vi{constructor(e,t){super(e),this.onError=t,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this}async setManifest(e){var t;this.release();const n=await this.exec("manifestLoaders",{actions:{addErrorMessage:Ae},result:null,errors:null,source:e});n.errors&&this.errorHandler(n.errors);const s=await $i((t=n.result)!==null&&t!==void 0?t:e);return this.manifest=s,this}async setInitial(){return this.setNext()}async setNext(e=this.manifest.metadata.initChapterId){const t=await this.exec("chapterLoaders",Me({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:ot,getChapter:Oe,getMedia:lt,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ae},result:null,errors:null,chapterId:e}));return t.errors&&this.errorHandler(t.errors),this.chapter=t.result.chapter,this.media=t.result.media,this.graph=t.result.graph,this}errorHandler(e){this.onError(e),console.error("Something went wrong with loaders",{errors:e})}getInitial(){return this.getByChapterId(this.manifest.metadata.initChapterId)||null}getByChapterId(e=this.manifest.metadata.initChapterId){const t=Oe(this.manifest.chapters,e);if(t){const n=lt(this.manifest.media,t.videoId),s=ot(this.manifest.graph,t.id);if(n)return{chapter:t,media:n,graph:s}}return null}getBranches(e=this.chapter.id){if(e===this.chapter.id)return this.getByBranches(this.chapter.branches);{const t=Oe(this.manifest.chapters,e);return this.getByBranches(t==null?void 0:t.branches)}}getByBranches(e=[]){return e.reduce((t,n)=>{const s=this.getByChapterId(n.chapterId);return s&&t.push(s),t},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}}const b={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyChanged:"history-changed"},ct={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},N={actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function Hi(){const i=new Map;function e({listId:s=Math.random().toString(),itemId:r=Math.random().toString(),...c}){const a=i.get(s),l={...c};return a?a[r]=l:i.set(s,{[r]:l}),{listId:s,itemId:r,...c}}function t(s,r){var c,a,l;const d=i.get(s);if(d){if(r)return(c=d[r])===null||c===void 0||c.player.destroy(),(a=d[r])===null||a===void 0||a.container.remove(),(l=d[r])===null||l===void 0||l.subscription.unsubscribe(),delete d[r],Object.keys(d).length||i.delete(s),!0;for(const f of Object.values(d))f.player.destroy(),f.container.remove();return i.delete(s),!0}else throw Error("Can't remove. Not find.")}function n(){for(const s of i)t(s[0])}return{createPlayer:e,removePlayer:t,map:i,removeAll:n}}function dt(i,e=[]){var t,n,s;let r={},c;const a=!e.length;for(const l of i.variants)if(!c&&"cover"in l&&(c=l.cover),"url"in l)switch(l.type.toLowerCase()){case"mp4":(a||e.includes("mp4"))&&(r.MPEG={...r.MPEG,[(t=l.standard)!==null&&t!==void 0?t:"Invariant quality"]:l.url});break;case"mpeg":(a||e.includes("mpeg"))&&(r.MPEG={...r.MPEG,[(n=l.standard)!==null&&n!==void 0?n:"Invariant quality"]:l.url});break;case"hls":(a||e.includes("hls"))&&(r={...r,HLS:{type:"url",url:l.url}});break;case"dash":(a||e.includes("dash"))&&(r={...r,DASH_SEP:{compatibilityMode:!0,type:"url",url:l.url}});break}return{sources:r,thumbUrl:c,title:(s=i.title)!==null&&s!==void 0?s:""}}const _e=(i,e)=>{const t=i.info.currentQuality$.getValue(),n=i.info.availableQualities$.getValue();t!==e&&n.includes(e)&&(i.setQuality(e),i.setAutoQuality(!1))},Ui=i=>{const e=i.variants.find(t=>{var n;return((n=t.payload)===null||n===void 0?void 0:n.type)==="vk"});if(e&&"payload"in e){const[t,n]=e.payload.id.split("_");return[t,n]}return[]},Se={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},zi=2;function qi(i){const e=Hi();let t,n;const s=new Vt;let r={},c=!1,a=null,l=!1,d;i&&f(i);function f(p){a=p}function u(p,g,v){var I;if(!a)throw Error("need to set interactive controller");const _=((I=e.map.get(p))!==null&&I!==void 0?I:{})[g];if(_){r={chapterId:v,listId:p,itemId:g,..._};const R=r.player;n=R.info.currentQuality$.subscribe(V=>{if(!(!V||!R.info.position$.getValue())){t=V;for(const P of e.map)Object.values(P[1]).forEach(({player:$})=>{R.info.isAutoQualityEnabled$.getValue()||_e($,V)})}}),_.container.remove(),c=!1,a.setPlayer(_.player),l||(a.init(),l=!0),s.emit(Se.activePlayerChanged,{player:r.player,config:r.config});return}throw Error("Can't set. Not find.")}async function y(p,g,v){if(!a)throw Error("need to set interactive controller");if(pe(r)||p!==r.itemId)return;if(v>=0&&!c){const S=a.getChapterBranches();c=!0;const _=new Set;for(const R of S)_.has(R.media.id)||(await E({media:R.media,chapterId:R.chapter.id,setAsActive:!1,title:R.chapter.label}),_.add(R.media.id))}}async function C({chapter:{id:p},media:g}){if(pe(r))return;n==null||n.unsubscribe();const v=r.player.info.muted$.getValue(),I=r.player.info.currentQuality$.getValue(),S=r.player.info.isAutoQualityEnabled$.getValue(),_=r.player.info.volume$.getValue(),R=r.player.info.currentPlaybackRate$.getValue(),V=!S;let P=!1;for(const $ of e.map)if($[0]===g.id){const ie=Object.keys($[1]);for(const Z of ie)Z===r.itemId?(ie.length<zi||(P=!0),e.removePlayer($[0],Z)):(P=!0,u($[0],Z,p),V?_e(r.player,I):r.player.setAutoQuality(!0),r.player.setVolume(_),r.player.setMuted(v),r.player.setPlaybackRate(R))}else e.removePlayer($[0]);P||(await E({media:g,chapterId:p,setAsActive:!0,playbackRate:R}),V?_e(r.player,I):r.player.setAutoQuality(!0),r.player.setVolume(_),r.player.setMuted(v))}async function E({media:p,chapterId:g,prefetch:v=!0,setAsActive:I=!0,autoplay:S=!1,preferredExt:_,title:R,playbackRate:V}){var P,$,ie;const Z=Math.random().toString(),ne=document.createElement("div");d.append(ne);const Gt=(P=r==null?void 0:r.player)===null||P===void 0?void 0:P.info.isAutoQualityEnabled$.getValue();let ye;if(!(($=a==null?void 0:a.options)===null||$===void 0)&&$.vkVideoLoader){const be=Ui(p);be.length&&(ye=await a.options.vkVideoLoader(...be))}const ze={container:ne,...((ie=ye==null?void 0:ye.videos)===null||ie===void 0?void 0:ie[0])||{sources:dt(p,_).sources},title:R},Y=new Yt.Player;Y.initVideo(ze);const Ht=ne.lastChild,qe=new H.Subscription;qe.add(Y.info.position$.subscribe(function(be){y(Z,Y.info.duration$.getValue(),be)})).add(Y.events.canplay$.subscribe(function(){Gt||_e(Y,t),V&&Y.setPlaybackRate(V)})),Ht&&(ne.style.display="none",ne.classList.add(g));const se=e.createPlayer({listId:p.id,itemId:Z,player:Y,container:ne,sources:dt(p,_).sources,config:ze,subscription:qe});return I&&u(p.id,se.itemId,g),S&&se.player.play(),v&&!S&&se.player.prepare(),s.emit(Se.playerCreated,se.player),{player:se.player,config:se.config}}function j(){h(),a=null}function h(){a==null||a.off(b.chapterChanged,C),e.removeAll(),r={},l=!1,c=!1}async function m({source:p,initialChapter:g,container:v}){if(!a)throw Error("need to set interactive controller");await a.setManifest(p),h(),d=v;const{media:I,chapter:S}=await a.setChapter({chapterId:g});if(I){a.on(b.chapterChanged,C);const{player:_,config:R}=await E({media:I,chapterId:S.id,title:S.label});return s.emit(Se.initiated,{container:v,media:I,chapterId:S.id}),{player:_,config:R}}else console.error("not found")}return{...e,on:s.on.bind(s),off:s.off.bind(s),init:m,setInteractiveController:f,createPlayer:E,removeAll:j,getActivePlayer:function(){return r}}}const Qi=3e3,Ki=()=>{let i=[],e=null;return{setPlayer:c=>{e=c},setContainers:c=>{i=c},deleteContainer:c=>{i=i.filter(a=>a.id!==c)},getNextInteractiveTime:(c=Qi)=>{if(!i.length||e===null)return null;let a=-1,l=!1;const d=e.info.position$.getValue()*1e3;for(const f of i){const u=f.startTime-c;if(u<=d&&(d<=f.endTime||f.endTime===null)){l=!0;break}d<u&&(a=a===-1?u:Math.min(a,u))}return!l&&a!==-1?a:null}}},ce=Ki(),O=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),Ue=i=>le(i)&&!jt(i),$t=i=>jt(i.branches)||i.order==="end",Xi=(i,e)=>{var t;const n=i*1e3;return Ue(e.controls)&&n<((t=e.startTime)!==null&&t!==void 0?t:0)},ht=(i,e)=>{var t,n;const s=i*1e3;return Ue(e.controls)&&s>=((t=e.startTime)!==null&&t!==void 0?t:0)&&s<=((n=e.endTime)!==null&&n!==void 0?n:1/0)},xe=i=>i.some(e=>e.action.type==="expect"),ut=i=>i.find(e=>e.action.type==="expect"),Zi=({fn:i,type:e=1},...t)=>(...n)=>e?i(...n,...t):i({...n[e],...t[e]}),Yi=(i=[])=>i.reduce((e,t,n)=>{var s,r,c;const a=((s=t==null?void 0:t.controls)!==null&&s!==void 0?s:[]).filter(l=>!ji(l));if(Ue(a)){const l=[(r=t.startTime)!==null&&r!==void 0?r:0,(c=t.endTime)!==null&&c!==void 0?c:1/0],d=t.id;if(!n)e.push({subjects:[d],range:l});else{const f=[];let u=-1/0,y=1/0,C=[];const E=[];for(let j=0;j<e.length;j++){const h=e[j];if(E.push(...h.subjects),h.range[0]<y&&(y=h.range[0]),h.range[1]>u&&(u=h.range[1]),h.range[0]<=l[0]&&h.range[1]>=l[1])return e[j].subjects.push(d),e;l[0]>=h.range[0]&&l[0]<=h.range[1]&&(f.push(j),C=C.concat(h.subjects),l[0]=h.range[0]),l[1]>=h.range[0]&&l[1]<=h.range[1]&&(f.push(j),C=C.concat(h.subjects),l[1]=h.range[1])}if(E.push(d),l[0]<=y&&l[1]>=u)return[{subjects:E,range:l}];f.length&&f.reverse().forEach(j=>{e.splice(j,1)}),e.push({subjects:C.concat([d]),range:l})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]),Ji=(i,e)=>xe(i.events)?!1:e.some(({container:t})=>t.container.id!==i.id&&xe(t.container.events)&&t.container.endTime===i.endTime&&!t.isRemoved);class en{constructor({player:e,container:t,branches:n,selectBranches:s,interactiveEvents:r,globalEventEmitter:c,ignoreContainerEvent:a}){this.hide=()=>{setTimeout(()=>{var l,d;this.gameState!==O.end&&(xe(this.container.container.events)&&this.gameState===O.afterInteractive||this.selectBranches.state.isExpect||((d=(l=this.container).hide)===null||d===void 0||d.call(l),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1})))})},this.show=()=>{var l,d;if(this.gameState===O.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())(d=(l=this.container).show)===null||d===void 0||d.call(l),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!0,isFirst:!1});else{const u=Zi({fn:this.selectBranches.onControlEvent,type:0},{branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1})},onEvent:(y,C)=>{this.isSelectedControlEvent=!0,y!==!1&&(this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1})),(this.gameState===O.end||this.gameState===O.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),C(),this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1})),ce.deleteContainer(this.container.container.id)},isEOV:()=>this.gameState===O.end});this.container.createView(u),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!0,isFirst:!0})}},this.onEndOfVideo=()=>{this.gameState=O.end,this.selectContainerEvent(!0)},this.whilePlaying=()=>{var l,d,f,u;if(((l=this.player.experimental.element$.getValue())===null||l===void 0?void 0:l.readyState)<1||[O.destroyed,O.removed].includes(this.gameState))return;const C=this.player.getExactTime();if(Xi(C,this.container.container))this.gameState!==O.beforeInteractive&&(this.gameState=O.beforeInteractive,this.onBeforeStartTime());else if(ht(C,this.container.container))this.gameState!==O.interactive&&(this.gameState=O.interactive,this.onStartTime());else if(this.gameState!==O.afterInteractive){const h=this.gameState;this.gameState=O.afterInteractive,h===O.interactive&&this.onEndTime()}else this.gameState!==O.destroyed&&this.removeView();const E=ht(C,this.container.container),j=this.container.container.startTime?[this.container.container.startTime,(d=this.container.container.endTime)!==null&&d!==void 0?d:1/0]:[];(u=(f=this.container).onProgress)===null||u===void 0||u.call(f,C,E),this.globalEventEmitter.emit(b.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:j,currentTime:C,isInteractiveTime:E})},this.container=t,this.branches=n,this.selectBranches=s,this.subscription=new H.Subscription,this.player=e,this.interactiveEvents=r,this.ignoreContainerEvent=a,this.globalEventEmitter=c,this.gameState=O.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo))}selectContainerEvent(e=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,id:this.container.container.id}),!this.isSelectedControlEvent&&(this.isSelectedContainerEvent||(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime)))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);const e=xe(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)===null||t===void 0||t.call(e),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=O.beforeInteractive}removeView(){this.container.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.containerRemoved,visibility:!1}),this.gameState=O.removed}destroy(){var e;this.reset(),this.removeView(),this.gameState=O.destroyed,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!==null&&e!==void 0?e:1/0,id:this.container.container.id}),ce.deleteContainer(this.container.container.id)}}function tn(){const i={};function e(){for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&delete i[a];return!0}function t(a){const l={};for(const d in i)+d<=a&&(l[d]=i[d]);return l}function n(a){const l={};for(const d in i)+d>=a&&(l[d]=i[d]);return l}function s({timestamp:a,priority:l,initiator:d}){var f;if(Je(a)){const u=(f=i[a])!==null&&f!==void 0?f:null;if(u&&Ce(l,!0)){let y={};const C=u[l];if(C&&(y={...y,...C}),y=pe(y)?null:y,y&&Ce(d,!0)){const E=y[d];return E!=null?E:null}return y}return u}return null}function r({timestamp:a,priority:l,initiator:d}){if(Je(a))if(i[a]){if(Ce(l,!0))if(i[a][l]){if(Ce(d,!0))if(i[a][l][d]){if(delete i[a][l][d],!pe(i[a][l]))return!0}else return!1;if(delete i[a][l],!pe(i[a]))return!0}else return!1;return delete i[a]}else return!1}function c({timestamp:a,priority:l,initiator:d,...f}){var u,y,C;!((y=(u=i[a])===null||u===void 0?void 0:u[l])===null||y===void 0)&&y[d]?i[a][l][d].push({...f}):!((C=i[a])===null||C===void 0)&&C[l]?i[a][l]={...i[a][l],[d]:[{...f}]}:i[a]?i[a]={...i[a],[l]:{[d]:[{...f}]}}:i[a]={[l]:{[d]:[{...f}]}}}return{map:i,remove:r,add:c,removeAll:e,get:s,getLte:t,getGte:n}}const nn=[A.expect,A.setNextBranch],sn=1/0;function ft(i){let e=i,t;const n=rn(),s=new tn;let r;const c=()=>{u(),j()},a=h=>{s.add.call(void 0,h),y()},l=(h=[])=>{for(const m of h)if(m.action(),nn.includes(m.actionType))break},d=h=>{var m,p,g;if(!n.isReady(h))return;const v=we((m=s.get({timestamp:h,priority:"control"}))!==null&&m!==void 0?m:{}),I=we((p=s.get({timestamp:h,priority:"container"}))!==null&&p!==void 0?p:{}),S=we((g=s.get({timestamp:h,priority:"chapter"}))!==null&&g!==void 0?g:{});l([...v,...I,...S])},f=()=>{var h;l([...we((h=s.get({timestamp:1/0,priority:"chapter"}))!==null&&h!==void 0?h:{})])},u=()=>{t&&(r==null||r.unsubscribe(),t=void 0)},y=()=>{t||(t=()=>setTimeout(()=>{d(1/0)}),r=e.events.ended$.subscribe(t))},C=h=>{u(),e=h},E=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),s.remove(h)},j=()=>{n.release(),s.removeAll()};return{setPlayer:C,add:a,remove:E,exec:d,execEndOfVideo:f,listen:y,unlisten:u,release:c,containersEventsCallState:n}}function rn(){const i=new Map;return{setCalled:({timestamp:c,id:a})=>{const l=i.get(c);l&&l[a]!==void 0&&(l[a]=!0)},setData:(c=[])=>{var a,l;for(const d of c){const f=(a=d.endTime)!==null&&a!==void 0?a:sn,u=(l=i.get(f))!==null&&l!==void 0?l:{};i.set(f,{...u,[d.id]:!1})}},resetCalled:c=>{const a=i.get(c);if(a)for(const l in a)a[l]=!1},isReady:c=>{const a=i.get(c);return a?!Object.values(a).some(l=>!l):!0},release:()=>i.clear()}}function we(i){return Object.values(i).flat().sort(e=>e.actionType===A.expect?-1:1)}const an=(i,e)=>{const{height:t,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&n))return{videoContentHeight:0,videoContentWidth:0};const{clientHeight:s,clientWidth:r}=e.experimental.element$.value||{};if(!(s&&r))return{videoContentHeight:0,videoContentWidth:0};const c=t/n,a=s/r;let l,d;return a>c?(d=r,l=r*c):a<c?(d=s/c,l=s):(d=r,l=s),{videoContentWidth:d,videoContentHeight:l}},on=250;function ln(i){let e=()=>{};const t=new ResizeObserver(a=>{r(a),e=r.bind(null,a)});function n(a){const{parentElement:l,player:d}=i();if(l&&d){const{videoContentWidth:f,videoContentHeight:u}=an(l,d);l.style.setProperty("--interactive-content-width",`${f}px`),l.style.setProperty("--interactive-content-height",`${u}px`),l.style.setProperty("--interactive-width",`${a[0].contentRect.width}px`),l.style.setProperty("--interactive-height",`${a[0].contentRect.height}px`)}}function s(){const{parentElement:a}=i();a.removeAttribute("style")}const r=Lt(a=>{const{fns:l=[]}=i();n(a);for(const d of l)d()},on);function c(){e=void 0,t.disconnect(),s()}return{resizeObserver:t,calc:()=>{e()},release:c}}class cn{constructor(){this.map={}}push(e,t){e in this.map?this.map[e].push(t):this.map[e]=[t]}get(e){const t=this.map[e];return t?t.slice():null}getAll(){const e=[];for(const t in this.map)e.push(...this.map[t]);return e}remove(e,t){e in this.map&&(this.map[e]=this.map[e].filter(n=>n!==t),this.map[e].length===0&&delete this.map[e])}clear(){this.map={}}size(){return Object.keys(this.map).length}keys(){return Object.keys(this.map)}}const dn=i=>Math.floor(Math.random()*i),hn=i=>{let e=i.length,t=1/0,n=null;for(;e--;)i[e].weight<t&&(t=i[e].weight,n=i[e]);return n},un=i=>{let e=i.length,t=-1/0,n=null;for(;e--;)i[e].weight>t&&(t=i[e].weight,n=i[e]);return n},fn=i=>{const e=i.length,t=dn(e);return i[t]},pt=1,pn=i=>{var e,t;let n=0;for(let r=0;r<i.length;++r)n+=(e=i[r].weight)!==null&&e!==void 0?e:pt;const s=Math.random()*n;n=0;for(let r=0;r<i.length-1;++r)if(n+=(t=i[r].weight)!==null&&t!==void 0?t:pt,n>=s)return i[r];return i[i.length-1]},vt=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0}),Le=(i,e=!1)=>({...i,args:e?{...i.args,...vt}:{...vt,...i.args}}),mt=({globalEventEmitter:i,player:e,interactiveEvents:t,removeControllers:n})=>{const s={isExpect:!1},r=()=>{s.isExpect&&(s.isExpect=!1)},c=({action:h,controlType:m,controlId:p,containerId:g,branches:v=[],onEvent:I,isEOV:S=()=>!1})=>{const _=Le(h,S()),R={timestamp:1/0,priority:"control",initiator:p,actionType:_.type},V=i.emit.bind(i,b.interactives,{subjectId:p,subjectType:m,subjectName:"control",type:N.actionChoice,actionType:h.type,payload:{containerId:g,..._.args}});switch(_.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{const P=v.find($=>$.id===_.args.branchId);if(!P)return;I(_.args.isDetachContainer,y.bind(null,{subjectId:p,subjectName:"control"})),V(),_.args.shouldOpenNow?E({subjectId:p,subjectName:"control",subjectType:m,action:_,payload:{chapterId:P.chapterId,autoSelect:!1}}):(t.add({...R,action:E.bind(null,{subjectId:p,subjectName:"control",subjectType:m,action:_,payload:{chapterId:P.chapterId,autoSelect:!1}})}),n==null||n());return}case A.continuePlayback.trim().toLowerCase():{I(_.args.isDetachContainer,y.bind(null,{subjectId:p,subjectName:"control"})),V(),_.args.shouldOpenNow?C({subjectId:p,subjectName:"control",subjectType:m,action:h}):t.add({...R,action:C.bind(null,{subjectId:p,subjectName:"control",subjectType:m,action:h})});return}case A.openURI.trim().toLowerCase():{I(_.args.isDetachContainer,y.bind(null,{subjectId:p,subjectName:"control"})),V(),_.args.shouldOpenNow?j({subjectId:p,subjectName:"control",subjectType:m,action:_,payload:{URI:h.args.uri}}):(t.add({...R,action:j.bind(null,{subjectId:p,subjectName:"control",subjectType:m,action:_,payload:{URI:h.args.uri}})}),n==null||n());return}default:console.error("Unexpected control event"),i.emit(b.errors,new L(L.Severity.RECOVERABLE,L.Category.INTERACTIVES,{message:"Unexpected control event"}));return}},a=({action:h,container:{id:m,endTime:p},branches:g=[],isEOV:v=!1,autoSelected:I=!1})=>{const S=Le(h,v),_={timestamp:!S.args.shouldOpenNow||v?1/0:p,priority:"container",initiator:m,actionType:S.type},R=i.emit.bind(i,b.interactives,{subjectId:m,subjectName:"container",type:N.actionChoice,actionType:S.type,payload:S.args});switch(S.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{const V=g.find(P=>P.id===S.args.branchId);if(!V)return;R(),t.add({..._,action:E.bind(null,{subjectId:m,subjectName:"container",action:S,payload:{chapterId:V.chapterId,autoSelect:I}})}),n==null||n();return}case A.setMaxWeightBranch.trim().toLowerCase():return;case A.setMinWeightBranch.trim().toLowerCase():return;case A.setRandomBranch.trim().toLowerCase():return;case A.setWeightlessRandomBranch.trim().toLowerCase():return;case A.continuePlayback.trim().toLowerCase():{R(),t.add({..._,action:C.bind(null,{subjectId:m,subjectName:"container",action:S})});return}case A.openURI.trim().toLowerCase():{R(),t.add({..._,action:j.bind(null,{subjectId:m,subjectName:"container",action:S,payload:{URI:h.args.uri}})}),n==null||n();return}default:console.error("Unexpected container event"),i.emit(b.errors,new L(L.Severity.RECOVERABLE,L.Category.INTERACTIVES,{message:"Unexpected container event"}));return}};function l({container:h,branches:m,isEOV:p=!1}){const g=ut(h.events);if(g){const v=Le(g.action,p);i.emit(b.interactives,{subjectId:h.id,subjectName:"container",type:N.actionChoice,actionType:v.type,payload:v.args}),t.add({timestamp:p?1/0:h.endTime,priority:"container",initiator:h.id,actionType:A.expect,action:u.bind(null,{subjectId:h.id,subjectName:"container"})}),s.isExpect=!0}else for(const v of h.events)a({action:v.action,container:h,branches:m,isEOV:p})}const d=({chapterId:h,action:m,branches:p=[]})=>{const g=i.emit.bind(i,b.interactives,{subjectId:h,subjectName:"chapter",type:N.actionChoice,actionType:m.type,payload:m.args});switch(m.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{const v=p.find(I=>I.id===m.args.branchId);return v!=null&&v.chapterId?(g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:m,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.setWeightlessRandomBranch.trim().toLowerCase():{const v=fn(p);return v!=null&&v.chapterId?(g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:m,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.setRandomBranch.trim().toLowerCase():{const v=pn(p);return v!=null&&v.chapterId?(g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:m,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.setMaxWeightBranch.trim().toLowerCase():{const v=un(p);return v!=null&&v.chapterId?(g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:m,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.setMinWeightBranch.trim().toLowerCase():{const v=hn(p);return v!=null&&v.chapterId?(g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:m,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.continuePlayback.trim().toLowerCase():return g(),C.bind(null,{subjectId:h,subjectName:"chapter",action:m});case A.openURI.trim().toLowerCase():return g(),j.bind(null,{subjectId:h,subjectName:"chapter",action:m,payload:{URI:m.args.uri}});default:console.error("Unexpected chapter event"),i.emit(b.errors,new L(L.Severity.RECOVERABLE,L.Category.INTERACTIVES,{message:"Unexpected chapter event"}));return}};function f(h){const m=ut(h.events);if(m){if($t(h))return;i.emit(b.interactives,{subjectId:h.id,subjectName:"chapter",type:N.actionChoice,actionType:m.action.type,payload:m.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:A.expect,action:u.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else h.events.forEach(p=>{const g=d({chapterId:h.id,action:p.action,branches:h.branches});g&&t.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:p.action.type,action:g})})}const u=({subjectId:h,subjectName:m,action:p})=>{var g;e.pause(),i.emit(b.interactives,{subjectId:h,subjectName:m,type:N.actionExecution,actionType:(g=p==null?void 0:p.type)!==null&&g!==void 0?g:A.expect})},y=({subjectId:h,subjectName:m})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),i.emit(b.interactives,{subjectId:h,subjectName:m,type:N.actionExecution,actionType:"after-expect"})},C=({subjectId:h,subjectName:m,subjectType:p,action:g})=>{i.emit(b.interactives,{subjectId:h,subjectName:m,subjectType:p,type:N.actionExecution,actionType:g.type})},E=({subjectId:h,subjectName:m,subjectType:p,action:g,payload:v})=>{v.behaviour="change-chapter",i.emit(b.interactives,{subjectId:h,subjectName:m,subjectType:p,type:N.actionExecution,actionType:g.type,payload:v})},j=({subjectId:h,subjectName:m,subjectType:p,action:g,payload:v})=>{if(!v.URI)return;const I=window.open(v.URI,"_blank","noopener,noreferrer");I&&(I.opener=null),i.emit(b.interactives,{subjectId:h,subjectName:m,subjectType:p,type:N.actionExecution,actionType:g.type})};return{onControlEvent:c,onContainerEvent:a,onChapterEvent:d,onExpectEvent:u,expectEventHandler:y,setManifestChapterEvents:f,setManifestContainerEvents:l,stopExpect:r,state:s}};var he,Dt,Ve,gt;class q{constructor(e,t,n,s){this.target=e,this.type=t,this.listener=n,this.options=o(q,he,"m",Dt).call(q,e,s),this.target.addEventListener(t,n,this.options)}unlisten(){this.target.removeEventListener(this.type,this.listener,this.options),this.target=null,this.listener=null,this.options=!1}}he=q,Dt=function(e,t){if(t===void 0)return!1;if(typeof t=="boolean")return t;{const n=new Set(["passive","capture"]),s=Object.keys(t).filter(c=>!n.has(c));return s.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+s.join(",")),o(q,he,"m",gt).call(q,e)?t:t.capture||!1}},gt=function(e){let t=o(q,he,"f",Ve);if(t===void 0){t=!1;try{const n={},s={get:()=>(t=!0,!1)};Object.defineProperty(n,"passive",s),Object.defineProperty(n,"capture",s);const r=()=>{};e.addEventListener("test",r,n),e.removeEventListener("test",r,n)}catch(n){t=!1}w(q,he,t,"f",Ve)}return t||!1};Ve={value:void 0};class vn{constructor(){this.bindingMap=new cn}release(){this.removeAll(),this.bindingMap=null}listen(e,t,n,s){if(!this.bindingMap)return;const r=new q(e,t,n,s);this.bindingMap.push(t,r)}listenOnce(e,t,n,s){const r=c=>{this.unlisten(e,t,r),n(c)};this.listen(e,t,r,s)}unlisten(e,t,n){if(!this.bindingMap)return;const s=this.bindingMap.get(t)||[];for(const r of s)r.target===e&&(n===r.listener||!n)&&(r.unlisten(),this.bindingMap.remove(t,r))}removeAll(){if(!this.bindingMap)return;const e=this.bindingMap.getAll();for(const t of e)t.unlisten();this.bindingMap.clear()}}class mn{constructor(){this._prevSizeId=0,this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))===null||e===void 0||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var e;const t=(e=this.rootElement.getContext("2d"))===null||e===void 0?void 0:e.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!t)return!1;const n=t.data,s=n.length;for(let r=3;r<s;r+=40)if(n[r]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))===null||e===void 0||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}async updateCanvasDimensions(e,t=!1){const n=e.width+e.height;if(this._prevSizeId===n)return;let s;t&&(s=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&s&&this.restore(s),this._prevSizeId=n}async save(){const e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))===null||t===void 0||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}}class gn{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){this.currentVideoDurationMs=1/0,this._containerTimeFrameShouldReceived=!1,this._endTimeFrameReceived=!1,this._shouldCallSkip=!1,this.onEachTick=s=>{const r=s!=null?s:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,c=this.isChapterEndTime(r);if(this.isContainerTime(r))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 Ut=Object.create;var Qe=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var qt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Kt=Object.prototype.hasOwnProperty;var Xt=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of qt(e))!Kt.call(i,s)&&s!==t&&Qe(i,s,{get:()=>e[s],enumerable:!(n=zt(e,s))||n.enumerable});return i};var Zt=(i,e,t)=>(t=i!=null?Ut(Qt(i)):{},Xt(e||!i||!i.__esModule?Qe(t,"default",{value:i,enumerable:!0}):t,i));var G=require("@vkontakte/videoplayer-shared/es2018.cjs.js"),Be=require("uuid"),Yt=require("@vkontakte/videoplayer-core/es2018.cjs.js");const Jt="1.0.6-dev.5a11a96.0";function Ct(i,e=1){let t="0",n="0",s="0";return i.length===4?(t="0x"+i[1]+i[1],n="0x"+i[2]+i[2],s="0x"+i[3]+i[3]):i.length===7&&(t="0x"+i[1]+i[2],n="0x"+i[3]+i[4],s="0x"+i[5]+i[6]),`rgba(${+t},${+n},${+s},${e})`}const W="SDK_NAME",ei="SDK_NAME-controls-container",Et=()=>document.querySelector(`.${ei}`),z={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"},Xe={start:"flex-start",end:"flex-end",center:"center"},Ze={start:"left",end:"right",center:"center"},wt=({target:i,props:e})=>{var t,n,s,r,c,o;i.style.alignItems=(n=Ke[(t=e==null?void 0:e.text)===null||t===void 0?void 0:t.gravityVertical])!==null&&n!==void 0?n:Ke.center,i.style.justifyContent=(r=Xe[(s=e==null?void 0:e.text)===null||s===void 0?void 0:s.gravityHorizontal])!==null&&r!==void 0?r:Xe.center,i.style.textAlign=(o=Ze[(c=e==null?void 0:e.text)===null||c===void 0?void 0:c.alignment])!==null&&o!==void 0?o:Ze.start},_t=({target:i,props:e,fallback:t,dependsOn:n})=>{var s,r,c,o,l,d;i.style.color=(r=(s=e==null?void 0:e.text)===null||s===void 0?void 0:s.color)!==null&&r!==void 0?r:t.textColor,i.style.fontSize=`calc(${n.height} * ${(o=(c=e==null?void 0:e.text)===null||c===void 0?void 0:c.size)!==null&&o!==void 0?o:t.textSize})`,i.textContent=(d=(l=e==null?void 0:e.text)===null||l===void 0?void 0:l.value)!==null&&d!==void 0?d:t.textContent},It=({target:i,props:e,fallback:t})=>{var n,s,r,c;i.style.backgroundColor=Ct((s=(n=e==null?void 0:e.background)===null||n===void 0?void 0:n.color)!==null&&s!==void 0?s:t.backgroundColor,(c=(r=e==null?void 0:e.background)===null||r===void 0?void 0:r.alpha)!==null&&c!==void 0?c:t.backgroundAlpha)},St=({target:i,props:e,fallback:t,dependsOn:n})=>{var s,r,c,o,l,d,f,u,y,C,E;i.style.border=`calc(${n.height} * ${(c=(r=(s=e==null?void 0:e.shape)===null||s===void 0?void 0:s.border)===null||r===void 0?void 0:r.width)!==null&&c!==void 0?c:t.borderWidth}) solid ${Ct((d=(l=(o=e==null?void 0:e.shape)===null||o===void 0?void 0:o.border)===null||l===void 0?void 0:l.color)!==null&&d!==void 0?d:t.borderColor,(y=(u=(f=e==null?void 0:e.shape)===null||f===void 0?void 0:f.border)===null||u===void 0?void 0:u.alpha)!==null&&y!==void 0?y:t.borderAlpha)}`,i.style.borderRadius=`calc(${n.height} * ${(E=(C=e==null?void 0:e.shape)===null||C===void 0?void 0:C.roundCorners)!==null&&E!==void 0?E:t.roundCorners})`},$e=({target:i,layoutParams:e,fallback:t})=>{var n;i.style.transform=`rotate(${(n=-e.angle)!==null&&n!==void 0?n:t.angle}rad)`};class De{constructor(e){this.control=e}createView(e){var t;const n=document.createElement("div");n.classList.add(`${W}-control-container-${this.control.id}`),e(n,this.control.layoutParams);const s=((t=this.control.layoutParams.innerSizesDependOn)!==null&&t!==void 0?t:z.innerSizesDependOn)==="self"?{height:n.style.height,width:n.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:n,dependsOn:s}}setEvents(e,t){e&&this.control.events.forEach(n=>{switch(n.type.trim().toLowerCase()){case"onclick":e.addEventListener("click",r=>{r.stopPropagation(),t&&t({action:n.action,controlId:this.control.id,controlType:this.control.type})});break}})}getElement(){return document.querySelector(`.${W}-control-container-${this.control.id}`)}}const Tt=i=>{if(i.type.trim().toLowerCase()==="area")return new ti(i)};class ti extends De{constructor(e){super(e)}createView({parent:e,layoutFn:t}){const{dependsOn:n,controlContainerEl:s}=super.createView(t),r=document.createElement("button");return r.classList.add(`${W}-${this.control.id}`),r.style.display="flex",r.style.width="100%",r.style.height="100%",r.style.cursor="pointer",r.type="button",It({target:r,props:this.control.props,fallback:{...z,backgroundColor:"transparent"}}),St({target:r,props:this.control.props,fallback:{...z,borderAlpha:0},dependsOn:n}),$e({target:r,layoutParams:this.control.layoutParams,fallback:z}),s.append(r),e.append(s),s}getElement(){return document.querySelector(`.${W}-${this.control.id}`)}}const Rt=i=>{if(i.type.trim().toLowerCase()==="button")return new ii(i)};class ii extends De{constructor(e){super(e)}createView({parent:e,layoutFn:t}){const{dependsOn:n,controlContainerEl:s}=super.createView(t),r=document.createElement("button");r.type="button",r.classList.add(`${W}-${this.control.id}`),r.style.display="flex",r.style.width="100%",r.style.height="100%",r.style.cursor="pointer",r.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",$e({target:r,layoutParams:this.control.layoutParams,fallback:z}),It({target:r,props:this.control.props,fallback:z}),St({target:r,props:this.control.props,fallback:z,dependsOn:n}),wt({target:r,props:this.control.props}),_t({target:c,props:this.control.props,fallback:z,dependsOn:n}),r.append(c),s.append(r),e.append(s),s}getElement(){return document.querySelector(`.${W}-${this.control.id}`)}}const ni=i=>{if(i.type.trim().toLowerCase()==="text")return new si(i)};class si extends De{constructor(e){super(e)}createView({parent:e,layoutFn:t}){const{dependsOn:n,controlContainerEl:s}=super.createView(t),r=document.createElement("div");r.classList.add(`${W}-${this.control.id}`),r.style.display="flex",r.style.width="100%",r.style.height="100%",r.style.fontFamily="inherit";const c=document.createElement("span");return c.style.whiteSpace="pre",$e({target:r,layoutParams:this.control.layoutParams,fallback:z}),wt({target:r,props:this.control.props}),_t({target:c,props:this.control.props,fallback:z,dependsOn:n}),r.append(c),s.append(r),e.append(s),s}getElement(){return document.querySelector(`.${W}-${this.control.id}`)}}class ri{constructor(e){this.layout=e}}const ai=i=>{if(i.type.trim().toLowerCase()==="relative")return new At(i)};class At extends ri{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,t){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${t.width})`,e.style.height=`calc(var(--interactive-content-height) * ${t.height})`,e.style.left=`calc(var(--interactive-content-width) * ${t.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${t.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}}function a(i,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(i):n?n.value:e.get(i)}function _(i,e,t,n,s){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!s:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?s.call(i,t):s?s.value=t:e.set(i,t),t}var re,Ie,Ye;class xt{constructor(e){re.add(this),this.container=e,this.factories=new Map,a(this,re,"m",Ie).call(this)}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),a(this,re,"m",Ie).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),a(this,re,"m",Ie).call(this)}}re=new WeakSet,Ie=function(){this.controls=a(this,re,"m",Ye).call(this)},Ye=function(){var e;return(e=this.container.controls)===null||e===void 0?void 0:e.reduce((t,n)=>{const s=n.type.trim().toLowerCase(),r=this.factories.get(s);return r?[...t,r(n)]:[...t]},[])};const Ot=(i,e)=>{if(i.type.trim().toLowerCase()==="choice")return new oi(i,e)};class oi extends xt{constructor(e,t){super(e),this.rootElement=t!=null?t:Et(),this.layout=new At(this.container.layout),this.isRemoved=!1,this.addControlFactory("button",Rt),this.addControlFactory("text",ni),this.addControlFactory("area",Tt)}createView(e){const t=document.createElement("div");return t.classList.add(`${W}-${this.container.id}`),this.layout.setContainerLayout(t),this.controls.forEach(n=>{const s=n.createView({parent:t,layoutFn:this.layout.setControlLayout});n.setEvents(s,e)}),this.rootElement.append(t),t}hide(){const e=this.getElement();e&&(e.style.visibility="hidden")}show(){const e=this.getElement();e&&(e.style.visibility="visible")}removeView(){var e;this.isRemoved||((e=this.getElement())===null||e===void 0||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${W}-${this.container.id}`)}}function Lt(i,e){let t;return(...n)=>{clearTimeout(t),t=setTimeout(()=>i(...n),e)}}const ge={Object:"Object",String:"String",Array:"Array",Number:"Number",Function:"Function",Boolean:"Boolean"},de=(i,e)=>Object.prototype.toString.call(i)===`[object ${e}]`,We=i=>de(i,ge.Object),Ne=i=>de(i,ge.String),le=i=>de(i,ge.Array),Nt=i=>de(i,ge.Number),li=i=>de(i,ge.Function),Je=i=>Nt(i)&&!isNaN(i),ci=i=>i==null,pe=i=>We(i)&&Object.keys(i).length===0,jt=i=>le(i)&&!i.length,Ce=(i,e)=>Ne(i)&&(e?i.trim():i).length,Mt=window.navigator.userAgent.toLowerCase(),di=/mobi/i.test(Mt);Mt.indexOf("android")>-1;const hi="video_interactive",ui="videoint",fi=250;class pi{constructor(e){this.onResize=t=>{this.isReady&&(!t[0].contentRect.width||!t[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:t[0].contentRect.width,height:t[0].contentRect.height}))},this.handleChapterChange=t=>{var n;if(this.isReady){if(this.isHidden||this.hide(),!(t!=null&&t.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(t.id),this.ngEditor.selectChapter(t.id),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=t.id,this.lastZoomInfo=void 0}},this.handleManifestChange=async(t,n=[])=>{var s;if(!Nt(t.graph.edit.chapters[0].x)){this.isReady=!1,(s=this.onError)===null||s===void 0||s.call(this,"Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=void 0,!this.ngEditor){let r;try{r=await G.loadVKLangPack(this.lang,hi,ui)}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:r}),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),t.metadata.id!==this.currentManifestId?(this.ngEditor.update(t),this.currentManifestId=t.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0},this.init(e)}init({root:e,onOpenPreviewClick:t,onError:n,lang:s,visitedChapters:r=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(r),this.onOpenPreviewClick=t,this.onError=n,this.lang=s!=null?s:"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=vi(e),this.resizeObserver=new ResizeObserver(Lt(this.onResize,fi)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor.updateVideosInfo(e)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var e,t;this.hide(),this.resizeObserver.disconnect(),(e=this.ngEditor)===null||e===void 0||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(t=this.ngEditor)===null||t===void 0||t.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}}function vi(i){const e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",i.append(e),e}const mi=(i={})=>{var e;return Array.from(new Set((e=i.sessions)===null||e===void 0?void 0:e.map(t=>{var n;return(n=t.visitedChapters.map(s=>s.chapterId))!==null&&n!==void 0?n:[]}).flat()))},et=(i=[],e="")=>i.reduce((t,n)=>(t.find(s=>s[e]===n[e])||t.push(n),t),[]),tt="chapterId";class ae{constructor(e){var t;this.id=(t=e==null?void 0:e.id)!==null&&t!==void 0?t:Be.v4(),this.startDate=e!=null&&e.startDate?new Date(e.startDate).toISOString():new Date(Date.now()).toISOString(),this.updateOn=e!=null&&e.updateOn?new Date(e.updateOn).toISOString():null,this.visitedChapters=e!=null&&e.visitedChapters?et(Array.from(e.visitedChapters),tt):[],this.branches=le(e==null?void 0:e.branches)?e.branches:[]}update(e){e!=null&&e.startDate&&(this.startDate=new Date(e.startDate).toISOString()),e!=null&&e.updateOn&&(this.updateOn=new Date(e.updateOn).toISOString()),le(e==null?void 0:e.visitedChapters)&&(this.visitedChapters=et([...this.visitedChapters,...e.visitedChapters],tt)),le(e==null?void 0:e.branches)&&(this.branches=this.branches.concat(e.branches))}getSession(){return{...this}}static createVisitedChapter(e){return[{chapterId:e}]}static createBranch(e,t,n){return[{chapterId:e,branchId:t,autoSelect:n}]}}class Ee{constructor(e){var t,n;this.id=(t=e==null?void 0:e.id)!==null&&t!==void 0?t:Be.v4(),this.manifestId=e==null?void 0:e.manifestId,this.manifestVersion=e==null?void 0:e.manifestVersion,this.manifestBuild=e==null?void 0:e.manifestBuild,this.sessions=le(e==null?void 0:e.sessions)?e==null?void 0:e.sessions.map(s=>new ae(s)):[],this.isCompleted=(n=e==null?void 0:e.isCompleted)!==null&&n!==void 0?n:!1}update(e){var t,n,s,r,c;this.id=(t=e==null?void 0:e.id)!==null&&t!==void 0?t:this.id,this.manifestId=(n=e==null?void 0:e.manifestId)!==null&&n!==void 0?n:this.manifestId,this.manifestVersion=(s=e==null?void 0:e.manifestVersion)!==null&&s!==void 0?s:this.manifestVersion,this.manifestBuild=(r=e==null?void 0:e.manifestBuild)!==null&&r!==void 0?r:this.manifestBuild,this.isCompleted=(c=e==null?void 0:e.isCompleted)!==null&&c!==void 0?c:this.isCompleted}addSession(e){this.sessions.push(new ae(e))}updateSession(e,t){let n;ci(e)?n=this.sessions[this.sessions.length-1]:n=this.sessions.find(s=>s.id===e),n&&n.update(t)}resetSession(){this.sessions=[]}getHistory(){return{...this,sessions:this.sessions.map(e=>e.getSession())}}}const je="SDK_NAME-history-changed";class gi extends EventTarget{constructor(){super(),this.history=new Ee,this.sendEvent()}onChapterChange({chapterId:e,mediaId:t,autoSelect:n=!1,isLastChapter:s=!1}){this.history.isCompleted?this.history=new Ee({manifestId:this.history.manifestId,manifestVersion:this.history.manifestVersion,manifestBuild:this.history.manifestBuild}):s&&this.history.update({isCompleted:!0}),this.history.sessions.length?this.history.updateSession(null,{updateOn:Date.now(),visitedChapters:ae.createVisitedChapter(e),branches:ae.createBranch(e,t,n)}):this.history.addSession({updateOn:Date.now(),visitedChapters:ae.createVisitedChapter(e),branches:ae.createBranch(e,t,!1)}),this.sendEvent()}onManifestChange(e,t){t?this.history=new Ee(t):this.history=new Ee({manifestId:e.id,manifestVersion:e.version,manifestBuild:e.build}),this.history.addSession({updateOn:Date.now()}),this.sendEvent()}getHistory(){if(history)return this.history.getHistory()}sendEvent(){this.dispatchEvent(new CustomEvent(je,{bubbles:!1,detail:this.getHistory()}))}destroy(){this.history=void 0}}function yi(i,e){var t;if(!e||!i||!e.sessions.length)return;const n=e.sessions.reverse().find(s=>s.branches.length);return(t=n.branches[n.branches.length-1].chapterId)!==null&&t!==void 0?t:void 0}const me=(i="",e="")=>{i=i.split("."),e=e.split(".");let t=0;for(let n=0;n<Math.max(i.length,e.length)&&!t;n++)i[n]>e[n]?t=1:i[n]<e[n]?t=-1:t=0;return t},bi="3.1",it={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},Ci={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ei=i=>{const e=[];for(const t of i.chapters){let n;const s=[];for(const{isDefault:o,...l}of t.branches)o&&(n=l.id),s.push(l);let r=[];const c=[];for(const{fallbackStrategy:o,...l}of t.containers){const d=!!l.endTime;let f=[Ci];switch(o){case"await":d?f=[]:r=[];break;case"default":{const u={type:"onSuspense",action:{type:it.default,args:{branchId:n,shouldOpenNow:!d,isDetachContainer:!0}}};d?f=[u]:r=[u];break}case"random":case"weightlessRandom":case"max":case"min":{const u={type:"onSuspense",action:{type:it[o],args:{}}};d?f=[u]:r=[u];break}}for(const u of l.controls)c.push({...l,controls:[{...u}],id:Be.v4(),events:f})}e.push({...t,containers:c,events:r,branches:s})}return i.metadata.version=bi,i.metadata.updated=new Date().toISOString(),{...i,chapters:e}},wi="3.2",_i=i=>{if(!i.media){const{media:e,...t}=i.metadata;return{...i,metadata:{...t,version:wi},media:e}}return i},Ii="3.3",Si=(i=[])=>({edit:{chapters:i},view:{}}),nt={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ti=i=>{var e;const t=[],n=[];for(const s of i.chapters){const{id:r,x:c,y:o,...l}=s,d=l.containers.map(f=>{var u;return{...f,controls:f.controls.map(({subtype:y,type:C,...E})=>({...E,type:y!=null?y:C})),events:!((u=f.events)===null||u===void 0)&&u.length?f.events:[nt]}});t.push({id:r,...l,containers:d,events:!((e=l.events)===null||e===void 0)&&e.length?l.events:[nt]}),n.push({id:r,x:c,y:o})}return{...i,chapters:t,graph:Si(n),metadata:{...i.metadata,version:Ii}}},Ri=[{version:"3.0",migrate:Ei},{version:"3.1",migrate:_i},{version:"3.2",migrate:Ti}],Ai=i=>Ri.reduce((e,t)=>me(e.metadata.version,t.version)?e:t.migrate(e),i),xi=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),A=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 st={metadata:"Object",chapters:"Array"},Oi="3.0.0",Li="3.3.0",He=i=>{const e=me(i,Oi);return e===-1?!1:e===0?!0:me(i,Li)!==1},Ni=i=>{if(!We(i))return!1;for(const e in st)if(!i[e]||!de(i[e],st[e]))return!1;return He(i.metadata.version)},ji=i=>i.type===xi.Text;class L{constructor(e,t,...n){this.severity=e,this.category=t,this.data=n}toString(){return`SDK_NAME ERROR ${JSON.stringify(this,null," ")}`}}L.Severity={RECOVERABLE:1,CRITICAL:2};L.Category={VIDEO:0,INTERACTIVES:1,GRAPH:2,MANIFEST:3,LOADERS:4,HISTORY:5,SEAMLESS:6};class Vt{constructor(){this.listeners={}}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];const n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){const n=this.listeners[e];if(!n)return this;for(let s=n.length;s>0;s--)if(n[s]===t){n.splice(s,1);break}return this}emit(e,...t){const n=this.listeners[e];return n?(n.forEach(s=>{s(...t)}),!0):!1}listenerCount(e){return(this.listeners[e]||[]).length}rawListeners(e){return this.listeners[e]}}class Mi{constructor(e){this.addFn=(t,n=!1)=>{li(t)&&(this.fns.push(t),n&&this.updateFn())},this.removeFn=(t,n=!1)=>{this.fns=this.fns.filter(s=>s!==t),n&&this.updateFn()},this.updateFn=()=>{this.fn=()=>{this.fns.forEach(t=>t()),this.raf&&this.forceRequestAnimation()}},this.forceRequestAnimation=()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))},this.requestAnimation=()=>{this.raf||this.forceRequestAnimation()},this.cancelAnimation=()=>{cancelAnimationFrame(this.raf),this.raf=void 0},this.raf,this.fn,this.fns=[],this.addFn(e)}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}}class Vi{constructor(e){var t,n;this.loaders={chapterLoaders:(t=e==null?void 0:e.chapterLoaders)!==null&&t!==void 0?t:[],manifestLoaders:(n=e==null?void 0:e.manifestLoaders)!==null&&n!==void 0?n:[]}}async exec(e,t){return ki(...this.loaders[e])(t)}}function ki(...i){return async function(t){const n=[...i];for(;n.length>0;)t=await n.shift()(t);return t}}function Ae(i,e,t){return i?{...i,[e]:i[e]?[t,...i[e]]:[t]}:{[e]:[t]}}function Me({actions:i,errors:e,chapterId:t,...n}){if(t){const s=i.getManifest(),r=i.getChapter(s.chapters,t);if(r){const c=i.getMedia(s.media,r.videoId),o=i.getGraph(s.graph,r.id);return c?{...n,actions:i,errors:e,result:{chapter:r,media:c,graph:o}}:{...n,errors:Ae(e,Me.name,"Could not find media"),actions:i}}}return{...n,errors:Ae(e,Me.name,"Could not find chapter"),actions:i}}class rt{constructor(){Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){if(!(e in this.listeners))return;const n=this.listeners[e];for(let s=0,r=n.length;s<r;s++)if(n[s].callback===t){n.splice(s,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;const n=this.listeners[e.type].slice();for(let s=0,r=n.length;s<r;s++){const c=n[s];try{c.callback.call(this,e)}catch(o){Promise.resolve().then(()=>{throw o})}c.options&&c.options.once&&this.removeEventListener(e.type,c.callback)}return!e.defaultPrevented}}class kt extends rt{constructor(){super(),this.listeners||rt.call(this),Object.defineProperty(this,"aborted",{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"onabort",{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,"reason",{value:void 0,writable:!0,configurable:!0})}toString(){return"[object AbortSignal]"}dispatchEvent(e){e.type==="abort"&&(this.aborted=!0,typeof this.onabort=="function"&&this.onabort.call(this,e)),super.dispatchEvent(e)}}class Pi{constructor(){Object.defineProperty(this,"signal",{value:new kt,writable:!0,configurable:!0})}abort(e){let t;try{t=new Event("abort")}catch(s){typeof document!="undefined"?document.createEvent?(t=document.createEvent("Event"),t.initEvent("abort",!1,!1)):(t=document.createEventObject(),t.type="abort"):t={type:"abort",bubbles:!1,cancelable:!1}}let n=e;if(n===void 0)if(typeof document=="undefined")n=new Error("This operation was aborted"),n.name="AbortError";else try{n=new DOMException("signal is aborted without reason")}catch(s){n=new Error("This operation was aborted"),n.name="AbortError"}this.signal.reason=n,this.signal.dispatchEvent(t)}toString(){return"[object AbortController]"}}typeof Symbol!="undefined"&&Symbol.toStringTag&&(Pi.prototype[Symbol.toStringTag]="AbortController",kt.prototype[Symbol.toStringTag]="AbortSignal");function Pt(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 Fi(i){typeof i=="function"&&(i={fetch:i});const{fetch:e,Request:t=e.Request,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:s=!1}=i;if(!Pt({fetch:e,Request:t,AbortController:n,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:s}))return{fetch:e,Request:r};let r=t;(r&&!r.prototype.hasOwnProperty("signal")||s)&&(r=function(d,f){let u;f&&f.signal&&(u=f.signal,delete f.signal);const y=new t(d,f);return u&&Object.defineProperty(y,"signal",{writable:!1,enumerable:!1,configurable:!0,value:u}),y},r.prototype=t.prototype);const c=e;return{fetch:(l,d)=>{const f=r&&r.prototype.isPrototypeOf(l)?l.signal:d?d.signal:void 0;if(f){let u;try{u=new DOMException("Aborted","AbortError")}catch(C){u=new Error("Aborted"),u.name="AbortError"}if(f.aborted)return Promise.reject(u);const y=new Promise((C,E)=>{f.addEventListener("abort",()=>E(u),{once:!0})});return d&&d.signal&&delete d.signal,Promise.race([y,c(l,d)])}return c(l,d)},Request:r}}const Ge=Pt({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}),Ft=Ge?Fi({fetch:window.fetch,Request:window.Request,AbortController:window.AbortController}):void 0,at=Ge?Ft.fetch:window.fetch;Ge?Ft.Request:window.Request;const Bi=async i=>{try{let e,t;if(We(i))e=i;else if(Ne(i)){t=new URL(i).href;const s=await at(t);if(!s.ok)return{};e=await s.json()}else return{};if(!Ni(e))return{};const n=e.metadata.media;if(Ne(n)&&!e.media)try{let s;t?s=new URL(n,t).href:(s=new URL(n).href,t=s);const r=await at(s);if(!r.ok)throw new Error;e.metadata.media=await r.json()}catch(s){return Hi(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:t}}catch(e){return{}}};async function $i(i){const{manifest:e,manifestURL:t}=await Bi(i),n=Ai(e);return n.media=Di(n.media,t),delete n.metadata.media,n}function Oe(i,e){return i.find(t=>t.id===e)}function ot(i,e){var t,n;return!((t=i.edit)===null||t===void 0)&&t.chapters?i.edit.chapters.find(s=>s.id===e):!((n=i.view)===null||n===void 0)&&n.chapters?i.view.chapters.find(s=>s.id===e):void 0}function lt(i,e){return i.videos.find(t=>t.id===e)}function Di(i,e){return{...i,videos:i.videos.map(t=>({...t,variants:t.variants.map(n=>{const s=Wi(n.url,e);return{...n,url:s||n.url}})}))}}function Wi(i,e){try{return new URL(i,e).href}catch(t){return""}}function Hi(i){return me(i,"3.2.0")>=0}class Bt extends Vi{constructor(e,t){super(e),this.onError=t,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this}async setManifest(e){var t;this.release();const n=await this.exec("manifestLoaders",{actions:{addErrorMessage:Ae},result:null,errors:null,source:e});n.errors&&this.errorHandler(n.errors);const s=await $i((t=n.result)!==null&&t!==void 0?t:e);return this.manifest=s,this}async setInitial(){return this.setNext()}async setNext(e=this.manifest.metadata.initChapterId){const t=await this.exec("chapterLoaders",Me({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:ot,getChapter:Oe,getMedia:lt,getByBranches:this.getByBranches.bind(this),addErrorMessage:Ae},result:null,errors:null,chapterId:e}));return t.errors&&this.errorHandler(t.errors),this.chapter=t.result.chapter,this.media=t.result.media,this.graph=t.result.graph,this}errorHandler(e){this.onError(e),console.error("Something went wrong with loaders",{errors:e})}getInitial(){return this.getByChapterId(this.manifest.metadata.initChapterId)||null}getByChapterId(e=this.manifest.metadata.initChapterId){const t=Oe(this.manifest.chapters,e);if(t){const n=lt(this.manifest.media,t.videoId),s=ot(this.manifest.graph,t.id);if(n)return{chapter:t,media:n,graph:s}}return null}getBranches(e=this.chapter.id){if(e===this.chapter.id)return this.getByBranches(this.chapter.branches);{const t=Oe(this.manifest.chapters,e);return this.getByBranches(t==null?void 0:t.branches)}}getByBranches(e=[]){return e.reduce((t,n)=>{const s=this.getByChapterId(n.chapterId);return s&&t.push(s),t},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}}const b={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyChanged:"history-changed"},ct={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},N={actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function Gi(){const i=new Map;function e({listId:s=Math.random().toString(),itemId:r=Math.random().toString(),...c}){const o=i.get(s),l={...c};return o?o[r]=l:i.set(s,{[r]:l}),{listId:s,itemId:r,...c}}function t(s,r){var c,o,l;const d=i.get(s);if(d){if(r)return(c=d[r])===null||c===void 0||c.player.destroy(),(o=d[r])===null||o===void 0||o.container.remove(),(l=d[r])===null||l===void 0||l.subscription.unsubscribe(),delete d[r],Object.keys(d).length||i.delete(s),!0;for(const f of Object.values(d))f.player.destroy(),f.container.remove();return i.delete(s),!0}else throw Error("Can't remove. Not find.")}function n(){for(const s of i)t(s[0])}return{createPlayer:e,removePlayer:t,map:i,removeAll:n}}function dt(i,e=[]){let t={},n;const s=!e.length;for(const r of i.variants)switch(!n&&"cover"in r&&(n=r.cover),r.type){case"mp4":(s||e.includes("mp4"))&&(t={...t,MPEG:{"Invariant quality":r.url}});break;case"hls":(s||e.includes("hls"))&&(t={...t,HLS:{type:"url",url:r.url}});break;case"dash":(s||e.includes("dash"))&&(t={...t,DASH:{type:"url",url:r.url}});break}return{sources:t,thumbUrl:n,title:i.id}}const we=(i,e)=>{const t=i.info.currentQuality$.getValue(),n=i.info.availableQualities$.getValue();t!==e&&n.includes(e)&&(i.setQuality(e),i.setAutoQuality(!1))},Ui=i=>{const e=i.variants.find(t=>{var n;return((n=t.payload)===null||n===void 0?void 0:n.type)==="vk"});if(e&&"payload"in e){const[t,n]=e.payload.id.split("_");return[t,n]}return[]},Se={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},zi=2;function qi(i){const e=Gi();let t,n;const s=new Vt;let r={},c=!1,o=null,l=!1,d;i&&f(i);function f(p){o=p}function u(p,g,v){var I;if(!o)throw Error("need to set interactive controller");const w=((I=e.map.get(p))!==null&&I!==void 0?I:{})[g];if(w){r={chapterId:v,listId:p,itemId:g,...w};const R=r.player;n=R.info.currentQuality$.subscribe(V=>{if(!(!V||!R.info.position$.getValue())){t=V;for(const P of e.map)Object.values(P[1]).forEach(({player:$})=>{R.info.isAutoQualityEnabled$.getValue()||we($,V)})}}),w.container.remove(),c=!1,o.setPlayer(w.player),l||(o.init(),l=!0),s.emit(Se.activePlayerChanged,{player:r.player,config:r.config});return}throw Error("Can't set. Not find.")}async function y(p,g,v){if(!o)throw Error("need to set interactive controller");if(pe(r)||p!==r.itemId)return;if(v>=0&&!c){const S=o.getChapterBranches();c=!0;const w=new Set;for(const R of S)w.has(R.media.id)||(await E({media:R.media,chapterId:R.chapter.id,setAsActive:!1,title:R.chapter.label}),w.add(R.media.id))}}async function C({chapter:{id:p},media:g}){if(pe(r))return;n==null||n.unsubscribe();const v=r.player.info.muted$.getValue(),I=r.player.info.currentQuality$.getValue(),S=r.player.info.isAutoQualityEnabled$.getValue(),w=r.player.info.volume$.getValue(),R=r.player.info.currentPlaybackRate$.getValue(),V=!S;let P=!1;for(const $ of e.map)if($[0]===g.id){const ie=Object.keys($[1]);for(const Z of ie)Z===r.itemId?(ie.length<zi||(P=!0),e.removePlayer($[0],Z)):(P=!0,u($[0],Z,p),V?we(r.player,I):r.player.setAutoQuality(!0),r.player.setVolume(w),r.player.setMuted(v),r.player.setPlaybackRate(R))}else e.removePlayer($[0]);P||(await E({media:g,chapterId:p,setAsActive:!0,playbackRate:R}),V?we(r.player,I):r.player.setAutoQuality(!0),r.player.setVolume(w),r.player.setMuted(v))}async function E({media:p,chapterId:g,prefetch:v=!0,setAsActive:I=!0,autoplay:S=!1,preferredExt:w,title:R,playbackRate:V}){var P,$,ie;const Z=Math.random().toString(),ne=document.createElement("div");d.append(ne);const Ht=(P=r==null?void 0:r.player)===null||P===void 0?void 0:P.info.isAutoQualityEnabled$.getValue();let ye;if(!(($=o==null?void 0:o.options)===null||$===void 0)&&$.vkVideoLoader){const be=Ui(p);be.length&&(ye=await o.options.vkVideoLoader(...be))}const ze={container:ne,...((ie=ye==null?void 0:ye.videos)===null||ie===void 0?void 0:ie[0])||{sources:dt(p,w).sources},title:R},Y=new Yt.Player;Y.initVideo(ze);const Gt=ne.lastChild,qe=new G.Subscription;qe.add(Y.info.position$.subscribe(function(be){y(Z,Y.info.duration$.getValue(),be)})).add(Y.events.canplay$.subscribe(function(){Ht||we(Y,t),V&&Y.setPlaybackRate(V)})),Gt&&(ne.style.display="none",ne.classList.add(g));const se=e.createPlayer({listId:p.id,itemId:Z,player:Y,container:ne,sources:dt(p,w).sources,config:ze,subscription:qe});return I&&u(p.id,se.itemId,g),S&&se.player.play(),v&&!S&&se.player.prepare(),s.emit(Se.playerCreated,se.player),{player:se.player,config:se.config}}function j(){h(),o=null}function h(){o==null||o.off(b.chapterChanged,C),e.removeAll(),r={},l=!1,c=!1}async function m({source:p,initialChapter:g,container:v}){if(!o)throw Error("need to set interactive controller");await o.setManifest(p),h(),d=v;const{media:I,chapter:S}=await o.setChapter({chapterId:g});if(I){o.on(b.chapterChanged,C);const{player:w,config:R}=await E({media:I,chapterId:S.id,title:S.label});return s.emit(Se.initiated,{container:v,media:I,chapterId:S.id}),{player:w,config:R}}else console.error("not found")}return{...e,on:s.on.bind(s),off:s.off.bind(s),init:m,setInteractiveController:f,createPlayer:E,removeAll:j,getActivePlayer:function(){return r}}}const Qi=3e3,Ki=()=>{let i=[],e=null;return{setPlayer:c=>{e=c},setContainers:c=>{i=c},deleteContainer:c=>{i=i.filter(o=>o.id!==c)},getNextInteractiveTime:(c=Qi)=>{if(!i.length||e===null)return null;let o=-1,l=!1;const d=e.info.position$.getValue()*1e3;for(const f of i){const u=f.startTime-c;if(u<=d&&(d<=f.endTime||f.endTime===null)){l=!0;break}d<u&&(o=o===-1?u:Math.min(o,u))}return!l&&o!==-1?o:null}}},ce=Ki(),O=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),Ue=i=>le(i)&&!jt(i),$t=i=>jt(i.branches)||i.order==="end",Xi=(i,e)=>{var t;const n=i*1e3;return Ue(e.controls)&&n<((t=e.startTime)!==null&&t!==void 0?t:0)},ht=(i,e)=>{var t,n;const s=i*1e3;return Ue(e.controls)&&s>=((t=e.startTime)!==null&&t!==void 0?t:0)&&s<=((n=e.endTime)!==null&&n!==void 0?n:1/0)},xe=i=>i.some(e=>e.action.type==="expect"),ut=i=>i.find(e=>e.action.type==="expect"),Zi=({fn:i,type:e=1},...t)=>(...n)=>e?i(...n,...t):i({...n[e],...t[e]}),Yi=(i=[])=>i.reduce((e,t,n)=>{var s,r,c;const o=((s=t==null?void 0:t.controls)!==null&&s!==void 0?s:[]).filter(l=>!ji(l));if(Ue(o)){const l=[(r=t.startTime)!==null&&r!==void 0?r:0,(c=t.endTime)!==null&&c!==void 0?c:1/0],d=t.id;if(!n)e.push({subjects:[d],range:l});else{const f=[];let u=-1/0,y=1/0,C=[];const E=[];for(let j=0;j<e.length;j++){const h=e[j];if(E.push(...h.subjects),h.range[0]<y&&(y=h.range[0]),h.range[1]>u&&(u=h.range[1]),h.range[0]<=l[0]&&h.range[1]>=l[1])return e[j].subjects.push(d),e;l[0]>=h.range[0]&&l[0]<=h.range[1]&&(f.push(j),C=C.concat(h.subjects),l[0]=h.range[0]),l[1]>=h.range[0]&&l[1]<=h.range[1]&&(f.push(j),C=C.concat(h.subjects),l[1]=h.range[1])}if(E.push(d),l[0]<=y&&l[1]>=u)return[{subjects:E,range:l}];f.length&&f.reverse().forEach(j=>{e.splice(j,1)}),e.push({subjects:C.concat([d]),range:l})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]),Ji=(i,e)=>xe(i.events)?!1:e.some(({container:t})=>t.container.id!==i.id&&xe(t.container.events)&&t.container.endTime===i.endTime&&!t.isRemoved);class en{constructor({player:e,container:t,branches:n,selectBranches:s,interactiveEvents:r,globalEventEmitter:c,ignoreContainerEvent:o}){this.hide=()=>{setTimeout(()=>{var l,d;this.gameState!==O.end&&(xe(this.container.container.events)&&this.gameState===O.afterInteractive||this.selectBranches.state.isExpect||((d=(l=this.container).hide)===null||d===void 0||d.call(l),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1})))})},this.show=()=>{var l,d;if(this.gameState===O.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())(d=(l=this.container).show)===null||d===void 0||d.call(l),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!0,isFirst:!1});else{const u=Zi({fn:this.selectBranches.onControlEvent,type:0},{branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1})},onEvent:(y,C)=>{this.isSelectedControlEvent=!0,y!==!1&&(this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1})),(this.gameState===O.end||this.gameState===O.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),C(),this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1})),ce.deleteContainer(this.container.container.id)},isEOV:()=>this.gameState===O.end});this.container.createView(u),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!0,isFirst:!0})}},this.onEndOfVideo=()=>{this.gameState=O.end,this.selectContainerEvent(!0)},this.whilePlaying=()=>{var l,d,f,u;if(((l=this.player.experimental.element$.getValue())===null||l===void 0?void 0:l.readyState)<1||[O.destroyed,O.removed].includes(this.gameState))return;const C=this.player.info.position$.getValue();if(Xi(C,this.container.container))this.gameState!==O.beforeInteractive&&(this.gameState=O.beforeInteractive,this.onBeforeStartTime());else if(ht(C,this.container.container))this.gameState!==O.interactive&&(this.gameState=O.interactive,this.onStartTime());else if(this.gameState!==O.afterInteractive){const h=this.gameState;this.gameState=O.afterInteractive,h===O.interactive&&this.onEndTime()}else this.gameState!==O.destroyed&&this.removeView();const E=ht(C,this.container.container),j=this.container.container.startTime?[this.container.container.startTime,(d=this.container.container.endTime)!==null&&d!==void 0?d:1/0]:[];(u=(f=this.container).onProgress)===null||u===void 0||u.call(f,C,E),this.globalEventEmitter.emit(b.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:j,currentTime:C,isInteractiveTime:E})},this.container=t,this.branches=n,this.selectBranches=s,this.subscription=new G.Subscription,this.player=e,this.interactiveEvents=r,this.ignoreContainerEvent=o,this.globalEventEmitter=c,this.gameState=O.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo))}selectContainerEvent(e=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime,id:this.container.container.id}),!this.isSelectedControlEvent&&(this.isSelectedContainerEvent||(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime)))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);const e=xe(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,t;(t=(e=this.container).hide)===null||t===void 0||t.call(e),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=O.beforeInteractive}removeView(){this.container.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:N.containerRemoved,visibility:!1}),this.gameState=O.removed}destroy(){var e;this.reset(),this.removeView(),this.gameState=O.destroyed,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!==null&&e!==void 0?e:1/0,id:this.container.container.id}),ce.deleteContainer(this.container.container.id)}}function tn(){const i={};function e(){for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&delete i[o];return!0}function t(o){const l={};for(const d in i)+d<=o&&(l[d]=i[d]);return l}function n(o){const l={};for(const d in i)+d>=o&&(l[d]=i[d]);return l}function s({timestamp:o,priority:l,initiator:d}){var f;if(Je(o)){const u=(f=i[o])!==null&&f!==void 0?f:null;if(u&&Ce(l,!0)){let y={};const C=u[l];if(C&&(y={...y,...C}),y=pe(y)?null:y,y&&Ce(d,!0)){const E=y[d];return E!=null?E:null}return y}return u}return null}function r({timestamp:o,priority:l,initiator:d}){if(Je(o))if(i[o]){if(Ce(l,!0))if(i[o][l]){if(Ce(d,!0))if(i[o][l][d]){if(delete i[o][l][d],!pe(i[o][l]))return!0}else return!1;if(delete i[o][l],!pe(i[o]))return!0}else return!1;return delete i[o]}else return!1}function c({timestamp:o,priority:l,initiator:d,...f}){var u,y,C;!((y=(u=i[o])===null||u===void 0?void 0:u[l])===null||y===void 0)&&y[d]?i[o][l][d].push({...f}):!((C=i[o])===null||C===void 0)&&C[l]?i[o][l]={...i[o][l],[d]:[{...f}]}:i[o]?i[o]={...i[o],[l]:{[d]:[{...f}]}}:i[o]={[l]:{[d]:[{...f}]}}}return{map:i,remove:r,add:c,removeAll:e,get:s,getLte:t,getGte:n}}const nn=[A.expect,A.setNextBranch],sn=1/0;function ft(i){let e=i,t;const n=rn(),s=new tn;let r;const c=()=>{u(),j()},o=h=>{s.add.call(void 0,h),y()},l=(h=[])=>{for(const m of h)if(m.action(),nn.includes(m.actionType))break},d=h=>{var m,p,g;if(!n.isReady(h))return;const v=_e((m=s.get({timestamp:h,priority:"control"}))!==null&&m!==void 0?m:{}),I=_e((p=s.get({timestamp:h,priority:"container"}))!==null&&p!==void 0?p:{}),S=_e((g=s.get({timestamp:h,priority:"chapter"}))!==null&&g!==void 0?g:{});l([...v,...I,...S])},f=()=>{var h;l([..._e((h=s.get({timestamp:1/0,priority:"chapter"}))!==null&&h!==void 0?h:{})])},u=()=>{t&&(r==null||r.unsubscribe(),t=void 0)},y=()=>{t||(t=()=>setTimeout(()=>{d(1/0)}),r=e.events.ended$.subscribe(t))},C=h=>{u(),e=h},E=h=>{h.priority==="container"&&n.resetCalled(h.timestamp),s.remove(h)},j=()=>{n.release(),s.removeAll()};return{setPlayer:C,add:o,remove:E,exec:d,execEndOfVideo:f,listen:y,unlisten:u,release:c,containersEventsCallState:n}}function rn(){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 d of c){const f=(o=d.endTime)!==null&&o!==void 0?o:sn,u=(l=i.get(f))!==null&&l!==void 0?l:{};i.set(f,{...u,[d.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 _e(i){return Object.values(i).flat().sort(e=>e.actionType===A.expect?-1:1)}const an=(i,e)=>{const{height:t,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&n))return{videoContentHeight:0,videoContentWidth:0};const{clientHeight:s,clientWidth:r}=e.experimental.element$.value||{};if(!(s&&r))return{videoContentHeight:0,videoContentWidth:0};const c=t/n,o=s/r;let l,d;return o>c?(d=r,l=r*c):o<c?(d=s/c,l=s):(d=r,l=s),{videoContentWidth:d,videoContentHeight:l}},on=250;function ln(i){let e=()=>{};const t=new ResizeObserver(o=>{r(o),e=r.bind(null,o)});function n(o){const{parentElement:l,player:d}=i();if(l&&d){const{videoContentWidth:f,videoContentHeight:u}=an(l,d);l.style.setProperty("--interactive-content-width",`${f}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 s(){const{parentElement:o}=i();o.removeAttribute("style")}const r=Lt(o=>{const{fns:l=[]}=i();n(o);for(const d of l)d()},on);function c(){e=void 0,t.disconnect(),s()}return{resizeObserver:t,calc:()=>{e()},release:c}}class cn{constructor(){this.map={}}push(e,t){e in this.map?this.map[e].push(t):this.map[e]=[t]}get(e){const t=this.map[e];return t?t.slice():null}getAll(){const e=[];for(const t in this.map)e.push(...this.map[t]);return e}remove(e,t){e in this.map&&(this.map[e]=this.map[e].filter(n=>n!==t),this.map[e].length===0&&delete this.map[e])}clear(){this.map={}}size(){return Object.keys(this.map).length}keys(){return Object.keys(this.map)}}const dn=i=>Math.floor(Math.random()*i),hn=i=>{let e=i.length,t=1/0,n=null;for(;e--;)i[e].weight<t&&(t=i[e].weight,n=i[e]);return n},un=i=>{let e=i.length,t=-1/0,n=null;for(;e--;)i[e].weight>t&&(t=i[e].weight,n=i[e]);return n},fn=i=>{const e=i.length,t=dn(e);return i[t]},pt=1,pn=i=>{var e,t;let n=0;for(let r=0;r<i.length;++r)n+=(e=i[r].weight)!==null&&e!==void 0?e:pt;const s=Math.random()*n;n=0;for(let r=0;r<i.length-1;++r)if(n+=(t=i[r].weight)!==null&&t!==void 0?t:pt,n>=s)return i[r];return i[i.length-1]},vt=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0}),Le=(i,e=!1)=>({...i,args:e?{...i.args,...vt}:{...vt,...i.args}}),mt=({globalEventEmitter:i,player:e,interactiveEvents:t,removeControllers:n})=>{const s={isExpect:!1},r=()=>{s.isExpect&&(s.isExpect=!1)},c=({action:h,controlType:m,controlId:p,containerId:g,branches:v=[],onEvent:I,isEOV:S=()=>!1})=>{const w=Le(h,S()),R={timestamp:1/0,priority:"control",initiator:p,actionType:w.type},V=i.emit.bind(i,b.interactives,{subjectId:p,subjectType:m,subjectName:"control",type:N.actionChoice,actionType:h.type,payload:{containerId:g,...w.args}});switch(w.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{const P=v.find($=>$.id===w.args.branchId);if(!P)return;I(w.args.isDetachContainer,y.bind(null,{subjectId:p,subjectName:"control"})),V(),w.args.shouldOpenNow?E({subjectId:p,subjectName:"control",subjectType:m,action:w,payload:{chapterId:P.chapterId,autoSelect:!1}}):(t.add({...R,action:E.bind(null,{subjectId:p,subjectName:"control",subjectType:m,action:w,payload:{chapterId:P.chapterId,autoSelect:!1}})}),n==null||n());return}case A.continuePlayback.trim().toLowerCase():{I(w.args.isDetachContainer,y.bind(null,{subjectId:p,subjectName:"control"})),V(),w.args.shouldOpenNow?C({subjectId:p,subjectName:"control",subjectType:m,action:h}):t.add({...R,action:C.bind(null,{subjectId:p,subjectName:"control",subjectType:m,action:h})});return}case A.openURI.trim().toLowerCase():{I(w.args.isDetachContainer,y.bind(null,{subjectId:p,subjectName:"control"})),V(),w.args.shouldOpenNow?j({subjectId:p,subjectName:"control",subjectType:m,action:w,payload:{URI:h.args.uri}}):(t.add({...R,action:j.bind(null,{subjectId:p,subjectName:"control",subjectType:m,action:w,payload:{URI:h.args.uri}})}),n==null||n());return}default:console.error("Unexpected control event"),i.emit(b.errors,new L(L.Severity.RECOVERABLE,L.Category.INTERACTIVES,{message:"Unexpected control event"}));return}},o=({action:h,container:{id:m,endTime:p},branches:g=[],isEOV:v=!1,autoSelected:I=!1})=>{const S=Le(h,v),w={timestamp:!S.args.shouldOpenNow||v?1/0:p,priority:"container",initiator:m,actionType:S.type},R=i.emit.bind(i,b.interactives,{subjectId:m,subjectName:"container",type:N.actionChoice,actionType:S.type,payload:S.args});switch(S.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{const V=g.find(P=>P.id===S.args.branchId);if(!V)return;R(),t.add({...w,action:E.bind(null,{subjectId:m,subjectName:"container",action:S,payload:{chapterId:V.chapterId,autoSelect:I}})}),n==null||n();return}case A.setMaxWeightBranch.trim().toLowerCase():return;case A.setMinWeightBranch.trim().toLowerCase():return;case A.setRandomBranch.trim().toLowerCase():return;case A.setWeightlessRandomBranch.trim().toLowerCase():return;case A.continuePlayback.trim().toLowerCase():{R(),t.add({...w,action:C.bind(null,{subjectId:m,subjectName:"container",action:S})});return}case A.openURI.trim().toLowerCase():{R(),t.add({...w,action:j.bind(null,{subjectId:m,subjectName:"container",action:S,payload:{URI:h.args.uri}})}),n==null||n();return}default:console.error("Unexpected container event"),i.emit(b.errors,new L(L.Severity.RECOVERABLE,L.Category.INTERACTIVES,{message:"Unexpected container event"}));return}};function l({container:h,branches:m,isEOV:p=!1}){const g=ut(h.events);if(g){const v=Le(g.action,p);i.emit(b.interactives,{subjectId:h.id,subjectName:"container",type:N.actionChoice,actionType:v.type,payload:v.args}),t.add({timestamp:p?1/0:h.endTime,priority:"container",initiator:h.id,actionType:A.expect,action:u.bind(null,{subjectId:h.id,subjectName:"container"})}),s.isExpect=!0}else for(const v of h.events)o({action:v.action,container:h,branches:m,isEOV:p})}const d=({chapterId:h,action:m,branches:p=[]})=>{const g=i.emit.bind(i,b.interactives,{subjectId:h,subjectName:"chapter",type:N.actionChoice,actionType:m.type,payload:m.args});switch(m.type.trim().toLowerCase()){case A.setNextBranch.trim().toLowerCase():{const v=p.find(I=>I.id===m.args.branchId);return v!=null&&v.chapterId?(g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:m,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.setWeightlessRandomBranch.trim().toLowerCase():{const v=fn(p);return v!=null&&v.chapterId?(g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:m,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.setRandomBranch.trim().toLowerCase():{const v=pn(p);return v!=null&&v.chapterId?(g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:m,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.setMaxWeightBranch.trim().toLowerCase():{const v=un(p);return v!=null&&v.chapterId?(g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:m,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.setMinWeightBranch.trim().toLowerCase():{const v=hn(p);return v!=null&&v.chapterId?(g(),E.bind(null,{subjectId:h,subjectName:"chapter",action:m,payload:{chapterId:v.chapterId,autoSelect:!0}})):void 0}case A.continuePlayback.trim().toLowerCase():return g(),C.bind(null,{subjectId:h,subjectName:"chapter",action:m});case A.openURI.trim().toLowerCase():return g(),j.bind(null,{subjectId:h,subjectName:"chapter",action:m,payload:{URI:m.args.uri}});default:console.error("Unexpected chapter event"),i.emit(b.errors,new L(L.Severity.RECOVERABLE,L.Category.INTERACTIVES,{message:"Unexpected chapter event"}));return}};function f(h){const m=ut(h.events);if(m){if($t(h))return;i.emit(b.interactives,{subjectId:h.id,subjectName:"chapter",type:N.actionChoice,actionType:m.action.type,payload:m.action.args}),t.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:A.expect,action:u.bind(null,{subjectId:h.id,subjectName:"chapter"})})}else h.events.forEach(p=>{const g=d({chapterId:h.id,action:p.action,branches:h.branches});g&&t.add({timestamp:1/0,priority:"chapter",initiator:h.id,actionType:p.action.type,action:g})})}const u=({subjectId:h,subjectName:m,action:p})=>{var g;e.pause(),i.emit(b.interactives,{subjectId:h,subjectName:m,type:N.actionExecution,actionType:(g=p==null?void 0:p.type)!==null&&g!==void 0?g:A.expect})},y=({subjectId:h,subjectName:m})=>{e.info.isEnded$.getValue()?t.execEndOfVideo():e.play(),i.emit(b.interactives,{subjectId:h,subjectName:m,type:N.actionExecution,actionType:"after-expect"})},C=({subjectId:h,subjectName:m,subjectType:p,action:g})=>{i.emit(b.interactives,{subjectId:h,subjectName:m,subjectType:p,type:N.actionExecution,actionType:g.type})},E=({subjectId:h,subjectName:m,subjectType:p,action:g,payload:v})=>{v.behaviour="change-chapter",i.emit(b.interactives,{subjectId:h,subjectName:m,subjectType:p,type:N.actionExecution,actionType:g.type,payload:v})},j=({subjectId:h,subjectName:m,subjectType:p,action:g,payload:v})=>{if(!v.URI)return;const I=window.open(v.URI,"_blank","noopener,noreferrer");I&&(I.opener=null),i.emit(b.interactives,{subjectId:h,subjectName:m,subjectType:p,type:N.actionExecution,actionType:g.type})};return{onControlEvent:c,onContainerEvent:o,onChapterEvent:d,onExpectEvent:u,expectEventHandler:y,setManifestChapterEvents:f,setManifestContainerEvents:l,stopExpect:r,state:s}};var he,Dt,Ve,gt;class q{constructor(e,t,n,s){this.target=e,this.type=t,this.listener=n,this.options=a(q,he,"m",Dt).call(q,e,s),this.target.addEventListener(t,n,this.options)}unlisten(){this.target.removeEventListener(this.type,this.listener,this.options),this.target=null,this.listener=null,this.options=!1}}he=q,Dt=function(e,t){if(t===void 0)return!1;if(typeof t=="boolean")return t;{const n=new Set(["passive","capture"]),s=Object.keys(t).filter(c=>!n.has(c));return s.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+s.join(",")),a(q,he,"m",gt).call(q,e)?t:t.capture||!1}},gt=function(e){let t=a(q,he,"f",Ve);if(t===void 0){t=!1;try{const n={},s={get:()=>(t=!0,!1)};Object.defineProperty(n,"passive",s),Object.defineProperty(n,"capture",s);const r=()=>{};e.addEventListener("test",r,n),e.removeEventListener("test",r,n)}catch(n){t=!1}_(q,he,t,"f",Ve)}return t||!1};Ve={value:void 0};class vn{constructor(){this.bindingMap=new cn}release(){this.removeAll(),this.bindingMap=null}listen(e,t,n,s){if(!this.bindingMap)return;const r=new q(e,t,n,s);this.bindingMap.push(t,r)}listenOnce(e,t,n,s){const r=c=>{this.unlisten(e,t,r),n(c)};this.listen(e,t,r,s)}unlisten(e,t,n){if(!this.bindingMap)return;const s=this.bindingMap.get(t)||[];for(const r of s)r.target===e&&(n===r.listener||!n)&&(r.unlisten(),this.bindingMap.remove(t,r))}removeAll(){if(!this.bindingMap)return;const e=this.bindingMap.getAll();for(const t of e)t.unlisten();this.bindingMap.clear()}}class mn{constructor(){this._prevSizeId=0,this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))===null||e===void 0||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var e;const t=(e=this.rootElement.getContext("2d"))===null||e===void 0?void 0:e.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!t)return!1;const n=t.data,s=n.length;for(let r=3;r<s;r+=40)if(n[r]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))===null||e===void 0||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}async updateCanvasDimensions(e,t=!1){const n=e.width+e.height;if(this._prevSizeId===n)return;let s;t&&(s=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&s&&this.restore(s),this._prevSizeId=n}async save(){const e=this.rootElement.toDataURL("image/jpeg",1),t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}restore(e){var t;this.rootElement&&((t=this.rootElement.getContext("2d"))===null||t===void 0||t.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}}class gn{constructor({parentElement:e,endOffsetMs:t=250,onError:n}){this.currentVideoDurationMs=1/0,this._containerTimeFrameShouldReceived=!1,this._endTimeFrameReceived=!1,this._shouldCallSkip=!1,this.onEachTick=s=>{const r=s!=null?s:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,c=this.isChapterEndTime(r);if(this.isContainerTime(r))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;
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
top: 50%;
|
|
17
17
|
left: 50%;
|
|
18
18
|
transform: translate(-50%, -50%);
|
|
19
|
-
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);const t=getComputedStyle(this.rootElement),n={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(s){this._onError(s)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var n,s,r;return((n=t.controls)===null||n===void 0?void 0:n.length)&&e>=((s=t.startTime)!==null&&s!==void 0?s:0)&&e<=Math.min((r=t.endTime)!==null&&r!==void 0?r:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,n;(n=(t=this._callbacks)===null||t===void 0?void 0:t.onError)===null||n===void 0||n.call(t,e)}}function yn(i=0){return new Promise(e=>{setTimeout(()=>{e(0)},i)})}var F,J,U,ee,X,B,D,K,x,te,ve,k,
|
|
19
|
+
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);const t=getComputedStyle(this.rootElement),n={width:parseInt(t.getPropertyValue("--interactive-content-width"),10),height:parseInt(t.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(s){this._onError(s)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>{var n,s,r;return((n=t.controls)===null||n===void 0?void 0:n.length)&&e>=((s=t.startTime)!==null&&s!==void 0?s:0)&&e<=Math.min((r=t.endTime)!==null&&r!==void 0?r:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,n;(n=(t=this._callbacks)===null||t===void 0?void 0:t.onError)===null||n===void 0||n.call(t,e)}}function yn(i=0){return new Promise(e=>{setTimeout(()=>{e(0)},i)})}var F,J,U,ee,X,B,D,K,x,te,ve,k,H,ue,M,T,Te,Wt,ke,yt,Pe,oe,fe,bt,Fe,Re;const bn=Object.freeze({parentElement:null,fullscreenTargetElement:null,lang:"ru",loaders:{},graph:!1,lastFrame:!1}),Q=Object.freeze({created:0,initiated:1,ready:2,destroyed:3});function Cn(){const i=document.createElement("div");return i.style.cssText=`
|
|
20
20
|
position: absolute;
|
|
21
21
|
top: 0;
|
|
22
22
|
left: 0;
|
|
23
|
-
`,i}class En{constructor(e){F.add(this),J.set(this,null),U.set(this,null),ee.set(this,null),X.set(this,null),B.set(this,null),D.set(this,null),K.set(this,null),x.set(this,null),te.set(this,new H.ValueSubject(!1)),ve.set(this,new Set),k.set(this,null),G.set(this,null),ue.set(this,null),M.set(this,null),T.set(this,null),this.emitPlayerChanged=t=>{o(this,T,"f").emit(b.playerChanged,t)},Wt.set(this,()=>{o(this,D,"f").fns.forEach(s=>s());const t=this.options.player.info.position$.getValue()*1e3,n=(o(this,x,"f").chapter.containers||[]).filter(s=>s.startTime>=Math.floor(t));for(const s of n){o(this,B,"f").remove({timestamp:1/0,priority:"container",initiator:s.id});for(const r of s.controls)o(this,B,"f").remove({timestamp:1/0,priority:"control",initiator:r.id});o(this,U,"f").find(r=>r.container.container.id===s.id).reset()}}),ke.set(this,()=>{o(this,J,"f").calc(),o(this,D,"f").requestAnimation()}),oe.set(this,()=>{o(this,U,"f").forEach(t=>{o(this,D,"f").removeFn(t.whilePlaying),t.destroy()})}),Re.set(this,({detail:t})=>{o(this,T,"f").emit(b.historyChanged,t)}),this.options={...bn,...e},w(this,U,[],"f"),this.factories=new Map([["choice",Ot]]),this.rootElement=Cn(),this.options.parentElement.append(this.rootElement),w(this,T,new Vt,"f"),w(this,X,new H.Subscription,"f"),w(this,ee,new vn,"f"),this.options.lastFrame&&w(this,M,new gn({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:t=>o(this,T,"f").emit(b.errors,new L(L.Severity.RECOVERABLE,L.Category.SEAMLESS,t))}),"f"),o(this,ee,"f").listen(this.rootElement,"mousedown",t=>t.stopPropagation()),o(this,ee,"f").listen(this.rootElement,"mouseup",t=>t.stopPropagation()),w(this,x,new Bt(this.options.loaders,t=>o(this,T,"f").emit(b.errors,new L(L.Severity.RECOVERABLE,L.Category.MANIFEST,t))),"f"),w(this,B,ft(this.options.player),"f"),w(this,D,new Mi,"f"),w(this,K,mt({player:this.options.player,interactiveEvents:o(this,B,"f"),globalEventEmitter:o(this,T,"f"),removeControllers:o(this,oe,"f")}),"f"),w(this,J,ln(()=>{var t;return{player:(t=this.options)===null||t===void 0?void 0:t.player,parentElement:this.options.parentElement,fns:this.options.lastFrame?[()=>{o(this,M,"f").updateCanvasDimensions(!0)}]:[]}}),"f"),this.options.graph&&w(this,k,new pi({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:t=>{this.setChapter({chapterId:t}),o(this,T,"f").emit(b.graph,{type:ct.watchAgainClicked,chapterId:t})},onError:t=>o(this,T,"f").emit(b.errors,new L(L.Severity.RECOVERABLE,L.Category.LOADERS,{message:t}))}),"f"),w(this,G,new gi,"f"),o(this,G,"f").addEventListener(je,o(this,Re,"f")),o(this,T,"f").on(b.interactives,t=>{var n,s;if(t.type===N.actionExecution){if(((n=t.payload)===null||n===void 0?void 0:n.behaviour)==="change-chapter"){const{chapterId:r,autoSelect:c}=t.payload;this.setChapter({chapterId:r,autoSelect:c})}if(((s=t.payload)===null||s===void 0?void 0:s.behaviour)==="change-manifest"){const{manifestURL:r}=t.payload;this.setManifest(r)}}}),this.isFirstChapterFetched=!1,this.state=Q.created}async initSeamless({source:e,initialChapter:t,visitedChapters:n=[],videosInfo:s}){w(this,ue,qi(this),"f");const r=document.createElement("div");o(this,ue,"f").on(Se.activePlayerChanged,this.emitPlayerChanged);const{player:c,config:a}=await o(this,ue,"f").init({source:e,initialChapter:t,container:r});return this.setVisitedChapters(n),this.updateGraphVideosInfo(s),{player:c,config:a}}getStatEvents(){return{click$:new H.Observable(e=>{o(this,T,"f").on(b.graph,({type:t,visibility:n})=>{t==="visibility"&&e.next(n?exports.INTERACTIVE_CLICK_ACTIONS.OPEN_GRAPH:exports.INTERACTIVE_CLICK_ACTIONS.CLOSE_GRAPH),t==="watchAgainClicked"&&e.next(exports.INTERACTIVE_CLICK_ACTIONS.WATCH_AGAIN)}),o(this,T,"f").on(b.interactives,({type:t,subjectName:n,subjectType:s})=>{t!=="action-choice"||n!=="control"||(s==="Button"&&e.next(exports.INTERACTIVE_CLICK_ACTIONS.GO_NEXT_BUTTON),s==="Area"&&e.next(exports.INTERACTIVE_CLICK_ACTIONS.GO_NEXT_AREA))})}),nextMovie$:new H.Observable(e=>{o(this,T,"f").on(b.playerChanged,({config:t})=>{t!=null&&t.unitedVideoId&&e.next(t.unitedVideoId)})})}}setPlayer(e){o(this,F,"m",Te).call(this),this.options.player=e,ce.setPlayer(this.options.player),o(this,B,"f")?o(this,B,"f").setPlayer(this.options.player):w(this,B,ft(this.options.player),"f"),w(this,K,mt({player:this.options.player,interactiveEvents:o(this,B,"f"),globalEventEmitter:o(this,T,"f"),removeControllers:o(this,oe,"f")}),"f"),this.state===Q.initiated&&(o(this,F,"m",Pe).call(this),o(this,F,"m",fe).call(this,o(this,x,"f").chapter))}async setManifest(e,t){o(this,F,"m",Te).call(this),this.isFirstChapterFetched=!1;const n=await o(this,x,"f").setManifest(e),s=t&&t.manifestId===n.manifest.metadata.id?{...t}:void 0;return o(this,G,"f").onManifestChange(n.manifest.metadata,s),o(this,k,"f")&&await o(this,k,"f").handleManifestChange(n.manifest,s?mi(s):[]),o(this,T,"f").emit(b.manifestChanged,{manifest:n.manifest}),o(this,F,"m",fe).call(this,o(this,x,"f").chapter),n.manifest}setVisitedChapters(e){var t;Array.isArray(e)&&((t=o(this,k,"f"))===null||t===void 0||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=o(this,k,"f"))===null||t===void 0||t.updateVideosInfo(e))}async setChapter({chapterId:e,autoSelect:t,tryContinueFromHistory:n=!1}={}){var s;o(this,F,"m",Te).call(this),o(this,M,"f")&&this.isFirstChapterFetched&&(o(this,M,"f").draw(),o(this,M,"f").show()),H.getCurrentBrowser().browser===H.CurrentClientBrowser.Safari&&await yn(35);let c;e?c=await o(this,x,"f").setNext(e):c=await(n?o(this,x,"f").setNext(yi(o(this,x,"f").manifest,this.getHistory())):o(this,x,"f").setInitial());const{chapter:a,media:l,graph:d}=c;return o(this,G,"f").onChapterChange({chapterId:a.id,mediaId:l.id,autoSelect:t,isLastChapter:$t(a)}),o(this,k,"f")&&o(this,k,"f").handleChapterChange(d),(s=o(this,M,"f"))===null||s===void 0||s.setCurrentChapter(this.getCurrentChapter().chapter),o(this,T,"f").emit(b.chapterChanged,{chapter:a,media:l,graph:d}),o(this,F,"m",fe).call(this,o(this,x,"f").chapter),w(this,ve,new Set,"f"),this.isFirstChapterFetched=!0,{chapter:a,media:l,graph:d}}toggleGraphView(e=!0){o(this,k,"f")&&(e?(o(this,k,"f").show(),o(this,te,"f").next(!1)):(o(this,k,"f").hide(),o(this,F,"m",Fe).call(this)),o(this,T,"f").emit(b.graph,{type:ct.visibility,visibility:e}))}init(){o(this,x,"f").chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.state===Q.created&&(o(this,J,"f").resizeObserver.observe(this.options.fullscreenTargetElement),o(this,F,"m",Pe).call(this),this.state=Q.initiated,o(this,F,"m",fe).call(this,o(this,x,"f").chapter))}isSupport(e=o(this,x,"f").manifest){return Ge(e.metadata.version)}getIsSeekable(){return o(this,te,"f")}getHistory(){return o(this,G,"f").getHistory()}getInteractiveRanges(){var e;return Yi((e=o(this,x,"f").chapter)===null||e===void 0?void 0:e.containers)}getNextInteractiveStartTime(e){return ce.getNextInteractiveTime(e)}getChapterBranches(e){return o(this,x,"f").getBranches(e)}getCurrentChapter(){return o(this,x,"f").getCurrent()}getCurrentManifest(){return o(this,x,"f").manifest}addFactory(e,t){this.factories.set(e.trim().toLowerCase(),t)}removeFactory(e){this.factories.delete(e.trim().toLowerCase())}on(...e){return o(this,T,"f").on(...e),this}off(...e){return o(this,T,"f").off(...e),this}once(...e){return o(this,T,"f").once(...e),this}destroy(){var e,t;o(this,oe,"f").call(this),w(this,U,void 0,"f"),o(this,G,"f").removeEventListener(je,o(this,Re,"f")),o(this,G,"f").destroy(),w(this,G,void 0,"f"),(e=o(this,k,"f"))===null||e===void 0||e.destroy(),w(this,k,void 0,"f"),o(this,J,"f").release(),w(this,J,void 0,"f"),w(this,K,void 0,"f"),o(this,D,"f").release(),w(this,D,void 0,"f"),o(this,B,"f").release(),w(this,B,void 0,"f"),o(this,x,"f").release(),w(this,K,void 0,"f"),o(this,ee,"f").release(),w(this,ee,void 0,"f"),o(this,X,"f").unsubscribe(),w(this,X,void 0,"f"),o(this,T,"f").reset(),w(this,T,void 0,"f"),(t=o(this,M,"f"))===null||t===void 0||t.destroy(),w(this,M,void 0,"f"),this.rootElement.remove(),this.rootElement=void 0,this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.state=Q.destroyed}}J=new WeakMap,U=new WeakMap,ee=new WeakMap,X=new WeakMap,B=new WeakMap,D=new WeakMap,K=new WeakMap,x=new WeakMap,te=new WeakMap,ve=new WeakMap,k=new WeakMap,G=new WeakMap,ue=new WeakMap,M=new WeakMap,T=new WeakMap,Wt=new WeakMap,ke=new WeakMap,oe=new WeakMap,Re=new WeakMap,F=new WeakSet,Te=function(){var e;this.state===Q.ready&&(o(this,oe,"f").call(this),w(this,U,[],"f"),o(this,D,"f").release(),(e=o(this,B,"f"))===null||e===void 0||e.release(),this.state=Q.initiated,o(this,te,"f").next(!1))},yt=function(e){(!o(this,k,"f")||o(this,k,"f").isHidden)&&o(this,F,"m",Fe).call(this);const t=e*1e3,s=this.getInteractiveRanges().findLast(({range:r})=>t>=r[1]);if(s){const r=s.range.join("-");o(this,ve,"f").has(r)||(o(this,ve,"f").add(r),o(this,T,"f").emit(b.interactives,{type:N.rangeEnded,payload:s,visibility:!0}))}},Pe=function(){o(this,X,"f").unsubscribe(),o(this,X,"f").add(this.options.player.events.started$.pipe(H.once()).subscribe(o(this,ke,"f"))).add(this.options.player.events.playing$.subscribe(o(this,D,"f").requestAnimation)).add(this.options.player.events.willPause$.subscribe(o(this,D,"f").cancelAnimation)).add(this.options.player.info.position$.subscribe(o(this,F,"m",yt).bind(this))),this.options.lastFrame&&o(this,X,"f").add(this.options.player.info.duration$.subscribe(e=>{o(this,M,"f").setVideoDuration(e*1e3)})).add(this.options.player.experimental.element$.subscribe(e=>{e&&o(this,M,"f").setVideoElement(e)})).add(this.options.player.events.firstFrame$.subscribe(()=>{o(this,M,"f").reset(),setTimeout(()=>{o(this,M,"f").hide(),o(this,M,"f").lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(o(this,M,"f").onSeek))},fe=function(e){o(this,x,"f").chapter&&this.state===Q.initiated&&(o(this,K,"f").setManifestChapterEvents(e),w(this,U,o(this,F,"m",bt).call(this,e),"f"),o(this,B,"f").containersEventsCallState.setData(e.containers),ce.setContainers(o(this,U,"f").map(t=>t.container.container)),this.options.lastFrame&&o(this,D,"f").addFn(()=>{o(this,M,"f").onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.state=Q.ready)},bt=function(e){var t,n;return(n=(t=e==null?void 0:e.containers)===null||t===void 0?void 0:t.reduce((s,r)=>{const c=r.type.trim().toLowerCase(),a=this.factories.get(c);if(a){const l=new en({player:this.options.player,container:a(r,this.rootElement),branches:o(this,x,"f").chapter.branches,selectBranches:o(this,K,"f"),interactiveEvents:o(this,B,"f"),globalEventEmitter:o(this,T,"f"),ignoreContainerEvent:()=>Ji(r,o(this,U,"f"))});return o(this,D,"f").addFn(l.whilePlaying,!0),[...s,l]}return[...s]},[]))!==null&&n!==void 0?n:[]},Fe=function(){const e=o(this,te,"f").getValue(),t=!!ce.getNextInteractiveTime();(t&&!e||!t&&e)&&o(this,te,"f").next(!e)};const _n={Container:xt,createChoiceContainer:Ot,createAreaControl:Tt,createButtonControl:Rt,createRelativeLayout:ai,getRootEl:Et,classnamesPrefix:W},wn={version:Jt};exports.CustomError=L;exports.EVENT_NAMES=b;exports.Interactives=En;exports.ManifestController=Bt;exports.SDKInfo=wn;exports.compareVersions=me;exports.isSupportedManifest=Ge;exports.utils=_n;
|
|
23
|
+
`,i}class En{constructor(e){F.add(this),J.set(this,null),U.set(this,null),ee.set(this,null),X.set(this,null),B.set(this,null),D.set(this,null),K.set(this,null),x.set(this,null),te.set(this,new G.ValueSubject(!1)),ve.set(this,new Set),k.set(this,null),H.set(this,null),ue.set(this,null),M.set(this,null),T.set(this,null),this.emitPlayerChanged=t=>{a(this,T,"f").emit(b.playerChanged,t)},Wt.set(this,()=>{a(this,D,"f").fns.forEach(s=>s());const t=this.options.player.info.position$.getValue()*1e3,n=(a(this,x,"f").chapter.containers||[]).filter(s=>s.startTime>=Math.floor(t));for(const s of n){a(this,B,"f").remove({timestamp:1/0,priority:"container",initiator:s.id});for(const r of s.controls)a(this,B,"f").remove({timestamp:1/0,priority:"control",initiator:r.id});a(this,U,"f").find(r=>r.container.container.id===s.id).reset()}}),ke.set(this,()=>{a(this,J,"f").calc(),a(this,D,"f").requestAnimation()}),oe.set(this,()=>{a(this,U,"f").forEach(t=>{a(this,D,"f").removeFn(t.whilePlaying),t.destroy()})}),Re.set(this,({detail:t})=>{a(this,T,"f").emit(b.historyChanged,t)}),this.options={...bn,...e},_(this,U,[],"f"),this.factories=new Map([["choice",Ot]]),this.rootElement=Cn(),this.options.parentElement.append(this.rootElement),_(this,T,new Vt,"f"),_(this,X,new G.Subscription,"f"),_(this,ee,new vn,"f"),this.options.lastFrame&&_(this,M,new gn({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:t=>a(this,T,"f").emit(b.errors,new L(L.Severity.RECOVERABLE,L.Category.SEAMLESS,t))}),"f"),a(this,ee,"f").listen(this.rootElement,"mousedown",t=>t.stopPropagation()),a(this,ee,"f").listen(this.rootElement,"mouseup",t=>t.stopPropagation()),_(this,x,new Bt(this.options.loaders,t=>a(this,T,"f").emit(b.errors,new L(L.Severity.RECOVERABLE,L.Category.MANIFEST,t))),"f"),_(this,B,ft(this.options.player),"f"),_(this,D,new Mi,"f"),_(this,K,mt({player:this.options.player,interactiveEvents:a(this,B,"f"),globalEventEmitter:a(this,T,"f"),removeControllers:a(this,oe,"f")}),"f"),_(this,J,ln(()=>{var t;return{player:(t=this.options)===null||t===void 0?void 0:t.player,parentElement:this.options.parentElement,fns:this.options.lastFrame?[()=>{a(this,M,"f").updateCanvasDimensions(!0)}]:[]}}),"f"),this.options.graph&&_(this,k,new pi({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:t=>{this.setChapter({chapterId:t}),a(this,T,"f").emit(b.graph,{type:ct.watchAgainClicked,chapterId:t})},onError:t=>a(this,T,"f").emit(b.errors,new L(L.Severity.RECOVERABLE,L.Category.LOADERS,{message:t}))}),"f"),_(this,H,new gi,"f"),a(this,H,"f").addEventListener(je,a(this,Re,"f")),a(this,T,"f").on(b.interactives,t=>{var n,s;if(t.type===N.actionExecution){if(((n=t.payload)===null||n===void 0?void 0:n.behaviour)==="change-chapter"){const{chapterId:r,autoSelect:c}=t.payload;this.setChapter({chapterId:r,autoSelect:c})}if(((s=t.payload)===null||s===void 0?void 0:s.behaviour)==="change-manifest"){const{manifestURL:r}=t.payload;this.setManifest(r)}}}),this.isFirstChapterFetched=!1,this.state=Q.created}async initSeamless({source:e,initialChapter:t,visitedChapters:n=[],videosInfo:s}){_(this,ue,qi(this),"f");const r=document.createElement("div");a(this,ue,"f").on(Se.activePlayerChanged,this.emitPlayerChanged);const{player:c,config:o}=await a(this,ue,"f").init({source:e,initialChapter:t,container:r});return this.setVisitedChapters(n),this.updateGraphVideosInfo(s),{player:c,config:o}}getStatEvents(){return{click$:new G.Observable(e=>{a(this,T,"f").on(b.graph,({type:t,visibility:n})=>{t==="visibility"&&e.next(n?exports.INTERACTIVE_CLICK_ACTIONS.OPEN_GRAPH:exports.INTERACTIVE_CLICK_ACTIONS.CLOSE_GRAPH),t==="watchAgainClicked"&&e.next(exports.INTERACTIVE_CLICK_ACTIONS.WATCH_AGAIN)}),a(this,T,"f").on(b.interactives,({type:t,subjectName:n,subjectType:s})=>{t!=="action-choice"||n!=="control"||(s==="Button"&&e.next(exports.INTERACTIVE_CLICK_ACTIONS.GO_NEXT_BUTTON),s==="Area"&&e.next(exports.INTERACTIVE_CLICK_ACTIONS.GO_NEXT_AREA))})}),nextMovie$:new G.Observable(e=>{a(this,T,"f").on(b.playerChanged,({config:t})=>{t!=null&&t.unitedVideoId&&e.next(t.unitedVideoId)})})}}setPlayer(e){a(this,F,"m",Te).call(this),this.options.player=e,ce.setPlayer(this.options.player),a(this,B,"f")?a(this,B,"f").setPlayer(this.options.player):_(this,B,ft(this.options.player),"f"),_(this,K,mt({player:this.options.player,interactiveEvents:a(this,B,"f"),globalEventEmitter:a(this,T,"f"),removeControllers:a(this,oe,"f")}),"f"),this.state===Q.initiated&&(a(this,F,"m",Pe).call(this),a(this,F,"m",fe).call(this,a(this,x,"f").chapter))}async setManifest(e,t){a(this,F,"m",Te).call(this),this.isFirstChapterFetched=!1;const n=await a(this,x,"f").setManifest(e),s=t&&t.manifestId===n.manifest.metadata.id?{...t}:void 0;return a(this,H,"f").onManifestChange(n.manifest.metadata,s),a(this,k,"f")&&await a(this,k,"f").handleManifestChange(n.manifest,s?mi(s):[]),a(this,T,"f").emit(b.manifestChanged,{manifest:n.manifest}),a(this,F,"m",fe).call(this,a(this,x,"f").chapter),n.manifest}setVisitedChapters(e){var t;Array.isArray(e)&&((t=a(this,k,"f"))===null||t===void 0||t.setVisitedChapters(e))}updateGraphVideosInfo(e){var t;Array.isArray(e)&&((t=a(this,k,"f"))===null||t===void 0||t.updateVideosInfo(e))}async setChapter({chapterId:e,autoSelect:t,tryContinueFromHistory:n=!1}={}){var s;a(this,F,"m",Te).call(this),a(this,M,"f")&&this.isFirstChapterFetched&&(a(this,M,"f").draw(),a(this,M,"f").show()),G.getCurrentBrowser().browser===G.CurrentClientBrowser.Safari&&await yn(35);let c;e?c=await a(this,x,"f").setNext(e):c=await(n?a(this,x,"f").setNext(yi(a(this,x,"f").manifest,this.getHistory())):a(this,x,"f").setInitial());const{chapter:o,media:l,graph:d}=c;return a(this,H,"f").onChapterChange({chapterId:o.id,mediaId:l.id,autoSelect:t,isLastChapter:$t(o)}),a(this,k,"f")&&a(this,k,"f").handleChapterChange(d),(s=a(this,M,"f"))===null||s===void 0||s.setCurrentChapter(this.getCurrentChapter().chapter),a(this,T,"f").emit(b.chapterChanged,{chapter:o,media:l,graph:d}),a(this,F,"m",fe).call(this,a(this,x,"f").chapter),_(this,ve,new Set,"f"),this.isFirstChapterFetched=!0,{chapter:o,media:l,graph:d}}toggleGraphView(e=!0){a(this,k,"f")&&(e?(a(this,k,"f").show(),a(this,te,"f").next(!1)):(a(this,k,"f").hide(),a(this,F,"m",Fe).call(this)),a(this,T,"f").emit(b.graph,{type:ct.visibility,visibility:e}))}init(){a(this,x,"f").chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.state===Q.created&&(a(this,J,"f").resizeObserver.observe(this.options.fullscreenTargetElement),a(this,F,"m",Pe).call(this),this.state=Q.initiated,a(this,F,"m",fe).call(this,a(this,x,"f").chapter))}isSupport(e=a(this,x,"f").manifest){return He(e.metadata.version)}getIsSeekable(){return a(this,te,"f")}getHistory(){return a(this,H,"f").getHistory()}getInteractiveRanges(){var e;return Yi((e=a(this,x,"f").chapter)===null||e===void 0?void 0:e.containers)}getNextInteractiveStartTime(e){return ce.getNextInteractiveTime(e)}getChapterBranches(e){return a(this,x,"f").getBranches(e)}getCurrentChapter(){return a(this,x,"f").getCurrent()}getCurrentManifest(){return a(this,x,"f").manifest}addFactory(e,t){this.factories.set(e.trim().toLowerCase(),t)}removeFactory(e){this.factories.delete(e.trim().toLowerCase())}on(...e){return a(this,T,"f").on(...e),this}off(...e){return a(this,T,"f").off(...e),this}once(...e){return a(this,T,"f").once(...e),this}destroy(){var e,t;a(this,oe,"f").call(this),_(this,U,void 0,"f"),a(this,H,"f").removeEventListener(je,a(this,Re,"f")),a(this,H,"f").destroy(),_(this,H,void 0,"f"),(e=a(this,k,"f"))===null||e===void 0||e.destroy(),_(this,k,void 0,"f"),a(this,J,"f").release(),_(this,J,void 0,"f"),_(this,K,void 0,"f"),a(this,D,"f").release(),_(this,D,void 0,"f"),a(this,B,"f").release(),_(this,B,void 0,"f"),a(this,x,"f").release(),_(this,K,void 0,"f"),a(this,ee,"f").release(),_(this,ee,void 0,"f"),a(this,X,"f").unsubscribe(),_(this,X,void 0,"f"),a(this,T,"f").reset(),_(this,T,void 0,"f"),(t=a(this,M,"f"))===null||t===void 0||t.destroy(),_(this,M,void 0,"f"),this.rootElement.remove(),this.rootElement=void 0,this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.state=Q.destroyed}}J=new WeakMap,U=new WeakMap,ee=new WeakMap,X=new WeakMap,B=new WeakMap,D=new WeakMap,K=new WeakMap,x=new WeakMap,te=new WeakMap,ve=new WeakMap,k=new WeakMap,H=new WeakMap,ue=new WeakMap,M=new WeakMap,T=new WeakMap,Wt=new WeakMap,ke=new WeakMap,oe=new WeakMap,Re=new WeakMap,F=new WeakSet,Te=function(){var e;this.state===Q.ready&&(a(this,oe,"f").call(this),_(this,U,[],"f"),a(this,D,"f").release(),(e=a(this,B,"f"))===null||e===void 0||e.release(),this.state=Q.initiated,a(this,te,"f").next(!1))},yt=function(e){(!a(this,k,"f")||a(this,k,"f").isHidden)&&a(this,F,"m",Fe).call(this);const t=e*1e3,s=this.getInteractiveRanges().findLast(({range:r})=>t>=r[1]);if(s){const r=s.range.join("-");a(this,ve,"f").has(r)||(a(this,ve,"f").add(r),a(this,T,"f").emit(b.interactives,{type:N.rangeEnded,payload:s,visibility:!0}))}},Pe=function(){a(this,X,"f").unsubscribe(),a(this,X,"f").add(this.options.player.events.started$.pipe(G.once()).subscribe(a(this,ke,"f"))).add(this.options.player.events.playing$.subscribe(a(this,D,"f").requestAnimation)).add(this.options.player.events.willPause$.subscribe(a(this,D,"f").cancelAnimation)).add(this.options.player.info.position$.subscribe(a(this,F,"m",yt).bind(this))),this.options.lastFrame&&a(this,X,"f").add(this.options.player.info.duration$.subscribe(e=>{a(this,M,"f").setVideoDuration(e*1e3)})).add(this.options.player.experimental.element$.subscribe(e=>{e&&a(this,M,"f").setVideoElement(e)})).add(this.options.player.events.firstFrame$.subscribe(()=>{a(this,M,"f").reset(),setTimeout(()=>{a(this,M,"f").hide(),a(this,M,"f").lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(a(this,M,"f").onSeek))},fe=function(e){a(this,x,"f").chapter&&this.state===Q.initiated&&(a(this,K,"f").setManifestChapterEvents(e),_(this,U,a(this,F,"m",bt).call(this,e),"f"),a(this,B,"f").containersEventsCallState.setData(e.containers),ce.setContainers(a(this,U,"f").map(t=>t.container.container)),this.options.lastFrame&&a(this,D,"f").addFn(()=>{a(this,M,"f").onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.state=Q.ready)},bt=function(e){var t,n;return(n=(t=e==null?void 0:e.containers)===null||t===void 0?void 0:t.reduce((s,r)=>{const c=r.type.trim().toLowerCase(),o=this.factories.get(c);if(o){const l=new en({player:this.options.player,container:o(r,this.rootElement),branches:a(this,x,"f").chapter.branches,selectBranches:a(this,K,"f"),interactiveEvents:a(this,B,"f"),globalEventEmitter:a(this,T,"f"),ignoreContainerEvent:()=>Ji(r,a(this,U,"f"))});return a(this,D,"f").addFn(l.whilePlaying,!0),[...s,l]}return[...s]},[]))!==null&&n!==void 0?n:[]},Fe=function(){const e=a(this,te,"f").getValue(),t=!!ce.getNextInteractiveTime();(t&&!e||!t&&e)&&a(this,te,"f").next(!e)};const wn={Container:xt,createChoiceContainer:Ot,createAreaControl:Tt,createButtonControl:Rt,createRelativeLayout:ai,getRootEl:Et,classnamesPrefix:W},_n={version:Jt};exports.CustomError=L;exports.EVENT_NAMES=b;exports.Interactives=En;exports.ManifestController=Bt;exports.SDKInfo=_n;exports.compareVersions=me;exports.isSupportedManifest=He;exports.utils=wn;
|