/*!
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 e,classCallCheck as n,createClass as i,get as r,getPrototypeOf as o,typeof as a}from"../_virtual/_rollupPluginBabelHelpers.js";import s from"./basePlugin.js";import l from"../../../../_virtual/delegate.js";import c from"../utils/debug.js";import u from"../utils/util.js";var h={CONTROLS:"controls",ROOT:"root"},f={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"},d={ICON_DISABLE:"xg-icon-disable"};function g(t){return!!t&&(t.indexOf&&/^(?:http|data:|\/)/.test(t))}function y(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",o=null;if(t instanceof window.Element)return u.addClass(t,n),Object.keys(i).map(function(e){t.setAttribute(e,i[e])}),t;if(g(t)||g(t.url))return i.src=g(t)?t:t.url||"",o=u.createDom(t.tag||"img","",i,"xg-img ".concat(n));if("function"==typeof t)try{return(o=t())instanceof window.Element?(u.addClass(o,n),Object.keys(i).map(function(t){o.setAttribute(t,i[t])}),o):(c.logWarn("warn>>icons.".concat(e," in config of plugin named [").concat(r,"] is a function mast return an Element Object")),null)}catch(a){return c.logError("Plugin named [".concat(r,"]:createIcon"),a),null}return"string"==typeof t?u.createDomFromHtml(t,i,n):(c.logWarn("warn>>icons.".concat(e," in config of plugin named [").concat(r,"] is invalid")),null)}function p(t,e){var n=e.config.icons||e.playerConfig.icons;Object.keys(t).map(function(i){var r=t[i],o=r&&r.class?r.class:"",s=r&&r.attr?r.attr:{},l=null;n&&n[i]&&(o=function(t,e){return"object"===a(t)&&t.class&&"string"==typeof t.class?"".concat(e," ").concat(t.class):e}(n[i],o),s=function(t,e){return"object"===a(t)&&t.attr&&"object"===a(t.attr)&&Object.keys(t.attr).map(function(n){e[n]=t.attr[n]}),e}(n[i],s),l=y(n[i],i,o,s,e.pluginName)),!l&&r&&(l=y(r.icon?r.icon:r,s,o,{},e.pluginName)),e.icons[i]=l})}var v=/* @__PURE__ */function(){t(y,s);var g=e(y);function y(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n(this,y),(t=g.call(this,e)).__delegates=[],t}return i(y,[{key:"__init",value:function(t){if(r(o(y.prototype),"__init",this).call(this,t),t.root){var e=t.root,n=null;this.icons={},this.root=null,this.parent=null,this.extraEls=[],p(this.registerIcons()||{},this),this.langText={};var i,a,s=this.registerLanguageTexts()||{};i=s,a=this,Object.keys(i).map(function(t){Object.defineProperty(a.langText,t,{get:function(){var e=a.lang,n=a.i18n;return n[t]?n[t]:i[t]&&i[t][e]||""}})});var l="";try{l=this.render()}catch(d){throw c.logError("Plugin:".concat(this.pluginName,":render"),d),new Error("Plugin:".concat(this.pluginName,":render:").concat(d.message))}if(l)(n=y.insert(l,e,t.index)).setAttribute("data-index",t.index);else{if(!t.tag)return;(n=u.createDom(t.tag,"",t.attr,t.name)).setAttribute("data-index",t.index),e.appendChild(n)}this.root=n,this.parent=e;var h=this.config.attr||{},f=this.config.style||{};this.setAttr(h),this.setStyle(f),this.config.index&&this.root.setAttribute("data-index",this.config.index),this.__registerChildren()}}},{key:"__registerChildren",value:function(){var t=this;if(this.root){this._children=[];var e=this.children();e&&"object"===a(e)&&Object.keys(e).length>0&&Object.keys(e).map(function(n){var i,r,o=n,s=e[o],l={root:t.root};"function"==typeof s?(i=t.config[o]||{},r=s):"object"===a(s)&&"function"==typeof s.plugin&&(i=s.options?u.deepCopy(t.config[o]||{},s.options):t.config[o]||{},r=s.plugin),l.config=i,void 0!==i.index&&(l.index=i.index),i.root&&(l.root=i.root),t.registerPlugin(r,l,o)})}}},{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,u.addClass(this.find(".xgplayer-icon"),d.ICON_DISABLE)}},{key:"enable",value:function(){this.config.disable=!1,u.removeClass(this.find(".xgplayer-icon"),d.ICON_DISABLE)}},{key:"children",value:function(){return{}}},{key:"registerPlugin",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";e.root=e.root||this.root;var i=r(o(y.prototype),"registerPlugin",this).call(this,t,e,n);return this._children.push(i),i}},{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=y.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"===u.typeOf(t)?this.root.style[t]=e:void("Object"===u.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"===u.typeOf(t)?this.root.setAttribute(t,e):void("Object"===u.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 c.logError("Plugin:appendChild",n),null}}},{key:"render",value:function(){return""}},{key:"destroy",value:function(){}},{key:"__destroy",value:function(){var t=this,e=this.player;this.__delegates.map(function(t){t.destroy()}),this.__delegates=[],this._children instanceof Array&&(this._children.map(function(t){e.unRegisterPlugin(t.pluginName)}),this._children=null),this.root&&(this.root.hasOwnProperty("remove")?this.root.remove():this.root.parentNode&&this.root.parentNode.removeChild(this.root)),r(o(y.prototype),"__destroy",this).call(this),this.icons={},["root","parent"].map(function(e){t[e]=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,s=null,l="";a<i;a++){s=e.children[a];var c=Number(s.getAttribute("data-index"));if(c>=r){l="beforebegin";break}c<r&&(l="afterend")}return o?"afterend"===l?e.appendChild(t):e.insertBefore(t,s):s.insertAdjacentHTML(l,t),"afterend"===l?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,n,i){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=[];if(t instanceof window.Node&&"function"==typeof i)if(Array.isArray(n))n.forEach(function(n){var a=l(t,e,n,i,r);a.key="".concat(e,"_").concat(n),o.push(a)});else{var a=l(t,e,n,i,r);a.key="".concat(e,"_").concat(n),o.push(a)}return o}},{key:"ROOT_TYPES",get:function(){return h}},{key:"POSITIONS",get:function(){return f}}]),y}();export{d as PLUGIN_STATE_CLASS,f as POSITIONS,h as ROOT_TYPES,v as default};