/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("../../events.js");var i=function(i){e.inherits(s,i);var r=e.createSuper(s);function s(){return e.classCallCheck(this,s),r.apply(this,arguments)}return e.createClass(s,[{key:"afterCreate",value:function(){var e=this,i=this.player,r=this.config,s=i.media||i.video;(this.timer=null,this._lastDecodedFrames=0,this._currentStuckCount=0,this._lastCheckPoint=null,this._payload=[],r.disabled)||s.getVideoPlaybackQuality&&(this.on(t.PLAY,function(){e._startTick()}),this.on(t.PAUSE,function(){e._stopTick()}),this.on(t.ENDED,function(){e._stopTick()}),this.on(t.EMPTIED,function(){e._stopTick()}))}},{key:"_startTick",value:function(){var e=this;this._stopTick(),this._timer=setTimeout(function(){e._checkDecodeFPS(),e._startTick()},this.config.tick)}},{key:"_stopTick",value:function(){clearTimeout(this._timer),this._timer=null}},{key:"_checkBuffer",value:function(e,t){for(var i=!1,r=[],s=0;s<t.length;s++){var a=t.start(s),u=t.end(s);if(r.push({start:a,end:u}),a<=e&&e<=u-1){i=!0;break}}return{enoughBuffer:i,buffers:r}}},{key:"_checkStuck",value:function(e,i,r,s){var a=this.player.media||this.player.video,u=document.hidden,n=a.paused,o=a.readyState,c=a.currentTime,l=a.buffered;if(!(u||n||o<4)){var h=this._checkBuffer(c,l),d=h.enoughBuffer,f=h.buffers;d&&(e<=this.config.reportFrame?(this._currentStuckCount++,this._payload.push({currentTime:c,buffers:f,curDecodedFrames:e,totalVideoFrames:i,droppedVideoFrames:r,checkInterval:s}),this._currentStuckCount>=this.config.stuckCount&&(this.emit(t.FPS_STUCK,this._payload),this._reset())):this._reset())}}},{key:"_reset",value:function(){this._payload=[],this._currentStuckCount=0}},{key:"_checkDecodeFPS",value:function(){var e=this.player.media||this.player.video;if(e){var t=e.getVideoPlaybackQuality(),i=t.totalVideoFrames,r=t.droppedVideoFrames,s=performance.now();if(i&&this._lastCheckPoint){var a=i-this._lastDecodedFrames,u=s-this._lastCheckPoint;this._checkStuck(a,i,r,u)}this._lastDecodedFrames=i,this._lastCheckPoint=s}}},{key:"destroy",value:function(){this._stopTick()}}],[{key:"pluginName",get:function(){return"FpsDetect"}},{key:"defaultConfig",get:function(){return{disabled:!1,tick:1e3,stuckCount:3,reportFrame:0}}}]),s}(require("../../plugin/plugin.js").default);exports.default=i;