import { jsx as t, jsxs as e, Fragment as I } from "react/jsx-runtime";
import { VList as _ } from "virtua";
import { useEffect as L, useMemo as C } from "react";
import { ErrorFillW700 as b } from "@material-symbols-svg/react-rounded/icons/error";
import { p as k, n as A, z as f } from "../../config-C5f_rI5O.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 F } from "../../hooks/useTransactions.js";
import { TransactionCard as v } from "./TransactionCard.js";
import { TransactionDetails as R } from "./TransactionDetails.js";
import { TransactionHistorySkeleton as S } from "./TransactionHistorySkeleton.js";
import { TransactionHistoryEmpty as d } from "./TransactionHistoryEmpty.js";
import { MAX_LIST_VIEW_AREA_HEIGHT as z, MIN_LIST_VIEW_AREA_HEIGHT as M, TX_ITEM_HEIGHT as W, LIST_CONTAINER_ID as j } from "./constants.js";
import { useTransactionHistoryListHeight as G } from "./useTransactionHistoryListHeight.js";
const Tt = ({
  isVisible: x,
  onPendingTransactionsCountChange: s,
  selectedTransaction: n,
  onSelectTransaction: m
}) => {
  const { isConnected: h } = k(), { tokens: a, isLoading: u } = A(), {
    transactions: i,
    pendingTransactionsCount: l,
    isLoading: g,
    isError: w,
    refetch: y,
    hasNextPage: c,
    fetchNextPage: T,
    isFetchingNextPage: o,
    isFetchNextPageError: r
  } = F();
  L(() => {
    s(l);
  }, [l, s]);
  const N = C(() => o ? "Loading..." : r ? "Retry" : "Show more", [r, o]), E = G({
    transactionsCount: i.length,
    hasNextPage: c,
    isVisible: x
  });
  return h ? u || g ? /* @__PURE__ */ t(S, {}) : w && !r ? /* @__PURE__ */ e("div", { className: "flex flex-col items-center justify-center py-sw-3xl", children: [
    /* @__PURE__ */ t(b, { 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(f, { size: "md", variant: "primary", onClick: () => y(), children: "Retry" })
  ] }) : i.length === 0 ? /* @__PURE__ */ t(d, { type: "empty" }) : n ? /* @__PURE__ */ t(
    R,
    {
      transaction: n,
      tokens: a,
      onClose: () => {
        m(null);
      }
    }
  ) : /* @__PURE__ */ t("div", { className: "flex flex-col gap-sw-md w-full", children: /* @__PURE__ */ e(
    _,
    {
      id: j,
      itemSize: W,
      className: "hide-scrollbar",
      style: {
        height: E,
        minHeight: M,
        maxHeight: z,
        overflowAnchor: "none",
        outline: "none"
      },
      children: [
        i.map((p, H) => /* @__PURE__ */ t(
          v,
          {
            transaction: p,
            tokens: a,
            className: "mb-sw-lg",
            onClick: () => {
              m(p);
            }
          },
          H
        )),
        c && /* @__PURE__ */ e(I, { 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(
            f,
            {
              size: "lg",
              variant: "outlined",
              className: r ? "mt-sw-md" : "mt-sw-2xl",
              state: o ? "loading" : "default",
              onClick: () => T(),
              children: N
            }
          )
        ] })
      ]
    }
  ) }) : /* @__PURE__ */ t(d, { type: "connect" });
};
export {
  Tt as TransactionHistory
};
//# sourceMappingURL=index.js.map
