@vkontakte/videoplayer-interactive 1.0.60-dev.7be47b47.0 → 1.0.60-dev.81767d01c.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es2018.cjs ADDED
@@ -0,0 +1,285 @@
1
+ /**
2
+ * @vkontakte/videoplayer-interactive v1.0.60-dev.81767d01c.0
3
+ * Wed, 11 Mar 2026 15:48:05 GMT
4
+ * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-60/doc/
5
+ */
6
+ var e=require(`@oxc-project/runtime/helpers/defineProperty`),t=require(`@oxc-project/runtime/helpers/classPrivateFieldInitSpec`),n=require(`@oxc-project/runtime/helpers/classPrivateFieldSet2`),r=require(`@oxc-project/runtime/helpers/classPrivateFieldGet2`),i=Object.create,a=Object.getPrototypeOf,o=Object.defineProperty,s=Object.getOwnPropertyNames,c=Object.getOwnPropertyDescriptor,l=Object.prototype.hasOwnProperty;function u(e){return this[e]}var d,f,p=(e,t,n)=>{var r=typeof e==`object`&&!!e;if(r){var c=t?d??=new WeakMap:f??=new WeakMap,p=c.get(e);if(p)return p}n=e==null?{}:i(a(e));let m=t||!e||!e.__esModule?o(n,`default`,{value:e,enumerable:!0}):n;for(let t of s(e))l.call(m,t)||o(m,t,{get:u.bind(e,t),enumerable:!0});return r&&c.set(e,m),m},m=e=>{var t=(h??=new WeakMap).get(e),n;if(t)return t;if(t=o({},`__esModule`,{value:!0}),e&&typeof e==`object`||typeof e==`function`)for(var r of s(e))l.call(t,r)||o(t,r,{get:u.bind(e,r),enumerable:!(n=c(e,r))||n.enumerable});return h.set(e,t),t},h,g=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),_=e=>e;function v(e,t){this[e]=_.bind(null,t)}var y=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0,configurable:!0,set:v.bind(t,n)})},b=g((e,t)=>{var n=function(e){return e&&e.Math===Math&&e};t.exports=n(typeof globalThis==`object`&&globalThis)||n(typeof window==`object`&&window)||n(typeof self==`object`&&self)||n(typeof global==`object`&&global)||n(typeof e==`object`&&e)||function(){return this}()||Function(`return this`)()}),x=g((e,t)=>{t.exports=function(e){try{return!!e()}catch{return!0}}}),S=g((e,t)=>{t.exports=!x()(function(){var e=function(){}.bind();return typeof e!=`function`||e.hasOwnProperty(`prototype`)})}),C=g((e,t)=>{var n=S(),r=Function.prototype,i=r.apply,a=r.call;t.exports=typeof Reflect==`object`&&Reflect.apply||(n?a.bind(i):function(){return a.apply(i,arguments)})}),w=g((e,t)=>{var n=S(),r=Function.prototype,i=r.call,a=n&&r.bind.bind(i,i);t.exports=n?a:function(e){return function(){return i.apply(e,arguments)}}}),T=g((e,t)=>{var n=w(),r=n({}.toString),i=n(``.slice);t.exports=function(e){return i(r(e),8,-1)}}),E=g((e,t)=>{var n=T(),r=w();t.exports=function(e){if(n(e)===`Function`)return r(e)}}),D=g((e,t)=>{var n=typeof document==`object`&&document.all;t.exports=n===void 0&&n!==void 0?function(e){return typeof e==`function`||e===n}:function(e){return typeof e==`function`}}),O=g((e,t)=>{t.exports=!x()(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),ee=g((e,t)=>{var n=S(),r=Function.prototype.call;t.exports=n?r.bind(r):function(){return r.apply(r,arguments)}}),te=g(e=>{var t={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor;e.f=n&&!t.call({1:2},1)?function(e){var t=n(this,e);return!!t&&t.enumerable}:t}),ne=g((e,t)=>{t.exports=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}}),re=g((e,t)=>{var n=w(),r=x(),i=T(),a=Object,o=n(``.split);t.exports=r(function(){return!a(`z`).propertyIsEnumerable(0)})?function(e){return i(e)===`String`?o(e,``):a(e)}:a}),ie=g((e,t)=>{t.exports=function(e){return e==null}}),ae=g((e,t)=>{var n=ie(),r=TypeError;t.exports=function(e){if(n(e))throw new r(`Can't call method on `+e);return e}}),oe=g((e,t)=>{var n=re(),r=ae();t.exports=function(e){return n(r(e))}}),se=g((e,t)=>{var n=D();t.exports=function(e){return typeof e==`object`?e!==null:n(e)}}),ce=g((e,t)=>{t.exports={}}),le=g((e,t)=>{var n=ce(),r=b(),i=D(),a=function(e){return i(e)?e:void 0};t.exports=function(e,t){return arguments.length<2?a(n[e])||a(r[e]):n[e]&&n[e][t]||r[e]&&r[e][t]}}),ue=g((e,t)=>{t.exports=w()({}.isPrototypeOf)}),de=g((e,t)=>{var n=b().navigator,r=n&&n.userAgent;t.exports=r?String(r):``}),fe=g((e,t)=>{var n=b(),r=de(),i=n.process,a=n.Deno,o=i&&i.versions||a&&a.version,s=o&&o.v8,c,l;s&&(c=s.split(`.`),l=c[0]>0&&c[0]<4?1:+(c[0]+c[1])),!l&&r&&(c=r.match(/Edge\/(\d+)/),(!c||c[1]>=74)&&(c=r.match(/Chrome\/(\d+)/),c&&(l=+c[1]))),t.exports=l}),pe=g((e,t)=>{var n=fe(),r=x(),i=b().String;t.exports=!!Object.getOwnPropertySymbols&&!r(function(){var e=Symbol(`symbol detection`);return!i(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&n&&n<41})}),me=g((e,t)=>{t.exports=pe()&&!Symbol.sham&&typeof Symbol.iterator==`symbol`}),he=g((e,t)=>{var n=le(),r=D(),i=ue(),a=me(),o=Object;t.exports=a?function(e){return typeof e==`symbol`}:function(e){var t=n(`Symbol`);return r(t)&&i(t.prototype,o(e))}}),ge=g((e,t)=>{var n=String;t.exports=function(e){try{return n(e)}catch{return`Object`}}}),_e=g((e,t)=>{var n=D(),r=ge(),i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not a function`)}}),ve=g((e,t)=>{var n=_e(),r=ie();t.exports=function(e,t){var i=e[t];return r(i)?void 0:n(i)}}),ye=g((e,t)=>{var n=ee(),r=D(),i=se(),a=TypeError;t.exports=function(e,t){var o,s;if(t===`string`&&r(o=e.toString)&&!i(s=n(o,e))||r(o=e.valueOf)&&!i(s=n(o,e))||t!==`string`&&r(o=e.toString)&&!i(s=n(o,e)))return s;throw new a(`Can't convert object to primitive value`)}}),be=g((e,t)=>{t.exports=!0}),xe=g((e,t)=>{var n=b(),r=Object.defineProperty;t.exports=function(e,t){try{r(n,e,{value:t,configurable:!0,writable:!0})}catch{n[e]=t}return t}}),Se=g((e,t)=>{var n=be(),r=b(),i=xe(),a=`__core-js_shared__`,o=t.exports=r[a]||i(a,{});(o.versions||=[]).push({version:`3.43.0`,mode:n?`pure`:`global`,copyright:`© 2014-2025 Denis Pushkarev (zloirock.ru)`,license:`https://github.com/zloirock/core-js/blob/v3.43.0/LICENSE`,source:`https://github.com/zloirock/core-js`})}),Ce=g((e,t)=>{var n=Se();t.exports=function(e,t){return n[e]||(n[e]=t||{})}}),we=g((e,t)=>{var n=ae(),r=Object;t.exports=function(e){return r(n(e))}}),Te=g((e,t)=>{var n=w(),r=we(),i=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(e,t){return i(r(e),t)}}),Ee=g((e,t)=>{var n=w(),r=0,i=Math.random(),a=n(1.1.toString);t.exports=function(e){return`Symbol(`+(e===void 0?``:e)+`)_`+a(++r+i,36)}}),De=g((e,t)=>{var n=b(),r=Ce(),i=Te(),a=Ee(),o=pe(),s=me(),c=n.Symbol,l=r(`wks`),u=s?c.for||c:c&&c.withoutSetter||a;t.exports=function(e){return i(l,e)||(l[e]=o&&i(c,e)?c[e]:u(`Symbol.`+e)),l[e]}}),Oe=g((e,t)=>{var n=ee(),r=se(),i=he(),a=ve(),o=ye(),s=De(),c=TypeError,l=s(`toPrimitive`);t.exports=function(e,t){if(!r(e)||i(e))return e;var s=a(e,l),u;if(s){if(t===void 0&&(t=`default`),u=n(s,e,t),!r(u)||i(u))return u;throw new c(`Can't convert object to primitive value`)}return t===void 0&&(t=`number`),o(e,t)}}),ke=g((e,t)=>{var n=Oe(),r=he();t.exports=function(e){var t=n(e,`string`);return r(t)?t:t+``}}),Ae=g((e,t)=>{var n=b(),r=se(),i=n.document,a=r(i)&&r(i.createElement);t.exports=function(e){return a?i.createElement(e):{}}}),je=g((e,t)=>{var n=O(),r=x(),i=Ae();t.exports=!n&&!r(function(){return Object.defineProperty(i(`div`),`a`,{get:function(){return 7}}).a!==7})}),Me=g(e=>{var t=O(),n=ee(),r=te(),i=ne(),a=oe(),o=ke(),s=Te(),c=je(),l=Object.getOwnPropertyDescriptor;e.f=t?l:function(e,t){if(e=a(e),t=o(t),c)try{return l(e,t)}catch{}if(s(e,t))return i(!n(r.f,e,t),e[t])}}),Ne=g((e,t)=>{var n=x(),r=D(),i=/#|\.prototype\./,a=function(e,t){var i=s[o(e)];return i===l?!0:i===c?!1:r(t)?n(t):!!t},o=a.normalize=function(e){return String(e).replace(i,`.`).toLowerCase()},s=a.data={},c=a.NATIVE=`N`,l=a.POLYFILL=`P`;t.exports=a}),Pe=g((e,t)=>{var n=E(),r=_e(),i=S(),a=n(n.bind);t.exports=function(e,t){return r(e),t===void 0?e:i?a(e,t):function(){return e.apply(t,arguments)}}}),Fe=g((e,t)=>{var n=O(),r=x();t.exports=n&&r(function(){return Object.defineProperty(function(){},`prototype`,{value:42,writable:!1}).prototype!==42})}),Ie=g((e,t)=>{var n=se(),r=String,i=TypeError;t.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not an object`)}}),Le=g(e=>{var t=O(),n=je(),r=Fe(),i=Ie(),a=ke(),o=TypeError,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=`enumerable`,u=`configurable`,d=`writable`;e.f=t?r?function(e,t,n){if(i(e),t=a(t),i(n),typeof e==`function`&&t===`prototype`&&`value`in n&&d in n&&!n[d]){var r=c(e,t);r&&r[d]&&(e[t]=n.value,n={configurable:u in n?n[u]:r[u],enumerable:l in n?n[l]:r[l],writable:!1})}return s(e,t,n)}:s:function(e,t,r){if(i(e),t=a(t),i(r),n)try{return s(e,t,r)}catch{}if(`get`in r||`set`in r)throw new o(`Accessors not supported`);return`value`in r&&(e[t]=r.value),e}}),Re=g((e,t)=>{var n=O(),r=Le(),i=ne();t.exports=n?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}}),k=g((e,t)=>{var n=b(),r=C(),i=E(),a=D(),o=Me().f,s=Ne(),c=ce(),l=Pe(),u=Re(),d=Te();Se();var f=function(e){var t=function(n,i,a){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(n);case 2:return new e(n,i)}return new e(n,i,a)}return r(e,this,arguments)};return t.prototype=e.prototype,t};t.exports=function(e,t){var r=e.target,p=e.global,m=e.stat,h=e.proto,g=p?n:m?n[r]:n[r]&&n[r].prototype,_=p?c:c[r]||u(c,r,{})[r],v=_.prototype,y,b,x,S,C,w,T,E,D;for(S in t)y=s(p?S:r+(m?`.`:`#`)+S,e.forced),b=!y&&g&&d(g,S),w=_[S],b&&(e.dontCallGetSet?(D=o(g,S),T=D&&D.value):T=g[S]),C=b&&T?T:t[S],!(!y&&!h&&typeof w==typeof C)&&(E=e.bind&&b?l(C,n):e.wrap&&b?f(C):h&&a(C)?i(C):C,(e.sham||C&&C.sham||w&&w.sham)&&u(E,`sham`,!0),u(_,S,E),h&&(x=r+`Prototype`,d(c,x)||u(c,x,{}),u(c[x],S,C),e.real&&v&&(y||!v[S])&&u(v,S,C)))}}),ze=g((e,t)=>{var n=Math.ceil,r=Math.floor;t.exports=Math.trunc||function(e){var t=+e;return(t>0?r:n)(t)}}),Be=g((e,t)=>{var n=ze();t.exports=function(e){var t=+e;return t!==t||t===0?0:n(t)}}),Ve=g((e,t)=>{var n=Be(),r=Math.max,i=Math.min;t.exports=function(e,t){var a=n(e);return a<0?r(a+t,0):i(a,t)}}),He=g((e,t)=>{var n=Be(),r=Math.min;t.exports=function(e){var t=n(e);return t>0?r(t,9007199254740991):0}}),Ue=g((e,t)=>{var n=He();t.exports=function(e){return n(e.length)}}),We=g((e,t)=>{var n=oe(),r=Ve(),i=Ue(),a=function(e){return function(t,a,o){var s=n(t),c=i(s);if(c===0)return!e&&-1;var l=r(o,c),u;if(e&&a!==a){for(;c>l;)if(u=s[l++],u!==u)return!0}else for(;c>l;l++)if((e||l in s)&&s[l]===a)return e||l||0;return!e&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}}),Ge=g((e,t)=>{t.exports=function(){}}),Ke=g(()=>{var e=k(),t=We().includes,n=x(),r=Ge();e({target:`Array`,proto:!0,forced:n(function(){return![,].includes()})},{includes:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),r(`includes`)}),qe=g((e,t)=>{t.exports=le()}),Je=g((e,t)=>{Ke(),t.exports=qe()(`Array`,`includes`)}),Ye=g((e,t)=>{t.exports=Je()}),Xe=g((e,t)=>{t.exports=Ye()}),Ze=g(()=>{var e=k(),t=we(),n=Ue(),r=Be(),i=Ge();e({target:`Array`,proto:!0},{at:function(e){var i=t(this),a=n(i),o=r(e),s=o>=0?o:a+o;return s<0||s>=a?void 0:i[s]}}),i(`at`)}),Qe=g((e,t)=>{Ze(),t.exports=qe()(`Array`,`at`)}),$e=g((e,t)=>{t.exports=Qe()}),et=g((e,t)=>{t.exports=$e()}),tt=g((e,t)=>{var n=De()(`toStringTag`),r={};r[n]=`z`,t.exports=String(r)===`[object z]`}),nt=g((e,t)=>{var n=tt(),r=D(),i=T(),a=De()(`toStringTag`),o=Object,s=i(function(){return arguments}())===`Arguments`,c=function(e,t){try{return e[t]}catch{}};t.exports=n?i:function(e){var t,n,l;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=c(t=o(e),a))==`string`?n:s?i(t):(l=i(t))===`Object`&&r(t.callee)?`Arguments`:l}}),rt=g((e,t)=>{var n=nt(),r=String;t.exports=function(e){if(n(e)===`Symbol`)throw TypeError(`Cannot convert a Symbol value to a string`);return r(e)}}),it=g(()=>{var e=k(),t=w(),n=ae(),r=Be(),i=rt(),a=x(),o=t(``.charAt);e({target:`String`,proto:!0,forced:a(function(){return`𠮷`.at(-2)!==`\ud842`})},{at:function(e){var t=i(n(this)),a=t.length,s=r(e),c=s>=0?s:a+s;return c<0||c>=a?void 0:o(t,c)}})}),at=g((e,t)=>{it(),t.exports=qe()(`String`,`at`)}),ot=g((e,t)=>{t.exports=at()}),st=g((e,t)=>{t.exports=ot()}),ct=g((e,t)=>{var n=Ce(),r=Ee(),i=n(`keys`);t.exports=function(e){return i[e]||(i[e]=r(e))}}),lt=g((e,t)=>{t.exports=!x()(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})}),ut=g((e,t)=>{var n=Te(),r=D(),i=we(),a=ct(),o=lt(),s=a(`IE_PROTO`),c=Object,l=c.prototype;t.exports=o?c.getPrototypeOf:function(e){var t=i(e);if(n(t,s))return t[s];var a=t.constructor;return r(a)&&t instanceof a?a.prototype:t instanceof c?l:null}}),dt=g((e,t)=>{t.exports={}}),ft=g((e,t)=>{var n=w(),r=Te(),i=oe(),a=We().indexOf,o=dt(),s=n([].push);t.exports=function(e,t){var n=i(e),c=0,l=[],u;for(u in n)!r(o,u)&&r(n,u)&&s(l,u);for(;t.length>c;)r(n,u=t[c++])&&(~a(l,u)||s(l,u));return l}}),pt=g((e,t)=>{t.exports=[`constructor`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`toLocaleString`,`toString`,`valueOf`]}),mt=g((e,t)=>{var n=ft(),r=pt();t.exports=Object.keys||function(e){return n(e,r)}}),ht=g((e,t)=>{var n=O(),r=x(),i=w(),a=ut(),o=mt(),s=oe(),c=te().f,l=i(c),u=i([].push),d=n&&r(function(){var e=Object.create(null);return e[2]=2,!l(e,2)}),f=function(e){return function(t){for(var r=s(t),i=o(r),c=d&&a(r)===null,f=i.length,p=0,m=[],h;f>p;)h=i[p++],(!n||(c?h in r:l(r,h)))&&u(m,e?[h,r[h]]:r[h]);return m}};t.exports={entries:f(!0),values:f(!1)}}),gt=g(()=>{var e=k(),t=ht().entries;e({target:`Object`,stat:!0},{entries:function(e){return t(e)}})}),_t=g((e,t)=>{gt(),t.exports=ce().Object.entries}),vt=g((e,t)=>{t.exports=_t()}),yt=g((e,t)=>{t.exports=vt()}),bt=g(()=>{var e=k(),t=ht().values;e({target:`Object`,stat:!0},{values:function(e){return t(e)}})}),xt=g((e,t)=>{bt(),t.exports=ce().Object.values}),St=g((e,t)=>{t.exports=xt()}),Ct=g((e,t)=>{t.exports=St()}),wt=g((e,t)=>{var n=T();t.exports=Array.isArray||function(e){return n(e)===`Array`}}),Tt=g((e,t)=>{var n=TypeError,r=9007199254740991;t.exports=function(e){if(e>r)throw n(`Maximum allowed index exceeded`);return e}}),Et=g((e,t)=>{var n=wt(),r=Ue(),i=Tt(),a=Pe(),o=function(e,t,s,c,l,u,d,f){for(var p=l,m=0,h=d?a(d,f):!1,g,_;m<c;)m in s&&(g=h?h(s[m],m,t):s[m],u>0&&n(g)?(_=r(g),p=o(e,t,g,_,p,u-1)-1):(i(p+1),e[p]=g),p++),m++;return p};t.exports=o}),Dt=g((e,t)=>{var n=w(),r=D(),i=Se(),a=n(Function.toString);r(i.inspectSource)||(i.inspectSource=function(e){return a(e)}),t.exports=i.inspectSource}),Ot=g((e,t)=>{var n=w(),r=x(),i=D(),a=nt(),o=le(),s=Dt(),c=function(){},l=o(`Reflect`,`construct`),u=/^\s*(?:class|function)\b/,d=n(u.exec),f=!u.test(c),p=function(e){if(!i(e))return!1;try{return l(c,[],e),!0}catch{return!1}},m=function(e){if(!i(e))return!1;switch(a(e)){case`AsyncFunction`:case`GeneratorFunction`:case`AsyncGeneratorFunction`:return!1}try{return f||!!d(u,s(e))}catch{return!0}};m.sham=!0,t.exports=!l||r(function(){var e;return p(p.call)||!p(Object)||!p(function(){e=!0})||e})?m:p}),kt=g((e,t)=>{var n=wt(),r=Ot(),i=se(),a=De()(`species`),o=Array;t.exports=function(e){var t;return n(e)&&(t=e.constructor,r(t)&&(t===o||n(t.prototype))?t=void 0:i(t)&&(t=t[a],t===null&&(t=void 0))),t===void 0?o:t}}),At=g((e,t)=>{var n=kt();t.exports=function(e,t){return new(n(e))(t===0?0:t)}}),jt=g(()=>{var e=k(),t=Et(),n=we(),r=Ue(),i=Be(),a=At();e({target:`Array`,proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,o=n(this),s=r(o),c=a(o,0);return c.length=t(c,o,o,s,0,e===void 0?1:i(e)),c}})}),Mt=g(()=>{Ge()(`flat`)}),Nt=g((e,t)=>{jt(),Mt(),t.exports=qe()(`Array`,`flat`)}),Pt=g((e,t)=>{t.exports=Nt()}),Ft=g((e,t)=>{t.exports=Pt()}),It={};y(It,{vkVideoIdsToChapterIds:()=>Xi,utils:()=>pa,migrateManifestToLatestVersion:()=>L.migrateManifestToLatestVersion,isValidManifest:()=>xn,isVKVariantItem:()=>qi,isTextControl:()=>Sn,isSupportedManifest:()=>L.isSupportedManifest,isOneTextCtrlContainer:()=>In,isLastChapter:()=>R,isButtonControl:()=>Cn,isAreaControl:()=>wn,interactivesEventTypes:()=>q,hasEndTemplate:()=>An,graphEventTypes:()=>gi,getVideoRawIdByMedia:()=>Ki,getVKVideoIdByMedia:()=>Ji,getChapterIdByVkVideoId:()=>Yi,eventTypes:()=>Dn,eventActionTypes:()=>On,controlTypes:()=>En,containerTypes:()=>Tn,compareVersions:()=>qr,chapterIdsToVKVideoIds:()=>Gi,SDKInfo:()=>ma,ManifestController:()=>ni,Interactives:()=>fa,EventTypes:()=>L.EventTypes,EventActionTypes:()=>L.EventActionTypes,EVENT_NAMES:()=>K,CustomError:()=>A,ControlTypes:()=>L.ControlTypes,ContainerTypes:()=>L.ContainerTypes}),module.exports=m(It);var Lt=`1.0.60-dev.81767d01c.0`,Rt=require(`@vkontakte/videoplayer-shared/es2018`);class zt{constructor(t,n){e(this,`layout`,void 0),e(this,`cssVarsManager`,void 0),this.layout=t,this.cssVarsManager=n}}class Bt extends zt{constructor(t,n){super(t,n),e(this,`cssVarsManager`,void 0),this.cssVarsManager=n,this.cssVarsManager=n}setContainerLayout(e){e.style.position=`relative`}setControlLayout(e,t){let n=this.cssVarsManager.getPropValue(`--interactive-content-width`),r=this.cssVarsManager.getPropValue(`--interactive-content-height`),i=this.cssVarsManager.getPropValue(`--interactive-width`),a=this.cssVarsManager.getPropValue(`--interactive-height`);e.style.position=`absolute`,e.style.width=`calc(${n} * (${t.width} + 0.0002))`,e.style.height=`calc(${r} * ${t.height})`,e.style.left=`calc(${n} * ${t.x} + ((${i} - ${n}) / 2))`,e.style.top=`calc(${r} * ${t.y} + ((${a} - ${r}) / 2))`}}var Vt=require(`@vkontakte/videoplayer-shared/es2018`);function Ht(e){return`features`in e}class A{constructor(t,n,...r){e(this,`severity`,void 0),e(this,`category`,void 0),e(this,`data`,void 0),this.severity=t,this.category=n,this.data=r}toString(){return`Interactive SDK error ${JSON.stringify(this,null,` `)}`}}function Ut({emitter$:e,error:t,subjectId:n,message:r=``,severity:i=1,category:a=1}){let o=new A(i,a,{message:r,error:t,details:{id:n}});e.next(o)}class Wt{constructor(t,n,r){e(this,`container`,void 0),e(this,`options`,void 0),e(this,`factories`,void 0),e(this,`controls`,void 0),e(this,`error$`,new Vt.Subject),e(this,`cssVarsManager`,void 0),this.container=t,this.options=r,this.factories=new Map,this.controls=[],this.setControls(),this.cssVarsManager=n}featureIsEnabled(e){return!!(this.options&&this.options.features&&Ht(this.options)&&this.options.features[e])}onError(e=``,t){Ut({emitter$:this.error$,error:t,message:e,subjectId:this.container.id})}addControlFactory(e,t){this.factories.set(e.trim().toLowerCase(),t),this.setControls()}removeControlFactory(e){this.factories.delete(e.trim().toLowerCase()),this.setControls()}setControls(){this.controls=this.chooseControls()}chooseControls(){return this.container.controls?.reduce((e,t)=>{let n=t.type.trim().toLowerCase(),r=this.factories.get(n);if(r){let n=r(t,this.options);if(n)return[...e,n]}return[...e]},[])||[]}}var j=require(`@vkontakte/videoplayer-shared/es2018`),M=(e,t)=>Object.prototype.toString.call(e)===`[object ${t}]`,Gt=e=>M(e,`Object`),Kt=e=>M(e,`String`),qt=e=>M(e,`Array`),Jt=e=>M(e,`Number`),Yt=e=>M(e,`Function`),Xt=e=>M(e,`Boolean`),Zt=e=>Jt(e)&&!isNaN(e),Qt=e=>Gt(e)&&Object.keys(e).length===0,$t=e=>qt(e)&&!e.length,en=(e,t)=>Kt(e)&&!!(t?e.trim():e).length;function tn(e,t=1){let n=`0`,r=`0`,i=`0`;return e.length===4?(n=`0x`+e[1]+e[1],r=`0x`+e[2]+e[2],i=`0x`+e[3]+e[3]):e.length===7&&(n=`0x`+e[1]+e[2],r=`0x`+e[3]+e[4],i=`0x`+e[5]+e[6]),`rgba(${+n},${+r},${+i},${t})`}var nn=`interactive`,N={textColor:`#000`,textSize:.4,textContent:``,roundCorners:0,borderWidth:0,borderWidthRawValue:`1px`,roundCornersRawValue:`0`,borderColor:`#000`,borderAlpha:1,backgroundColor:`#fff`,backgroundAlpha:1,innerSizesDependOn:`self`,angle:0,shadowColorLight:`#fff`,shadowColorDark:`#000`,shadowColorAlpha:.24},rn;(e=>{e.top=`flex-start`,e.bottom=`flex-end`,e.center=`center`})(rn||={});var an;(e=>{e.start=`flex-start`,e.end=`flex-end`,e.center=`center`})(an||={});var on=({target:e,props:t})=>{e.style.alignItems=(t?.gravityVertical&&rn[t.gravityVertical])??`center`,e.style.justifyContent=(t?.gravityHorizontal&&an[t.gravityHorizontal])??`center`,e.style.textAlign=t?.alignment??`center`},sn=({target:e,props:t,fallback:n,dependsOn:r})=>{var i,a,o;e.style.color=(t==null||(i=t.text)==null?void 0:i.color)??n.textColor,e.style.fontSize=`calc(${r.height} * ${(t==null||(a=t.text)==null?void 0:a.size)??n.textSize})`,e.textContent=(t==null||(o=t.text)==null?void 0:o.value)??n.textContent},cn=({target:e,props:t,fallback:n})=>{var r,i;e.style.backgroundColor=tn((t==null||(r=t.background)==null?void 0:r.color)??n.backgroundColor,(t==null||(i=t.background)==null?void 0:i.alpha)??n.backgroundAlpha)},ln=({target:e,props:t,fallback:n,dependsOn:r,useRawValues:i=!1})=>{var a,o,s,c;let l=i?n.borderWidthRawValue:`calc(${r.height} * ${(t==null||(a=t.shape)==null||(a=a.border)==null?void 0:a.width)??n.borderWidth})`,u=i?n.roundCornersRawValue:`calc(${r.height} * ${(t==null||(o=t.shape)==null?void 0:o.roundCorners)??n.roundCorners})`;e.style.borderWidth=l,e.style.borderStyle=`solid`,e.style.borderColor=tn(i?n.borderColor:(t==null||(s=t.shape)==null||(s=s.border)==null?void 0:s.color)??n.borderColor,i?n.borderAlpha:(t==null||(c=t.shape)==null||(c=c.border)==null?void 0:c.alpha)??n.borderAlpha),e.style.borderRadius=u},un=({target:e,isDark:t,baseDimension:n,fallback:r})=>{let i=tn(r.shadowColorLight,r.shadowColorAlpha),a=tn(r.shadowColorDark,r.shadowColorAlpha),o=`0px 0px ${`calc(${n} * 0.25)`} ${`calc(${n} * 0.11)`} ${t?a:i}`;e.style.boxShadow=o},dn=({target:e,layoutParams:t,fallback:n})=>{let r=t.angle??n.angle;r&&=r*-1,e.style.transform=`rotate(${r}rad)`},P=require(`@vkontakte/videoplayer-shared/es2018`),fn=`interactive-control-tap`,pn={common:fn,animation:`${fn}-animation`,visible:`${fn}-visible`},mn=60;class hn{constructor({controlRotateAngleRad:t,clickCancelCondition:n,circleDiameterPx:r=mn,useDimensionsBasedSize:i=!1}){e(this,`element`,void 0),e(this,`controlRotateAngleRad`,void 0),e(this,`clickCancelCondition`,void 0),e(this,`circleDiameterPx`,void 0),e(this,`useDimensionsBasedSize`,void 0),e(this,`onElementClick`,e=>{if(!e.target||!e.currentTarget||this.clickCancelCondition())return;let t=e.currentTarget.parentElement;if(!t)return;let n=t.getBoundingClientRect(),r={width:this.useDimensionsBasedSize?t.offsetWidth:this.circleDiameterPx,height:this.useDimensionsBasedSize?t.offsetHeight:this.circleDiameterPx},i=Math.min(r.width,r.height),a=n.left+n.width/2,o=n.top+n.height/2,s=gn(e.clientX-a,e.clientY-o,this.controlRotateAngleRad);this.element.style.width=i+`px`,this.element.style.left=s.x+n.width/2-i/2+`px`,this.element.style.top=s.y+n.height/2-i/2+`px`,this.element.classList.add(pn.visible,pn.animation)}),e(this,`onAnimationEnd`,e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.element.classList.remove(pn.visible,pn.animation)});let a=document.createElement(`div`);a.classList.add(pn.common),this.controlRotateAngleRad=t,this.element=a,this.clickCancelCondition=n,this.circleDiameterPx=r,this.useDimensionsBasedSize=i}}function gn(e,t,n){return{x:e*Math.cos(n)-t*Math.sin(n),y:e*Math.sin(n)+t*Math.cos(n)}}function _n(e){return`features`in e}var F=`interactive-control`,I={common:F,selected:`${F}-selected`,wrapper:`${F}-wrapper`,disabled:`${F}-disabled`,button:`${F}-button`,area:`${F}-area`,text:`${F}-text`,blinkAnim:`${F}-blink-anim`,blinkAnimButton:`${F}-blink-anim-button`,blinkAnimArea:`${F}-blink-anim-area`},vn=40,yn=p(Xe(),1),L=require(`@interactiveplatform/movika-manifest`),bn={metadata:`Object`,chapters:`Array`},xn=e=>{if(!Gt(e))return!1;for(let t in bn){let n=e[t];if(!n||!M(n,bn[t]))return!1}return L.isSupportedManifest(e.metadata.version)};function Sn(e){return e.type===L.ControlTypes.Text}function Cn(e){return e.type===L.ControlTypes.Button}function wn(e){return e.type===L.ControlTypes.Area}var Tn={Choice:`Choice`,TextInput:`TextInput`},En={Button:`Button`,Area:`Area`,Text:`Text`},Dn={onClick:`onClick`,onSuspense:`onSuspense`},On={openURI:`openURI`,setNextBranch:`setNextBranch`,setWeightlessRandomBranch:`setWeightlessRandomBranch`,setRandomBranch:`setRandomBranch`,setMaxWeightBranch:`setMaxWeightBranch`,setMinWeightBranch:`setMinWeightBranch`,setDefaultBranch:`setDefaultBranch`,continuePlayback:`continuePlayback`,expect:`expect`},kn=e=>qt(e)&&!$t(e),R=e=>e.order===`end`,An=e=>qt(e.containers)&&!$t(e.containers)&&R(e),jn=(e,t)=>{let n=e*1e3;return kn(t.controls)&&n<(t.startTime??0)},Mn=(e,t)=>{let n=e*1e3;return kn(t.controls)&&n>=(t.startTime??0)&&n<=(t.endTime??1/0)},Nn=(e=[])=>e.some(e=>e.action.type===`expect`),Pn=(e=[])=>e.find(e=>e.action.type===`expect`),Fn=e=>e?.length===1,In=e=>Fn(e)&&Sn(e[0]);function Ln(e=[],t=1/0,n=[]){return e.filter(({container:e})=>!yn.default(n,e.container.id)&&Nn(e.container.events)&&e.container.endTime===t&&!e.isRemoved&&!e.willRemoved)}function Rn({gameControllers:e=[],subjectName:t,subjectId:n,execFn:r}){for(let i of e)if(t===`container`&&i.container.container.id===n){r(i),Ln(e,i.container.container.endTime,[i.container.container.id]).forEach(e=>{r(e)});break}}function zn(e){for(let t of e.events)if(t.action.type===`openURI`)return!0;return!1}var Bn=(e,t)=>{let n=Nn(e.events)&&!(e=>t.find(({container:t})=>t.container.id===e)?.container.isRemoved)(e.id),r=(t,n=!1,r=!1)=>{let i=r?`every`:`some`;return t.controls[i](r=>{let a=n?t.endTime===e.endTime:!0;return r.events?.[i](e=>e.action?.type===L.EventActionTypes.openURI)&&a})},i=e=>e.some(({container:e})=>r(e.container,!0,!1)&&!e.isRemoved),a=e=>e.every(({container:e})=>e.isRemoved||e.willRemoved?!0:r(e.container,!0,!0)),o=Ln(t,e.endTime,[e.id]).length,s=e=>e.controls.some(e=>e.events?.some(e=>{var t;return(t=e.action)==null||(t=t.args)==null?void 0:t.shouldOpenNow})),c=n||o>0,l=i(t),u=r(e),d=a(t),f=n?!1:o>0,p=s(e);return{isExpectTime:c,hasOtherExpect:o>0,hasOpenURIEvent:l,hasOpenURIEventInCurrentContainer:u,isAllOpenURIEventsValid:d,isExpectEventForCurrentContainer:f,hasShouldOpenNowEvent:p}};class Vn{constructor(t,n=void 0){e(this,`control`,void 0),e(this,`options`,void 0),e(this,`container`,null),e(this,`controlElement`,null),e(this,`subscriptions`,new P.Subscription),e(this,`error$`,new P.Subject),e(this,`controlTap`,void 0),e(this,`isInteracted`,!1),e(this,`isRemoved`,!1),e(this,`cssVarsManager`,null),e(this,`onControlSelect`,()=>{var e;this.container?.isManifestContainerDisabled()||zn(this.control)||(e=this.container)==null||(e=e.element)==null||e.classList.add(`interactive-control-wrapper-selected`)}),e(this,`onTransitionEnd`,e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}),this.control=t,this.options=n}setCssVarsManager(e){this.cssVarsManager=e}removeView(e=!1){let t=this.getElement();if(t){if(e){if(t.classList.contains(`interactive-control-before-remove`))return;t.classList.add(`interactive-control-before-remove`),this.subscriptions.add(P.fromEvent(t,`transitionend`).subscribe(this.onTransitionEnd,e=>this.onError(`${Vn.name} remove view transition error`,e))).add(P.fromEvent(t,`transitioncancel`).subscribe(this.onTransitionEnd,e=>this.onError(`${Vn.name} remove view transition error`,e)));return}this.removeListeners(),t.remove(),this.isRemoved=!0}}onError(e=``,t){Ut({emitter$:this.error$,error:t,message:e,subjectId:this.control.id})}addControlTap(e){this.featureIsEnabled(`controlsTapPlace`)&&this.container&&(this.controlTap=new hn({controlRotateAngleRad:this.control.layoutParams.angle??N.angle,clickCancelCondition:this.container.isManifestContainerDisabled,circleDiameterPx:this.isTouch()?vn:void 0}),this.subscriptions.add(P.fromEvent(e,`click`).subscribe(this.controlTap.onElementClick,e=>this.onError(`Control click tap animation error`,e))).add(P.fromEvent(this.controlTap.element,`animationend`).subscribe(this.controlTap.onAnimationEnd,e=>this.onError(`Tap animationend error`,e))),this.container.element.append(this.controlTap.element))}createContainerElement(e){let t=document.createElement(`div`);t.classList.add(I.wrapper),e.setControlLayout(t,this.control.layoutParams),this.container={element:t,dimensions:(this.control.layoutParams.innerSizesDependOn??N.innerSizesDependOn)===`self`?{height:t.style.height,width:t.style.width}:{height:this.cssVarsManager?.getPropValue(`--interactive-content-height`)??0,width:this.cssVarsManager?.getPropValue(`--interactive-content-width`)??0},isManifestContainerDisabled:()=>e.isContainerDisabled?.call(e)??!1}}createClickListener(e){return t=>{t.stopPropagation(),this.isInteracted=!0,e()}}featureIsEnabled(e){return!!(this.options&&_n(this.options)&&this.options.features[e])}isTouch(){return!!(this.options&&_n(this.options)&&this.options.isTouch)}setEvents(e){!this.container||!this.control.events||this.control.events.forEach(t=>{switch(t.type.trim().toLowerCase()){case`onclick`:if(!this.container)break;this.subscriptions.add(P.fromEvent(this.container.element,`click`).subscribe(this.createClickListener(()=>e({action:t.action,controlId:this.control.id,controlType:this.control.type})),e=>this.onError(`Error happened on control interaction`,e)));break;default:break}})}removeListeners(){this.subscriptions.unsubscribe()}}var Hn=`interactive-blink-anim-reference`,z={common:Hn,animation:`${Hn}-animation`,disabled:`${Hn}-disabled`};class Un{constructor(){e(this,`_RAFId`,0),e(this,`_element`,void 0)}get element(){return this._element}create(){if(this._element)return;let e=document.createElement(`div`);e.classList.add(z.common,z.animation),this._element=e}restart(){this._element&&(this._element.classList.add(z.disabled),this.cleanupRAF(),this._RAFId=requestAnimationFrame(()=>{this._element&&(this._element.classList.remove(z.disabled),this.cleanupRAF())}))}cleanupRAF(){this._RAFId&&=(cancelAnimationFrame(this._RAFId),0)}destroy(){this.cleanupRAF(),this._element=void 0}}var Wn=`interactive-container`,B={common:Wn,hidden:`${Wn}-hidden`,disabled:`${Wn}-disabled`},Gn=(e,t)=>{if(e.type.trim().toLowerCase()===`area`)return new Kn(e,t)};class Kn extends Vn{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let n=document.createElement(`button`);n.type=`button`,n.classList.add(I.common,I.area),n.setAttribute(`data-testid`,`int_area`),cn({target:n,props:this.control.props,fallback:{...N,backgroundColor:`transparent`}}),dn({target:n,layoutParams:this.control.layoutParams,fallback:N}),this.addControlTap(n),this.subscriptions.add(j.fromEvent(this.container.element,`click`).pipe(j.once()).subscribe(this.onControlSelect,e=>this.onError(`Control click handler error`,e))),this.container.element.append(n),e.append(this.container.element),this.controlElement=n,this.updateShadowStyles(),this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){if(!this.featureIsEnabled(`controlsExpectTimeBlinkAnimation`))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(j.fromEvent(this.controlElement,`mouseleave`).subscribe(()=>{if(e.classList.contains(B.disabled))return;let t=e.parentElement;if(t){let e=t.querySelector(`.${z.common}`);e&&this.syncBlinkAnimation(e)}},e=>this.onError(`Error happened in mouseleave callback`,e))),this.subscriptions.add(j.fromEvent(this.controlElement,`mouseenter`).subscribe(()=>{e.classList.contains(B.disabled)||this.onBlinkHovering()},e=>this.onError(`Error happened in mouseenter callback`,e))).add(j.fromEvent(this.controlElement,`mouseleave`).subscribe(()=>{this.controlElement&&(this.controlElement.style.animation=``)},e=>this.onError(`Error happened in mouseleave callback`,e))))}disable(){this.controlElement&&this.controlElement.classList.add(I.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(I.disabled)}getElement(){return this.controlElement}updateShadowStyles(e){if(!(!this.container||!this.controlElement))if(Xt(e)){var t;let n=Math.min(this.controlElement.offsetWidth,this.controlElement.offsetHeight)+`px`;un({target:this.controlElement,props:this.control.props,fallback:N,isDark:e,baseDimension:n}),ln({target:this.controlElement,props:this.control.props,fallback:{...N,borderColor:e?N.shadowColorDark:N.shadowColorLight,borderAlpha:1,borderWidthRawValue:`0.1px`,roundCornersRawValue:`calc(${this.container.dimensions.height} * ${((t=this.control.props)==null||(t=t.shape)==null?void 0:t.roundCorners)??N.roundCorners})`},dependsOn:this.container.dimensions,useRawValues:!0})}else ln({target:this.controlElement,props:this.control.props,fallback:{...N,borderAlpha:0},dependsOn:this.container.dimensions})}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(I.blinkAnim,e),this.controlElement?.classList.toggle(I.blinkAnimArea,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${I.blinkAnimArea}`)||this.controlElement.classList.contains(I.selected)||this.controlElement.classList.contains(z.disabled)||(this.controlElement.classList.add(z.disabled),this.subscriptions.add(j.fromEvent(e,`animationiteration`).pipe(j.once()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(z.disabled)},e=>this.onError(`Error happened in animationiteration callback`,e)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${I.blinkAnimArea}`)||this.controlElement.classList.contains(I.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue(`--interactive-area-hover-opacity`).trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation=`none`,requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}setShowTimeRange(){}updateFillAnimationDimensions(){}onProgress(){}onResize(){}}var V=require(`@vkontakte/videoplayer-shared/es2018`),qn=e=>{let t=document.createElement(`span`);switch(e){case`Button`:case`button`:{let e=document.createElement(`div`);return Object.assign(e.style,{overflow:`hidden`,display:`flex`,justifyContent:`center`,alignItems:`center`}),e.append(t),Object.assign(t.style,{display:`inline-block`,whiteSpace:`pre`,textOverflow:`ellipsis`,maxWidth:`initial`,maxHeight:`100%`,wordBreak:`normal`}),e}default:return Object.assign(t.style,{display:`inline-block`,whiteSpace:`break-spaces`,overflow:`hidden`,textOverflow:`ellipsis`,maxWidth:`100%`,maxHeight:`100%`,wordBreak:`break-all`}),t}},Jn=Math.PI,Yn=2*Jn,Xn=Jn/2,Zn=3*Xn,Qn=[0,Xn,Jn,Zn];function $n(e){return e===Xn}function er(e){return e===Jn}function tr(e){return e===Zn}function nr(e){return(e%Yn+Yn)%Yn}function rr(e){for(let t of Qn)if(e===t)return t}function ir(e){return rr(e)?null:[1,2,3,4][Math.floor(e/Xn)+1-1]}function ar(e){return e*180/Math.PI}var H=`interactive-control-fill-animation`,U={common:H,fillerWrapper:`${H}-filler-wrapper`,filler:`${H}-filler`,fillHeight:`${H}-fill-height`,fillWidth:`${H}-fill-width`,fromTop:`${H}-from-top`,fromBottom:`${H}-from-bottom`,fromLeft:`${H}-from-left`,fromRight:`${H}-from-right`};class or{constructor(t){e(this,`fillAnimationElement`,void 0),e(this,`fillAnimationFillerElement`,void 0),e(this,`fillAnimationFillerWrapperElement`,void 0),e(this,`startTime`,void 0),e(this,`endTime`,void 0),e(this,`shouldFillHeight`,void 0),e(this,`widthExpansionCoef`,0),e(this,`isDebug`,void 0),e(this,`fromLeft`,void 0),e(this,`useSkew`,void 0),e(this,`rotateAngle`,void 0);let n=document.createElement(`div`);n.classList.add(U.common);let r=document.createElement(`div`);r.classList.add(U.fillerWrapper);let i=document.createElement(`div`);i.classList.add(U.filler),r.append(i),n.append(r);let a=nr(t.rotateAngle),o=ir(a),s=o!==null,c=o===2||!s&&er(a)||o===3,l=!s&&$n(a),u=!s&&tr(a),d=!c&&!l&&!u,f=l||u,p=s&&!f,m=p?a:0;n.style.borderRadius=t.borderRadius,r.style.transform=`skew(${m*-1}rad)`,f?(i.classList.add(U.fillHeight,l?U.fromTop:U.fromBottom),r.classList.add(U.fillHeight,l?U.fromTop:U.fromBottom)):(i.classList.add(U.fillWidth,d?U.fromLeft:U.fromRight),r.classList.add(U.fillWidth)),t.debug&&console.log(`[interactive ${or.name}]`,{widthExpansionCoef:this.widthExpansionCoef,opts:t,shouldFillHeight:f,rotateAngleRad:a,rotateAngelDeg:ar(a),rotateAngleRaw:t.rotateAngle,fromRight:c,fromTop:l,fromBottom:u,fromLeft:d}),this.useSkew=p,this.fromLeft=d,this.rotateAngle=a,this.fillAnimationElement=n,this.fillAnimationFillerElement=i,this.fillAnimationFillerWrapperElement=r,this.startTime=t.startTime,this.endTime=t.endTime,this.shouldFillHeight=f,this.isDebug=t.debug??!1}updateDimension(e){this.fillAnimationElement.style.top=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.left=`${e.borderWidth*-1}px`,this.fillAnimationElement.style.width=`${e.width}px`,this.fillAnimationElement.style.height=`${e.height}px`;let t=this.calcWidthExpansionCoef({rotateAngle:this.rotateAngle,isSkewed:this.useSkew,initWidth:e.width,initHeight:e.height});!this.shouldFillHeight&&(this.fillAnimationFillerWrapperElement.style.width=100*t+100+`%`,this.fillAnimationFillerWrapperElement.style[`${this.fromLeft?`left`:`right`}`]=`calc((${t} * 100%) / 2 * -1)`),this.widthExpansionCoef=t}updateAnimation(e){if((e=>e<this.startTime||e>this.endTime)(e))return;let t=this.endTime-this.startTime,n=Math.min(Math.max((e-this.startTime)/t,0),1);this.shouldFillHeight?this.fillAnimationFillerElement.style.transform=`scaleY(${n})`:this.fillAnimationFillerElement.style.transform=`scaleX(${n})`}calcWidthExpansionCoef({rotateAngle:e,isSkewed:t=!1,initWidth:n,initHeight:r}){return t?(n+r*Math.abs(Math.tan(e)))/n-1:0}}var sr=(e,t)=>{if(e.type.trim().toLowerCase()===`button`)return new cr(e,t)};class cr extends Vn{constructor(t,n){super(t,n),e(this,`startTime`,void 0),e(this,`endTime`,void 0),e(this,`controlFillAnimation`,void 0)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let n=document.createElement(`button`);n.type=`button`,n.classList.add(I.common,I.button),n.setAttribute(`data-testid`,`int_bttn`),dn({target:n,layoutParams:this.control.layoutParams,fallback:N}),cn({target:n,props:this.control.props,fallback:N}),ln({target:n,props:this.control.props,fallback:N,dependsOn:this.container.dimensions}),on({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let r=qn(this.control.type.trim().toLowerCase());sn({target:r.firstElementChild??r,props:this.control.props,fallback:N,dependsOn:this.container.dimensions}),this.addControlTap(n),this.startTime!==void 0&&this.endTime!==void 0&&this.featureIsEnabled(`controlsFillAnimation`)&&(this.controlFillAnimation=new or({startTime:this.startTime,endTime:this.endTime,rotateAngle:this.control.layoutParams.angle??N.angle,borderRadius:n.style.borderRadius})),this.subscriptions.add(V.fromEvent(n,`click`).pipe(V.once()).subscribe(this.onControlSelect,e=>this.onError(`Control click handler error`,e))),n.append(r,this.controlFillAnimation?.fillAnimationElement??``),this.container.element.append(this.controlTap?.element??``,n),e.append(this.container.element),this.controlElement=n,this.registerBlinkAnimationEvents()}registerBlinkAnimationEvents(){if(!this.featureIsEnabled(`controlsExpectTimeBlinkAnimation`))return;let e=this.container?.element.parentElement;!e||!this.controlElement||(this.subscriptions.add(V.fromEvent(this.controlElement,`mouseleave`).subscribe(()=>{if(e.classList.contains(B.disabled))return;let t=e.parentElement;if(t){let e=t.querySelector(`.${z.common}`);e&&this.syncBlinkAnimation(e)}},e=>this.onError(`Error happened in mouseleave callback`,e))),this.subscriptions.add(V.fromEvent(this.controlElement,`mouseenter`).subscribe(()=>{e.classList.contains(B.disabled)||this.onBlinkHovering()},e=>this.onError(`Error happened in mouseenter callback`,e))).add(V.fromEvent(this.controlElement,`mouseleave`).subscribe(()=>{this.controlElement&&(this.controlElement.style.animation=``)},e=>this.onError(`Error happened in mouseleave callback`,e))))}disable(){this.controlElement&&this.controlElement.classList.add(I.disabled)}enable(){this.controlElement&&this.controlElement.classList.remove(I.disabled)}getElement(){return this.controlElement}toggleBlinkAnimation(e){this.controlElement?.classList.toggle(I.blinkAnim,e),this.controlElement?.classList.toggle(I.blinkAnimButton,e)}syncBlinkAnimation(e){this.controlElement&&(!this.controlElement.classList.contains(`${I.blinkAnimButton}`)||this.controlElement.classList.contains(I.selected)||this.controlElement.classList.contains(z.disabled)||(this.controlElement.classList.add(z.disabled),this.subscriptions.add(V.fromEvent(e,`animationiteration`).pipe(V.once()).subscribe(()=>{this.controlElement&&this.controlElement.classList.remove(z.disabled)},e=>this.onError(`Error happened in animationiteration callback`,e)))))}onBlinkHovering(){if(!this.controlElement||!this.controlElement.classList.contains(`${I.blinkAnimButton}`)||this.controlElement.classList.contains(I.selected))return;let e=window.getComputedStyle(this.controlElement),t=e.getPropertyValue(`--interactive-button-hover-opacity`).trim();this.controlElement.style.opacity=e.opacity,this.controlElement.style.animation=`none`,requestAnimationFrame(()=>{this.controlElement&&(this.controlElement.style.opacity=t)})}updateFillAnimationDimensions(){if(!this.container||!this.controlElement||!this.controlFillAnimation)return;let e=getComputedStyle(this.controlElement),t={width:parseFloat(e.width),height:parseFloat(e.height),borderWidth:parseFloat(e.borderWidth)||0};this.controlFillAnimation.updateDimension(t)}setShowTimeRange(e,t){this.startTime=e,this.endTime=t}onProgress(e){this.controlFillAnimation?.updateAnimation(e)}onResize(){this.updateFillAnimationDimensions()}updateShadowStyles(){}}var lr=(e,t)=>{if(e.type.trim().toLowerCase()===`text`)return new ur(e,t)};class ur extends Vn{constructor(e,t){super(e,t)}createView({parentElement:e,callbacks:t}){if(super.createContainerElement(t),!this.container)return;this.isInteracted=!1,this.isRemoved=!1;let n=document.createElement(`div`);n.classList.add(I.common,I.text),n.setAttribute(`data-testid`,`int_text`),dn({target:n,layoutParams:this.control.layoutParams,fallback:N}),on({target:n,props:{...this.control.props.text,alignment:this.control.layoutParams.alignment}});let r=qn(this.control.type.trim().toLowerCase());sn({target:r.firstElementChild??r,props:this.control.props,fallback:N,dependsOn:this.container.dimensions}),n.append(r),this.container.element.append(n),e.append(this.container.element),this.controlElement=n}getElement(){return this.controlElement}disable(){}enable(){}onProgress(){}onResize(){}updateShadowStyles(){}toggleBlinkAnimation(){}setShowTimeRange(){}updateFillAnimationDimensions(){}}var dr=(e,t,n,r)=>{if(e.type.trim().toLowerCase()===`choice`)return new fr(e,t,n,r)};class fr extends Wt{constructor(t,n,r,i){super(t,r,i),e(this,`rootElement`,void 0),e(this,`containerElement`,null),e(this,`layout`,void 0),e(this,`subscriptions`,new Rt.Subscription),e(this,`isRemoved`,void 0),e(this,`isDisabled`,void 0),e(this,`willRemoved`,void 0),e(this,`cssVarsManager`,void 0),e(this,`onTransitionEnd`,e=>{e.stopPropagation(),!(!e.target||!e.currentTarget)&&e.target===e.currentTarget&&this.removeView()}),this.rootElement=n,this.layout=new Bt(this.container.layout,r),this.cssVarsManager=r,this.isRemoved=!1,this.isDisabled=!1,this.addControlFactory(`button`,sr),this.addControlFactory(`text`,lr),this.addControlFactory(`area`,Gn)}createView({eventCallback:e,videoDurationMs:t}){let n=document.createElement(`div`);return n.classList.add(B.common,B.disabled),n.setAttribute(`data-subjectId`,this.container.id),requestAnimationFrame(()=>{n.classList.remove(B.disabled)}),this.layout.setContainerLayout(n),this.controls.forEach(r=>{r.setShowTimeRange(this.container.startTime,this.container.endTime??t),r.setCssVarsManager(this.cssVarsManager),r.createView({parentElement:n,callbacks:{setControlLayout:(e,t)=>this.layout.setControlLayout(e,t),isContainerDisabled:()=>this.isDisabled}}),r.setEvents(e),this.subscriptions.add(r.error$.subscribe(this.error$))}),this.rootElement.append(n),this.isRemoved=!1,this.willRemoved=!1,this.containerElement=n,this.updateControlsFillAnimationDimensions(),n}updateControlsFillAnimationDimensions(){for(let e of this.controls)e.updateFillAnimationDimensions()}hide(){let e=this.getElement();e&&e.classList.add(B.hidden)}show(){let e=this.getElement();e&&e.classList.remove(B.hidden)}enable(){let e=this.getElement();e&&(e.classList.remove(B.disabled),this.controls.forEach(e=>e.enable()),this.isDisabled=!1)}disable(){let e=this.getElement();e&&(e.classList.add(B.disabled),this.controls.forEach(e=>e.disable()),this.isDisabled=!0)}removeView(e=!1,t=!1){let n=this.getElement();if(n){if(e){if(this.willRemoved)return;this.willRemoved=!0,t&&n.classList.add(`interactive-container-before-remove-delay`),n.classList.add(`interactive-container-before-remove`),this.subscriptions.add(Rt.fromEvent(n,`transitionend`).subscribe(this.onTransitionEnd,e=>this.onError(`${fr.name} remove view transition error`,e))).add(Rt.fromEvent(n,`transitioncancel`).subscribe(this.onTransitionEnd,e=>this.onError(`${fr.name} remove view transition error`,e)));return}this.subscriptions.unsubscribe(),this.removeAllControls(),n.remove(),this.isRemoved=!0,this.willRemoved=!1,this.containerElement=null}}removeAllControls(e=!1){this.controls.forEach(t=>t.removeView(e))}removeNonInteractedControls(e=!1){this.controls.forEach(t=>{t.isInteracted||t.removeView(e)})}isInteracted(){return this.controls.some(e=>e.isInteracted)}fakeRemove(){this.isRemoved||=!0}getElement(){return this.containerElement}onProgress(e,t){t&&this.controls.forEach(t=>{t.onProgress(e)})}onResize(e){e&&this.controls.forEach(e=>{e.onResize()})}updateControlsShadowStyles(e){this.controls.forEach(t=>t.updateShadowStyles(e))}toggleBlinkAnimation(e){this.controls.forEach(t=>t.toggleBlinkAnimation(e))}}var pr=p(et(),1),mr=p(st(),1),hr=(e,t)=>typeof e==`string`?mr.default(e,t):pr.default(e,t),W=require(`@vkontakte/videoplayer-shared/es2018`),gr=require(`@vkontakte/videoplayer-statistics/es2018`),_r=require(`@vkontakte/videoplayer-shared/es2018`);function vr(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}}var yr=`video_interactive`,br=`videoint`,xr=250;class Sr{constructor(t){e(this,`isHidden`,void 0),e(this,`currentManifestId`,void 0),e(this,`currentChapterId`,void 0),e(this,`visitedChapterIds`,void 0),e(this,`onOpenPreviewClick`,void 0),e(this,`onError`,void 0),e(this,`lang`,void 0),e(this,`zoom`,void 0),e(this,`lastZoomInfo`,void 0),e(this,`isReady`,void 0),e(this,`ngEditor`,void 0),e(this,`ngEditorSize`,void 0),e(this,`graphWrapperElement`,void 0),e(this,`resizeObserver`,void 0),e(this,`manifest`,void 0),e(this,`handleZoomChange`,vr(e=>{this.lastZoomInfo=e},xr)),e(this,`onResize`,e=>{if(!this.isReady||this.isHidden||!e[0].contentRect.width||!e[0].contentRect.height)return;let t=this.getNextPoint();t&&this.ngEditor?.zoomTo(t,void 0,{isFromCenter:!0}),this.ngEditorSize={width:e[0].contentRect.width,height:e[0].contentRect.height}}),e(this,`handleChapterChange`,e=>{if(this.manifest){if(this.isHidden||this.hide(),!e?.id){this.onError?.call(this,`Chapter id is not found`);return}this.visitedChapterIds.add(e.id),this.ngEditor?.selectChapter(e.id),this.ngEditor?.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId=e.id,this.lastZoomInfo=null}}),e(this,`handleManifestChange`,(e,t=[])=>{if(this.isReady=!1,!Jt(e.graph.edit.chapters[0].x)){this.onError?.call(this,`Can't show graph`);return}this.lastZoomInfo=null,this.manifest=e,this.visitedChapterIds=new Set(t),this.ngEditor&&(this.manifest.metadata.id===this.currentManifestId?this.ngEditor.setVisitedChapters(Array.from(t)):(this.ngEditor.update(e),this.currentManifestId=this.manifest.metadata.id),this.isReady=!0)}),this.init(t)}init({root:e,onOpenPreviewClick:t,onError:n,lang:r,visitedChapters:i=[]}){this.isReady=!1,this.isHidden=!0,this.manifest=null,this.visitedChapterIds=new Set(i),this.onOpenPreviewClick=t,this.onError=n,this.lang=r??`ru`,this.zoom=.7,this.lastZoomInfo=null,this.currentManifestId=null,this.currentChapterId=null,this.ngEditor=null,this.ngEditorSize=null,this.graphWrapperElement=Cr(e),this.resizeObserver=new ResizeObserver(vr(this.onResize,xr)),this.resizeObserver.observe(this.graphWrapperElement)}getNextPoint(e=this.ngEditorSize){return!this.lastZoomInfo||!e?null:[(this.lastZoomInfo.x-e.width/2)/this.lastZoomInfo.value*-1,(this.lastZoomInfo.y-e.height/2)/this.lastZoomInfo.value*-1]}setVisitedChapters(e){this.visitedChapterIds=new Set([...this.visitedChapterIds,...e]),this.ngEditor?.setVisitedChapters(Array.from(this.visitedChapterIds))}updateVideosInfo(e){this.ngEditor?.updateVideosInfo(e)}async show(){this.manifest&&(this.ngEditor||await this.initNgEditor(),this.graphWrapperElement.style.display=`block`,!this.lastZoomInfo&&this.currentChapterId&&this.ngEditor?.focusChapter(this.currentChapterId),this.isHidden=!1)}async initNgEditor(){if(!this.manifest)return;let e;try{e=await _r.loadVKLangPack(this.lang,yr,br)}catch{this.onError?.call(this,`Unable to load graph language pack`)}let{GraphEditor:t}=await import(`@interactiveplatform/movika-graph-editor`);this.ngEditor=new t(this.graphWrapperElement,{mode:`view`,lang:this.lang===`ru`?`ru`:`en`,translation:e}),this.currentManifestId=this.manifest.metadata.id,this.ngEditor.update(this.manifest),this.ngEditor.setVisitedChapters(Array.from(this.visitedChapterIds)),this.currentChapterId&&this.ngEditor.selectChapter(this.currentChapterId),this.ngEditor.on(`control`,({name:e,...t})=>{e===`openPreview`&&`chapterId`in t&&this.onOpenPreviewClick?.call(this,t.chapterId)}),this.ngEditor.on(`zoom`,this.handleZoomChange),this.isReady=!0}hide(){this.graphWrapperElement.style.display=`none`,this.isHidden=!0}destroy(){this.hide(),this.manifest=null,this.resizeObserver.disconnect(),this.ngEditor?.setVisitedChapters([]),this.onOpenPreviewClick=void 0,this.ngEditor?.dispose(),this.graphWrapperElement.remove(),this.isReady=!1}}function Cr(e){let t=document.createElement(`div`);return t.style.position=`absolute`,t.style.top=`0`,t.style.left=`0`,t.style.height=`100%`,t.style.width=`100%`,t.style.display=`none`,e.append(t),t}var wr=3e3;class Tr{constructor(){e(this,`_containers`,[]),e(this,`_player`,null),e(this,`setPlayer`,e=>{this._player=e}),e(this,`setContainers`,e=>{this._containers=e}),e(this,`deleteContainer`,e=>{this._containers=this._containers.filter(t=>t.id!==e)}),e(this,`getNextInteractiveTime`,(e=wr)=>{if(!this._containers.length||this._player===null)return null;let t=-1,n=!1,r=Math.round(this._player.info.position$.getValue()*1e3);for(let i of this._containers){let a=i.startTime-e;if(a<=r&&(i.endTime&&r<=i.endTime||i.endTime===null)){n=!0;break}r<a&&(t=t===-1?a:Math.min(t,a))}return!n&&t!==-1?t:null})}}class Er{constructor(){e(this,`listeners`,{})}addListener(e,t){return this.listeners[e]=this.listeners[e]||[],this.listeners[e].push(t),this}on(e,t){return this.addListener(e,t)}once(e,t){this.listeners[e]=this.listeners[e]||[];let n=()=>{t(),this.off(e,n)};return this.listeners[e].push(n),this}off(e,t){return this.removeListener(e,t)}reset(){this.listeners={}}removeListener(e,t){let n=this.listeners[e]||[];for(let e=n.length;e>0;e--)if(n[e]===t){n.splice(e,1);break}return this}emit(e,...t){let n=this.listeners[e];return n?(n.forEach(e=>{e(...t)}),!0):!1}listenerCount(e){return this.rawListeners(e).length}rawListeners(e){return this.listeners[e]||[]}}class Dr{constructor(t){e(this,`raf`,void 0),e(this,`fn`,void 0),e(this,`fns`,[]),e(this,`addFn`,(e,t=!1)=>{Yt(e)&&(this.fns.push(e),t&&this.updateFn())}),e(this,`removeFn`,(e,t=!1)=>{this.fns=this.fns.filter(t=>t!==e),t&&this.updateFn()}),e(this,`updateFn`,()=>{this.fn=()=>{this.fns.forEach(e=>e()),this.raf&&this.forceRequestAnimation()}}),e(this,`forceRequestAnimation`,()=>{this.fn&&(this.raf=requestAnimationFrame(this.fn))}),e(this,`requestAnimation`,()=>{this.raf||this.forceRequestAnimation()}),e(this,`cancelAnimation`,()=>{this.raf&&=(cancelAnimationFrame(this.raf),void 0)}),t&&(this.fn=t,this.addFn(t))}release(){this.cancelAnimation(),this.fn=void 0,this.fns=[]}}var Or=p(yt(),1);class kr{constructor(t){e(this,`rootElement`,void 0),e(this,`isCssVarsSupported`,void 0),e(this,`rootElementProps`,{}),this.rootElement=t,this.isCssVarsSupported=kr.checkCssVarsSupport(t)}static checkCssVarsSupport(e){let t=`--test-key`,n=`test`;e.style.setProperty(t,n);let r=e.style.getPropertyValue(t)===n;return r&&e.style.removeProperty(t),r}getPropValue(e){return this.isCssVarsSupported?`var(${e})`:this.rootElementProps[e]??``}setup(e){if(this.rootElementProps={...this.rootElementProps,...e},this.isCssVarsSupported)for(let[t,n]of Or.default(e))this.rootElement.style.setProperty(t,n)}cleanup(){for(let e in this.rootElementProps)this.rootElement.style.removeProperty(e);this.rootElementProps={}}setProp(e,t){this.rootElementProps[e]=t,this.isCssVarsSupported&&this.rootElement.style.setProperty(e,t)}}var Ar=require(`@vkontakte/videoplayer-shared/es2018`);class jr{constructor(t){e(this,`loaders`,void 0),this.loaders={chapterLoaders:t?.chapterLoaders??[],manifestLoaders:t?.manifestLoaders??[]}}async exec(e,t){return Mr(...this.loaders[e])(t)}}function Mr(...e){return async function(t){let n=[...e];for(;n.length>0;)t=await n.shift()(t);return t}}function Nr(e,t,n){return e?{...e,[t]:e[t]?[n,...e[t]]:[n]}:{[t]:[n]}}function Pr({actions:e,errors:t,chapterId:n,...r}){if(n){let i=e.getManifest();if(i){let a=e.getChapter(i.chapters,n);if(a){let n=e.getMedia(i.media,a.videoId),o=e.getGraph(i.graph,a.id);return n?{...r,actions:e,errors:t,result:{chapter:a,media:n,graph:o}}:{...r,errors:Nr(t,Pr.name,`Could not find media`),actions:e}}}}return{...r,errors:Nr(t,Pr.name,`Could not find chapter`),actions:e}}var{NativeAbortSignal:Fr,NativeAbortController:Ir}=function(e){return{NativeAbortSignal:e.AbortSignal,NativeAbortController:e.AbortController}}(typeof self<`u`?self:global);function Lr(e){let t;try{t=new Event(`abort`)}catch{typeof document<`u`?document.createEvent?(t=document.createEvent(`Event`),t.initEvent(`abort`,!1,!1)):(t=document.createEventObject(),t.type=`abort`):t={type:`abort`,bubbles:!1,cancelable:!1}}return t.reason=e,t}function Rr(e){if(e===void 0)if(typeof document>`u`)e=Error(`This operation was aborted`),e.name=`AbortError`;else try{e=new DOMException(`signal is aborted without reason`),Object.defineProperty(e,`name`,{value:`AbortError`})}catch{e=Error(`This operation was aborted`),e.name=`AbortError`}return e}class zr{constructor(){Object.defineProperty(this,`listeners`,{value:{},writable:!0,configurable:!0})}addEventListener(e,t,n){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:n})}removeEventListener(e,t){if(!(e in this.listeners))return;let n=this.listeners[e];for(let e=0,r=n.length;e<r;e++)if(n[e].callback===t){n.splice(e,1);return}}dispatchEvent(e){if(!(e.type in this.listeners))return;let t=this.listeners[e.type].slice();for(let n=0,r=t.length;n<r;n++){let r=t[n];try{r.callback.call(this,e)}catch(e){Promise.resolve().then(()=>{throw e})}r.options&&r.options.once&&this.removeEventListener(e.type,r.callback)}return!e.defaultPrevented}}class Br extends zr{constructor(){super(),this.listeners||zr.call(this),Object.defineProperty(this,`aborted`,{value:!1,writable:!0,configurable:!0}),Object.defineProperty(this,`onabort`,{value:null,writable:!0,configurable:!0}),Object.defineProperty(this,`reason`,{value:void 0,writable:!0,configurable:!0})}toString(){return`[object AbortSignal]`}dispatchEvent(e){e.type===`abort`&&(this.aborted=!0,typeof this.onabort==`function`&&this.onabort.call(this,e)),super.dispatchEvent(e)}throwIfAborted(){let{aborted:e,reason:t=`Aborted`}=this;if(e)throw t}static timeout(e){let t=new Vr;return setTimeout(()=>t.abort(new DOMException(`This signal is timeout in ${e}ms`,`TimeoutError`)),e),t.signal}static any(e){let t=new Vr;function n(){t.abort(this.reason),r()}function r(){for(let t of e)t.removeEventListener(`abort`,n)}for(let r of e)if(r.aborted){t.abort(r.reason);break}else r.addEventListener(`abort`,n);return t.signal}}class Vr{constructor(){Object.defineProperty(this,`signal`,{value:new Br,writable:!0,configurable:!0})}abort(e){let t=Rr(e),n=Lr(t);this.signal.reason=t,this.signal.dispatchEvent(n)}toString(){return`[object AbortController]`}}typeof Symbol<`u`&&Symbol.toStringTag&&(Vr.prototype[Symbol.toStringTag]=`AbortController`,Br.prototype[Symbol.toStringTag]=`AbortSignal`);function Hr(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 Ur(e){typeof e==`function`&&(e={fetch:e});let{fetch:t,Request:n=t.Request,AbortController:r,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i=!1}=e;if(!Hr({fetch:t,Request:n,AbortController:r,__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL:i}))return{fetch:t,Request:a};let a=n;(a&&!a.prototype.hasOwnProperty(`signal`)||i)&&(a=function(e,t){let r;t&&t.signal&&(r=t.signal,delete t.signal);let i=new n(e,t);return r&&Object.defineProperty(i,`signal`,{writable:!1,enumerable:!1,configurable:!0,value:r}),i},a.prototype=n.prototype);let o=t;return{fetch:(e,t)=>{let n=a&&a.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(n){let r;try{r=new DOMException(`Aborted`,`AbortError`)}catch{r=Error(`Aborted`),r.name=`AbortError`}if(n.aborted)return Promise.reject(r);let i=new Promise((e,t)=>{n.addEventListener(`abort`,()=>t(r),{once:!0})});return t&&t.signal&&delete t.signal,Promise.race([i,o(e,t)])}return o(e,t)},Request:a}}var G=typeof globalThis==`object`&&globalThis||typeof window==`object`&&window,Wr=`fetch`in G&&Hr({fetch:G.fetch,Request:G.Request,AbortController:G.AbortController}),Gr=Wr?Ur({fetch:G.fetch,Request:G.Request,AbortController:G.AbortController}):void 0,Kr=Wr?Gr.fetch:G.fetch;Wr?Gr.Request:G.Request,Wr||G.AbortController,Wr||G.AbortSignal;var qr=(e=``,t=``)=>{let n=e.split(`.`),r=t.split(`.`),i=0;for(let e=0;e<Math.max(n.length,r.length)&&!i;e++)i=n[e]>r[e]?1:n[e]<r[e]?-1:0;return i},Jr=async e=>{try{let t={},n;if(Kt(e)){n=new URL(e).href;let r=await Kr(n);if(!r.ok)return{};t=await r.json()}else if(Gt(e))t=e;else return{};if(!xn(t))return{};let r=t.metadata.media;if(Kt(r)&&!(`media`in t))try{let e;n?e=new URL(r,n).href:(e=new URL(r).href,n=e);let i=await Kr(e);if(!i.ok)throw Error();t.metadata.media=await i.json()}catch{return ti(t.metadata.version)?{manifest:t}:{}}return{manifest:t,manifestURL:n}}catch{return{}}};async function Yr(e){let{manifest:t,manifestURL:n}=await Jr(e);if(!t)throw Error(`Failed on fetch`);let r=L.migrateManifestToLatestVersion(t);return r.media=$r(r.media,n),delete r.metadata.media,r}function Xr(e,t){if(t)return e.find(e=>e.id===t)}function Zr(e,t){if(e.edit?.chapters)return e.edit.chapters.find(e=>e.id===t);if(e.view?.chapters)return e.view.chapters.find(e=>e.id===t)}function Qr(e,t){return e.videos.find(e=>e.id===t)}function $r(e,t){return{...e,videos:e.videos.map(e=>({...e,variants:e.variants.map(e=>{let n=`url`in e?e.url:``,r=ei(n,t);return{...e,url:r||n}})}))}}function ei(e=``,t){try{return new URL(e,t).href}catch{return``}}function ti(e){return qr(e,`3.2.0`)>=0}class ni extends jr{constructor(t,n){super(t),e(this,`manifest`,null),e(this,`chapter`,null),e(this,`media`,null),e(this,`graph`,null),e(this,`prevChapter$`,new Ar.ValueSubject(null)),e(this,`onError`,void 0),this.onError=n,this.release()}release(){return this.manifest=null,this.chapter=null,this.media=null,this.graph=null,this.prevChapter$.next(null),this}async setManifest(e){this.release();let t=await this.exec(`manifestLoaders`,{actions:{addErrorMessage:Nr},result:null,errors:null,source:e});return t.errors&&this.errorHandler(t.errors),this.manifest=await Yr(t.result??e),this}async setInitial(){return this.setNext()}async setNext(e=this.manifest?.metadata.initChapterId){if(!e)return this;this.prevChapter$.next(this.chapter);let t=await this.exec(`chapterLoaders`,Pr({actions:{getManifest:()=>this.manifest,getCurrent:this.getCurrent,getGraph:Zr,getChapter:Xr,getMedia:Qr,getByBranches:this.getByBranches.bind(this),addErrorMessage:Nr},result:null,errors:null,chapterId:e}));return t.errors&&this.errorHandler(t.errors),t.result&&(this.chapter=t.result.chapter,this.media=t.result.media,this.graph=t.result.graph),this}errorHandler(e){this.onError(e),console.error(`Something went wrong with loaders`,{errors:e})}getInitial(){return this.getByChapterId(this.manifest?.metadata.initChapterId)||null}getByChapterId(e=this.manifest?.metadata.initChapterId){if(!e||!this.manifest)return null;let t=Xr(this.manifest.chapters,e);if(t){let e=Qr(this.manifest.media,t.videoId),n=Zr(this.manifest.graph,t.id);if(e)return{chapter:t,media:e,graph:n}}return null}getBranches(e=this.chapter?.id){if(e===this.chapter?.id)return this.getByBranches(this.chapter?.branches);{let t=Xr(this.manifest?.chapters||[],e);return this.getByBranches(t?.branches)}}getByBranches(e=[]){return e.reduce((e,t)=>{let n=this.getByChapterId(t.chapterId);return n&&e.push(n),e},[])}getCurrent(){return{chapter:this.chapter,media:this.media,graph:this.graph}}isInitialChapter(){return this.chapter?.id===this.manifest?.metadata.initChapterId}isEndChapter(){return this.chapter?R(this.chapter):!1}}var ri=p(Ct(),1),ii=require(`@vkontakte/videoplayer-core/es2018`),ai=require(`@vkontakte/videoplayer-shared/es2018`),oi=e=>{let t=e.variants.find(e=>e.payload?.type===`vk`);if(t&&t.payload){let[e,n]=t.payload.id.split(`_`);return[e,n]}return[]},si=p(Ct(),1);function ci(){let e=new Map;function t({listId:t=Math.random().toString(),itemId:n=Math.random().toString(),...r}){let i=e.get(t),a={...r};return i?i[n]=a:e.set(t,{[n]:a}),{listId:t,itemId:n,...r}}function n(e){e.player.destroy(),e.container.remove(),e.subscription.unsubscribe(),e.statistics?.oneStat.destroy(),e.statistics?.statSubscription.unsubscribe()}function r(t,r){let i=e.get(t);if(!i)throw Error(`Can't remove. Not find.`);if(r){let a=i[r];a&&n(a),delete i[r],Object.keys(i).length||e.delete(t)}else{for(let e of si.default(i))n(e);e.delete(t)}}function i(){for(let t of e)r(t[0])}return{createPlayer:t,removePlayer:r,map:e,removeAll:i}}var li=p(Xe(),1),ui=p(Xe(),1),di=(e,...t)=>typeof e==`string`?e.includes(...t):ui.default(e,...t);function fi(e,t=[]){let n={},r,i=!t.length;for(let a of e.variants)if(!r&&`cover`in a&&(r=a.cover),`url`in a)switch(a.type.toLowerCase()){case`mp4`:(i||li.default(t,`mp4`))&&(n.MPEG={...n.MPEG,[a.standard??`Invariant quality`]:a.url});break;case`mpeg`:(i||li.default(t,`mpeg`))&&(n.MPEG={...n.MPEG,[a.standard??`Invariant quality`]:a.url});break;case`hls`:(i||li.default(t,`hls`))&&(n={...n,HLS:{type:`url`,url:a.url}});break;case`dash`:(i||li.default(t,`dash`))&&(n={...n,DASH_SEP:{compatibilityMode:!0,type:`url`,url:a.url}});break;default:break}return{sources:n,thumbUrl:r,title:e.title??``}}var pi=(e,t)=>{let n=e.info.currentQuality$.getValue(),r=e.info.availableQualities$.getValue();n!==t&&di(r,t)&&(e.setQuality(t),e.setAutoQuality(!1))},mi=2;function hi(e){let t=ci(),n=new ai.Subscription,r={},i=null,a=!1,o,s=new ai.ValueSubject(null);e&&c(e);function c(e){i=e}function l(e,n,o){if(!i)throw Error(`need to set interactive controller`);if(!i.options)return;let c=(t.map.get(e)??{})[n];if(c){r={chapterId:o,listId:e,itemId:n,...c};let l=r.player;r.subscription.add(l.info.currentQuality$.subscribe(e=>{let n=l.info.position$.getValue(),r=l.info.isAutoQualityEnabled$.getValue();if(!(!e||!n||r))for(let n of t.map)ri.default(n[1]).forEach(({player:t})=>{pi(t,e)})})).add(l.events.started$.subscribe(()=>{u(n)})),c.container.remove(),i.setPlayer(c.player),a||=(i.init(),!0),s.next({player:r.player,config:r.config,statistics:r.statistics});return}throw Error(`Can't set. Not find.`)}async function u(e){if(!i)throw Error(`need to set interactive controller`);if(Qt(r)||e!==r.itemId)return;let t=i.getChapterBranches(),n=new Set;for(let e of t)n.has(e.media.id)||(await f({media:e.media,chapterId:e.chapter.id,setAsActive:!1,title:e.chapter.label}),n.add(e.media.id))}async function d({chapter:{id:e},manifestVideo:n}){if(Qt(r)||!i)return;let a=r.player.info.muted$.getValue(),o=r.player.info.currentQuality$.getValue(),s=r.player.info.isAutoQualityEnabled$.getValue(),c=r.player.info.volume$.getValue(),u=r.player.info.currentPlaybackRate$.getValue(),d=!s,p=!1;for(let s of t.map)if(s[0]===n.id&&!i.state.isReplay$.getValue()){let n=Object.keys(s[1]);for(let i of n)i===r.itemId?(n.length<mi||(p=!0),t.removePlayer(s[0],i)):(p=!0,l(s[0],i,e),d?pi(r.player,o):r.player.setAutoQuality(!0),r.player.setVolume(c),r.player.setMuted(a),r.player.setPlaybackRate(u))}else t.removePlayer(s[0]);p||(await f({media:n,chapterId:e,setAsActive:!0,playbackRate:u}),d?pi(r.player,o):r.player.setAutoQuality(!0),r.player.setVolume(c),r.player.setMuted(a))}async function f({media:e,chapterId:n,prefetch:a=!0,setAsActive:s=!0,autoplay:c=!1,preferredExt:u,title:d,playbackRate:f}){var p,m,h,g;let _=Math.random().toString(),v=document.createElement(`div`);o.append(v);let y;if(!(i==null||(p=i.options)==null)&&p.vkVideoLoader){let t=oi(e);t.length&&(y=await i.options.vkVideoLoader(...t))}let b={...(i==null||(m=i.options)==null?void 0:m.coreConfig)||void 0},x={container:v,sources:fi(e,u).sources,...y==null||(h=y.videos)==null?void 0:h[0],title:d,failoverHosts:y?.failoverHosts||[]},S=new ii.Player(b,ai.TracerFactory.createRootTracer());S.initVideo(x);let C=null;if(y?.videos&&i?.options.createOneStat){let e=y.videos[0],t=i.options.createOneStat(e),n=new ai.Subscription;t&&(n.add(t.attachTo(S)),C={oneStat:t,statSubscription:n})}let w=new ai.Subscription,T=r==null||(g=r.player)==null?void 0:g.info.isAutoQualityEnabled$.getValue();w.add(S.events.canplay$.subscribe(function(){T||pi(S,r.player.info.currentQuality$.getValue()),f&&S.setPlaybackRate(f)}));let E=t.createPlayer({listId:e.id,itemId:_,player:S,container:v,sources:fi(e,u).sources,config:x,subscription:w,statistics:C});return s&&l(e.id,E.itemId,n),c&&E.player.play(),a&&!c&&E.player.prepare(),{player:E.player,config:E.config,statistics:E.statistics}}function p(){m(),i=null,o.remove()}function m(){n.unsubscribe(),t.removeAll(),r={},a=!1}async function h(){if(!i)throw Error(`need to set interactive controller`);m(),o=document.createElement(`div`);let{media:e,chapter:t}=i.getCurrentChapter();e&&t?(n.add(i.events.chapterChanged$.subscribe(d)),await f({media:e,chapterId:t.id,title:t.label})):console.error(`not found`)}return{map:t.map,removePlayer:t.removePlayer,init:h,setInteractiveController:c,createPlayer:f,removeAll:p,getActivePlayer:function(){return r},activePlayerChanged:s}}var K={graph:`graph`,interactives:`interactives`,chapterChanged:`chapter-changed`,playerChanged:`player-changed`,manifestChanged:`manifest-changed`,errors:`errors`,eachTick:`eachTick`,historyInited:`history-inited`,historyDestroyed:`history-destroyed`},gi={visibility:`visibility`,watchAgainClicked:`watchAgainClicked`},q={actionChoiceCanceled:`action-choice-canceled`,actionChoice:`action-choice`,actionExecution:`action-execution`,visibility:`visibility`,containerRemoved:`container-removed`,rangeEnded:`range-ended`},_i=require(`@vkontakte/videoplayer-shared/es2018`);function vi(e){return function(...t){return e(...t.reverse())}}function yi(e,...t){return(...n)=>Gt(t[0])&&Gt(n[0])?e({...t[0],...n[0]}):e(...t,...n)}class bi{constructor({player:t,container:n,branches:r,selectBranches:i,interactiveEvents:a,globalEvents:o,globalEventEmitter:s,getContainerEventState:c,permanentTextControls:l,interactiveTimeOpenUri:u,disabledControls$:d,onRemove:f,onError:p,disableTextControlContainerVisibilityEvents:m=!1,features:h}){e(this,`container`,void 0),e(this,`branches`,void 0),e(this,`selectBranches`,void 0),e(this,`subscription`,void 0),e(this,`player`,void 0),e(this,`interactiveEvents`,void 0),e(this,`getContainerEventState`,void 0),e(this,`isPermanentText`,void 0),e(this,`interactiveTimeOpenUri`,void 0),e(this,`disabledControls$`,void 0),e(this,`onRemove`,void 0),e(this,`globalEventEmitter`,void 0),e(this,`gameState`,void 0),e(this,`isSelectedControlEvent`,void 0),e(this,`isSelectedContainerEvent`,void 0),e(this,`globalEvents`,void 0),e(this,`onError`,void 0),e(this,`disableTextControlContainerVisibilityEvents`,void 0),e(this,`features`,void 0),e(this,`hide`,()=>{setTimeout(()=>{if(this.gameState!==4&&!(Nn(this.container.container.events)&&this.gameState===3||this.selectBranches.state.isExpect)){if(this.gameState!==2){var e;(e=this.container).hide?.call(e)}this.emitContainerVisibilityEvent(!1)}})}),e(this,`show`,()=>{if(!(this.gameState!==2||this.isSelectedControlEvent))if(this.container.getElement()){var e;let{hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState();if((e=this.container).show?.call(e),this.interactiveTimeOpenUri&&t||this.disableTextControlContainerVisibilityEvents)return;this.emitContainerVisibilityEvent(!0,!1)}else{let e={isDisabled:()=>this.container.isDisabled,branches:this.branches,containerId:this.container.container.id,onDetachContainer:()=>{this.removeView(),this.emitContainerVisibilityEvent(!1)},onEvent:(e,t)=>{let{isExpectTime:n,hasOtherExpect:r,hasOpenURIEvent:i,hasOpenURIEventInCurrentContainer:a,isAllOpenURIEventsValid:o,hasShouldOpenNowEvent:s}=this.getContainerEventState(),c=this.interactiveTimeOpenUri&&!a,l=this.interactiveTimeOpenUri&&a;if((!this.interactiveTimeOpenUri||c)&&(this.isSelectedControlEvent=!0),e!==!1){if(!this.selectBranches.state.isExpect&&(!this.interactiveTimeOpenUri||c)){if(this.interactiveTimeOpenUri){let e=!r&&!o&&a;e&&this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:`container`,type:`container-fake-removed`,removeAllOpenURI:e})}this.removeView()}this.emitContainerVisibilityEvent(!1)}if(this.gameState===4||this.gameState===3||this.selectBranches.state.isExpect||this.interactiveTimeOpenUri&&i&&this.gameState!==5){if(l){let e=((e,t,n,r)=>!e&&!t&&n||e&&!t&&n&&!r||e&&!t&&n&&r)(n,r,o,this.isSelectedContainerEvent);this.fakeRemoveView(e)}else this.removeView(),this.emitContainerVisibilityEvent(!1);(!n||!r||!s)&&(this.selectBranches.stopExpect(),t())}},isEOV:()=>this.gameState===4},n=yi(this.selectBranches.onControlEvent,e),r=(this.player?.info.duration$.getValue()??1/0)*1e3;if(this.container.createView({eventCallback:n,videoDurationMs:r}),this.disableTextControlContainerVisibilityEvents||this.emitContainerVisibilityEvent(!0,!0),this.disabledControls$.getValue()){var t;(t=this.container).disable?.call(t)}}}),e(this,`onEndOfVideo`,()=>{this.gameState=4,this.selectContainerEvent(!0)}),e(this,`whilePlaying`,()=>{let e=this.player.experimental.element$.getValue(),t=e instanceof HTMLVideoElement;if(this.features.enableAvPlayerSupport&&(t||=e instanceof HTMLObjectElement&&e?.getAttribute(`type`)===`application/avplayer`),!(t&&e?.readyState)||this.isRemovedOrDestroyed()&&!this.isPermanentText)return;let n=this.player.getExactTime();if(jn(n,this.container.container))this.gameState!==1&&(this.gameState=1,this.onBeforeStartTime());else if(Mn(n,this.container.container))this.gameState!==2&&(this.gameState=2,this.onStartTime());else if(this.gameState!==3){let e=this.gameState;this.gameState=3,e===2&&this.onEndTime()}else{let{hasOpenURIEventInCurrentContainer:e}=this.getContainerEventState(),t=this.selectBranches.state.isExpect,n=this.interactiveTimeOpenUri&&e;if(n&&!t){let e=this.container.getElement();if(e){if(e.style.visibility!==`hidden`){var r;(r=this.container).hide?.call(r)}this.container.isRemoved||this.fakeRemoveView()}}!this.isPermanentText&&!n&&this.removeView()}let i=Mn(n,this.container.container),a=this.container.container.startTime?[this.container.container.startTime,this.container.container.endTime??1/0]:[],o={subjectId:this.container.container.id,subjectName:`container`,range:a,currentTime:n,isInteractiveTime:i};this.container.onProgress(n*1e3,i),this.globalEventEmitter.emit(K.eachTick,o),this.globalEvents.eachTick$.next(o)}),this.container=n,this.branches=r,this.selectBranches=i,this.subscription=new _i.Subscription,this.player=t,this.interactiveEvents=a,this.getContainerEventState=c;let g=In(n.container.controls);this.isPermanentText=l&&g,this.disableTextControlContainerVisibilityEvents=m&&g,this.interactiveTimeOpenUri=u,this.disabledControls$=d,this.onRemove=f,this.globalEventEmitter=s,this.gameState=0,this.globalEvents=o,this.onError=p,this.features=h,this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.registerEvents()}emitContainerVisibilityEvent(e,t=!1){e?(this.globalEventEmitter.emit(K.interactives,{subjectId:this.container.container.id,subjectName:`container`,type:q.visibility,visibility:e,isFirst:t}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:`container`,type:`visibility`,visibility:e,isFirst:t})):(this.globalEventEmitter.emit(K.interactives,{subjectId:this.container.container.id,subjectName:`container`,type:q.visibility,visibility:!1}),this.globalEvents.interactiveVisibilityChanged$.next({subjectId:this.container.container.id,subjectName:`container`,type:`visibility`,visibility:e}))}registerEvents(){this.subscription.add(this.player.events.playing$.subscribe(this.show)).add(this.player.events.paused$.subscribe(this.hide)).add(this.player.events.ended$.subscribe(this.onEndOfVideo)).add(this.disabledControls$.subscribe(e=>{if(e){var t;(t=this.container).disable?.call(t)}else{var n;(n=this.container).enable?.call(n)}})),this.subscription.add(this.container.error$.subscribe(this.onError))}selectContainerEvent(e=!1){let{isExpectEventForCurrentContainer:t}=this.getContainerEventState();this.interactiveEvents.containersEventsCallState.setCalled({timestamp:e?1/0:this.container.container.endTime??1/0,id:this.container.container.id}),!(this.isSelectedControlEvent||this.isSelectedContainerEvent)&&(this.isSelectedContainerEvent=!0,!t&&!this.container.isRemoved&&this.selectBranches.setManifestContainerEvents({container:this.container.container,branches:this.branches,isEOV:e}),!e&&this.interactiveEvents.exec(this.container.container.endTime??1/0))}onStartTime(){this.show()}onEndTime(){this.selectContainerEvent(!1);let{isExpectTime:e,hasOpenURIEventInCurrentContainer:t}=this.getContainerEventState(),n=this.interactiveTimeOpenUri?e||t:Nn(this.container.container.events)||e;(this.isSelectedControlEvent||!n)&&this.removeView()}onBeforeStartTime(){var e;(e=this.container).hide?.call(e),this.emitContainerVisibilityEvent(!1)}onResize(e){this.container.onResize(e)}reset(){this.isSelectedControlEvent=!1,this.isSelectedContainerEvent=!1,this.gameState=1}removeView(e=this.features.controlsHideAnimation){if(e){if(this.isRemovedOrDestroyed())return;this.container.removeNonInteractedControls(!0),this.container.removeView(!0,!0)}else this.container.removeView();this.globalEventEmitter.emit(K.interactives,{subjectId:this.container.container.id,subjectName:`container`,type:q.containerRemoved,visibility:!1}),this.globalEvents.interactiveContainerRemoved$.next({subjectId:this.container.container.id,subjectName:`container`,type:`container-removed`}),this.gameState=5,this.onRemove?.call(this)}fakeRemoveView(e=!1){this.container.isRemoved||this.globalEvents.interactiveContainerFakeRemoved$.next({subjectId:this.container.container.id,subjectName:`container`,type:`container-fake-removed`,removeAllOpenURI:e}),this.container.fakeRemove()}updateControlsShadowStyles(e){this.container.updateControlsShadowStyles(e)}toggleBlinkAnimation(e){this.container.toggleBlinkAnimation(e)}isInteracted(){return this.container.isInteracted()}isRemovedOrDestroyed(e=!0){let t=e?this.container.willRemoved:!1;return this.gameState===5||t||this.gameState===6}destroy(e=!1){this.reset(),this.removeView(e),this.gameState=6,this.subscription.unsubscribe(),this.branches=[],this.interactiveEvents.containersEventsCallState.setCalled({timestamp:this.container.container.endTime??1/0,id:this.container.container.id})}}var xi=(e=[])=>e.reduce((e,t,n)=>{if(kn((t?.controls??[]).filter(e=>!Sn(e)))){let r=[t.startTime??0,t.endTime??1/0],i={id:t.id,isRemoved:!1};if(!n)e.push({subjects:[i],range:r});else{let t=[],n=-1/0,a=1/0,o=[],s=[];for(let c=0;c<e.length;c++){let l=e[c];if(s.push(...l.subjects),l.range[0]<a&&(a=l.range[0]),l.range[1]>n&&(n=l.range[1]),r[0]>=l.range[0]&&r[1]<=l.range[1])return e[c].subjects.push(i),e;r[0]<l.range[0]&&r[1]>l.range[0]&&(t.push(c),o=o.concat(l.subjects)),r[0]>=l.range[0]&&r[0]<=l.range[1]&&(t.push(c),o=o.concat(l.subjects),r[0]=l.range[0]),r[1]>=l.range[0]&&r[1]<=l.range[1]&&(t.push(c),o=o.concat(l.subjects),r[1]=l.range[1])}if(s.push(i),r[0]<=a&&r[1]>=n)return[{subjects:s,range:r}];t.length&&t.reverse().forEach(t=>{e.splice(t,1)}),e.push({subjects:o.concat([i]),range:r})}}return e},[]).sort((e,t)=>e.range[0]-t.range[0]),Si=p(Xe(),1),Ci=p(Ct(),1),wi=p(Ft(),1);function Ti(){let e={};function t(){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&delete e[t]}function n(t){let n={};for(let r in e)+r<=t&&(n[r]=e[r]);return n}function r(t){let n={};for(let r in e)+r>=t&&(n[r]=e[r]);return n}function i({timestamp:t,priority:n,initiator:r}){if(Zt(t)){let i=e[t]??null;if(i&&n&&en(n,!0)){let e={},t=i[n];return t&&(e={...e,...t}),e=Qt(e)?null:e,e&&en(r,!0)?e[r]??null:e}return i}return null}function a({timestamp:t,priority:n,initiator:r}){if(Zt(t))if(e[t]){if(n&&en(n,!0))if(e[t][n]){if(r&&en(r,!0))if(e[t][n][r]){if(delete e[t][n][r],!Qt(e[t][n]))return!0}else return!1;if(delete e[t][n],!Qt(e[t]))return!0}else return!1;return delete e[t]}else return!1;return!1}function o({timestamp:t,priority:n,initiator:r,...i}){var a;!((a=e[t])==null||(a=a[n])==null)&&a[r]?e[t][n][r].push({...i}):e[t]?.[n]?e[t][n]={...e[t][n],[r]:[{...i}]}:e[t]?e[t]={...e[t],[n]:{[r]:[{...i}]}}:e[t]={[n]:{[r]:[{...i}]}}}return{map:e,remove:a,add:o,removeAll:t,get:i,getLte:n,getGte:r}}var Ei=[L.EventActionTypes.expect,L.EventActionTypes.setNextBranch],Di=1/0;function Oi(e,t){let n=e,r,i=ki(t),a=Ti(),o,s=()=>{p(),_()},c=e=>{a.add.call(void 0,e),m()},l=(e=[])=>{for(let t of e)if(t.action(),Si.default(Ei,t.actionType))break},u=(e=1/0)=>{let t=Ai(a.get({timestamp:e,priority:`control`})??{}),n=Ai(a.get({timestamp:e,priority:`container`})??{}),r=Ai(a.get({timestamp:e,priority:`chapter`})??{});return[...t,...n,...r]},d=e=>{i.isReady(e)&&l(u(e))},f=()=>{l([...Ai(a.get({timestamp:1/0,priority:`chapter`})??{})])},p=()=>{r&&=(o?.unsubscribe(),void 0)},m=()=>{r||(r=()=>setTimeout(()=>{d(1/0)}),o=n.events.ended$.subscribe(r))},h=e=>{p(),n=e},g=e=>{e.priority===`container`&&i.resetCalled(e.timestamp),a.remove(e)},_=()=>{i.release(),a.removeAll()};return{setPlayer:h,add:c,remove:g,exec:d,execEndOfVideo:f,listen:m,unlisten:p,release:s,containersEventsCallState:i,getPreparedToExecActions:u}}function ki(e){let t=new Map;return{setCalled:({timestamp:e,id:n})=>{let r=t.get(e);r&&r[n]!==void 0&&(r[n]=!0)},setData:(e=[])=>{for(let n of e){let e=n.endTime??Di,r=t.get(e);t.set(e,{...r,[n.id]:!1})}},resetCalled:e=>{let n=t.get(e);if(n)for(let e in n)n[e]=!1},isReady:n=>{let r=t.get(n);if(!r)return!0;let i=Ci.default(r);return e?i.some(e=>e):!i.some(e=>!e)},release:()=>t.clear()}}function Ai(e){return wi.default(Ci.default(e)).sort(e=>e.actionType===L.EventActionTypes.expect?-1:1)}var ji={videoContentHeight:0,videoContentWidth:0},Mi=e=>{let{height:t,width:n}=e.info.intrinsicVideoSize$.getValue()||{};if(!(t&&n))return ji;let{clientHeight:r,clientWidth:i}=e.experimental.element$.getValue()||{};if(!(r&&i))return ji;let a=t/n,o=r/i,s,c;return o>a?(c=i,s=i*a):o<a?(c=r/a,s=r):(c=i,s=r),{videoContentWidth:c,videoContentHeight:s}},Ni=250;function Pi(e){let t,n=new ResizeObserver(e=>{a(e),t=a.bind(null,e)});function r(t){let{parentElement:n,player:r,cssVarsManager:i}=e();if(!n||!r)return;let{videoContentWidth:a,videoContentHeight:o}=Mi(r);i.setup({"--interactive-content-width":`${a}px`,"--interactive-content-height":`${o}px`,"--interactive-width":`${t[0].contentRect.width}px`,"--interactive-height":`${t[0].contentRect.height}px`})}function i(){let{parentElement:t}=e();t.removeAttribute(`style`)}let a=vr(t=>{let{fns:n=[]}=e();r(t);for(let e of n)e()},Ni);function o(){t=void 0,n.disconnect(),i()}return{resizeObserver:n,calc:()=>{t?.()},release:o}}var Fi=e=>Math.floor(Math.random()*e),Ii=e=>{let t=e.length,n=1/0,r=null;for(;t--;){let i=e[t],a=i.weight??1;a<n&&(n=a,r=i)}return r},Li=e=>{let t=e.length,n=-1/0,r=null;for(;t--;){let i=e[t],a=i.weight??0;a>n&&(n=a,r=i)}return r},Ri=e=>{let t=e.length;return e[Fi(t)]},zi=1,Bi=e=>{let t=0;for(let n=0;n<e.length;++n)t+=e[n].weight??zi;let n=Math.random()*t;t=0;for(let r=0;r<e.length-1;++r)if(t+=e[r].weight??zi,t>=n)return e[r];return e[e.length-1]},Vi={shouldOpenNow:!0,isDetachContainer:!0},Hi=`after-expect`,Ui=(e,t=!1)=>({...e,args:t?{...e.args,...Vi}:{...Vi,...e.args}}),Wi=({globalEventEmitter:e,globalEvents:t,player:n,interactiveEvents:r})=>{let i={isExpect:!1},a=()=>{i.isExpect&&=!1},o=({action:n,controlType:i,controlId:a,containerId:o,branches:s=[],onEvent:c,isEOV:l=()=>!1,isDisabled:d=()=>!1})=>{let f=Ui(n,l()),_={timestamp:1/0,priority:`control`,initiator:a,actionType:f.type},v=d(),y=e.emit.bind(e,K.interactives,{subjectId:a,subjectType:i,subjectName:`control`,type:v?q.actionChoiceCanceled:q.actionChoice,actionType:n.type,payload:{invokeImmediately:f.args.shouldOpenNow,containerId:o,...f.args}}),b=()=>{t.interactiveActionChoice$.next({subjectId:a,subjectType:i,subjectName:`control`,type:v?`action-choice-canceled`:`action-choice`,actionType:n.type,payload:{invokeImmediately:f.args.shouldOpenNow,containerId:o,...f.args}})};if(v){y(),b();return}switch(f.type.trim().toLowerCase()){case L.EventActionTypes.setNextBranch.trim().toLowerCase():{let e=s.find(e=>e.id===f.args.branchId);if(!e)return;c(f.args.isDetachContainer,p.bind(null,{subjectId:a,subjectName:`control`})),y(),b(),f.args.shouldOpenNow?h({subjectId:a,subjectName:`control`,subjectType:i,action:f,payload:{chapterId:e.chapterId,autoSelect:!1}}):r.add({..._,action:h.bind(null,{subjectId:a,subjectName:`control`,subjectType:i,action:f,payload:{chapterId:e.chapterId,autoSelect:!1}})});return}case L.EventActionTypes.continuePlayback.trim().toLowerCase():c(f.args.isDetachContainer,p.bind(null,{subjectId:a,subjectName:`control`})),y(),b(),f.args.shouldOpenNow?m({subjectId:a,subjectName:`control`,subjectType:i,action:n}):r.add({..._,action:m.bind(null,{subjectId:a,subjectName:`control`,subjectType:i,action:n})});return;case L.EventActionTypes.openURI.trim().toLowerCase():c(f.args.isDetachContainer,p.bind(null,{subjectId:a,subjectName:`control`})),y(),b(),f.args.shouldOpenNow?g({subjectId:a,subjectName:`control`,subjectType:i,action:f,payload:{URI:n.args.uri}}):r.add({..._,action:g.bind(null,{subjectId:a,subjectName:`control`,subjectType:i,action:f,payload:{URI:n.args.uri}})});return;default:{let e=`Unexpected control event`;u(new A(1,1,{message:e}),e);return}}},s=({action:n,container:{id:i,endTime:a},branches:o=[],isEOV:s=!1,autoSelected:c=!1})=>{let l=Ui(n,s),d={timestamp:!l.args.shouldOpenNow||s?1/0:a??1/0,priority:`container`,initiator:i,actionType:l.type},f=e.emit.bind(e,K.interactives,{subjectId:i,subjectName:`container`,type:q.actionChoice,actionType:l.type,payload:{invokeImmediately:l.args.shouldOpenNow,...l.args}}),p=()=>{t.interactiveActionChoice$.next({subjectId:i,subjectName:`container`,type:`action-choice`,actionType:l.type,payload:{invokeImmediately:l.args.shouldOpenNow,...l.args}})};switch(l.type.trim().toLowerCase()){case L.EventActionTypes.setNextBranch.trim().toLowerCase():{let e=o.find(e=>e.id===l.args.branchId);if(!e)return;f(),p(),r.add({...d,action:h.bind(null,{subjectId:i,subjectName:`container`,action:l,payload:{chapterId:e.chapterId,autoSelect:c}})});return}case L.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():return;case L.EventActionTypes.setMinWeightBranch.trim().toLowerCase():return;case L.EventActionTypes.setRandomBranch.trim().toLowerCase():return;case L.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():return;case L.EventActionTypes.continuePlayback.trim().toLowerCase():f(),p(),r.add({...d,action:m.bind(null,{subjectId:i,subjectName:`container`,action:l})});return;case L.EventActionTypes.openURI.trim().toLowerCase():f(),p(),r.add({...d,action:g.bind(null,{subjectId:i,subjectName:`container`,action:l,payload:{URI:n.args.uri}})});return;default:{let e=`Unexpected container event`;u(new A(1,1,{message:e}),e);return}}};function c({container:n,branches:a,isEOV:o=!1}){let c=Pn(n.events);if(c){let a=Ui(c.action,o);e.emit(K.interactives,{subjectId:n.id,subjectName:`container`,type:q.actionChoice,actionType:a.type,payload:{invokeImmediately:a.args.shouldOpenNow,...a.args}}),t.interactiveActionChoice$.next({subjectId:n.id,subjectName:`container`,type:`action-choice`,actionType:a.type,payload:{invokeImmediately:a.args.shouldOpenNow,...a.args}}),r.add({timestamp:o?1/0:n.endTime??1/0,priority:`container`,initiator:n.id,actionType:L.EventActionTypes.expect,action:f.bind(null,{subjectId:n.id,subjectName:`container`})}),i.isExpect=!0}else for(let e of n.events??[])s({action:e.action,container:n,branches:a,isEOV:o})}let l=({chapterId:n,action:r,branches:i=[]})=>{let a=e.emit.bind(e,K.interactives,{subjectId:n,subjectName:`chapter`,type:q.actionChoice,actionType:r.type,payload:r.args}),o=()=>{t.interactiveActionChoice$.next({subjectId:n,subjectName:`chapter`,type:`action-choice`,actionType:r.type,payload:r.args})};switch(r.type.trim().toLowerCase()){case L.EventActionTypes.setNextBranch.trim().toLowerCase():{let e=i.find(e=>e.id===r.args.branchId);return e?.chapterId?(a(),o(),h.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case L.EventActionTypes.setWeightlessRandomBranch.trim().toLowerCase():{let e=Ri(i);return e?.chapterId?(a(),o(),h.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case L.EventActionTypes.setRandomBranch.trim().toLowerCase():{let e=Bi(i);return e?.chapterId?(a(),o(),h.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case L.EventActionTypes.setMaxWeightBranch.trim().toLowerCase():{let e=Li(i);return e?.chapterId?(a(),o(),h.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case L.EventActionTypes.setMinWeightBranch.trim().toLowerCase():{let e=Ii(i);return e?.chapterId?(a(),o(),h.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{chapterId:e.chapterId,autoSelect:!0}})):void 0}case L.EventActionTypes.continuePlayback.trim().toLowerCase():return a(),o(),m.bind(null,{subjectId:n,subjectName:`chapter`,action:r});case L.EventActionTypes.openURI.trim().toLowerCase():return a(),o(),g.bind(null,{subjectId:n,subjectName:`chapter`,action:r,payload:{URI:r.args.uri}});default:{let e=`Unexpected chapter event`;u(new A(1,1,{message:e}),e);return}}};function u(n,r){console.error(r),t.error$.next(n),e.emit(K.errors,n)}function d(n){let i=Pn(n.events);if(i){if(R(n))return;e.emit(K.interactives,{subjectId:n.id,subjectName:`chapter`,type:q.actionChoice,actionType:i.action.type,payload:i.action.args}),t.interactiveActionChoice$.next({subjectId:n.id,subjectName:`chapter`,type:`action-choice`,actionType:i.action.type,payload:i.action.args}),r.add({timestamp:1/0,priority:`chapter`,initiator:n.id,actionType:L.EventActionTypes.expect,action:f.bind(null,{subjectId:n.id,subjectName:`chapter`})})}else n.events?.forEach(e=>{let t=l({chapterId:n.id,action:e.action,branches:n.branches});t&&r.add({timestamp:1/0,priority:`chapter`,initiator:n.id,actionType:e.action.type,action:t})})}let f=({subjectId:r,subjectName:i})=>{n.pause(),e.emit(K.interactives,{subjectId:r,subjectName:i,type:q.actionExecution,actionType:L.EventActionTypes.expect}),t.interactiveActionExecution$.next({subjectId:r,subjectName:i,type:`action-execution`,actionType:L.EventActionTypes.expect})},p=({subjectId:i,subjectName:a})=>{n.info.isEnded$.getValue()?r.execEndOfVideo():n.play(),e.emit(K.interactives,{subjectId:i,subjectName:a,type:q.actionExecution,actionType:Hi}),t.interactiveActionExecution$.next({subjectId:i,subjectName:a,type:`action-execution`,actionType:Hi})},m=({subjectId:n,subjectName:r,subjectType:i,action:a})=>{e.emit(K.interactives,{subjectId:n,subjectName:r,subjectType:i,type:q.actionExecution,actionType:a.type}),t.interactiveActionExecution$.next({subjectId:n,subjectName:r,subjectType:i,type:`action-execution`,actionType:a.type})},h=({subjectId:n,subjectName:r,subjectType:i,action:a,payload:o})=>{o.behaviour=`change-chapter`,e.emit(K.interactives,{subjectId:n,subjectName:r,subjectType:i,type:q.actionExecution,actionType:a.type,payload:o}),t.interactiveActionExecution$.next({subjectId:n,subjectName:r,subjectType:i,type:`action-execution`,actionType:a.type,payload:o})},g=({subjectId:n,subjectName:r,subjectType:i,action:a,payload:o})=>{if(!o.URI)return;let s=window.open(o.URI,`_blank`,`noopener,noreferrer`);s&&(s.opener=null),e.emit(K.interactives,{subjectId:n,subjectName:r,subjectType:i,type:q.actionExecution,actionType:a.type}),t.interactiveActionExecution$.next({subjectId:n,subjectName:r,subjectType:i,type:`action-execution`,actionType:a.type})};return{onControlEvent:o,onContainerEvent:s,onChapterEvent:l,onExpectEvent:f,expectEventHandler:p,setManifestChapterEvents:d,setManifestContainerEvents:c,stopExpect:a,state:i}},J=require(`@vkontakte/videoplayer-shared/es2018`),Gi=(e,t)=>{let n={};return e.map(e=>{if(!n[e]){let r=t.chapters.find(t=>t.id===e);if(!r)return null;let i=t.media.videos.find(e=>r.videoId===e.id);if(!i)return null;n[e]=Ji(i)}return n[e]}).filter(e=>e!==null)},Ki=e=>{for(let t of e.variants)if(qi(t)&&t.payload)return t.payload.id},qi=e=>!!(e.type===`custom`&&e.payload&&e.payload.type===`vk`),Ji=e=>{let t=Ki(e);if(!t)return null;let n=t.split(`_`).pop();return n?parseInt(n,10):null},Yi=(e,t)=>{for(let n of e.media.videos)if(t===Ji(n)){for(let t of e.chapters)if(t.videoId===n.id)return t.id;return}},Xi=(e,t)=>e.reduce((e,n)=>{let r=Yi(t,n);return r?[...e,r]:e},[]),Y=new WeakMap,Zi=new WeakMap,Qi=new WeakMap,X=new WeakMap,$i=new WeakMap,Z=new WeakMap,Q=new WeakMap,$=new WeakMap,ea=new WeakMap,ta=new WeakMap,na=new WeakMap;class ra{constructor({globalEventEmitter:i,videoId:a,interactiveController:o,historyApi:s,settings:c}){e(this,`state`,{history$:new J.ValueSubject([]),hasPrevChapter$:new J.ValueSubject(!1),prevChapter$:new J.ValueSubject(null),isInitialChapter$:new J.ValueSubject(!1),isGoBackLimited$:new J.ValueSubject(!1)}),t(this,Y,null),t(this,Zi,void 0),t(this,Qi,!1),t(this,X,null),t(this,$i,null),e(this,`events`,{inited$:new J.Subject,destroyed$:new J.Subject,error$:new J.Subject}),t(this,Z,null),t(this,Q,null),t(this,$,null),t(this,ea,new J.Subscription),t(this,ta,!1),t(this,na,0),n(Z,this,a),n($,this,i),n(Q,this,o),n(Y,this,s),n(Zi,this,c),this.state.history$&&r(ea,this)&&r(ea,this)?.add(this.state.history$.subscribe(e=>{var t;this.state.prevChapter$.next(hr(e,-2)||null),this.state.hasPrevChapter$.next(e.length>1),this.state.isInitialChapter$.next(this.getInitialChapterId()===((t=r(X,this))==null||(t=t.metadata)==null?void 0:t.initChapterId)),this.state.isGoBackLimited$.next(r(na,this)===r(Zi,this).maxLength-1)}))}async setManifest(e){if(!r(Q,this)||!r($,this))return;n(X,this,e),await this.getProjectHistory();let t=this.getInitialChapterId();await r(Q,this).setChapter({chapterId:t,pushToHistory:!1}),r(Qi,this)||(n(Qi,this,!0),this.events.inited$.next({initChapterId:t}))}get inited(){return r(Qi,this)}async updateHistory(e,t=!0){if(!r(X,this))return;if(r(ta,this)){var i;n(ta,this,!1),n(na,this,(i=r(na,this),i++,i))}else n(na,this,0);let a=r(X,this),o=e.length-r(Zi,this).maxLength,s=o>0?e.slice(o):e,c=Gi(s,a);if(n($i,this,c),this.state.history$.next(s),!(!t||!r(Y,this)||!r(Z,this)))try{await r(Y,this).save(r(Z,this),c)}catch{let e=new A(1,5,`Unable to save interactive history`);this.events.error$.next(e),r($,this)?.emit(K.errors,e)}}async goBack(){if(!this.state||!r(Q,this)){let e=new A(1,5,`Unable to save interactive history`);this.events.error$.next(e),r($,this)?.emit(K.errors,e);return}n(ta,this,!0);let e=this.state.history$.getValue().slice(0,-1),t=e.pop();this.state.history$.next(e),await r(Q,this).setChapter({chapterId:t,playPrev:!0})}async getProjectHistory(){if(!r(X,this)||!r(Z,this))return;let e=r(X,this),t=[this.getInitialVideoId()];if(r(Y,this))try{let e=await r(Y,this).get(r(Z,this));e.length&&(t=e)}catch{let e=new A(1,5,`Error while trying to fetch data`);this.events.error$.next(e),r($,this)?.emit(K.errors,e)}let n=Xi(t,e);this.state.history$.next(n)}getInitialChapterId(){let e=this.state.history$.getValue();return(e==null?void 0:hr(e,-1))||r(Zi,this).initChapterId||r(X,this)?.metadata.initChapterId}getInitialVideoId(){return r(X,this)?Gi([this.getInitialChapterId()],r(X,this)).pop():null}destroy(){n(Z,this,null),n(Y,this,null),n(Q,this,null),r(ea,this)?.unsubscribe(),n(ea,this,null),n(Qi,this,!1),r($,this)?.emit(K.historyDestroyed),this.events.destroyed$.next(),n($,this,null)}}class ia{constructor(){e(this,`rootElement`,void 0),e(this,`canvasImgSrc`,void 0),e(this,`_prevSizeId`,0),this.rootElement=document.createElement(`canvas`)}clear(){this.rootElement.getContext(`2d`)?.clearRect(0,0,this.rootElement.width,this.rootElement.height)}isImageDrawn(){let e=this.rootElement.getContext(`2d`)?.getImageData(0,0,this.rootElement.width,this.rootElement.height);if(!e)return!1;let t=e.data,n=t.length;for(let e=3;e<n;e+=40)if(t[e]!==0)return!0;return!1}destroy(){this.rootElement.remove()}show(){this.rootElement.style.visibility=`visible`}hide(){this.rootElement.style.visibility=`hidden`}setCanvasImageSource(e){this.canvasImgSrc=e}draw(){this.canvasImgSrc&&this.rootElement.getContext(`2d`)?.drawImage(this.canvasImgSrc,0,0,this.rootElement.width,this.rootElement.height)}async updateCanvasDimensions(e,t=!1){let n=e.width+e.height;if(this._prevSizeId===n)return;let r;t&&(r=await this.save()),this.rootElement.width=e.width,this.rootElement.height=e.height,t&&r&&this.restore(r),this._prevSizeId=n}async save(){let e=this.rootElement.toDataURL(`image/jpeg`,1),t=new Image;return t.crossOrigin=`anonymous`,t.src=e,await t.decode(),t}restore(e){this.rootElement&&this.rootElement.getContext(`2d`)?.drawImage(e,0,0,this.rootElement.width,this.rootElement.height)}}class aa{constructor({parentElement:t,endOffsetMs:n=250,onError:r}){e(this,`lastFrameCanvas`,void 0),e(this,`endOffsetMs`,void 0),e(this,`currentChapter`,void 0),e(this,`currentVideoDurationMs`,1/0),e(this,`rootElement`,void 0),e(this,`_containerTimeFrameShouldReceived`,!1),e(this,`_endTimeFrameReceived`,!1),e(this,`_shouldCallSkip`,!1),e(this,`_callbacks`,void 0),e(this,`onEachTick`,e=>{let t=e??this.lastFrameCanvas.canvasImgSrc.currentTime*1e3,n=this.isChapterEndTime(t);if(this.isContainerTime(t))this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!0,this._shouldCallSkip=!0;else if(n)this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1,this._endTimeFrameReceived||(this.draw(),this._endTimeFrameReceived=!0,this.show());else{if(this._shouldCallSkip){this._shouldCallSkip=!1;return}this.reset()}}),e(this,`onSeek`,()=>{this.onEachTick(),!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived&&(this.hide(),this.lastFrameCanvas.clear())}),this.rootElement=document.createElement(`div`),this.rootElement.style.cssText=`
7
+ position: absolute;
8
+ top: 0;
9
+ left: 0;
10
+ width: var(--interactive-width);
11
+ height: var(--interactive-height);
12
+ background-color: var(--black);
13
+ visibility: hidden;
14
+ `,this.lastFrameCanvas=new ia,this.endOffsetMs=n,this._callbacks={onError:r},this.lastFrameCanvas.rootElement.style.cssText=`
15
+ position: absolute;
16
+ top: 50%;
17
+ left: 50%;
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(e){this.currentVideoDurationMs=e}setVideoElement(e){this.lastFrameCanvas.setCanvasImageSource(e)}setCurrentChapter(e){this.currentChapter=e}show(){this.rootElement.style.visibility=`visible`}hide(){this.rootElement.style.visibility=`hidden`}async updateCanvasDimensions(e=!1){this._containerTimeFrameShouldReceived||this._endTimeFrameReceived||(e=!1);let t=getComputedStyle(this.rootElement),n={width:parseInt(t.getPropertyValue(`--interactive-content-width`),10),height:parseInt(t.getPropertyValue(`--interactive-content-height`),10)};try{this.lastFrameCanvas.updateCanvasDimensions(n,e)}catch(e){this._onError(e)}}draw(){(this._containerTimeFrameShouldReceived||!this._containerTimeFrameShouldReceived&&!this._endTimeFrameReceived)&&this.lastFrameCanvas.draw()}isChapterEndTime(e){return!!(this.currentVideoDurationMs&&e>=this.currentVideoDurationMs-this.endOffsetMs)}isContainerTime(e){if(this.currentChapter)return this.currentChapter.containers.some(t=>t.controls?.length&&e>=(t.startTime??0)&&e<=Math.min(t.endTime??1/0,this.currentVideoDurationMs-this.endOffsetMs))}reset(){this._endTimeFrameReceived=!1,this._containerTimeFrameShouldReceived=!1,this._shouldCallSkip=!1}_onError(e){var t,n;(t=this._callbacks)==null||(n=t.onError)==null||n.call(t,e)}}function oa(e=0){return new Promise(t=>{setTimeout(()=>{t(0)},e)})}var sa=`/* interactive-container */
20
+ .interactive-container {
21
+ opacity: 1;
22
+ visibility: visible;
23
+ transition: opacity var(--interactive-transition-1);
24
+ }
25
+
26
+ .interactive-container-disabled {
27
+ opacity: 0.5;
28
+ }
29
+
30
+ .interactive-container-hidden {
31
+ visibility: hidden;
32
+ }
33
+
34
+ .interactive-container.interactive-container-before-remove.interactive-container-before-remove-delay {
35
+ transition-delay: var(--interactive-remove-delay);
36
+ }
37
+
38
+ .interactive-container.interactive-container-before-remove {
39
+ transition: opacity var(--interactive-transition-1);
40
+ opacity: 0;
41
+ pointer-events: none;
42
+ }
43
+
44
+ /* blink-anim */
45
+ .interactive-control-blink-anim {
46
+ animation-duration: 2001ms;
47
+ animation-iteration-count: infinite;
48
+ animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
49
+ }
50
+
51
+ .interactive-control-blink-anim-button {
52
+ animation-name: interactive-blinking-button;
53
+ }
54
+
55
+ .interactive-control-blink-anim-area {
56
+ animation-name: interactive-blinking-area;
57
+ }
58
+
59
+ @keyframes interactive-blinking-area {
60
+ 0%, 100% {
61
+ opacity: 1;
62
+ }
63
+ 50% {
64
+ opacity: var(--interactive-area-hover-opacity);
65
+ }
66
+ }
67
+
68
+ @keyframes interactive-blinking-button {
69
+ 0%, 100% {
70
+ opacity: 1;
71
+ }
72
+ 50% {
73
+ opacity: var(--interactive-button-hover-opacity);
74
+ }
75
+ }
76
+
77
+ /* blink-anim-reference */
78
+ .interactive-blink-anim-reference {
79
+ position: absolute;
80
+ height: 0;
81
+ width: 0;
82
+ top: 0;
83
+ left: 0;
84
+ pointer-events: none;
85
+ }
86
+
87
+ .interactive-blink-anim-reference-animation {
88
+ animation-duration: 2001ms;
89
+ animation-iteration-count: infinite;
90
+ animation-timing-function: cubic-bezier(0.3, 0.3, 0.3, 1);
91
+ animation-name: interactive-blinking-button;
92
+ }
93
+
94
+ .interactive-blink-anim-reference-disabled {
95
+ animation: none;
96
+ }
97
+
98
+ /* control tap */
99
+ .interactive-control-tap {
100
+ position: absolute;
101
+ aspect-ratio: 1;
102
+ background-color: var(--interactive-bg-color-1);
103
+ border: 1px solid var(--interactive-color-1);
104
+ border-radius: 50%;
105
+ transition: opacity var(--interactive-transition-1);
106
+ opacity: 0;
107
+ pointer-events: none;
108
+ z-index: 1;
109
+ }
110
+
111
+ .interactive-control-tap-animation {
112
+ animation-duration: 300ms;
113
+ animation-iteration-count: 1;
114
+ animation-timing-function: ease;
115
+ animation-name: interactive-control-tap-bounce;
116
+ }
117
+
118
+ @keyframes interactive-control-tap-bounce {
119
+ 0%, 100% {
120
+ transform: scale(1);
121
+ }
122
+ 50% {
123
+ transform: scale(0.3);
124
+ }
125
+ }
126
+
127
+ .interactive-container:not(.interactive-container-disabled) .interactive-control-tap-visible {
128
+ opacity: 1;
129
+ }
130
+
131
+ /* interactive-chapter */
132
+ .interactive-chapter {
133
+ position: absolute;
134
+ top: 0;
135
+ left: 0;
136
+ font-family: inherit;
137
+
138
+ --interactive-transition-1: 100ms ease-in-out;
139
+ --interactive-transition-2: 400ms cubic-bezier(0.4, 0, 0.2, 1);
140
+ --interactive-color-1: #fff;
141
+ --interactive-bg-color-1: rgba(255, 255, 255, 0.08);
142
+ --interactive-button-hover-opacity: 0.8;
143
+ --interactive-area-hover-opacity: 0;
144
+ --interactive-remove-delay: 300ms;
145
+ }
146
+
147
+ /* interactive-control */
148
+ .interactive-control-wrapper-selected {
149
+ pointer-events: none;
150
+ }
151
+
152
+ .interactive-control {
153
+ display: flex;
154
+ width: 100%;
155
+ height: 100%;
156
+ font-family: inherit;
157
+
158
+ position: relative;
159
+ isolation: isolate;
160
+ opacity: 1;
161
+
162
+ box-shadow: none;
163
+ border: none;
164
+ }
165
+
166
+ .interactive-control.interactive-control-disabled {
167
+ cursor: default;
168
+ }
169
+
170
+ .interactive-control-button,
171
+ .interactive-control-area {
172
+ cursor: pointer;
173
+ }
174
+
175
+ .interactive-control-button {
176
+ transition: opacity var(--interactive-transition-2);
177
+ }
178
+
179
+ .interactive-control-area {
180
+ transition: border-color var(--interactive-transition-1), box-shadow var(--interactive-transition-1), opacity var(--interactive-transition-2);
181
+ }
182
+
183
+ .interactive-control-wrapper-selected > .interactive-control-button {
184
+ transition: opacity var(--interactive-transition-1);
185
+ opacity: 0.5;
186
+ }
187
+
188
+ .interactive-control-wrapper-selected > .interactive-control-area {
189
+ transition: opacity var(--interactive-transition-1);
190
+ opacity: 0;
191
+ }
192
+
193
+
194
+ .interactive-control.interactive-control-before-remove {
195
+ transition: opacity var(--interactive-transition-1);
196
+ opacity: 0;
197
+ pointer-events: none;
198
+ }
199
+
200
+ .interactive-container.interactive-container-disabled .interactive-control-button,
201
+ .interactive-container.interactive-container-disabled .interactive-control-area {
202
+ animation: none;
203
+ }
204
+
205
+ .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-button:not(.interactive-control-blink-anim):hover,
206
+ .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-button:not(.interactive-control-blink-anim):focus-visible {
207
+ opacity: var(--interactive-button-hover-opacity);
208
+ animation: none;
209
+ }
210
+
211
+ .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-area:not(.interactive-control-blink-anim):hover,
212
+ .interactive-container:not(.interactive-container-disabled) .interactive-control-wrapper:not(.interactive-control-wrapper-selected) > .interactive-control-area:not(.interactive-control-blink-anim):focus-visible {
213
+ opacity: var(--interactive-area-hover-opacity);
214
+ animation: none;
215
+ }
216
+
217
+ /* fill animation */
218
+ .interactive-control-fill-animation {
219
+ position: absolute;
220
+ overflow: hidden;
221
+ z-index: -1;
222
+ pointer-events: none;
223
+ }
224
+
225
+ .interactive-control-fill-animation-filler-wrapper {
226
+ position: absolute;
227
+ width: 100%;
228
+ height: 100%;
229
+ transform-origin: center;
230
+ }
231
+
232
+ .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-fill-width {
233
+ top: 0;
234
+ }
235
+
236
+ .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-fill-height {
237
+ left: 0;
238
+ }
239
+
240
+ .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-right {
241
+ right: 0;
242
+ }
243
+
244
+ .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-left {
245
+ left: 0;
246
+ }
247
+
248
+ .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-top {
249
+ top: 0;
250
+ }
251
+
252
+ .interactive-control-fill-animation-filler-wrapper.interactive-control-fill-animation-from-bottom {
253
+ bottom: 0;
254
+ }
255
+
256
+ .interactive-control-fill-animation-filler {
257
+ width: 100%;
258
+ height: 100%;
259
+ background-color: rgba(173, 211, 255, 0.32);
260
+ }
261
+
262
+ .interactive-control-fill-animation-filler.interactive-control-fill-animation-fill-width {
263
+ transform: scaleX(0);
264
+ }
265
+
266
+ .interactive-control-fill-animation-filler.interactive-control-fill-animation-fill-height {
267
+ transform: scaleY(0);
268
+ }
269
+
270
+ .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-right {
271
+ transform-origin: right;
272
+ }
273
+
274
+ .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-left {
275
+ transform-origin: left;
276
+ }
277
+
278
+ .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-top {
279
+ transform-origin: top;
280
+ }
281
+
282
+ .interactive-control-fill-animation-filler.interactive-control-fill-animation-from-bottom {
283
+ transform-origin: bottom;
284
+ }
285
+ `,ca=e=>{let t=document.createElement(`style`);t.textContent=sa,e.prepend(t)},la=require(`@vkontakte/videoplayer-core/es2018`),ua=Object.freeze({lang:W.InterfaceLanguage.RU,loaders:{},graph:!1,initSeamless:!1,lastFrame:!1,permanentTextControls:!0,interactiveTimeOpenUri:!1,config:{historyMaxLength:100,noInteractionEventTimeout:3e4},isTouch:!1,disableTextControlContainerVisibilityEvents:!1,animationsFeatureToggles:{areaControlShadow:!1,controlsExpectTimeBlinkAnimation:!1,controlsTapPlace:!1,controlsFillAnimation:!1,controlsHideAnimation:!1},enableAvPlayerSupport:!1});function da(){let e=document.createElement(`div`);return e.classList.add(`interactive-chapter`),e}class fa{constructor(t){if(e(this,`playerSubscriptions`,new W.Subscription),e(this,`subscriptions`,new W.Subscription),e(this,`globalEventEmitter`,new Er),e(this,`animation`,new Dr),e(this,`seekToInteractiveController`,new Tr),e(this,`endedRanges`,new Set),e(this,`gameControllers`,[]),e(this,`rootElement`,da()),e(this,`factories`,new Map([[`choice`,dr]])),e(this,`isFirstChapterFetched`,!1),e(this,`_options`,void 0),e(this,`manifestController`,void 0),e(this,`resizeManager`,void 0),e(this,`cssVarsManager`,void 0),e(this,`historyController`,void 0),e(this,`player`,null),e(this,`interactiveEvents`,null),e(this,`selectBranches`,null),e(this,`seamlessController`,null),e(this,`seamlessControllerSubs`,new W.Subscription),e(this,`graph`,null),e(this,`lastFrame`,null),e(this,`noInteractionTimeout`,void 0),e(this,`blinkAnimationRef`,null),e(this,`appState`,0),e(this,`state`,{prevChapter$:new W.ValueSubject(null),isInitialChapter$:new W.ValueSubject(!1),isFirstChapter$:new W.ValueSubject(!0),isEndChapter$:new W.ValueSubject(!1),isInteractiveExpectation$:new W.ValueSubject(!1),isReplay$:new W.ValueSubject(!1),calledByInteractive$:new W.ValueSubject(!1),lastChapterChangeWasInitiatedByInteractive$:new W.ValueSubject(!1),disabledControls$:new W.ValueSubject(!1),interactiveRanges$:new W.ValueSubject([]),isInteractiveTime$:new W.ValueSubject(!1),statistics$:new W.ValueSubject(null),isSeekable$:new W.ValueSubject(!1)}),e(this,`events`,{noInteraction$:new W.Subject,graphVisibilityChanged$:new W.Subject,watchAgainIsClicked$:new W.Subject,chapterChanged$:new W.Subject,playerChanged$:new W.Subject,error$:new W.Subject,eachTick$:new W.Subject,manifestChanged$:new W.Subject,interactiveRangeEnded$:new W.Subject,interactiveContainerRemoved$:new W.Subject,interactiveContainerFakeRemoved$:new W.Subject,interactiveActionExecution$:new W.Subject,interactiveActionChoice$:new W.Subject,interactiveVisibilityChanged$:new W.Subject}),e(this,`emitErrorEvent`,e=>{this.events.error$.next(e),this.globalEventEmitter.emit(K.errors,e)}),e(this,`clearHistoryIfEnded`,()=>{let e=this.player?.info.isEnded$.getValue(),t=this.state.isInteractiveExpectation$.getValue(),{chapter:n}=this.getCurrentChapter();e&&n&&R(n)&&!t&&this.historyController.updateHistory([]),window.removeEventListener(`beforeunload`,this.clearHistoryIfEnded)}),e(this,`handleSeamlessPlayerChanged`,e=>{if(!e)return;let{statistics:t,...n}=e;if(t){let{statSubscription:e,oneStat:n}=t;e.add(n.attachToInteractive(this.getStatEvents())),this.state.statistics$.next(t)}this.state.isReplay$.getValue()&&this.state.isReplay$.next(!1),this.events.playerChanged$.next(n),this.globalEventEmitter.emit(K.playerChanged,n)}),e(this,`onPlaybackStarted`,()=>{this.resizeManager?.calc(),this.animation.requestAnimation()}),e(this,`destroyGameControllers`,({removeTextControls:e=!0,withTransition:t=!1}={})=>{for(let n of this.gameControllers)!e&&n.isPermanentText||(this.animation.removeFn(n.whilePlaying),n.destroy(t))}),e(this,`completeInteractiveRange`,e=>{let{interactiveRanges$:t}=this.state,n=t.getValue().map(t=>({...t,subjects:t.subjects.filter(t=>t.id!==e)}));t.next(n)}),e(this,`clearNoInteractionTimeout`,()=>{this.noInteractionTimeout&&=(clearTimeout(this.noInteractionTimeout),void 0)}),this._options={...ua,...t,config:{...ua.config,...t.config}},this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation){this.blinkAnimationRef=new Un,this.blinkAnimationRef.create();let e=this.blinkAnimationRef.element;e&&this.rootElement.append(e)}this._options.parentElement.append(this.rootElement),this.historyController=new ra({interactiveController:this,globalEventEmitter:this.globalEventEmitter,videoId:this._options.projectInfo?.videoId,historyApi:this._options.historyApi,settings:{maxLength:this._options.config.historyMaxLength,initChapterId:this._options.initChapterId}}),this._options.lastFrame&&(this.lastFrame=new aa({parentElement:this._options.parentElement,onError:e=>{let t=new A(1,6,e);this.emitErrorEvent(t)}})),ca(this._options.parentElement),this.subscriptions.add(W.fromEvent(this.rootElement,`mousedown`).subscribe(e=>e.stopPropagation())).add(W.fromEvent(this.rootElement,`mouseup`).subscribe(e=>e.stopPropagation())),this.manifestController=new ni(this._options.loaders,e=>{let t=new A(1,3,e);this.emitErrorEvent(t)});let n=[];this._options.lastFrame&&n.push(()=>{this.lastFrame?.updateCanvasDimensions(!0)}),n.push(()=>{let e=this.state.isInteractiveTime$.getValue();for(let t of this.gameControllers)t.onResize(e)}),this.cssVarsManager=new kr(this._options?.parentElement),this.resizeManager=Pi(()=>({player:this.player,cssVarsManager:this.cssVarsManager,parentElement:this._options.parentElement,fns:n})),this._options.graph&&(this.graph=new Sr({root:this._options.parentElement,lang:this._options.lang,onOpenPreviewClick:e=>{this.setChapter({chapterId:e}),this.globalEventEmitter.emit(K.graph,{type:gi.watchAgainClicked,chapterId:e}),this.events.watchAgainIsClicked$.next(e)},onError:e=>{let t=new A(1,2,{message:e});this.emitErrorEvent(t)}})),this.initSubscriptions()}initSubscriptions(){this.playerSubscriptions.add(this.historyController.events.inited$.subscribe(async({videosInfo:e=[]})=>{this._options.initSeamless&&(await this.initSeamless(),this.updateGraphVideosInfo(e))})),this.subscriptions.add(this.events.interactiveContainerRemoved$.subscribe(({subjectId:e})=>{this.completeInteractiveRange(e)})).add(this.events.interactiveContainerFakeRemoved$.subscribe(({subjectId:e,removeAllOpenURI:t})=>{this.handleFakeRemoval(e,t)})).add(this.events.interactiveActionExecution$.subscribe(e=>{if(this.state.calledByInteractive$.next(!0),(e.actionType===`setNextBranch`||!this._options.endChapterHistoryFix)&&this.state.lastChapterChangeWasInitiatedByInteractive$.next(!0),e.payload?.behaviour===`change-chapter`){let{chapterId:t}=e.payload;this.setChapter({chapterId:t}),this.state.isFirstChapter$.getValue()&&this.state.isFirstChapter$.next(!1)}else if(e.payload?.behaviour===`change-manifest`){let{manifestURL:t}=e.payload;t&&this.setManifest(t)}e.actionType===`expect`?(this.state.isInteractiveExpectation$.next(!0),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!0})):e.actionType===`after-expect`&&(this.state.isInteractiveExpectation$.next(!1),this.updateControlsShadowStyles({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}),this.toggleBlinkAnimation({subjectName:e.subjectName,subjectId:e.subjectId,isExpect:!1}))})).add(this.events.manifestChanged$.subscribe(()=>{this.state.calledByInteractive$.next(!1),this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)})).add(this.events.interactiveActionChoice$.subscribe(({type:e,subjectName:t,payload:n})=>{e!==`action-choice`||t===`chapter`||`invokeImmediately`in n&&n.invokeImmediately||this.destroyGameControllers({removeTextControls:!1,withTransition:this._options.animationsFeatureToggles?.controlsHideAnimation})}))}async initSeamless(){this.seamlessController=hi(this),this.seamlessControllerSubs.add(this.seamlessController.activePlayerChanged.subscribe(this.handleSeamlessPlayerChanged)),await this.seamlessController.init()}handlePositionChange(e){(!this.graph||this.graph.isHidden)&&this.checkIfSeekable();let t=e*1e3,n=this.getInteractiveRanges().reverse().find(({range:e})=>t>=e[1]);if(n){let e=n.range.join(`-`);this.endedRanges.has(e)||(this.endedRanges.add(e),this.globalEventEmitter.emit(K.interactives,{type:q.rangeEnded,payload:n,visibility:!0}),this.events.interactiveRangeEnded$.next({type:`range-ended`,payload:n}))}}registerVideoEvents(){this.player&&(window.removeEventListener(`beforeunload`,this.clearHistoryIfEnded),this.playerSubscriptions.unsubscribe(),window.addEventListener(`beforeunload`,this.clearHistoryIfEnded),this.playerSubscriptions.add(this.player.events.started$.pipe(W.once()).subscribe(this.onPlaybackStarted)).add(this.player.events.playing$.subscribe(this.animation.requestAnimation)).add(this.player.events.willPause$.subscribe(this.animation.cancelAnimation)).add(this.player.info.position$.subscribe(this.handlePositionChange.bind(this))).add(this.manifestController.prevChapter$.subscribe(e=>this.state.prevChapter$.next(e))).add(W.combine({position:this.player.info.position$,interactiveRanges:this.state.interactiveRanges$,isInteractiveExpectation:this.state.isInteractiveExpectation$}).subscribe(({position:e,interactiveRanges:t,isInteractiveExpectation:n})=>{let r;if(n)r=!0;else{let n=e*1e3;r=!!t.find(({range:[e,t],subjects:r})=>e<n&&n<t&&r.some(e=>!e.isRemoved)&&r.length)}r!==this.state.isInteractiveTime$.getValue()&&this.state.isInteractiveTime$.next(r);let i=!!this.noInteractionTimeout,a=this.player?.info.playbackState$.getValue()===`playing`||n;r&&!i&&a?this.noInteractionTimeout=window.setTimeout(()=>{this.events.noInteraction$.next()},this._options.config.noInteractionEventTimeout):i&&!a&&this.clearNoInteractionTimeout()})),this.playerSubscriptions.add(this.historyController.events.error$.subscribe(this.events.error$)),this._options.lastFrame&&this.playerSubscriptions.add(this.player.info.duration$.subscribe(e=>{this.lastFrame?.setVideoDuration(e*1e3)})).add(this.player.experimental.element$.subscribe(e=>{e&&this.lastFrame?.setVideoElement(e)})).add(this.player.events.firstFrame$.subscribe(()=>{this.lastFrame?.reset(),setTimeout(()=>{this.lastFrame?.hide(),this.lastFrame?.lastFrameCanvas.clear()},50)})).add(this.player.events.seeked$.subscribe(this.lastFrame.onSeek)))}setGameControllers(){let e=this.manifestController.chapter;e&&this.appState===1&&(this.selectBranches?.setManifestChapterEvents(e),this.gameControllers=this.getGameControllers(e),this.interactiveEvents?.containersEventsCallState.setData(e.containers),this.seekToInteractiveController.setContainers(this.gameControllers.map(e=>e.container.container).filter(e=>!In(e.controls))),this._options.lastFrame&&this.animation.addFn(()=>{this.player&&this.lastFrame?.onEachTick(this.player.info.position$.getValue()*1e3)},!0),this.state.interactiveRanges$.next(this.getInteractiveRanges()),this.appState=2)}getGameControllers(e){let t=[];return e.containers.forEach(n=>{let r=n.type.trim().toLowerCase(),i=this.factories.get(r)?.(n,this.rootElement,this.cssVarsManager,{isTouch:this._options?.isTouch??!1,features:{controlsExpectTimeBlinkAnimation:this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation,controlsTapPlace:this._options.animationsFeatureToggles?.controlsTapPlace,controlsFillAnimation:this._options.animationsFeatureToggles?.controlsFillAnimation}});if(i&&this.selectBranches&&this.interactiveEvents&&this.player){let r=new bi({player:this.player,container:i,branches:e.branches,selectBranches:this.selectBranches,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter,getContainerEventState:()=>Bn(n,this.gameControllers),permanentTextControls:this._options.permanentTextControls,interactiveTimeOpenUri:this._options.interactiveTimeOpenUri,disabledControls$:this.state.disabledControls$,onRemove:()=>{this.seekToInteractiveController.deleteContainer(n.id)},onError:this.emitErrorEvent,disableTextControlContainerVisibilityEvents:this.options.disableTextControlContainerVisibilityEvents??!1,features:{controlsHideAnimation:this._options.animationsFeatureToggles?.controlsHideAnimation,enableAvPlayerSupport:this._options.enableAvPlayerSupport}});this.animation.addFn(r.whilePlaying,!0),t.push(r)}}),t}checkIfSeekable(){if(this.state.isInteractiveExpectation$.getValue()){this.state.isSeekable$.next(!1);return}let e=this.state.isSeekable$.getValue(),t=!!this.seekToInteractiveController.getNextInteractiveTime();(t&&!e||!t&&e)&&this.state.isSeekable$.next(!e)}updateLastEventInfo(){this.state.calledByInteractive$.getValue()?this.state.calledByInteractive$.next(!1):this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1)}pushChapterToHistory(e){if(this.updateLastEventInfo(),!this.historyController.inited)return;let t=this.state.lastChapterChangeWasInitiatedByInteractive$.getValue(),n=this.state.prevChapter$.getValue(),r=(n&&R(n)&&An(n))??!1,i=this.manifestController.manifest?.metadata.initChapterId===e,a=this.historyController.state.history$.getValue();if(i||r&&t){this.historyController.updateHistory([e]);return}hr(a,-1)!==e&&this.historyController.updateHistory([...a,e])}handleFakeRemoval(e,t){let{interactiveRanges$:n}=this.state,r=n.getValue().map(n=>{let r=n.subjects.some(t=>t.id===e),i=n.subjects.map(n=>t&&r||n.id===e?{...n,isRemoved:!0}:n);return{...n,subjects:i}});n.next(r)}reset(){this.appState===2&&(this.destroyGameControllers(),this.gameControllers=[],this.animation.release(),this.interactiveEvents?.release(),this.appState=1,this.state.isSeekable$.next(!1),this._options.endChapterHistoryFix&&this.state.lastChapterChangeWasInitiatedByInteractive$.next(!1),this.clearNoInteractionTimeout())}toggleBlinkAnimation(e){if(!this._options.animationsFeatureToggles?.controlsExpectTimeBlinkAnimation)return;let t=(e,t)=>{e.toggleBlinkAnimation(t)};Rn({...e,gameControllers:this.gameControllers,execFn:yi(vi(t),e.isExpect)}),e.isExpect&&this.blinkAnimationRef?.restart()}updateControlsShadowStyles(e){if(!this._options.animationsFeatureToggles?.areaControlShadow)return;let t=(e,t)=>{e.updateControlsShadowStyles(t)};e.isExpect?Rn({...e,gameControllers:this.gameControllers,execFn:yi(vi(t),!1)}):Rn({...e,gameControllers:this.gameControllers,execFn:t})}get options(){return this._options}init(){this.manifestController.chapter&&this._options.parentElement&&this.player&&this._options.fullscreenTargetElement&&this.appState===0&&(this.resizeManager?.resizeObserver.observe(this._options.fullscreenTargetElement),this.registerVideoEvents(),this.appState=1,this.setGameControllers())}async setManifest(e){this.reset(),this.isFirstChapterFetched=!1;let t=await this.manifestController.setManifest(e);if(t.manifest)return this.graph&&this.graph.handleManifestChange(t.manifest),await this.historyController.setManifest(t.manifest),this.events.manifestChanged$.next(t.manifest),this.globalEventEmitter.emit(K.manifestChanged,{manifest:t.manifest}),this.setGameControllers(),t.manifest}setPlayer(e){this.reset(),this.player=e,this.seekToInteractiveController.setPlayer(this.player),this.interactiveEvents?this.interactiveEvents.setPlayer(this.player):this.interactiveEvents=Oi(this.player,this._options.interactiveTimeOpenUri),this.selectBranches=Wi({player:this.player,interactiveEvents:this.interactiveEvents,globalEvents:this.events,globalEventEmitter:this.globalEventEmitter}),this.appState===1&&(this.registerVideoEvents(),this.setGameControllers())}async setChapter({chapterId:e,pushToHistory:t=!0,playPrev:n=!1}={}){this.reset(),this.lastFrame&&this.isFirstChapterFetched&&(this.lastFrame.draw(),this.lastFrame.show()),this.lastFrame&&la.clientChecker.browser.isSafari&&await oa(35);let r=!n&&this.state.isEndChapter$.getValue()&&this.getCurrentManifest()?.metadata.initChapterId===e;this.state.isReplay$.next(r);let{chapter:i,media:a,graph:o}=await(e?this.manifestController.setNext(e):this.manifestController.setInitial());(!e||r)&&this.state.isFirstChapter$.next(!0),!(!i||!a)&&(t&&this.pushChapterToHistory(i.id),this.state.isInitialChapter$.next(this.manifestController.isInitialChapter()),this.state.isEndChapter$.next(this.manifestController.isEndChapter()),this.graph&&this.graph.handleChapterChange(i),this.state.isInteractiveTime$.next(!1),this.state.isInteractiveExpectation$.next(!1),this.lastFrame?.setCurrentChapter(i),this.events.chapterChanged$.next({chapter:i,manifestVideo:a}),this.globalEventEmitter.emit(K.chapterChanged,{chapter:i,media:a,graph:o}),this.setGameControllers(),this.endedRanges=new Set,this.isFirstChapterFetched=!0)}getStatEvents(){return{click$:new W.Observable(e=>{this.subscriptions.add(this.events.graphVisibilityChanged$.subscribe(t=>{e.next(t?gr.InteractiveInterfaceClick.GRAPH_SHOW:gr.InteractiveInterfaceClick.GRAPH_HIDE)})).add(this.events.watchAgainIsClicked$.subscribe(()=>{e.next(gr.InteractiveInterfaceClick.WATCH_AGAIN)})).add(this.events.interactiveActionChoice$.subscribe(({type:t,subjectName:n,subjectType:r})=>{t!==`action-choice`||n!==`control`||(r===`Button`&&e.next(gr.InteractiveInterfaceClick.NEXT_BUTTON),r===`Area`&&e.next(gr.InteractiveInterfaceClick.NEXT_AREA))}))}),nextMovie$:new W.Observable(e=>{this.events.playerChanged$.subscribe(({config:t})=>{t?.unitedVideoId&&!this.state.isFirstChapter$.getValue()&&e.next(t.unitedVideoId)})})}}async toggleGraphView(e=!0){this.graph&&(e?(await this.graph.show(),this.state.isSeekable$.next(!1)):(this.graph.hide(),this.checkIfSeekable()),this.globalEventEmitter.emit(K.graph,{type:gi.visibility,visibility:e}),this.events.graphVisibilityChanged$.next(e))}setVisitedChapters(e){Array.isArray(e)&&this.graph?.setVisitedChapters(e)}updateGraphVideosInfo(e){Array.isArray(e)&&this.graph?.updateVideosInfo(e)}deadEndCheck(){return!(this.interactiveEvents?.getPreparedToExecActions()||[]).some(e=>e.actionType===L.EventActionTypes.setNextBranch)}allControlsAreRemoved(e=!0){return!this.gameControllers.some(t=>{let n=e&&this._options.animationsFeatureToggles?.controlsHideAnimation?t.container.willRemoved:!0;return!t.container.isRemoved||!n})}isEndedExpectation(){return!this.player||!this.gameControllers?!1:this.player.info.position$.getValue()===this.player.info.duration$.getValue()&&this.gameControllers.some(e=>{let t=e.container.container;return!e.container.isRemoved&&!e.container.willRemoved&&t.endTime===null&&Nn(t.events)})}playPrevChapter(){this.historyController.goBack()}setDisabledControls(e){this.state.disabledControls$.next(e)}isSupport(e=this.manifestController.manifest){return!!e&&L.isSupportedManifest(e.metadata.version)}getInitialVideoInfo(){return{videoId:this.historyController.getInitialVideoId(),chapterId:this.historyController.getInitialChapterId()}}getHistoryState(){return this.historyController.state}getIsSeekable(){return this.state.isSeekable$}getInteractiveRanges(){return xi(this.manifestController.chapter?.containers)}getNextInteractiveStartTime(e){return this.seekToInteractiveController.getNextInteractiveTime(e)}getChapterBranches(e){return this.manifestController.getBranches(e)}getCurrentChapter(){return this.manifestController.getCurrent()}getCurrentManifest(){return this.manifestController.manifest}on(e,t){return this.globalEventEmitter.on(e,t),this}off(e,t){return this.globalEventEmitter.off(e,t),this}once(e,t){return this.globalEventEmitter.once(e,t),this}destroy(){this.clearHistoryIfEnded(),this.blinkAnimationRef?.destroy(),this.destroyGameControllers(),this.gameControllers=[],this.graph?.destroy(),this.seamlessControllerSubs.unsubscribe(),this.seamlessController?.removeAll(),this.resizeManager?.release(),this.animation.release(),this.interactiveEvents?.release(),this.manifestController.release(),this.playerSubscriptions.unsubscribe(),this.subscriptions.unsubscribe(),this.globalEventEmitter.reset(),this.lastFrame?.destroy(),this.rootElement.remove(),this.historyController.destroy(),this.isFirstChapterFetched=!1,this.appState=3}}var pa={Container:Wt,createChoiceContainer:dr,createAreaControl:Gn,createButtonControl:sr,classnamesPrefix:nn},ma={version:Lt};