/*!
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("../../events.js"),r=require("../../plugin/plugin.js"),a=require("../common/optionsIcon.js");var i=function(i){t.inherits(o,i);var n=t.createSuper(o);function o(e){var r;return t.classCallCheck(this,o),(r=n.call(this,e)).curRate=1,r}return t.createClass(o,[{key:"beforeCreate",value:function(t){var e=t.player.config.playbackRate,r=e?Array.isArray(e)?e:t.config.list:[];Array.isArray(r)&&(t.config.list=r.map(function(t){return"number"==typeof t?t={rate:t,text:"".concat(t,"x")}:!t.text&&t.rate&&(t.text="".concat(t.rate,"x")),t}))}},{key:"afterCreate",value:function(){var r=this;t.get(t.getPrototypeOf(o.prototype),"afterCreate",this).call(this),this.on(e.RATE_CHANGE,function(){r.curValue!==r.player.playbackRate&&r.renderItemList()}),this.renderItemList()}},{key:"show",value:function(e){this.config.list&&0!==this.config.list.length&&t.get(t.getPrototypeOf(o.prototype),"show",this).call(this)}},{key:"onItemClick",value:function(e,r){t.get(t.getPrototypeOf(o.prototype),"onItemClick",this).call(this,e,r);var a=e.delegateTarget,i=Number(a.getAttribute("rate"));if(!i||i===this.curValue)return!1;var n={playbackRate:{from:this.player.playbackRate,to:i}};this.emitUserAction(e,"change_rate",{props:n}),this.curValue=i,this.player.playbackRate=i}},{key:"renderItemList",value:function(){var e=this,r=this.player.playbackRate||1;this.curValue=r;var a=-1,i=this.config.list.map(function(t,i){var n={rate:t.rate};return n.rate===r&&(n.selected=!0,a=i),n.showText=e.getTextByLang(t),n});t.get(t.getPrototypeOf(o.prototype),"renderItemList",this).call(this,i,a)}},{key:"changeCurrentText",value:function(){if(!this.isIcons){var t=this.config.list,e=t[this.curIndex<t.length?this.curIndex:0],r="";r=!e||this.curIndex<0?"".concat(this.player.playbackRate,"x"):this.getTextByLang(e,"iconText"),this.find(".icon-text").innerHTML=r}}},{key:"destroy",value:function(){t.get(t.getPrototypeOf(o.prototype),"destroy",this).call(this)}}],[{key:"pluginName",get:function(){return"playbackRate"}},{key:"defaultConfig",get:function(){return t.objectSpread2(t.objectSpread2({},a.default.defaultConfig),{},{position:r.POSITIONS.CONTROLS_RIGHT,index:4,list:[2,1.5,1,.75,.5],className:"xgplayer-playbackrate",isShowIcon:!0,hidePortrait:!1})}}]),o}(a.default);exports.default=i;