@gumlet/insights-js-core 2.1.2 → 2.1.4

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.
@@ -4,6 +4,6 @@
4
4
  // This source code and its use and distribution, is subject to the terms
5
5
  // and conditions of the applicable license agreement.
6
6
 
7
- // @gumlet/insights-js-core version 2.1.2
7
+ // @gumlet/insights-js-core version 2.1.4
8
8
 
9
9
  const e={READY:`ready`,STARTUP:`startup`,SOURCE_LOADED:`sourceLoaded`,PLAY:`play`,PAUSE:`pause`,TIMECHANGED:`timechanged`,SEEK:`seek`,SEEKED:`seeked`,START_CAST:`startCasting`,END_CAST:`endCasting`,START_BUFFERING:`startBuffering`,END_BUFFERING:`endBuffering`,AUDIO_CHANGE:`audioChange`,VIDEO_CHANGE:`videoChange`,START_FULLSCREEN:`startFullscreen`,END_FULLSCREEN:`endFullscreen`,START_AD:`adStart`,END_AD:`adEnd`,MUTE:`mute`,UN_MUTE:`unMute`,ERROR:`playerError`,NON_FATAL_ERROR:`playerNonFatalError`,PLAYBACK_FINISHED:`end`,SCREEN_RESIZE:`resize`,UNLOAD:`unload`,END:`end`,METADATA_LOADED:`metadataLoaded`,SOURCE_UNLOADED:`sourceUnloaded`,PLAYBACK_PLAYING:`playback_playing`};export{e as t};
@@ -4,6 +4,6 @@
4
4
  // This source code and its use and distribution, is subject to the terms
5
5
  // and conditions of the applicable license agreement.
6
6
 
7
- // @gumlet/insights-js-core version 2.1.2
7
+ // @gumlet/insights-js-core version 2.1.4
8
8
 
9
- import{t as e}from"./Events-0c7mGtu4.mjs";import{t}from"./Logger-cMmxz-cn.mjs";var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),l=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e},u=((e,t,i)=>(i=e==null?{}:n(o(e)),l(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e)))(c(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(`StateMachine`,[],r):typeof e==`object`?e.StateMachine=r():n.StateMachine=r()})(e,function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=5)})([(function(e,t,n){e.exports=function(e,t){var n,r,i;for(n=1;n<arguments.length;n++)for(i in r=arguments[n],r)r.hasOwnProperty(i)&&(e[i]=r[i]);return e}}),(function(e,t,n){var r=n(0);e.exports={build:function(e,t){var n,i,a,o=t.plugins;for(n=0,i=o.length;n<i;n++)a=o[n],a.methods&&r(e,a.methods),a.properties&&Object.defineProperties(e,a.properties)},hook:function(e,t,n){var r,i,a,o,s=e.config.plugins,c=[e.context];for(n&&(c=c.concat(n)),r=0,i=s.length;r<i;r++)o=s[r],a=s[r][t],a&&a.apply(o,c)}}}),(function(e,t,n){function r(e){if(e.length===0)return e;var t,n,r=e.split(/[_-]/);if(r.length===1&&r[0][0].toLowerCase()===r[0][0])return e;for(n=r[0].toLowerCase(),t=1;t<r.length;t++)n=n+r[t].charAt(0).toUpperCase()+r[t].substring(1).toLowerCase();return n}r.prepended=function(e,t){return t=r(t),e+t[0].toUpperCase()+t.substring(1)},e.exports=r}),(function(e,t,n){var r=n(0),i=n(2);function a(e,t){e||={},this.options=e,this.defaults=t.defaults,this.states=[],this.transitions=[],this.map={},this.lifecycle=this.configureLifecycle(),this.init=this.configureInitTransition(e.init),this.data=this.configureData(e.data),this.methods=this.configureMethods(e.methods),this.map[this.defaults.wildcard]={},this.configureTransitions(e.transitions||[]),this.plugins=this.configurePlugins(e.plugins,t.plugin)}r(a.prototype,{addState:function(e){this.map[e]||(this.states.push(e),this.addStateLifecycleNames(e),this.map[e]={})},addStateLifecycleNames:function(e){this.lifecycle.onEnter[e]=i.prepended(`onEnter`,e),this.lifecycle.onLeave[e]=i.prepended(`onLeave`,e),this.lifecycle.on[e]=i.prepended(`on`,e)},addTransition:function(e){this.transitions.indexOf(e)<0&&(this.transitions.push(e),this.addTransitionLifecycleNames(e))},addTransitionLifecycleNames:function(e){this.lifecycle.onBefore[e]=i.prepended(`onBefore`,e),this.lifecycle.onAfter[e]=i.prepended(`onAfter`,e),this.lifecycle.on[e]=i.prepended(`on`,e)},mapTransition:function(e){var t=e.name,n=e.from,r=e.to;return this.addState(n),typeof r!=`function`&&this.addState(r),this.addTransition(t),this.map[n][t]=e,e},configureLifecycle:function(){return{onBefore:{transition:`onBeforeTransition`},onAfter:{transition:`onAfterTransition`},onEnter:{state:`onEnterState`},onLeave:{state:`onLeaveState`},on:{transition:`onTransition`}}},configureInitTransition:function(e){return typeof e==`string`?this.mapTransition(r({},this.defaults.init,{to:e,active:!0})):typeof e==`object`?this.mapTransition(r({},this.defaults.init,e,{active:!0})):(this.addState(this.defaults.init.from),this.defaults.init)},configureData:function(e){return typeof e==`function`?e:typeof e==`object`?function(){return e}:function(){return{}}},configureMethods:function(e){return e||{}},configurePlugins:function(e,t){e||=[];var n,r,i;for(n=0,r=e.length;n<r;n++)i=e[n],typeof i==`function`&&(e[n]=i=i()),i.configure&&i.configure(this);return e},configureTransitions:function(e){var t,n,r,i,a,o=this.defaults.wildcard;for(n=0;n<e.length;n++)for(r=e[n],i=Array.isArray(r.from)?r.from:[r.from||o],a=r.to||o,t=0;t<i.length;t++)this.mapTransition({name:r.name,from:i[t],to:a})},transitionFor:function(e,t){var n=this.defaults.wildcard;return this.map[e][t]||this.map[n][t]},transitionsFor:function(e){var t=this.defaults.wildcard;return Object.keys(this.map[e]).concat(Object.keys(this.map[t]))},allStates:function(){return this.states},allTransitions:function(){return this.transitions}}),e.exports=a}),(function(e,t,n){var r=n(0),i=n(6),a=n(1),o=[null,[]];function s(e,t){this.context=e,this.config=t,this.state=t.init.from,this.observers=[e]}r(s.prototype,{init:function(e){if(r(this.context,this.config.data.apply(this.context,e)),a.hook(this,`init`),this.config.init.active)return this.fire(this.config.init.name,[])},is:function(e){return Array.isArray(e)?e.indexOf(this.state)>=0:this.state===e},isPending:function(){return this.pending},can:function(e){return!this.isPending()&&!!this.seek(e)},cannot:function(e){return!this.can(e)},allStates:function(){return this.config.allStates()},allTransitions:function(){return this.config.allTransitions()},transitions:function(){return this.config.transitionsFor(this.state)},seek:function(e,t){var n=this.config.defaults.wildcard,r=this.config.transitionFor(this.state,e),i=r&&r.to;return typeof i==`function`?i.apply(this.context,t):i===n?this.state:i},fire:function(e,t){return this.transit(e,this.state,this.seek(e,t),t)},transit:function(e,t,n,r){var i=this.config.lifecycle,a=this.config.options.observeUnchangedState||t!==n;return n?this.isPending()?this.context.onPendingTransition(e,t,n):(this.config.addState(n),this.beginTransit(),r.unshift({transition:e,from:t,to:n,fsm:this.context}),this.observeEvents([this.observersForEvent(i.onBefore.transition),this.observersForEvent(i.onBefore[e]),a?this.observersForEvent(i.onLeave.state):o,a?this.observersForEvent(i.onLeave[t]):o,this.observersForEvent(i.on.transition),a?[`doTransit`,[this]]:o,a?this.observersForEvent(i.onEnter.state):o,a?this.observersForEvent(i.onEnter[n]):o,a?this.observersForEvent(i.on[n]):o,this.observersForEvent(i.onAfter.transition),this.observersForEvent(i.onAfter[e]),this.observersForEvent(i.on[e])],r)):this.context.onInvalidTransition(e,t,n)},beginTransit:function(){this.pending=!0},endTransit:function(e){return this.pending=!1,e},failTransit:function(e){throw this.pending=!1,e},doTransit:function(e){this.state=e.to},observe:function(e){if(e.length===2){var t={};t[e[0]]=e[1],this.observers.push(t)}else this.observers.push(e[0])},observersForEvent:function(e){for(var t=0,n=this.observers.length,r,i=[];t<n;t++)r=this.observers[t],r[e]&&i.push(r);return[e,i,!0]},observeEvents:function(e,t,n,r){if(e.length===0)return this.endTransit(r===void 0?!0:r);var i=e[0][0],o=e[0][1],s=e[0][2];if(t[0].event=i,i&&s&&i!==n&&a.hook(this,`lifecycle`,t),o.length===0)return e.shift(),this.observeEvents(e,t,i,r);var c=o.shift(),l=c[i].apply(c,t);return l&&typeof l.then==`function`?l.then(this.observeEvents.bind(this,e,t,i)).catch(this.failTransit.bind(this)):l===!1?this.endTransit(!1):this.observeEvents(e,t,i,l)},onInvalidTransition:function(e,t,n){throw new i(`transition is invalid in current state`,e,t,n,this.state)},onPendingTransition:function(e,t,n){throw new i(`transition is invalid while previous transition is still in progress`,e,t,n,this.state)}}),e.exports=s}),(function(e,t,n){var r=n(0),i=n(2),a=n(1),o=n(3),s=n(4),c={is:function(e){return this._fsm.is(e)},can:function(e){return this._fsm.can(e)},cannot:function(e){return this._fsm.cannot(e)},observe:function(){return this._fsm.observe(arguments)},transitions:function(){return this._fsm.transitions()},allTransitions:function(){return this._fsm.allTransitions()},allStates:function(){return this._fsm.allStates()},onInvalidTransition:function(e,t,n){return this._fsm.onInvalidTransition(e,t,n)},onPendingTransition:function(e,t,n){return this._fsm.onPendingTransition(e,t,n)}},l={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(e){throw Error(`use transitions to change state`)}}};function u(e){return f(this||{},e)}function d(){var e,t;typeof arguments[0]==`function`?(e=arguments[0],t=arguments[1]||{}):(e=function(){this._fsm.apply(this,arguments)},t=arguments[0]||{});var n=new o(t,u);return p(e.prototype,n),e.prototype._fsm.config=n,e}function f(e,t){return p(e,new o(t,u)),e._fsm(),e}function p(e,t){if(typeof e!=`object`||Array.isArray(e))throw Error(`StateMachine can only be applied to objects`);a.build(e,t),Object.defineProperties(e,l),r(e,c),r(e,t.methods),t.allTransitions().forEach(function(t){e[i(t)]=function(){return this._fsm.fire(t,[].slice.call(arguments))}}),e._fsm=function(){this._fsm=new s(this,t),this._fsm.init(arguments)}}u.version=`3.0.1`,u.factory=d,u.apply=f,u.defaults={wildcard:`*`,init:{name:`init`,from:`none`}},e.exports=u}),(function(e,t,n){e.exports=function(e,t,n,r,i){this.message=e,this.transition=t,this.from=n,this.to=r,this.current=i}})])})}))(),1),d=class{constructor(e,t={}){this.previousRecordTime=0,this.playbackWatchTime=0,this.lastPlayHeadDuration=0,this.onEnterStateTimestamp=0,this.heartbeatTimestamp=0,this.seekStartedAt=null,this.seekedFrom=0,this.seekedTimestamp=0,this.pausedAtPlayheadMs=0,this.lastPreJumpPlayheadSec=null,this.playTimeStamp=null,this.startupBufferingPending=!1,this.pendingErrorRecovery_=!1,this.States={SETUP:`SETUP`,STARTUP:`STARTUP`,READY:`READY`,PLAYING:`PLAYING`,REBUFFERING:`REBUFFERING`,PAUSE:`PAUSE`,PAUSED_SEEKING:`PAUSED_SEEKING`,END:`END`,ERROR:`ERROR`,CASTING:`CASTING`},this.callbacks=e,this.opts=t,this.createStateMachine()}callEvent(e,n,r){this.fsm.can(e)?this.fsm[e](r,n):t.log(`Ignored Event: ${e}`)}updateMetadata(e){this.callbacks.updateSample(e)}allStates(){return Object.values(this.States)}createStateMachine(){let n=this,r=this.States,i=this.opts,a=[e.PLAY,e.PAUSE,e.SEEK,e.SEEKED,e.PLAYBACK_PLAYING,e.PLAYBACK_FINISHED,e.READY,e.SCREEN_RESIZE,e.END,e.ERROR,e.NON_FATAL_ERROR,e.UN_MUTE,e.MUTE];this.fsm=new u.default({init:r.SETUP,transitions:[{name:e.TIMECHANGED,from:r.SETUP,to:r.SETUP},{name:e.READY,from:[r.SETUP,r.ERROR],to:r.READY},{name:e.SOURCE_LOADED,from:r.SETUP,to:r.SETUP},{name:e.PLAY,from:r.READY,to:r.STARTUP},{name:e.SOURCE_LOADED,from:r.READY,to:r.READY},{name:e.SEEK,from:r.READY,to:r.READY},{name:e.SEEKED,from:r.READY,to:r.READY},{name:e.MUTE,from:r.READY,to:r.READY},{name:e.UN_MUTE,from:r.READY,to:r.READY},{name:e.VIDEO_CHANGE,from:r.READY,to:r.READY},{name:e.AUDIO_CHANGE,from:r.READY,to:r.READY},{name:e.TIMECHANGED,from:r.STARTUP,to:r.PLAYING},{name:e.START_BUFFERING,from:r.STARTUP,to:r.STARTUP},{name:e.END_BUFFERING,from:r.STARTUP,to:r.STARTUP},{name:e.VIDEO_CHANGE,from:r.STARTUP,to:r.STARTUP},{name:e.AUDIO_CHANGE,from:r.STARTUP,to:r.STARTUP},{name:e.SEEK,from:r.STARTUP,to:r.STARTUP},{name:e.SEEKED,from:r.STARTUP,to:r.STARTUP},{name:e.SOURCE_LOADED,from:r.STARTUP,to:r.STARTUP},{name:e.END,from:r.STARTUP,to:r.END},{name:e.TIMECHANGED,from:r.PLAYING,to:r.PLAYING},{name:e.END_BUFFERING,from:r.PLAYING,to:r.PLAYING},{name:e.SEEK,from:r.PLAYING,to:r.PLAYING},{name:e.SEEKED,from:r.PLAYING,to:r.PLAYING},{name:e.SOURCE_LOADED,from:r.PLAYING,to:r.PLAYING},{name:e.VIDEO_CHANGE,from:r.PLAYING,to:r.PLAYING},{name:e.AUDIO_CHANGE,from:r.PLAYING,to:r.PLAYING},{name:e.MUTE,from:r.PLAYING,to:r.PLAYING},{name:e.UN_MUTE,from:r.PLAYING,to:r.PLAYING},{name:e.PAUSE,from:r.PLAYING,to:r.PAUSE},{name:e.START_BUFFERING,from:r.PLAYING,to:r.REBUFFERING},{name:e.END,from:r.PLAYING,to:r.END},{name:e.START_BUFFERING,from:r.REBUFFERING,to:r.REBUFFERING},{name:e.VIDEO_CHANGE,from:r.REBUFFERING,to:r.REBUFFERING},{name:e.AUDIO_CHANGE,from:r.REBUFFERING,to:r.REBUFFERING},{name:e.PLAY,from:r.REBUFFERING,to:r.PLAYING},{name:e.TIMECHANGED,from:r.REBUFFERING,to:r.PLAYING},{name:e.SEEKED,from:r.REBUFFERING,to:r.PLAYING},{name:e.PAUSE,from:r.REBUFFERING,to:r.PAUSE},{name:e.END,from:r.REBUFFERING,to:r.END},{name:e.TIMECHANGED,from:r.PAUSE,to:r.PAUSE},{name:e.SEEKED,from:r.PAUSE,to:r.PAUSE},{name:e.VIDEO_CHANGE,from:r.PAUSE,to:r.PAUSE},{name:e.AUDIO_CHANGE,from:r.PAUSE,to:r.PAUSE},{name:e.MUTE,from:r.PAUSE,to:r.PAUSE},{name:e.UN_MUTE,from:r.PAUSE,to:r.PAUSE},{name:e.PLAY,from:r.PAUSE,to:r.PLAYING},{name:e.SEEK,from:r.PAUSE,to:r.PAUSED_SEEKING},{name:e.END,from:r.PAUSE,to:r.END},{name:e.SEEK,from:r.PAUSED_SEEKING,to:r.PAUSED_SEEKING},{name:e.AUDIO_CHANGE,from:r.PAUSED_SEEKING,to:r.PAUSED_SEEKING},{name:e.VIDEO_CHANGE,from:r.PAUSED_SEEKING,to:r.PAUSED_SEEKING},{name:e.START_BUFFERING,from:r.PAUSED_SEEKING,to:r.PAUSED_SEEKING},{name:e.END_BUFFERING,from:r.PAUSED_SEEKING,to:r.PAUSED_SEEKING},{name:e.PLAY,from:r.PAUSED_SEEKING,to:r.PAUSED_SEEKING},{name:e.SEEKED,from:r.PAUSED_SEEKING,to:r.PAUSE},{name:e.TIMECHANGED,from:r.PAUSED_SEEKING,to:r.PLAYING},{name:e.PAUSE,from:r.PAUSED_SEEKING,to:r.PAUSE},{name:e.END,from:r.PAUSED_SEEKING,to:r.END},{name:e.SEEK,from:r.END,to:r.END},{name:e.SEEKED,from:r.END,to:r.END},{name:e.TIMECHANGED,from:r.END,to:r.END},{name:e.END_BUFFERING,from:r.END,to:r.END},{name:e.START_BUFFERING,from:r.END,to:r.END},{name:e.END,from:r.END,to:r.END},{name:e.PLAY,from:r.END,to:r.PLAYING},{name:e.ERROR,from:this.allStates(),to:r.ERROR},{name:e.PAUSE,from:r.ERROR,to:r.ERROR},{name:e.PLAY,from:r.ERROR,to:r.PLAYING},{name:e.TIMECHANGED,from:r.ERROR,to:r.PLAYING},{name:e.SOURCE_LOADED,from:r.ERROR,to:r.ERROR},{name:e.METADATA_LOADED,from:r.ERROR,to:r.ERROR},{name:e.START_BUFFERING,from:r.ERROR,to:r.REBUFFERING},{name:e.SEEK,from:r.ERROR,to:r.ERROR},{name:e.SEEKED,from:r.ERROR,to:r.ERROR},{name:e.MUTE,from:r.ERROR,to:r.ERROR},{name:e.UN_MUTE,from:r.ERROR,to:r.ERROR},{name:e.VIDEO_CHANGE,from:r.ERROR,to:r.ERROR},{name:e.AUDIO_CHANGE,from:r.ERROR,to:r.ERROR},{name:e.END_BUFFERING,from:r.ERROR,to:r.ERROR},{name:e.END,from:r.ERROR,to:r.END},...this.allStates().map(t=>({name:e.NON_FATAL_ERROR,from:t,to:t})),{name:e.UNLOAD,from:this.allStates(),to:r.END},{name:e.START_CAST,from:[r.READY,r.PAUSE],to:r.CASTING},{name:e.PAUSE,from:r.CASTING,to:r.CASTING},{name:e.PLAY,from:r.CASTING,to:r.CASTING},{name:e.TIMECHANGED,from:r.CASTING,to:r.CASTING},{name:e.MUTE,from:r.CASTING,to:r.CASTING},{name:e.SEEK,from:r.CASTING,to:r.CASTING},{name:e.SEEKED,from:r.CASTING,to:r.CASTING},{name:e.END_CAST,from:r.CASTING,to:r.READY}],methods:{onBeforeTransition(t,i,o){if(n.callbacks.playbackWatchTime(n.playbackWatchTime),t.transition===e.SEEK&&(t.from===r.PLAYING||t.from===r.CASTING)&&n.seekStartedAt===null&&(n.seekedFrom=Math.round(n.previousRecordTime*1e3)),t.transition===e.SEEK&&t.from===r.PAUSE&&(n.seekedFrom=n.pausedAtPlayheadMs),t.transition===e.PAUSE&&t.from!==r.PAUSED_SEEKING){let e=o?.currentTime;if(typeof e==`number`)if(n.lastPreJumpPlayheadSec!=null)n.pausedAtPlayheadMs=Math.round(n.lastPreJumpPlayheadSec*1e3),n.lastPreJumpPlayheadSec=null;else{let t=n.previousRecordTime;n.pausedAtPlayheadMs=Math.abs(e-t)>=5?Math.round(t*1e3):Math.round(e*1e3)}}a.includes(t.transition)&&(t.transition===e.PLAYBACK_FINISHED&&(n.previousRecordTime=0),o&&(n.previousRecordTime=o.currentTime)),o&&t.transition!==e.SOURCE_LOADED&&(n.lastPlayHeadDuration=o.currentTime*1e3)},onLeaveState(i,a,o){if(!a)return;let s=a-n.onEnterStateTimestamp;o&&i.to!==r.PAUSED_SEEKING&&(t.log(`Setting video time end to ${o.currentTime}, going to ${i.to}`),n.callbacks.setVideoTimeEndFromEvent(o));let c=i.from.toLowerCase();if(i.from===r.PAUSED_SEEKING){let e=a-(n.seekStartedAt??a);n.seekStartedAt=null,n.callbacks.playback_seeked(n.seekedFrom,o.currentTime*1e3,e,i.to),n.callbacks.heartbeat(a,r.PAUSE.toLowerCase(),o),t.log(`Seek was ${e}ms`)}else i.transition===e.UNLOAD&&i.from===r.PLAYING?n.callbacks.playingAndBye(s,c,o):i.from===r.PAUSE&&i.to!==r.PAUSED_SEEKING&&i.to!==r.PLAYING&&(n.callbacks.setVideoTimeStartFromEvent(i.transition),n.callbacks.pause(s,c,o),n.callbacks.heartbeat(a,c,o))},onAfterTransition(r,i,a){n.callbacks.resetSessionExpiry(),r.transition===e.VIDEO_CHANGE?n.callbacks.videoChange(a):r.transition===e.AUDIO_CHANGE?n.callbacks.audioChange(a):r.transition===e.MUTE?(t.log(`Setting sample to muted`),n.callbacks.mute(i,a)):r.transition===e.UN_MUTE&&(t.log(`Setting sample to unmuted`),n.callbacks.unMute(i,a))},onEnterState(t,o,s){t.to===r.ERROR&&(n.pendingErrorRecovery_=!1),n.callbacks.playbackWatchTime(n.playbackWatchTime),a.includes(t.transition)&&s&&(n.previousRecordTime=s.currentTime),t.transition!==e.NON_FATAL_ERROR&&(t.from===`none`&&i.starttime?n.onEnterStateTimestamp=i.starttime:n.onEnterStateTimestamp=o||Date.now()),(t.to===r.PLAYING&&(t.from===r.STARTUP||t.from===r.PAUSE||t.from===r.REBUFFERING||t.from===r.PAUSED_SEEKING||t.from===r.ERROR)||t.from===`none`&&t.to===r.SETUP)&&(n.heartbeatTimestamp=t.from===`none`&&i.starttime?i.starttime:o||Date.now()),s&&t.to!==r.PAUSED_SEEKING&&n.callbacks.setVideoTimeStartFromEvent(s)},onEnterSetup(e,t,a){e.from===`none`&&n.callbacks.setup(t,r.SETUP,a,i)},onEnterReady(e,t,i){e.from===r.SETUP&&n.callbacks.ready(t,r.READY,i)},onEnterStartup(t,i,a){t.transition===e.PLAY&&(n.playTimeStamp=new Date,n.callbacks.first_play(i,r.STARTUP,a))},onEnterPlaying(t,i,a){t.transition===e.PLAY&&t.from===r.PAUSE?(n.callbacks.play(i,r.PLAYING,a),n.callbacks.playing(i,r.PLAYING,a),n.callbacks.heartbeat(i,r.PLAYING,a)):t.from===r.STARTUP?(n.startupBufferingPending&&(n.startupBufferingPending=!1,n.callbacks.start_rebuffer(i,r.REBUFFERING,a),n.callbacks.end_rebuffer(i,r.REBUFFERING,a)),n.callbacks.playing(i,r.PLAYING,a),n.callbacks.playback_started(a)):t.from===r.REBUFFERING?(n.callbacks.end_rebuffer(i,r.REBUFFERING,a),n.pendingErrorRecovery_&&(n.pendingErrorRecovery_=!1,n.callbacks.error_recovered(i,r.ERROR,a))):t.from===r.ERROR&&n.callbacks.error_recovered(i,r.ERROR,a)},onEnterPause(e,t,i){e.from===r.PAUSED_SEEKING&&i&&typeof i.currentTime==`number`&&(n.pausedAtPlayheadMs=i.currentTime*1e3),e.from===r.PLAYING&&(n.callbacks.pause(t,r.PAUSE,i),n.callbacks.heartbeat(t,r.PAUSE,i))},onEnterRebuffering(t,i,a){t.transition===e.START_BUFFERING&&(n.callbacks.start_rebuffer(i,r.REBUFFERING,a),t.from===r.ERROR&&(n.pendingErrorRecovery_=!0))},onBeforeStartBuffering(e,t,i){e.from===r.STARTUP&&(n.startupBufferingPending=!0)},onEnterEnd(e,t,i){n.callbacks.end(t,r.END,i),n.callbacks.heartbeat(t,r.END,i)},onBeforeSourceLoaded(e,t,i){let a=e.from===r.PLAYING&&n.playTimeStamp?Date.now()-n.playTimeStamp.getTime():null;n.callbacks.loaded(t,r.READY,i,a)},onSeek(e,t,r){r&&(n.previousRecordTime=r.currentTime),n.callbacks.playbackWatchTime(n.playbackWatchTime),n.seekStartedAt=n.seekStartedAt??t},onSeeked(e,i,a){if(a&&(n.previousRecordTime=a.currentTime),n.callbacks.playbackWatchTime(n.playbackWatchTime),n.seekedTimestamp=i,a&&(e.from===r.PLAYING&&e.to===r.PLAYING||e.from===r.CASTING&&e.to===r.CASTING)){let e=n.seekStartedAt==null?0:i-n.seekStartedAt;n.callbacks.playback_seeked(n.seekedFrom,a.currentTime*1e3,e,null),t.log(`Seek was ${e}ms`)}n.seekStartedAt=null},onTimechanged(e,r,i){n.callbacks.playbackWatchTime(n.playbackWatchTime);let a=i.currentTime-n.previousRecordTime;a>0&&a<5?(n.playbackWatchTime+=Math.round(a*1e3),n.previousRecordTime=i.currentTime,n.lastPreJumpPlayheadSec=null):(n.lastPreJumpPlayheadSec=n.previousRecordTime,n.previousRecordTime=i.currentTime);let o=r-n.heartbeatTimestamp;o>1e4&&(n.callbacks.setVideoTimeEndFromEvent(i),t.log(`Sending heartbeat`),n.callbacks.heartbeat(o,e.from.toLowerCase(),i),n.heartbeatTimestamp=r,n.callbacks.setVideoTimeStartFromEvent(i),n.callbacks.resetSessionExpiry())},onPlayerError(e,t,r){n.callbacks.error(r)},onPlayerNonFatalError(e,t,r){n.callbacks.error(r)}}})}static pad(e,t){return(e+Array(t).join(` `)).slice(0,t)}};export{d as GumletStateMachine};
9
+ import{t as e}from"./Events-D5KYZXXC.mjs";import{t}from"./Logger-CXYCiU0M.mjs";var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),l=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e},u=((e,t,i)=>(i=e==null?{}:n(o(e)),l(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e)))(c(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(`StateMachine`,[],r):typeof e==`object`?e.StateMachine=r():n.StateMachine=r()})(e,function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=5)})([(function(e,t,n){e.exports=function(e,t){var n,r,i;for(n=1;n<arguments.length;n++)for(i in r=arguments[n],r)r.hasOwnProperty(i)&&(e[i]=r[i]);return e}}),(function(e,t,n){var r=n(0);e.exports={build:function(e,t){var n,i,a,o=t.plugins;for(n=0,i=o.length;n<i;n++)a=o[n],a.methods&&r(e,a.methods),a.properties&&Object.defineProperties(e,a.properties)},hook:function(e,t,n){var r,i,a,o,s=e.config.plugins,c=[e.context];for(n&&(c=c.concat(n)),r=0,i=s.length;r<i;r++)o=s[r],a=s[r][t],a&&a.apply(o,c)}}}),(function(e,t,n){function r(e){if(e.length===0)return e;var t,n,r=e.split(/[_-]/);if(r.length===1&&r[0][0].toLowerCase()===r[0][0])return e;for(n=r[0].toLowerCase(),t=1;t<r.length;t++)n=n+r[t].charAt(0).toUpperCase()+r[t].substring(1).toLowerCase();return n}r.prepended=function(e,t){return t=r(t),e+t[0].toUpperCase()+t.substring(1)},e.exports=r}),(function(e,t,n){var r=n(0),i=n(2);function a(e,t){e||={},this.options=e,this.defaults=t.defaults,this.states=[],this.transitions=[],this.map={},this.lifecycle=this.configureLifecycle(),this.init=this.configureInitTransition(e.init),this.data=this.configureData(e.data),this.methods=this.configureMethods(e.methods),this.map[this.defaults.wildcard]={},this.configureTransitions(e.transitions||[]),this.plugins=this.configurePlugins(e.plugins,t.plugin)}r(a.prototype,{addState:function(e){this.map[e]||(this.states.push(e),this.addStateLifecycleNames(e),this.map[e]={})},addStateLifecycleNames:function(e){this.lifecycle.onEnter[e]=i.prepended(`onEnter`,e),this.lifecycle.onLeave[e]=i.prepended(`onLeave`,e),this.lifecycle.on[e]=i.prepended(`on`,e)},addTransition:function(e){this.transitions.indexOf(e)<0&&(this.transitions.push(e),this.addTransitionLifecycleNames(e))},addTransitionLifecycleNames:function(e){this.lifecycle.onBefore[e]=i.prepended(`onBefore`,e),this.lifecycle.onAfter[e]=i.prepended(`onAfter`,e),this.lifecycle.on[e]=i.prepended(`on`,e)},mapTransition:function(e){var t=e.name,n=e.from,r=e.to;return this.addState(n),typeof r!=`function`&&this.addState(r),this.addTransition(t),this.map[n][t]=e,e},configureLifecycle:function(){return{onBefore:{transition:`onBeforeTransition`},onAfter:{transition:`onAfterTransition`},onEnter:{state:`onEnterState`},onLeave:{state:`onLeaveState`},on:{transition:`onTransition`}}},configureInitTransition:function(e){return typeof e==`string`?this.mapTransition(r({},this.defaults.init,{to:e,active:!0})):typeof e==`object`?this.mapTransition(r({},this.defaults.init,e,{active:!0})):(this.addState(this.defaults.init.from),this.defaults.init)},configureData:function(e){return typeof e==`function`?e:typeof e==`object`?function(){return e}:function(){return{}}},configureMethods:function(e){return e||{}},configurePlugins:function(e,t){e||=[];var n,r,i;for(n=0,r=e.length;n<r;n++)i=e[n],typeof i==`function`&&(e[n]=i=i()),i.configure&&i.configure(this);return e},configureTransitions:function(e){var t,n,r,i,a,o=this.defaults.wildcard;for(n=0;n<e.length;n++)for(r=e[n],i=Array.isArray(r.from)?r.from:[r.from||o],a=r.to||o,t=0;t<i.length;t++)this.mapTransition({name:r.name,from:i[t],to:a})},transitionFor:function(e,t){var n=this.defaults.wildcard;return this.map[e][t]||this.map[n][t]},transitionsFor:function(e){var t=this.defaults.wildcard;return Object.keys(this.map[e]).concat(Object.keys(this.map[t]))},allStates:function(){return this.states},allTransitions:function(){return this.transitions}}),e.exports=a}),(function(e,t,n){var r=n(0),i=n(6),a=n(1),o=[null,[]];function s(e,t){this.context=e,this.config=t,this.state=t.init.from,this.observers=[e]}r(s.prototype,{init:function(e){if(r(this.context,this.config.data.apply(this.context,e)),a.hook(this,`init`),this.config.init.active)return this.fire(this.config.init.name,[])},is:function(e){return Array.isArray(e)?e.indexOf(this.state)>=0:this.state===e},isPending:function(){return this.pending},can:function(e){return!this.isPending()&&!!this.seek(e)},cannot:function(e){return!this.can(e)},allStates:function(){return this.config.allStates()},allTransitions:function(){return this.config.allTransitions()},transitions:function(){return this.config.transitionsFor(this.state)},seek:function(e,t){var n=this.config.defaults.wildcard,r=this.config.transitionFor(this.state,e),i=r&&r.to;return typeof i==`function`?i.apply(this.context,t):i===n?this.state:i},fire:function(e,t){return this.transit(e,this.state,this.seek(e,t),t)},transit:function(e,t,n,r){var i=this.config.lifecycle,a=this.config.options.observeUnchangedState||t!==n;return n?this.isPending()?this.context.onPendingTransition(e,t,n):(this.config.addState(n),this.beginTransit(),r.unshift({transition:e,from:t,to:n,fsm:this.context}),this.observeEvents([this.observersForEvent(i.onBefore.transition),this.observersForEvent(i.onBefore[e]),a?this.observersForEvent(i.onLeave.state):o,a?this.observersForEvent(i.onLeave[t]):o,this.observersForEvent(i.on.transition),a?[`doTransit`,[this]]:o,a?this.observersForEvent(i.onEnter.state):o,a?this.observersForEvent(i.onEnter[n]):o,a?this.observersForEvent(i.on[n]):o,this.observersForEvent(i.onAfter.transition),this.observersForEvent(i.onAfter[e]),this.observersForEvent(i.on[e])],r)):this.context.onInvalidTransition(e,t,n)},beginTransit:function(){this.pending=!0},endTransit:function(e){return this.pending=!1,e},failTransit:function(e){throw this.pending=!1,e},doTransit:function(e){this.state=e.to},observe:function(e){if(e.length===2){var t={};t[e[0]]=e[1],this.observers.push(t)}else this.observers.push(e[0])},observersForEvent:function(e){for(var t=0,n=this.observers.length,r,i=[];t<n;t++)r=this.observers[t],r[e]&&i.push(r);return[e,i,!0]},observeEvents:function(e,t,n,r){if(e.length===0)return this.endTransit(r===void 0?!0:r);var i=e[0][0],o=e[0][1],s=e[0][2];if(t[0].event=i,i&&s&&i!==n&&a.hook(this,`lifecycle`,t),o.length===0)return e.shift(),this.observeEvents(e,t,i,r);var c=o.shift(),l=c[i].apply(c,t);return l&&typeof l.then==`function`?l.then(this.observeEvents.bind(this,e,t,i)).catch(this.failTransit.bind(this)):l===!1?this.endTransit(!1):this.observeEvents(e,t,i,l)},onInvalidTransition:function(e,t,n){throw new i(`transition is invalid in current state`,e,t,n,this.state)},onPendingTransition:function(e,t,n){throw new i(`transition is invalid while previous transition is still in progress`,e,t,n,this.state)}}),e.exports=s}),(function(e,t,n){var r=n(0),i=n(2),a=n(1),o=n(3),s=n(4),c={is:function(e){return this._fsm.is(e)},can:function(e){return this._fsm.can(e)},cannot:function(e){return this._fsm.cannot(e)},observe:function(){return this._fsm.observe(arguments)},transitions:function(){return this._fsm.transitions()},allTransitions:function(){return this._fsm.allTransitions()},allStates:function(){return this._fsm.allStates()},onInvalidTransition:function(e,t,n){return this._fsm.onInvalidTransition(e,t,n)},onPendingTransition:function(e,t,n){return this._fsm.onPendingTransition(e,t,n)}},l={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(e){throw Error(`use transitions to change state`)}}};function u(e){return f(this||{},e)}function d(){var e,t;typeof arguments[0]==`function`?(e=arguments[0],t=arguments[1]||{}):(e=function(){this._fsm.apply(this,arguments)},t=arguments[0]||{});var n=new o(t,u);return p(e.prototype,n),e.prototype._fsm.config=n,e}function f(e,t){return p(e,new o(t,u)),e._fsm(),e}function p(e,t){if(typeof e!=`object`||Array.isArray(e))throw Error(`StateMachine can only be applied to objects`);a.build(e,t),Object.defineProperties(e,l),r(e,c),r(e,t.methods),t.allTransitions().forEach(function(t){e[i(t)]=function(){return this._fsm.fire(t,[].slice.call(arguments))}}),e._fsm=function(){this._fsm=new s(this,t),this._fsm.init(arguments)}}u.version=`3.0.1`,u.factory=d,u.apply=f,u.defaults={wildcard:`*`,init:{name:`init`,from:`none`}},e.exports=u}),(function(e,t,n){e.exports=function(e,t,n,r,i){this.message=e,this.transition=t,this.from=n,this.to=r,this.current=i}})])})}))(),1),d=class{constructor(e,t={}){this.previousRecordTime=0,this.playbackWatchTime=0,this.lastPlayHeadDuration=0,this.onEnterStateTimestamp=0,this.heartbeatTimestamp=0,this.seekStartedAt=null,this.seekedFrom=0,this.seekedTimestamp=0,this.pausedAtPlayheadMs=0,this.lastPreJumpPlayheadSec=null,this.playTimeStamp=null,this.startupBufferingPending=!1,this.pendingErrorRecovery_=!1,this.States={SETUP:`SETUP`,STARTUP:`STARTUP`,READY:`READY`,PLAYING:`PLAYING`,REBUFFERING:`REBUFFERING`,PAUSE:`PAUSE`,PAUSED_SEEKING:`PAUSED_SEEKING`,END:`END`,ERROR:`ERROR`,CASTING:`CASTING`},this.callbacks=e,this.opts=t,this.createStateMachine()}callEvent(e,n,r){this.fsm.can(e)?this.fsm[e](r,n):t.log(`Ignored Event: ${e}`)}updateMetadata(e){this.callbacks.updateSample(e)}allStates(){return Object.values(this.States)}createStateMachine(){let n=this,r=this.States,i=this.opts,a=[e.PLAY,e.PAUSE,e.SEEK,e.SEEKED,e.PLAYBACK_PLAYING,e.PLAYBACK_FINISHED,e.READY,e.SCREEN_RESIZE,e.END,e.ERROR,e.NON_FATAL_ERROR,e.UN_MUTE,e.MUTE];this.fsm=new u.default({init:r.SETUP,transitions:[{name:e.TIMECHANGED,from:r.SETUP,to:r.SETUP},{name:e.READY,from:[r.SETUP,r.ERROR],to:r.READY},{name:e.SOURCE_LOADED,from:r.SETUP,to:r.SETUP},{name:e.PLAY,from:r.READY,to:r.STARTUP},{name:e.SOURCE_LOADED,from:r.READY,to:r.READY},{name:e.SEEK,from:r.READY,to:r.READY},{name:e.SEEKED,from:r.READY,to:r.READY},{name:e.MUTE,from:r.READY,to:r.READY},{name:e.UN_MUTE,from:r.READY,to:r.READY},{name:e.VIDEO_CHANGE,from:r.READY,to:r.READY},{name:e.AUDIO_CHANGE,from:r.READY,to:r.READY},{name:e.TIMECHANGED,from:r.STARTUP,to:r.PLAYING},{name:e.START_BUFFERING,from:r.STARTUP,to:r.STARTUP},{name:e.END_BUFFERING,from:r.STARTUP,to:r.STARTUP},{name:e.VIDEO_CHANGE,from:r.STARTUP,to:r.STARTUP},{name:e.AUDIO_CHANGE,from:r.STARTUP,to:r.STARTUP},{name:e.SEEK,from:r.STARTUP,to:r.STARTUP},{name:e.SEEKED,from:r.STARTUP,to:r.STARTUP},{name:e.SOURCE_LOADED,from:r.STARTUP,to:r.STARTUP},{name:e.END,from:r.STARTUP,to:r.END},{name:e.TIMECHANGED,from:r.PLAYING,to:r.PLAYING},{name:e.END_BUFFERING,from:r.PLAYING,to:r.PLAYING},{name:e.SEEK,from:r.PLAYING,to:r.PLAYING},{name:e.SEEKED,from:r.PLAYING,to:r.PLAYING},{name:e.SOURCE_LOADED,from:r.PLAYING,to:r.PLAYING},{name:e.VIDEO_CHANGE,from:r.PLAYING,to:r.PLAYING},{name:e.AUDIO_CHANGE,from:r.PLAYING,to:r.PLAYING},{name:e.MUTE,from:r.PLAYING,to:r.PLAYING},{name:e.UN_MUTE,from:r.PLAYING,to:r.PLAYING},{name:e.PAUSE,from:r.PLAYING,to:r.PAUSE},{name:e.START_BUFFERING,from:r.PLAYING,to:r.REBUFFERING},{name:e.END,from:r.PLAYING,to:r.END},{name:e.START_BUFFERING,from:r.REBUFFERING,to:r.REBUFFERING},{name:e.VIDEO_CHANGE,from:r.REBUFFERING,to:r.REBUFFERING},{name:e.AUDIO_CHANGE,from:r.REBUFFERING,to:r.REBUFFERING},{name:e.PLAY,from:r.REBUFFERING,to:r.PLAYING},{name:e.TIMECHANGED,from:r.REBUFFERING,to:r.PLAYING},{name:e.SEEKED,from:r.REBUFFERING,to:r.PLAYING},{name:e.PAUSE,from:r.REBUFFERING,to:r.PAUSE},{name:e.END,from:r.REBUFFERING,to:r.END},{name:e.TIMECHANGED,from:r.PAUSE,to:r.PAUSE},{name:e.SEEKED,from:r.PAUSE,to:r.PAUSE},{name:e.VIDEO_CHANGE,from:r.PAUSE,to:r.PAUSE},{name:e.AUDIO_CHANGE,from:r.PAUSE,to:r.PAUSE},{name:e.MUTE,from:r.PAUSE,to:r.PAUSE},{name:e.UN_MUTE,from:r.PAUSE,to:r.PAUSE},{name:e.PLAY,from:r.PAUSE,to:r.PLAYING},{name:e.SEEK,from:r.PAUSE,to:r.PAUSED_SEEKING},{name:e.END,from:r.PAUSE,to:r.END},{name:e.SEEK,from:r.PAUSED_SEEKING,to:r.PAUSED_SEEKING},{name:e.AUDIO_CHANGE,from:r.PAUSED_SEEKING,to:r.PAUSED_SEEKING},{name:e.VIDEO_CHANGE,from:r.PAUSED_SEEKING,to:r.PAUSED_SEEKING},{name:e.START_BUFFERING,from:r.PAUSED_SEEKING,to:r.PAUSED_SEEKING},{name:e.END_BUFFERING,from:r.PAUSED_SEEKING,to:r.PAUSED_SEEKING},{name:e.PLAY,from:r.PAUSED_SEEKING,to:r.PAUSED_SEEKING},{name:e.SEEKED,from:r.PAUSED_SEEKING,to:r.PAUSE},{name:e.TIMECHANGED,from:r.PAUSED_SEEKING,to:r.PLAYING},{name:e.PAUSE,from:r.PAUSED_SEEKING,to:r.PAUSE},{name:e.END,from:r.PAUSED_SEEKING,to:r.END},{name:e.SEEK,from:r.END,to:r.END},{name:e.SEEKED,from:r.END,to:r.END},{name:e.TIMECHANGED,from:r.END,to:r.END},{name:e.END_BUFFERING,from:r.END,to:r.END},{name:e.START_BUFFERING,from:r.END,to:r.END},{name:e.END,from:r.END,to:r.END},{name:e.PLAY,from:r.END,to:r.PLAYING},{name:e.ERROR,from:this.allStates(),to:r.ERROR},{name:e.PAUSE,from:r.ERROR,to:r.ERROR},{name:e.PLAY,from:r.ERROR,to:r.PLAYING},{name:e.TIMECHANGED,from:r.ERROR,to:r.PLAYING},{name:e.SOURCE_LOADED,from:r.ERROR,to:r.ERROR},{name:e.METADATA_LOADED,from:r.ERROR,to:r.ERROR},{name:e.START_BUFFERING,from:r.ERROR,to:r.REBUFFERING},{name:e.SEEK,from:r.ERROR,to:r.ERROR},{name:e.SEEKED,from:r.ERROR,to:r.ERROR},{name:e.MUTE,from:r.ERROR,to:r.ERROR},{name:e.UN_MUTE,from:r.ERROR,to:r.ERROR},{name:e.VIDEO_CHANGE,from:r.ERROR,to:r.ERROR},{name:e.AUDIO_CHANGE,from:r.ERROR,to:r.ERROR},{name:e.END_BUFFERING,from:r.ERROR,to:r.ERROR},{name:e.END,from:r.ERROR,to:r.END},...this.allStates().map(t=>({name:e.NON_FATAL_ERROR,from:t,to:t})),{name:e.UNLOAD,from:this.allStates(),to:r.END},{name:e.START_CAST,from:[r.READY,r.PAUSE],to:r.CASTING},{name:e.PAUSE,from:r.CASTING,to:r.CASTING},{name:e.PLAY,from:r.CASTING,to:r.CASTING},{name:e.TIMECHANGED,from:r.CASTING,to:r.CASTING},{name:e.MUTE,from:r.CASTING,to:r.CASTING},{name:e.SEEK,from:r.CASTING,to:r.CASTING},{name:e.SEEKED,from:r.CASTING,to:r.CASTING},{name:e.END_CAST,from:r.CASTING,to:r.READY}],methods:{onBeforeTransition(t,i,o){if(n.callbacks.playbackWatchTime(n.playbackWatchTime),t.transition===e.SEEK&&(t.from===r.PLAYING||t.from===r.CASTING)&&n.seekStartedAt===null&&(n.seekedFrom=Math.round(n.previousRecordTime*1e3)),t.transition===e.SEEK&&t.from===r.PAUSE&&(n.seekedFrom=n.pausedAtPlayheadMs),t.transition===e.PAUSE&&t.from!==r.PAUSED_SEEKING){let e=o?.currentTime;if(typeof e==`number`)if(n.lastPreJumpPlayheadSec!=null)n.pausedAtPlayheadMs=Math.round(n.lastPreJumpPlayheadSec*1e3),n.lastPreJumpPlayheadSec=null;else{let t=n.previousRecordTime;n.pausedAtPlayheadMs=Math.abs(e-t)>=5?Math.round(t*1e3):Math.round(e*1e3)}}a.includes(t.transition)&&(t.transition===e.PLAYBACK_FINISHED&&(n.previousRecordTime=0),o&&(n.previousRecordTime=o.currentTime)),o&&t.transition!==e.SOURCE_LOADED&&(n.lastPlayHeadDuration=o.currentTime*1e3)},onLeaveState(i,a,o){if(!a)return;let s=a-n.onEnterStateTimestamp;o&&i.to!==r.PAUSED_SEEKING&&(t.log(`Setting video time end to ${o.currentTime}, going to ${i.to}`),n.callbacks.setVideoTimeEndFromEvent(o));let c=i.from.toLowerCase();if(i.from===r.PAUSED_SEEKING){let e=a-(n.seekStartedAt??a);n.seekStartedAt=null,n.callbacks.playback_seeked(n.seekedFrom,o.currentTime*1e3,e,i.to),n.callbacks.heartbeat(a,r.PAUSE.toLowerCase(),o),t.log(`Seek was ${e}ms`)}else i.transition===e.UNLOAD&&i.from===r.PLAYING?n.callbacks.playingAndBye(s,c,o):i.from===r.PAUSE&&i.to!==r.PAUSED_SEEKING&&i.to!==r.PLAYING&&(n.callbacks.setVideoTimeStartFromEvent(i.transition),n.callbacks.pause(s,c,o),n.callbacks.heartbeat(a,c,o))},onAfterTransition(r,i,a){n.callbacks.resetSessionExpiry(),r.transition===e.VIDEO_CHANGE?n.callbacks.videoChange(a):r.transition===e.AUDIO_CHANGE?n.callbacks.audioChange(a):r.transition===e.MUTE?(t.log(`Setting sample to muted`),n.callbacks.mute(i,a)):r.transition===e.UN_MUTE&&(t.log(`Setting sample to unmuted`),n.callbacks.unMute(i,a))},onEnterState(t,o,s){t.to===r.ERROR&&(n.pendingErrorRecovery_=!1),n.callbacks.playbackWatchTime(n.playbackWatchTime),a.includes(t.transition)&&s&&(n.previousRecordTime=s.currentTime),t.transition!==e.NON_FATAL_ERROR&&(t.from===`none`&&i.starttime?n.onEnterStateTimestamp=i.starttime:n.onEnterStateTimestamp=o||Date.now()),(t.to===r.PLAYING&&(t.from===r.STARTUP||t.from===r.PAUSE||t.from===r.REBUFFERING||t.from===r.PAUSED_SEEKING||t.from===r.ERROR)||t.from===`none`&&t.to===r.SETUP)&&(n.heartbeatTimestamp=t.from===`none`&&i.starttime?i.starttime:o||Date.now()),s&&t.to!==r.PAUSED_SEEKING&&n.callbacks.setVideoTimeStartFromEvent(s)},onEnterSetup(e,t,a){e.from===`none`&&n.callbacks.setup(t,r.SETUP,a,i)},onEnterReady(e,t,i){e.from===r.SETUP&&n.callbacks.ready(t,r.READY,i)},onEnterStartup(t,i,a){t.transition===e.PLAY&&(n.playTimeStamp=new Date,n.callbacks.first_play(i,r.STARTUP,a))},onEnterPlaying(t,i,a){t.transition===e.PLAY&&t.from===r.PAUSE?(n.callbacks.play(i,r.PLAYING,a),n.callbacks.playing(i,r.PLAYING,a),n.callbacks.heartbeat(i,r.PLAYING,a)):t.from===r.STARTUP?(n.startupBufferingPending&&(n.startupBufferingPending=!1,n.callbacks.start_rebuffer(i,r.REBUFFERING,a),n.callbacks.end_rebuffer(i,r.REBUFFERING,a)),n.callbacks.playing(i,r.PLAYING,a),n.callbacks.playback_started(a)):t.from===r.REBUFFERING?(n.callbacks.end_rebuffer(i,r.REBUFFERING,a),n.pendingErrorRecovery_&&(n.pendingErrorRecovery_=!1,n.callbacks.error_recovered(i,r.ERROR,a))):t.from===r.ERROR&&n.callbacks.error_recovered(i,r.ERROR,a)},onEnterPause(e,t,i){e.from===r.PAUSED_SEEKING&&i&&typeof i.currentTime==`number`&&(n.pausedAtPlayheadMs=i.currentTime*1e3),e.from===r.PLAYING&&(n.callbacks.pause(t,r.PAUSE,i),n.callbacks.heartbeat(t,r.PAUSE,i))},onEnterRebuffering(t,i,a){t.transition===e.START_BUFFERING&&(n.callbacks.start_rebuffer(i,r.REBUFFERING,a),t.from===r.ERROR&&(n.pendingErrorRecovery_=!0))},onBeforeStartBuffering(e,t,i){e.from===r.STARTUP&&(n.startupBufferingPending=!0)},onEnterEnd(e,t,i){n.callbacks.end(t,r.END,i),n.callbacks.heartbeat(t,r.END,i)},onBeforeSourceLoaded(e,t,i){let a=e.from===r.PLAYING&&n.playTimeStamp?Date.now()-n.playTimeStamp.getTime():null;n.callbacks.loaded(t,r.READY,i,a)},onSeek(e,t,r){r&&(n.previousRecordTime=r.currentTime),n.callbacks.playbackWatchTime(n.playbackWatchTime),n.seekStartedAt=n.seekStartedAt??t},onSeeked(e,i,a){if(a&&(n.previousRecordTime=a.currentTime),n.callbacks.playbackWatchTime(n.playbackWatchTime),n.seekedTimestamp=i,a&&(e.from===r.PLAYING&&e.to===r.PLAYING||e.from===r.CASTING&&e.to===r.CASTING)){let e=n.seekStartedAt==null?0:i-n.seekStartedAt;n.callbacks.playback_seeked(n.seekedFrom,a.currentTime*1e3,e,null),t.log(`Seek was ${e}ms`)}n.seekStartedAt=null},onTimechanged(e,r,i){n.callbacks.playbackWatchTime(n.playbackWatchTime);let a=i.currentTime-n.previousRecordTime;a>0&&a<5?(n.playbackWatchTime+=Math.round(a*1e3),n.previousRecordTime=i.currentTime,n.lastPreJumpPlayheadSec=null):(n.lastPreJumpPlayheadSec=n.previousRecordTime,n.previousRecordTime=i.currentTime);let o=r-n.heartbeatTimestamp;o>1e4&&(n.callbacks.setVideoTimeEndFromEvent(i),t.log(`Sending heartbeat`),n.callbacks.heartbeat(o,e.from.toLowerCase(),i),n.heartbeatTimestamp=r,n.callbacks.setVideoTimeStartFromEvent(i),n.callbacks.resetSessionExpiry())},onPlayerError(e,t,r){n.callbacks.error(r)},onPlayerNonFatalError(e,t,r){n.callbacks.error(r)}}})}static pad(e,t){return(e+Array(t).join(` `)).slice(0,t)}};export{d as GumletStateMachine};
@@ -4,6 +4,6 @@
4
4
  // This source code and its use and distribution, is subject to the terms
5
5
  // and conditions of the applicable license agreement.
6
6
 
7
- // @gumlet/insights-js-core version 2.1.2
7
+ // @gumlet/insights-js-core version 2.1.4
8
8
 
9
- import{t as e}from"./Events-0c7mGtu4.mjs";import{t}from"./Players-CDWpB8LO.mjs";const n=`video/mp4`,r=`video/webm`,i=`application/x-mpegURL`,a=`application/dash+xml`,o={MP4:n,WEBM:r,HLS:i,DASH:a};function s(e){return e=e.toLowerCase(),e.endsWith(`.m3u8`)?i:e.endsWith(`.mp4`)||e.endsWith(`.m4v`)||e.endsWith(`.m4a`)?n:e.endsWith(`.webm`)?r:e.endsWith(`.mpd`)?a:null}const{MP4:c,WEBM:l,HLS:u,DASH:d}=o,f={[c]:`mp4`,[l]:`webm`,[u]:`hls`,[d]:`dash`};function p(e){return f[e]}const m=1e3;var h=class{constructor(e,n,r,i=null){this.lastKnownCurrentTime_=0,this.sourceSwitching_=!1,this.eventCallback=n,this.playerSoftwareName=i??t.HTML,this.stateMachine=r,this.mediaEl=e,this.mediaElEventHandlers=[],this.analyticsBitrate_=-1,this.audioCodec_=``,this.videoCodec_=``,this.bufferingTimeout_=null,this.isBuffering_=!1,this.isLive_=!1,this.isPaused_=!1,this.previousMediaTime_=null,this.needsReadyEvent_=!0,this.needsFirstPlayIntent_=!0,this.mediaElementSet_=!1,this.playbackReadySet_=!1,e&&this.setMediaElement()}getCurrentQualityLevelInfo(){return null}isLive(){return!1}getMIMEType(){let e=this.mediaEl;if(!e)return null;let t=e.src||e.querySelector(`source`)?.src||null;return t?s(t):null}getStreamType(){return p(this.getMIMEType()??``)}getPlayerVersion(){return null}getStreamURL(){let e=this.mediaEl;return e&&(e.src||e.querySelector(`source`)?.src)||null}destroy(){this.mediaEl&&this.unregisterMediaElement()}setMediaElement(e=null){if(e&&this.mediaEl&&(this.unregisterMediaElement(),this.mediaElementSet_=!1),e&&(this.mediaEl=e),!this.mediaEl)throw Error(`No media element owned`);if(this.mediaElementSet_)throw Error(`Media element already set (only call this once)`);this.mediaElementSet_=!0,this.registerMediaElement(),this.onMaybeReady()}resetMedia(){this.mediaEl=null,this.mediaElEventHandlers=[]}registerMediaElement(){let t=this.mediaEl;t&&(this.listenToMediaElementEvent(`loadedmetadata`,()=>{if(t.readyState!==1)return;this.checkQualityLevelAttributes(!0);let{duration:n,autoplay:r,videoWidth:i,videoHeight:a,muted:o}=t,s={type:`html5`,isLive:this.isLive(),version:this.getPlayerVersion()??`html5`,streamType:this.getStreamType(),streamUrl:this.getStreamURL(),duration:n,autoplay:r,currentVideoData:{height:a,width:i,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},videoWindowWidth:t.clientWidth,videoWindowHeight:t.clientHeight,muted:o};this.needsFirstPlayIntent_||this.eventCallback(e.METADATA_LOADED,s)}),this.listenToMediaElementEvent(`canplay`,()=>{if(this.playbackReadySet_)return;this.playbackReadySet_=!0;let{duration:n,autoplay:r,videoWidth:i,videoHeight:a,muted:o}=t,s={type:`html5`,isLive:this.isLive(),version:this.getPlayerVersion()??`html5`,streamType:this.getStreamType(),streamUrl:this.getStreamURL(),duration:n,autoplay:r,playerSoftware:this.playerSoftwareName,videoWindowWidth:t.clientWidth,videoWindowHeight:t.clientHeight,currentVideoData:{height:a,width:i,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},muted:o};this.eventCallback(e.SOURCE_LOADED,s)}),this.listenToMediaElementEvent(`emptied`,()=>{this.sourceSwitching_=!0}),this.listenToMediaElementEvent(`play`,()=>{let{currentTime:n,videoWidth:r,videoHeight:i}=t;this.needsFirstPlayIntent_=!1,this.eventCallback(e.PLAY,{currentVideoData:{height:i,width:r,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},currentTime:n})}),this.listenToMediaElementEvent(`pause`,()=>{this.onPaused()}),this.listenToMediaElementEvent(`playing`,()=>{let{currentTime:n,videoWidth:r,videoHeight:i}=t;this.isPaused_=!1,!this.needsFirstPlayIntent_&&(this.sourceSwitching_||this.eventCallback(e.TIMECHANGED,{currentVideoData:{height:i,width:r,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},currentTime:n}))}),this.listenToMediaElementEvent(`error`,()=>{let{error:n}=t;this.eventCallback(e.ERROR,{currentTime:this.lastKnownCurrentTime_,code:n?.code,message:n?.message})}),this.listenToMediaElementEvent(`volumechange`,()=>{let{muted:n,currentTime:r}=t;n?this.eventCallback(e.MUTE,{currentTime:r}):this.eventCallback(e.UN_MUTE,{currentTime:r})}),this.listenToMediaElementEvent(`seeking`,()=>{let{currentTime:n,videoWidth:r,videoHeight:i}=t;this.eventCallback(e.SEEK,{currentVideoData:{height:i,width:r,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},currentTime:n,droppedFrames:0})}),this.listenToMediaElementEvent(`seeked`,()=>{let{currentTime:n,videoWidth:r,videoHeight:i}=t;this.bufferingTimeout_&&clearTimeout(this.bufferingTimeout_),this.eventCallback(e.SEEKED,{currentVideoData:{height:i,width:r,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},currentTime:n,droppedFrames:0})}),this.listenToMediaElementEvent(`ended`,()=>{let{currentTime:n,videoWidth:r,videoHeight:i}=t;this.eventCallback(e.END,{currentVideoData:{height:i,width:r,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},currentTime:n})}),this.listenToMediaElementEvent(`timeupdate`,()=>{let{currentTime:n,videoHeight:r,videoWidth:i}=t;this.isBuffering_=!1,n>0&&(this.lastKnownCurrentTime_=n,this.sourceSwitching_=!1),!this.needsFirstPlayIntent_&&(!this.isPaused_&&!this.sourceSwitching_&&this.eventCallback(e.TIMECHANGED,{currentVideoData:{height:r,width:i,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},currentTime:n}),this.checkQualityLevelAttributes(),this.checkPlayheadProgress(),this.previousMediaTime_=n)}),this.listenToMediaElementEvent(`stalled`,()=>{}),this.listenToMediaElementEvent(`waiting`,()=>{this.onBuffering()}))}listenToMediaElementEvent(e,t){if(!this.mediaEl)throw Error(`No media attached`);let n=t.bind(this);this.mediaElEventHandlers.push({event:e,handler:n}),this.mediaEl.addEventListener(e,n,!1)}unregisterMediaElement(){if(!this.mediaEl)throw Error(`No media attached`);for(let{event:e,handler:t}of this.mediaElEventHandlers)this.mediaEl.removeEventListener(e,t,!1);this.resetMedia()}onMaybeReady(){if(!this.needsReadyEvent_||!this.mediaEl)return;this.needsReadyEvent_=!1;let{duration:t,autoplay:n,videoWidth:r,videoHeight:i,muted:a,preload:o}=this.mediaEl,s=this.getStreamURL(),c=o!==`none`,l={type:`html5`,isLive:this.isLive(),version:this.getPlayerVersion()??`html5`,streamType:this.getStreamType(),streamUrl:s,duration:t,autoplay:n,preload:c,playerSoftware:this.playerSoftwareName,currentVideoData:{height:i,width:r,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},videoWindowWidth:this.mediaEl.clientWidth,videoWindowHeight:this.mediaEl.clientHeight,muted:a};this.stateMachine.updateMetadata(l),this.eventCallback(e.READY,l)}onBuffering(){let{currentTime:t}=this.mediaEl;this.isBuffering_||this.isPaused_||(this.eventCallback(e.START_BUFFERING,{currentTime:t}),this.isBuffering_=!0)}onPaused(){if(this.isPaused_)return;if(this.sourceSwitching_){this.isPaused_=!0;return}let{videoHeight:t,videoWidth:n}=this.mediaEl,r=this.lastKnownCurrentTime_>0?this.lastKnownCurrentTime_:this.mediaEl.currentTime??0;this.eventCallback(e.PAUSE,{currentVideoData:{height:t,width:n,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},currentTime:r}),this.isPaused_=!0}checkPlayheadProgress(){let e=this.mediaEl;e.paused&&this.onPaused(),this.bufferingTimeout_&&clearTimeout(this.bufferingTimeout_),this.bufferingTimeout_=setTimeout(()=>{(e.paused||e.ended)&&!this.isBuffering_||e.currentTime-(this.previousMediaTime_??e.currentTime)<m&&this.onBuffering()},m)}checkQualityLevelAttributes(t=!1){let n=this.mediaEl,r=this.getCurrentQualityLevelInfo();if(!r)return;let{bitrate:i,width:a,height:o,videoCodec:s,audioCodec:c}=r,l=this.isLive();if(l!==this.isLive_&&(this.isLive_=l,t||this.stateMachine.updateMetadata({isLive:l})),this.audioCodec_=c??``,this.videoCodec_=s??``,this.analyticsBitrate_!==i){let r={width:a,height:o,bitrate:i,videoCodec:s,audioCodec:c,currentTime:n.currentTime};t||this.eventCallback(e.VIDEO_CHANGE,r),this.analyticsBitrate_=i??-1}}};export{h as HTML5Adapter,o as t};
9
+ import{t as e}from"./Events-D5KYZXXC.mjs";import{t}from"./Players-C89XH3yK.mjs";const n=`video/mp4`,r=`video/webm`,i=`application/x-mpegURL`,a=`application/dash+xml`,o={MP4:n,WEBM:r,HLS:i,DASH:a};function s(e){return e=e.toLowerCase(),e.endsWith(`.m3u8`)?i:e.endsWith(`.mp4`)||e.endsWith(`.m4v`)||e.endsWith(`.m4a`)?n:e.endsWith(`.webm`)?r:e.endsWith(`.mpd`)?a:null}const{MP4:c,WEBM:l,HLS:u,DASH:d}=o,f={[c]:`mp4`,[l]:`webm`,[u]:`hls`,[d]:`dash`};function p(e){return f[e]}const m=1e3;var h=class{constructor(e,n,r,i=null){this.lastKnownCurrentTime_=0,this.sourceSwitching_=!1,this.eventCallback=n,this.playerSoftwareName=i??t.HTML,this.stateMachine=r,this.mediaEl=e,this.mediaElEventHandlers=[],this.analyticsBitrate_=-1,this.audioCodec_=``,this.videoCodec_=``,this.bufferingTimeout_=null,this.isBuffering_=!1,this.isLive_=!1,this.isPaused_=!1,this.previousMediaTime_=null,this.needsReadyEvent_=!0,this.needsFirstPlayIntent_=!0,this.mediaElementSet_=!1,this.playbackReadySet_=!1,e&&this.setMediaElement()}getCurrentQualityLevelInfo(){return null}isLive(){return!1}getMIMEType(){let e=this.mediaEl;if(!e)return null;let t=e.src||e.querySelector(`source`)?.src||null;return t?s(t):null}getStreamType(){return p(this.getMIMEType()??``)}getPlayerVersion(){return null}getStreamURL(){let e=this.mediaEl;return e&&(e.src||e.querySelector(`source`)?.src)||null}destroy(){this.mediaEl&&this.unregisterMediaElement()}setMediaElement(e=null){if(e&&this.mediaEl&&(this.unregisterMediaElement(),this.mediaElementSet_=!1),e&&(this.mediaEl=e),!this.mediaEl)throw Error(`No media element owned`);if(this.mediaElementSet_)throw Error(`Media element already set (only call this once)`);this.mediaElementSet_=!0,this.registerMediaElement(),this.onMaybeReady()}resetMedia(){this.mediaEl=null,this.mediaElEventHandlers=[]}registerMediaElement(){let t=this.mediaEl;t&&(this.listenToMediaElementEvent(`loadedmetadata`,()=>{if(t.readyState!==1)return;this.checkQualityLevelAttributes(!0);let{duration:n,autoplay:r,videoWidth:i,videoHeight:a,muted:o}=t,s={type:`html5`,isLive:this.isLive(),version:this.getPlayerVersion()??`html5`,streamType:this.getStreamType(),streamUrl:this.getStreamURL(),duration:n,autoplay:r,currentVideoData:{height:a,width:i,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},videoWindowWidth:t.clientWidth,videoWindowHeight:t.clientHeight,muted:o};this.needsFirstPlayIntent_||this.eventCallback(e.METADATA_LOADED,s)}),this.listenToMediaElementEvent(`canplay`,()=>{if(this.playbackReadySet_)return;this.playbackReadySet_=!0;let{duration:n,autoplay:r,videoWidth:i,videoHeight:a,muted:o}=t,s={type:`html5`,isLive:this.isLive(),version:this.getPlayerVersion()??`html5`,streamType:this.getStreamType(),streamUrl:this.getStreamURL(),duration:n,autoplay:r,playerSoftware:this.playerSoftwareName,videoWindowWidth:t.clientWidth,videoWindowHeight:t.clientHeight,currentVideoData:{height:a,width:i,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},muted:o};this.eventCallback(e.SOURCE_LOADED,s)}),this.listenToMediaElementEvent(`emptied`,()=>{this.sourceSwitching_=!0}),this.listenToMediaElementEvent(`play`,()=>{let{currentTime:n,videoWidth:r,videoHeight:i}=t;this.needsFirstPlayIntent_=!1,this.eventCallback(e.PLAY,{currentVideoData:{height:i,width:r,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},currentTime:n})}),this.listenToMediaElementEvent(`pause`,()=>{this.onPaused()}),this.listenToMediaElementEvent(`playing`,()=>{let{currentTime:n,videoWidth:r,videoHeight:i}=t;this.isPaused_=!1,!this.needsFirstPlayIntent_&&(this.sourceSwitching_||this.eventCallback(e.TIMECHANGED,{currentVideoData:{height:i,width:r,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},currentTime:n}))}),this.listenToMediaElementEvent(`error`,()=>{let{error:n}=t;this.eventCallback(e.ERROR,{currentTime:this.lastKnownCurrentTime_,code:n?.code,message:n?.message})}),this.listenToMediaElementEvent(`volumechange`,()=>{let{muted:n,currentTime:r}=t;n?this.eventCallback(e.MUTE,{currentTime:r}):this.eventCallback(e.UN_MUTE,{currentTime:r})}),this.listenToMediaElementEvent(`seeking`,()=>{let{currentTime:n,videoWidth:r,videoHeight:i}=t;this.eventCallback(e.SEEK,{currentVideoData:{height:i,width:r,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},currentTime:n,droppedFrames:0})}),this.listenToMediaElementEvent(`seeked`,()=>{let{currentTime:n,videoWidth:r,videoHeight:i}=t;this.bufferingTimeout_&&clearTimeout(this.bufferingTimeout_),this.eventCallback(e.SEEKED,{currentVideoData:{height:i,width:r,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},currentTime:n,droppedFrames:0})}),this.listenToMediaElementEvent(`ended`,()=>{let{currentTime:n,videoWidth:r,videoHeight:i}=t;this.eventCallback(e.END,{currentVideoData:{height:i,width:r,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},currentTime:n})}),this.listenToMediaElementEvent(`timeupdate`,()=>{let{currentTime:n,videoHeight:r,videoWidth:i}=t;this.isBuffering_=!1,n>0&&(this.lastKnownCurrentTime_=n,this.sourceSwitching_=!1),!this.needsFirstPlayIntent_&&(!this.isPaused_&&!this.sourceSwitching_&&this.eventCallback(e.TIMECHANGED,{currentVideoData:{height:r,width:i,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},currentTime:n}),this.checkQualityLevelAttributes(),this.checkPlayheadProgress(),this.previousMediaTime_=n)}),this.listenToMediaElementEvent(`stalled`,()=>{}),this.listenToMediaElementEvent(`waiting`,()=>{this.onBuffering()}))}listenToMediaElementEvent(e,t){if(!this.mediaEl)throw Error(`No media attached`);let n=t.bind(this);this.mediaElEventHandlers.push({event:e,handler:n}),this.mediaEl.addEventListener(e,n,!1)}unregisterMediaElement(){if(!this.mediaEl)throw Error(`No media attached`);for(let{event:e,handler:t}of this.mediaElEventHandlers)this.mediaEl.removeEventListener(e,t,!1);this.resetMedia()}onMaybeReady(){if(!this.needsReadyEvent_||!this.mediaEl)return;this.needsReadyEvent_=!1;let{duration:t,autoplay:n,videoWidth:r,videoHeight:i,muted:a,preload:o}=this.mediaEl,s=this.getStreamURL(),c=o!==`none`,l={type:`html5`,isLive:this.isLive(),version:this.getPlayerVersion()??`html5`,streamType:this.getStreamType(),streamUrl:s,duration:t,autoplay:n,preload:c,playerSoftware:this.playerSoftwareName,currentVideoData:{height:i,width:r,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},videoWindowWidth:this.mediaEl.clientWidth,videoWindowHeight:this.mediaEl.clientHeight,muted:a};this.stateMachine.updateMetadata(l),this.eventCallback(e.READY,l)}onBuffering(){let{currentTime:t}=this.mediaEl;this.isBuffering_||this.isPaused_||(this.eventCallback(e.START_BUFFERING,{currentTime:t}),this.isBuffering_=!0)}onPaused(){if(this.isPaused_)return;if(this.sourceSwitching_){this.isPaused_=!0;return}let{videoHeight:t,videoWidth:n}=this.mediaEl,r=this.lastKnownCurrentTime_>0?this.lastKnownCurrentTime_:this.mediaEl.currentTime??0;this.eventCallback(e.PAUSE,{currentVideoData:{height:t,width:n,bitrate:this.analyticsBitrate_,audioCodec:this.audioCodec_,videoCodec:this.videoCodec_},currentTime:r}),this.isPaused_=!0}checkPlayheadProgress(){let e=this.mediaEl;e.paused&&this.onPaused(),this.bufferingTimeout_&&clearTimeout(this.bufferingTimeout_),this.bufferingTimeout_=setTimeout(()=>{(e.paused||e.ended)&&!this.isBuffering_||e.currentTime-(this.previousMediaTime_??e.currentTime)<m&&this.onBuffering()},m)}checkQualityLevelAttributes(t=!1){let n=this.mediaEl,r=this.getCurrentQualityLevelInfo();if(!r)return;let{bitrate:i,width:a,height:o,videoCodec:s,audioCodec:c}=r,l=this.isLive();if(l!==this.isLive_&&(this.isLive_=l,t||this.stateMachine.updateMetadata({isLive:l})),this.audioCodec_=c??``,this.videoCodec_=s??``,this.analyticsBitrate_!==i){let r={width:a,height:o,bitrate:i,videoCodec:s,audioCodec:c,currentTime:n.currentTime};t||this.eventCallback(e.VIDEO_CHANGE,r),this.analyticsBitrate_=i??-1}}};export{h as HTML5Adapter,o as t};
@@ -4,6 +4,6 @@
4
4
  // This source code and its use and distribution, is subject to the terms
5
5
  // and conditions of the applicable license agreement.
6
6
 
7
- // @gumlet/insights-js-core version 2.1.2
7
+ // @gumlet/insights-js-core version 2.1.4
8
8
 
9
- import{t as e}from"./Events-0c7mGtu4.mjs";import{t}from"./Players-CDWpB8LO.mjs";import{HTML5Adapter as n,t as r}from"./HTML5Adapter-BsJ_q8no.mjs";var i=class extends n{constructor(e,n,r){super(null,n,r,t.HLSJS),this.hls=e,this.playerSoftwareName=t.HLSJS,this.boundOnMediaAttaching=this.onMediaAttaching.bind(this),this.boundOnMediaDetaching=this.onMediaDetaching.bind(this),this.boundOnManifestLoading=this.onManifestLoading.bind(this),this.hlsErrorHandler=(e,t)=>this.onError(t),this.resetMedia(),this.registerHlsEvents()}getCurrentQualityLevelInfo(){let e=this.hls,t=e.levels?.[e.currentLevel];if(!t)return null;let n=t.attrs,r=n.BANDWIDTH?parseInt(n.BANDWIDTH,10):0,i=n.RESOLUTION?.width?parseInt(n.RESOLUTION.width,10):0,a=n.RESOLUTION?.height?parseInt(n.RESOLUTION.height,10):0,o=null,s=null;if(n.CODECS){let e=n.CODECS.split(`,`);s=e[0]??null,o=e.length>1?e[1]:null}return{bitrate:r,width:i,height:a,audioCodec:o,videoCodec:s}}isLive(){let e=this.hls;return e.currentLevel<0?!1:!!(e.levels?.[e.currentLevel])?.details?.live}getPlayerVersion(){return Hls.version}getMIMEType(){return r.HLS}getStreamURL(){return this.hls.url??null}destroy(){let e=this.hls;e.off(Hls.Events.MEDIA_ATTACHING,this.boundOnMediaAttaching),e.off(Hls.Events.MEDIA_DETACHING,this.boundOnMediaDetaching),e.off(Hls.Events.MANIFEST_LOADING,this.boundOnManifestLoading),e.off(Hls.Events.ERROR,this.hlsErrorHandler),super.destroy()}registerHlsEvents(){let e=this.hls;if(!Hls)throw Error(`Hls.js is not installed (must be loaded before analytics module)`);e.on(Hls.Events.MEDIA_ATTACHING,this.boundOnMediaAttaching),e.on(Hls.Events.MEDIA_DETACHING,this.boundOnMediaDetaching),e.on(Hls.Events.MANIFEST_LOADING,this.boundOnManifestLoading),e.on(Hls.Events.ERROR,this.hlsErrorHandler),e.media&&this.onMediaAttaching(),e.url&&this.onManifestLoading()}onMediaAttaching(){this.mediaEl||(this.mediaEl=this.hls.media,this.registerMediaElement(),this.onMaybeReady())}onMediaDetaching(){this.unregisterMediaElement()}onManifestLoading(){this.onMaybeReady()}onError(t){let n=t,r=this.lastKnownCurrentTime_>0?this.lastKnownCurrentTime_:this.mediaEl?.currentTime??0;n?.fatal===!0&&n?.details===`internalException`&&console.error(t),this.eventCallback(e.ERROR,{currentTime:r,code:n?.type,message:JSON.stringify({details:n?.details,fatal:n?.fatal,type:n?.type,fragment_url:n?.url,error:{message:n?.error?.message,stack:n?.error?.stack},extra:{networkDetails:{status:n?.networkDetails?.status,statusText:n?.networkDetails?.statusText,url:n?.networkDetails?.url,responseHeaders:n?.networkDetails?.responseHeaders,responseText:n?.networkDetails?.responseText,responseURL:n?.networkDetails?.responseURL,data:n?.networkDetails?.data}}})})}};export{i as HlsjsAdapter};
9
+ import{t as e}from"./Events-D5KYZXXC.mjs";import{t}from"./Players-C89XH3yK.mjs";import{HTML5Adapter as n,t as r}from"./HTML5Adapter-Cr6SpCtZ.mjs";var i=class extends n{constructor(e,n,r){super(null,n,r,t.HLSJS),this.hls=e,this.playerSoftwareName=t.HLSJS,this.boundOnMediaAttaching=this.onMediaAttaching.bind(this),this.boundOnMediaDetaching=this.onMediaDetaching.bind(this),this.boundOnManifestLoading=this.onManifestLoading.bind(this),this.hlsErrorHandler=(e,t)=>this.onError(t),this.resetMedia(),this.registerHlsEvents()}getCurrentQualityLevelInfo(){let e=this.hls,t=e.levels?.[e.currentLevel];if(!t)return null;let n=t.attrs,r=n.BANDWIDTH?parseInt(n.BANDWIDTH,10):0,i=n.RESOLUTION?.width?parseInt(n.RESOLUTION.width,10):0,a=n.RESOLUTION?.height?parseInt(n.RESOLUTION.height,10):0,o=null,s=null;if(n.CODECS){let e=n.CODECS.split(`,`);s=e[0]??null,o=e.length>1?e[1]:null}return{bitrate:r,width:i,height:a,audioCodec:o,videoCodec:s}}isLive(){let e=this.hls;return e.currentLevel<0?!1:!!(e.levels?.[e.currentLevel])?.details?.live}getPlayerVersion(){return Hls.version}getMIMEType(){return r.HLS}getStreamURL(){return this.hls.url??null}destroy(){let e=this.hls;e.off(Hls.Events.MEDIA_ATTACHING,this.boundOnMediaAttaching),e.off(Hls.Events.MEDIA_DETACHING,this.boundOnMediaDetaching),e.off(Hls.Events.MANIFEST_LOADING,this.boundOnManifestLoading),e.off(Hls.Events.ERROR,this.hlsErrorHandler),super.destroy()}registerHlsEvents(){let e=this.hls;if(!Hls)throw Error(`Hls.js is not installed (must be loaded before analytics module)`);e.on(Hls.Events.MEDIA_ATTACHING,this.boundOnMediaAttaching),e.on(Hls.Events.MEDIA_DETACHING,this.boundOnMediaDetaching),e.on(Hls.Events.MANIFEST_LOADING,this.boundOnManifestLoading),e.on(Hls.Events.ERROR,this.hlsErrorHandler),e.media&&this.onMediaAttaching(),e.url&&this.onManifestLoading()}onMediaAttaching(){this.mediaEl||(this.mediaEl=this.hls.media,this.registerMediaElement(),this.onMaybeReady())}onMediaDetaching(){this.unregisterMediaElement()}onManifestLoading(){this.onMaybeReady()}onError(t){let n=t,r=this.lastKnownCurrentTime_>0?this.lastKnownCurrentTime_:this.mediaEl?.currentTime??0;n?.fatal===!0&&n?.details===`internalException`&&console.error(t),this.eventCallback(e.ERROR,{currentTime:r,code:n?.type,message:JSON.stringify({details:n?.details,fatal:n?.fatal,type:n?.type,fragment_url:n?.url,error:{message:n?.error?.message,stack:n?.error?.stack},extra:{networkDetails:{status:n?.networkDetails?.status,statusText:n?.networkDetails?.statusText,url:n?.networkDetails?.url,responseHeaders:n?.networkDetails?.responseHeaders,responseText:n?.networkDetails?.responseText,responseURL:n?.networkDetails?.responseURL,data:n?.networkDetails?.data}}})})}};export{i as HlsjsAdapter};
@@ -4,6 +4,6 @@
4
4
  // This source code and its use and distribution, is subject to the terms
5
5
  // and conditions of the applicable license agreement.
6
6
 
7
- // @gumlet/insights-js-core version 2.1.2
7
+ // @gumlet/insights-js-core version 2.1.4
8
8
 
9
9
  const e=`urn:x-cast:com.gumlet.ingest.cast`,t=`https://ingest.gumlytics.com`,n=`https://ingest.gumlytics.com`.endsWith(`/`)?t:`${t}/`,r=new URL(`v2`,n).href.replace(/\/+$/,``),i=1e4,a=new class{constructor(e=!1){this.log=e=>{this.showLogs&&console.log(e)},this.error=e=>{this.showLogs&&console.error(e)},this.warning=e=>{this.showLogs&&console.warn(e)},this.showLogs=e}setLogging(e){this.showLogs=e}isLogging(){return this.showLogs}};export{e as a,i,t as n,r,a as t};
@@ -4,6 +4,6 @@
4
4
  // This source code and its use and distribution, is subject to the terms
5
5
  // and conditions of the applicable license agreement.
6
6
 
7
- // @gumlet/insights-js-core version 2.1.2
7
+ // @gumlet/insights-js-core version 2.1.4
8
8
 
9
9
  const e={JW:`jw`,RADIANT:`radiant`,HLSJS:`hlsjs`,SHAKA:`shaka`,HTML:`html5`,REACTNATIVEVIDEO:`react-native-video`};export{e as t};
@@ -4,6 +4,6 @@
4
4
  // This source code and its use and distribution, is subject to the terms
5
5
  // and conditions of the applicable license agreement.
6
6
 
7
- // @gumlet/insights-js-core version 2.1.2
7
+ // @gumlet/insights-js-core version 2.1.4
8
8
 
9
- import{t as e}from"./Events-0c7mGtu4.mjs";import{t}from"./Players-CDWpB8LO.mjs";import{HTML5Adapter as n,t as r}from"./HTML5Adapter-BsJ_q8no.mjs";var i=class extends n{constructor(n,r,i,a){if(super(a,r,i,t.SHAKA),typeof shaka>`u`)throw Error("`shaka` lib is not installed (must be loaded before analytics module)");this.shakaPlayer=n,this.playerSoftwareName=t.SHAKA,this.shakaErrorHandler=t=>{this.onGumletShakaError(t,this.eventCallback,this.mediaEl).catch(()=>{let t=this.lastKnownCurrentTime_>0?this.lastKnownCurrentTime_:this.mediaEl?.currentTime??0;this.eventCallback(e.ERROR,{currentTime:t,code:`error_handler_exception`,message:`Shaka error handler threw before firing callback`})})},this.registerShakaEvents()}getPlayerVersion(){return shaka.Player.version}isLive(){return this.shakaPlayer?.isLive()??!1}getMIMEType(){return this.shakaPlayer?.getManifestType?.()===`HLS`?r.HLS:r.DASH}getStreamURL(){return this.shakaPlayer?.getAssetUri()??null}getCurrentQualityLevelInfo(){let e=this.shakaPlayer.getVariantTracks().filter(e=>e.active).find(e=>e.videoCodec!==null||e.videoId!==null);return e?{bitrate:e.videoBandwidth??e.bandwidth??null,width:e.width??null,height:e.height??null,videoCodec:e.videoCodec??null,audioCodec:e.audioCodec??null}:null}destroy(){this.shakaPlayer.removeEventListener(`error`,this.shakaErrorHandler),super.destroy()}registerShakaEvents(){if(!this.shakaPlayer)throw Error(`Shaka player object is not defined`);this.shakaPlayer.addEventListener(`error`,this.shakaErrorHandler)}getEnumNameFromValue(e,t){if(!e||t==null)return null;for(let[n,r]of Object.entries(e))if(r===t)return n;return null}getShakaErrorCodeName(e){let t=globalThis.shaka?.util?.Error?.Code;return this.getEnumNameFromValue(t,e)}getShakaErrorCategoryName(e){let t=globalThis.shaka?.util?.Error?.Category;return this.getEnumNameFromValue(t,e)}getBufferedRanges(e){if(!e?.buffered)return[];let t=[];for(let n=0;n<e.buffered.length;n+=1)t.push({start:e.buffered.start(n),end:e.buffered.end(n)});return t}getPlaybackQuality(e){if(!e?.getVideoPlaybackQuality)return null;let t=e.getVideoPlaybackQuality();return{droppedVideoFrames:t.droppedVideoFrames,totalVideoFrames:t.totalVideoFrames,corruptedVideoFrames:t.corruptedVideoFrames}}getMediaElementState(e,t){return{readyState:e?.readyState??null,networkState:e?.networkState??null,currentSrc:e?.currentSrc??null,currentTime:e?.currentTime??t??null,paused:e?.paused??null,ended:e?.ended??null,seeking:e?.seeking??null,playbackRate:e?.playbackRate??null,muted:e?.muted??null,videoWidth:e?.videoWidth??null,videoHeight:e?.videoHeight??null}}getHtml5MediaError(e){let t=e?.error;return t?{code:t.code??null,message:t?.message??null}:null}getQualityLevelInfoFallback(){let e=this.shakaPlayer.getVariantTracks().find(e=>e.videoCodec!==null||e.videoId!==null);return e?{bitrate:e.videoBandwidth??e.bandwidth??null,width:e.width??null,height:e.height??null,videoCodec:e.videoCodec??null,audioCodec:e.audioCodec??null}:null}getExtraDataHint(e,t){if(!Array.isArray(e))return null;let n={item_count:e.length,item_types:e.map(e=>e===null?`null`:Array.isArray(e)?`array`:typeof e)};return t?.includes(`DECODE`)&&(n.decode_context={first:e[0]??null,second:e[1]??null}),n}async onGumletShakaError(t,n,r){let i=this.lastKnownCurrentTime_>0?this.lastKnownCurrentTime_:r?.currentTime??0,a=t;if(!a.detail){n(e.ERROR,{currentTime:i,code:`not_set_by_shaka`,message:`{}`});return}let o=a.detail,s=[];if(o.data)for(let e of o.data)s.push(e);let c=[],l=null,u=null,d=null;try{let e=[],t=this.shakaPlayer.getVariantTracks();if(t.forEach(t=>{e.push({width:t.width,height:t.height,bitrate:t.videoBandwidth??t.bandwidth,framerate:t.frameRate,contentType:`${t.mimeType}; codecs="${t.videoCodec}"`})}),navigator?.mediaCapabilities?.decodingInfo)for(let t of e)try{let e={type:`media-source`,video:{contentType:t.contentType,width:t.width??0,height:t.height??0,bitrate:t.bitrate??0,framerate:t.framerate??0},keySystemConfiguration:{keySystem:`com.widevine.alpha`,video:{contentType:t.contentType}}},n=await navigator.mediaCapabilities.decodingInfo(e);c.push({...n,keySystemAccess:n.keySystemAccess?.getConfiguration()})}catch{}l=this.getCurrentQualityLevelInfo(),l||(u=this.getQualityLevelInfoFallback()),d={manifest_type:this.shakaPlayer.getManifestType?.()??null,asset_uri:this.shakaPlayer.getAssetUri?.()??null,is_live:this.shakaPlayer.isLive?.()??null,player_version:this.getPlayerVersion(),variant_track_count:t.length}}catch{}let f=!o.severity||o.severity===2?e.ERROR:e.NON_FATAL_ERROR,p=o.category??o.v??null,m=this.getShakaErrorCodeName(o.code),h=this.getShakaErrorCategoryName(p);n(f,{currentTime:i,code:o.code,message:JSON.stringify({category:p,category_name:h,code:o.code,code_name:m,severity:o.severity,handled:o.handled,timestamp:a.timestamp,extra_data:s,extra_data_hint:this.getExtraDataHint(s,m),media_capabilities:c,selected_quality_info:l,selected_quality_info_fallback:u,html5_media_error:this.getHtml5MediaError(r),media_element_state:this.getMediaElementState(r,i),buffered_ranges:this.getBufferedRanges(r),playback_quality:this.getPlaybackQuality(r),shaka_runtime_context:d})})}};export{i as ShakaAdapter};
9
+ import{t as e}from"./Events-D5KYZXXC.mjs";import{t}from"./Players-C89XH3yK.mjs";import{HTML5Adapter as n,t as r}from"./HTML5Adapter-Cr6SpCtZ.mjs";var i=class extends n{constructor(n,r,i,a){if(super(a,r,i,t.SHAKA),typeof shaka>`u`)throw Error("`shaka` lib is not installed (must be loaded before analytics module)");this.shakaPlayer=n,this.playerSoftwareName=t.SHAKA,this.shakaErrorHandler=t=>{this.onGumletShakaError(t,this.eventCallback,this.mediaEl).catch(()=>{let t=this.lastKnownCurrentTime_>0?this.lastKnownCurrentTime_:this.mediaEl?.currentTime??0;this.eventCallback(e.ERROR,{currentTime:t,code:`error_handler_exception`,message:`Shaka error handler threw before firing callback`})})},this.registerShakaEvents()}getPlayerVersion(){return shaka.Player.version}isLive(){return this.shakaPlayer?.isLive()??!1}getMIMEType(){return this.shakaPlayer?.getManifestType?.()===`HLS`?r.HLS:r.DASH}getStreamURL(){return this.shakaPlayer?.getAssetUri()??null}getCurrentQualityLevelInfo(){let e=this.shakaPlayer.getVariantTracks().filter(e=>e.active).find(e=>e.videoCodec!==null||e.videoId!==null);return e?{bitrate:e.videoBandwidth??e.bandwidth??null,width:e.width??null,height:e.height??null,videoCodec:e.videoCodec??null,audioCodec:e.audioCodec??null}:null}destroy(){this.shakaPlayer.removeEventListener(`error`,this.shakaErrorHandler),super.destroy()}registerShakaEvents(){if(!this.shakaPlayer)throw Error(`Shaka player object is not defined`);this.shakaPlayer.addEventListener(`error`,this.shakaErrorHandler)}getEnumNameFromValue(e,t){if(!e||t==null)return null;for(let[n,r]of Object.entries(e))if(r===t)return n;return null}getShakaErrorCodeName(e){let t=globalThis.shaka?.util?.Error?.Code;return this.getEnumNameFromValue(t,e)}getShakaErrorCategoryName(e){let t=globalThis.shaka?.util?.Error?.Category;return this.getEnumNameFromValue(t,e)}getBufferedRanges(e){if(!e?.buffered)return[];let t=[];for(let n=0;n<e.buffered.length;n+=1)t.push({start:e.buffered.start(n),end:e.buffered.end(n)});return t}getPlaybackQuality(e){if(!e?.getVideoPlaybackQuality)return null;let t=e.getVideoPlaybackQuality();return{droppedVideoFrames:t.droppedVideoFrames,totalVideoFrames:t.totalVideoFrames,corruptedVideoFrames:t.corruptedVideoFrames}}getMediaElementState(e,t){return{readyState:e?.readyState??null,networkState:e?.networkState??null,currentSrc:e?.currentSrc??null,currentTime:e?.currentTime??t??null,paused:e?.paused??null,ended:e?.ended??null,seeking:e?.seeking??null,playbackRate:e?.playbackRate??null,muted:e?.muted??null,videoWidth:e?.videoWidth??null,videoHeight:e?.videoHeight??null}}getHtml5MediaError(e){let t=e?.error;return t?{code:t.code??null,message:t?.message??null}:null}getQualityLevelInfoFallback(){let e=this.shakaPlayer.getVariantTracks().find(e=>e.videoCodec!==null||e.videoId!==null);return e?{bitrate:e.videoBandwidth??e.bandwidth??null,width:e.width??null,height:e.height??null,videoCodec:e.videoCodec??null,audioCodec:e.audioCodec??null}:null}getExtraDataHint(e,t){if(!Array.isArray(e))return null;let n={item_count:e.length,item_types:e.map(e=>e===null?`null`:Array.isArray(e)?`array`:typeof e)};return t?.includes(`DECODE`)&&(n.decode_context={first:e[0]??null,second:e[1]??null}),n}async onGumletShakaError(t,n,r){let i=this.lastKnownCurrentTime_>0?this.lastKnownCurrentTime_:r?.currentTime??0,a=t;if(!a.detail){n(e.ERROR,{currentTime:i,code:`not_set_by_shaka`,message:`{}`});return}let o=a.detail,s=[];if(o.data)for(let e of o.data)s.push(e);let c=[],l=null,u=null,d=null;try{let e=[],t=this.shakaPlayer.getVariantTracks();if(t.forEach(t=>{e.push({width:t.width,height:t.height,bitrate:t.videoBandwidth??t.bandwidth,framerate:t.frameRate,contentType:`${t.mimeType}; codecs="${t.videoCodec}"`})}),navigator?.mediaCapabilities?.decodingInfo)for(let t of e)try{let e={type:`media-source`,video:{contentType:t.contentType,width:t.width??0,height:t.height??0,bitrate:t.bitrate??0,framerate:t.framerate??0},keySystemConfiguration:{keySystem:`com.widevine.alpha`,video:{contentType:t.contentType}}},n=await navigator.mediaCapabilities.decodingInfo(e);c.push({...n,keySystemAccess:n.keySystemAccess?.getConfiguration()})}catch{}l=this.getCurrentQualityLevelInfo(),l||(u=this.getQualityLevelInfoFallback()),d={manifest_type:this.shakaPlayer.getManifestType?.()??null,asset_uri:this.shakaPlayer.getAssetUri?.()??null,is_live:this.shakaPlayer.isLive?.()??null,player_version:this.getPlayerVersion(),variant_track_count:t.length}}catch{}let f=!o.severity||o.severity===2?e.ERROR:e.NON_FATAL_ERROR,p=o.category??o.v??null,m=this.getShakaErrorCodeName(o.code),h=this.getShakaErrorCategoryName(p);n(f,{currentTime:i,code:o.code,message:JSON.stringify({category:p,category_name:h,code:o.code,code_name:m,severity:o.severity,handled:o.handled,timestamp:a.timestamp,extra_data:s,extra_data_hint:this.getExtraDataHint(s,m),media_capabilities:c,selected_quality_info:l,selected_quality_info_fallback:u,html5_media_error:this.getHtml5MediaError(r),media_element_state:this.getMediaElementState(r,i),buffered_ranges:this.getBufferedRanges(r),playback_quality:this.getPlaybackQuality(r),shaka_runtime_context:d})})}};export{i as ShakaAdapter};