/*!
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,createClass as n}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"../../utils/util.js";import{DURATION_CHANGE as s,SEEKED as o,TIME_UPDATE as a,ENDED as h,EMPTIED as m}from"../../events.js";import u,{POSITIONS as c}from"../../plugin/plugin.js";var l=/* @__PURE__ */function(){t(f,u);var l=i(f);function f(t){var i;return e(this,f),(i=l.call(this,t)).isActiving=!1,i}return n(f,[{key:"duration",get:function(){var t=this.player,i=t.offsetDuration,e=t.duration;return this.playerConfig.customDuration||i||e}},{key:"currentTime",get:function(){var t=this.player,i=t.offsetCurrentTime,e=t.currentTime;return i>=0?i:e}},{key:"timeOffset",get:function(){return this.playerConfig.timeOffset||0}},{key:"afterCreate",value:function(){var t=this.player.controls.config.mode;this.mode="flex"===t?"flex":"normal",this.config.disable||("flex"===this.mode&&(this.createCenterTime(),this.root.style.display="none"),this.durationDom=this.find(".time-duration"),this.timeDom=this.find(".time-current"),this.listenEvents())}},{key:"listenEvents",value:function(){var t=this;this.on([s,o,a],function(i){"durationchange"===i.eventName&&(t.isActiving=!1),t.onTimeUpdate()}),this.on(h,function(){t.onTimeUpdate(!0)}),this.on(m,function(){t.onReset()})}},{key:"show",value:function(t){if("flex"===this.mode)return this.centerCurDom&&(this.centerCurDom.style.display="block"),void(this.centerDurDom&&(this.centerDurDom.style.display="block"));this.root.style.display="block"}},{key:"hide",value:function(){if("flex"===this.mode)return this.centerCurDom&&(this.centerCurDom.style.display="none"),void(this.centerDurDom&&(this.centerDurDom.style.display="none"));this.root.style.display="none"}},{key:"onTimeUpdate",value:function(t){var i=this.player,e=this.config,n=this.duration;if(!e.disable&&!this.isActiving&&i.hasStart){var s=this.currentTime+this.timeOffset;s=r.adjustTimeByDuration(s,n,t),"flex"===this.mode?(this.centerCurDom.innerHTML=this.minWidthTime(r.format(s)),n!==1/0&&n>0&&(this.centerDurDom.innerHTML=r.format(n))):(this.timeDom.innerHTML=this.minWidthTime(r.format(s)),n!==1/0&&n>0&&(this.durationDom.innerHTML=r.format(n)))}}},{key:"onReset",value:function(){"flex"===this.mode?(this.centerCurDom.innerHTML=this.minWidthTime(r.format(0)),this.centerDurDom.innerHTML=r.format(0)):(this.timeDom.innerHTML=this.minWidthTime(r.format(0)),this.durationDom.innerHTML=r.format(0))}},{key:"createCenterTime",value:function(){var t=this.player;if(t.controls&&t.controls.center){var i=t.controls.center;this.centerCurDom=r.createDom("xg-icon","00:00",{},"xgplayer-time xg-time-left"),this.centerDurDom=r.createDom("xg-icon","00:00",{},"xgplayer-time xg-time-right"),i.children.length>0?i.insertBefore(this.centerCurDom,i.children[0]):i.appendChild(this.centerCurDom),i.appendChild(this.centerDurDom),this.extraEls=[this.centerCurDom,this.centerDurDom]}}},{key:"afterPlayerInit",value:function(){var t=this.config;this.duration===1/0||this.playerConfig.isLive?(r.hide(this.durationDom),r.hide(this.timeDom),r.hide(this.find(".time-separator")),r.show(this.find(".time-live-tag"))):r.hide(this.find(".time-live-tag")),t.hide?this.hide():this.show()}},{key:"changeLiveState",value:function(t){t?(r.hide(this.durationDom),r.hide(this.timeDom),r.hide(this.find(".time-separator")),r.show(this.find(".time-live-tag"))):(r.hide(this.find(".time-live-tag")),r.show(this.find(".time-separator")),r.show(this.durationDom),r.show(this.timeDom))}},{key:"updateTime",value:function(t){this.isActiving=!0,!t&&0!==t||t>this.duration||("flex"!==this.mode?this.timeDom.innerHTML=this.minWidthTime(r.format(t)):this.centerCurDom.innerHTML=this.minWidthTime(r.format(t)))}},{key:"minWidthTime",value:function(t){return t.split(":").map(function(t){return'<span class="time-min-width">'.concat(t,"</span>")}).join(":")}},{key:"resetActive",value:function(){var t=this,i=this.player,e=function(){t.isActiving=!1};this.off(o,e),i.isSeeking&&i.media.seeking?this.once(o,e):this.isActiving=!1}},{key:"destroy",value:function(){var t=this.player.controls.center;this.centerCurDom&&t.removeChild(this.centerCurDom),this.centerCurDom=null,this.centerDurDom&&t.removeChild(this.centerDurDom),this.centerDurDom=null}},{key:"render",value:function(){if(!this.config.disable)return'<xg-icon class="xgplayer-time">\n    <span class="time-current">00:00</span>\n    <span class="time-separator">/</span>\n    <span class="time-duration">00:00</span>\n    <span class="time-live-tag">'.concat(this.i18n.LIVE_TIP,"</span>\n    </xg-icon>")}}],[{key:"pluginName",get:function(){return"time"}},{key:"defaultConfig",get:function(){return{position:c.CONTROLS_LEFT,index:2,disable:!1}}}]),f}();export{l as default};