/*!
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("../../utils/util.js"),i=require("../../events.js");require("../../../../../_virtual/delegate.js");var e={time:0,text:"",id:1,duration:1,color:"#fff",style:{},width:6,height:6};function s(t){Object.keys(e).map(function(i){void 0===t[i]&&(t[i]=e[i])})}var o={_updateDotDom:function(i,e){if(e){var s=this.calcuPosition(i.time,i.duration),o=i.style||{};o.left="".concat(s.left,"%"),o.width="".concat(s.width,"%"),e.setAttribute("data-text",i.text),e.setAttribute("data-time",i.time),s.isMini?t.default.addClass(e,"mini"):t.default.removeClass(e,"mini"),Object.keys(o).map(function(t){e.style[t]=o[t]})}},initDots:function(){var t=this;this._ispots.map(function(i){t.createDot(i,!1)}),this.ispotsInit=!0},createDot:function(i){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=this.player.plugins.progress;if(o&&(e&&(s(i),this._ispots.push(i)),this.ispotsInit||!e)){var n=this.calcuPosition(i.time,i.duration),a=i.style||{};a.left="".concat(n.left,"%"),a.width="".concat(n.width,"%");var r="xgspot_".concat(i.id," xgplayer-spot");n.isMini&&(r+=" mini");var p=i.template?'<div class="xgplayer-spot-pop">'.concat(i.template,"</div>"):"",l=t.default.createDom("xg-spot",p,{"data-text":i.text,"data-time":i.time,"data-id":i.id},r);Object.keys(a).map(function(t){l.style[t]=a[t]}),o.outer&&o.outer.appendChild(l),this.positionDot(l,i.id)}},findDot:function(t){if(this.player.plugins.progress){var i=this._ispots.filter(function(i,e){return i.id===t});return i.length>0?i[0]:null}},updateDot:function(t){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],e=this.player.plugins.progress;if(e){var s=this.findDot(t.id);if(s&&Object.keys(t).map(function(i){s[i]=t[i]}),this.ispotsInit){var o=e.find('xg-spot[data-id="'.concat(t.id,'"]'));o&&(this._updateDotDom(t,o),i&&this.showDot(t.id))}}},deleteDot:function(t){var i=this._ispots,e=this.player.plugins.progress;if(e){for(var s=[],o=0;o<i.length;o++)i[o].id===t&&s.push(o);for(var n=s.length-1;n>=0;n--)if(i.splice(s[n],1),this.ispotsInit){var a=e.find('xg-spot[data-id="'.concat(t,'"]'));a&&a.parentElement.removeChild(a)}}},deleteAllDots:function(){var t=this.player.plugins.progress;if(t)if(this.ispotsInit){for(var i=t.root.getElementsByTagName("xg-spot"),e=i.length-1;e>=0;e--)t.outer.removeChild(i[e]);this._ispots=[]}else this._ispots=[]},updateAllDots:function(){var t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=this.player.plugins.progress;if(e)if(this.ispotsInit){this._ispots=[];var s=e.root.getElementsByTagName("xg-spot"),o=s.length;if(o>i.length)for(var n=o-1;n>i.length-1;n--)e.outer.removeChild(s[n]);i.forEach(function(i,e){e<o?(s[e].setAttribute("data-id","".concat(i.id)),t._ispots.push(i),t.updateDot(i)):t.createDot(i)})}else this._ispots=i},positionDots:function(){var t=this,i=this._ispots,e=this.playerSize,s=this.player.sizeInfo,o=this.player.plugins.progress;o&&s.width!==e.width&&(e.width=s.width,e.left=s.left,i.forEach(function(i){var e=o.find('xg-spot[data-id="'.concat(i.id,'"]'));e&&t.positionDot(e,i.id)}))},positionDot:function(i,e){var s=t.default.findDom(i,".xgplayer-spot-pop");if(s){var o=this.playerSize,n=i.getBoundingClientRect(),a=s.getBoundingClientRect(),r=n.left-o.left,p=o.width-r-n.width/2;if(r<a.width/2||o.width<a.width){var l=a.width/2-r;s.style.left="".concat(l,"px")}else if(p<a.width/2){var d=p-a.width/2+n.width/2;s.style.left="".concat(d,"px")}else s.style.left="50%"}},updateDuration:function(){var t=this,i=this.player.plugins.progress;i&&this._ispots.forEach(function(e){var s=i.find('xg-spot[data-id="'.concat(e.id,'"]'));t._updateDotDom(e,s)})},getAllDotsDom:function(){var t=this.player.plugins.progress;return t?t.root.getElementsByTagName("xg-spot"):[]},getDotDom:function(t){var i=this.player.plugins.progress;if(i)return i.find('xg-spot[data-id="'.concat(t,'"]'))}};exports.default=function(t){var e=t.config,n=t.player;Object.keys(o).map(function(i){t[i]=o[i].bind(t)});var a=n.config.progressDot||e.ispots||[];t._ispots=a.map(function(t){return s(t),t}),t.ispotsInit=!1,t.playerSize={left:n.sizeInfo.left,width:n.sizeInfo.width},t.on(i.DURATION_CHANGE,function(){t.ispotsInit?t.updateDuration():t.initDots()}),t.on(i.VIDEO_RESIZE,function(){t.positionDots()})};