import{ensureArrayQueryFilter as e}from"../ensureArrayQueryFilter.mjs";import{getFiltersAndPaginationFromBody as t}from"./getFiltersAndPaginationFromBody.mjs";const n=(n,r)=>{let{filters:i,...a}=t(n),{roles:o,organization:s}=r?.locals||n.locals||{},c={},l={updatedAt:-1},{name:u,search:d,ids:f,organizationId:p,membersIds:m,sortBy:h,sortOrder:g,fetchAll:_}=i??{};if(f&&(c={...c,_id:{$in:e(f)}}),u&&(c={...c,name:new RegExp(u,`i`)}),d){let e=new RegExp(d,`i`);c={...c,$or:[{name:e}]}}return p&&(c={...c,organizationId:p}),m&&(c={...c,membersIds:{$in:e(m)}}),h&&g&&(g===`asc`||g===`desc`)&&(l={[h]:g===`asc`?1:-1}),o.includes(`admin`)&&_===`true`||(c={...c,organizationId:s?.id}),{filters:c,sortOptions:l,...a}};export{n as getProjectFiltersAndPagination};
//# sourceMappingURL=getProjectFiltersAndPagination.mjs.map