@vkontakte/videoplayer-interactive 1.0.10-dev.b4e1f23a.0 → 1.0.10-dev.c85f7c9e.0

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