import { jsx, Fragment, jsxs } from "react/jsx-runtime";
import { useCurrentContentGraphQlClient } from "@contember/react-client";
import { memo, useCallback } from "react";
import { MemberList } from "../member/MemberList.js";
const UsersList = memo(({ editUserLink, ...props }) => /* @__PURE__ */ jsx(
  MemberList,
  {
    ...props,
    editIdentityLink: editUserLink,
    memberType: "PERSON",
    Identity: ({ identity }) => /* @__PURE__ */ jsx(Fragment, { children: identity.person ? identity.person.email : "?" })
  }
));
const useRoleRendererFactory = ({ rolesDataQuery, roleRenderers }) => {
  const contentClient = useCurrentContentGraphQlClient();
  return useCallback(async () => {
    const rolesData = rolesDataQuery ? await contentClient.sendRequest(rolesDataQuery) : void 0;
    return ({ role, variables }) => {
      if (!roleRenderers) {
        return /* @__PURE__ */ jsx(Fragment, { children: role });
      }
      const Renderer = roleRenderers?.[role];
      if (!Renderer) {
        return /* @__PURE__ */ jsxs(Fragment, { children: [
          "Unknown role ",
          role
        ] });
      }
      return /* @__PURE__ */ jsx(Renderer, { rolesData, variables });
    };
  }, [contentClient, roleRenderers, rolesDataQuery]);
};
export {
  UsersList,
  useRoleRendererFactory
};
//# sourceMappingURL=UsersList.js.map
