"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxDevRuntime = require("react/jsx-dev-runtime");
const ui = require("@contember/ui");
const react = require("react");
const reactBindingUi = require("@contember/react-binding-ui");
const RoleRenderer = require("./RoleRenderer.cjs");
const useRemoveMemberIntent = require("./useRemoveMemberIntent.cjs");
const IdentityMembership = require("./IdentityMembership.cjs");
const QueryLoader = require("../QueryLoader.cjs");
const listUsers = require("../../queries/listUsers.cjs");
const LinkButton = require("../../../routing/LinkButton.cjs");
const MemberList = react.memo(
  ({ project, createRoleRenderer, editIdentityLink, Identity, memberType }) => {
    const { state: query, refetch: refetchMembersList } = listUsers.useListMembersQuery(project, memberType);
    const removeMember = useRemoveMemberIntent.useRemoveMemberIntent(project, refetchMembersList);
    const RoleRenderer$1 = RoleRenderer.useRoleRenderer(createRoleRenderer, query);
    return /* @__PURE__ */ jsxDevRuntime.jsxDEV(QueryLoader.QueryLoader, { query, children: ({ query: query2 }) => {
      if (query2.data.project.members.length === 0) {
        return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBindingUi.EmptyMessage, { children: "No members" }, void 0, false, {
          fileName: "/__w/interface/interface/packages/admin/src/tenant/components/member/MemberList.tsx",
          lineNumber: 32,
          columnNumber: 13
        }, void 0);
      }
      return /* @__PURE__ */ jsxDevRuntime.jsxDEV(ui.SpinnerContainer, { enabled: !RoleRenderer$1, children: RoleRenderer$1 && /* @__PURE__ */ jsxDevRuntime.jsxDEV(ui.Table, { bare: true, children: query2.data.project.members.map((member) => {
        return /* @__PURE__ */ jsxDevRuntime.jsxDEV(ui.TableRow, { children: [
          /* @__PURE__ */ jsxDevRuntime.jsxDEV(ui.TableCell, { children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(Identity, { identity: member.identity }, void 0, false, {
            fileName: "/__w/interface/interface/packages/admin/src/tenant/components/member/MemberList.tsx",
            lineNumber: 43,
            columnNumber: 13
          }, void 0) }, void 0, false, {
            fileName: "/__w/interface/interface/packages/admin/src/tenant/components/member/MemberList.tsx",
            lineNumber: 42,
            columnNumber: 12
          }, void 0),
          /* @__PURE__ */ jsxDevRuntime.jsxDEV(ui.TableCell, { children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(IdentityMembership.IdentityMembership, { RoleRenderer: RoleRenderer$1, memberships: member.memberships }, void 0, false, {
            fileName: "/__w/interface/interface/packages/admin/src/tenant/components/member/MemberList.tsx",
            lineNumber: 46,
            columnNumber: 13
          }, void 0) }, void 0, false, {
            fileName: "/__w/interface/interface/packages/admin/src/tenant/components/member/MemberList.tsx",
            lineNumber: 45,
            columnNumber: 12
          }, void 0),
          /* @__PURE__ */ jsxDevRuntime.jsxDEV(ui.TableCell, { shrunk: true, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(LinkButton.LinkButton, { size: "small", to: editIdentityLink, parameters: { identityId: member.identity.id, projectSlug: project }, children: "Edit roles" }, void 0, false, {
            fileName: "/__w/interface/interface/packages/admin/src/tenant/components/member/MemberList.tsx",
            lineNumber: 49,
            columnNumber: 13
          }, void 0) }, void 0, false, {
            fileName: "/__w/interface/interface/packages/admin/src/tenant/components/member/MemberList.tsx",
            lineNumber: 48,
            columnNumber: 12
          }, void 0),
          /* @__PURE__ */ jsxDevRuntime.jsxDEV(ui.TableCell, { shrunk: true, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(ui.Button, { size: "small", intent: "danger", onClick: () => removeMember(member.identity.id), children: "Revoke access" }, void 0, false, {
            fileName: "/__w/interface/interface/packages/admin/src/tenant/components/member/MemberList.tsx",
            lineNumber: 54,
            columnNumber: 13
          }, void 0) }, void 0, false, {
            fileName: "/__w/interface/interface/packages/admin/src/tenant/components/member/MemberList.tsx",
            lineNumber: 53,
            columnNumber: 12
          }, void 0)
        ] }, member.identity.id, true, {
          fileName: "/__w/interface/interface/packages/admin/src/tenant/components/member/MemberList.tsx",
          lineNumber: 41,
          columnNumber: 11
        }, void 0);
      }) }, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/tenant/components/member/MemberList.tsx",
        lineNumber: 38,
        columnNumber: 8
      }, void 0) }, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/tenant/components/member/MemberList.tsx",
        lineNumber: 36,
        columnNumber: 6
      }, void 0);
    } }, void 0, false, {
      fileName: "/__w/interface/interface/packages/admin/src/tenant/components/member/MemberList.tsx",
      lineNumber: 29,
      columnNumber: 3
    }, void 0);
  }
);
exports.MemberList = MemberList;
//# sourceMappingURL=MemberList.cjs.map
