import{i as e,o as t,r as n,t as r}from"./button-DJ30HgDO.js";import{S as i,y as a}from"./free-solid-svg-icons-CttZC1b4.js";var o=t(e(),1);function s(){let[e,t]=(0,o.useState)(``),[n,r]=(0,o.useState)(``);return{searchTerm:e,submittedTerm:n,handleInputChange:(0,o.useCallback)(e=>{t(e.target.value)},[]),handleSearchSubmit:(0,o.useCallback)(t=>{t.preventDefault(),r(e)},[e]),handleClearSearch:(0,o.useCallback)(()=>{t(``),r(``)},[])}}var c=t(n(),1);const l=({value:e,onInputChange:t,onSubmit:n,onClear:s,placeholder:l=`Search...`,...u})=>{let d=e.length>0,f=(0,o.useCallback)(()=>{s()},[s]);return(0,c.jsxs)(`form`,{onSubmit:n,className:`shrink-0 flex h-8 rounded border text-sm mb-1 mt-2
      border-text-primary-hover dark:border-text-primary-hover-dark
      bg-ui-bg dark:bg-ui-bg-dark overflow-hidden relative`,style:{minWidth:`100px`,maxWidth:`250px`},children:[(0,c.jsx)(`input`,{type:`text`,value:e,onChange:t,placeholder:l,name:`searchTerm`,className:`grow min-w-0 px-3 py-1 text-ui-text dark:text-ui-text-dark bg-ui-bg
          dark:bg-ui-bg-dark placeholder-text-primary dark:placeholder-text-primary-dark focus:outline-none pr-8`,...u}),d&&(0,c.jsx)(r,{variant:`ghost`,onClick:f,title:`Clear search`,className:`h-full w-8 rounded-none shrink-0 hover:bg-transparent dark:hover:bg-transparent hover:text-btn-secondary-text-hover dark:hover:text-btn-secondary-text-hover-dark absolute right-8 top-0`,icon:i}),(0,c.jsx)(r,{type:`submit`,title:`Search`,variant:`ghost`,className:`h-full w-8 rounded-none border-l border-text-primary-hover dark:border-text-primary-hover-dark`,icon:a})]})};function u({columns:e}){return(0,c.jsx)(`div`,{role:`rowgroup`,className:`shrink-0`,children:(0,c.jsx)(`div`,{role:`row`,className:`flex items-center h-(--table-row-height) border-b
          border-btn-secondary-border dark:border-btn-secondary-border-dark
          font-semibold text-left`,children:e.map((e,t)=>(0,c.jsx)(`div`,{role:`columnheader`,className:`px-1 flex-1 min-w-0 truncate ${e.className||``}`,children:e.header},e.id||(typeof e.header==`string`?e.header:t)))})})}function d({searchTerm:e}){return(0,c.jsx)(`p`,{className:`text-btn-secondary-text dark:text-btn-secondary-text-dark italic p-4`,children:e?`No items found for "${e}"`:`No items found`})}function f(){return(0,c.jsx)(`div`,{id:`pagination-footer`,className:`flex-shrink-0 italic text-right pt-2`,children:`placeholder for pagination`})}function p(e){let{item:t,columns:n,fallbackKey:r}=e,i=t.id??r;return(0,c.jsx)(`div`,{role:`row`,className:`flex items-center h-(--table-row-height) border-b group
              border-btn-secondary-border dark:border-btn-secondary-border-dark
              hover:bg-table-row-hover dark:hover:bg-table-row-hover `,children:n.map((e,n)=>(0,c.jsx)(`div`,{role:`cell`,className:`px-1 flex-1 min-w-0 truncate ${e.className||``}`,children:e.render(t)},e.id||(typeof e.header==`string`?e.header:n)))},i)}function m(e){let{data:t,columns:n,searchTerm:r}=e;return(0,c.jsxs)(`div`,{role:`table`,className:`flex flex-col flex-1 overflow-hidden text-sm`,children:[(0,c.jsx)(u,{columns:n}),(0,c.jsx)(`div`,{role:`rowgroup`,className:`flex-1 overflow-y-auto`,children:t.length>0?t.map((e,t)=>(0,c.jsx)(p,{item:e,columns:n,fallbackKey:t,index:t},e.id??t)):(0,c.jsx)(d,{searchTerm:r})}),(0,c.jsx)(f,{})]})}function h({isLoading:e,loadingText:t,error:n,onRetry:i}){return e?(0,c.jsx)(`div`,{className:`flex h-full justify-center items-center p-8`,children:(0,c.jsx)(`p`,{className:`text-lg font-medium animate-pulse text-text-primary dark:text-text-primary-dark`,children:t??`Loading...`})}):n?(0,c.jsxs)(`div`,{className:`flex flex-wrap h-full justify-center content-center items-center gap-4 text-status-danger dark:text-status-danger-dark p-8`,children:[(0,c.jsx)(`p`,{className:`text-xl font-medium`,children:`Error: ${n.message}`}),i&&(0,c.jsx)(r,{variant:`danger`,onClick:i,children:`Try Again`})]}):null}export{s as i,m as n,l as r,h as t};