/*!
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("./basePlugin.js"),n=require("../../../../_virtual/delegate.js"),i=require("../utils/debug.js"),r=require("../utils/util.js");var o={CONTROLS:"controls",ROOT:"root"},a={ROOT:"root",ROOT_LEFT:"rootLeft",ROOT_RIGHT:"rootRight",ROOT_TOP:"rootTop",CONTROLS_LEFT:"controlsLeft",CONTROLS_RIGTH:"controlsRight",CONTROLS_RIGHT:"controlsRight",CONTROLS_CENTER:"controlsCenter",CONTROLS:"controls"},l={ICON_DISABLE:"xg-icon-disable"};function s(t){return!!t&&(t.indexOf&&/^(?:http|data:|\/)/.test(t))}function u(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",l=null;if(t instanceof window.Element)return r.default.addClass(t,n),Object.keys(o).map(function(e){t.setAttribute(e,o[e])}),t;if(s(t)||s(t.url))return o.src=s(t)?t:t.url||"",l=r.default.createDom(t.tag||"img","",o,"xg-img ".concat(n));if("function"==typeof t)try{return(l=t())instanceof window.Element?(r.default.addClass(l,n),Object.keys(o).map(function(t){l.setAttribute(t,o[t])}),l):(i.default.logWarn("warn>>icons.".concat(e," in config of plugin named [").concat(a,"] is a function mast return an Element Object")),null)}catch(u){return i.default.logError("Plugin named [".concat(a,"]:createIcon"),u),null}return"string"==typeof t?r.default.createDomFromHtml(t,o,n):(i.default.logWarn("warn>>icons.".concat(e," in config of plugin named [").concat(a,"] is invalid")),null)}function c(e,n){var i=n.config.icons||n.playerConfig.icons;Object.keys(e).map(function(r){var o=e[r],a=o&&o.class?o.class:"",l=o&&o.attr?o.attr:{},s=null;i&&i[r]&&(a=function(e,n){return"object"===t.typeof(e)&&e.class&&"string"==typeof e.class?"".concat(n," ").concat(e.class):n}(i[r],a),l=function(e,n){return"object"===t.typeof(e)&&e.attr&&"object"===t.typeof(e.attr)&&Object.keys(e.attr).map(function(t){n[t]=e.attr[t]}),n}(i[r],l),s=u(i[r],r,a,l,n.pluginName)),!s&&o&&(s=u(o.icon?o.icon:o,l,a,{},n.pluginName)),n.icons[r]=s})}var f=function(e){t.inherits(u,e);var s=t.createSuper(u);function u(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t.classCallCheck(this,u),(e=s.call(this,n)).__delegates=[],e}return t.createClass(u,[{key:"__init",value:function(e){if(t.get(t.getPrototypeOf(u.prototype),"__init",this).call(this,e),e.root){var n=e.root,o=null;this.icons={},this.root=null,this.parent=null,this.extraEls=[],c(this.registerIcons()||{},this),this.langText={};var a,l,s=this.registerLanguageTexts()||{};a=s,l=this,Object.keys(a).map(function(t){Object.defineProperty(l.langText,t,{get:function(){var e=l.lang,n=l.i18n;return n[t]?n[t]:a[t]&&a[t][e]||""}})});var f="";try{f=this.render()}catch(g){throw i.default.logError("Plugin:".concat(this.pluginName,":render"),g),new Error("Plugin:".concat(this.pluginName,":render:").concat(g.message))}if(f)(o=u.insert(f,n,e.index)).setAttribute("data-index",e.index);else{if(!e.tag)return;(o=r.default.createDom(e.tag,"",e.attr,e.name)).setAttribute("data-index",e.index),n.appendChild(o)}this.root=o,this.parent=n;var d=this.config.attr||{},h=this.config.style||{};this.setAttr(d),this.setStyle(h),this.config.index&&this.root.setAttribute("data-index",this.config.index),this.__registerChildren()}}},{key:"__registerChildren",value:function(){var e=this;if(this.root){this._children=[];var n=this.children();n&&"object"===t.typeof(n)&&Object.keys(n).length>0&&Object.keys(n).map(function(i){var o,a,l=i,s=n[l],u={root:e.root};"function"==typeof s?(o=e.config[l]||{},a=s):"object"===t.typeof(s)&&"function"==typeof s.plugin&&(o=s.options?r.default.deepCopy(e.config[l]||{},s.options):e.config[l]||{},a=s.plugin),u.config=o,void 0!==o.index&&(u.index=o.index),o.root&&(u.root=o.root),e.registerPlugin(a,u,l)})}}},{key:"updateLang",value:function(t){t||(t=this.lang);var e=this.root,n=this.i18n,i=this.langText;e&&function t(e,n){for(var i=0;i<e.children.length;i++)e.children[i].children.length>0?t(e.children[i],n):n(e.children[i])}(e,function(e){var r=e.getAttribute&&e.getAttribute("lang-key");if(r){var o=n[r.toUpperCase()]||i[r];o&&(e.innerHTML="function"==typeof o?o(t):o)}})}},{key:"lang",get:function(){return this.player.lang}},{key:"changeLangTextKey",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=this.i18n||{},i=this.langText;t.setAttribute&&t.setAttribute("lang-key",e);var r=n[e]||i[e]||"";r&&(t.innerHTML=r)}},{key:"plugins",value:function(){return this._children}},{key:"disable",value:function(){this.config.disable=!0,r.default.addClass(this.find(".xgplayer-icon"),l.ICON_DISABLE)}},{key:"enable",value:function(){this.config.disable=!1,r.default.removeClass(this.find(".xgplayer-icon"),l.ICON_DISABLE)}},{key:"children",value:function(){return{}}},{key:"registerPlugin",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";n.root=n.root||this.root;var r=t.get(t.getPrototypeOf(u.prototype),"registerPlugin",this).call(this,e,n,i);return this._children.push(r),r}},{key:"registerIcons",value:function(){return{}}},{key:"registerLanguageTexts",value:function(){return{}}},{key:"find",value:function(t){if(this.root)return this.root.querySelector(t)}},{key:"bind",value:function(t,e,n){var i=this;if(arguments.length<3&&"function"==typeof e)Array.isArray(t)?t.forEach(function(t){i.bindEL(t,e)}):this.bindEL(t,e);else{var r=u.delegate.call(this,this.root,t,e,n);this.__delegates=this.__delegates.concat(r)}}},{key:"unbind",value:function(t,e){var n=this;if(arguments.length<3&&"function"==typeof e)Array.isArray(t)?t.forEach(function(t){n.unbindEL(t,e)}):this.unbindEL(t,e);else for(var i="".concat(t,"_").concat(e),r=0;r<this.__delegates.length;r++)if(this.__delegates[r].key===i){this.__delegates[r].destroy(),this.__delegates.splice(r,1);break}}},{key:"setStyle",value:function(t,e){var n=this;if(this.root)return"String"===r.default.typeOf(t)?this.root.style[t]=e:void("Object"===r.default.typeOf(t)&&Object.keys(t).map(function(e){n.root.style[e]=t[e]}))}},{key:"setAttr",value:function(t,e){var n=this;if(this.root)return"String"===r.default.typeOf(t)?this.root.setAttribute(t,e):void("Object"===r.default.typeOf(t)&&Object.keys(t).map(function(e){n.root.setAttribute(e,t[e])}))}},{key:"setHtml",value:function(t,e){this.root&&(this.root.innerHTML=t,"function"==typeof e&&e())}},{key:"bindEL",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.root&&"on".concat(t)in this.root&&"function"==typeof e&&this.root.addEventListener(t,e,n)}},{key:"unbindEL",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.root&&"on".concat(t)in this.root&&"function"==typeof e&&this.root.removeEventListener(t,e,n)}},{key:"show",value:function(t){if(this.root)return this.root.style.display=void 0!==t?t:"block","none"===window.getComputedStyle(this.root,null).getPropertyValue("display")?this.root.style.display="block":void 0}},{key:"hide",value:function(){this.root&&(this.root.style.display="none")}},{key:"appendChild",value:function(t,e){if(!this.root)return null;if(arguments.length<2&&arguments[0]instanceof window.Element)return this.root.appendChild(arguments[0]);if(!(e&&e instanceof window.Element))return null;try{return"string"==typeof t?this.find(t).appendChild(e):t.appendChild(e)}catch(n){return i.default.logError("Plugin:appendChild",n),null}}},{key:"render",value:function(){return""}},{key:"destroy",value:function(){}},{key:"__destroy",value:function(){var e=this,n=this.player;this.__delegates.map(function(t){t.destroy()}),this.__delegates=[],this._children instanceof Array&&(this._children.map(function(t){n.unRegisterPlugin(t.pluginName)}),this._children=null),this.root&&(this.root.hasOwnProperty("remove")?this.root.remove():this.root.parentNode&&this.root.parentNode.removeChild(this.root)),t.get(t.getPrototypeOf(u.prototype),"__destroy",this).call(this),this.icons={},["root","parent"].map(function(t){e[t]=null}),this.extraEls=[]}}],[{key:"insert",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=e.children.length,r=Number(n),o=t instanceof window.Node;if(i){for(var a=0,l=null,s="";a<i;a++){l=e.children[a];var u=Number(l.getAttribute("data-index"));if(u>=r){s="beforebegin";break}u<r&&(s="afterend")}return o?"afterend"===s?e.appendChild(t):e.insertBefore(t,l):l.insertAdjacentHTML(s,t),"afterend"===s?e.children[e.children.length-1]:e.children[a]}return o?e.appendChild(t):e.insertAdjacentHTML("beforeend",t),e.children[e.children.length-1]}},{key:"defaultConfig",get:function(){return{}}},{key:"delegate",value:function(t,e,i,r){var o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=[];if(t instanceof window.Node&&"function"==typeof r)if(Array.isArray(i))i.forEach(function(i){var l=n.default(t,e,i,r,o);l.key="".concat(e,"_").concat(i),a.push(l)});else{var l=n.default(t,e,i,r,o);l.key="".concat(e,"_").concat(i),a.push(l)}return a}},{key:"ROOT_TYPES",get:function(){return o}},{key:"POSITIONS",get:function(){return a}}]),u}(e.default);exports.PLUGIN_STATE_CLASS=l,exports.POSITIONS=a,exports.ROOT_TYPES=o,exports.default=f;