import { jsx as t, jsxs as z } from "react/jsx-runtime";
import { useState as a, useEffect as D } from "react";
function M({ data: i = [], config: m = {} }) {
  const {
    columns: d = [{ title: "名称", key: "name" }],
    rowHeight: f = 36,
    headerHeight: v = 40,
    headerBgColor: y = "rgba(24, 144, 255, 0.3)",
    headerTextColor: w = "#1890ff",
    rowBgColor: C = "rgba(255,255,255,0.02)",
    rowAltBgColor: I = "rgba(255,255,255,0.05)",
    textColor: b = "#fff",
    fontSize: c = 14,
    scrollSpeed: h = 3e3,
    showHeader: k = !0,
    pageSize: o = 5
  } = m, [A, g] = a(0), [u, x] = a(!1), [S, p] = a(!1), l = i.length, H = l > o ? [...i, ...i.slice(0, o)] : i;
  if (D(() => {
    if (l <= o || u) return;
    const e = setInterval(() => {
      p(!0), g((r) => {
        const n = r + 1;
        return n >= l && setTimeout(() => {
          p(!1), g(0);
        }, 300), n;
      });
    }, h);
    return () => clearInterval(e);
  }, [l, o, h, u]), i.length === 0)
    return /* @__PURE__ */ t("div", { style: {
      width: "100%",
      height: "100%",
      display: "flex",
      alignItems: "center",
      justifyContent: "center",
      color: "#999"
    }, children: "暂无数据" });
  const $ = A * f;
  return /* @__PURE__ */ z(
    "div",
    {
      className: "carousel-list",
      style: {
        width: "100%",
        height: "100%",
        overflow: "hidden",
        display: "flex",
        flexDirection: "column"
      },
      onMouseEnter: () => x(!0),
      onMouseLeave: () => x(!1),
      children: [
        k && /* @__PURE__ */ t(
          "div",
          {
            style: {
              height: v,
              backgroundColor: y,
              display: "flex",
              alignItems: "center",
              padding: "0 12px",
              flexShrink: 0
            },
            children: d.map((e, r) => /* @__PURE__ */ t(
              "div",
              {
                style: {
                  flex: e.width ? `0 0 ${e.width}px` : 1,
                  color: w,
                  fontSize: c,
                  fontWeight: "bold",
                  textAlign: r === 0 ? "left" : "center"
                },
                children: e.title
              },
              e.key
            ))
          }
        ),
        /* @__PURE__ */ t(
          "div",
          {
            style: {
              flex: 1,
              overflow: "hidden",
              position: "relative"
            },
            children: /* @__PURE__ */ t(
              "div",
              {
                style: {
                  transform: `translateY(-${$}px)`,
                  transition: S ? "transform 0.3s ease" : "none"
                },
                children: H.map((e, r) => {
                  const n = r % l, B = n % 2 === 1;
                  return /* @__PURE__ */ t(
                    "div",
                    {
                      style: {
                        height: f,
                        backgroundColor: B ? I : C,
                        display: "flex",
                        alignItems: "center",
                        padding: "0 12px",
                        borderBottom: "1px solid rgba(255,255,255,0.05)"
                      },
                      children: d.map((s, j) => /* @__PURE__ */ t(
                        "div",
                        {
                          style: {
                            flex: s.width ? `0 0 ${s.width}px` : 1,
                            color: b,
                            fontSize: c,
                            textAlign: j === 0 ? "left" : "center",
                            overflow: "hidden",
                            textOverflow: "ellipsis",
                            whiteSpace: "nowrap"
                          },
                          children: e[s.key] ?? "-"
                        },
                        s.key
                      ))
                    },
                    `${r}-${e.id || n}`
                  );
                })
              }
            )
          }
        )
      ]
    }
  );
}
export {
  M as default
};
//# sourceMappingURL=CarouselList-CJboS52N.mjs.map
