/*!
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
*/
import{inherits as e,createSuper as t,classCallCheck as a,defineProperty as i,assertThisInitialized as n,createClass as r}from"../../_virtual/_rollupPluginBabelHelpers.js";import{WAITING as s,PLAY as u,SEEKING as l}from"../../events.js";import o from"../../plugin/plugin.js";var f=/* @__PURE__ */function(){e(p,o);var f=t(p);function p(){var e;a(this,p);for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return e=f.call.apply(f,[this].concat(r)),i(n(e),"onGapJump",function(){var t=n(e),a=t.player,i=t.config;if(a.media.readyState!==HTMLMediaElement.HAVE_NOTHING){if(a.media.seeking){if(!e.seekingEventReceived)return}else e.seekingEventReceived=!1;if(!a.media.paused||0===a.media.currentTime||!e.hasPlayed){var r=a.media.buffered,s=i.smallGapLimit||.5,u=i.gapDetectionThreshold||.3,l=a.media.currentTime,o=e._getIndex(r,l,u);if(null!==o&&0!==o){console.log("GapJump  bufferRange ",r.start(o),r.end(o));var f=r.start(o)+.1;if(!(f>a.media.duration)){var d=f-l,m=d<=s;d<p.BROWSER_GAP_TOLERANCE||m&&(!1!==i.useGapJump&&(a.media.currentTime=e.isSafari?f+.1:f),e.player&&e.player.emit("detectGap"),console.log("gapJump gapIndex",o," isGapSamll:",m," currentTime:",a.media.currentTime," jumpSize:",l-a.media.currentTime),.08!==f&&a&&a.emit("log",{type:"oneevent",end_type:"gap",vid:a.config.vid,ext:{video_postion:Math.floor(1e3*f)}}))}}}}}),e}return r(p,[{key:"afterCreate",value:function(){var e=this;!1!==this.config.useGapJump&&(this.hasPlayed=!1,this.seekingEventReceived=!1,this.isSafari=/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),this.on(s,this.onGapJump),this.on(u,function(){e.hasPlayed=!0}),this.on(l,function(){e.seekingEventReceived=!0}))}},{key:"_getIndex",value:function(e,t,a){if(!e||!e.length)return null;if(1===e.length&&e.end(0)-e.start(0)<1e-6)return null;for(var i=this._getBuffered(e),n=null,r=0;r<i.length;r++){if(i[r].start>t&&(0===r||i[r-1].end-t<=a)){n=r;break}}return n}},{key:"_getBuffered",value:function(e){if(!e)return[];for(var t=[],a=0;a<e.length;a++)t.push({start:e.start(a),end:e.end(a)});return t}}],[{key:"pluginName",get:function(){return"gapJump"}},{key:"defaultConfig",get:function(){return{useGapJump:!1,smallGapLimit:.5,gapDetectionThreshold:.3}}}]),p}();f.BROWSER_GAP_TOLERANCE=.001;export{f as default};