import { e as gql, j as jsxRuntimeExports, m, d as c, o as a, p as s, q as c$1, u, t as n, v as i, k as c$2, l as i$1, s as s$1 } from "./index-Cr4zbAtA.js";
import { M as Metadata } from "./Metadata-aK5zM6ek.js";
import { c as createCell } from "./createCell-D7cbP3PP.js";
import { S as StatisticsIntervalChart, a as StatisticsDetailTable, b as StatisticsIntervalTable, c as SpansDetailsTable } from "./StatisticsIntervalTable-CyekKWJv.js";
import "./LinkingIcon-P8eDpGZr.js";
import "./formatDistanceToNow-OiNykSxl.js";
import "./getRoundingMethod-DBxbmHsV.js";
import "./toDate-C1yAaWVq.js";
import "./parseISO-Bd-Y3niL.js";
import "./en-US-femdFzaW.js";
const beforeQuery = (props) => {
  return {
    variables: props,
    pollInterval: 2e3,
    fetchPolicy: "cache-and-network"
  };
};
const QUERY = gql`
  query GraphQLOperationsQuery {
    details: graphQLOperationSpans {
      id
      spanId
      startedAt
      durationMs
      durationSec
      attributeKey
      attributeValue
    }
    statistics: graphQLOperationStatistics(intervalMins: 1) {
      intervalStartedAt
      statisticCount
      minDuration
      minDurationMs
      minDurationSec
      maxDuration
      maxDurationMs
      maxDurationSec
      avgDuration
      avgDurationMs
      avgDurationSec
    }
    gqlOperationsStats: graphQLOperationAttributeStatistics {
      attributeValue
      statisticCount
      minDuration
      minDurationMs
      minDurationSec
      maxDuration
      maxDurationMs
      maxDurationSec
      avgDuration
      avgDurationMs
      avgDurationSec
    }
  }
`;
const Loading = () => /* @__PURE__ */ jsxRuntimeExports.jsx(m, { children: "Loading..." });
const Empty = () => /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(c, {
  children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(m, { children: "Recent GraphQL Operations" }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(a, { children: "No recent records." })
  ]
}) });
const Failure = ({
  error
}) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
  className: "font-bold text-tremor-brand dark:text-dark-tremor-brand",
  children: [
    "Error: ",
    error == null ? void 0 : error.message
  ]
});
const Success = ({
  details,
  statistics,
  gqlOperationsStats
}) => {
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(s, {
    children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(c$1, {
        className: "mt-8",
        children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(u, { children: "Overview" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(u, { children: "Recent Details" })
        ]
      }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(n, {
        children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(i, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(c$2, {
            numItemsSm: 2,
            numItemsLg: 3,
            className: "gap-6",
            children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx(i$1, { numColSpanSm: 2, numColSpanLg: 3, children: /* @__PURE__ */ jsxRuntimeExports.jsx(StatisticsIntervalChart, { statistics, interval: "1 Min" }) }),
              /* @__PURE__ */ jsxRuntimeExports.jsx(i$1, { numColSpanSm: 2, numColSpanLg: 3, children: /* @__PURE__ */ jsxRuntimeExports.jsx(StatisticsDetailTable, { statistics: gqlOperationsStats }) }),
              /* @__PURE__ */ jsxRuntimeExports.jsx(i$1, { numColSpanSm: 2, numColSpanLg: 3, children: /* @__PURE__ */ jsxRuntimeExports.jsx(StatisticsIntervalTable, { statistics, interval: "1 Min" }) })
            ]
          }) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(i, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(c, {
            children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx(m, { children: "Recent GraphQL Operations" }),
              /* @__PURE__ */ jsxRuntimeExports.jsx(SpansDetailsTable, { details, caption: "Operation" })
            ]
          }) })
        ]
      })
    ]
  });
};
const GraphQLOperationsCell = createCell({ beforeQuery, QUERY, Loading, Empty, Failure, Success, displayName: "GraphQLOperationsCell" });
const GraphQLOperationsPage = () => {
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(Metadata, { title: "GraphQL Operations", description: "GraphQL Operations" }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(s$1, { className: "pb-4", children: "GraphQL Operations" }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(GraphQLOperationsCell, {})
  ] });
};
export {
  GraphQLOperationsPage as default
};
