var t,e,i={9236(t,e,i){i.d(e,{L:()=>s});var s,r=i(2900),a=i(9609),l=i(3203),d=i(4084),o=(i(6650),i(2927)),n=i(8899),h=i(3013),c=function(t,e,i,s){var r,a=arguments.length,l=a<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,e,i,s);else for(var d=t.length-1;d>=0;d--)(r=t[d])&&(l=(a<3?r(l):a>3?r(e,i,l):r(e,i))||l);return a>3&&l&&Object.defineProperty(e,i,l),l};!function(t){t.prefixId="item-";let e=class extends((0,l.y)(o.LitElement)){constructor(){super(...arguments),this.items=[],this.isLoading=!1,this.isMulti=!1,this.groupOnMultiSelect=!1,this.value=[],this.ariaRoleList="listbox",this.ariaRoleListItem="option",this.ariaLabelList="",this.isError=!1,this.containerHeight="292px",this.lastSelectedIdByOrder="",this.selectAllItems=!1,this.focusReset=!1,this.disabledItems=[],this.totalRecords=0,this.isNonSelectable=!1,this.scrollIndex=-1,this.activeId="",this.selectedItemsIds=[],this.isUserNavigated=!1,this.handleKeyDown=e=>{var i,s,a;const{ArrowDown:l,ArrowUp:d,Tab:o,Space:n,Enter:h}=r.Uz,{code:c}=e,p=c===l,u=c===d,v=c===o,m=c===n,I=c===h;if(p||u){if(e.preventDefault(),this.isUserNavigated=!0,""===this.activeId&&this.value.length>0&&""!==this.value[0])return void(this.activeId=this.value[0]);if(""===this.activeId&&!u&&this.items.length>0)return void(this.activeId=this.items[0].id);const t=this.items.findIndex(t=>t.id===this.activeId);p?t<this.items.length-1&&!this.isNextElemenentStatusIndicator(t)&&(this.scrollIndex=t+1,this.activeId=this.items[this.scrollIndex].id,null===(i=this.virtualizer)||void 0===i||i.scrollToIndex(this.scrollIndex,"start")):t>0&&(this.scrollIndex=t-1,this.activeId=this.items[this.scrollIndex].id,null===(s=this.virtualizer)||void 0===s||s.scrollToIndex(this.scrollIndex,"start"))}else if(v)""===this.activeId&&this.value.length>0&&(this.activeId=this.value[0]);else if((m||I)&&(e.preventDefault(),this.activeId)){const e=null===(a=this.shadowRoot)||void 0===a?void 0:a.querySelector(`#${t.prefixId}${this.activeId}`);e&&("true"===e.getAttribute("aria-disabled")||e.hasAttribute("disabled")||this.updateItemSelection(e))}},this.handleRangeChange=t=>{const{last:e}=t;this.updateSelectedState(),this.items.length<this.totalRecords&&e>=this.items.length-1&&!this.isLoading&&!this.isError&&this.dispatchEvent(new CustomEvent("load-more",{bubbles:!0,composed:!0})),this.isUserNavigated=!1},this.renderItem=(e,i)=>{if(!e)return o.html`<div class="default-wrapper-error">Invalid item</div>`;if(!e.id)return console.warn(`AdvanceList.renderItem: item missing id at index ${i}`,e),o.html`<div class="default-wrapper-error">Item missing ID</div>`;try{return"status-indicator"===e.id?o.html`
            <div class="default-wrapper-status-indicator" id="status-indicator">${e.template(e,i)}</div>
          `:o.html`
          <div
            class="default-wrapper ${e.id} ${this.isNonSelectable?"non-selectable":""}"
            part="advance-list-item-wrapper"
            aria-setsize="${this.totalRecords}"
            aria-posinset="${i+1}"
            role="${this.ariaRoleListItem}"
            aria-label=${e.name||"Unknown item"}
            id="${t.prefixId}${e.id}"
            data-index="${i}"
          >
            ${e.template(e,i)}
          </div>
        `}catch(t){return console.error(`AdvanceList.renderItem: Error rendering item ${e.id} at index ${i}:`,t,e),o.html`<div class="default-wrapper-error">Error rendering item</div>`}}}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.handleClick)}static get styles(){return[d.A,h.A]}getStyles(){return o.html`
        <style>
          :host .virtual-scroll {
            height: ${this.containerHeight};
          }
        </style>
      `}disconnectedCallback(){var t;super.disconnectedCallback(),this.removeEventListener("click",this.handleClick),null===(t=this.listContainer)||void 0===t||t.removeEventListener("keydown",this.handleKeyDown)}firstUpdated(t){var e;super.firstUpdated(t),null===(e=this.listContainer)||void 0===e||e.addEventListener("keydown",this.handleKeyDown)}willUpdate(t){var e;null===(e=super.willUpdate)||void 0===e||e.call(this,t),t.has("value")&&(void 0!==t.get("value")||this.value.length>0)&&(this.selectedItemsIds=this.value),t.has("selectAllItems")&&this.selectAllItems&&(this.selectedItemsIds=this.items.filter(t=>t&&t.id&&!this.disabledItems.includes(t.id)).map(t=>t.id)),t.has("focusReset")&&this.focusReset&&(this.activeId="")}updated(t){super.updated(t),t.has("value")&&(void 0!==t.get("value")||this.value.length>0)&&requestAnimationFrame(()=>this.updateSelectedState()),t.has("selectAllItems")&&this.selectAllItems&&(this.updateSelectedState(),this.notifySelectedChange()),t.has("activeId")&&this.isUserNavigated&&requestAnimationFrame(()=>this.updateSelectedState())}setCheckboxAttributes(t,e){var i,s,r,a;!t||(null===(i=e.firstElementChild)||void 0===i?void 0:i.hasAttribute("disabled"))&&"true"===(null===(s=e.firstElementChild)||void 0===s?void 0:s.getAttribute("aria-disabled"))?null===(a=e.querySelector("md-checkbox"))||void 0===a||a.removeAttribute("checked"):null===(r=e.querySelector("md-checkbox"))||void 0===r||r.setAttribute("checked","true")}updateWrapperAttributes(t,e){this.isMulti?this.setCheckboxAttributes(e,t):t.classList.toggle("selected",e),t.setAttribute("selected",e.toString()),t.setAttribute("aria-selected",e.toString()),t.setAttribute("tabindex",e?"0":"-1")}updateSelectedState(){var e;Array.from((null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll(".default-wrapper"))||[]).forEach(e=>{var i,s;const r=this.selectedItemsIds.some(i=>e.id===`${t.prefixId}${i}`);this.updateWrapperAttributes(e,r),this.groupOnMultiSelect&&this.value.length>0&&this.items.length!==this.value.length&&e.id===`${t.prefixId}${this.lastSelectedIdByOrder}`?e.classList.add("selected-border-bottom"):e.classList.remove("selected-border-bottom"),e.id===`${t.prefixId}${this.activeId}`?(e.setAttribute("tabindex","0"),this.isUserNavigated&&e.focus()):e.setAttribute("tabindex","-1"),""==this.activeId&&e.id===`${t.prefixId}${this.value[0]}`&&e.setAttribute("tabindex","0"),(null===(i=e.firstElementChild)||void 0===i?void 0:i.hasAttribute("disabled"))||"true"===(null===(s=e.firstElementChild)||void 0===s?void 0:s.getAttribute("aria-disabled"))?(e.setAttribute("disabled",""),e.setAttribute("aria-disabled","true")):(e.removeAttribute("disabled"),e.removeAttribute("aria-disabled"))})}findClickedItem(t){var e;const i=Array.from((null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll(".default-wrapper"))||[]),s=t.composedPath(),r=i.find(t=>s.includes(t));if(r)return(null==r?void 0:r.hasAttribute("disabled"))||"true"===(null==r?void 0:r.getAttribute("aria-disabled"))?0:r}isNextElemenentStatusIndicator(t){return(this.isLoading||this.isError)&&t===this.items.length-2}updateItemForMultiSelect(t){const e=this.selectedItemsIds.indexOf(t);-1===e?(this.selectedItemsIds.push(this.activeId),this.selectedItemsIds.length===this.items.length-this.disabledItems.length&&(this.selectAllItems=!0)):(this.selectedItemsIds.splice(e,1),this.selectAllItems=!1)}updateItemSelection(t){t&&(this.activeId=t.id.substring(t.id.indexOf("-")+1),this.isMulti?this.updateItemForMultiSelect(this.activeId):this.selectedItemsIds=[this.activeId],this.updateSelectedState(),this.notifySelectedChange())}handleClick(t){t.preventDefault(),this.isUserNavigated=!1;const e=this.findClickedItem(t);e&&(this.scrollIndex=parseInt(e.getAttribute("index")||"0"),this.updateItemSelection(e))}notifySelectedChange(){this.dispatchEvent(new CustomEvent("list-item-change",{detail:{selected:this.selectedItemsIds},bubbles:!0,composed:!0}))}getActiveDescendant(){return this.activeId?`${t.prefixId}${this.activeId}`:this.value&&this.value.length>0&&this.value[0]?`${t.prefixId}${this.value[0]}`:""}render(){return o.html`
        ${this.getStyles()}
        <div
          class="md-advance-list-wrapper virtual-scroll"
          tabindex="0"
          aria-activedescendant=${this.getActiveDescendant()}
          aria-multiselectable=${this.isMulti}
          aria-label=${this.ariaLabelList}
          role=${this.ariaRoleList}
        >
          <lit-virtualizer
            .items=${this.items}
            .renderItem=${(t,e)=>this.renderItem(t,e)}
            @rangeChanged=${this.handleRangeChange}
          ></lit-virtualizer>
        </div>
      `}};c([(0,n.property)({type:Array})],e.prototype,"items",void 0),c([(0,n.property)({type:Boolean})],e.prototype,"isLoading",void 0),c([(0,n.property)({type:Boolean,attribute:"is-multi"})],e.prototype,"isMulti",void 0),c([(0,n.property)({type:Boolean})],e.prototype,"groupOnMultiSelect",void 0),c([(0,n.property)({type:Array})],e.prototype,"value",void 0),c([(0,n.property)({type:String})],e.prototype,"ariaRoleList",void 0),c([(0,n.property)({type:String})],e.prototype,"ariaRoleListItem",void 0),c([(0,n.property)({type:String})],e.prototype,"ariaLabelList",void 0),c([(0,n.property)({type:Boolean})],e.prototype,"isError",void 0),c([(0,n.property)({type:String})],e.prototype,"containerHeight",void 0),c([(0,n.property)({type:String})],e.prototype,"lastSelectedIdByOrder",void 0),c([(0,n.property)({type:Boolean})],e.prototype,"selectAllItems",void 0),c([(0,n.property)({type:Boolean})],e.prototype,"focusReset",void 0),c([(0,n.property)({type:Array})],e.prototype,"disabledItems",void 0),c([(0,n.property)({type:Number})],e.prototype,"totalRecords",void 0),c([(0,n.property)({type:Boolean})],e.prototype,"isNonSelectable",void 0),c([(0,n.query)(".virtual-scroll")],e.prototype,"listContainer",void 0),c([(0,n.query)("lit-virtualizer")],e.prototype,"virtualizer",void 0),c([(0,n.state)()],e.prototype,"scrollIndex",void 0),c([(0,n.state)()],e.prototype,"activeId",void 0),c([(0,n.state)()],e.prototype,"selectedItemsIds",void 0),c([(0,n.state)()],e.prototype,"isUserNavigated",void 0),e=c([(0,a.w)("md-advance-list")],e),t.ELEMENT=e}(s||(s={}))}},s={};function r(t){var e=s[t];if(void 0!==e)return e.exports;var a=s[t]={exports:{}};return i[t](a,a.exports,r),a.exports}r.m=i,t=[],r.O=(e,i,s,a)=>{if(!i){var l=1/0;for(h=0;h<t.length;h++){for(var[i,s,a]=t[h],d=!0,o=0;o<i.length;o++)(!1&a||l>=a)&&Object.keys(r.O).every(t=>r.O[t](i[o]))?i.splice(o--,1):(d=!1,a<l&&(l=a));if(d){t.splice(h--,1);var n=s();void 0!==n&&(e=n)}}return e}a=a||0;for(var h=t.length;h>0&&t[h-1][2]>a;h--)t[h]=t[h-1];t[h]=[i,s,a]},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);export{r as __webpack_require__};e={3079:0},r.C=t=>{var i,s,{__webpack_esm_ids__:a,__webpack_esm_modules__:l,__webpack_esm_runtime__:d}=t,o=0;for(i in l)r.o(l,i)&&(r.m[i]=l[i]);for(d&&d(r);o<a.length;o++)s=a[o],r.o(e,s)&&e[s]&&e[s][0](),e[a[o]]=0;r.O()},r.O.j=t=>0===e[t];import*as a from"../9609.js";r.C(a);import*as l from"../4084.js";r.C(l);import*as d from"../519.js";r.C(d);import*as o from"../4137.js";r.C(o);import*as n from"../2927.js";r.C(n);import*as h from"../8441.js";r.C(h);import*as c from"../9983.js";r.C(c);import*as p from"../1982.js";r.C(p);var u=r.O(void 0,[9609,4084,519,4137,2927,8441,9983,1982],()=>r(9236));const v=(u=r.O(u)).L;export{v as AdvanceList};