import { jsx as t, jsxs as e, Fragment as _ } from "react/jsx-runtime";
import { VList as L } from "virtua";
import { useEffect as C, useMemo as b } from "react";
import { ErrorFillW700 as k } from "@material-symbols-svg/react-rounded/icons/error";
import { p as A, n as F, z as d } from "../../config-D-Ik_SSx.js";
import "../../constants/chains.js";
import "@tanstack/react-query";
import "../../logger.js";
import "@scure/base";
import "zod";
import "../../utils/near/rpc.js";
import "ethers";
import "../../machine/machine.js";
import "../../index-DEq3oXQF.js";
import "@defuse-protocol/intents-sdk";
import "change-case";
import "../../localstorage-DVS0q1yC.js";
import "@defuse-protocol/internal-utils";
import "bs58";
import "@defuse-protocol/one-click-sdk-typescript";
import "axios";
import "../../network.js";
import "@ton/core";
import "../../utils/cn.js";
import "../../hooks/useMakeNearTransfer/nearClient.js";
import "../../utils/feeServiceTokens.js";
import "../../hooks/useOneClickExecutionStatus.js";
import { useTransactions as v } from "../../hooks/useTransactions.js";
import { TransactionCard as M } from "./TransactionCard.js";
import { TransactionDetails as R } from "./TransactionDetails.js";
import { TransactionHistorySkeleton as S } from "./TransactionHistorySkeleton.js";
import { TransactionHistoryEmpty as f } from "./TransactionHistoryEmpty.js";
import { MAX_LIST_VIEW_AREA_HEIGHT as z, MIN_LIST_VIEW_AREA_HEIGHT as P, TX_ITEM_HEIGHT as W, LIST_CONTAINER_ID as j } from "./constants.js";
import { useTransactionHistoryListHeight as G } from "./useTransactionHistoryListHeight.js";
const Nt = ({
  isVisible: x,
  onPendingTransactionsCountChange: s,
  selectedTransaction: n,
  onSelectTransaction: a
}) => {
  const { isConnected: h } = A(), { tokens: m, isLoading: g } = F(), {
    transactions: i,
    pendingTransactionsCount: l,
    isLoading: u,
    isError: w,
    refetch: y,
    hasNextPage: T,
    fetchNextPage: N,
    isFetchingNextPage: o,
    isFetchNextPageError: r
  } = v();
  C(() => {
    s(l);
  }, [l, s]);
  const E = b(() => o ? "Loading..." : r ? "Retry" : "Show more", [r, o]), c = T || o || r, H = G({
    transactionsCount: i.length,
    hasNextPage: c,
    isVisible: x
  });
  return h ? g || u ? /* @__PURE__ */ t(S, {}) : w && !r ? /* @__PURE__ */ e("div", { className: "flex flex-col items-center justify-center py-sw-3xl", children: [
    /* @__PURE__ */ t(k, { className: "w-[32px] h-[32px] text-sw-gray-200 mb-sw-lg" }),
    /* @__PURE__ */ t("p", { className: "text-sw-body-md text-sw-gray-300 text-center max-w-[265px] mb-sw-2xl", children: "Failed to load transactions history." }),
    /* @__PURE__ */ t(d, { size: "md", variant: "primary", onClick: () => y(), children: "Retry" })
  ] }) : i.length === 0 ? /* @__PURE__ */ t(f, { type: "empty" }) : n ? /* @__PURE__ */ t(
    R,
    {
      transaction: n,
      tokens: m,
      onClose: () => {
        a(null);
      }
    }
  ) : /* @__PURE__ */ t("div", { className: "flex flex-col gap-sw-md w-full", children: /* @__PURE__ */ e(
    L,
    {
      id: j,
      itemSize: W,
      className: "hide-scrollbar",
      style: {
        height: H,
        minHeight: P,
        maxHeight: z,
        overflowAnchor: "none",
        outline: "none"
      },
      children: [
        i.map((p, I) => /* @__PURE__ */ t(
          M,
          {
            transaction: p,
            tokens: m,
            className: "mb-sw-lg",
            onClick: () => {
              a(p);
            }
          },
          I
        )),
        c && /* @__PURE__ */ e(_, { children: [
          r && /* @__PURE__ */ t("p", { className: "text-sw-label-sm text-sw-status-error text-center mt-sw-2xl", children: "Failed to load more transactions." }),
          /* @__PURE__ */ t(
            d,
            {
              size: "lg",
              variant: "outlined",
              className: r ? "mt-sw-md" : "mt-sw-2xl",
              state: o ? "loading" : "default",
              onClick: () => N(),
              children: E
            }
          )
        ] })
      ]
    }
  ) }) : /* @__PURE__ */ t(f, { type: "connect" });
};
export {
  Nt as TransactionHistory
};
//# sourceMappingURL=index.js.map
