import { jsx as t, jsxs as n, Fragment as h } from "react/jsx-runtime";
import { forwardRef as o } from "react";
import { cx as c } from "../../utils/classNames.js";
import { useArrowTheme as b } from "../../hooks/useArrowTheme.js";
const y = (e, r = "USD", l = "en-US") => new Intl.NumberFormat(l, {
  style: "currency",
  currency: r,
  minimumFractionDigits: 2
}).format(e), p = (e) => {
  if (e.type === "pending" || e.type === "inactive")
    return "N/A";
  const r = Number(e.value ?? 0), l = Number(e.delta ?? 0), a = r + (e.type === "addition" ? l : 0);
  return y(a);
}, _ = ({ series: e }) => {
  const r = e.every((a) => a.label), l = e.every((a) => a.subLine);
  return /* @__PURE__ */ t("div", { className: "tdds-hybrid-bar-chart__wrapper", children: e.map((a, i) => {
    const s = c("tdds-hybrid-bar-chart__bar", {
      [`tdds-hybrid-bar-chart__bar--${a.type}`]: !!a.type && a.type !== "current"
    });
    return /* @__PURE__ */ n("div", { className: "tdds-hybrid-bar-chart__group", children: [
      /* @__PURE__ */ t("div", { className: "tdds-hybrid-bar-chart__bars", children: a.delta ? /* @__PURE__ */ n(h, { children: [
        /* @__PURE__ */ t(
          "div",
          {
            className: s,
            style: { "--bar-value": a.delta },
            "data-value": a.delta
          }
        ),
        /* @__PURE__ */ t(
          "div",
          {
            className: "tdds-hybrid-bar-chart__bar",
            style: { "--bar-value": a.value },
            "data-value": a.value !== void 0 ? a.value : void 0
          }
        )
      ] }) : /* @__PURE__ */ t(
        "div",
        {
          className: s,
          style: { "--bar-value": a.value },
          "data-value": a.value !== void 0 ? a.value : void 0
        }
      ) }),
      /* @__PURE__ */ n("div", { className: "tdds-hybrid-bar-chart__labels", children: [
        r ? /* @__PURE__ */ t("span", { className: "tdds-hybrid-bar-chart__labels--label", children: a.label }) : null,
        l ? /* @__PURE__ */ t("span", { className: "tdds-hybrid-bar-chart__labels--subline", children: a.subLine }) : null,
        /* @__PURE__ */ t("span", { className: "tdds-hybrid-bar-chart__labels--value", children: p(a) })
      ] })
    ] }, i);
  }) });
}, N = o(
  ({ inverse: e, series: r, variant: l, className: a }, i) => {
    const s = b(), u = e ?? s.inverse, m = Math.min(0, ...r.map((d) => (d.value ?? 0) + (d.delta ?? 0))), v = Math.max(0, ...r.map((d) => (d.value ?? 0) + (d.delta ?? 0)));
    return /* @__PURE__ */ t(
      "div",
      {
        ref: i,
        className: c("tdds-hybrid-bar-chart", a),
        "data-inverse": u ? "true" : void 0,
        "data-variant": l ?? void 0,
        style: {
          "--max-bar-value": v,
          "--min-bar-value": m
        },
        children: /* @__PURE__ */ t(_, { series: r })
      }
    );
  }
);
N.displayName = "HybridBarChart";
export {
  N as HybridBarChart
};
//# sourceMappingURL=HybridBarChart.js.map
