import { d as e } from "./styled-components-b776227d.js";
import { useState as r, useEffect as t, useMemo as a } from "react";
import { f as n } from "./lodash-226cb5b1.js";
import { R as o } from "./react-json-view-364658b4.js";
import { e3 as i, e4 as l, av as s, e5 as d, e6 as c, e7 as f, e8 as b } from "./index-6d97e67f.js";
import { T as h } from "./antd-eb0b81b8.js";
import { lA as p, lR as g, lS as u } from "./ant-design-icons-a81e6d18.js";
const x = e.div`
  display: flex;
  align-items: center;
  padding: 12px 16px 20px 16px;
  cursor: move;
  background-color: #ffffff;
  border-radius: inherit;
`, m = e.div`
  margin-right: 8px;
  height: 16px;

  svg {
    width: 16px;
    height: 16px;
  }
`, w = e.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;
`, y = e.div`
  display: flex;
  flex-shrink: 0;
  align-items: center;
  margin-right: 24px;
  color: #8b8fa3;
  line-height: 13px;
  margin-left: auto;
`, k = e.div`
  margin-left: auto;
  width: 16px;
  height: 16px;
  cursor: pointer;

  color: ${i};

  &:hover {
    color: ${l};
  }
`, j = e.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);
  }
`, v = e(h)`
  .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;
  }
`, O = e.pre`
  word-break: break-word;
  white-space: pre-wrap;
`, A = e.span`
  color: #b8b9bf;
  margin-left: 8px;
`, S = A;
function L(e2) {
  const { success: i2, errorMessage: l2, dataType: h2, data: x2, title: L2, runTime: $ } = e2, [C, R] = r(false);
  t(() => R(false), [e2.data]);
  const [T, z] = a(() => {
    if ("default" !== h2)
      return [false, []];
    if (Array.isArray(x2)) {
      let e3 = true;
      const r2 = x2.reduce((r3, t2) => (t2 && n.isPlainObject(t2) ? Object.keys(t2).forEach((e4) => r3.add(e4)) : e3 = false, r3), /* @__PURE__ */ new Set());
      if (e3)
        return [true, Array.from(r2).reduce((e4, r3) => [...e4, { title: r3, dataIndex: r3, ellipsis: true, render: (e5) => "string" == typeof e5 ? e5 : JSON.stringify(e5) }], [])];
    }
    return [false, []];
  }, [x2, h2]), J = a(() => {
    if (l2)
      return l2;
    if (C)
      return p(o, { name: false, src: x2 });
    switch (h2) {
      case "function":
        return p(O, { children: s("resultPanel.returnFunction") });
      case "json":
        return n.isObjectLike(x2) ? p(o, { name: false, src: x2 }) : p(O, { children: String(x2) });
      default:
        return T ? p(v, { tableLayout: "auto", scroll: { x: "100%" }, columns: z, dataSource: x2.map((e3, r2) => ({ ...e3, key: r2 })), pagination: false }) : n.isObjectLike(x2) ? p(o, { name: false, src: x2 }) : p(O, { children: x2 });
    }
  }, [e2, C]);
  let N = null;
  return "function" !== h2 && (N = n.isArray(x2) ? `Array(${x2.length})` : n.isObject(x2) ? `Object(${Object.keys(x2).length} keys)` : typeof x2), { header: g(u, { children: [g(w, { children: [p(m, { children: p(i2 ? d : c, {}) }), L2, $ ? p(A, { children: s("resultPanel.consume", { time: P($) || "" }) }) : null, N && p(S, { children: N }), T && g(y, { children: [p(f, { value: C, onChange: (e3) => R(e3) }), s("resultPanel.JSON")] })] }), p(k, { onClick: e2.onClose, children: p(b, {}) })] }), body: p(j, { children: J }) };
}
function P(e2) {
  let r2 = e2;
  const t2 = ["ms", "s", "min", "h"], a2 = [1, 1e3, 60, 60];
  for (let e3 = 0; e3 < 4; e3++) {
    if (r2 / a2[e3] < 1)
      return r2 + t2[e3 - 1];
    r2 /= a2[e3];
  }
}
export {
  x as H,
  L as u
};
