import { b9 as t, fP as S, hz as C, c9 as d, V as r, ee as u, a0 as g, P as x, bh as P, hA as R, hB as $, hr as F, hC as J, fK as L } from "./684d2f28.js";
import { useState as W, useEffect as H, useMemo as v } from "react";
const q = t.div`
  display: flex;
  align-items: center;
  padding: 12px 16px 20px 16px;
  cursor: move;
  background-color: #ffffff;
  border-radius: inherit;
`, z = t.div`
  margin-right: 8px;
  height: 16px;

  svg {
    width: 16px;
    height: 16px;
  }
`, E = t.div`
  display: flex;
  align-items: center;
  flex-grow: 1;

  height: 24px;
  font-size: 13px;
  line-height: 13px;
  color: #222222;
  border-radius: 4px;
  border: none;
  word-break: break-all;
`, I = t.div`
  display: flex;
  flex-shrink: 0;
  align-items: center;
  margin-right: 24px;
  color: #8b8fa3;
  line-height: 13px;
  margin-left: auto;
`, B = t.div`
  margin-left: auto;
  width: 16px;
  height: 16px;
  cursor: pointer;

  color: ${S};

  &:hover {
    color: ${C};
  }
`, M = t.div`
  height: 100%;
  overflow-x: hidden;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  padding-left: 16px;
  background-color: #ffffff;

  &::-webkit-scrollbar {
    width: 16px;
  }

  &::-webkit-scrollbar-thumb {
    border: 4px solid transparent;
    background-clip: content-box;
    border-radius: 9999px;
    background-color: rgba(139, 143, 163, 0.2);
    min-height: 50px;
  }

  &::-webkit-scrollbar-thumb:hover {
    background-color: rgba(139, 143, 163, 0.36);
  }
`, D = t(L)`
  .ant-table {
    font-size: 13px;
    border: none;
  }

  .ant-table-thead {
    margin-bottom: 4px;
  }

  .ant-table-thead > tr > th {
    color: #8b8fa3;
    background: #ffffff;
    line-height: 13px;
    padding-bottom: 9px;
    // border-bottom: 1px solid #8b8fa3;
  }

  .ant-table-thead > tr > th::before {
    display: none;
  }

  .ant-table-tbody > tr > td {
    border: none;
  }

  .ant-table-row {
    margin-top: 4px;
  }

  .ant-table-cell {
    height: 22px;
    padding: 0 24px 0 0;
    margin-left: 24px;
    max-width: 184px; // actual width + padding right
  }

  // two-side shadow with scrollbar
  .ant-table-ping-left:not(.ant-table-has-fix-left) .ant-table-container::before {
    box-shadow: none;
  }

  .ant-table-ping-right:not(.ant-table-has-fix-right) .ant-table-container::after {
    box-shadow: none;
  }
`, m = t.pre`
  word-break: break-word;
  white-space: pre-wrap;
`, T = t.span`
  color: #b8b9bf;
  margin-left: 8px;
`, G = T;
function Q(n) {
  const {
    success: l,
    errorMessage: f,
    dataType: a,
    data: e,
    title: j,
    runTime: w
  } = n, [h, y] = W(!1);
  H(() => y(!1), [n.data]);
  const [k, O] = v(() => {
    if (a !== "default")
      return [!1, []];
    if (Array.isArray(e)) {
      let o = !0;
      const p = e.reduce((b, i) => (i && d.isPlainObject(i) ? Object.keys(i).forEach((c) => b.add(c)) : o = !1, b), /* @__PURE__ */ new Set());
      if (o)
        return [!0, Array.from(p).reduce((b, i) => [...b, {
          title: i,
          dataIndex: i,
          ellipsis: !0,
          render: (c) => typeof c == "string" ? c : JSON.stringify(c)
        }], [])];
    }
    return [!1, []];
  }, [e, a]), A = v(() => {
    if (f)
      return f;
    if (h)
      return /* @__PURE__ */ r(u, {
        name: !1,
        src: e
      });
    switch (a) {
      case "function":
        return /* @__PURE__ */ r(m, {
          children: g("resultPanel.returnFunction")
        });
      case "json":
        return d.isObjectLike(e) ? /* @__PURE__ */ r(u, {
          name: !1,
          src: e
        }) : /* @__PURE__ */ r(m, {
          children: String(e)
        });
      default:
        return k ? /* @__PURE__ */ r(D, {
          tableLayout: "auto",
          scroll: {
            x: "100%"
          },
          columns: O,
          dataSource: e.map((o, p) => ({
            ...o,
            key: p
          })),
          pagination: !1
        }) : d.isObjectLike(e) ? /* @__PURE__ */ r(u, {
          name: !1,
          src: e
        }) : /* @__PURE__ */ r(m, {
          children: e
        });
    }
  }, [n, h]);
  let s = null;
  return a !== "function" && (d.isArray(e) ? s = `Array(${e.length})` : d.isObject(e) ? s = `Object(${Object.keys(e).length} keys)` : s = typeof e), {
    header: /* @__PURE__ */ x(P, {
      children: [/* @__PURE__ */ x(E, {
        children: [/* @__PURE__ */ r(z, {
          children: l ? /* @__PURE__ */ r(R, {}) : /* @__PURE__ */ r($, {})
        }), j, w ? /* @__PURE__ */ r(T, {
          children: g("resultPanel.consume", {
            time: K(w) || ""
          })
        }) : null, s && /* @__PURE__ */ r(G, {
          children: s
        }), k && /* @__PURE__ */ x(I, {
          children: [/* @__PURE__ */ r(F, {
            value: h,
            onChange: (o) => y(o)
          }), g("resultPanel.JSON")]
        })]
      }), /* @__PURE__ */ r(B, {
        onClick: n.onClose,
        children: /* @__PURE__ */ r(J, {})
      })]
    }),
    body: /* @__PURE__ */ r(M, {
      children: A
    })
  };
}
function K(n) {
  let l = n;
  const f = ["ms", "s", "min", "h"], a = [1, 1e3, 60, 60];
  for (let e = 0; e < 4; e++) {
    if (l / a[e] < 1)
      return l + f[e - 1];
    l /= a[e];
  }
}
export {
  q as H,
  Q as u
};
