import { jsxs as r, jsx as t } from "react/jsx-runtime";
import { QrCodeW700 as u } from "@material-symbols-svg/react-rounded/icons/qr-code";
import { ProgressActivityW700 as f } from "@material-symbols-svg/react-rounded/icons/progress-activity";
import { RefreshW700 as x } from "@material-symbols-svg/react-rounded/icons/refresh";
import { cn as T } from "../utils/cn.js";
import { Card as k } from "../components/Card.js";
import { Steps as l } from "../components/Steps.js";
import { Toggle as h } from "../components/Toggle.js";
import { b as m, A as w, u as y, E as S, z as g } from "../config-D-Ik_SSx.js";
import { TokenSelectButton as N } from "../components/TokenSelectButton.js";
import { formatBigToHuman as _ } from "../utils/formatters/formatBigToHuman.js";
import { useTypedTranslation as p } from "../localisation.js";
import { guardStates as b } from "../machine/guards/index.js";
import "../machine/machine.js";
import { fireEvent as c } from "../machine/events/utils/fireEvent.js";
const D = ({ onMsg: s }) => {
  const { t: o } = p(), { ctx: e } = m(), { minDepositTokenAmount: n } = y();
  if (!b(e, [
    "initial_wallet",
    "input_valid_internal",
    "input_valid_external",
    "quote_success_internal",
    "quote_success_external"
  ]))
    return null;
  const a = e.sourceToken ? _(n, e.sourceToken.decimals) : 0;
  return /* @__PURE__ */ r(l, { className: "pt-sw-2xl", children: [
    /* @__PURE__ */ t(
      l.Step,
      {
        title: o(
          "deposit.external.stepSelectToken.title",
          "Select token to deposit"
        ),
        description: e.sourceToken ? `Minimum deposit ${a} ${e.sourceToken.symbol}` : "You can send any amount of this token",
        asideElement: /* @__PURE__ */ t(
          N,
          {
            token: e.sourceToken,
            onClick: () => s({ type: "on_toggle_tokens_modal", isOpen: !0 })
          }
        )
      }
    ),
    /* @__PURE__ */ t(
      l.Step,
      {
        title: `Send ${e.sourceToken ? `${e.sourceToken?.symbol} ` : ""}to address`,
        description: e.sourceToken ? `Use ${e.sourceToken.chainName} network` : "Use selected token's network",
        asideElement: (() => {
          switch (e.quoteStatus) {
            case "idle":
            case "success":
              return /* @__PURE__ */ t("span", { className: "h-[36px]" });
            case "error":
              return /* @__PURE__ */ r(
                g,
                {
                  size: "md",
                  variant: "primary",
                  className: "w-fit py-sw-sm px-sw-lg",
                  onClick: () => c("quoteReset", null),
                  children: [
                    /* @__PURE__ */ t(x, { size: 16 }),
                    o("deposit.external.stepSelectToken.retry", "Try again")
                  ]
                }
              );
            case "pending":
            default:
              return /* @__PURE__ */ t("div", { className: "flex items-center justify-center h-[36px]", children: /* @__PURE__ */ t("span", { className: "animate-spin", children: /* @__PURE__ */ t(f, { size: 24, className: "text-sw-gray-200" }) }) });
          }
        })(),
        children: e.quoteStatus === "success" && /* @__PURE__ */ t(S, { onMsg: s })
      }
    )
  ] });
}, Q = ({ className: s, onMsg: o }) => {
  const { ctx: e } = m(), { t: n } = p(), i = (!!e.sourceToken && !e.sourceToken.isIntent || !e.sourceToken) && !!e.walletAddress, a = (d) => {
    i && (c("externalDepositTxSet", void 0), c("depositTypeSet", { isExternal: d }));
  };
  return /* @__PURE__ */ r(
    k,
    {
      className: T(
        "flex flex-col",
        { "pb-sw-lg": e.isDepositFromExternalWallet },
        s
      ),
      children: [
        /* @__PURE__ */ r("header", { className: "gap-sw-md flex items-center justify-between", children: [
          /* @__PURE__ */ t(u, { size: 16, className: "text-sw-gray-200" }),
          /* @__PURE__ */ t("span", { className: "text-sw-label-md text-sw-gray-200", children: n("deposit.method.switcher.label", "Deposit from external wallet") }),
          /* @__PURE__ */ t(
            w,
            {
              className: "mr-auto",
              text: n(
                "deposit.external.tooltip.text",
                "Generate a deposit address and QR code to fund your account. Send any amount of the selected asset and it will be credited to your Intents balance."
              )
            }
          ),
          /* @__PURE__ */ t(
            h,
            {
              isOn: e.isDepositFromExternalWallet,
              isDisabled: !i,
              onToggle: a
            }
          )
        ] }),
        e.isDepositFromExternalWallet && /* @__PURE__ */ t(D, { onMsg: o })
      ]
    }
  );
};
export {
  Q as DepositMethodSwitcher
};
//# sourceMappingURL=DepositMethodSwitcher.js.map
