import { jsx as r } from "../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { useState as h, useCallback as f, useEffect as p } from "../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { popoverUtil as k } from "../../../internal/Popover/utils/popoverUtil.js";
import g from "../../PaymentLinkCreation/components/PaymentLinkCreationContainer/PaymentLinkCreationContainer.js";
import w from "../../PaymentLinkSettings/components/PaymentLinkSettingsContainer/PaymentLinkSettingsContainer.js";
import O from "../../../../core/Context/preact/useCoreContext.js";
import P from "../../../internal/Modal/Modal.js";
const j = ({
  isModalVisible: e,
  onCloseModal: o,
  modalType: t,
  paymentLinkCreation: n,
  paymentLinkSettings: u,
  storeIds: i,
  onContactSupport: s,
  refreshPaymentLinkList: a
}) => {
  const { i18n: c } = O(), [l, m] = h(!1), v = f(() => {
    o(), l && (a?.(), m(!1));
  }, [o, l, a]);
  p(() => {
    e && k.closeAll();
  }, [e]);
  const d = f(
    (C) => {
      n?.onPaymentLinkCreated?.(C), m(!0);
    },
    [n]
  );
  return !e || !t ? null : /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r(
    P,
    {
      isOpen: e,
      "aria-label": c.get("payByLink.overview.title"),
      onClose: v,
      isDismissible: !0,
      headerWithBorder: !1,
      size: "large",
      children: [
        t === "Creation" ? /* @__PURE__ */ r(
          g,
          {
            ...n,
            onPaymentLinkCreated: d,
            storeIds: i,
            onContactSupport: s,
            embeddedInOverview: !0
          }
        ) : null,
        t === "Settings" ? /* @__PURE__ */ r(
          w,
          {
            ...u,
            storeIds: i,
            onContactSupport: s,
            embeddedInOverview: !0
          }
        ) : null
      ]
    }
  ) });
};
export {
  j as PaymentLinksOverviewModal
};
