/*!
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 e=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("../../utils/util.js"),i=require("../../utils/sniffer.js"),s=require("../../events.js"),o=require("../../plugin/plugin.js"),a=require("../assets/volumeLarge.js"),n=require("../assets/volumeSmall.js"),l=require("../assets/volumeMuted.js");var u=function(u){e.inherits(d,u);var r=e.createSuper(d);function d(){var i;e.classCallCheck(this,d);for(var s=arguments.length,o=new Array(s),a=0;a<s;a++)o[a]=arguments[a];return i=r.call.apply(r,[this].concat(o)),e.defineProperty(e.assertThisInitialized(i),"onBarMousedown",function(s){var o=e.assertThisInitialized(i).player,a=i.find(".xgplayer-bar");t.default.event(s);var n=a.getBoundingClientRect(),l=t.default.getEventPos(s,o.zoom),u=n.height-(l.clientY-n.top);if(l.h=u,l.barH=n.height,i.pos=l,!(u<-2))return i.updateVolumePos(u,s),document.addEventListener("mouseup",i.onBarMouseUp),i._d.isStart=!0,!1}),e.defineProperty(e.assertThisInitialized(i),"onBarMouseMove",function(s){var o=e.assertThisInitialized(i)._d;if(o.isStart){var a=e.assertThisInitialized(i),n=a.pos,l=a.player;s.preventDefault(),s.stopPropagation(),t.default.event(s);var u=t.default.getEventPos(s,l.zoom);o.isMoving=!0;var r=n.h-u.clientY+n.clientY;r>n.barH||i.updateVolumePos(r,s)}}),e.defineProperty(e.assertThisInitialized(i),"onBarMouseUp",function(s){t.default.event(s),document.removeEventListener("mouseup",i.onBarMouseUp);var o=e.assertThisInitialized(i)._d;o.isStart=!1,o.isMoving=!1}),e.defineProperty(e.assertThisInitialized(i),"onMouseenter",function(e){i._d.isActive=!0,i.focus(),i.emit("icon_mouseenter",{pluginName:i.pluginName})}),e.defineProperty(e.assertThisInitialized(i),"onMouseleave",function(e){i._d.isActive=!1,i.unFocus(100,!1,e),i.emit("icon_mouseleave",{pluginName:i.pluginName})}),e.defineProperty(e.assertThisInitialized(i),"onVolumeChange",function(e){if(i.player){var t=i.player,s=t.muted,o=t.volume;i._d.isMoving||(i.find(".xgplayer-drag").style.height=s||0===o?"4px":"".concat(100*o,"%"),i.config.showValueLabel&&i.updateVolumeValue()),i.animate(s,o)}}),i}return e.createClass(d,[{key:"registerIcons",value:function(){return{volumeSmall:{icon:n.default,class:"xg-volume-small"},volumeLarge:{icon:a.default,class:"xg-volume"},volumeMuted:{icon:l.default,class:"xg-volume-mute"}}}},{key:"afterCreate",value:function(){var e=this;if(this._timerId=null,this._d={isStart:!1,isMoving:!1,isActive:!1},!this.config.disable){this.initIcons();var o=this.playerConfig,a=o.commonStyle,n=o.volume;a.volumeColor&&(this.find(".xgplayer-drag").style.backgroundColor=a.volumeColor),this.changeMutedHandler=this.hook("mutedChange",function(t){e.changeMuted(t)},{pre:function(e){e.preventDefault(),e.stopPropagation()}}),this._onMouseenterHandler=this.hook("mouseenter",this.onMouseenter),this._onMouseleaveHandler=this.hook("mouseleave",this.onMouseleave),"mobile"!==i.default.device&&"mobile"!==this.playerConfig.isMobileSimulateMode&&(this.bind("mouseenter",this._onMouseenterHandler),this.bind(["blur","mouseleave"],this._onMouseleaveHandler),this.bind(".xgplayer-slider","mousedown",this.onBarMousedown),this.bind(".xgplayer-slider","mousemove",this.onBarMouseMove),this.bind(".xgplayer-slider","mouseup",this.onBarMouseUp)),this.bind(".xgplayer-icon",["touchend","click"],this.changeMutedHandler),this.on(s.VOLUME_CHANGE,this.onVolumeChange),this.once(s.LOADED_DATA,this.onVolumeChange),"Number"!==t.default.typeOf(n)&&(this.player.volume=this.config.default),this.onVolumeChange()}}},{key:"updateVolumePos",value:function(e,t){var i=this.player,s=this.find(".xgplayer-drag"),o=this.find(".xgplayer-bar");if(o&&s){var a=parseInt(e/o.getBoundingClientRect().height*1e3,10);s.style.height="".concat(e,"px");var n=Math.max(Math.min(a/1e3,1),0),l={volume:{from:i.volume,to:n}};i.muted&&(l.muted={from:!0,to:!1}),this.emitUserAction(t,"change_volume",{muted:i.muted,volume:i.volume,props:l}),i.volume=Math.max(Math.min(a/1e3,1),0),i.muted&&(i.muted=!1),this.config.showValueLabel&&this.updateVolumeValue()}}},{key:"updateVolumeValue",value:function(){var e=this.player,t=e.volume,i=e.muted,s=this.find(".xgplayer-value-label"),o=Math.max(Math.min(t,1),0);s.innerText=i?0:Math.round(100*o)}},{key:"focus",value:function(){this.player.focus({autoHide:!1}),this._timerId&&(t.default.clearTimeout(this,this._timerId),this._timerId=null),t.default.addClass(this.root,"slide-show")}},{key:"unFocus",value:function(){var e=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,s=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=arguments.length>2?arguments[2]:void 0,a=this._d,n=this.player;a.isActive||(this._timerId&&(t.default.clearTimeout(this,this._timerId),this._timerId=null),this._timerId=t.default.setTimeout(this,function(){a.isActive||(s?n.blur():n.focus(),t.default.removeClass(e.root,"slide-show"),a.isStart&&e.onBarMouseUp(o)),e._timerId=null},i))}},{key:"changeMuted",value:function(e){e&&e.stopPropagation();var t=this.player;this._d.isStart&&this.onBarMouseUp(e),this.emitUserAction(e,"change_muted",{muted:t.muted,volume:t.volume,props:{muted:{from:t.muted,to:!t.muted}}}),t.volume>0&&(t.muted=!t.muted),t.volume<.01&&(t.volume=this.config.miniVolume)}},{key:"animate",value:function(e,t){e||0===t?this.setAttr("data-state","mute"):t<.5&&this.icons.volumeSmall?this.setAttr("data-state","small"):this.setAttr("data-state","normal")}},{key:"initIcons",value:function(){var e=this.icons;this.appendChild(".xgplayer-icon",e.volumeSmall),this.appendChild(".xgplayer-icon",e.volumeLarge),this.appendChild(".xgplayer-icon",e.volumeMuted)}},{key:"destroy",value:function(){this._timerId&&(t.default.clearTimeout(this,this._timerId),this._timerId=null),this.unbind("mouseenter",this.onMouseenter),this.unbind(["blur","mouseleave"],this.onMouseleave),this.unbind(".xgplayer-slider","mousedown",this.onBarMousedown),this.unbind(".xgplayer-slider","mousemove",this.onBarMouseMove),this.unbind(".xgplayer-slider","mouseup",this.onBarMouseUp),document.removeEventListener("mouseup",this.onBarMouseUp),this.unbind(".xgplayer-icon","mobile"===i.default.device?"touchend":"click",this.changeMutedHandler)}},{key:"render",value:function(){if(!this.config.disable){var e=this.config.default||this.player.volume,t=this.config.showValueLabel;return'\n    <xg-icon class="xgplayer-volume" data-state="normal">\n      <div class="xgplayer-icon">\n      </div>\n      <xg-slider class="xgplayer-slider">\n        '.concat(t?'<div class="xgplayer-value-label">'.concat(100*e,"</div>"):"",'\n        <div class="xgplayer-bar">\n          <xg-drag class="xgplayer-drag" style="height: ').concat(100*e,'%"></xg-drag>\n        </div>\n      </xg-slider>\n    </xg-icon>')}}}],[{key:"pluginName",get:function(){return"volume"}},{key:"defaultConfig",get:function(){return{position:o.POSITIONS.CONTROLS_RIGHT,index:1,disable:!1,showValueLabel:!1,default:.6,miniVolume:.2}}}]),d}(o.default);exports.default=u;