'use client';
import { jsx as s, jsxs as d, Fragment as O } from "react/jsx-runtime";
import Q, { useCallback as t } from "react";
import { Modal as T, ModalContent as V, ModalHeader as W, Button as Y, ModalBody as Z, ModalFooter as _ } from "@heroui/react";
import { XMarkIcon as k } from "@heroicons/react/24/outline";
import { SignInForm as F } from "./sign-in-form.js";
import { useConfig as B } from "../../../hooks/use-config.js";
function as({
  isOpen: n = !1,
  onClose: e,
  modalSize: l = "md",
  closeOnBackdropClick: m = !0,
  closeOnEscape: c = !0,
  modalClassName: r = "",
  showCloseButton: x = !0,
  methods: z = ["password", "oauth", "magic-link"],
  email: M,
  organizationId: y,
  redirectUrl: i,
  onSuccess: p,
  onError: h,
  title: u,
  subtitle: f,
  size: I = "md",
  showBranding: v = !0,
  disabled: a = !1,
  showSignUpLink: w = !0,
  showForgotPasswordLink: S = !0,
  footer: D,
  header: j,
  backdrop: P = "blur",
  placement: $ = "center",
  modalHeader: b,
  modalFooter: N,
  hideHeader: o = !1,
  hideFooter: K = !1,
  scrollBehavior: R = "inside"
}) {
  const { components: A } = B(), X = A.SignInModal;
  if (X)
    return /* @__PURE__ */ s(X, { isOpen: n, onClose: e, modalSize: l, closeOnBackdropClick: m, closeOnEscape: c, modalClassName: r, showCloseButton: x, methods: z, email: M, organizationId: y, redirectUrl: i, onSuccess: p, onError: h, title: u, subtitle: f, size: I, showBranding: v, disabled: a, showSignUpLink: w, showForgotPasswordLink: S, footer: D, header: j, backdrop: P, placement: $, modalHeader: b, modalFooter: N, hideHeader: o, hideFooter: K, scrollBehavior: R });
  const G = t((g) => {
    p?.(g), i || e?.();
  }, [p, e, i]), J = t(() => {
    a || e?.();
  }, [e, a]), q = (() => {
    switch (l) {
      case "sm":
        return { size: "sm", className: "max-w-sm" };
      case "md":
        return { size: "md", className: "max-w-md" };
      case "lg":
        return { size: "lg", className: "max-w-lg" };
      case "xl":
        return { size: "xl", className: "max-w-xl" };
      case "full":
        return { size: "full", className: "max-w-full" };
      default:
        return { size: "md", className: "max-w-md" };
    }
  })();
  return /* @__PURE__ */ s(
    T,
    {
      isOpen: n,
      onClose: J,
      size: q.size,
      backdrop: P,
      placement: $,
      scrollBehavior: R,
      closeButton: x,
      isDismissable: m && !a,
      isKeyboardDismissDisabled: !c || a,
      className: `${r}`,
      classNames: {
        wrapper: "z-[9999]",
        backdrop: "z-[9998]",
        base: `${q.className}`
      },
      children: /* @__PURE__ */ s(V, { children: (g) => /* @__PURE__ */ d(O, { children: [
        !o && /* @__PURE__ */ s(W, { className: "flex flex-col gap-1 px-6 py-4", children: b || /* @__PURE__ */ d("div", { className: "flex items-center justify-between w-full", children: [
          /* @__PURE__ */ d("div", { children: [
            u && /* @__PURE__ */ s("h2", { className: "text-lg font-semibold text-foreground", children: u }),
            f && /* @__PURE__ */ s("p", { className: "text-sm text-default-500 mt-1", children: f })
          ] }),
          x && /* @__PURE__ */ s(
            Y,
            {
              isIconOnly: !0,
              variant: "light",
              size: "sm",
              onPress: g,
              className: "text-default-400 hover:text-default-600",
              isDisabled: a,
              children: /* @__PURE__ */ s(k, { className: "w-4 h-4" })
            }
          )
        ] }) }),
        /* @__PURE__ */ s(Z, { className: "px-6 py-4", children: /* @__PURE__ */ s(
          F,
          {
            methods: z,
            email: M,
            organizationId: y,
            redirectUrl: i,
            onSuccess: G,
            onError: h,
            title: o ? u : void 0,
            subtitle: o ? f : void 0,
            size: I,
            showBranding: v,
            disabled: a,
            showSignUpLink: w,
            showForgotPasswordLink: S,
            header: j,
            footer: D,
            variant: "minimal",
            className: "space-y-4"
          }
        ) }),
        !K && N && /* @__PURE__ */ s(_, { className: "px-6 py-4", children: N })
      ] }) })
    }
  );
}
function ts() {
  const [n, e] = Q.useState(!1), l = t(() => e(!0), []), m = t(() => e(!1), []), c = t(() => e((r) => !r), []);
  return {
    isOpen: n,
    open: l,
    close: m,
    toggle: c,
    setIsOpen: e
  };
}
export {
  as as SignInModal,
  ts as useSignInModal
};
//# sourceMappingURL=sign-in-modal.js.map
