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