/*!
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("../../events.js"),n=require("../../plugin/plugin.js"),o=require("../common/optionsIcon.js");var r=function(r){t.inherits(a,r);var s=t.createSuper(a);function a(e){var i;return t.classCallCheck(this,a),(i=s.call(this,e)).curTime=0,i.isPaused=!0,i}return t.createClass(a,[{key:"beforeCreate",value:function(t){var e=t.config.list;Array.isArray(e)&&e.length>0&&(t.config.list=e.map(function(t){return!t.text&&t.name&&(t.text=t.name),t.text||(t.text=t.definition),t}))}},{key:"afterCreate",value:function(){var e=this;t.get(t.getPrototypeOf(a.prototype),"afterCreate",this).call(this),this.on("resourceReady",function(t){e.changeDefinitionList(t)}),this.on(i.DEFINITION_CHANGE,function(t){e.renderItemList(e.config.list,t.to)}),this.player.definitionList.length<2&&this.hide()}},{key:"show",value:function(t){!this.config.list||this.config.list.length<2||e.default.addClass(this.root,"show")}},{key:"initDefinition",value:function(){var t=this.config,e=t.list,i=t.defaultDefinition;if(e.length>0){var n=null;e.map(function(t){t.definition===i&&(n=t)}),n||(n=e[0]),this.changeDefinition(n)}}},{key:"renderItemList",value:function(){var e=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.config.list||[],n=arguments.length>1?arguments[1]:void 0,o=n&&n.definition?n.definition:this.config.defaultDefinition;n&&i.forEach(function(t){t.selected=!1});var r=0,s=i.map(function(i,n){var s=t.objectSpread2(t.objectSpread2({},i),{},{showText:e.getTextByLang(i)||i.definition,selected:!1});return(i.selected||i.definition&&i.definition==o)&&(s.selected=!0,r=n),s});t.get(t.getPrototypeOf(a.prototype),"renderItemList",this).call(this,s,r)}},{key:"changeDefinitionList",value:function(t){Array.isArray(t)&&(this.config.list=t.map(function(t){return!t.text&&t.name&&(t.text=t.name),t.text||(t.text=t.definition),t}),this.renderItemList(),this.config.list.length<2?this.hide():this.show())}},{key:"changeDefinition",value:function(t,e){this.player.changeDefinition(t,e)}},{key:"onItemClick",value:function(e,i){var n=this.player.definitionList;t.get(t.getPrototypeOf(a.prototype),"onItemClick",this).apply(this,arguments),this.emitUserAction(e,"change_definition",{from:i.from,to:i.to});for(var o=0;o<n.length;o++)i.to&&n[o].definition===i.to.definition&&(i.to.url=n[o].url),i.from&&n[o].definition===i.from.definition&&(i.from.url=n[o].url);this.player.changeDefinition(i.to,i.from)}}],[{key:"pluginName",get:function(){return"definition"}},{key:"defaultConfig",get:function(){return t.objectSpread2(t.objectSpread2({},o.default.defaultConfig),{},{position:n.POSITIONS.CONTROLS_RIGHT,index:3,list:[],defaultDefinition:"",disable:!1,hidePortrait:!1,className:"xgplayer-definition",isShowIcon:!0})}}]),a}(o.default);exports.default=r;