import{O as j,Q as p,P as i,dR as L,dS as y,r as o,aK as T,cH as v,j as a,a as r,bG as d,L as G,aH as R,bH as M}from"./index-_eM6l4Nf.js";import{c as q}from"./index-HeUA1Nop.js";const A=j.injectEndpoints({endpoints:s=>({getMappings:s.query({query:()=>({url:"/admin/group/mapping?sort_by=id"}),transformResponse:e=>(e==null?void 0:e.count)>0?e.items:[],providesTags:p.providesList(i.AdminProjectMappingTags.Mapping)}),getMapping:s.query({query:({id:e})=>({url:`/admin/group/mapping/${e}`}),providesTags:p.cacheByIdArgProperty(i.AdminProjectMappingTags.Mapping)}),updateMapping:s.mutation({query:({id:e,data:t})=>({url:`/admin/group/mapping/${e}`,method:"put",data:t}),invalidatesTags:p.invalidatesList(i.AdminProjectMappingTags.Mapping)}),createMapping:s.mutation({query:({data:e})=>({url:"/admin/group/mapping",method:"post",data:e}),invalidatesTags:p.invalidatesList(i.AdminProjectMappingTags.Mapping)}),createMappingBulk:s.mutation({query:({data:e})=>({url:"/admin/group/mapping/bulk",method:"post",data:e}),invalidatesTags:p.invalidatesList(i.AdminProjectMappingTags.Mapping)}),deleteMapping:s.mutation({query:({id:e})=>({url:`/admin/group/mapping/${e}`,method:"delete"}),invalidatesTags:p.invalidatesList(i.AdminProjectMappingTags.Mapping)})})}),{useGetMappingsQuery:I,useUpdateMappingMutation:H,useCreateMappingBulkMutation:E,useDeleteMappingMutation:O}=A,f=L.injectEndpoints({endpoints:s=>({getRemoteGroups:s.query({query:(e="")=>({url:`/mapping/search?query=${encodeURIComponent(e)}`}),providesTags:p.providesList(y.RemoteProjectMappingTags.Groups)}),getRemoteGroupMembers:s.query({query:({groups:e})=>({url:"/mapping/members",query:e}),providesTags:p.providesList(y.RemoteProjectMappingTags.Members)})})}),{useGetRemoteGroupsQuery:k}=f,P=({isEdit:s,value:e,onChange:t,...n})=>{const[g,u]=o.useState(""),c=T(g,500),{data:m=[],isFetching:l}=k(c),{data:h,isLoading:F}=v("ldap_groups_search_filter");return o.useLayoutEffect(()=>{u(h??"")},[h]),a.jsxs(r,{flexDirection:"column",children:[a.jsx(d,{mb:"10px",children:"Remote groups"}),a.jsxs(r,{mb:"20px",alignItems:"center",children:[a.jsx(G,{mr:"10px",width:"400px",children:a.jsx(R,{placeholder:"filter query",value:g,onChange:x=>u(x.target.value),width:"100%"})}),a.jsx(d,{width:"30px",children:"->"}),a.jsx(M,{isMulti:!s,noDataMessage:"No group found",value:e,options:m,placeholder:"pick remote groups",isLoading:l,preventAdding:!0,onChange:t,...n},`key-${e}`)]})]})},S=o.memo(P),b=({isEdit:s,value:e,onChange:t,...n})=>a.jsxs(r,{flexDirection:"column",children:[a.jsx(d,{mb:"10px",children:"Remote groups"}),a.jsx(r,{mb:"20px",alignItems:"center",children:a.jsx(M,{isMulti:!s,noDataMessage:"you have to add groups manually",value:e,options:[],placeholder:"pick remote groups",isLoading:!1,onChange:t,...n},`key-${e}`)})]}),U=o.memo(b),$=({isEdit:s,value:e,onChange:t,...n})=>{const{data:g,isLoading:u}=q(),c=m=>m?m.map(l=>l.groupName):[];return a.jsxs(r,{flexDirection:"column",children:[a.jsx(d,{mb:"10px",children:"Groups"}),a.jsx(r,{mb:"20px",alignItems:"center",children:a.jsx(M,{isMulti:!s,noDataMessage:"No group found",value:e,options:c(g),placeholder:"pick groups",isLoading:u,preventAdding:!0,onChange:t,...n},`key-${e}`)})]})},_=o.memo($);export{_ as H,S as L,U as O,O as a,I as b,E as c,H as u};
