@vkontakte/videoplayer-interactive 1.0.14-dev.e025b924.0 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015.cjs.js +6 -6
- package/es2015.esm.js +6 -6
- package/es2018.cjs.js +6 -6
- package/es2018.esm.js +6 -6
- package/esnext.cjs.js +6 -6
- package/esnext.esm.js +6 -6
- package/evergreen.esm.js +6 -6
- package/package.json +3 -3
- package/types/index.d.ts +1 -1
- package/types/modules/Interactives/Interactives.d.ts +1 -2
- package/types/modules/Interactives/utils/gameUtils.d.ts +0 -1
- package/types/modules/Interactives/utils/getInteractiveRanges.d.ts +7 -0
- package/types/movika.core/manifest/index.d.ts +3 -2
- package/types/utils/LastFrame.d.ts +1 -1
package/es2015.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-interactive v1.0.14
|
|
3
|
-
*
|
|
2
|
+
* @vkontakte/videoplayer-interactive v1.0.14
|
|
3
|
+
* Mon, 12 Aug 2024 12:01:19 GMT
|
|
4
4
|
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-14/doc/
|
|
5
5
|
*/
|
|
6
|
-
"use strict";var Fn=Object.create;var Ht=Object.defineProperty,Dn=Object.defineProperties,Hn=Object.getOwnPropertyDescriptor,Gn=Object.getOwnPropertyDescriptors,Un=Object.getOwnPropertyNames,ce=Object.getOwnPropertySymbols,Wn=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty,ji=Object.prototype.propertyIsEnumerable;var Xe=(i,t,e)=>t in i?Ht(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,p=(i,t)=>{for(var e in t||(t={}))qe.call(t,e)&&Xe(i,e,t[e]);if(ce)for(var e of ce(t))ji.call(t,e)&&Xe(i,e,t[e]);return i},b=(i,t)=>Dn(i,Gn(t));var X=(i,t)=>{var e={};for(var n in i)qe.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&ce)for(var n of ce(i))t.indexOf(n)<0&&ji.call(i,n)&&(e[n]=i[n]);return e};var zn=(i,t)=>{for(var e in t)Ht(i,e,{get:t[e],enumerable:!0})},Pi=(i,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Un(t))!qe.call(i,r)&&r!==e&&Ht(i,r,{get:()=>t[r],enumerable:!(n=Hn(t,r))||n.enumerable});return i};var Qn=(i,t,e)=>(e=i!=null?Fn(Wn(i)):{},Pi(t||!i||!i.__esModule?Ht(e,"default",{value:i,enumerable:!0}):e,i)),Kn=i=>Pi(Ht({},"__esModule",{value:!0}),i);var O=(i,t,e)=>(Xe(i,typeof t!="symbol"?t+"":t,e),e),Ze=(i,t,e)=>{if(!t.has(i))throw TypeError("Cannot "+e)};var a=(i,t,e)=>(Ze(i,t,"read from private field"),e?e.call(i):t.get(i)),v=(i,t,e)=>{if(t.has(i))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(i):t.set(i,e)},m=(i,t,e,n)=>(Ze(i,t,"write to private field"),n?n.call(i,e):t.set(i,e),e);var $i=(i,t,e,n)=>({set _(r){m(i,t,r,e)},get _(){return a(i,t,n)}}),$=(i,t,e)=>(Ze(i,t,"access private method"),e);var V=(i,t,e)=>new Promise((n,r)=>{var s=c=>{try{o(e.next(c))}catch(h){r(h)}},l=c=>{try{o(e.throw(c))}catch(h){r(h)}},o=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,l);o((e=e.apply(i,t)).next())});var Is={};zn(Is,{CustomError:()=>S,EVENT_NAMES:()=>y,INTERACTIVE_CLICK_ACTIONS:()=>Te,Interactives:()=>ne,ManifestController:()=>xt,SDKInfo:()=>Es,chapterIdsToVKVideoIds:()=>Le,compareVersions:()=>rt,getChapterIdByVkVideoId:()=>Vn,getVKVideoIdByMedia:()=>Ii,getVideoRawIdByMedia:()=>Sn,graphEventTypes:()=>Pt,hasEndTemplate:()=>qt,interactivesEventTypes:()=>_,isLastChapter:()=>nt,isSupportedManifest:()=>Kt,isVKVariantItem:()=>wn,utils:()=>On,vkVideoIdsToChapterIds:()=>xi});module.exports=Kn(Is);var Oi="1.0.14-dev.e025b924.0";function Ye(i,t=1){let e="0",n="0",r="0";return i.length===4?(e="0x"+i[1]+i[1],n="0x"+i[2]+i[2],r="0x"+i[3]+i[3]):i.length===7&&(e="0x"+i[1]+i[2],n="0x"+i[3]+i[4],r="0x"+i[5]+i[6]),`rgba(${+e},${+n},${+r},${t})`}var G="SDK_NAME",Xn="SDK_NAME-controls-container",le=()=>document.querySelector(`.${Xn}`),Hi=.4,q={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},Bi={top:"flex-start",bottom:"flex-end",center:"center"},Fi={start:"flex-start",end:"flex-end",center:"center"},Di={start:"left",end:"right",center:"center"},he=({target:i,props:t})=>{var e,n,r,s,l,o;i.style.alignItems=(n=Bi[(e=t==null?void 0:t.text)==null?void 0:e.gravityVertical])!=null?n:Bi.center,i.style.justifyContent=(s=Fi[(r=t==null?void 0:t.text)==null?void 0:r.gravityHorizontal])!=null?s:Fi.center,i.style.textAlign=(o=Di[(l=t==null?void 0:t.text)==null?void 0:l.alignment])!=null?o:Di.start},de=({target:i,props:t,fallback:e,dependsOn:n})=>{var r,s,l,o,c,h;i.style.color=(s=(r=t==null?void 0:t.text)==null?void 0:r.color)!=null?s:e.textColor,i.style.fontSize=`calc(${n.height} * ${(o=(l=t==null?void 0:t.text)==null?void 0:l.size)!=null?o:e.textSize})`,i.textContent=(h=(c=t==null?void 0:t.text)==null?void 0:c.value)!=null?h:e.textContent},pe=({target:i,props:t,fallback:e})=>{var n,r,s,l;i.style.backgroundColor=Ye((r=(n=t==null?void 0:t.background)==null?void 0:n.color)!=null?r:e.backgroundColor,(l=(s=t==null?void 0:t.background)==null?void 0:s.alpha)!=null?l:e.backgroundAlpha)},ue=({target:i,props:t,fallback:e,dependsOn:n})=>{var r,s,l,o,c,h,C,E,I,w,x;i.style.border=`calc(${n.height} * ${(l=(s=(r=t==null?void 0:t.shape)==null?void 0:r.border)==null?void 0:s.width)!=null?l:e.borderWidth}) solid ${Ye((h=(c=(o=t==null?void 0:t.shape)==null?void 0:o.border)==null?void 0:c.color)!=null?h:e.borderColor,(I=(E=(C=t==null?void 0:t.shape)==null?void 0:C.border)==null?void 0:E.alpha)!=null?I:e.borderAlpha)}`,i.style.borderRadius=`calc(${n.height} * ${(x=(w=t==null?void 0:t.shape)==null?void 0:w.roundCorners)!=null?x:e.roundCorners})`},At=({target:i,layoutParams:t,fallback:e})=>{i.style.transform=`rotate(${-t.angle}rad)`};var Je="int",Lt={AREA:`${Je}_area`,TEXT:`${Je}_text`,BUTTON:`${Je}_bttn`};var ft=class{constructor(t){this.control=t}createView(t){var r;let e=document.createElement("div");e.classList.add(`${G}-control-container-${this.control.id}`),t(e,this.control.layoutParams);let n=((r=this.control.layoutParams.innerSizesDependOn)!=null?r:q.innerSizesDependOn)==="self"?{height:e.style.height,width:e.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:e,dependsOn:n}}setEvents(t,e){t&&this.control.events.forEach(n=>{switch(n.type.trim().toLowerCase()){case"onclick":t.addEventListener("click",s=>{s.stopPropagation(),e&&e({action:n.action,controlId:this.control.id,controlType:this.control.type})});break;default:break}})}getElement(){return document.querySelector(`.${G}-control-container-${this.control.id}`)}};var fe=i=>{if(i.type.trim().toLowerCase()==="area")return new ti(i)},ti=class extends ft{constructor(t){super(t)}createView({parent:t,layoutFn:e}){let{dependsOn:n,controlContainerEl:r}=super.createView(e),s=document.createElement("button");return s.classList.add(`${G}-${this.control.id}`),s.setAttribute("data-testid",Lt.AREA),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.type="button",pe({target:s,props:this.control.props,fallback:b(p({},q),{backgroundColor:"transparent"})}),ue({target:s,props:this.control.props,fallback:b(p({},q),{borderAlpha:0}),dependsOn:n}),At({target:s,layoutParams:this.control.layoutParams,fallback:q}),r.append(s),t.append(r),this.controlEl=s,r}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}};var me=()=>{let i=document.createElement("span");return i.style.display="inline-block",i.style.whiteSpace="pre",i.style.overflow="hidden",i.style.textOverflow="ellipsis",i.style.maxWidth="100%",i.style.maxHeight="100%",i};var ye=i=>{if(i.type.trim().toLowerCase()==="button")return new ei(i)},ei=class extends ft{constructor(t){super(t)}createView({parent:t,layoutFn:e}){let{dependsOn:n,controlContainerEl:r}=super.createView(e),s=document.createElement("button");s.type="button",s.classList.add(`${G}-${this.control.id}`),s.setAttribute("data-testid",Lt.BUTTON),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.style.fontFamily="inherit";let l=me();return At({target:s,layoutParams:this.control.layoutParams,fallback:q}),pe({target:s,props:this.control.props,fallback:q}),ue({target:s,props:this.control.props,fallback:q,dependsOn:n}),he({target:s,props:this.control.props}),de({target:l,props:this.control.props,fallback:q,dependsOn:n}),s.append(l),r.append(s),t.append(r),this.controlEl=s,r}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}};var Gi=i=>{if(i.type.trim().toLowerCase()==="text")return new ii(i)},ii=class extends ft{constructor(t){super(t)}createView({parent:t,layoutFn:e}){let{dependsOn:n,controlContainerEl:r}=super.createView(e),s=document.createElement("div");s.classList.add(`${G}-${this.control.id}`),s.setAttribute("data-testid",Lt.TEXT),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.fontFamily="inherit";let l=me();return At({target:s,layoutParams:this.control.layoutParams,fallback:q}),he({target:s,props:this.control.props}),de({target:l,props:this.control.props,fallback:q,dependsOn:n}),s.append(l),r.append(s),t.append(r),this.controlEl=s,r}disable(){}enable(){}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}};var ni=class{constructor(t){this.layout=t}},Ui=i=>{if(i.type.trim().toLowerCase()==="relative")return new Gt(i)},Gt=class extends ni{constructor(t){super(t)}setContainerLayout(t){t.style.position="relative"}setControlLayout(t,e){t.style.position="absolute",t.style.width=`calc(var(--interactive-content-width) * ${e.width})`,t.style.height=`calc(var(--interactive-content-height) * ${e.height})`,t.style.left=`calc(var(--interactive-content-width) * ${e.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,t.style.top=`calc(var(--interactive-content-height) * ${e.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var Nt,ge,ve,Wi,kt=class{constructor(t){v(this,Nt);v(this,ve);this.container=t,this.factories=new Map,$(this,Nt,ge).call(this)}addControlFactory(t,e){this.factories.set(t.trim().toLowerCase(),e),$(this,Nt,ge).call(this)}removeControlFactory(t){this.factories.delete(t.trim().toLowerCase()),$(this,Nt,ge).call(this)}};Nt=new WeakSet,ge=function(){this.controls=$(this,ve,Wi).call(this)},ve=new WeakSet,Wi=function(){var t;return(t=this.container.controls)==null?void 0:t.reduce((e,n)=>{let r=n.type.trim().toLowerCase(),s=this.factories.get(r);return s?[...e,s(n)]:[...e]},[])};var be=(i,t)=>{if(i.type.trim().toLowerCase()==="choice")return new si(i,t)},si=class extends kt{constructor(t,e){super(t),this.rootElement=e!=null?e:le(),this.layout=new Gt(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",ye),this.addControlFactory("text",Gi),this.addControlFactory("area",fe)}createView(t){let e=document.createElement("div");return e.classList.add(`${G}-${this.container.id}`),this.layout.setContainerLayout(e),this.controls.forEach(n=>{let r=n.createView({parent:e,layoutFn:this.layout.setControlLayout});n.setEvents(r,t)}),this.rootElement.append(e),this.isRemoved=!1,e}hide(){let t=this.getElement();t&&(t.style.visibility="hidden")}show(){let t=this.getElement();t&&(t.style.visibility="visible")}enable(){let t=this.getElement();t&&(this.controls.forEach(e=>e.enable()),t.style.opacity=1,this.isDisabled=!1)}disable(){let t=this.getElement();t&&(this.controls.forEach(e=>e.disable()),t.style.opacity=Hi,this.isDisabled=!0)}removeView(){var t;this.isRemoved||((t=this.getElement())==null||t.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${G}-${this.container.id}`)}};var N=require("@vkontakte/videoplayer-shared");var qi=require("@vkontakte/videoplayer-shared");function Ce(i,t){let e;return(...n)=>{clearTimeout(e),e=setTimeout(()=>i(...n),t)}}var Ut={Object:"Object",String:"String",Array:"Array",Number:"Number",Function:"Function",Boolean:"Boolean"},Ct=(i,t)=>Object.prototype.toString.call(i)===`[object ${t}]`,Wt=i=>Ct(i,Ut.Object),Ee=i=>Ct(i,Ut.String),Ie=i=>Ct(i,Ut.Array),xe=i=>Ct(i,Ut.Number),zi=i=>Ct(i,Ut.Function);var ri=i=>xe(i)&&!isNaN(i);var Et=i=>Wt(i)&&Object.keys(i).length===0,ai=i=>Ie(i)&&!i.length;var zt=(i,t)=>Ee(i)&&(t?i.trim():i).length;var oi=window.navigator.userAgent.toLowerCase(),dr=/ipad|iphone|ipod/.test(oi),Qi=/mobi/i.test(oi),pr=oi.indexOf("android")>-1&&Qi,qn=!Qi,ur=window.safari!==void 0&&qn;var Ki="video_interactive",Xi="videoint";var Zn=250,Qt=class{constructor(t){O(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}))});O(this,"handleChapterChange",t=>{var e;if(this.isReady){if(this.isHidden||this.hide(),!(t!=null&&t.id)){(e=this.onError)==null||e.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}});O(this,"handleManifestChange",(n,...r)=>V(this,[n,...r],function*(t,e=[]){var s;if(!xe(t.graph.edit.chapters[0].x)){this.isReady=!1,(s=this.onError)==null||s.call(this,"Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=void 0,!this.ngEditor){let l;try{l=yield(0,qi.loadVKLangPack)(this.lang,Ki,Xi)}catch(c){console.log("Unable to load graph language pack")}let{GraphEditor:o}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new o(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:l}),this.ngEditor.on("control",({name:c,chapterId:h})=>{c==="openPreview"&&this.onOpenPreviewClick(h)}),this.ngEditor.on("zoomEnd",c=>{this.lastZoomInfo=p({},c)})}this.visitedChapterIds=new Set(e),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(t)}init({root:t,onOpenPreviewClick:e,onError:n,lang:r,visitedChapters:s=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=e,this.onError=n,this.lang=r!=null?r:"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=Yn(t),this.resizeObserver=new ResizeObserver(Ce(this.onResize,Zn)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(t=this.ngEditorSize){return[(this.lastZoomInfo.x-t.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-t.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(t){this.visitedChapterIds=new Set([...this.visitedChapterIds,...t]),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(t){this.ngEditor.updateVideosInfo(t)}show(){!this.ngEditor||!this.isReady||(this.graphWrapperElement.style.display="block",this.lastZoomInfo||this.ngEditor.focusChapter(this.currentChapterId),this.isHidden=!1)}hide(){this.graphWrapperElement.style.display="none",this.isHidden=!0}destroy(){var t,e;this.hide(),this.resizeObserver.disconnect(),(t=this.ngEditor)==null||t.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(e=this.ngEditor)==null||e.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function Yn(i){let t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.height="100%",t.style.width="100%",t.style.display="none",i.append(t),t}var ci=()=>{let i=[],t=null;return{setPlayer:l=>{t=l},setContainers:l=>{i=l},deleteContainer:l=>{i=i.filter(o=>o.id!==l)},getNextInteractiveTime:(l=3e3)=>{if(!i.length||t===null)return null;let o=-1,c=!1,h=Math.round(t.info.position$.getValue()*1e3);for(let C of i){let E=C.startTime-l;if(E<=h&&(h<=C.endTime||C.endTime===null)){c=!0;break}h<E&&(o=o===-1?E:Math.min(o,E))}return!c&&o!==-1?o:null}}};var rt=(i="",t="")=>{i=i.split("."),t=t.split(".");let e=0;for(let n=0;n<Math.max(i.length,t.length)&&!e;n++)i[n]>t[n]?e=1:i[n]<t[n]?e=-1:e=0;return e};var Yi=require("uuid");var Jn="3.1",Zi={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},ts={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Ji=i=>{let t=[];for(let l of i.chapters){let o,c=[];for(let e of l.branches){let n=e,{isDefault:E}=n,I=X(n,["isDefault"]);E&&(o=I.id),c.push(I)}let h=[],C=[];for(let r of l.containers){let s=r,{fallbackStrategy:E}=s,I=X(s,["fallbackStrategy"]);let w=!!I.endTime,x=[ts];switch(E){case"await":w?x=[]:h=[];break;case"default":{let R={type:"onSuspense",action:{type:Zi.default,args:{branchId:o,shouldOpenNow:!w,isDetachContainer:!0}}};w?x=[R]:h=[R];break}case"random":case"weightlessRandom":case"max":case"min":{let R={type:"onSuspense",action:{type:Zi[E],args:{}}};w?x=[R]:h=[R];break}}for(let R of I.controls)C.push(b(p({},I),{controls:[p({},R)],id:(0,Yi.v4)(),events:x}))}t.push(b(p({},l),{containers:C,events:h,branches:c}))}return i.metadata.version=Jn,i.metadata.updated=new Date().toISOString(),b(p({},i),{chapters:t})};var es="3.2",tn=i=>{if(!i.media){let t=i.metadata,{media:e}=t,n=X(t,["media"]);return b(p({},i),{metadata:b(p({},n),{version:es}),media:e})}return i};var is="3.3",ns=(i=[])=>({edit:{chapters:i},view:{}}),en={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},nn=i=>{var r;let t=[],e=[];for(let s of i.chapters){let n=s,{id:l,x:o,y:c}=n,h=X(n,["id","x","y"]),C=h.containers.map(E=>{var I;return b(p({},E),{controls:E.controls.map(P=>{var f=P,{subtype:w,type:x}=f,R=X(f,["subtype","type"]);return b(p({},R),{type:w!=null?w:x})}),events:(I=E.events)!=null&&I.length?E.events:[en]})});t.push(b(p({id:l},h),{containers:C,events:(r=h.events)!=null&&r.length?h.events:[en]})),e.push({id:l,x:o,y:c})}return b(p({},i),{chapters:t,graph:ns(e),metadata:b(p({},i.metadata),{version:is})})};var ss=[{version:"3.0",migrate:Ji},{version:"3.1",migrate:tn},{version:"3.2",migrate:nn}],li=i=>ss.reduce((t,e)=>rt(t.metadata.version,e.version)?t:e.migrate(t),i);var Fr=Object.freeze({Choice:"Choice",TextInput:"TextInput"}),sn=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),Dr=Object.freeze({onClick:"onClick",onSuspense:"onSuspense"}),j=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"}),Te=(s=>(s.GO_NEXT_BUTTON="GO_NEXT_BUTTON",s.GO_NEXT_AREA="GO_NEXT_AREA",s.WATCH_AGAIN="WATCH_AGAIN",s.OPEN_GRAPH="OPEN_GRAPH",s.CLOSE_GRAPH="CLOSE_GRAPH",s))(Te||{});var rn={metadata:"Object",chapters:"Array"},rs="3.0.0",as="3.3.0",Kt=i=>{let t=rt(i,rs);return t===-1?!1:t===0?!0:rt(i,as)!==1},an=i=>{if(!Wt(i))return!1;for(let t in rn)if(!i[t]||!Ct(i[t],rn[t]))return!1;return Kt(i.metadata.version)},hi=i=>i.type===sn.Text;var S=class{constructor(t,e,...n){this.severity=t,this.category=e,this.data=n}toString(){return`SDK_NAME ERROR ${JSON.stringify(this,null," ")}`}};O(S,"Severity",{RECOVERABLE:1,CRITICAL:2}),O(S,"Category",{VIDEO:0,INTERACTIVES:1,GRAPH:2,MANIFEST:3,LOADERS:4,HISTORY:5,SEAMLESS:6});var jt=class{constructor(){O(this,"listeners",{})}addListener(t,e){return this.listeners[t]=this.listeners[t]||[],this.listeners[t].push(e),this}on(t,e){return this.addListener(t,e)}once(t,e){this.listeners[t]=this.listeners[t]||[];let n=()=>{e(),this.off(t,n)};return this.listeners[t].push(n),this}off(t,e){return this.removeListener(t,e)}reset(){this.listeners={}}removeListener(t,e){let n=this.listeners[t];if(!n)return this;for(let r=n.length;r>0;r--)if(n[r]===e){n.splice(r,1);break}return this}emit(t,...e){let n=this.listeners[t];return n?(n.forEach(r=>{r(...e)}),!0):!1}listenerCount(t){return(this.listeners[t]||[]).length}rawListeners(t){return this.listeners[t]}};var Se=class{constructor(t){O(this,"addFn",(t,e=!1)=>{zi(t)&&(this.fns.push(t),e&&this.updateFn())});O(this,"removeFn",(t,e=!1)=>{this.fns=this.fns.filter(n=>n!==t),e&&this.updateFn()});O(this,"updateFn",()=>{this.fn=()=>{this.fns.forEach(t=>t()),this.raf&&this.forceRequestAnimation()}});O(this,"forceRequestAnimation",()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))});O(this,"requestAnimation",()=>{this.raf||this.forceRequestAnimation()});O(this,"cancelAnimation",()=>{cancelAnimationFrame(this.raf),this.raf=void 0});this.raf,this.fn,this.fns=[],this.addFn(t)}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}};var pn=require("@vkontakte/videoplayer-shared");var we=class{constructor(t){var e,n;this.loaders={chapterLoaders:(e=t==null?void 0:t.chapterLoaders)!=null?e:[],manifestLoaders:(n=t==null?void 0:t.manifestLoaders)!=null?n:[]}}exec(t,e){return V(this,null,function*(){return os(...this.loaders[t])(e)})}};function os(...i){return function(e){return V(this,null,function*(){let n=[...i];for(;n.length>0;)e=yield n.shift()(e);return e})}}function Xt(i,t,e){return i?b(p({},i),{[t]:i[t]?[e,...i[t]]:[e]}):{[t]:[e]}}function Ve(r){var s=r,{actions:i,errors:t,chapterId:e}=s,n=X(s,["actions","errors","chapterId"]);if(e){let l=i.getManifest(),o=i.getChapter(l.chapters,e);if(o){let c=i.getMedia(l.media,o.videoId),h=i.getGraph(l.graph,o.id);return c?b(p({},n),{actions:i,errors:t,result:{chapter:o,media:c,graph:h}}):b(p({},n),{errors:Xt(t,Ve.name,"Could not find media"),actions:i})}}return b(p({},n),{errors:Xt(t,Ve.name,"Could not find chapter"),actions:i})}var cs=i=>V(void 0,null,function*(){try{let t,e;if(Wt(i))t=i;else if(Ee(i)){e=new URL(i).href;let r=yield fetch(e);if(!r.ok)return{};t=yield r.json()}else return{};if(!an(t))return{};let n=t.metadata.media;if(Ee(n)&&!t.media)try{let r;e?r=new URL(n,e).href:(r=new URL(n).href,e=r);let s=yield fetch(r);if(!s.ok)throw new Error;t.metadata.media=yield s.json()}catch(r){return ds(t.metadata.version)?{manifest:t}:{}}return{manifest:t,manifestURL:e}}catch(t){return{}}});function on(i){return V(this,null,function*(){let{manifest:t,manifestURL:e}=yield cs(i),n=li(t);return n.media=ls(n.media,e),delete n.metadata.media,n})}function Re(i,t){return i.find(e=>e.id===t)}function di(i,t){var e,n;return(e=i.edit)!=null&&e.chapters?i.edit.chapters.find(r=>r.id===t):(n=i.view)!=null&&n.chapters?i.view.chapters.find(r=>r.id===t):void 0}function pi(i,t){return i.videos.find(e=>e.id===t)}function ls(i,t){return b(p({},i),{videos:i.videos.map(e=>b(p({},e),{variants:e.variants.map(n=>{let r=hs(n.url,t);return b(p({},n),{url:r||n.url})})}))})}function hs(i,t){try{return new URL(i,t).href}catch(e){return""}}function ds(i){return rt(i,"3.2.0")>=0}var D=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),ui=i=>Ie(i)&&!ai(i),nt=i=>i.order==="end",qt=i=>Ie(i.containers)&&!ai(i.containers)&&nt(i),cn=(i,t)=>{var n;let e=i*1e3;return ui(t.controls)&&e<((n=t.startTime)!=null?n:0)},fi=(i,t)=>{var n,r;let e=i*1e3;return ui(t.controls)&&e>=((n=t.startTime)!=null?n:0)&&e<=((r=t.endTime)!=null?r:1/0)};var It=i=>i.some(t=>t.action.type==="expect"),mi=i=>i.find(t=>t.action.type==="expect"),ps=i=>(i==null?void 0:i.length)===1,_e=i=>ps(i)&&hi(i[0]);var ln=({fn:i,type:t=1},...e)=>(...n)=>t?i(...n,...e):i(p(p({},n[t]),e[t])),hn=(i=[])=>i.reduce((t,e,n)=>{var s,l,o;let r=((s=e==null?void 0:e.controls)!=null?s:[]).filter(c=>!hi(c));if(ui(r)){let c=[(l=e.startTime)!=null?l:0,(o=e.endTime)!=null?o:1/0],h=e.id;if(!n)t.push({subjects:[h],range:c});else{let C=[],E=-1/0,I=1/0,w=[],x=[];for(let R=0;R<t.length;R++){let P=t[R];if(x.push(...P.subjects),P.range[0]<I&&(I=P.range[0]),P.range[1]>E&&(E=P.range[1]),P.range[0]<=c[0]&&P.range[1]>=c[1])return t[R].subjects.push(h),t;c[0]>=P.range[0]&&c[0]<=P.range[1]&&(C.push(R),w=w.concat(P.subjects),c[0]=P.range[0]),c[1]>=P.range[0]&&c[1]<=P.range[1]&&(C.push(R),w=w.concat(P.subjects),c[1]=P.range[1])}if(x.push(h),c[0]<=I&&c[1]>=E)return[{subjects:x,range:c}];C.length&&C.reverse().forEach(R=>{t.splice(R,1)}),t.push({subjects:w.concat([h]),range:c})}}return t},[]).sort((t,e)=>t.range[0]-e.range[0]),dn=(i,t)=>It(i.events)?!1:t.some(({container:e})=>e.container.id!==i.id&&It(e.container.events)&&e.container.endTime===i.endTime&&!e.isRemoved);var xt=class extends we{constructor(t,e){super(t),this.onError=e,this.prevChapter$=new pn.ValueSubject(null),this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(t){return V(this,null,function*(){var r;this.release();let e=yield this.exec("manifestLoaders",{actions:{addErrorMessage:Xt},result:null,errors:null,source:t});e.errors&&this.errorHandler(e.errors);let n=yield on((r=e.result)!=null?r:t);return this.manifest=n,this})}setInitial(){return V(this,null,function*(){return this.setNext()})}setNext(){return V(this,arguments,function*(t=this.manifest.metadata.initChapterId){this.prevChapter$.next(this.chapter);let e=yield this.exec("chapterLoaders",Ve({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:di,getChapter:Re,getMedia:pi,getByBranches:this.getByBranches.bind(this),addErrorMessage:Xt},result:null,errors:null,chapterId:t}));return e.errors&&this.errorHandler(e.errors),this.chapter=e.result.chapter,this.media=e.result.media,this.graph=e.result.graph,this})}errorHandler(t){this.onError(t),console.error("Something went wrong with loaders",{errors:t})}getInitial(){return this.getByChapterId(this.manifest.metadata.initChapterId)||null}getByChapterId(t=this.manifest.metadata.initChapterId){let e=Re(this.manifest.chapters,t);if(e){let n=pi(this.manifest.media,e.videoId),r=di(this.manifest.graph,e.id);if(n)return{chapter:e,media:n,graph:r}}return null}getBranches(t=this.chapter.id){if(t===this.chapter.id)return this.getByBranches(this.chapter.branches);{let e=Re(this.manifest.chapters,t);return this.getByBranches(e==null?void 0:e.branches)}}getByBranches(t=[]){return t.reduce((e,n)=>{let r=this.getByChapterId(n.chapterId);return r&&e.push(r),e},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter.id===this.manifest.metadata.initChapterId}isEndChapter(){return nt(this.chapter)}};var fn=require("@vkontakte/videoplayer-core"),mn=require("@vkontakte/videoplayer-shared");var un=i=>{let t=i.variants.find(e=>{var n;return((n=e.payload)==null?void 0:n.type)==="vk"});if(t&&"payload"in t){let[e,n]=t.payload.id.split("_");return[e,n]}return[]};var y={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},Pt={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},_={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function yi(){let i=new Map;function t(o){var c=o,{listId:r=Math.random().toString(),itemId:s=Math.random().toString()}=c,l=X(c,["listId","itemId"]);let h=i.get(r),C=p({},l);return h?h[s]=C:i.set(r,{[s]:C}),p({listId:r,itemId:s},l)}function e(r,s){var o,c,h;let l=i.get(r);if(l){if(s)return(o=l[s])==null||o.player.destroy(),(c=l[s])==null||c.container.remove(),(h=l[s])==null||h.subscription.unsubscribe(),delete l[s],Object.keys(l).length||i.delete(r),!0;for(let C of Object.values(l))C.player.destroy(),C.container.remove();return i.delete(r),!0}else throw Error("Can't remove. Not find.")}function n(){for(let r of i)e(r[0])}return{createPlayer:t,removePlayer:e,map:i,removeAll:n}}function gi(i,t=[]){var s,l,o;let e={},n,r=!t.length;for(let c of i.variants)if(!n&&"cover"in c&&(n=c.cover),"url"in c)switch(c.type.toLowerCase()){case"mp4":(r||t.includes("mp4"))&&(e.MPEG=b(p({},e.MPEG),{[(s=c.standard)!=null?s:"Invariant quality"]:c.url}));break;case"mpeg":(r||t.includes("mpeg"))&&(e.MPEG=b(p({},e.MPEG),{[(l=c.standard)!=null?l:"Invariant quality"]:c.url}));break;case"hls":(r||t.includes("hls"))&&(e=b(p({},e),{HLS:{type:"url",url:c.url}}));break;case"dash":(r||t.includes("dash"))&&(e=b(p({},e),{DASH_SEP:{compatibilityMode:!0,type:"url",url:c.url}}));break;default:break}return{sources:e,thumbUrl:n,title:(o=i.title)!=null?o:""}}var Zt=(i,t)=>{let e=i.info.currentQuality$.getValue(),n=i.info.availableQualities$.getValue();e!==t&&n.includes(t)&&(i.setQuality(t),i.setAutoQuality(!1))};var Yt={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},us=2;function vi(i){let t=yi(),e,n,r=new jt,s={},l=!1,o=null,c=!1,h;i&&C(i);function C(d){o=d}function E(d,g,T){var k;if(!o)throw Error("need to set interactive controller");if(!o.options)return;let M=((k=t.map.get(d))!=null?k:{})[g];if(M){s=p({chapterId:T,listId:d,itemId:g},M);let F=s.player;n=F.info.currentQuality$.subscribe(A=>{if(!(!A||!F.info.position$.getValue())){e=A;for(let et of t.map)Object.values(et[1]).forEach(({player:J})=>{F.info.isAutoQualityEnabled$.getValue()||Zt(J,A)})}}),M.container.remove(),l=!1,o.setPlayer(M.player),c||(o.init(),c=!0),r.emit(Yt.activePlayerChanged,{player:s.player,config:s.config});return}throw Error("Can't set. Not find.")}function I(d,g,T){return V(this,null,function*(){if(!o)throw Error("need to set interactive controller");if(Et(s)||d!==s.itemId)return;if(T>=0&&!l){let M=o.getChapterBranches();l=!0;let k=new Set;for(let F of M)k.has(F.media.id)||(yield x({media:F.media,chapterId:F.chapter.id,setAsActive:!1,title:F.chapter.label}),k.add(F.media.id))}})}function w(T){return V(this,arguments,function*({chapter:{id:d},media:g}){if(Et(s))return;n==null||n.unsubscribe();let u=s.player.info.muted$.getValue(),M=s.player.info.currentQuality$.getValue(),k=s.player.info.isAutoQualityEnabled$.getValue(),F=s.player.info.volume$.getValue(),A=s.player.info.currentPlaybackRate$.getValue(),et=!k,J=!1;for(let Q of t.map)if(Q[0]===g.id){let ut=Object.keys(Q[1]);for(let K of ut)K===s.itemId?(ut.length<us||(J=!0),t.removePlayer(Q[0],K)):(J=!0,E(Q[0],K,d),et?Zt(s.player,M):s.player.setAutoQuality(!0),s.player.setVolume(F),s.player.setMuted(u),s.player.setPlaybackRate(A))}else t.removePlayer(Q[0]);J||(yield x({media:g,chapterId:d,setAsActive:!0,playbackRate:A}),et?Zt(s.player,M):s.player.setAutoQuality(!0),s.player.setVolume(F),s.player.setMuted(u))})}function x(et){return V(this,arguments,function*({media:d,chapterId:g,prefetch:T=!0,setAsActive:u=!0,autoplay:M=!1,preferredExt:k,title:F,playbackRate:A}){var Mi,Ai,Li,Ni,ki;let J=Math.random().toString(),Q=document.createElement("div");h.append(Q);let ut=(Mi=s==null?void 0:s.player)==null?void 0:Mi.info.isAutoQualityEnabled$.getValue(),K;if((Ai=o==null?void 0:o.options)!=null&&Ai.vkVideoLoader){let oe=un(d);oe.length&&(K=yield o.options.vkVideoLoader(...oe))}let Vi=((Li=o==null?void 0:o.options)==null?void 0:Li.coreConfig)||{},Bn=b(p({},Vi),{configName:[...(Ni=Vi.configName)!=null?Ni:[],"interactive"]}),Ri=b(p({container:Q},((ki=K==null?void 0:K.videos)==null?void 0:ki[0])||{sources:gi(d,k).sources}),{title:F,failoverHosts:(K==null?void 0:K.failoverHosts)||[]}),bt=new fn.Player(Bn);bt.initVideo(Ri);let _i=new mn.Subscription;_i.add(bt.info.position$.subscribe(function(oe){I(J,bt.info.duration$.getValue(),oe)})).add(bt.events.canplay$.subscribe(function(){ut||Zt(bt,e),A&&bt.setPlaybackRate(A)}));let Mt=t.createPlayer({listId:d.id,itemId:J,player:bt,container:Q,sources:gi(d,k).sources,config:Ri,subscription:_i});return u&&E(d.id,Mt.itemId,g),M&&Mt.player.play(),T&&!M&&Mt.player.prepare(),r.emit(Yt.playerCreated,Mt.player),{player:Mt.player,config:Mt.config}})}function R(){P(),o=null}function P(){o==null||o.off(y.chapterChanged,w),t.removeAll(),s={},c=!1,l=!1}function f(g){return V(this,arguments,function*({container:d}){if(!o)throw Error("need to set interactive controller");P(),h=d;let{media:T,chapter:u}=o.getCurrentChapter();if(T){o.on(y.chapterChanged,w);let{player:M,config:k}=yield x({media:T,chapterId:u.id,title:u.label});return r.emit(Yt.initiated,{container:d,media:T,chapterId:u.id}),{player:M,config:k}}else console.error("not found")})}return b(p({},t),{on:r.on.bind(r),off:r.off.bind(r),init:f,setInteractiveController:C,createPlayer:x,removeAll:R,getActivePlayer:function(){return s}})}var yn=require("@vkontakte/videoplayer-shared");var Me=class{constructor({player:t,container:e,branches:n,selectBranches:r,interactiveEvents:s,globalEventEmitter:l,ignoreContainerEvent:o,permanentTextControls:c,disabledControls$:h,onRemove:C}){O(this,"hide",()=>{setTimeout(()=>{var t,e;this.gameState!==D.end&&(It(this.container.container.events)&&this.gameState===D.afterInteractive||this.selectBranches.state.isExpect||(this.gameState!==D.interactive&&((e=(t=this.container).hide)==null||e.call(t)),this.globalEventEmitter.emit(y.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})))})});O(this,"show",()=>{var t,e,n,r;if(this.gameState===D.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())(r=(n=this.container).show)==null||r.call(n),this.globalEventEmitter.emit(y.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!0,isFirst:!1});else{let l=ln({fn:this.selectBranches.onControlEvent,type:0},{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(y.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})},onEvent:(o,c)=>{this.isSelectedControlEvent=!0,o!==!1&&(this.removeView(),this.globalEventEmitter.emit(y.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})),(this.gameState===D.end||this.gameState===D.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),c(),this.removeView(),this.globalEventEmitter.emit(y.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1}))},isEOV:()=>this.gameState===D.end});this.container.createView(l),this.globalEventEmitter.emit(y.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((e=(t=this.container).disable)==null||e.call(t))}});O(this,"onEndOfVideo",()=>{this.gameState=D.end,this.selectContainerEvent(!0)});O(this,"whilePlaying",()=>{var s,l;if(((s=this.player.experimental.element$.getValue())==null?void 0:s.readyState)<1||[D.destroyed,D.removed].includes(this.gameState)&&!this.isPermanentText)return;let e=this.player.getExactTime();if(cn(e,this.container.container))this.gameState!==D.beforeInteractive&&(this.gameState=D.beforeInteractive,this.onBeforeStartTime());else if(fi(e,this.container.container))this.gameState!==D.interactive&&(this.gameState=D.interactive,this.onStartTime());else if(this.gameState!==D.afterInteractive){let o=this.gameState;this.gameState=D.afterInteractive,o===D.interactive&&this.onEndTime()}else this.gameState!==D.destroyed&&!this.isPermanentText&&this.removeView();let n=fi(e,this.container.container),r=this.container.container.startTime?[this.container.container.startTime,(l=this.container.container.endTime)!=null?l:1/0]:[];this.globalEventEmitter.emit(y.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:r,currentTime:e,isInteractiveTime:n})});this.container=e,this.branches=n,this.selectBranches=r,this.subscription=new yn.Subscription,this.player=t,this.interactiveEvents=s,this.ignoreContainerEvent=o,this.isPermanentText=c&&_e(e.container.controls),this.disabledControls$=h,this.onRemove=C,this.globalEventEmitter=l,this.gameState=D.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(t=>{var e,n,r,s;t?(n=(e=this.container).disable)==null||n.call(e):(s=(r=this.container).enable)==null||s.call(r)}))}selectContainerEvent(t=!1){this.interactiveEvents.containersEventsCallState.setCalled({timestamp:t?1/0:this.container.container.endTime,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,this.ignoreContainerEvent()||this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:t}),!t&&this.interactiveEvents.exec(this.container.container.endTime))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let t=It(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!t)&&this.removeView()}onBeforeStartTime(){var t,e;(e=(t=this.container).hide)==null||e.call(t),this.globalEventEmitter.emit(y.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=D.beforeInteractive}removeView(){var t;this.container.removeView(),this.globalEventEmitter.emit(y.interactives,{subjectId:this.container.container.id,subjectName:"container",type:_.containerRemoved,visibility:!1}),this.gameState=D.removed,(t=this.onRemove)==null||t.call(this)}destroy(){var t;this.reset(),this.removeView(),this.gameState=D.destroyed,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(t=this.container.container.endTime)!=null?t:1/0,id:this.container.container.id})}};function gn(){let i={};function t(){for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&delete i[o];return!0}function e(o){let c={};for(let h in i)+h<=o&&(c[h]=i[h]);return c}function n(o){let c={};for(let h in i)+h>=o&&(c[h]=i[h]);return c}function r({timestamp:o,priority:c,initiator:h}){var C;if(ri(o)){let E=(C=i[o])!=null?C:null;if(E&&zt(c,!0)){let I={},w=E[c];if(w&&(I=p(p({},I),w)),I=Et(I)?null:I,I&&zt(h,!0)){let x=I[h];return x!=null?x:null}return I}return E}return null}function s({timestamp:o,priority:c,initiator:h}){if(ri(o))if(i[o]){if(zt(c,!0))if(i[o][c]){if(zt(h,!0))if(i[o][c][h]){if(delete i[o][c][h],!Et(i[o][c]))return!0}else return!1;if(delete i[o][c],!Et(i[o]))return!0}else return!1;return delete i[o]}else return!1}function l(E){var I=E,{timestamp:o,priority:c,initiator:h}=I,C=X(I,["timestamp","priority","initiator"]);var w,x,R;(x=(w=i[o])==null?void 0:w[c])!=null&&x[h]?i[o][c][h].push(p({},C)):(R=i[o])!=null&&R[c]?i[o][c]=b(p({},i[o][c]),{[h]:[p({},C)]}):i[o]?i[o]=b(p({},i[o]),{[c]:{[h]:[p({},C)]}}):i[o]={[c]:{[h]:[p({},C)]}}}return{map:i,remove:s,add:l,removeAll:t,get:r,getLte:e,getGte:n}}var fs=[j.expect,j.setNextBranch],ms=1/0;function bi(i){let t=i,e,n=ys(),r=new gn,s,l=()=>{I(),f()},o=d=>{r.add.call(void 0,d),x()},c=(d=[])=>{for(let g of d)if(g.action(),fs.includes(g.actionType))break},h=(d=1/0)=>{var M,k,F;let g=Ae((M=r.get({timestamp:d,priority:"control"}))!=null?M:{}),T=Ae((k=r.get({timestamp:d,priority:"container"}))!=null?k:{}),u=Ae((F=r.get({timestamp:d,priority:"chapter"}))!=null?F:{});return[...g,...T,...u]},C=d=>{n.isReady(d)&&c(h(d))},E=()=>{var d;c([...Ae((d=r.get({timestamp:1/0,priority:"chapter"}))!=null?d:{})])},I=()=>{e&&(s==null||s.unsubscribe(),e=void 0)},w=d=>{},x=()=>{e||(e=()=>setTimeout(()=>{C(1/0)}),s=t.events.ended$.subscribe(e))},R=d=>{I(),t=d},P=d=>{d.priority==="container"&&n.resetCalled(d.timestamp),r.remove(d)},f=()=>{n.release(),r.removeAll()};return{setPlayer:R,add:o,remove:P,exec:C,execEndOfVideo:E,listen:x,unlisten:I,release:l,containersEventsCallState:n,getPreparedToExecActions:h}}function ys(){let i=new Map;return{setCalled:({timestamp:l,id:o})=>{let c=i.get(l);c&&c[o]!==void 0&&(c[o]=!0)},setData:(l=[])=>{var o,c;for(let h of l){let C=(o=h.endTime)!=null?o:ms,E=(c=i.get(C))!=null?c:{};i.set(C,b(p({},E),{[h.id]:!1}))}},resetCalled:l=>{let o=i.get(l);if(o)for(let c in o)o[c]=!1},isReady:l=>{let o=i.get(l);return o?!Object.values(o).some(c=>!c):!0},release:()=>i.clear()}}function Ae(i){return Object.values(i).flat().sort(t=>t.actionType===j.expect?-1:1)}var vn=(i,t)=>{let{height:e,width:n}=t.info.intrinsicVideoSize$.getValue()||{};if(!(e&&n))return{videoContentHeight:0,videoContentWidth:0};let{clientHeight:r,clientWidth:s}=t.experimental.element$.value||{};if(!(r&&s))return{videoContentHeight:0,videoContentWidth:0};let l=e/n,o=r/s,c,h;return o>l?(h=s,c=s*l):o<l?(h=r/l,c=r):(h=s,c=r),{videoContentWidth:h,videoContentHeight:c}};var gs=250;function bn(i){let t=()=>{},e=new ResizeObserver(o=>{s(o),t=s.bind(null,o)});function n(o){let{parentElement:c,player:h}=i();if(c&&h){let{videoContentWidth:C,videoContentHeight:E}=vn(c,h);c.style.setProperty("--interactive-content-width",`${C}px`),c.style.setProperty("--interactive-content-height",`${E}px`),c.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),c.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function r(){let{parentElement:o}=i();o.removeAttribute("style")}let s=Ce(o=>{let{fns:c=[]}=i();n(o);for(let h of c)h()},gs);function l(){t=void 0,e.disconnect(),r()}return{resizeObserver:e,calc:()=>{t()},release:l}}var Jt=class{constructor(){this.map={}}push(t,e){t in this.map?this.map[t].push(e):this.map[t]=[e]}get(t){let e=this.map[t];return e?e.slice():null}getAll(){let t=[];for(let e in this.map)t.push(...this.map[e]);return t}remove(t,e){t in this.map&&(this.map[t]=this.map[t].filter(n=>n!==e),this.map[t].length===0&&delete this.map[t])}clear(){this.map={}}size(){return Object.keys(this.map).length}keys(){return Object.keys(this.map)}};var vs=i=>Math.floor(Math.random()*i),Cn=i=>{let t=i.length,e=1/0,n=null;for(;t--;)i[t].weight<e&&(e=i[t].weight,n=i[t]);return n},En=i=>{let t=i.length,e=-1/0,n=null;for(;t--;)i[t].weight>e&&(e=i[t].weight,n=i[t]);return n};var In=i=>{let t=i.length,e=vs(t);return i[e]};var xn=i=>{var n,r;let t=0;for(let s=0;s<i.length;++s)t+=(n=i[s].weight)!=null?n:1;let e=Math.random()*t;t=0;for(let s=0;s<i.length-1;++s)if(t+=(r=i[s].weight)!=null?r:1,t>=e)return i[s];return i[i.length-1]};var Tn=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0});var Ci=(i,t=!1)=>b(p({},i),{args:t?p(p({},i.args),Tn):p(p({},Tn),i.args)}),Ei=({globalEventEmitter:i,player:t,interactiveEvents:e,removeControllers:n})=>{let r={isExpect:!1},s=()=>{r.isExpect&&(r.isExpect=!1)},l=({action:f,controlType:d,controlId:g,containerId:T,branches:u=[],onEvent:M,isEOV:k=()=>!1,isDisabled:F=()=>!1})=>{let A=Ci(f,k()),et={timestamp:1/0,priority:"control",initiator:g,actionType:A.type},J=F(),Q=i.emit.bind(i,y.interactives,{subjectId:g,subjectType:d,subjectName:"control",type:J?_.actionChoiceCanceled:_.actionChoice,actionType:f.type,payload:p({containerId:T},A.args)});if(J){Q();return}switch(A.type.trim().toLowerCase()){case j.setNextBranch.trim().toLowerCase():{let ut=u.find(K=>K.id===A.args.branchId);if(!ut)return;M(A.args.isDetachContainer,I.bind(null,{subjectId:g,subjectName:"control"})),Q(),A.args.shouldOpenNow?x({subjectId:g,subjectName:"control",subjectType:d,action:A,payload:{chapterId:ut.chapterId,autoSelect:!1}}):(e.add(b(p({},et),{action:x.bind(null,{subjectId:g,subjectName:"control",subjectType:d,action:A,payload:{chapterId:ut.chapterId,autoSelect:!1}})})),n==null||n());return}case j.continuePlayback.trim().toLowerCase():{M(A.args.isDetachContainer,I.bind(null,{subjectId:g,subjectName:"control"})),Q(),A.args.shouldOpenNow?w({subjectId:g,subjectName:"control",subjectType:d,action:f}):e.add(b(p({},et),{action:w.bind(null,{subjectId:g,subjectName:"control",subjectType:d,action:f})}));return}case j.openURI.trim().toLowerCase():{M(A.args.isDetachContainer,I.bind(null,{subjectId:g,subjectName:"control"})),Q(),A.args.shouldOpenNow?P({subjectId:g,subjectName:"control",subjectType:d,action:A,payload:{URI:f.args.uri}}):(e.add(b(p({},et),{action:P.bind(null,{subjectId:g,subjectName:"control",subjectType:d,action:A,payload:{URI:f.args.uri}})})),n==null||n());return}default:console.error("Unexpected control event"),i.emit(y.errors,new S(S.Severity.RECOVERABLE,S.Category.INTERACTIVES,{message:"Unexpected control event"}));return}},o=({action:f,container:{id:d,endTime:g},branches:T=[],isEOV:u=!1,autoSelected:M=!1})=>{let k=Ci(f,u),F={timestamp:!k.args.shouldOpenNow||u?1/0:g,priority:"container",initiator:d,actionType:k.type},A=i.emit.bind(i,y.interactives,{subjectId:d,subjectName:"container",type:_.actionChoice,actionType:k.type,payload:k.args});switch(k.type.trim().toLowerCase()){case j.setNextBranch.trim().toLowerCase():{let et=T.find(J=>J.id===k.args.branchId);if(!et)return;A(),e.add(b(p({},F),{action:x.bind(null,{subjectId:d,subjectName:"container",action:k,payload:{chapterId:et.chapterId,autoSelect:M}})})),n==null||n();return}case j.setMaxWeightBranch.trim().toLowerCase():return;case j.setMinWeightBranch.trim().toLowerCase():return;case j.setRandomBranch.trim().toLowerCase():return;case j.setWeightlessRandomBranch.trim().toLowerCase():return;case j.continuePlayback.trim().toLowerCase():{A(),e.add(b(p({},F),{action:w.bind(null,{subjectId:d,subjectName:"container",action:k})}));return}case j.openURI.trim().toLowerCase():{A(),e.add(b(p({},F),{action:P.bind(null,{subjectId:d,subjectName:"container",action:k,payload:{URI:f.args.uri}})})),n==null||n();return}default:console.error("Unexpected container event"),i.emit(y.errors,new S(S.Severity.RECOVERABLE,S.Category.INTERACTIVES,{message:"Unexpected container event"}));return}};function c({container:f,branches:d,isEOV:g=!1}){let T=mi(f.events);if(T){let u=Ci(T.action,g);i.emit(y.interactives,{subjectId:f.id,subjectName:"container",type:_.actionChoice,actionType:u.type,payload:u.args}),e.add({timestamp:g?1/0:f.endTime,priority:"container",initiator:f.id,actionType:j.expect,action:E.bind(null,{subjectId:f.id,subjectName:"container"})}),r.isExpect=!0}else for(let u of f.events)o({action:u.action,container:f,branches:d,isEOV:g})}let h=({chapterId:f,action:d,branches:g=[]})=>{let T=i.emit.bind(i,y.interactives,{subjectId:f,subjectName:"chapter",type:_.actionChoice,actionType:d.type,payload:d.args});switch(d.type.trim().toLowerCase()){case j.setNextBranch.trim().toLowerCase():{let u=g.find(M=>M.id===d.args.branchId);return u!=null&&u.chapterId?(T(),x.bind(null,{subjectId:f,subjectName:"chapter",action:d,payload:{chapterId:u.chapterId,autoSelect:!0}})):void 0}case j.setWeightlessRandomBranch.trim().toLowerCase():{let u=In(g);return u!=null&&u.chapterId?(T(),x.bind(null,{subjectId:f,subjectName:"chapter",action:d,payload:{chapterId:u.chapterId,autoSelect:!0}})):void 0}case j.setRandomBranch.trim().toLowerCase():{let u=xn(g);return u!=null&&u.chapterId?(T(),x.bind(null,{subjectId:f,subjectName:"chapter",action:d,payload:{chapterId:u.chapterId,autoSelect:!0}})):void 0}case j.setMaxWeightBranch.trim().toLowerCase():{let u=En(g);return u!=null&&u.chapterId?(T(),x.bind(null,{subjectId:f,subjectName:"chapter",action:d,payload:{chapterId:u.chapterId,autoSelect:!0}})):void 0}case j.setMinWeightBranch.trim().toLowerCase():{let u=Cn(g);return u!=null&&u.chapterId?(T(),x.bind(null,{subjectId:f,subjectName:"chapter",action:d,payload:{chapterId:u.chapterId,autoSelect:!0}})):void 0}case j.continuePlayback.trim().toLowerCase():return T(),w.bind(null,{subjectId:f,subjectName:"chapter",action:d});case j.openURI.trim().toLowerCase():return T(),P.bind(null,{subjectId:f,subjectName:"chapter",action:d,payload:{URI:d.args.uri}});default:console.error("Unexpected chapter event"),i.emit(y.errors,new S(S.Severity.RECOVERABLE,S.Category.INTERACTIVES,{message:"Unexpected chapter event"}));return}};function C(f){let d=mi(f.events);if(d){if(nt(f))return;i.emit(y.interactives,{subjectId:f.id,subjectName:"chapter",type:_.actionChoice,actionType:d.action.type,payload:d.action.args}),e.add({timestamp:1/0,priority:"chapter",initiator:f.id,actionType:j.expect,action:E.bind(null,{subjectId:f.id,subjectName:"chapter"})})}else f.events.forEach(g=>{let T=h({chapterId:f.id,action:g.action,branches:f.branches});T&&e.add({timestamp:1/0,priority:"chapter",initiator:f.id,actionType:g.action.type,action:T})})}let E=({subjectId:f,subjectName:d,action:g})=>{var T;t.pause(),i.emit(y.interactives,{subjectId:f,subjectName:d,type:_.actionExecution,actionType:(T=g==null?void 0:g.type)!=null?T:j.expect})},I=({subjectId:f,subjectName:d})=>{t.info.isEnded$.getValue()?e.execEndOfVideo():t.play(),i.emit(y.interactives,{subjectId:f,subjectName:d,type:_.actionExecution,actionType:"after-expect"})},w=({subjectId:f,subjectName:d,subjectType:g,action:T})=>{i.emit(y.interactives,{subjectId:f,subjectName:d,subjectType:g,type:_.actionExecution,actionType:T.type})},x=({subjectId:f,subjectName:d,subjectType:g,action:T,payload:u})=>{u.behaviour="change-chapter",i.emit(y.interactives,{subjectId:f,subjectName:d,subjectType:g,type:_.actionExecution,actionType:T.type,payload:u})},R=({subjectId:f,subjectName:d,subjectType:g,action:T,payload:u})=>{u.behaviour="change-manifest",i.emit(y.interactives,{subjectId:f,subjectName:d,subjectType:g,type:_.actionExecution,actionType:T.type,payload:u})},P=({subjectId:f,subjectName:d,subjectType:g,action:T,payload:u})=>{if(!u.URI)return;let M=window.open(u.URI,"_blank","noopener,noreferrer");M&&(M.opener=null),i.emit(y.interactives,{subjectId:f,subjectName:d,subjectType:g,type:_.actionExecution,actionType:T.type})};return{onControlEvent:l,onContainerEvent:o,onChapterEvent:h,onExpectEvent:E,expectEventHandler:I,setManifestChapterEvents:C,setManifestContainerEvents:c,stopExpect:s,state:r}};var mt=require("@vkontakte/videoplayer-shared");var Le=(i,t)=>{let e={};return i.map(n=>{if(!e[n]){let r=t.chapters.find(l=>l.id===n);if(!r)return null;let s=t.media.videos.find(l=>r.videoId===l.id);if(!s)return null;e[n]=Ii(s)}return e[n]}).filter(Boolean)},Sn=i=>{for(let t of i.variants)if(wn(t)&&"payload"in t)return t.payload.id},wn=i=>i.type==="custom"&&"payload"in i&&i.payload.type==="vk",Ii=i=>{let t=Sn(i);if(!t)return null;let e=t.split("_").pop();return e?parseInt(e,10):null},Vn=(i,t)=>{for(let e of i.media.videos)if(t===Ii(e)){for(let n of i.chapters)if(n.videoId===e.id)return n.id;return}},xi=(i,t)=>i.reduce((e,n)=>{let r=Vn(t,n);return r?[...e,r]:e},[]);var at,Tt,St,tt,Ne,ot,ct,it,wt,$t,Ot,te=class{constructor({globalEventEmitter:t,videoId:e,interactiveController:n,historyApi:r,settings:s}){this.state={history$:new mt.ValueSubject([]),hasPrevChapter$:new mt.ValueSubject(!1),prevChapter$:new mt.ValueSubject(null),isInitialChapter$:new mt.ValueSubject(!1),isGoBackLimited$:new mt.ValueSubject(!1)};v(this,at,null);v(this,Tt,void 0);v(this,St,!1);v(this,tt,null);v(this,Ne,null);v(this,ot,null);v(this,ct,null);v(this,it,null);v(this,wt,new mt.Subscription);v(this,$t,!1);v(this,Ot,0);var l,o,c;m(this,ot,e),m(this,it,t),m(this,ct,n),m(this,at,r),m(this,Tt,s),(l=this.state)!=null&&l.history$&&a(this,wt)&&((c=a(this,wt))==null||c.add((o=this.state)==null?void 0:o.history$.subscribe(h=>{var C,E,I,w,x,R;(C=this.state)==null||C.prevChapter$.next(h.at(-2)||null),(E=this.state)==null||E.hasPrevChapter$.next(h.length>1),(x=this.state)==null||x.isInitialChapter$.next(this.getInitialChapterId()===((w=(I=a(this,tt))==null?void 0:I.metadata)==null?void 0:w.initChapterId)),(R=this.state)==null||R.isGoBackLimited$.next(a(this,Ot)===a(this,Tt).maxLength-1)})))}setManifest(t){return V(this,null,function*(){!a(this,ct)||!a(this,it)||(m(this,tt,t),yield this.getProjectHistory(),yield a(this,ct).setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),a(this,St)||(m(this,St,!0),a(this,it).emit(y.historyInited,{initChapterId:this.getInitialChapterId()})))})}get inited(){return a(this,St)}updateHistory(t,e=!0){return V(this,null,function*(){var o,c;if(!a(this,tt))return;a(this,$t)?(m(this,$t,!1),$i(this,Ot)._++):m(this,Ot,0);let n=a(this,tt),r=t.length-a(this,Tt).maxLength,s=r>0?t.slice(r):t,l=Le(s,n);if(m(this,Ne,l),(o=this==null?void 0:this.state)==null||o.history$.next(s),!(!e||!a(this,at)||!a(this,ot)))try{yield a(this,at).save(a(this,ot),l)}catch(h){(c=a(this,it))==null||c.emit(y.errors,new S(S.Severity.RECOVERABLE,S.Category.HISTORY,"Unable to save interactive history"))}})}goBack(){return V(this,null,function*(){var n;if(!this.state||!a(this,ct))return(n=a(this,it))==null?void 0:n.emit(y.errors,new S(S.Severity.RECOVERABLE,S.Category.HISTORY,"Cannot go back because HistoryController has not been initialized"));m(this,$t,!0);let t=this.state.history$.getValue().slice(0,-1),e=t.pop();this.state.history$.next(t),yield a(this,ct).setChapter({chapterId:e})})}getProjectHistory(){return V(this,null,function*(){var r,s;if(!a(this,tt)||!a(this,ot))return;let t=a(this,tt),e=[this.getInitialVideoId()];if(a(this,at))try{let l=yield a(this,at).get(a(this,ot));l.length&&(e=l)}catch(l){(r=a(this,it))==null||r.emit(y.errors,new S(S.Severity.RECOVERABLE,S.Category.HISTORY,"Error while trying to fetch data"))}let n=xi(e,t);(s=this==null?void 0:this.state)==null||s.history$.next(n)})}getInitialChapterId(){var e,n;let t=(e=this.state)==null?void 0:e.history$.getValue();return(t==null?void 0:t.at(-1))||a(this,Tt).initChapterId||((n=a(this,tt))==null?void 0:n.metadata.initChapterId)}getInitialVideoId(){if(a(this,tt)){let t=this.getInitialChapterId();return Le([t],a(this,tt)).pop()}return null}destroy(){var t,e;this.state=null,m(this,ot,null),m(this,at,null),m(this,ct,null),(t=a(this,wt))==null||t.unsubscribe(),m(this,wt,null),m(this,St,!1),(e=a(this,it))==null||e.emit(y.historyDestroyed),m(this,it,null)}};at=new WeakMap,Tt=new WeakMap,St=new WeakMap,tt=new WeakMap,Ne=new WeakMap,ot=new WeakMap,ct=new WeakMap,it=new WeakMap,wt=new WeakMap,$t=new WeakMap,Ot=new WeakMap;var je,Rn,ee,Pe,_n,lt=class lt{constructor(t,e,n,r){var s;this.target=t,this.type=e,this.listener=n,this.options=$(s=lt,je,Rn).call(s,t,r),this.target.addEventListener(e,n,this.options)}unlisten(){this.target.removeEventListener(this.type,this.listener,this.options),this.target=null,this.listener=null,this.options=!1}};je=new WeakSet,Rn=function(t,e){var n;if(e===void 0)return!1;if(typeof e=="boolean")return e;{let r=new Set(["passive","capture"]),s=Object.keys(e).filter(o=>!r.has(o));return s.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+s.join(",")),$(n=lt,Pe,_n).call(n,t)?e:e.capture||!1}},ee=new WeakMap,Pe=new WeakSet,_n=function(t){let e=a(lt,ee);if(e===void 0){e=!1;try{let n={},r={get:()=>(e=!0,!1)};Object.defineProperty(n,"passive",r),Object.defineProperty(n,"capture",r);let s=()=>{};t.addEventListener("test",s,n),t.removeEventListener("test",s,n)}catch(n){e=!1}m(lt,ee,e)}return e||!1},v(lt,je),v(lt,Pe),v(lt,ee,void 0);var ke=lt;var $e=class{constructor(){this.bindingMap=new Jt}release(){this.removeAll(),this.bindingMap=null}listen(t,e,n,r){if(!this.bindingMap)return;let s=new ke(t,e,n,r);this.bindingMap.push(e,s)}listenOnce(t,e,n,r){let s=l=>{this.unlisten(t,e,s),n(l)};this.listen(t,e,s,r)}unlisten(t,e,n){if(!this.bindingMap)return;let r=this.bindingMap.get(e)||[];for(let s of r)s.target===t&&(n===s.listener||!n)&&(s.unlisten(),this.bindingMap.remove(e,s))}removeAll(){if(!this.bindingMap)return;let t=this.bindingMap.getAll();for(let e of t)e.unlisten();this.bindingMap.clear()}};var Oe=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var t;(t=this.rootElement.getContext("2d"))==null||t.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var r;let t=(r=this.rootElement.getContext("2d"))==null?void 0:r.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!t)return!1;let e=t.data,n=e.length;for(let s=3;s<n;s+=40)if(e[s]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(t){this.canvasImgSrc=t}draw(){var t;this.canvasImgSrc&&((t=this.rootElement.getContext("2d"))==null||t.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(t,e=!1){return V(this,null,function*(){let n=t.width+t.height;if(this._prevSizeId===n)return;let r;e&&(r=yield this.save()),this.rootElement.width=t.width,this.rootElement.height=t.height,e&&r&&this.restore(r),this._prevSizeId=n})}save(){return V(this,null,function*(){let t=this.rootElement.toDataURL("image/jpeg",1),e=new Image;return e.crossOrigin="anonymous",e.src=t,yield e.decode(),e})}restore(t){var e;this.rootElement&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(t,0,0,this.rootElement.width,this.rootElement.height))}};var Be=class{constructor({parentElement:t,endOffsetMs:e=250,onError:n}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=t=>{let e=t!=null?t:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(e);if(this.isContainerTime(e))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)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 to=Object.create;var Ze=Object.defineProperty,ro=Object.defineProperties,io=Object.getOwnPropertyDescriptor,no=Object.getOwnPropertyDescriptors,so=Object.getOwnPropertyNames,Ct=Object.getOwnPropertySymbols,ao=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty,Li=Object.prototype.propertyIsEnumerable;var vr=(t,e,r)=>e in t?Ze(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,d=(t,e)=>{for(var r in e||(e={}))gr.call(e,r)&&vr(t,r,e[r]);if(Ct)for(var r of Ct(e))Li.call(e,r)&&vr(t,r,e[r]);return t},x=(t,e)=>ro(t,no(e));var Y=(t,e)=>{var r={};for(var i in t)gr.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&Ct)for(var i of Ct(t))e.indexOf(i)<0&&Li.call(t,i)&&(r[i]=t[i]);return r};var p=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),oo=(t,e)=>{for(var r in e)Ze(t,r,{get:e[r],enumerable:!0})},ji=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of so(e))!gr.call(t,n)&&n!==r&&Ze(t,n,{get:()=>e[n],enumerable:!(i=io(e,n))||i.enumerable});return t};var Ni=(t,e,r)=>(r=t!=null?to(ao(t)):{},ji(e||!t||!t.__esModule?Ze(r,"default",{value:t,enumerable:!0}):r,t)),co=t=>ji(Ze({},"__esModule",{value:!0}),t);var F=(t,e,r)=>(vr(t,typeof e!="symbol"?e+"":e,r),r),br=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var a=(t,e,r)=>(br(t,e,"read from private field"),r?r.call(t):e.get(t)),C=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},g=(t,e,r,i)=>(br(t,e,"write to private field"),i?i.call(t,r):e.set(t,r),r);var Pi=(t,e,r,i)=>({set _(n){g(t,e,n,r)},get _(){return a(t,e,i)}}),k=(t,e,r)=>(br(t,e,"access private method"),r);var A=(t,e,r)=>new Promise((i,n)=>{var s=c=>{try{o(r.next(c))}catch(h){n(h)}},l=c=>{try{o(r.throw(c))}catch(h){n(h)}},o=c=>c.done?i(c.value):Promise.resolve(c.value).then(s,l);o((r=r.apply(t,e)).next())});var oe=p((Sn,Tn)=>{"use strict";var Wt=function(t){return t&&t.Math==Math&&t};Tn.exports=Wt(typeof globalThis=="object"&&globalThis)||Wt(typeof window=="object"&&window)||Wt(typeof self=="object"&&self)||Wt(typeof global=="object"&&global)||function(){return this}()||Sn||Function("return this")()});var ge=p((qd,wn)=>{"use strict";wn.exports=function(t){try{return!!t()}catch(e){return!0}}});var ht=p((Dd,_n)=>{"use strict";var No=ge();_n.exports=!No(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")})});var On=p((Hd,Mn)=>{"use strict";var Po=ht(),An=Function.prototype,Rn=An.apply,Vn=An.call;Mn.exports=typeof Reflect=="object"&&Reflect.apply||(Po?Vn.bind(Rn):function(){return Vn.apply(Rn,arguments)})});var Ve=p((Gd,Nn)=>{"use strict";var Ln=ht(),jn=Function.prototype,Dr=jn.call,ko=Ln&&jn.bind.bind(Dr,Dr);Nn.exports=Ln?ko:function(t){return function(){return Dr.apply(t,arguments)}}});var Hr=p((Ud,kn)=>{"use strict";var Pn=Ve(),$o=Pn({}.toString),Fo=Pn("".slice);kn.exports=function(t){return Fo($o(t),8,-1)}});var Gr=p((zd,$n)=>{"use strict";var Bo=Hr(),qo=Ve();$n.exports=function(t){if(Bo(t)==="Function")return qo(t)}});var zr=p((Wd,Fn)=>{"use strict";var Ur=typeof document=="object"&&document.all,Do=typeof Ur=="undefined"&&Ur!==void 0;Fn.exports={all:Ur,IS_HTMLDDA:Do}});var be=p((Kd,qn)=>{"use strict";var Bn=zr(),Ho=Bn.all;qn.exports=Bn.IS_HTMLDDA?function(t){return typeof t=="function"||t===Ho}:function(t){return typeof t=="function"}});var He=p((Qd,Dn)=>{"use strict";var Go=ge();Dn.exports=!Go(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7})});var Qt=p((Yd,Hn)=>{"use strict";var Uo=ht(),Kt=Function.prototype.call;Hn.exports=Uo?Kt.bind(Kt):function(){return Kt.apply(Kt,arguments)}});var Wn=p(zn=>{"use strict";var Gn={}.propertyIsEnumerable,Un=Object.getOwnPropertyDescriptor,zo=Un&&!Gn.call({1:2},1);zn.f=zo?function(e){var r=Un(this,e);return!!r&&r.enumerable}:Gn});var Wr=p((Zd,Kn)=>{"use strict";Kn.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}});var Yn=p((Jd,Qn)=>{"use strict";var Wo=Ve(),Ko=ge(),Qo=Hr(),Kr=Object,Yo=Wo("".split);Qn.exports=Ko(function(){return!Kr("z").propertyIsEnumerable(0)})?function(t){return Qo(t)=="String"?Yo(t,""):Kr(t)}:Kr});var Qr=p((ep,Xn)=>{"use strict";Xn.exports=function(t){return t==null}});var Yr=p((tp,Zn)=>{"use strict";var Xo=Qr(),Zo=TypeError;Zn.exports=function(t){if(Xo(t))throw Zo("Can't call method on "+t);return t}});var es=p((rp,Jn)=>{"use strict";var Jo=Yn(),ec=Yr();Jn.exports=function(t){return Jo(ec(t))}});var ut=p((ip,is)=>{"use strict";var ts=be(),rs=zr(),tc=rs.all;is.exports=rs.IS_HTMLDDA?function(t){return typeof t=="object"?t!==null:ts(t)||t===tc}:function(t){return typeof t=="object"?t!==null:ts(t)}});var Xr=p((np,ns)=>{"use strict";ns.exports={}});var ei=p((sp,as)=>{"use strict";var Zr=Xr(),Jr=oe(),rc=be(),ss=function(t){return rc(t)?t:void 0};as.exports=function(t,e){return arguments.length<2?ss(Zr[t])||ss(Jr[t]):Zr[t]&&Zr[t][e]||Jr[t]&&Jr[t][e]}});var cs=p((ap,os)=>{"use strict";var ic=Ve();os.exports=ic({}.isPrototypeOf)});var hs=p((op,ls)=>{"use strict";ls.exports=typeof navigator!="undefined"&&String(navigator.userAgent)||""});var vs=p((cp,ys)=>{"use strict";var ms=oe(),ti=hs(),us=ms.process,ds=ms.Deno,ps=us&&us.versions||ds&&ds.version,fs=ps&&ps.v8,ie,Yt;fs&&(ie=fs.split("."),Yt=ie[0]>0&&ie[0]<4?1:+(ie[0]+ie[1]));!Yt&&ti&&(ie=ti.match(/Edge\/(\d+)/),(!ie||ie[1]>=74)&&(ie=ti.match(/Chrome\/(\d+)/),ie&&(Yt=+ie[1])));ys.exports=Yt});var ri=p((lp,bs)=>{"use strict";var gs=vs(),nc=ge(),sc=oe(),ac=sc.String;bs.exports=!!Object.getOwnPropertySymbols&&!nc(function(){var t=Symbol();return!ac(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&gs&&gs<41})});var ii=p((hp,Es)=>{"use strict";var oc=ri();Es.exports=oc&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var ni=p((up,Cs)=>{"use strict";var cc=ei(),lc=be(),hc=cs(),uc=ii(),dc=Object;Cs.exports=uc?function(t){return typeof t=="symbol"}:function(t){var e=cc("Symbol");return lc(e)&&hc(e.prototype,dc(t))}});var Is=p((dp,xs)=>{"use strict";var pc=String;xs.exports=function(t){try{return pc(t)}catch(e){return"Object"}}});var si=p((pp,Ss)=>{"use strict";var fc=be(),mc=Is(),yc=TypeError;Ss.exports=function(t){if(fc(t))return t;throw yc(mc(t)+" is not a function")}});var ws=p((fp,Ts)=>{"use strict";var vc=si(),gc=Qr();Ts.exports=function(t,e){var r=t[e];return gc(r)?void 0:vc(r)}});var Rs=p((mp,_s)=>{"use strict";var ai=Qt(),oi=be(),ci=ut(),bc=TypeError;_s.exports=function(t,e){var r,i;if(e==="string"&&oi(r=t.toString)&&!ci(i=ai(r,t))||oi(r=t.valueOf)&&!ci(i=ai(r,t))||e!=="string"&&oi(r=t.toString)&&!ci(i=ai(r,t)))return i;throw bc("Can't convert object to primitive value")}});var As=p((yp,Vs)=>{"use strict";Vs.exports=!0});var Ls=p((vp,Os)=>{"use strict";var Ms=oe(),Ec=Object.defineProperty;Os.exports=function(t,e){try{Ec(Ms,t,{value:e,configurable:!0,writable:!0})}catch(r){Ms[t]=e}return e}});var Ps=p((gp,Ns)=>{"use strict";var Cc=oe(),xc=Ls(),js="__core-js_shared__",Ic=Cc[js]||xc(js,{});Ns.exports=Ic});var Fs=p((bp,$s)=>{"use strict";var Sc=As(),ks=Ps();($s.exports=function(t,e){return ks[t]||(ks[t]=e!==void 0?e:{})})("versions",[]).push({version:"3.31.0",mode:Sc?"pure":"global",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.0/LICENSE",source:"https://github.com/zloirock/core-js"})});var li=p((Ep,Bs)=>{"use strict";var Tc=Yr(),wc=Object;Bs.exports=function(t){return wc(Tc(t))}});var Xt=p((Cp,qs)=>{"use strict";var _c=Ve(),Rc=li(),Vc=_c({}.hasOwnProperty);qs.exports=Object.hasOwn||function(e,r){return Vc(Rc(e),r)}});var Hs=p((xp,Ds)=>{"use strict";var Ac=Ve(),Mc=0,Oc=Math.random(),Lc=Ac(1 .toString);Ds.exports=function(t){return"Symbol("+(t===void 0?"":t)+")_"+Lc(++Mc+Oc,36)}});var zs=p((Ip,Us)=>{"use strict";var jc=oe(),Nc=Fs(),Gs=Xt(),Pc=Hs(),kc=ri(),$c=ii(),Ge=jc.Symbol,hi=Nc("wks"),Fc=$c?Ge.for||Ge:Ge&&Ge.withoutSetter||Pc;Us.exports=function(t){return Gs(hi,t)||(hi[t]=kc&&Gs(Ge,t)?Ge[t]:Fc("Symbol."+t)),hi[t]}});var Ys=p((Sp,Qs)=>{"use strict";var Bc=Qt(),Ws=ut(),Ks=ni(),qc=ws(),Dc=Rs(),Hc=zs(),Gc=TypeError,Uc=Hc("toPrimitive");Qs.exports=function(t,e){if(!Ws(t)||Ks(t))return t;var r=qc(t,Uc),i;if(r){if(e===void 0&&(e="default"),i=Bc(r,t,e),!Ws(i)||Ks(i))return i;throw Gc("Can't convert object to primitive value")}return e===void 0&&(e="number"),Dc(t,e)}});var ui=p((Tp,Xs)=>{"use strict";var zc=Ys(),Wc=ni();Xs.exports=function(t){var e=zc(t,"string");return Wc(e)?e:e+""}});var ea=p((wp,Js)=>{"use strict";var Kc=oe(),Zs=ut(),di=Kc.document,Qc=Zs(di)&&Zs(di.createElement);Js.exports=function(t){return Qc?di.createElement(t):{}}});var pi=p((_p,ta)=>{"use strict";var Yc=He(),Xc=ge(),Zc=ea();ta.exports=!Yc&&!Xc(function(){return Object.defineProperty(Zc("div"),"a",{get:function(){return 7}}).a!=7})});var na=p(ia=>{"use strict";var Jc=He(),el=Qt(),tl=Wn(),rl=Wr(),il=es(),nl=ui(),sl=Xt(),al=pi(),ra=Object.getOwnPropertyDescriptor;ia.f=Jc?ra:function(e,r){if(e=il(e),r=nl(r),al)try{return ra(e,r)}catch(i){}if(sl(e,r))return rl(!el(tl.f,e,r),e[r])}});var aa=p((Vp,sa)=>{"use strict";var ol=ge(),cl=be(),ll=/#|\.prototype\./,dt=function(t,e){var r=ul[hl(t)];return r==pl?!0:r==dl?!1:cl(e)?ol(e):!!e},hl=dt.normalize=function(t){return String(t).replace(ll,".").toLowerCase()},ul=dt.data={},dl=dt.NATIVE="N",pl=dt.POLYFILL="P";sa.exports=dt});var la=p((Ap,ca)=>{"use strict";var oa=Gr(),fl=si(),ml=ht(),yl=oa(oa.bind);ca.exports=function(t,e){return fl(t),e===void 0?t:ml?yl(t,e):function(){return t.apply(e,arguments)}}});var ua=p((Mp,ha)=>{"use strict";var vl=He(),gl=ge();ha.exports=vl&&gl(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42})});var pa=p((Op,da)=>{"use strict";var bl=ut(),El=String,Cl=TypeError;da.exports=function(t){if(bl(t))return t;throw Cl(El(t)+" is not an object")}});var ya=p(ma=>{"use strict";var xl=He(),Il=pi(),Sl=ua(),Zt=pa(),fa=ui(),Tl=TypeError,fi=Object.defineProperty,wl=Object.getOwnPropertyDescriptor,mi="enumerable",yi="configurable",vi="writable";ma.f=xl?Sl?function(e,r,i){if(Zt(e),r=fa(r),Zt(i),typeof e=="function"&&r==="prototype"&&"value"in i&&vi in i&&!i[vi]){var n=wl(e,r);n&&n[vi]&&(e[r]=i.value,i={configurable:yi in i?i[yi]:n[yi],enumerable:mi in i?i[mi]:n[mi],writable:!1})}return fi(e,r,i)}:fi:function(e,r,i){if(Zt(e),r=fa(r),Zt(i),Il)try{return fi(e,r,i)}catch(n){}if("get"in i||"set"in i)throw Tl("Accessors not supported");return"value"in i&&(e[r]=i.value),e}});var ga=p((jp,va)=>{"use strict";var _l=He(),Rl=ya(),Vl=Wr();va.exports=_l?function(t,e,r){return Rl.f(t,e,Vl(1,r))}:function(t,e,r){return t[e]=r,t}});var Ca=p((Np,Ea)=>{"use strict";var Jt=oe(),Al=On(),Ml=Gr(),Ol=be(),Ll=na().f,jl=aa(),Ue=Xr(),Nl=la(),ze=ga(),ba=Xt(),Pl=function(t){var e=function(r,i,n){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,i)}return new t(r,i,n)}return Al(t,this,arguments)};return e.prototype=t.prototype,e};Ea.exports=function(t,e){var r=t.target,i=t.global,n=t.stat,s=t.proto,l=i?Jt:n?Jt[r]:(Jt[r]||{}).prototype,o=i?Ue:Ue[r]||ze(Ue,r,{})[r],c=o.prototype,h,m,S,v,I,T,V,_,f;for(v in e)h=jl(i?v:r+(n?".":"#")+v,t.forced),m=!h&&l&&ba(l,v),T=o[v],m&&(t.dontCallGetSet?(f=Ll(l,v),V=f&&f.value):V=l[v]),I=m&&V?V:e[v],!(m&&typeof T==typeof I)&&(t.bind&&m?_=Nl(I,Jt):t.wrap&&m?_=Pl(I):s&&Ol(I)?_=Ml(I):_=I,(t.sham||I&&I.sham||T&&T.sham)&&ze(_,"sham",!0),ze(o,v,_),s&&(S=r+"Prototype",ba(Ue,S)||ze(Ue,S,{}),ze(Ue[S],v,I),t.real&&c&&(h||!c[v])&&ze(c,v,I)))}});var Ia=p((Pp,xa)=>{"use strict";var kl=Math.ceil,$l=Math.floor;xa.exports=Math.trunc||function(e){var r=+e;return(r>0?$l:kl)(r)}});var gi=p((kp,Sa)=>{"use strict";var Fl=Ia();Sa.exports=function(t){var e=+t;return e!==e||e===0?0:Fl(e)}});var wa=p(($p,Ta)=>{"use strict";var Bl=gi(),ql=Math.min;Ta.exports=function(t){return t>0?ql(Bl(t),9007199254740991):0}});var Ra=p((Fp,_a)=>{"use strict";var Dl=wa();_a.exports=function(t){return Dl(t.length)}});var Aa=p((Bp,Va)=>{"use strict";Va.exports=function(){}});var Ma=p(()=>{"use strict";var Hl=Ca(),Gl=li(),Ul=Ra(),zl=gi(),Wl=Aa();Hl({target:"Array",proto:!0},{at:function(e){var r=Gl(this),i=Ul(r),n=zl(e),s=n>=0?n:i+n;return s<0||s>=i?void 0:r[s]}});Wl("at")});var La=p((Hp,Oa)=>{"use strict";var Kl=ei();Oa.exports=Kl});var Na=p((Gp,ja)=>{"use strict";Ma();var Ql=La();ja.exports=Ql("Array","at")});var ka=p((Up,Pa)=>{"use strict";var Yl=Na();Pa.exports=Yl});var Fa=p((zp,$a)=>{"use strict";var Xl=ka();$a.exports=Xl});var eh={};oo(eh,{CustomError:()=>R,EVENT_NAMES:()=>b,INTERACTIVE_CLICK_ACTIONS:()=>kt,Interactives:()=>yt,ManifestController:()=>Re,SDKInfo:()=>Jl,chapterIdsToVKVideoIds:()=>er,compareVersions:()=>ae,getChapterIdByVkVideoId:()=>Da,getVKVideoIdByMedia:()=>bi,getVideoRawIdByMedia:()=>Ba,graphEventTypes:()=>De,hasEndTemplate:()=>at,interactivesEventTypes:()=>M,isLastChapter:()=>se,isSupportedManifest:()=>nt,isVKVariantItem:()=>qa,utils:()=>Ja,vkVideoIdsToChapterIds:()=>Ei});module.exports=co(eh);var ki="1.0.14";function Er(t,e=1){let r="0",i="0",n="0";return t.length===4?(r="0x"+t[1]+t[1],i="0x"+t[2]+t[2],n="0x"+t[3]+t[3]):t.length===7&&(r="0x"+t[1]+t[2],i="0x"+t[3]+t[4],n="0x"+t[5]+t[6]),`rgba(${+r},${+i},${+n},${e})`}var G="SDK_NAME",lo="SDK_NAME-controls-container",xt=()=>document.querySelector(`.${lo}`),qi=.4,X={textColor:"#000",textSize:.4,textContent:"",roundCorners:0,borderWidth:0,borderColor:"#000",borderAlpha:1,backgroundColor:"#fff",backgroundAlpha:1,innerSizesDependOn:"self",angle:0},$i={top:"flex-start",bottom:"flex-end",center:"center"},Fi={start:"flex-start",end:"flex-end",center:"center"},Bi={start:"left",end:"right",center:"center"},It=({target:t,props:e})=>{var r,i,n,s,l,o;t.style.alignItems=(i=$i[(r=e==null?void 0:e.text)==null?void 0:r.gravityVertical])!=null?i:$i.center,t.style.justifyContent=(s=Fi[(n=e==null?void 0:e.text)==null?void 0:n.gravityHorizontal])!=null?s:Fi.center,t.style.textAlign=(o=Bi[(l=e==null?void 0:e.text)==null?void 0:l.alignment])!=null?o:Bi.start},St=({target:t,props:e,fallback:r,dependsOn:i})=>{var n,s,l,o,c,h;t.style.color=(s=(n=e==null?void 0:e.text)==null?void 0:n.color)!=null?s:r.textColor,t.style.fontSize=`calc(${i.height} * ${(o=(l=e==null?void 0:e.text)==null?void 0:l.size)!=null?o:r.textSize})`,t.textContent=(h=(c=e==null?void 0:e.text)==null?void 0:c.value)!=null?h:r.textContent},Tt=({target:t,props:e,fallback:r})=>{var i,n,s,l;t.style.backgroundColor=Er((n=(i=e==null?void 0:e.background)==null?void 0:i.color)!=null?n:r.backgroundColor,(l=(s=e==null?void 0:e.background)==null?void 0:s.alpha)!=null?l:r.backgroundAlpha)},wt=({target:t,props:e,fallback:r,dependsOn:i})=>{var n,s,l,o,c,h,m,S,v,I,T;t.style.border=`calc(${i.height} * ${(l=(s=(n=e==null?void 0:e.shape)==null?void 0:n.border)==null?void 0:s.width)!=null?l:r.borderWidth}) solid ${Er((h=(c=(o=e==null?void 0:e.shape)==null?void 0:o.border)==null?void 0:c.color)!=null?h:r.borderColor,(v=(S=(m=e==null?void 0:e.shape)==null?void 0:m.border)==null?void 0:S.alpha)!=null?v:r.borderAlpha)}`,t.style.borderRadius=`calc(${i.height} * ${(T=(I=e==null?void 0:e.shape)==null?void 0:I.roundCorners)!=null?T:r.roundCorners})`},ke=({target:t,layoutParams:e,fallback:r})=>{t.style.transform=`rotate(${-e.angle}rad)`};var Cr="int",$e={AREA:`${Cr}_area`,TEXT:`${Cr}_text`,BUTTON:`${Cr}_bttn`};var ve=class{constructor(e){this.control=e}createView(e){var n;let r=document.createElement("div");r.classList.add(`${G}-control-container-${this.control.id}`),e(r,this.control.layoutParams);let i=((n=this.control.layoutParams.innerSizesDependOn)!=null?n:X.innerSizesDependOn)==="self"?{height:r.style.height,width:r.style.width}:{height:"var(--interactive-content-height)",width:"var(--interactive-content-width)"};return{controlContainerEl:r,dependsOn:i}}setEvents(e,r){e&&this.control.events.forEach(i=>{switch(i.type.trim().toLowerCase()){case"onclick":e.addEventListener("click",s=>{s.stopPropagation(),r&&r({action:i.action,controlId:this.control.id,controlType:this.control.type})});break;default:break}})}getElement(){return document.querySelector(`.${G}-control-container-${this.control.id}`)}};var _t=t=>{if(t.type.trim().toLowerCase()==="area")return new xr(t)},xr=class extends ve{constructor(e){super(e)}createView({parent:e,layoutFn:r}){let{dependsOn:i,controlContainerEl:n}=super.createView(r),s=document.createElement("button");return s.classList.add(`${G}-${this.control.id}`),s.setAttribute("data-testid",$e.AREA),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.type="button",Tt({target:s,props:this.control.props,fallback:x(d({},X),{backgroundColor:"transparent"})}),wt({target:s,props:this.control.props,fallback:x(d({},X),{borderAlpha:0}),dependsOn:i}),ke({target:s,layoutParams:this.control.layoutParams,fallback:X}),n.append(s),e.append(n),this.controlEl=s,n}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}};var Rt=()=>{let t=document.createElement("span");return t.style.display="inline-block",t.style.whiteSpace="pre",t.style.overflow="hidden",t.style.textOverflow="ellipsis",t.style.maxWidth="100%",t.style.maxHeight="100%",t};var Vt=t=>{if(t.type.trim().toLowerCase()==="button")return new Ir(t)},Ir=class extends ve{constructor(e){super(e)}createView({parent:e,layoutFn:r}){let{dependsOn:i,controlContainerEl:n}=super.createView(r),s=document.createElement("button");s.type="button",s.classList.add(`${G}-${this.control.id}`),s.setAttribute("data-testid",$e.BUTTON),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.cursor="pointer",s.style.fontFamily="inherit";let l=Rt();return ke({target:s,layoutParams:this.control.layoutParams,fallback:X}),Tt({target:s,props:this.control.props,fallback:X}),wt({target:s,props:this.control.props,fallback:X,dependsOn:i}),It({target:s,props:this.control.props}),St({target:l,props:this.control.props,fallback:X,dependsOn:i}),s.append(l),n.append(s),e.append(n),this.controlEl=s,n}disable(){this.controlEl&&(this.controlEl.style.cursor="default")}enable(){this.controlEl&&(this.controlEl.style.cursor="pointer")}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}};var Di=t=>{if(t.type.trim().toLowerCase()==="text")return new Sr(t)},Sr=class extends ve{constructor(e){super(e)}createView({parent:e,layoutFn:r}){let{dependsOn:i,controlContainerEl:n}=super.createView(r),s=document.createElement("div");s.classList.add(`${G}-${this.control.id}`),s.setAttribute("data-testid",$e.TEXT),s.style.display="flex",s.style.width="100%",s.style.height="100%",s.style.fontFamily="inherit";let l=Rt();return ke({target:s,layoutParams:this.control.layoutParams,fallback:X}),It({target:s,props:this.control.props}),St({target:l,props:this.control.props,fallback:X,dependsOn:i}),s.append(l),n.append(s),e.append(n),this.controlEl=s,n}disable(){}enable(){}getElement(){return document.querySelector(`.${G}-${this.control.id}`)}};var Tr=class{constructor(e){this.layout=e}},Hi=t=>{if(t.type.trim().toLowerCase()==="relative")return new Je(t)},Je=class extends Tr{constructor(e){super(e)}setContainerLayout(e){e.style.position="relative"}setControlLayout(e,r){e.style.position="absolute",e.style.width=`calc(var(--interactive-content-width) * ${r.width})`,e.style.height=`calc(var(--interactive-content-height) * ${r.height})`,e.style.left=`calc(var(--interactive-content-width) * ${r.x} + ((var(--interactive-width) - var(--interactive-content-width)) / 2))`,e.style.top=`calc(var(--interactive-content-height) * ${r.y} + ((var(--interactive-height) - var(--interactive-content-height)) / 2))`}};var Fe,At,Mt,Gi,Be=class{constructor(e){C(this,Fe);C(this,Mt);this.container=e,this.factories=new Map,k(this,Fe,At).call(this)}addControlFactory(e,r){this.factories.set(e.trim().toLowerCase(),r),k(this,Fe,At).call(this)}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),k(this,Fe,At).call(this)}};Fe=new WeakSet,At=function(){this.controls=k(this,Mt,Gi).call(this)},Mt=new WeakSet,Gi=function(){var e;return(e=this.container.controls)==null?void 0:e.reduce((r,i)=>{let n=i.type.trim().toLowerCase(),s=this.factories.get(n);return s?[...r,s(i)]:[...r]},[])};var Ot=(t,e)=>{if(t.type.trim().toLowerCase()==="choice")return new wr(t,e)},wr=class extends Be{constructor(e,r){super(e),this.rootElement=r!=null?r:xt(),this.layout=new Je(this.container.layout),this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory("button",Vt),this.addControlFactory("text",Di),this.addControlFactory("area",_t)}createView(e){let r=document.createElement("div");return r.classList.add(`${G}-${this.container.id}`),this.layout.setContainerLayout(r),this.controls.forEach(i=>{let n=i.createView({parent:r,layoutFn:this.layout.setControlLayout});i.setEvents(n,e)}),this.rootElement.append(r),this.isRemoved=!1,r}hide(){let e=this.getElement();e&&(e.style.visibility="hidden")}show(){let e=this.getElement();e&&(e.style.visibility="visible")}enable(){let e=this.getElement();e&&(this.controls.forEach(r=>r.enable()),e.style.opacity=1,this.isDisabled=!1)}disable(){let e=this.getElement();e&&(this.controls.forEach(r=>r.disable()),e.style.opacity=qi,this.isDisabled=!0)}removeView(){var e;this.isRemoved||((e=this.getElement())==null||e.remove(),this.isRemoved=!0)}getElement(){return this.rootElement.querySelector(`.${G}-${this.container.id}`)}};var $=require("@vkontakte/videoplayer-shared");var Qi=require("@vkontakte/videoplayer-shared");function Lt(t,e){let r;return(...i)=>{clearTimeout(r),r=setTimeout(()=>t(...i),e)}}var et={Object:"Object",String:"String",Array:"Array",Number:"Number",Function:"Function",Boolean:"Boolean"},Te=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`,tt=t=>Te(t,et.Object),jt=t=>Te(t,et.String),Nt=t=>Te(t,et.Array),Pt=t=>Te(t,et.Number),Ui=t=>Te(t,et.Function);var _r=t=>Pt(t)&&!isNaN(t);var we=t=>tt(t)&&Object.keys(t).length===0,Rr=t=>Nt(t)&&!t.length;var rt=(t,e)=>jt(t)&&(e?t.trim():t).length;var Vr=window.navigator.userAgent.toLowerCase(),Hh=/ipad|iphone|ipod/.test(Vr),zi=/mobi/i.test(Vr),Gh=Vr.indexOf("android")>-1&&zi,ho=!zi,Uh=window.safari!==void 0&&ho;var Wi="video_interactive",Ki="videoint";var uo=250,it=class{constructor(e){F(this,"onResize",e=>{this.isReady&&(!e[0].contentRect.width||!e[0].contentRect.height||(this.lastZoomInfo&&this.ngEditor.zoomTo(this.getNextPoint()),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}))});F(this,"handleChapterChange",e=>{var r;if(this.isReady){if(this.isHidden||this.hide(),!(e!=null&&e.id)){(r=this.onError)==null||r.call(this,"Id is not found"),console.error("Id is not found");return}this.visitedChapterIds.add(e.id),this.ngEditor.selectChapter(e.id),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=void 0}});F(this,"handleManifestChange",(i,...n)=>A(this,[i,...n],function*(e,r=[]){var s;if(!Pt(e.graph.edit.chapters[0].x)){this.isReady=!1,(s=this.onError)==null||s.call(this,"Can't show graph"),console.error("Can't show graph");return}if(this.lastZoomInfo=void 0,!this.ngEditor){let l;try{l=yield(0,Qi.loadVKLangPack)(this.lang,Wi,Ki)}catch(c){console.log("Unable to load graph language pack")}let{GraphEditor:o}=yield import("@interactiveplatform/movika-graph-editor");this.ngEditor=new o(this.graphWrapperElement,{mode:"read",lang:this.lang,translation:l}),this.ngEditor.on("control",({name:c,chapterId:h})=>{c==="openPreview"&&this.onOpenPreviewClick(h)}),this.ngEditor.on("zoomEnd",c=>{this.lastZoomInfo=d({},c)})}this.visitedChapterIds=new Set(r),e.metadata.id!==this.currentManifestId?(this.ngEditor.update(e),this.currentManifestId=e.metadata.id):this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.isReady=!0}));this.init(e)}init({root:e,onOpenPreviewClick:r,onError:i,lang:n,visitedChapters:s=[]}){this.isHidden=!0,this.currentManifestId=void 0,this.currentChapterId=void 0,this.visitedChapterIds=new Set(s),this.onOpenPreviewClick=r,this.onError=i,this.lang=n!=null?n:"ru",this.zoom=.7,this.isReady=!1,this.lastZoomInfo=void 0,this.ngEditorSize=void 0,this.ngEditor=void 0,this.graphWrapperElement=po(e),this.resizeObserver=new ResizeObserver(Lt(this.onResize,uo)),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,r;this.hide(),this.resizeObserver.disconnect(),(e=this.ngEditor)==null||e.setVisitedChapters([]),this.onOpenPreviewClick=void 0,(r=this.ngEditor)==null||r.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}};function po(t){let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.display="none",t.append(e),e}var Ar=()=>{let t=[],e=null;return{setPlayer:l=>{e=l},setContainers:l=>{t=l},deleteContainer:l=>{t=t.filter(o=>o.id!==l)},getNextInteractiveTime:(l=3e3)=>{if(!t.length||e===null)return null;let o=-1,c=!1,h=Math.round(e.info.position$.getValue()*1e3);for(let m of t){let S=m.startTime-l;if(S<=h&&(h<=m.endTime||m.endTime===null)){c=!0;break}h<S&&(o=o===-1?S:Math.min(o,S))}return!c&&o!==-1?o:null}}};var ae=(t="",e="")=>{t=t.split("."),e=e.split(".");let r=0;for(let i=0;i<Math.max(t.length,e.length)&&!r;i++)t[i]>e[i]?r=1:t[i]<e[i]?r=-1:r=0;return r};var Xi=require("uuid");var fo="3.1",Yi={default:"setNextBranch",random:"setRandomBranch",weightlessRandom:"setWeightlessRandomBranch",max:"setMaxWeightBranch",min:"setMinWeightBranch"},mo={type:"onSuspense",action:{type:"continuePlayback",args:{shouldOpenNow:!0,isDetachContainer:!0}}},Zi=t=>{let e=[];for(let l of t.chapters){let o,c=[];for(let r of l.branches){let i=r,{isDefault:S}=i,v=Y(i,["isDefault"]);S&&(o=v.id),c.push(v)}let h=[],m=[];for(let n of l.containers){let s=n,{fallbackStrategy:S}=s,v=Y(s,["fallbackStrategy"]);let I=!!v.endTime,T=[mo];switch(S){case"await":I?T=[]:h=[];break;case"default":{let V={type:"onSuspense",action:{type:Yi.default,args:{branchId:o,shouldOpenNow:!I,isDetachContainer:!0}}};I?T=[V]:h=[V];break}case"random":case"weightlessRandom":case"max":case"min":{let V={type:"onSuspense",action:{type:Yi[S],args:{}}};I?T=[V]:h=[V];break}}for(let V of v.controls)m.push(x(d({},v),{controls:[d({},V)],id:(0,Xi.v4)(),events:T}))}e.push(x(d({},l),{containers:m,events:h,branches:c}))}return t.metadata.version=fo,t.metadata.updated=new Date().toISOString(),x(d({},t),{chapters:e})};var yo="3.2",Ji=t=>{if(!t.media){let e=t.metadata,{media:r}=e,i=Y(e,["media"]);return x(d({},t),{metadata:x(d({},i),{version:yo}),media:r})}return t};var vo="3.3",go=(t=[])=>({edit:{chapters:t},view:{}}),en={type:"onSuspense",action:{type:"expect",args:{shouldOpenNow:!0,isDetachContainer:!0}}},tn=t=>{var n;let e=[],r=[];for(let s of t.chapters){let i=s,{id:l,x:o,y:c}=i,h=Y(i,["id","x","y"]),m=h.containers.map(S=>{var v;return x(d({},S),{controls:S.controls.map(_=>{var f=_,{subtype:I,type:T}=f,V=Y(f,["subtype","type"]);return x(d({},V),{type:I!=null?I:T})}),events:(v=S.events)!=null&&v.length?S.events:[en]})});e.push(x(d({id:l},h),{containers:m,events:(n=h.events)!=null&&n.length?h.events:[en]})),r.push({id:l,x:o,y:c})}return x(d({},t),{chapters:e,graph:go(r),metadata:x(d({},t.metadata),{version:vo})})};var bo=[{version:"3.0",migrate:Zi},{version:"3.1",migrate:Ji},{version:"3.2",migrate:tn}],Mr=t=>bo.reduce((e,r)=>ae(e.metadata.version,r.version)?e:r.migrate(e),t);var gu=Object.freeze({Choice:"Choice",TextInput:"TextInput"}),rn=Object.freeze({Button:"Button",Area:"Area",Text:"Text"}),bu=Object.freeze({onClick:"onClick",onSuspense:"onSuspense"}),P=Object.freeze({openURI:"openURI",setNextBranch:"setNextBranch",setWeightlessRandomBranch:"setWeightlessRandomBranch",setRandomBranch:"setRandomBranch",setMaxWeightBranch:"setMaxWeightBranch",setMinWeightBranch:"setMinWeightBranch",setDefaultBranch:"setDefaultBranch",continuePlayback:"continuePlayback",expect:"expect"}),kt=(s=>(s.GO_NEXT_BUTTON="GO_NEXT_BUTTON",s.GO_NEXT_AREA="GO_NEXT_AREA",s.WATCH_AGAIN="WATCH_AGAIN",s.OPEN_GRAPH="OPEN_GRAPH",s.CLOSE_GRAPH="CLOSE_GRAPH",s))(kt||{});var nn={metadata:"Object",chapters:"Array"},Eo="3.0.0",Co="3.3.0",nt=t=>{let e=ae(t,Eo);return e===-1?!1:e===0?!0:ae(t,Co)!==1},sn=t=>{if(!tt(t))return!1;for(let e in nn)if(!t[e]||!Te(t[e],nn[e]))return!1;return nt(t.metadata.version)},$t=t=>t.type===rn.Text;var R=class{constructor(e,r,...i){this.severity=e,this.category=r,this.data=i}toString(){return`SDK_NAME ERROR ${JSON.stringify(this,null," ")}`}};F(R,"Severity",{RECOVERABLE:1,CRITICAL:2}),F(R,"Category",{VIDEO:0,INTERACTIVES:1,GRAPH:2,MANIFEST:3,LOADERS:4,HISTORY:5,SEAMLESS:6});var qe=class{constructor(){F(this,"listeners",{})}addListener(e,r){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(r),this}on(e,r){return this.addListener(e,r)}once(e,r){this.listeners[e]=this.listeners[e]||[];let i=()=>{r(),this.off(e,i)};return this.listeners[e].push(i),this}off(e,r){return this.removeListener(e,r)}reset(){this.listeners={}}removeListener(e,r){let i=this.listeners[e];if(!i)return this;for(let n=i.length;n>0;n--)if(i[n]===r){i.splice(n,1);break}return this}emit(e,...r){let i=this.listeners[e];return i?(i.forEach(n=>{n(...r)}),!0):!1}listenerCount(e){return(this.listeners[e]||[]).length}rawListeners(e){return this.listeners[e]}};var Ft=class{constructor(e){F(this,"addFn",(e,r=!1)=>{Ui(e)&&(this.fns.push(e),r&&this.updateFn())});F(this,"removeFn",(e,r=!1)=>{this.fns=this.fns.filter(i=>i!==e),r&&this.updateFn()});F(this,"updateFn",()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}});F(this,"forceRequestAnimation",()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))});F(this,"requestAnimation",()=>{this.raf||this.forceRequestAnimation()});F(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=[]}};var hn=require("@vkontakte/videoplayer-shared");var Bt=class{constructor(e){var r,i;this.loaders={chapterLoaders:(r=e==null?void 0:e.chapterLoaders)!=null?r:[],manifestLoaders:(i=e==null?void 0:e.manifestLoaders)!=null?i:[]}}exec(e,r){return A(this,null,function*(){return xo(...this.loaders[e])(r)})}};function xo(...t){return function(r){return A(this,null,function*(){let i=[...t];for(;i.length>0;)r=yield i.shift()(r);return r})}}function st(t,e,r){return t?x(d({},t),{[e]:t[e]?[r,...t[e]]:[r]}):{[e]:[r]}}function qt(n){var s=n,{actions:t,errors:e,chapterId:r}=s,i=Y(s,["actions","errors","chapterId"]);if(r){let l=t.getManifest(),o=t.getChapter(l.chapters,r);if(o){let c=t.getMedia(l.media,o.videoId),h=t.getGraph(l.graph,o.id);return c?x(d({},i),{actions:t,errors:e,result:{chapter:o,media:c,graph:h}}):x(d({},i),{errors:st(e,qt.name,"Could not find media"),actions:t})}}return x(d({},i),{errors:st(e,qt.name,"Could not find chapter"),actions:t})}var Io=t=>A(void 0,null,function*(){try{let e,r;if(tt(t))e=t;else if(jt(t)){r=new URL(t).href;let n=yield fetch(r);if(!n.ok)return{};e=yield n.json()}else return{};if(!sn(e))return{};let i=e.metadata.media;if(jt(i)&&!e.media)try{let n;r?n=new URL(i,r).href:(n=new URL(i).href,r=n);let s=yield fetch(n);if(!s.ok)throw new Error;e.metadata.media=yield s.json()}catch(n){return wo(e.metadata.version)?{manifest:e}:{}}return{manifest:e,manifestURL:r}}catch(e){return{}}});function an(t){return A(this,null,function*(){let{manifest:e,manifestURL:r}=yield Io(t),i=Mr(e);return i.media=So(i.media,r),delete i.metadata.media,i})}function Dt(t,e){return t.find(r=>r.id===e)}function Or(t,e){var r,i;return(r=t.edit)!=null&&r.chapters?t.edit.chapters.find(n=>n.id===e):(i=t.view)!=null&&i.chapters?t.view.chapters.find(n=>n.id===e):void 0}function Lr(t,e){return t.videos.find(r=>r.id===e)}function So(t,e){return x(d({},t),{videos:t.videos.map(r=>x(d({},r),{variants:r.variants.map(i=>{let n=To(i.url,e);return x(d({},i),{url:n||i.url})})}))})}function To(t,e){try{return new URL(t,e).href}catch(r){return""}}function wo(t){return ae(t,"3.2.0")>=0}var D=Object.freeze({nothing:0,beforeInteractive:1,interactive:2,afterInteractive:3,end:4,removed:5,destroyed:6}),Ht=t=>Nt(t)&&!Rr(t),se=t=>t.order==="end",at=t=>Nt(t.containers)&&!Rr(t.containers)&&se(t),on=(t,e)=>{var i;let r=t*1e3;return Ht(e.controls)&&r<((i=e.startTime)!=null?i:0)},jr=(t,e)=>{var i,n;let r=t*1e3;return Ht(e.controls)&&r>=((i=e.startTime)!=null?i:0)&&r<=((n=e.endTime)!=null?n:1/0)};var _e=t=>t.some(e=>e.action.type==="expect"),Nr=t=>t.find(e=>e.action.type==="expect"),_o=t=>(t==null?void 0:t.length)===1,Gt=t=>_o(t)&&$t(t[0]);var cn=({fn:t,type:e=1},...r)=>(...i)=>e?t(...i,...r):t(d(d({},i[e]),r[e])),ln=(t,e)=>_e(t.events)?!1:e.some(({container:r})=>r.container.id!==t.id&&_e(r.container.events)&&r.container.endTime===t.endTime&&!r.isRemoved);var Re=class extends Bt{constructor(e,r){super(e),this.onError=r,this.prevChapter$=new hn.ValueSubject(null),this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}setManifest(e){return A(this,null,function*(){var n;this.release();let r=yield this.exec("manifestLoaders",{actions:{addErrorMessage:st},result:null,errors:null,source:e});r.errors&&this.errorHandler(r.errors);let i=yield an((n=r.result)!=null?n:e);return this.manifest=i,this})}setInitial(){return A(this,null,function*(){return this.setNext()})}setNext(){return A(this,arguments,function*(e=this.manifest.metadata.initChapterId){this.prevChapter$.next(this.chapter);let r=yield this.exec("chapterLoaders",qt({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Or,getChapter:Dt,getMedia:Lr,getByBranches:this.getByBranches.bind(this),addErrorMessage:st},result:null,errors:null,chapterId:e}));return r.errors&&this.errorHandler(r.errors),this.chapter=r.result.chapter,this.media=r.result.media,this.graph=r.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){let r=Dt(this.manifest.chapters,e);if(r){let i=Lr(this.manifest.media,r.videoId),n=Or(this.manifest.graph,r.id);if(i)return{chapter:r,media:i,graph:n}}return null}getBranches(e=this.chapter.id){if(e===this.chapter.id)return this.getByBranches(this.chapter.branches);{let r=Dt(this.manifest.chapters,e);return this.getByBranches(r==null?void 0:r.branches)}}getByBranches(e=[]){return e.reduce((r,i)=>{let n=this.getByChapterId(i.chapterId);return n&&r.push(n),r},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter.id===this.manifest.metadata.initChapterId}isEndChapter(){return se(this.chapter)}};var dn=require("@vkontakte/videoplayer-core"),pn=require("@vkontakte/videoplayer-shared");var un=t=>{let e=t.variants.find(r=>{var i;return((i=r.payload)==null?void 0:i.type)==="vk"});if(e&&"payload"in e){let[r,i]=e.payload.id.split("_");return[r,i]}return[]};var b={graph:"graph",interactives:"interactives",chapterChanged:"chapter-changed",playerChanged:"player-changed",manifestChanged:"manifest-changed",errors:"errors",eachTick:"eachTick",historyInited:"history-inited",historyDestroyed:"history-destroyed"},De={visibility:"visibility",watchAgainClicked:"watchAgainClicked"},M={actionChoiceCanceled:"action-choice-canceled",actionChoice:"action-choice",actionExecution:"action-execution",visibility:"visibility",containerRemoved:"container-removed",rangeEnded:"range-ended"};function Pr(){let t=new Map;function e(o){var c=o,{listId:n=Math.random().toString(),itemId:s=Math.random().toString()}=c,l=Y(c,["listId","itemId"]);let h=t.get(n),m=d({},l);return h?h[s]=m:t.set(n,{[s]:m}),d({listId:n,itemId:s},l)}function r(n,s){var o,c,h;let l=t.get(n);if(l){if(s)return(o=l[s])==null||o.player.destroy(),(c=l[s])==null||c.container.remove(),(h=l[s])==null||h.subscription.unsubscribe(),delete l[s],Object.keys(l).length||t.delete(n),!0;for(let m of Object.values(l))m.player.destroy(),m.container.remove();return t.delete(n),!0}else throw Error("Can't remove. Not find.")}function i(){for(let n of t)r(n[0])}return{createPlayer:e,removePlayer:r,map:t,removeAll:i}}function kr(t,e=[]){var s,l,o;let r={},i,n=!e.length;for(let c of t.variants)if(!i&&"cover"in c&&(i=c.cover),"url"in c)switch(c.type.toLowerCase()){case"mp4":(n||e.includes("mp4"))&&(r.MPEG=x(d({},r.MPEG),{[(s=c.standard)!=null?s:"Invariant quality"]:c.url}));break;case"mpeg":(n||e.includes("mpeg"))&&(r.MPEG=x(d({},r.MPEG),{[(l=c.standard)!=null?l:"Invariant quality"]:c.url}));break;case"hls":(n||e.includes("hls"))&&(r=x(d({},r),{HLS:{type:"url",url:c.url}}));break;case"dash":(n||e.includes("dash"))&&(r=x(d({},r),{DASH_SEP:{compatibilityMode:!0,type:"url",url:c.url}}));break;default:break}return{sources:r,thumbUrl:i,title:(o=t.title)!=null?o:""}}var ot=(t,e)=>{let r=t.info.currentQuality$.getValue(),i=t.info.availableQualities$.getValue();r!==e&&i.includes(e)&&(t.setQuality(e),t.setAutoQuality(!1))};var ct={activePlayerChanged:"sc-active-player-changed",initiated:"sc-initiated",playerCreated:"sc-player-created"},Ro=2;function $r(t){let e=Pr(),r,i,n=new qe,s={},l=!1,o=null,c=!1,h;t&&m(t);function m(u){o=u}function S(u,E,w){var N;if(!o)throw Error("need to set interactive controller");if(!o.options)return;let O=((N=e.map.get(u))!=null?N:{})[E];if(O){s=d({chapterId:w,listId:u,itemId:E},O);let q=s.player;i=q.info.currentQuality$.subscribe(L=>{if(!(!L||!q.info.position$.getValue())){r=L;for(let re of e.map)Object.values(re[1]).forEach(({player:ee})=>{q.info.isAutoQualityEnabled$.getValue()||ot(ee,L)})}}),O.container.remove(),l=!1,o.setPlayer(O.player),c||(o.init(),c=!0),n.emit(ct.activePlayerChanged,{player:s.player,config:s.config});return}throw Error("Can't set. Not find.")}function v(u,E,w){return A(this,null,function*(){if(!o)throw Error("need to set interactive controller");if(we(s)||u!==s.itemId)return;if(w>=0&&!l){let O=o.getChapterBranches();l=!0;let N=new Set;for(let q of O)N.has(q.media.id)||(yield T({media:q.media,chapterId:q.chapter.id,setAsActive:!1,title:q.chapter.label}),N.add(q.media.id))}})}function I(w){return A(this,arguments,function*({chapter:{id:u},media:E}){if(we(s))return;i==null||i.unsubscribe();let y=s.player.info.muted$.getValue(),O=s.player.info.currentQuality$.getValue(),N=s.player.info.isAutoQualityEnabled$.getValue(),q=s.player.info.volume$.getValue(),L=s.player.info.currentPlaybackRate$.getValue(),re=!N,ee=!1;for(let K of e.map)if(K[0]===E.id){let ye=Object.keys(K[1]);for(let Q of ye)Q===s.itemId?(ye.length<Ro||(ee=!0),e.removePlayer(K[0],Q)):(ee=!0,S(K[0],Q,u),re?ot(s.player,O):s.player.setAutoQuality(!0),s.player.setVolume(q),s.player.setMuted(y),s.player.setPlaybackRate(L))}else e.removePlayer(K[0]);ee||(yield T({media:E,chapterId:u,setAsActive:!0,playbackRate:L}),re?ot(s.player,O):s.player.setAutoQuality(!0),s.player.setVolume(q),s.player.setMuted(y))})}function T(re){return A(this,arguments,function*({media:u,chapterId:E,prefetch:w=!0,setAsActive:y=!0,autoplay:O=!1,preferredExt:N,title:q,playbackRate:L}){var Ri,Vi,Ai,Mi,Oi;let ee=Math.random().toString(),K=document.createElement("div");h.append(K);let ye=(Ri=s==null?void 0:s.player)==null?void 0:Ri.info.isAutoQualityEnabled$.getValue(),Q;if((Vi=o==null?void 0:o.options)!=null&&Vi.vkVideoLoader){let Et=un(u);Et.length&&(Q=yield o.options.vkVideoLoader(...Et))}let Ti=((Ai=o==null?void 0:o.options)==null?void 0:Ai.coreConfig)||{},eo=x(d({},Ti),{configName:[...(Mi=Ti.configName)!=null?Mi:[],"interactive"]}),wi=x(d({container:K},((Oi=Q==null?void 0:Q.videos)==null?void 0:Oi[0])||{sources:kr(u,N).sources}),{title:q,failoverHosts:(Q==null?void 0:Q.failoverHosts)||[]}),Se=new dn.Player(eo);Se.initVideo(wi);let _i=new pn.Subscription;_i.add(Se.info.position$.subscribe(function(Et){v(ee,Se.info.duration$.getValue(),Et)})).add(Se.events.canplay$.subscribe(function(){ye||ot(Se,r),L&&Se.setPlaybackRate(L)}));let Pe=e.createPlayer({listId:u.id,itemId:ee,player:Se,container:K,sources:kr(u,N).sources,config:wi,subscription:_i});return y&&S(u.id,Pe.itemId,E),O&&Pe.player.play(),w&&!O&&Pe.player.prepare(),n.emit(ct.playerCreated,Pe.player),{player:Pe.player,config:Pe.config}})}function V(){_(),o=null}function _(){o==null||o.off(b.chapterChanged,I),e.removeAll(),s={},c=!1,l=!1}function f(E){return A(this,arguments,function*({container:u}){if(!o)throw Error("need to set interactive controller");_(),h=u;let{media:w,chapter:y}=o.getCurrentChapter();if(w){o.on(b.chapterChanged,I);let{player:O,config:N}=yield T({media:w,chapterId:y.id,title:y.label});return n.emit(ct.initiated,{container:u,media:w,chapterId:y.id}),{player:O,config:N}}else console.error("not found")})}return x(d({},e),{on:n.on.bind(n),off:n.off.bind(n),init:f,setInteractiveController:m,createPlayer:T,removeAll:V,getActivePlayer:function(){return s}})}var fn=require("@vkontakte/videoplayer-shared");var Ut=class{constructor({player:e,container:r,branches:i,selectBranches:n,interactiveEvents:s,globalEventEmitter:l,ignoreContainerEvent:o,permanentTextControls:c,disabledControls$:h,onRemove:m}){F(this,"hide",()=>{setTimeout(()=>{var e,r;this.gameState!==D.end&&(_e(this.container.container.events)&&this.gameState===D.afterInteractive||this.selectBranches.state.isExpect||(this.gameState!==D.interactive&&((r=(e=this.container).hide)==null||r.call(e)),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1})))})});F(this,"show",()=>{var e,r,i,n;if(this.gameState===D.interactive&&!this.isSelectedControlEvent)if(this.container.getElement())(n=(i=this.container).show)==null||n.call(i),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!0,isFirst:!1});else{let l=cn({fn:this.selectBranches.onControlEvent,type:0},{isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1})},onEvent:(o,c)=>{this.isSelectedControlEvent=!0,o!==!1&&(this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1})),(this.gameState===D.end||this.gameState===D.afterInteractive||this.selectBranches.state.isExpect)&&(this.selectBranches.stopExpect(),c(),this.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1}))},isEOV:()=>this.gameState===D.end});this.container.createView(l),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!0,isFirst:!0}),this.disabledControls$.getValue()&&((r=(e=this.container).disable)==null||r.call(e))}});F(this,"onEndOfVideo",()=>{this.gameState=D.end,this.selectContainerEvent(!0)});F(this,"whilePlaying",()=>{var s,l;if(((s=this.player.experimental.element$.getValue())==null?void 0:s.readyState)<1||[D.destroyed,D.removed].includes(this.gameState)&&!this.isPermanentText)return;let r=this.player.getExactTime();if(on(r,this.container.container))this.gameState!==D.beforeInteractive&&(this.gameState=D.beforeInteractive,this.onBeforeStartTime());else if(jr(r,this.container.container))this.gameState!==D.interactive&&(this.gameState=D.interactive,this.onStartTime());else if(this.gameState!==D.afterInteractive){let o=this.gameState;this.gameState=D.afterInteractive,o===D.interactive&&this.onEndTime()}else this.gameState!==D.destroyed&&!this.isPermanentText&&this.removeView();let i=jr(r,this.container.container),n=this.container.container.startTime?[this.container.container.startTime,(l=this.container.container.endTime)!=null?l:1/0]:[];this.globalEventEmitter.emit(b.eachTick,{subjectId:this.container.container.id,subjectName:"container",range:n,currentTime:r,isInteractiveTime:i})});this.container=r,this.branches=i,this.selectBranches=n,this.subscription=new fn.Subscription,this.player=e,this.interactiveEvents=s,this.ignoreContainerEvent=o,this.isPermanentText=c&&Gt(r.container.controls),this.disabledControls$=h,this.onRemove=m,this.globalEventEmitter=l,this.gameState=D.nothing,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{var r,i,n,s;e?(i=(r=this.container).disable)==null||i.call(r):(s=(n=this.container).enable)==null||s.call(n)}))}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);let e=_e(this.container.container.events)||this.ignoreContainerEvent();(this.isSelectedControlEvent||!e)&&this.removeView()}onBeforeStartTime(){var e,r;(r=(e=this.container).hide)==null||r.call(e),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.visibility,visibility:!1})}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=D.beforeInteractive}removeView(){var e;this.container.removeView(),this.globalEventEmitter.emit(b.interactives,{subjectId:this.container.container.id,subjectName:"container",type:M.containerRemoved,visibility:!1}),this.gameState=D.removed,(e=this.onRemove)==null||e.call(this)}destroy(){var e;this.reset(),this.removeView(),this.gameState=D.destroyed,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:(e=this.container.container.endTime)!=null?e:1/0,id:this.container.container.id})}};var mn=(t=[])=>t.reduce((e,r,i)=>{var s,l,o;let n=((s=r==null?void 0:r.controls)!=null?s:[]).filter(c=>!$t(c));if(Ht(n)){let c=[(l=r.startTime)!=null?l:0,(o=r.endTime)!=null?o:1/0],h=r.id;if(!i)e.push({subjects:[h],range:c});else{let m=[],S=-1/0,v=1/0,I=[],T=[];for(let V=0;V<e.length;V++){let _=e[V];if(T.push(..._.subjects),_.range[0]<v&&(v=_.range[0]),_.range[1]>S&&(S=_.range[1]),c[0]>=_.range[0]&&c[1]<=_.range[1])return e[V].subjects.push(h),e;c[0]<_.range[0]&&c[1]>_.range[0]&&(m.push(V),I=I.concat(_.subjects)),c[0]>=_.range[0]&&c[0]<=_.range[1]&&(m.push(V),I=I.concat(_.subjects),c[0]=_.range[0]),c[1]>=_.range[0]&&c[1]<=_.range[1]&&(m.push(V),I=I.concat(_.subjects),c[1]=_.range[1])}if(T.push(h),c[0]<=v&&c[1]>=S)return[{subjects:T,range:c}];m.length&&m.reverse().forEach(V=>{e.splice(V,1)}),e.push({subjects:I.concat([h]),range:c})}}return e},[]).sort((e,r)=>e.range[0]-r.range[0]);function yn(){let t={};function e(){for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&delete t[o];return!0}function r(o){let c={};for(let h in t)+h<=o&&(c[h]=t[h]);return c}function i(o){let c={};for(let h in t)+h>=o&&(c[h]=t[h]);return c}function n({timestamp:o,priority:c,initiator:h}){var m;if(_r(o)){let S=(m=t[o])!=null?m:null;if(S&&rt(c,!0)){let v={},I=S[c];if(I&&(v=d(d({},v),I)),v=we(v)?null:v,v&&rt(h,!0)){let T=v[h];return T!=null?T:null}return v}return S}return null}function s({timestamp:o,priority:c,initiator:h}){if(_r(o))if(t[o]){if(rt(c,!0))if(t[o][c]){if(rt(h,!0))if(t[o][c][h]){if(delete t[o][c][h],!we(t[o][c]))return!0}else return!1;if(delete t[o][c],!we(t[o]))return!0}else return!1;return delete t[o]}else return!1}function l(S){var v=S,{timestamp:o,priority:c,initiator:h}=v,m=Y(v,["timestamp","priority","initiator"]);var I,T,V;(T=(I=t[o])==null?void 0:I[c])!=null&&T[h]?t[o][c][h].push(d({},m)):(V=t[o])!=null&&V[c]?t[o][c]=x(d({},t[o][c]),{[h]:[d({},m)]}):t[o]?t[o]=x(d({},t[o]),{[c]:{[h]:[d({},m)]}}):t[o]={[c]:{[h]:[d({},m)]}}}return{map:t,remove:s,add:l,removeAll:e,get:n,getLte:r,getGte:i}}var Vo=[P.expect,P.setNextBranch],Ao=1/0;function Fr(t){let e=t,r,i=Mo(),n=new yn,s,l=()=>{v(),f()},o=u=>{n.add.call(void 0,u),T()},c=(u=[])=>{for(let E of u)if(E.action(),Vo.includes(E.actionType))break},h=(u=1/0)=>{var O,N,q;let E=zt((O=n.get({timestamp:u,priority:"control"}))!=null?O:{}),w=zt((N=n.get({timestamp:u,priority:"container"}))!=null?N:{}),y=zt((q=n.get({timestamp:u,priority:"chapter"}))!=null?q:{});return[...E,...w,...y]},m=u=>{i.isReady(u)&&c(h(u))},S=()=>{var u;c([...zt((u=n.get({timestamp:1/0,priority:"chapter"}))!=null?u:{})])},v=()=>{r&&(s==null||s.unsubscribe(),r=void 0)},I=u=>{},T=()=>{r||(r=()=>setTimeout(()=>{m(1/0)}),s=e.events.ended$.subscribe(r))},V=u=>{v(),e=u},_=u=>{u.priority==="container"&&i.resetCalled(u.timestamp),n.remove(u)},f=()=>{i.release(),n.removeAll()};return{setPlayer:V,add:o,remove:_,exec:m,execEndOfVideo:S,listen:T,unlisten:v,release:l,containersEventsCallState:i,getPreparedToExecActions:h}}function Mo(){let t=new Map;return{setCalled:({timestamp:l,id:o})=>{let c=t.get(l);c&&c[o]!==void 0&&(c[o]=!0)},setData:(l=[])=>{var o,c;for(let h of l){let m=(o=h.endTime)!=null?o:Ao,S=(c=t.get(m))!=null?c:{};t.set(m,x(d({},S),{[h.id]:!1}))}},resetCalled:l=>{let o=t.get(l);if(o)for(let c in o)o[c]=!1},isReady:l=>{let o=t.get(l);return o?!Object.values(o).some(c=>!c):!0},release:()=>t.clear()}}function zt(t){return Object.values(t).flat().sort(e=>e.actionType===P.expect?-1:1)}var vn=(t,e)=>{let{height:r,width:i}=e.info.intrinsicVideoSize$.getValue()||{};if(!(r&&i))return{videoContentHeight:0,videoContentWidth:0};let{clientHeight:n,clientWidth:s}=e.experimental.element$.value||{};if(!(n&&s))return{videoContentHeight:0,videoContentWidth:0};let l=r/i,o=n/s,c,h;return o>l?(h=s,c=s*l):o<l?(h=n/l,c=n):(h=s,c=n),{videoContentWidth:h,videoContentHeight:c}};var Oo=250;function gn(t){let e=()=>{},r=new ResizeObserver(o=>{s(o),e=s.bind(null,o)});function i(o){let{parentElement:c,player:h}=t();if(c&&h){let{videoContentWidth:m,videoContentHeight:S}=vn(c,h);c.style.setProperty("--interactive-content-width",`${m}px`),c.style.setProperty("--interactive-content-height",`${S}px`),c.style.setProperty("--interactive-width",`${o[0].contentRect.width}px`),c.style.setProperty("--interactive-height",`${o[0].contentRect.height}px`)}}function n(){let{parentElement:o}=t();o.removeAttribute("style")}let s=Lt(o=>{let{fns:c=[]}=t();i(o);for(let h of c)h()},Oo);function l(){e=void 0,r.disconnect(),n()}return{resizeObserver:r,calc:()=>{e()},release:l}}var lt=class{constructor(){this.map={}}push(e,r){e in this.map?this.map[e].push(r):this.map[e]=[r]}get(e){let r=this.map[e];return r?r.slice():null}getAll(){let e=[];for(let r in this.map)e.push(...this.map[r]);return e}remove(e,r){e in this.map&&(this.map[e]=this.map[e].filter(i=>i!==r),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)}};var Lo=t=>Math.floor(Math.random()*t),bn=t=>{let e=t.length,r=1/0,i=null;for(;e--;)t[e].weight<r&&(r=t[e].weight,i=t[e]);return i},En=t=>{let e=t.length,r=-1/0,i=null;for(;e--;)t[e].weight>r&&(r=t[e].weight,i=t[e]);return i};var Cn=t=>{let e=t.length,r=Lo(e);return t[r]};var xn=t=>{var i,n;let e=0;for(let s=0;s<t.length;++s)e+=(i=t[s].weight)!=null?i:1;let r=Math.random()*e;e=0;for(let s=0;s<t.length-1;++s)if(e+=(n=t[s].weight)!=null?n:1,e>=r)return t[s];return t[t.length-1]};var In=Object.freeze({shouldOpenNow:!0,isDetachContainer:!0});var Br=(t,e=!1)=>x(d({},t),{args:e?d(d({},t.args),In):d(d({},In),t.args)}),qr=({globalEventEmitter:t,player:e,interactiveEvents:r,removeControllers:i})=>{let n={isExpect:!1},s=()=>{n.isExpect&&(n.isExpect=!1)},l=({action:f,controlType:u,controlId:E,containerId:w,branches:y=[],onEvent:O,isEOV:N=()=>!1,isDisabled:q=()=>!1})=>{let L=Br(f,N()),re={timestamp:1/0,priority:"control",initiator:E,actionType:L.type},ee=q(),K=t.emit.bind(t,b.interactives,{subjectId:E,subjectType:u,subjectName:"control",type:ee?M.actionChoiceCanceled:M.actionChoice,actionType:f.type,payload:d({containerId:w},L.args)});if(ee){K();return}switch(L.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let ye=y.find(Q=>Q.id===L.args.branchId);if(!ye)return;O(L.args.isDetachContainer,v.bind(null,{subjectId:E,subjectName:"control"})),K(),L.args.shouldOpenNow?T({subjectId:E,subjectName:"control",subjectType:u,action:L,payload:{chapterId:ye.chapterId,autoSelect:!1}}):(r.add(x(d({},re),{action:T.bind(null,{subjectId:E,subjectName:"control",subjectType:u,action:L,payload:{chapterId:ye.chapterId,autoSelect:!1}})})),i==null||i());return}case P.continuePlayback.trim().toLowerCase():{O(L.args.isDetachContainer,v.bind(null,{subjectId:E,subjectName:"control"})),K(),L.args.shouldOpenNow?I({subjectId:E,subjectName:"control",subjectType:u,action:f}):r.add(x(d({},re),{action:I.bind(null,{subjectId:E,subjectName:"control",subjectType:u,action:f})}));return}case P.openURI.trim().toLowerCase():{O(L.args.isDetachContainer,v.bind(null,{subjectId:E,subjectName:"control"})),K(),L.args.shouldOpenNow?_({subjectId:E,subjectName:"control",subjectType:u,action:L,payload:{URI:f.args.uri}}):(r.add(x(d({},re),{action:_.bind(null,{subjectId:E,subjectName:"control",subjectType:u,action:L,payload:{URI:f.args.uri}})})),i==null||i());return}default:console.error("Unexpected control event"),t.emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.INTERACTIVES,{message:"Unexpected control event"}));return}},o=({action:f,container:{id:u,endTime:E},branches:w=[],isEOV:y=!1,autoSelected:O=!1})=>{let N=Br(f,y),q={timestamp:!N.args.shouldOpenNow||y?1/0:E,priority:"container",initiator:u,actionType:N.type},L=t.emit.bind(t,b.interactives,{subjectId:u,subjectName:"container",type:M.actionChoice,actionType:N.type,payload:N.args});switch(N.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let re=w.find(ee=>ee.id===N.args.branchId);if(!re)return;L(),r.add(x(d({},q),{action:T.bind(null,{subjectId:u,subjectName:"container",action:N,payload:{chapterId:re.chapterId,autoSelect:O}})})),i==null||i();return}case P.setMaxWeightBranch.trim().toLowerCase():return;case P.setMinWeightBranch.trim().toLowerCase():return;case P.setRandomBranch.trim().toLowerCase():return;case P.setWeightlessRandomBranch.trim().toLowerCase():return;case P.continuePlayback.trim().toLowerCase():{L(),r.add(x(d({},q),{action:I.bind(null,{subjectId:u,subjectName:"container",action:N})}));return}case P.openURI.trim().toLowerCase():{L(),r.add(x(d({},q),{action:_.bind(null,{subjectId:u,subjectName:"container",action:N,payload:{URI:f.args.uri}})})),i==null||i();return}default:console.error("Unexpected container event"),t.emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.INTERACTIVES,{message:"Unexpected container event"}));return}};function c({container:f,branches:u,isEOV:E=!1}){let w=Nr(f.events);if(w){let y=Br(w.action,E);t.emit(b.interactives,{subjectId:f.id,subjectName:"container",type:M.actionChoice,actionType:y.type,payload:y.args}),r.add({timestamp:E?1/0:f.endTime,priority:"container",initiator:f.id,actionType:P.expect,action:S.bind(null,{subjectId:f.id,subjectName:"container"})}),n.isExpect=!0}else for(let y of f.events)o({action:y.action,container:f,branches:u,isEOV:E})}let h=({chapterId:f,action:u,branches:E=[]})=>{let w=t.emit.bind(t,b.interactives,{subjectId:f,subjectName:"chapter",type:M.actionChoice,actionType:u.type,payload:u.args});switch(u.type.trim().toLowerCase()){case P.setNextBranch.trim().toLowerCase():{let y=E.find(O=>O.id===u.args.branchId);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setWeightlessRandomBranch.trim().toLowerCase():{let y=Cn(E);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setRandomBranch.trim().toLowerCase():{let y=xn(E);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setMaxWeightBranch.trim().toLowerCase():{let y=En(E);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.setMinWeightBranch.trim().toLowerCase():{let y=bn(E);return y!=null&&y.chapterId?(w(),T.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{chapterId:y.chapterId,autoSelect:!0}})):void 0}case P.continuePlayback.trim().toLowerCase():return w(),I.bind(null,{subjectId:f,subjectName:"chapter",action:u});case P.openURI.trim().toLowerCase():return w(),_.bind(null,{subjectId:f,subjectName:"chapter",action:u,payload:{URI:u.args.uri}});default:console.error("Unexpected chapter event"),t.emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.INTERACTIVES,{message:"Unexpected chapter event"}));return}};function m(f){let u=Nr(f.events);if(u){if(se(f))return;t.emit(b.interactives,{subjectId:f.id,subjectName:"chapter",type:M.actionChoice,actionType:u.action.type,payload:u.action.args}),r.add({timestamp:1/0,priority:"chapter",initiator:f.id,actionType:P.expect,action:S.bind(null,{subjectId:f.id,subjectName:"chapter"})})}else f.events.forEach(E=>{let w=h({chapterId:f.id,action:E.action,branches:f.branches});w&&r.add({timestamp:1/0,priority:"chapter",initiator:f.id,actionType:E.action.type,action:w})})}let S=({subjectId:f,subjectName:u,action:E})=>{var w;e.pause(),t.emit(b.interactives,{subjectId:f,subjectName:u,type:M.actionExecution,actionType:(w=E==null?void 0:E.type)!=null?w:P.expect})},v=({subjectId:f,subjectName:u})=>{e.info.isEnded$.getValue()?r.execEndOfVideo():e.play(),t.emit(b.interactives,{subjectId:f,subjectName:u,type:M.actionExecution,actionType:"after-expect"})},I=({subjectId:f,subjectName:u,subjectType:E,action:w})=>{t.emit(b.interactives,{subjectId:f,subjectName:u,subjectType:E,type:M.actionExecution,actionType:w.type})},T=({subjectId:f,subjectName:u,subjectType:E,action:w,payload:y})=>{y.behaviour="change-chapter",t.emit(b.interactives,{subjectId:f,subjectName:u,subjectType:E,type:M.actionExecution,actionType:w.type,payload:y})},V=({subjectId:f,subjectName:u,subjectType:E,action:w,payload:y})=>{y.behaviour="change-manifest",t.emit(b.interactives,{subjectId:f,subjectName:u,subjectType:E,type:M.actionExecution,actionType:w.type,payload:y})},_=({subjectId:f,subjectName:u,subjectType:E,action:w,payload:y})=>{if(!y.URI)return;let O=window.open(y.URI,"_blank","noopener,noreferrer");O&&(O.opener=null),t.emit(b.interactives,{subjectId:f,subjectName:u,subjectType:E,type:M.actionExecution,actionType:w.type})};return{onControlEvent:l,onContainerEvent:o,onChapterEvent:h,onExpectEvent:S,expectEventHandler:v,setManifestChapterEvents:m,setManifestContainerEvents:c,stopExpect:s,state:n}};var Ci=Ni(Fa(),1),Ee=require("@vkontakte/videoplayer-shared");var er=(t,e)=>{let r={};return t.map(i=>{if(!r[i]){let n=e.chapters.find(l=>l.id===i);if(!n)return null;let s=e.media.videos.find(l=>n.videoId===l.id);if(!s)return null;r[i]=bi(s)}return r[i]}).filter(Boolean)},Ba=t=>{for(let e of t.variants)if(qa(e)&&"payload"in e)return e.payload.id},qa=t=>t.type==="custom"&&"payload"in t&&t.payload.type==="vk",bi=t=>{let e=Ba(t);if(!e)return null;let r=e.split("_").pop();return r?parseInt(r,10):null},Da=(t,e)=>{for(let r of t.media.videos)if(e===bi(r)){for(let i of t.chapters)if(i.videoId===r.id)return i.id;return}},Ei=(t,e)=>t.reduce((r,i)=>{let n=Da(e,i);return n?[...r,n]:r},[]);var ce,Ae,Me,te,tr,le,he,ne,Oe,We,Ke,pt=class{constructor({globalEventEmitter:e,videoId:r,interactiveController:i,historyApi:n,settings:s}){this.state={history$:new Ee.ValueSubject([]),hasPrevChapter$:new Ee.ValueSubject(!1),prevChapter$:new Ee.ValueSubject(null),isInitialChapter$:new Ee.ValueSubject(!1),isGoBackLimited$:new Ee.ValueSubject(!1)};C(this,ce,null);C(this,Ae,void 0);C(this,Me,!1);C(this,te,null);C(this,tr,null);C(this,le,null);C(this,he,null);C(this,ne,null);C(this,Oe,new Ee.Subscription);C(this,We,!1);C(this,Ke,0);var l,o,c;g(this,le,r),g(this,ne,e),g(this,he,i),g(this,ce,n),g(this,Ae,s),(l=this.state)!=null&&l.history$&&a(this,Oe)&&((c=a(this,Oe))==null||c.add((o=this.state)==null?void 0:o.history$.subscribe(h=>{var m,S,v,I,T,V;(m=this.state)==null||m.prevChapter$.next((0,Ci.default)(h,-2)||null),(S=this.state)==null||S.hasPrevChapter$.next(h.length>1),(T=this.state)==null||T.isInitialChapter$.next(this.getInitialChapterId()===((I=(v=a(this,te))==null?void 0:v.metadata)==null?void 0:I.initChapterId)),(V=this.state)==null||V.isGoBackLimited$.next(a(this,Ke)===a(this,Ae).maxLength-1)})))}setManifest(e){return A(this,null,function*(){!a(this,he)||!a(this,ne)||(g(this,te,e),yield this.getProjectHistory(),yield a(this,he).setChapter({chapterId:this.getInitialChapterId(),pushToHistory:!1}),a(this,Me)||(g(this,Me,!0),a(this,ne).emit(b.historyInited,{initChapterId:this.getInitialChapterId()})))})}get inited(){return a(this,Me)}updateHistory(e,r=!0){return A(this,null,function*(){var o,c;if(!a(this,te))return;a(this,We)?(g(this,We,!1),Pi(this,Ke)._++):g(this,Ke,0);let i=a(this,te),n=e.length-a(this,Ae).maxLength,s=n>0?e.slice(n):e,l=er(s,i);if(g(this,tr,l),(o=this==null?void 0:this.state)==null||o.history$.next(s),!(!r||!a(this,ce)||!a(this,le)))try{yield a(this,ce).save(a(this,le),l)}catch(h){(c=a(this,ne))==null||c.emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.HISTORY,"Unable to save interactive history"))}})}goBack(){return A(this,null,function*(){var i;if(!this.state||!a(this,he))return(i=a(this,ne))==null?void 0:i.emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.HISTORY,"Cannot go back because HistoryController has not been initialized"));g(this,We,!0);let e=this.state.history$.getValue().slice(0,-1),r=e.pop();this.state.history$.next(e),yield a(this,he).setChapter({chapterId:r})})}getProjectHistory(){return A(this,null,function*(){var n,s;if(!a(this,te)||!a(this,le))return;let e=a(this,te),r=[this.getInitialVideoId()];if(a(this,ce))try{let l=yield a(this,ce).get(a(this,le));l.length&&(r=l)}catch(l){(n=a(this,ne))==null||n.emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.HISTORY,"Error while trying to fetch data"))}let i=Ei(r,e);(s=this==null?void 0:this.state)==null||s.history$.next(i)})}getInitialChapterId(){var r,i;let e=(r=this.state)==null?void 0:r.history$.getValue();return(0,Ci.default)(e,-1)||a(this,Ae).initChapterId||((i=a(this,te))==null?void 0:i.metadata.initChapterId)}getInitialVideoId(){if(a(this,te)){let e=this.getInitialChapterId();return er([e],a(this,te)).pop()}return null}destroy(){var e,r;this.state=null,g(this,le,null),g(this,ce,null),g(this,he,null),(e=a(this,Oe))==null||e.unsubscribe(),g(this,Oe,null),g(this,Me,!1),(r=a(this,ne))==null||r.emit(b.historyDestroyed),g(this,ne,null)}};ce=new WeakMap,Ae=new WeakMap,Me=new WeakMap,te=new WeakMap,tr=new WeakMap,le=new WeakMap,he=new WeakMap,ne=new WeakMap,Oe=new WeakMap,We=new WeakMap,Ke=new WeakMap;var ir,Ha,ft,nr,Ga,ue=class ue{constructor(e,r,i,n){var s;this.target=e,this.type=r,this.listener=i,this.options=k(s=ue,ir,Ha).call(s,e,n),this.target.addEventListener(r,i,this.options)}unlisten(){this.target.removeEventListener(this.type,this.listener,this.options),this.target=null,this.listener=null,this.options=!1}};ir=new WeakSet,Ha=function(e,r){var i;if(r===void 0)return!1;if(typeof r=="boolean")return r;{let n=new Set(["passive","capture"]),s=Object.keys(r).filter(o=>!n.has(o));return s.length===0&&console.warn("Unsupported flag(s) to addEventListener: "+s.join(",")),k(i=ue,nr,Ga).call(i,e)?r:r.capture||!1}},ft=new WeakMap,nr=new WeakSet,Ga=function(e){let r=a(ue,ft);if(r===void 0){r=!1;try{let i={},n={get:()=>(r=!0,!1)};Object.defineProperty(i,"passive",n),Object.defineProperty(i,"capture",n);let s=()=>{};e.addEventListener("test",s,i),e.removeEventListener("test",s,i)}catch(i){r=!1}g(ue,ft,r)}return r||!1},C(ue,ir),C(ue,nr),C(ue,ft,void 0);var rr=ue;var sr=class{constructor(){this.bindingMap=new lt}release(){this.removeAll(),this.bindingMap=null}listen(e,r,i,n){if(!this.bindingMap)return;let s=new rr(e,r,i,n);this.bindingMap.push(r,s)}listenOnce(e,r,i,n){let s=l=>{this.unlisten(e,r,s),i(l)};this.listen(e,r,s,n)}unlisten(e,r,i){if(!this.bindingMap)return;let n=this.bindingMap.get(r)||[];for(let s of n)s.target===e&&(i===s.listener||!i)&&(s.unlisten(),this.bindingMap.remove(r,s))}removeAll(){if(!this.bindingMap)return;let e=this.bindingMap.getAll();for(let r of e)r.unlisten();this.bindingMap.clear()}};var ar=class{constructor(){this._prevSizeId=0;this.rootElement=document.createElement("canvas")}clear(){var e;(e=this.rootElement.getContext("2d"))==null||e.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){var n;let e=(n=this.rootElement.getContext("2d"))==null?void 0:n.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let r=e.data,i=r.length;for(let s=3;s<i;s+=40)if(r[s]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){var e;this.canvasImgSrc&&((e=this.rootElement.getContext("2d"))==null||e.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height))}updateCanvasDimensions(e,r=!1){return A(this,null,function*(){let i=e.width+e.height;if(this._prevSizeId===i)return;let n;r&&(n=yield this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,r&&n&&this.restore(n),this._prevSizeId=i})}save(){return A(this,null,function*(){let e=this.rootElement.toDataURL("image/jpeg",1),r=new Image;return r.crossOrigin="anonymous",r.src=e,yield r.decode(),r})}restore(e){var r;this.rootElement&&((r=this.rootElement.getContext("2d"))==null||r.drawImage(e,0,0,this.rootElement.width,this.rootElement.height))}};var or=class{constructor({parentElement:e,endOffsetMs:r=250,onError:i}){this.currentVideoDurationMs=1/0;this._containerTimeFrameShouldReceived=!1;this._endTimeFrameReceived=!1;this._shouldCallSkip=!1;this.onEachTick=e=>{let r=e!=null?e:this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,i=this.isChapterEndTime(r);if(this.isContainerTime(r))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(i)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}};this.onSeek=()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())};this.rootElement=document.createElement("div"),this.rootElement.style.cssText=`
|
|
7
7
|
position: absolute;
|
|
8
8
|
top: 0;
|
|
9
9
|
left: 0;
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
height: var(--interactive-height);
|
|
12
12
|
background-color: var(--black);
|
|
13
13
|
visibility: hidden;
|
|
14
|
-
`,this.lastFrameCanvas=new
|
|
14
|
+
`,this.lastFrameCanvas=new ar,this.endOffsetMs=r,this._callbacks={onError:i},this.lastFrameCanvas.rootElement.style.cssText=`
|
|
15
15
|
position: absolute;
|
|
16
16
|
top: 50%;
|
|
17
17
|
left: 50%;
|
|
18
18
|
transform: translate(-50%, -50%);
|
|
19
|
-
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),
|
|
19
|
+
`,this.rootElement.prepend(this.lastFrameCanvas.rootElement),e.prepend(this.rootElement)}destroy(){this.hide(),this.reset(),this._callbacks=void 0,this.lastFrameCanvas.destroy(),this.rootElement.remove()}setVideoDuration(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility="visible"}hide(){this.rootElement.style.visibility="hidden"}updateCanvasDimensions(e=!1){return A(this,null,function*(){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let r=getComputedStyle(this.rootElement),i={width:parseInt(r.getPropertyValue("--interactive-content-width"),10),height:parseInt(r.getPropertyValue("--interactive-content-height"),10)};try{this.lastFrameCanvas.updateCanvasDimensions(i,e)}catch(n){this._onError(n)}})}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(r=>{var i,n,s;return((i=r.controls)==null?void 0:i.length)&&e>=((n=r.startTime)!=null?n:0)&&e<=Math.min((s=r.endTime)!=null?s:1/0,this.currentVideoDurationMs-this.endOffsetMs)})}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var r,i;(i=(r=this._callbacks)==null?void 0:r.onError)==null||i.call(r,e)}};function Ua(t=0){return new Promise(e=>{setTimeout(()=>{e(0)},t)})}var za=Object.freeze({parentElement:null,fullscreenTargetElement:null,lang:"ru",loaders:{},graph:!1,historyApi:null,historyParams:null,projectInfo:{},initSeamless:!1,lastFrame:!1,permanentTextControls:!0,config:{historyMaxLength:100,noInteractionEventTimeout:3e4}}),de=Object.freeze({created:0,initiated:1,ready:2,destroyed:3});function Zl(){let t=document.createElement("div");return t.style.cssText=`
|
|
20
20
|
position: absolute;
|
|
21
21
|
top: 0;
|
|
22
22
|
left: 0;
|
|
23
|
-
`,i}var yt,Z,gt,z,st,U,Y,dt,B,pt,Bt,W,Ft,H,L,vt,Vt,De,Ln,He,Nn,Dt,Fe,wi,Ge,Ue,kn,se,Ti,Rt,_t,ie,We,jn,re,Si,ze,Pn,Qe,$n,Ke,ae,ne=class{constructor(t){v(this,De);v(this,He);v(this,Dt);v(this,Ue);v(this,se);v(this,_t);v(this,We);v(this,re);v(this,ze);v(this,Qe);v(this,yt,null);v(this,Z,null);v(this,gt,null);v(this,z,null);v(this,st,null);v(this,U,null);v(this,Y,null);v(this,dt,null);v(this,B,null);v(this,pt,new N.ValueSubject(!1));v(this,Bt,new Set);v(this,W,null);v(this,Ft,null);v(this,H,null);v(this,L,null);v(this,vt,ci());v(this,Vt,null);O(this,"state",{prevChapter$:new N.ValueSubject(null),isInitialChapter$:new N.ValueSubject(!1),isEndChapter$:new N.ValueSubject(!1),isInteractiveExpectation$:new N.ValueSubject(!1),calledByInteractive$:new N.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new N.ValueSubject(!1),disabledControls$:new N.ValueSubject(!1),interactiveRanges$:new N.ValueSubject([]),isInteractiveTime$:new N.ValueSubject(!1)});O(this,"events",{noInteraction$:new N.Subject});O(this,"emitPlayerChanged",t=>{a(this,L).emit(y.playerChanged,t)});v(this,wi,()=>{a(this,Y).fns.forEach(n=>n());let t=this.options.player.info.position$.getValue()*1e3,e=(a(this,B).chapter.containers||[]).filter(n=>n.startTime>=Math.floor(t));for(let n of e){a(this,U).remove({timestamp:1/0,priority:"container",initiator:n.id});for(let r of n.controls)a(this,U).remove({timestamp:1/0,priority:"control",initiator:r.id});a(this,Z).find(r=>r.container.container.id===n.id).reset()}});v(this,Ge,()=>{a(this,yt).calc(),a(this,Y).requestAnimation()});v(this,Rt,(t=!0)=>{a(this,Z).forEach(e=>{!t&&e.isPermanentText||(a(this,Y).removeFn(e.whilePlaying),e.destroy())})});v(this,Ke,t=>{let{interactiveRanges$:e}=this.state,r=e.getValue().map(s=>b(p({},s),{subjects:s.subjects.filter(l=>l!==t)}));e.next(r)});v(this,ae,()=>{a(this,Vt)&&(clearTimeout(a(this,Vt)),m(this,Vt,null))});var e;this.options=b(p(p({},An),t),{config:p(p({},An.config),t.config)}),m(this,Z,[]),this.factories=new Map([["choice",be]]),this.rootElement=Cs(),this.options.parentElement.append(this.rootElement),m(this,L,new jt),m(this,st,new N.Subscription),m(this,gt,new $e),m(this,z,new te({interactiveController:this,globalEventEmitter:a(this,L),videoId:(e=this.options.projectInfo)==null?void 0:e.videoId,historyApi:this.options.historyApi,settings:{maxLength:this.options.config.historyMaxLength,initChapterId:this.options.initChapterId}})),this.options.lastFrame&&m(this,H,new Be({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:n=>a(this,L).emit(y.errors,new S(S.Severity.RECOVERABLE,S.Category.SEAMLESS,n))})),a(this,gt).listen(this.rootElement,"mousedown",n=>n.stopPropagation()),a(this,gt).listen(this.rootElement,"mouseup",n=>n.stopPropagation()),m(this,B,new xt(this.options.loaders,n=>a(this,L).emit(y.errors,new S(S.Severity.RECOVERABLE,S.Category.MANIFEST,n)))),m(this,U,bi(this.options.player)),m(this,Y,new Se),m(this,dt,Ei({player:this.options.player,interactiveEvents:a(this,U),globalEventEmitter:a(this,L),removeControllers:a(this,Rt)})),m(this,yt,bn(()=>{var n,r,s;return{player:(n=this.options)==null?void 0:n.player,parentElement:(r=this.options)==null?void 0:r.parentElement,fns:(s=this.options)!=null&&s.lastFrame?[()=>{a(this,H).updateCanvasDimensions(!0)}]:[]}})),this.options.graph&&m(this,W,new Qt({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:n=>{this.setChapter({chapterId:n}),a(this,L).emit(y.graph,{type:Pt.watchAgainClicked,chapterId:n})},onError:n=>a(this,L).emit(y.errors,new S(S.Severity.RECOVERABLE,S.Category.LOADERS,{message:n}))})),$(this,De,Ln).call(this,this.options.initSeamless),this.isFirstChapterFetched=!1,this.appState=ht.created}getStatEvents(){return{click$:new N.Observable(t=>{a(this,L).on(y.graph,({type:e,visibility:n})=>{e==="visibility"&&t.next(n?"OPEN_GRAPH":"CLOSE_GRAPH"),e==="watchAgainClicked"&&t.next("WATCH_AGAIN")}),a(this,L).on(y.interactives,({type:e,subjectName:n,subjectType:r})=>{e!=="action-choice"||n!=="control"||(r==="Button"&&t.next("GO_NEXT_BUTTON"),r==="Area"&&t.next("GO_NEXT_AREA"))})}),nextMovie$:new N.Observable(t=>{a(this,L).on(y.playerChanged,({config:e})=>{e!=null&&e.unitedVideoId&&t.next(e.unitedVideoId)})})}}setPlayer(t){$(this,Dt,Fe).call(this),this.options.player=t,a(this,vt).setPlayer(this.options.player),a(this,U)?a(this,U).setPlayer(this.options.player):m(this,U,bi(this.options.player)),m(this,dt,Ei({player:this.options.player,interactiveEvents:a(this,U),globalEventEmitter:a(this,L),removeControllers:()=>a(this,Rt).call(this,!1)})),this.appState===ht.initiated&&($(this,se,Ti).call(this),$(this,_t,ie).call(this,a(this,B).chapter))}setManifest(t){return V(this,null,function*(){$(this,Dt,Fe).call(this),this.isFirstChapterFetched=!1;let e=yield a(this,B).setManifest(t);return a(this,W)&&(yield a(this,W).handleManifestChange(e.manifest)),yield a(this,z).setManifest(e.manifest),a(this,L).emit(y.manifestChanged,{manifest:e.manifest}),$(this,_t,ie).call(this,a(this,B).chapter),e.manifest})}setVisitedChapters(t){var e;Array.isArray(t)&&((e=a(this,W))==null||e.setVisitedChapters(t))}updateGraphVideosInfo(t){var e;Array.isArray(t)&&((e=a(this,W))==null||e.updateVideosInfo(t))}setChapter(){return V(this,arguments,function*({chapterId:t,pushToHistory:e=!0}={}){var o;$(this,Dt,Fe).call(this),a(this,H)&&this.isFirstChapterFetched&&(a(this,H).draw(),a(this,H).show()),(0,N.getCurrentBrowser)().browser===N.CurrentClientBrowser.Safari&&(yield Mn(35));let{chapter:r,media:s,graph:l}=yield t?a(this,B).setNext(t):a(this,B).setInitial();return e&&$(this,Qe,$n).call(this,r.id),this.state.isInitialChapter$.next(a(this,B).isInitialChapter()),this.state.isEndChapter$.next(a(this,B).isEndChapter()),a(this,W)&&a(this,W).handleChapterChange(l),(o=a(this,H))==null||o.setCurrentChapter(this.getCurrentChapter().chapter),a(this,L).emit(y.chapterChanged,{chapter:r,media:s,graph:l}),$(this,_t,ie).call(this,a(this,B).chapter),m(this,Bt,new Set),this.isFirstChapterFetched=!0,{chapter:r,media:s,graph:l}})}toggleGraphView(t=!0){a(this,W)&&(t?(a(this,W).show(),a(this,pt).next(!1)):(a(this,W).hide(),$(this,re,Si).call(this)),a(this,L).emit(y.graph,{type:Pt.visibility,visibility:t}))}init(){a(this,B).chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.appState===ht.created&&(a(this,yt).resizeObserver.observe(this.options.fullscreenTargetElement),$(this,se,Ti).call(this),this.appState=ht.initiated,$(this,_t,ie).call(this,a(this,B).chapter))}deadEndCheck(){var n,r;return!((r=(n=a(this,U))==null?void 0:n.getPreparedToExecActions())!=null?r:[]).some(s=>s.actionType===j.setNextBranch)}allControlsAreRemoved(){return!a(this,Z).some(e=>!e.container.isRemoved)}isEndedExpectation(){var n;if(!((n=this.options)!=null&&n.player)||!a(this,Z))return!1;let t=this.options.player.info.position$.getValue(),e=this.options.player.info.duration$.getValue();return t===e&&a(this,Z).some(r=>{let s=r.container.container;return!s.isRemoved&&s.endTime===null&&It(s.events)})}playPrevChapter(){var t;(t=a(this,z))==null||t.goBack()}setDisabledControls(t){this.state.disabledControls$.next(t)}isSupport(t=a(this,B).manifest){return Kt(t.metadata.version)}getInitialVideoInfo(){return{videoId:a(this,z).getInitialVideoId(),chapterId:a(this,z).getInitialChapterId()}}getHistoryState(){return a(this,z).state}getIsSeekable(){return a(this,pt)}getInteractiveRanges(){var t;return hn((t=a(this,B).chapter)==null?void 0:t.containers)}getNextInteractiveStartTime(t){return a(this,vt).getNextInteractiveTime(t)}getChapterBranches(t){return a(this,B).getBranches(t)}getCurrentChapter(){return a(this,B).getCurrent()}getCurrentManifest(){return a(this,B).manifest}addFactory(t,e){this.factories.set(t.trim().toLowerCase(),e)}removeFactory(t){this.factories.delete(t.trim().toLowerCase())}on(...t){return a(this,L).on(...t),this}off(...t){return a(this,L).off(...t),this}once(...t){return a(this,L).once(...t),this}destroy(){var t,e;a(this,Rt).call(this),m(this,Z,void 0),this.state=void 0,(t=a(this,W))==null||t.destroy(),m(this,W,void 0),a(this,yt).release(),m(this,yt,void 0),m(this,dt,void 0),a(this,Y).release(),m(this,Y,void 0),a(this,U).release(),m(this,U,void 0),a(this,B).release(),m(this,dt,void 0),a(this,gt).release(),m(this,gt,void 0),a(this,st).unsubscribe(),m(this,st,void 0),a(this,L).reset(),m(this,L,void 0),(e=a(this,H))==null||e.destroy(),m(this,H,void 0),this.rootElement.remove(),this.rootElement=void 0,a(this,z).destroy(),m(this,z,void 0),this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.appState=ht.destroyed}};yt=new WeakMap,Z=new WeakMap,gt=new WeakMap,z=new WeakMap,st=new WeakMap,U=new WeakMap,Y=new WeakMap,dt=new WeakMap,B=new WeakMap,pt=new WeakMap,Bt=new WeakMap,W=new WeakMap,Ft=new WeakMap,H=new WeakMap,L=new WeakMap,vt=new WeakMap,Vt=new WeakMap,De=new WeakSet,Ln=function(t=!1){a(this,L).on(y.historyInited,r=>V(this,[r],function*({initChapterId:e,videosInfo:n=[]}){t&&(yield $(this,He,Nn).call(this,{initialChapter:e,videosInfo:n}))})),a(this,L).on(y.interactives,e=>V(this,null,function*(){var n,r;if(e.type===_.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((n=e.payload)==null?void 0:n.behaviour)==="change-chapter"){let{chapterId:l}=e.payload;this.setChapter({chapterId:l})}if(((r=e.payload)==null?void 0:r.behaviour)==="change-manifest"){let{manifestURL:l}=e.payload;this.setManifest(l)}let s=e.type==="action-execution";s&&e.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):s&&e.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)}e.type===_.containerRemoved&&a(this,Ke).call(this,e.subjectId)})),a(this,L).on(y.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})},He=new WeakSet,Nn=function(n){return V(this,arguments,function*({source:t,videosInfo:e=[]}){m(this,Ft,vi(this));let r=document.createElement("div");a(this,Ft).on(Yt.activePlayerChanged,this.emitPlayerChanged);let{player:s,config:l}=yield a(this,Ft).init({source:t,initialChapter:a(this,z).getInitialChapterId(),container:r});return this.updateGraphVideosInfo(e),{player:s,config:l}})},Dt=new WeakSet,Fe=function(){var t;this.appState===ht.ready&&(a(this,Rt).call(this),m(this,Z,[]),a(this,Y).release(),(t=a(this,U))==null||t.release(),this.appState=ht.initiated,a(this,pt).next(!1),a(this,ae).call(this))},wi=new WeakMap,Ge=new WeakMap,Ue=new WeakSet,kn=function(t){(!a(this,W)||a(this,W).isHidden)&&$(this,re,Si).call(this);let e=t*1e3,r=this.getInteractiveRanges().findLast(({range:s})=>e>=s[1]);if(r){let s=r.range.join("-");a(this,Bt).has(s)||(a(this,Bt).add(s),a(this,L).emit(y.interactives,{type:_.rangeEnded,payload:r,visibility:!0}))}},se=new WeakSet,Ti=function(){if(a(this,st).unsubscribe(),a(this,st).add(this.options.player.events.started$.pipe((0,N.once)()).subscribe(a(this,Ge))).add(this.options.player.events.playing$.subscribe(a(this,Y).requestAnimation)).add(this.options.player.events.willPause$.subscribe(a(this,Y).cancelAnimation)).add(this.options.player.info.position$.subscribe($(this,Ue,kn).bind(this))).add(a(this,B).prevChapter$.subscribe(t=>this.state.prevChapter$.next(t))).add((0,N.combine)({position:this.options.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:t,interactiveRanges:e,isInteractiveExpectation:n})=>{let r;if(n)r=!0;else{let s=t*1e3;r=!!(e==null?void 0:e.find(({range:[o,c],subjects:h})=>o<s&&s<c&&h.length))}r!==this.state.isInteractiveTime$.getValue()&&(this.state.isInteractiveTime$.next(r),r?m(this,Vt,setTimeout(()=>{this.events.noInteraction$.next()},this.options.config.noInteractionEventTimeout)):a(this,ae).call(this))})),this.options.lastFrame){let t=(0,N.isMobile)();a(this,st).add(this.options.player.info.duration$.subscribe(e=>{a(this,H).setVideoDuration(e*1e3)})).add(this.options.player.experimental.element$.subscribe(e=>{e&&a(this,H).setVideoElement(e)})).add(this.options.player.events.firstFrame$.subscribe(()=>{a(this,H).reset(),setTimeout(()=>{a(this,H).hide(),a(this,H).lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(()=>{this.hasQualityRecentlyChanged&&t?this.hasQualityRecentlyChanged=!1:a(this,H).onSeek()})),t&&a(this,st).add(this.options.player.events.qualityWillChange$.subscribe(()=>{a(this,H).draw(!0),a(this,H).show(),this.hasQualityRecentlyChanged=!0})).add(this.options.player.info.playbackState$.subscribe(e=>{e==="playing"&&a(this,H).hide()}))}},Rt=new WeakMap,_t=new WeakSet,ie=function(t){a(this,B).chapter&&this.appState===ht.initiated&&(a(this,dt).setManifestChapterEvents(t),m(this,Z,$(this,We,jn).call(this,t)),a(this,U).containersEventsCallState.setData(t.containers),a(this,vt).setContainers(a(this,Z).map(e=>e.container.container).filter(e=>!_e(e.controls))),this.options.lastFrame&&a(this,Y).addFn(()=>{a(this,H).onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=ht.ready)},We=new WeakSet,jn=function(t){var e,n;return(n=(e=t==null?void 0:t.containers)==null?void 0:e.reduce((r,s)=>{let l=s.type.trim().toLowerCase(),o=this.factories.get(l);if(o){let c=new Me({player:this.options.player,container:o(s,this.rootElement),branches:a(this,B).chapter.branches,selectBranches:a(this,dt),interactiveEvents:a(this,U),globalEventEmitter:a(this,L),ignoreContainerEvent:()=>dn(s,a(this,Z)),permanentTextControls:this.options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{a(this,vt).deleteContainer(s.id)}});return a(this,Y).addFn(c.whilePlaying,!0),[...r,c]}return[...r]},[]))!=null?n:[]},re=new WeakSet,Si=function(){if(this.state.isInteractiveExpectation$.getValue()){a(this,pt).next(!1);return}let e=a(this,pt).getValue(),n=!!a(this,vt).getNextInteractiveTime();(n&&!e||!n&&e)&&a(this,pt).next(!e)},ze=new WeakSet,Pn=function(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)},Qe=new WeakSet,$n=function(t){var o;if($(this,ze,Pn).call(this),!a(this,z).inited)return;let e=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),r=(o=n&&nt(n)&&qt(n))!=null?o:!1,s=a(this,B).manifest.metadata.initChapterId===t,l=a(this,z).state.history$.getValue();if(s||r&&e){a(this,z).updateHistory([t]);return}l.at(-1)!==t&&a(this,z).updateHistory([...l,t])},Ke=new WeakMap,ae=new WeakMap;var On={Container:kt,createChoiceContainer:be,createAreaControl:fe,createButtonControl:ye,createRelativeLayout:Ui,getRootEl:le,classnamesPrefix:G};var Es={version:Oi};
|
|
23
|
+
`,t}var Ce,Z,xe,W,pe,U,J,fe,B,me,Qe,z,Ye,H,j,Ie,Le,lr,Wa,hr,Ka,Xe,cr,Si,ur,dr,Qa,vt,xi,je,Ne,mt,pr,Ya,gt,Ii,fr,Xa,mr,Za,yr,bt,yt=class{constructor(e){C(this,lr);C(this,hr);C(this,Xe);C(this,dr);C(this,vt);C(this,Ne);C(this,pr);C(this,gt);C(this,fr);C(this,mr);C(this,Ce,null);C(this,Z,null);C(this,xe,null);C(this,W,null);C(this,pe,null);C(this,U,null);C(this,J,null);C(this,fe,null);C(this,B,null);C(this,me,new $.ValueSubject(!1));C(this,Qe,new Set);C(this,z,null);C(this,Ye,null);C(this,H,null);C(this,j,null);C(this,Ie,Ar());C(this,Le,null);F(this,"state",{prevChapter$:new $.ValueSubject(null),isInitialChapter$:new $.ValueSubject(!1),isEndChapter$:new $.ValueSubject(!1),isInteractiveExpectation$:new $.ValueSubject(!1),calledByInteractive$:new $.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new $.ValueSubject(!1),disabledControls$:new $.ValueSubject(!1),interactiveRanges$:new $.ValueSubject([]),isInteractiveTime$:new $.ValueSubject(!1)});F(this,"events",{noInteraction$:new $.Subject});F(this,"emitPlayerChanged",e=>{a(this,j).emit(b.playerChanged,e)});C(this,Si,()=>{a(this,J).fns.forEach(i=>i());let e=this.options.player.info.position$.getValue()*1e3,r=(a(this,B).chapter.containers||[]).filter(i=>i.startTime>=Math.floor(e));for(let i of r){a(this,U).remove({timestamp:1/0,priority:"container",initiator:i.id});for(let n of i.controls)a(this,U).remove({timestamp:1/0,priority:"control",initiator:n.id});a(this,Z).find(n=>n.container.container.id===i.id).reset()}});C(this,ur,()=>{a(this,Ce).calc(),a(this,J).requestAnimation()});C(this,je,(e=!0)=>{a(this,Z).forEach(r=>{!e&&r.isPermanentText||(a(this,J).removeFn(r.whilePlaying),r.destroy())})});C(this,yr,e=>{let{interactiveRanges$:r}=this.state,n=r.getValue().map(s=>x(d({},s),{subjects:s.subjects.filter(l=>l!==e)}));r.next(n)});C(this,bt,()=>{a(this,Le)&&(clearTimeout(a(this,Le)),g(this,Le,null))});var r;this.options=x(d(d({},za),e),{config:d(d({},za.config),e.config)}),g(this,Z,[]),this.factories=new Map([["choice",Ot]]),this.rootElement=Zl(),this.options.parentElement.append(this.rootElement),g(this,j,new qe),g(this,pe,new $.Subscription),g(this,xe,new sr),g(this,W,new pt({interactiveController:this,globalEventEmitter:a(this,j),videoId:(r=this.options.projectInfo)==null?void 0:r.videoId,historyApi:this.options.historyApi,settings:{maxLength:this.options.config.historyMaxLength,initChapterId:this.options.initChapterId}})),this.options.lastFrame&&g(this,H,new or({parentElement:this.options.parentElement,interactivesRootElement:this.rootElement,onError:i=>a(this,j).emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.SEAMLESS,i))})),a(this,xe).listen(this.rootElement,"mousedown",i=>i.stopPropagation()),a(this,xe).listen(this.rootElement,"mouseup",i=>i.stopPropagation()),g(this,B,new Re(this.options.loaders,i=>a(this,j).emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.MANIFEST,i)))),g(this,U,Fr(this.options.player)),g(this,J,new Ft),g(this,fe,qr({player:this.options.player,interactiveEvents:a(this,U),globalEventEmitter:a(this,j),removeControllers:a(this,je)})),g(this,Ce,gn(()=>{var i,n,s;return{player:(i=this.options)==null?void 0:i.player,parentElement:(n=this.options)==null?void 0:n.parentElement,fns:(s=this.options)!=null&&s.lastFrame?[()=>{a(this,H).updateCanvasDimensions(!0)}]:[]}})),this.options.graph&&g(this,z,new it({root:this.options.parentElement,lang:this.options.lang,onOpenPreviewClick:i=>{this.setChapter({chapterId:i}),a(this,j).emit(b.graph,{type:De.watchAgainClicked,chapterId:i})},onError:i=>a(this,j).emit(b.errors,new R(R.Severity.RECOVERABLE,R.Category.LOADERS,{message:i}))})),k(this,lr,Wa).call(this,this.options.initSeamless),this.isFirstChapterFetched=!1,this.appState=de.created}getStatEvents(){return{click$:new $.Observable(e=>{a(this,j).on(b.graph,({type:r,visibility:i})=>{r==="visibility"&&e.next(i?"OPEN_GRAPH":"CLOSE_GRAPH"),r==="watchAgainClicked"&&e.next("WATCH_AGAIN")}),a(this,j).on(b.interactives,({type:r,subjectName:i,subjectType:n})=>{r!=="action-choice"||i!=="control"||(n==="Button"&&e.next("GO_NEXT_BUTTON"),n==="Area"&&e.next("GO_NEXT_AREA"))})}),nextMovie$:new $.Observable(e=>{a(this,j).on(b.playerChanged,({config:r})=>{r!=null&&r.unitedVideoId&&e.next(r.unitedVideoId)})})}}setPlayer(e){k(this,Xe,cr).call(this),this.options.player=e,a(this,Ie).setPlayer(this.options.player),a(this,U)?a(this,U).setPlayer(this.options.player):g(this,U,Fr(this.options.player)),g(this,fe,qr({player:this.options.player,interactiveEvents:a(this,U),globalEventEmitter:a(this,j),removeControllers:()=>a(this,je).call(this,!1)})),this.appState===de.initiated&&(k(this,vt,xi).call(this),k(this,Ne,mt).call(this,a(this,B).chapter))}setManifest(e){return A(this,null,function*(){k(this,Xe,cr).call(this),this.isFirstChapterFetched=!1;let r=yield a(this,B).setManifest(e);return a(this,z)&&(yield a(this,z).handleManifestChange(r.manifest)),yield a(this,W).setManifest(r.manifest),a(this,j).emit(b.manifestChanged,{manifest:r.manifest}),k(this,Ne,mt).call(this,a(this,B).chapter),r.manifest})}setVisitedChapters(e){var r;Array.isArray(e)&&((r=a(this,z))==null||r.setVisitedChapters(e))}updateGraphVideosInfo(e){var r;Array.isArray(e)&&((r=a(this,z))==null||r.updateVideosInfo(e))}setChapter(){return A(this,arguments,function*({chapterId:e,pushToHistory:r=!0}={}){var o;k(this,Xe,cr).call(this),a(this,H)&&this.isFirstChapterFetched&&(a(this,H).draw(),a(this,H).show()),(0,$.getCurrentBrowser)().browser===$.CurrentClientBrowser.Safari&&(yield Ua(35));let{chapter:n,media:s,graph:l}=yield e?a(this,B).setNext(e):a(this,B).setInitial();return r&&k(this,mr,Za).call(this,n.id),this.state.isInitialChapter$.next(a(this,B).isInitialChapter()),this.state.isEndChapter$.next(a(this,B).isEndChapter()),a(this,z)&&a(this,z).handleChapterChange(l),(o=a(this,H))==null||o.setCurrentChapter(this.getCurrentChapter().chapter),a(this,j).emit(b.chapterChanged,{chapter:n,media:s,graph:l}),k(this,Ne,mt).call(this,a(this,B).chapter),g(this,Qe,new Set),this.isFirstChapterFetched=!0,{chapter:n,media:s,graph:l}})}toggleGraphView(e=!0){a(this,z)&&(e?(a(this,z).show(),a(this,me).next(!1)):(a(this,z).hide(),k(this,gt,Ii).call(this)),a(this,j).emit(b.graph,{type:De.visibility,visibility:e}))}init(){a(this,B).chapter&&this.options.parentElement&&this.options.player&&this.options.fullscreenTargetElement&&this.appState===de.created&&(a(this,Ce).resizeObserver.observe(this.options.fullscreenTargetElement),k(this,vt,xi).call(this),this.appState=de.initiated,k(this,Ne,mt).call(this,a(this,B).chapter))}deadEndCheck(){var i,n;return!((n=(i=a(this,U))==null?void 0:i.getPreparedToExecActions())!=null?n:[]).some(s=>s.actionType===P.setNextBranch)}allControlsAreRemoved(){return!a(this,Z).some(r=>!r.container.isRemoved)}isEndedExpectation(){var i;if(!((i=this.options)!=null&&i.player)||!a(this,Z))return!1;let e=this.options.player.info.position$.getValue(),r=this.options.player.info.duration$.getValue();return e===r&&a(this,Z).some(n=>{let s=n.container.container;return!s.isRemoved&&s.endTime===null&&_e(s.events)})}playPrevChapter(){var e;(e=a(this,W))==null||e.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=a(this,B).manifest){return nt(e.metadata.version)}getInitialVideoInfo(){return{videoId:a(this,W).getInitialVideoId(),chapterId:a(this,W).getInitialChapterId()}}getHistoryState(){return a(this,W).state}getIsSeekable(){return a(this,me)}getInteractiveRanges(){var e;return mn((e=a(this,B).chapter)==null?void 0:e.containers)}getNextInteractiveStartTime(e){return a(this,Ie).getNextInteractiveTime(e)}getChapterBranches(e){return a(this,B).getBranches(e)}getCurrentChapter(){return a(this,B).getCurrent()}getCurrentManifest(){return a(this,B).manifest}addFactory(e,r){this.factories.set(e.trim().toLowerCase(),r)}removeFactory(e){this.factories.delete(e.trim().toLowerCase())}on(...e){return a(this,j).on(...e),this}off(...e){return a(this,j).off(...e),this}once(...e){return a(this,j).once(...e),this}destroy(){var e,r;a(this,je).call(this),g(this,Z,void 0),this.state=void 0,(e=a(this,z))==null||e.destroy(),g(this,z,void 0),a(this,Ce).release(),g(this,Ce,void 0),g(this,fe,void 0),a(this,J).release(),g(this,J,void 0),a(this,U).release(),g(this,U,void 0),a(this,B).release(),g(this,fe,void 0),a(this,xe).release(),g(this,xe,void 0),a(this,pe).unsubscribe(),g(this,pe,void 0),a(this,j).reset(),g(this,j,void 0),(r=a(this,H))==null||r.destroy(),g(this,H,void 0),this.rootElement.remove(),this.rootElement=void 0,a(this,W).destroy(),g(this,W,void 0),this.factories=void 0,this.options=void 0,this.isFirstChapterFetched=!1,this.appState=de.destroyed}};Ce=new WeakMap,Z=new WeakMap,xe=new WeakMap,W=new WeakMap,pe=new WeakMap,U=new WeakMap,J=new WeakMap,fe=new WeakMap,B=new WeakMap,me=new WeakMap,Qe=new WeakMap,z=new WeakMap,Ye=new WeakMap,H=new WeakMap,j=new WeakMap,Ie=new WeakMap,Le=new WeakMap,lr=new WeakSet,Wa=function(e=!1){a(this,j).on(b.historyInited,n=>A(this,[n],function*({initChapterId:r,videosInfo:i=[]}){e&&(yield k(this,hr,Ka).call(this,{initialChapter:r,videosInfo:i}))})),a(this,j).on(b.interactives,r=>A(this,null,function*(){var i,n;if(r.type===M.actionExecution){if(this.state.calledByInteractive$.next(!0),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),((i=r.payload)==null?void 0:i.behaviour)==="change-chapter"){let{chapterId:l}=r.payload;this.setChapter({chapterId:l})}if(((n=r.payload)==null?void 0:n.behaviour)==="change-manifest"){let{manifestURL:l}=r.payload;this.setManifest(l)}let s=r.type==="action-execution";s&&r.actionType==="expect"?this.state.isInteractiveExpectation$.next(!0):s&&r.actionType==="after-expect"&&this.state.isInteractiveExpectation$.next(!1)}r.type===M.containerRemoved&&a(this,yr).call(this,r.subjectId)})),a(this,j).on(b.manifestChanged,()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})},hr=new WeakSet,Ka=function(i){return A(this,arguments,function*({source:e,videosInfo:r=[]}){g(this,Ye,$r(this));let n=document.createElement("div");a(this,Ye).on(ct.activePlayerChanged,this.emitPlayerChanged);let{player:s,config:l}=yield a(this,Ye).init({source:e,initialChapter:a(this,W).getInitialChapterId(),container:n});return this.updateGraphVideosInfo(r),{player:s,config:l}})},Xe=new WeakSet,cr=function(){var e;this.appState===de.ready&&(a(this,je).call(this),g(this,Z,[]),a(this,J).release(),(e=a(this,U))==null||e.release(),this.appState=de.initiated,a(this,me).next(!1),a(this,bt).call(this))},Si=new WeakMap,ur=new WeakMap,dr=new WeakSet,Qa=function(e){(!a(this,z)||a(this,z).isHidden)&&k(this,gt,Ii).call(this);let r=e*1e3,n=this.getInteractiveRanges().findLast(({range:s})=>r>=s[1]);if(n){let s=n.range.join("-");a(this,Qe).has(s)||(a(this,Qe).add(s),a(this,j).emit(b.interactives,{type:M.rangeEnded,payload:n,visibility:!0}))}},vt=new WeakSet,xi=function(){a(this,pe).unsubscribe(),a(this,pe).add(this.options.player.events.started$.pipe((0,$.once)()).subscribe(a(this,ur))).add(this.options.player.events.playing$.subscribe(a(this,J).requestAnimation)).add(this.options.player.events.willPause$.subscribe(a(this,J).cancelAnimation)).add(this.options.player.info.position$.subscribe(k(this,dr,Qa).bind(this))).add(a(this,B).prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add((0,$.combine)({position:this.options.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:r,isInteractiveExpectation:i})=>{let n;if(i)n=!0;else{let s=e*1e3;n=!!(r==null?void 0:r.find(({range:[o,c],subjects:h})=>o<s&&s<c&&h.length))}n!==this.state.isInteractiveTime$.getValue()&&(this.state.isInteractiveTime$.next(n),n?g(this,Le,setTimeout(()=>{this.events.noInteraction$.next()},this.options.config.noInteractionEventTimeout)):a(this,bt).call(this))})),this.options.lastFrame&&a(this,pe).add(this.options.player.info.duration$.subscribe(e=>{a(this,H).setVideoDuration(e*1e3)})).add(this.options.player.experimental.element$.subscribe(e=>{e&&a(this,H).setVideoElement(e)})).add(this.options.player.events.firstFrame$.subscribe(()=>{a(this,H).reset(),setTimeout(()=>{a(this,H).hide(),a(this,H).lastFrameCanvas.clear()},50)})).add(this.options.player.events.seeked$.subscribe(a(this,H).onSeek))},je=new WeakMap,Ne=new WeakSet,mt=function(e){a(this,B).chapter&&this.appState===de.initiated&&(a(this,fe).setManifestChapterEvents(e),g(this,Z,k(this,pr,Ya).call(this,e)),a(this,U).containersEventsCallState.setData(e.containers),a(this,Ie).setContainers(a(this,Z).map(r=>r.container.container).filter(r=>!Gt(r.controls))),this.options.lastFrame&&a(this,J).addFn(()=>{a(this,H).onEachTick(this.options.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=de.ready)},pr=new WeakSet,Ya=function(e){var r,i;return(i=(r=e==null?void 0:e.containers)==null?void 0:r.reduce((n,s)=>{let l=s.type.trim().toLowerCase(),o=this.factories.get(l);if(o){let c=new Ut({player:this.options.player,container:o(s,this.rootElement),branches:a(this,B).chapter.branches,selectBranches:a(this,fe),interactiveEvents:a(this,U),globalEventEmitter:a(this,j),ignoreContainerEvent:()=>ln(s,a(this,Z)),permanentTextControls:this.options.permanentTextControls,disabledControls$:this.state.disabledControls$,onRemove:()=>{a(this,Ie).deleteContainer(s.id)}});return a(this,J).addFn(c.whilePlaying,!0),[...n,c]}return[...n]},[]))!=null?i:[]},gt=new WeakSet,Ii=function(){if(this.state.isInteractiveExpectation$.getValue()){a(this,me).next(!1);return}let r=a(this,me).getValue(),i=!!a(this,Ie).getNextInteractiveTime();(i&&!r||!i&&r)&&a(this,me).next(!r)},fr=new WeakSet,Xa=function(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)},mr=new WeakSet,Za=function(e){var o;if(k(this,fr,Xa).call(this),!a(this,W).inited)return;let r=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),i=this.state.prevChapter$.getValue(),n=(o=i&&se(i)&&at(i))!=null?o:!1,s=a(this,B).manifest.metadata.initChapterId===e,l=a(this,W).state.history$.getValue();if(s||n&&r){a(this,W).updateHistory([e]);return}l.at(-1)!==e&&a(this,W).updateHistory([...l,e])},yr=new WeakMap,bt=new WeakMap;var Ja={Container:Be,createChoiceContainer:Ot,createAreaControl:_t,createButtonControl:Vt,createRelativeLayout:Hi,getRootEl:xt,classnamesPrefix:G};var Jl={version:ki};
|