/*!
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{createClass as t,classCallCheck as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import i from"../../utils/util.js";import s from"../../plugin/plugin.js";var o=/* @__PURE__ */function(){function o(t){e(this,o),this.config=t.config,this.parent=t.root,this.root=i.createDom("ul","",{},"xg-options-list xg-list-slide-scroll ".concat(this.config.className)),t.root.appendChild(this.root);var a=this.config.maxHeight;a&&this.setStyle({maxHeight:a}),this.onItemClick=this.onItemClick.bind(this),this.renderItemList();var l="touch"===this.config.domEventType?"touchend":"click";this._delegates=s.delegate.call(this,this.root,"li",l,this.onItemClick)}return t(o,[{key:"renderItemList",value:function(t){var e=this,s=this.config,o=this.root;t?s.data=t:t=s.data,s.style&&Object.keys(s.style).map(function(t){o.style[t]=s[t]}),t.length>0&&(this.attrKeys=Object.keys(t[0])),this.root.innerHTML="",t.map(function(t,s){var o=t.selected?"option-item selected":"option-item";t["data-index"]=s,e.root.appendChild(i.createDom("li","<span>".concat(t.showText,"</span>"),t,o))})}},{key:"onItemClick",value:function(t){t.delegateTarget||(t.delegateTarget=t.target);var e=t.delegateTarget;if(e&&i.hasClass(e,"selected"))return!1;var s="function"==typeof this.config.onItemClick?this.config.onItemClick:null,o=this.root.querySelector(".selected");i.addClass(e,"selected"),o&&i.removeClass(o,"selected"),s(t,{from:o?this.getAttrObj(o,this.attrKeys):null,to:this.getAttrObj(e,this.attrKeys)})}},{key:"getAttrObj",value:function(t,e){if(!t||!e)return{};var i={};e.map(function(e){i[e]=t.getAttribute(e)});var s=t.getAttribute("data-index");return s&&(i.index=Number(s)),i}},{key:"show",value:function(){i.removeClass(this.root,"hide"),i.addClass(this.root,"active")}},{key:"hide",value:function(){i.removeClass(this.root,"active"),i.addClass(this.root,"hide")}},{key:"setStyle",value:function(t){var e=this;Object.keys(t).forEach(function(i){e.root.style[i]=t[i]})}},{key:"destroy",value:function(){this._delegates&&(this._delegates.map(function(t){t.destroy&&t.destroy()}),this._delegates=null),this.root.innerHTML=null,this.parent.removeChild(this.root),this.root=null}}]),o}();export{o as default};