function e(e,t){e.preventDefault(),e.stopPropagation();const{minWidth:n=50,startX:i,startWidth:o,element:l}=t,r=e.target;r.classList.add("resizing");const a=e=>{e.preventDefault(),e.stopPropagation();const t=e.pageX-i,r=Math.max(n,o+t);l.style.width=r+"px",function(e,t){const n=e.closest("nile-table-body");if(!n)return;const i="nile-table-header-item"===e.tagName.toLowerCase(),o="nile-table-cell-item",l=function(e,t){const n=e.closest("nile-table-row");if(n){const i=n.querySelectorAll(t);return Array.from(i).indexOf(e)}return 0}(e,i?"nile-table-header-item":"nile-table-cell-item");n.querySelectorAll("nile-table-row").forEach((e=>{const n=e.querySelectorAll(o);n[l]&&(n[l].style.width=t+"px")}))}(l,r)},c=()=>{r.classList.remove("resizing"),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",c)};return document.addEventListener("mousemove",a),document.addEventListener("mouseup",c),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",c)}}function t(e){const t=e.querySelectorAll("nile-table-header-item"),n=e.querySelectorAll("nile-table-cell-item");t.forEach((e=>{e.style.removeProperty("width")})),n.forEach((e=>{e.style.removeProperty("width")}))}function n(t,n=50){return i=>{e(i,{minWidth:n,startX:i.pageX,startWidth:t.offsetWidth,element:t})}}function i(e){const t=Array.from(e.children),n=t.some((e=>"nile-table-header-item"===e.tagName.toLowerCase()&&e.hasAttribute("resizable"))),i=t.some((e=>"nile-table-cell-item"===e.tagName.toLowerCase()&&e.hasAttribute("resizable")));return n||i}export{n as c,i as h,t as r};
