import{p as n,j as t,k as z}from"./JQJBiNWj.js";import{u as b}from"./F98GHXdS.js";import{u as h}from"./DvBDpJyt.js";function R(v,g,e){const y=n(),r=t(0),l=t((e==null?void 0:e.initialRows)??10),u=t([]),c=t(!1),f=b(v,async()=>{var d;c.value=!0;const a=((d=e==null?void 0:e.filters)==null?void 0:d.value)||{},s=await g({page:r.value,size:l.value,sort:u.value??void 0,...a});return s?(r.value=s.number??0,l.value=s.size,s):m()},{default:()=>m(),lazy:!0,...e,watch:[r,u,l,...(e==null?void 0:e.watch)||[]]});z(()=>{var a;return(a=e==null?void 0:e.filters)==null?void 0:a.value},()=>{e!=null&&e.filters&&(r.value!==0?r.value=0:f.refresh())},{immediate:!1});function w(a){r.value=a.page,l.value=a.rows}function i(a){r.value=0,u.value=a.sortField?[a.sortField+","+(a.sortOrder===1?"asc":"desc")]:[]}return h(f.error,a=>{y.add({severity:"error",life:1e4,summary:(e==null?void 0:e.errorMessage)||"Erro ao buscar items.",detail:a.message})}),{...f,page:r,size:l,sort:u,updatePageable:w,updateSortable:i,initialRows:e==null?void 0:e.initialRows,executed:c}}function m(){return{content:[],size:0,totalElements:0,totalPages:0,number:0,numberOfElements:0,first:!1,last:!1,empty:!1,pageable:{sort:{sorted:!1,unsorted:!1,empty:!1},offset:0,pageNumber:0,pageSize:0,unpaged:!1,paged:!1},sort:{sorted:!1,unsorted:!1,empty:!1}}}export{m as c,R as u};
