'use client';
import { jsx as s, jsxs as v, Fragment as H } from "react/jsx-runtime";
import F, { useCallback as l } from "react";
import { Modal as K, ModalContent as L, ModalHeader as R, Button as X, ModalBody as A } from "@heroui/react";
import { XMarkIcon as G } from "@heroicons/react/24/outline";
import { SignUpForm as J } from "./sign-up-form.js";
import { useConfig as O } from "../../../hooks/use-config.js";
function _({
  isOpen: i = !1,
  onClose: e,
  modalSize: o = "md",
  closeOnBackdropClick: r = !0,
  closeOnEscape: m = !0,
  modalClassName: c = "",
  showCloseButton: n = !0,
  methods: a = ["password", "oauth", "magic-link"],
  email: g,
  organizationId: N,
  invitationToken: z,
  redirectUrl: u,
  onSuccess: h,
  onError: w,
  title: d,
  subtitle: f,
  size: M = "md",
  showBranding: y = !0,
  disabled: t = !1,
  requireTerms: S = !0,
  termsUrl: B = "/terms",
  privacyUrl: b = "/privacy",
  backdrop: D = "blur",
  placement: P = "center"
}) {
  const { components: I } = O(), j = I.SignUpModal;
  if (j)
    return /* @__PURE__ */ s(j, { isOpen: i, onClose: e, modalSize: o, closeOnBackdropClick: r, closeOnEscape: m, modalClassName: c, showCloseButton: n, methods: a, email: g, organizationId: N, invitationToken: z, redirectUrl: u, onSuccess: h, onError: w, title: d, subtitle: f, size: M, showBranding: y, disabled: t, requireTerms: S, termsUrl: B, privacyUrl: b, backdrop: D, placement: P });
  const $ = l((p) => {
    h?.(p), u || setTimeout(() => {
      e?.();
    }, 2e3);
  }, [h, e, u]), k = l(() => {
    t || e?.();
  }, [e, t]), x = (() => {
    switch (o) {
      case "sm":
        return {
          size: "sm",
          className: "max-w-sm max-h-[90vh]",
          scrollBehavior: "inside"
        };
      case "md":
        return {
          size: "md",
          className: "max-w-md max-h-[90vh]",
          scrollBehavior: "inside"
        };
      case "lg":
        return {
          size: "lg",
          className: "max-w-lg max-h-[90vh]",
          scrollBehavior: "inside"
        };
      case "xl":
        return {
          size: "xl",
          className: "max-w-xl max-h-[90vh]",
          scrollBehavior: "inside"
        };
      case "full":
        return {
          size: "full",
          className: "max-w-full h-full",
          scrollBehavior: "outside"
        };
      default:
        return {
          size: "md",
          className: "max-w-md max-h-[90vh]",
          scrollBehavior: "inside"
        };
    }
  })();
  return /* @__PURE__ */ s(
    K,
    {
      isOpen: i,
      onClose: k,
      size: x.size,
      backdrop: D,
      placement: P,
      scrollBehavior: x.scrollBehavior,
      closeButton: !1,
      isDismissable: r && !t,
      isKeyboardDismissDisabled: !m || t,
      className: `${c}`,
      classNames: {
        wrapper: "z-[9999]",
        backdrop: "z-[9998]",
        base: `${x.className}`,
        body: "px-0 py-0"
      },
      children: /* @__PURE__ */ s(L, { children: (p) => /* @__PURE__ */ v(H, { children: [
        /* @__PURE__ */ v(R, { className: "flex items-center justify-between px-6 py-4 border-b border-divider", children: [
          /* @__PURE__ */ v("div", { className: "flex-1", children: [
            d && /* @__PURE__ */ s("h2", { className: "text-lg font-semibold text-foreground", children: d }),
            f && /* @__PURE__ */ s("p", { className: "text-sm text-default-500 mt-1", children: f })
          ] }),
          n && /* @__PURE__ */ s(
            X,
            {
              isIconOnly: !0,
              variant: "light",
              size: "sm",
              onPress: p,
              className: "text-default-400 hover:text-default-600 -mr-2",
              isDisabled: t,
              children: /* @__PURE__ */ s(G, { className: "w-4 h-4" })
            }
          )
        ] }),
        /* @__PURE__ */ s(A, { children: /* @__PURE__ */ s("div", { className: "px-6 py-6", children: /* @__PURE__ */ s(
          J,
          {
            methods: a,
            email: g,
            organizationId: N,
            invitationToken: z,
            redirectUrl: u,
            onSuccess: $,
            onError: w,
            title: void 0,
            subtitle: void 0,
            size: M,
            showBranding: y,
            disabled: t,
            requireTerms: S,
            termsUrl: B,
            privacyUrl: b,
            variant: "minimal",
            className: "space-y-4",
            showSignInLink: !0,
            autoFocus: !0
          }
        ) }) })
      ] }) })
    }
  );
}
function q() {
  const [i, e] = F.useState(!1), [o, r] = F.useState({}), m = l((a) => {
    a && r(a), e(!0);
  }, []), c = l(() => {
    e(!1), setTimeout(() => {
      r({});
    }, 300);
  }, []), n = l(() => e((a) => !a), []);
  return {
    isOpen: i,
    open: m,
    close: c,
    toggle: n,
    setIsOpen: e,
    modalData: o,
    setModalData: r
  };
}
export {
  _ as SignUpModal,
  q as useSignUpModal
};
//# sourceMappingURL=sign-up-modal.js.map
