import{r as i,h as t,g as s,H as e}from"./p-23a36bb6.js";import{JSUtils as h,ElementIDUtils as l}from"@sankhyalabs/core";const o=class{constructor(t){i(this,t),this._dataKey=""}async show(i){i!==this._focusedIndex&&0<=i&&i<this._totalStackItems&&(this.policyHideRemove(),this.policyShowAppend(i),this._focusedIndex=i)}async getSelectedIndex(){return this._focusedIndex}policyHideRemove(){let i=this._hostElem.querySelector(`#${this._dataKey}_el_${this._focusedIndex}`);this.checkElementVisibility(i)}policyShowAppend(i){let t=this._hostElem.querySelector(`#${this._dataKey}_el_${i}`);t?t.setAttribute("style","visibility: visible"):this._hostElem.append(this._elemList[i])}checkElementVisibility(i){"hide"!==i.getAttribute("hidePolicy")&&i.getAttribute("hidePolicy")?"remove"===i.getAttribute("hidePolicy")&&i.remove():i.setAttribute("style","display: none")}componentWillRender(){this._dataKey="id_".concat(h.generateUUID()),this._elemList||(this._elemList=[],this._focusedIndex=0,this._totalStackItems=0,this._hostElem.classList.add("ez-view-stack__container"),this._hostElem.querySelectorAll(":scope > stack-item").forEach(((i,t)=>{i.setAttribute("id",`${this._dataKey}_el_${t}`),0!==t?this.checkElementVisibility(i):i.setAttribute("style","visibility: visible"),this._totalStackItems++,this._elemList.push(i)})))}componentDidLoad(){l.addIDInfo(this._hostElem)}disconectCallback(){this._hostElem=null,this._elemList=null}render(){return t(e,null)}get _hostElem(){return s(this)}};o.style=":host{width:100%;height:100%}.ez-view-stack__container{width:100%;height:100%}";export{o as ez_view_stack}