import { j as jsxRuntimeExports, x as l, y as l$1, z as m, A as o, B as i, C as m$1, n as namedRoutes, d as c, m as m$2, T } from "./index-Cr4zbAtA.js";
import { L as LinkingIcon } from "./LinkingIcon-P8eDpGZr.js";
import { f as formatDistanceToNow } from "./formatDistanceToNow-OiNykSxl.js";
import { p as parseISO } from "./parseISO-Bd-Y3niL.js";
const SpansDetailsTable = ({
  details,
  caption
}) => {
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(l, { className: "mt-5", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(l$1, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(m, { children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(o, { children: caption }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(o, { className: "max-w-96", children: "Operation" }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(o, { children: "Ago" }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(o, { className: "text-right", children: "Duration (msec)" }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(o, { className: "text-right", children: "Duration (s)" })
    ] }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(i, { children: details.map((item) => {
      return /* @__PURE__ */ jsxRuntimeExports.jsxs(m, { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(LinkingIcon, { to: namedRoutes.opentelemetrySpan({
          id: item.spanId
        }) }) }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { className: "!text-wrap max-w-96 !whitespace-normal !break-all", children: item.attributeValue }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { children: formatDistanceToNow(parseISO(item.startedAt), {
          includeSeconds: true,
          addSuffix: true
        }) }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { className: "text-right", children: item.durationMs }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { className: "text-right", children: item.durationSec })
      ] }, item.id);
    }) })
  ] });
};
const StatisticsDetailTable = ({
  statistics
}) => {
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(c, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(m$2, { children: "Stats Overall" }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(l, { className: "mt-5", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(l$1, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(m, { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(o, { className: "max-w-96", children: "SQL Statement" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(o, { className: "text-right", children: "Count" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(o, { className: "text-right", children: "Min Duration (msec)" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(o, { className: "text-right", children: "Max Duration (msec)" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(o, { className: "text-right", children: "Avg. Duration (msec)" })
      ] }) }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(i, { children: statistics.map((item) => {
        return /* @__PURE__ */ jsxRuntimeExports.jsxs(m, { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { className: "!text-wrap max-w-96 !whitespace-normal !break-all", children: item.attributeValue }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { className: "text-right", children: item.statisticCount }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { className: "text-right", children: item.minDurationMs }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { className: "text-right", children: item.maxDurationMs }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { className: "text-right", children: item.avgDurationMs })
        ] }, item.attributeValue);
      }) })
    ] })
  ] });
};
const StatisticsIntervalChart = ({
  statistics,
  interval
}) => {
  const data = statistics.map((item) => {
    return {
      date: item.intervalStartedAt,
      count: item.statisticCount,
      min: item.minDurationMs,
      max: item.maxDurationMs,
      avg: item.avgDurationMs
    };
  });
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(c, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs(m$2, { children: [
      "Overall vs Time (",
      interval,
      " Intervals)"
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(T, { index: "date", data, categories: ["min", "max", "avg"], colors: ["orange", "emerald", "rose"] })
  ] });
};
const StatisticsIntervalTable = ({
  statistics,
  interval
}) => {
  const data = statistics.map((item) => {
    return {
      date: item.intervalStartedAt,
      count: item.statisticCount,
      min: item.minDurationMs,
      max: item.maxDurationMs,
      avg: item.avgDurationMs
    };
  });
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(c, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs(m$2, { children: [
      "Overall Stats (",
      interval,
      " Intervals)"
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(l, { className: "mt-5", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(l$1, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(m, { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(o, { children: "Ago" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(o, { className: "text-right", children: "Count" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(o, { className: "text-right", children: "Min Duration (msec)" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(o, { className: "text-right", children: "Max Duration (msec)" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(o, { className: "text-right", children: "Avg. Duration (msec)" })
      ] }) }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(i, { children: data.map((item) => {
        return /* @__PURE__ */ jsxRuntimeExports.jsxs(m, { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { children: formatDistanceToNow(parseISO(item.date), {
            includeSeconds: true,
            addSuffix: true
          }) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { className: "text-right", children: item.count }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { className: "text-right", children: item.min }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { className: "text-right", children: item.max }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(m$1, { className: "text-right", children: item.avg })
        ] }, item.date);
      }) })
    ] })
  ] });
};
export {
  StatisticsIntervalChart as S,
  StatisticsDetailTable as a,
  StatisticsIntervalTable as b,
  SpansDetailsTable as c
};
