import{j as C}from"./index.ed1fc0db.js";import{u as K}from"./ScrollTo.81bea8a7.js";import{Z as t,X as M,g as U}from"./runtime-core.esm-bundler.4f558f23.js";const q=(h={})=>{const{changeItemsPerPageSlug:c,fetchData:P,orderBy:b,orderDir:y,pageNumber:T,resetSelectedFilters:_=()=>{},resultsPerPage:m,selectedFilters:S,slug:D,tableId:F,tableRef:i,wpTableLoading:L}=h,v=t("all"),o=b||t(null),f=y||t(null),a=T||t(1),s=t(m||20),u=t(null),g=S||t(null),x=t(0),l=L||t(!1),p=C(),A=K().scrollTo,B=()=>(l.value=!0,r().then(()=>{l.value=!1,i==null||i.editRow(null)})),I=({filters:e,term:n=null,number:W=null})=>{l.value=!0,g.value=e,u.value=n??u.value,a.value=W??a.value,r(e).then(()=>l.value=!1)},w=e=>{var n;typeof e=="object"&&(e=(n=e==null?void 0:e.target)==null?void 0:n.value),a.value=1,u.value=e,l.value=!0,r().then(()=>l.value=!1)},j=e=>{a.value=e,l.value=!0,r().then(()=>l.value=!1)},N=e=>{v.value=e.slug,u.value=null,a.value=1,l.value=!0,_(),r().then(()=>l.value=!1)},O=e=>{a.value=1,s.value=e,l.value=!0,p.changeItemsPerPage({slug:c,value:e}).then(()=>r().then(()=>A(F))).then(()=>l.value=!1)},R=(e,n)=>(n.target.blur(),o.value=e.slug,f.value=o.value!==e.slug?e.sortDir:e.sortDir==="asc"?"desc":"asc",l.value=!0,r().then(()=>l.value=!1)),d=M(()=>a.value===1?0:(a.value-1)*s.value),r=(e=g.value)=>P({slug:D,orderBy:o.value,orderDir:f.value,limit:s.value,offset:d.value,searchTerm:u.value,filter:v.value,additionalFilters:e});return U(()=>{c&&(s.value=p.settings.tablePagination[c]||s.value)}),{filter:v,offset:d,orderBy:o,orderDir:f,pageNumber:a,processAdditionalFilters:I,processChangeItemsPerPage:O,processFetchTableData:r,processFilterTable:N,processPagination:j,processSearch:w,processSort:R,refreshTable:B,resultsPerPage:s,searchTerm:u,selectedFilters:g,wpTableKey:x,wpTableLoading:l}};export{q as u};
