"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const reactClient = require("@contember/react-client");
const react = require("react");
const MemberList = require("../member/MemberList.cjs");
const UsersList = react.memo(({ editUserLink, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
  MemberList.MemberList,
  {
    ...props,
    editIdentityLink: editUserLink,
    memberType: "PERSON",
    Identity: ({ identity }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: identity.person ? identity.person.email : "?" })
  }
));
const useRoleRendererFactory = ({ rolesDataQuery, roleRenderers }) => {
  const contentClient = reactClient.useCurrentContentGraphQlClient();
  return react.useCallback(async () => {
    const rolesData = rolesDataQuery ? await contentClient.sendRequest(rolesDataQuery) : void 0;
    return ({ role, variables }) => {
      if (!roleRenderers) {
        return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: role });
      }
      const Renderer = roleRenderers?.[role];
      if (!Renderer) {
        return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
          "Unknown role ",
          role
        ] });
      }
      return /* @__PURE__ */ jsxRuntime.jsx(Renderer, { rolesData, variables });
    };
  }, [contentClient, roleRenderers, rolesDataQuery]);
};
exports.UsersList = UsersList;
exports.useRoleRendererFactory = useRoleRendererFactory;
//# sourceMappingURL=UsersList.cjs.map
