/*!
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 t,createSuper as i,classCallCheck as e,defineProperty as s,assertThisInitialized as o,createClass as n}from"../../_virtual/_rollupPluginBabelHelpers.js";import a from"../../utils/util.js";import r from"../../utils/sniffer.js";import{DURATION_CHANGE as h}from"../../events.js";import l from"../../plugin/plugin.js";import u from"./dotsApi.js";var d={dragmove:"onProgressMove",dragstart:"onProgressDragStart",dragend:"onProgressDragEnd",click:"onProgressClick",mouseover:"onProgressMouseOver",mouseenter:"onProgressMouseOver"},p=/* @__PURE__ */function(){t(v,l);var p=i(v);function v(t){var i;return e(this,v),i=p.call(this,t),s(o(i),"onMousemove",function(t){i.config.disable||(a.hasClass(t.target,"xg-spot-content")&&i.config.isHideThumbnailHover?i.player.plugins.progress.onMouseLeave(t):(i._state.f||a.hasClass(t.target,"xg-spot-content"))&&(a.event(t),t.stopPropagation()))}),s(o(i),"onMousedown",function(t){i.config.disable||(i._state.f||a.hasClass(t.target,"xg-spot-content"))&&(a.event(t),t.stopPropagation())}),s(o(i),"onMouseup",function(t){if(i.isDrag){var e=i.player.plugins.progress;e&&e.pos&&(e.onMouseUp(t),!e.pos.isEnter&&e.onMouseLeave(t))}}),s(o(i),"onDotMouseLeave",function(t){if(!i.config.disable){i._curDot.removeEventListener("mouseleave",i.onDotMouseLeave),i.blurDot(t.target),i._curDot=null;var e=i.player.plugins.progress;e&&e.enableBlur(),i.show()}}),s(o(i),"onProgressMouseOver",function(t,e){if(!i.config.disable&&a.hasClass(e.target,"xgplayer-spot")&&!i._curDot){i._curDot=e.target,i.focusDot(e.target),i._curDot.children.length>0&&i.hide();var s=i.player.plugins.progress;s&&s.disableBlur(),i._curDot.addEventListener("mouseleave",i.onDotMouseLeave)}}),i._ispots=[],i.videoPreview=null,i.videothumbnail=null,i.thumbnail=null,i.timeStr="",i._state={now:0,f:!1},i}return n(v,[{key:"beforeCreate",value:function(t){var i=t.player.plugins.progress;i&&(t.root=i.root)}},{key:"afterCreate",value:function(){var t=this;this._curDot=null,this.handlerSpotClick=this.hook("spotClick",function(i,e){e.seekTime&&t.player.seek(e.seekTime)}),this.transformTimeHook=this.hook("transformTime",function(i){t.setTimeContent(a.format(i))}),u(this),this.on(h,function(){t.show()}),this.config.disable&&this.disable(),this.extTextRoot=this.find(".xg-spot-ext-text")}},{key:"setConfig",value:function(t){var i=this;t&&Object.keys(t).map(function(e){i.config[e]=t[e]})}},{key:"onPluginsReady",value:function(){this.player.plugins.progress&&(this.previewLine=this.find(".xg-spot-line"),this.timePoint=this.find(".xgplayer-progress-point"),this.timeText=this.find(".xg-spot-time"),this.tipText=this.find(".spot-inner-text"),this._hasThumnail=!1,this.registerThumbnail(),this.bindEvents())}},{key:"bindEvents",value:function(){var t=this,i=this.player.plugins.progress;if(i&&(Object.keys(d).map(function(e){t[d[e]]=t[d[e]].bind(t),i.addCallBack(e,t[d[e]])}),"mobile"!==r.device)){this.bind(".xg-spot-info","mousemove",this.onMousemove),this.bind(".xg-spot-info","mousedown",this.onMousedown),this.bind(".xg-spot-info","mouseup",this.onMouseup);var e=this.hook("previewClick",function(){});this.handlerPreviewClick=function(s){s.stopPropagation(),e(parseInt(1e3*t._state.now,10)/1e3,s),i&&i.onMouseUp(s)},this.bind(".xg-spot-content","mouseup",this.handlerPreviewClick)}}},{key:"onProgressMove",value:function(t,i){!this.config.disable&&this.player.duration&&this.updatePosition(t.offset,t.width,t.currentTime,t.e)}},{key:"onProgressDragStart",value:function(t){!this.config.disable&&this.player.duration&&(this.isDrag=!0,this.videoPreview&&a.addClass(this.videoPreview,"show"))}},{key:"onProgressDragEnd",value:function(t){!this.config.disable&&this.player.duration&&(this.isDrag=!1,this.videoPreview&&a.removeClass(this.videoPreview,"show"))}},{key:"onProgressClick",value:function(t,i){this.config.disable||a.hasClass(i.target,"xgplayer-spot")&&(i.stopPropagation(),i.preventDefault(),["time","id","text"].map(function(e){t[e]=i.target.getAttribute("data-".concat(e))}),t.time&&(t.time=Number(t.time)),this.handlerSpotClick(i,t))}},{key:"updateLinePos",value:function(t,i){var e=this.root,s=this.previewLine,o=this.player,n=this.config,a="flex"===o.controls.mode,r=e.getBoundingClientRect().width;if(r||!this._hasThumnail){var h,l=t-(r=this._hasThumnail&&r<n.width?n.width:r)/2;l<0&&!a?(l=0,h=t-r/2):l>i-r&&!a?(h=l-(i-r),l=i-r):h=0,void 0!==h&&(s.style.transform="translateX(".concat(h.toFixed(2),"px)")),e.style.transform="translateX(".concat(l.toFixed(2),"px) translateZ(0)")}}},{key:"updateTimeText",value:function(t){var i=this.timeText,e=this.timePoint;i.innerHTML=t,!this.thumbnail&&(e.innerHTML=t)}},{key:"updatePosition",value:function(t,i,e,s){var o=this.root,n=this.config,r=this._state;if(o){r.now=e,this.transformTimeHook(e);var h=this.timeStr;s&&s.target&&a.hasClass(s.target,"xgplayer-spot")?(this.showTips(s.target.getAttribute("data-text"),!1,h),this.focusDot(s.target),r.f=!0,n.isFocusDots&&r.f&&(r.now=parseInt(s.target.getAttribute("data-time"),10))):n.defaultText?(r.f=!1,this.showTips(n.defaultText,!0,h)):(r.f=!1,this.hideTips("")),this.updateTimeText(h),this.updateThumbnails(r.now),this.updateLinePos(t,i)}}},{key:"setTimeContent",value:function(t){this.timeStr=t}},{key:"updateThumbnails",value:function(t){var i=this.player,e=this.videoPreview,s=this.config,o=i.plugins.thumbnail;if(o&&o.usable){this.thumbnail&&o.update(this.thumbnail,t,s.width,s.height);var n=e&&e.getBoundingClientRect();this.videothumbnail&&o.update(this.videothumbnail,t,n.width,n.height)}}},{key:"registerThumbnail",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("mobile"!==r.device){var i=this.player,e=this.config,s=i.getPlugin("thumbnail");if(s&&s.setConfig(t),s&&s.usable&&e.isShowThumbnail){a.removeClass(this.root,"short-line no-thumbnail"),"short"===e.mode&&a.addClass(this.root,"short-line"),this._hasThumnail=!0;var o=this.find(".xg-spot-thumbnail");this.thumbnail=s.createThumbnail(o,"progress-thumbnail"),e.isShowCoverPreview&&(this.videoPreview=a.createDom("xg-video-preview","",{},"xgvideo-preview"),i.root.appendChild(this.videoPreview),this.videothumbnail=s.createThumbnail(this.videoPreview,"xgvideo-thumbnail")),this.updateThumbnails(0)}else a.addClass(this.root,"short-line no-thumbnail")}}},{key:"calcuPosition",value:function(t,i){var e=this.player.plugins.progress,s=this.player,o=e.root.getBoundingClientRect().width,n=s.duration/o*6;return t+i>s.duration&&(i=s.duration-t),s.duration,s.duration,{left:t/s.duration*100,width:i/s.duration*100,isMini:i<n}}},{key:"showDot",value:function(t){var i=this.findDot(t);if(i){var e=this.root.getBoundingClientRect().width,s=i.time/this.player.duration*e;this.updatePosition(s,e,i.time)}}},{key:"focusDot",value:function(t,i){t&&(i||(i=t.getAttribute("data-id")),a.addClass(t,"active"),this._activeDotId=i)}},{key:"blurDot",value:function(t){if(!t){var i=this._activeDotId;t=this.getDotDom(i)}t&&(a.removeClass(t,"active"),this._activeDotId=null)}},{key:"showTips",value:function(t,i){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";a.addClass(this.root,"no-timepoint"),t&&(a.addClass(this.find(".xg-spot-content"),"show-text"),i&&"production"===this.config.mode?(a.addClass(this.root,"product"),this.tipText.textContent=t):(a.removeClass(this.root,"product"),this.tipText.textContent=this._hasThumnail?t:"".concat(e," ").concat(t)))}},{key:"hideTips",value:function(){a.removeClass(this.root,"no-timepoint"),this.tipText.textContent="",a.removeClass(this.find(".xg-spot-content"),"show-text"),a.removeClass(this.root,"product")}},{key:"hide",value:function(){a.addClass(this.root,"hide")}},{key:"show",value:function(t){a.removeClass(this.root,"hide")}},{key:"enable",value:function(){var t=this.config,i=this.playerConfig;this.config.disable=!1,this.show(),!this.thumbnail&&t.isShowThumbnail&&this.registerThumbnail(i.thumbnail||{})}},{key:"disable",value:function(){this.config.disable=!0,this.hide()}},{key:"destroy",value:function(){var t=this,i=this.player.plugins.progress;i&&Object.keys(d).map(function(e){i.removeCallBack(e,t[d[e]])}),this.videothumbnail=null,this.thumbnail=null,this.videoPreview&&this.player.root.removeChild(this.videoPreview),this.unbind(".xg-spot-info","mousemove",this.onMousemove),this.unbind(".xg-spot-info","mousedown",this.onMousedown),this.unbind(".xg-spot-info","mouseup",this.onMouseup),this.unbind(".xg-spot-content","mouseup",this.handlerPreviewClick)}},{key:"render",value:function(){return"mobile"===r.device||"mobile"===this.playerConfig.isMobileSimulateMode?"":'<div class="xg-spot-info hide '.concat("short"===this.config.mode?"short-line":"",'">\n      <div class="xg-spot-content">\n        <div class="xg-spot-thumbnail">\n          <span class="xg-spot-time"></span>\n        </div>\n        <div class="xg-spot-text"><span class="spot-inner-text"></span></div>\n      </div>\n      <div class="xgplayer-progress-point">00:00</div>\n      <div class="xg-spot-ext-text"></div>\n      <div class="xg-spot-line"></div>\n    </div>')}}],[{key:"pluginName",get:function(){return"progresspreview"}},{key:"defaultConfig",get:function(){return{index:1,miniWidth:6,ispots:[],defaultText:"",isFocusDots:!0,isHideThumbnailHover:!0,isShowThumbnail:!0,isShowCoverPreview:!1,mode:"",disable:!1,width:160,height:90}}}]),v}();export{p as default};