import { jsxs as s, jsx as l } from "react/jsx-runtime";
import { t as N } from "../../classix-DG18itHa.js";
import { Loading as v } from "../loading/index.js";
import '../../assets/index8.css';const f = "_graph_1web1_11", x = "_plot_1web1_20", k = "_item_1web1_34", V = "_column_1web1_40", y = "_value_1web1_48", M = "_track_1web1_58", j = "_bar_1web1_65", S = "_label_1web1_87", a = {
  graph: f,
  plot: x,
  item: k,
  column: V,
  value: y,
  track: M,
  bar: j,
  label: S,
  "is-loading": "_is-loading_1web1_96"
}, h = (t) => Number.isFinite(t) ? Math.max(0, t) : 0, L = ({
  accessibleLabel: t,
  className: _,
  height: o,
  items: n = [],
  style: m,
  valueFormatter: p = (r) => r.toLocaleString(),
  ...b
}) => {
  const r = n.reduce((e, c) => Math.max(e, h(c.value)), 0), u = {
    ...m,
    "--graph-columns": Math.max(n.length, 1),
    "--graph-height": o || "calc(var(--utils-tokens-unit) * 16)"
  };
  return /* @__PURE__ */ s("figure", { className: N(a.graph, _), style: u, ...b, "data-component": "graph", children: [
    t && /* @__PURE__ */ l("figcaption", { "data-content": "screen-reader", children: t }),
    n.length > 0 ? /* @__PURE__ */ l("ul", { className: a.plot, children: n.map((e, c) => {
      const i = h(e.value), d = r > 0 ? i / r * 100 : 0, g = i > 0 ? Math.max(d, 6) : 0, w = {
        "--bar-color": e.color,
        "--bar-delay": c * 50 + "ms",
        "--bar-height": g + "%"
      };
      return /* @__PURE__ */ s("li", { className: a.item, "data-component": "graph", children: [
        /* @__PURE__ */ s("div", { className: a.column, children: [
          /* @__PURE__ */ l("span", { className: a.value, children: p(e.value) }),
          /* @__PURE__ */ l("span", { className: a.track, children: /* @__PURE__ */ l("span", { className: a.bar, style: w }) })
        ] }),
        /* @__PURE__ */ l("span", { className: a.label, title: e.label, children: e.label })
      ] }, e.label + c);
    }) }) : /* @__PURE__ */ l("div", { className: a["is-loading"], children: /* @__PURE__ */ l(v, {}) })
  ] });
};
export {
  L as Graph
};
//# sourceMappingURL=index.js.map
