import {
  MembersList_default
} from "./chunk-3JYSN6ZG.mjs";
import {
  NUMBER_OF_MEMBERS_ON_FIRST_LOAD
} from "./chunk-2WMKN4WI.mjs";
import {
  UserMembersListPaginationQuery
} from "./chunk-PHVFV76U.mjs";

// tmp-babel/profiles/web/ProfileMembers/index.js
import { Suspense } from "react";
import { useCurrentProfile } from "@baseapp-frontend/authentication";
import { LoadingState as DefaultLoadingState } from "@baseapp-frontend/design-system/components/web/displays";
import { Typography } from "@mui/material";
import { useLazyLoadQuery } from "react-relay";
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
var _excluded = ["title", "subtitle", "InitialLoadingState"];
function _typeof(o) {
  "@babel/helpers - typeof";
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
    return typeof o2;
  } : function(o2) {
    return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
  }, _typeof(o);
}
function _objectWithoutProperties(e, t) {
  if (null == e) return {};
  var o, r, i = _objectWithoutPropertiesLoose(e, t);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(e);
    for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
  }
  return i;
}
function _objectWithoutPropertiesLoose(r, e) {
  if (null == r) return {};
  var t = {};
  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
    if (-1 !== e.indexOf(n)) continue;
    t[n] = r[n];
  }
  return t;
}
function ownKeys(e, r) {
  var t = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var o = Object.getOwnPropertySymbols(e);
    r && (o = o.filter(function(r2) {
      return Object.getOwnPropertyDescriptor(e, r2).enumerable;
    })), t.push.apply(t, o);
  }
  return t;
}
function _objectSpread(e) {
  for (var r = 1; r < arguments.length; r++) {
    var t = null != arguments[r] ? arguments[r] : {};
    r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
      _defineProperty(e, r2, t[r2]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
      Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
    });
  }
  return e;
}
function _defineProperty(e, r, t) {
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
}
function _toPropertyKey(t) {
  var i = _toPrimitive(t, "string");
  return "symbol" == _typeof(i) ? i : i + "";
}
function _toPrimitive(t, r) {
  if ("object" != _typeof(t) || !t) return t;
  var e = t[Symbol.toPrimitive];
  if (void 0 !== e) {
    var i = e.call(t, r || "default");
    if ("object" != _typeof(i)) return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return ("string" === r ? String : Number)(t);
}
var ProfileMembers = function ProfileMembers2(_ref) {
  var _ref$MembersListProps = _ref.MembersListProps, MembersListProps = _ref$MembersListProps === void 0 ? {} : _ref$MembersListProps;
  var _useCurrentProfile = useCurrentProfile(), currentProfile = _useCurrentProfile.currentProfile;
  var data = useLazyLoadQuery(UserMembersListPaginationQuery, {
    profileId: (currentProfile === null || currentProfile === void 0 ? void 0 : currentProfile.id) || "",
    count: NUMBER_OF_MEMBERS_ON_FIRST_LOAD,
    orderBy: "status"
  });
  if (!data.profile) return null;
  return /* @__PURE__ */ _jsx(MembersList_default, _objectSpread({
    userRef: data === null || data === void 0 ? void 0 : data.profile
  }, MembersListProps));
};
var ProfileMembersSuspended = function ProfileMembersSuspended2(_ref2) {
  var _ref2$title = _ref2.title, title = _ref2$title === void 0 ? "Members" : _ref2$title, subtitle = _ref2.subtitle, _ref2$InitialLoadingS = _ref2.InitialLoadingState, InitialLoadingState = _ref2$InitialLoadingS === void 0 ? DefaultLoadingState : _ref2$InitialLoadingS, props = _objectWithoutProperties(_ref2, _excluded);
  return /* @__PURE__ */ _jsxs(_Fragment, {
    children: [/* @__PURE__ */ _jsx(Typography, {
      component: "h4",
      variant: "h4",
      mb: 1,
      children: title
    }), /* @__PURE__ */ _jsx(Typography, {
      component: "p",
      variant: "body2",
      color: "text.secondary",
      mb: 4,
      children: subtitle
    }), /* @__PURE__ */ _jsx(Suspense, {
      fallback: /* @__PURE__ */ _jsx(InitialLoadingState, {
        CircularProgressProps: {
          size: 20
        }
      }),
      children: /* @__PURE__ */ _jsx(ProfileMembers, _objectSpread({}, props))
    })]
  });
};
var ProfileMembers_default = ProfileMembersSuspended;

export {
  ProfileMembers_default
};
//# sourceMappingURL=chunk-LGBWOBBL.mjs.map