import{r as t,c as e,h as o,H as r,g as a}from"./p-0b541f88.js";const s=":host{--color-background-default:var(--pine-color-white);background:var(--color-background-default);border-collapse:separate;-webkit-box-sizing:border-box;box-sizing:border-box;display:table;width:100%}:host(:focus-visible){--box-shadow-focus:0 0 0 1px #ffffff, 0 0 0 3px var(--pine-color-purple-300);-webkit-box-shadow:var(--box-shadow-focus);box-shadow:var(--box-shadow-focus);outline:none}:host(.is-responsive){background-attachment:local, local, scroll, scroll;background-image:-webkit-gradient(linear, left top, right top, from(var(--color-background-default)), to(var(--color-background-default))), -webkit-gradient(linear, left top, right top, from(var(--color-background-default)), to(var(--color-background-default))), -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, 0.1)), to(rgba(255, 255, 255, 0))), -webkit-gradient(linear, right top, left top, from(rgba(0, 0, 0, 0.1)), to(rgba(255, 255, 255, 0)));background-image:linear-gradient(to right, var(--color-background-default), var(--color-background-default)), linear-gradient(to right, var(--color-background-default), var(--color-background-default)), linear-gradient(to right, rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0)), linear-gradient(to left, rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0));background-position:left center, right center, left center, right center;background-repeat:no-repeat;background-size:4px 100%, 4px 100%, 4px 100%, 4px 100%;display:block;margin:0 auto;max-width:-webkit-fit-content;max-width:-moz-fit-content;max-width:fit-content;overflow-x:auto;white-space:nowrap}";const n=s;const i=class{constructor(o){t(this,o);this.pdsTableSelect=e(this,"pdsTableSelect",7);this.pdsTableSelectAll=e(this,"pdsTableSelectAll",7);this.compact=undefined;this.componentId=undefined;this.responsive=undefined;this.fixedColumn=undefined;this.selectable=undefined;this.sortingColumn=null;this.sortingDirection="asc"}componentWillLoad(){this.sortingColumn=null}classNames(){const t=["pds-table"];if(this.compact){t.push("is-compact")}if(this.responsive){t.push("is-responsive")}return t.join("  ")}sortTable(t,e){const o=this.el.querySelector("pds-table-body");const r=Array.from(o.querySelectorAll("pds-table-row"));const a=Array.from(this.el.querySelectorAll("pds-table-head-cell[sortable]"));const s=a.find((e=>e.innerText.trim()===t));if(!s){console.warn(`Column "${t}" not found.`);return}const n=a.indexOf(s);r.sort(((t,o)=>{const r=t.querySelector(`pds-table-cell:nth-child(${n+1})`).textContent.trim();const a=o.querySelector(`pds-table-cell:nth-child(${n+1})`).textContent.trim();if(e==="asc"){return r.localeCompare(a)}else{return a.localeCompare(r)}}));o.innerHTML="";r.forEach((t=>{o.appendChild(t)}))}handleTableSort(t){const{direction:e}=t.detail;this.sortTable(t.detail.column,e);this.sortingColumn=t.detail.column;this.sortingDirection=e}handleTableSelectAll(t){if(t.defaultPrevented)return;const e=this.el.querySelector("pds-table-body");const o=Array.from(e.querySelectorAll("pds-table-row"));o.forEach((e=>{e.isSelected=t.detail.isSelected}))}async handleTableSelect(t){if(t.defaultPrevented)return;const e=this.el.querySelectorAll("pds-table-row");const o=Array.from(e).every((t=>t.isSelected));const r=Array.from(e).every((t=>!t.isSelected));const a=this.el.querySelector("pds-table-head");if(!a)return;const s=a.shadowRoot.querySelector("pds-checkbox");s.checked=o;s.indeterminate=!o&&!r}render(){return o(r,{key:"95cc4db296681faa0fc046c9b1d6807d640b7730",class:this.classNames(),id:this.componentId,role:"grid",selectable:this.selectable,tabindex:"0"},o("slot",{key:"ecc9bc0761409d5a2819a05d72290c294e27454f"}))}get el(){return a(this)}};i.style=n;export{i as pds_table};
//# sourceMappingURL=p-c6c2433a.entry.js.map