import { jsxs as v, jsx as i } from "react/jsx-runtime";
import { classNames as n } from "./index-classNames.js";
import { useState as z } from "react";
import e from "./index-BenchmarkGauge.module.scss.js";
import { BenchmarkGaugeMarker as F } from "./index-BenchmarkGaugeMarker.js";
import { useBenchmarkGaugeRenderState as U } from "./index-use-benchmark-gauge-render-state.js";
import { resolveMarkerColor as W } from "./index-utils3.js";
import { Render as c } from "./index-Render.js";
import { Text as x, TextTypes as y } from "./index-Text.js";
const _ = (m) => {
  const {
    min: N,
    max: C,
    markers: I,
    orientation: g = "horizontal",
    colorByRank: M,
    rankColors: B,
    growHighlightedMarker: H,
    testId: b,
    className: S
  } = m, [r, h] = z(void 0), {
    isVertical: G,
    rankCount: s,
    isProgressMode: L,
    hoverHighlights: f,
    dimsItems: D,
    dimsMarkers: T,
    rankMap: u,
    trackBarStyle: E,
    ghostStyle: R,
    shouldUseTrackGradient: j,
    fillStyle: w,
    effectiveStartLabel: p,
    effectiveEndLabel: k,
    hasLegend: P,
    legendMarkers: V
  } = U(m);
  return v("div", {
    "data-testid": b,
    className: n(e.root, G && e.rootVertical, S),
    children: [i(c, {
      if: P,
      children: i("div", {
        className: e.legend,
        children: V.map((t) => {
          const d = r === t.id, o = r !== void 0 && r !== t.id, l = u.get(t.id) ?? 0, a = {
            marker: t,
            orientation: g,
            rankIndex: l,
            rankCount: s,
            isHighlighted: d,
            isDimmed: o
          };
          return i("div", {
            className: n(e.legendItem, d && e.legendItemHighlighted, o && D && e.legendItemDimmed),
            style: {
              "--legend-item-bg": t.legendBackgroundColor ?? "var(--n000)"
            },
            onMouseEnter: f ? () => h(t.id) : void 0,
            onMouseLeave: f ? () => h(void 0) : void 0,
            children: t.renderLegend(a)
          }, t.id);
        })
      })
    }), i("div", {
      className: e.trackWrapper,
      children: v("div", {
        className: n(L && e.trackBarProgress, e.trackBar),
        style: E,
        children: [i("div", {
          className: e.trackGhost,
          style: R
        }), i("div", {
          className: n(e.trackFill, j && e.trackGradient),
          style: w
        }), i(c, {
          if: !!p,
          children: i(x, {
            className: n(e.label, e.labelStart),
            color: "--n000",
            type: y.textCaption,
            children: p
          })
        }), i(c, {
          if: !!k,
          children: i(x, {
            className: n(e.label, e.labelEnd),
            color: "--n000",
            type: y.textCaption,
            children: k
          })
        }), I.map((t) => {
          const d = u.get(t.id) ?? 0, o = r !== void 0 && r !== t.id && T, l = r === t.id, a = W({
            markerColor: t.color,
            rankIndex: d,
            rankCount: s,
            colorByRank: M,
            rankColors: B
          });
          return i(F, {
            marker: t,
            min: N,
            max: C,
            orientation: g,
            rankIndex: d,
            rankCount: s,
            isDimmed: o,
            isHighlighted: l,
            growHighlightedMarker: H,
            resolvedColor: a
          }, t.id);
        })]
      })
    })]
  });
};
export {
  _ as BenchmarkGauge
};
