{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-cells",
  "title": "Chart cells",
  "description": "The cells of a chart drawn as a grid of cells, on the chart root with the grid reader: the cells, the scroll of a grid wider than its card, the one under the pointer bright while the rest step back, a new range filling them in a wave, the legend of the colour’s steps, the tooltip and the placeholder. The Heatmap and Waffle charts draw on it.",
  "dependencies": [],
  "registryDependencies": [
    "https://kinoui.com/r/chart-core.json",
    "https://kinoui.com/r/chart-root.json",
    "https://kinoui.com/r/chart-grid.json",
    "https://kinoui.com/r/chart-math.json",
    "https://kinoui.com/r/placeholder.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/lib/chart-cells.tsx",
      "content": "'use client'\n\nimport {\n  type ActiveIndexProps,\n  type AxisNames,\n  type CategoryChartProps,\n  ChartAxesContext,\n  type ChartAxesValue,\n  type ChartAxisName,\n  IndexActive,\n  stickTo,\n  useChartActive,\n  useChartLife,\n  useChartLoad,\n  useChartPick,\n  useIndexFocus,\n  useLeavingItems,\n  writeDatum,\n} from '@/registry/lib/chart-base'\nimport {\n  type CellBox,\n  cellBox,\n  type CellShape,\n  cellUnder,\n  gridAspect,\n  hexStepKey,\n  type LaidCell,\n  labelRoom,\n  SPOTLIGHT_RINGS,\n  spotlightRing,\n  stepOf,\n  stepStrength,\n} from '@/registry/lib/chart-grid'\nimport type { GridStop } from '@/registry/lib/chart-grid-reader'\nimport {\n  type ChartDatum,\n  type GridCell,\n  numberOf,\n  type ReadingDirection,\n} from '@/registry/lib/chart-math'\nimport {\n  ChartFrame,\n  type ChartPoint,\n  type ChartReader,\n  type ChartRootState,\n  type ChartRootValue,\n  labelOnClassName,\n  type PlotPoint,\n  plotLayerClassName,\n  seriesColor,\n  stepBackLayerClassName,\n  useChartRoot,\n  useChartRootValue,\n} from '@/registry/lib/chart-root'\nimport {\n  type ChartStatus,\n  type ChartTarget,\n  indexOfKey,\n  targetKey,\n} from '@/registry/lib/chart-state'\nimport {\n  placeholderBreatheClassName,\n  placeholderFillClassName,\n} from '@/registry/lib/placeholder'\nimport {\n  type ComponentProps,\n  createContext,\n  type CSSProperties,\n  memo,\n  type ReactNode,\n  type Ref,\n  use,\n  useLayoutEffect,\n  useMemo,\n  useState,\n} from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * The cells: what a chart drawn as a grid of cells, such as a heatmap,\n * shares on the chart root. Each cell is a stop of the grid reader\n * (`chart-grid-reader`), held by its key, so the tooltip, the table, the\n * announcements and `selected` work as in any chart; this part keeps the\n * cells, places them, picks the one under the pointer, gives the axes their\n * names and draws the cells, their legend and their placeholder. The cell\n * under the pointer stays bright while the rest step back, and a new range\n * fills the cells in a wave along the columns. The cells are squares or\n * hexagons (`CellShape`); hexagons make a surface, so the cells around the\n * lit one step back by how far they are. The Waffle draws its squares with\n * the same cells.\n */\n\n/** The tallest the plot grows with square cells before its cells widen instead, in px. */\nconst MOST_HEIGHT = 320\n\n/** The tallest a cell grows, so a grid of a row or two stays a strip, in px. */\nconst MOST_CELL = 40\n\n/** The shortest a row gets, so a cell can still be pointed at, in px. */\nconst LEAST_CELL = 11\n/** The narrowest a column gets in a chart that scrolls sideways, a cell with its gap, in px: a year of weeks fits a desktop card whole. */\nconst LEAST_COLUMN = 10\n\n/** The least room between two values under the legend, in px. */\nconst LEGEND_GAP = 8\n\n/** The height a value written in a cell needs, in px: a line of the chart's 12px text. */\nconst LABEL_HEIGHT = 14\n\n/** The room either side of a value written in a cell, in px. */\nconst LABEL_PAD = 3\n\n/** Where a cell sits, and the name it takes on each axis, by its place in the axis's names. */\ninterface CellAt extends GridCell {\n  x: number | null\n  y: number | null\n}\n\n/** A cell as its layout lays it out: where it sits and under which names, its key and name, and the caller's row, or null for a cell the data leaves out. */\ninterface LaidOutCell extends CellAt {\n  key: string\n  value: string\n  datum: ChartDatum | null\n}\n\n/** One axis of a grid of cells: its names, and how it writes them. */\ninterface CellAxis {\n  names: readonly ChartAxisName[]\n  format: (value: unknown) => string\n}\n\n/** The grid's cells, in reading order, with the axes' names. */\ninterface CellGridLayout {\n  cells: readonly LaidOutCell[]\n  columns: number\n  rowCount: number\n  x: CellAxis\n  y: CellAxis\n}\n\n/** The laid-out cells for `cells`, each with its name, its key and where it sits. */\nfunction laidOutCells<T>(\n  cells: readonly LaidCell<T>[],\n  name: (cell: LaidCell<T>) => string,\n  key: (cell: LaidCell<T>) => string,\n  at: (cell: LaidCell<T>) => CellAt,\n): LaidOutCell[] {\n  return cells.map((cell) => ({\n    ...at(cell),\n    key: key(cell),\n    value: name(cell),\n    datum: cell.datum,\n  }))\n}\n\n/** Names that each take one line of the grid, a column or a row, over the band `bandOf` gives each. */\nfunction lineNames(\n  values: readonly unknown[],\n  bandOf: (index: number) => { start: number; size: number },\n): ChartAxisName[] {\n  return values.map((value, index) => ({\n    key: String(value),\n    value,\n    index,\n    band: bandOf(index),\n    leaving: false,\n  }))\n}\n\n/** A cell still in the data, with the names it sits under. */\ntype CellStop = GridStop & Pick<CellAt, 'x' | 'y'>\n\n/** What a chart of cells keeps before it draws its cells. */\ninterface CellsChart {\n  state: ChartRootState\n  /** The cells still in the data, in reading order; none while it loads or failed. */\n  cells: readonly CellStop[]\n  /** Every cell to draw, the leaving ones too, in a fixed order by key. */\n  drawn: readonly (CellStop & { leaving: boolean })[]\n  status: ChartStatus\n  /** The placeholder shows while the data loads. */\n  placeholder: boolean\n  /** The key of the cell picked, or null. */\n  picked: string | null\n  selectable: boolean\n  /** Picks the cell keyed `key`, or lets it go if it was picked. */\n  togglePicked: (key: string) => void\n  activeProps: ActiveIndexProps\n  /** Anything under a series' key as the chart writes it: a number, a `[from, to]` range, or no value. */\n  datumText: (value: unknown) => string\n}\n\n/** The cells of a chart that loads or failed: one array, so what compares them sees no change. */\nconst NO_CELLS: readonly LaidOutCell[] = []\n\n/**\n * A chart of cells' root state, its cells, what it shows and what is\n * picked. The plot holds square cells, so its height comes from its data.\n */\nfunction useCellsChart(\n  props: Omit<CategoryChartProps, 'index'>,\n  layout: CellGridLayout,\n): CellsChart {\n  const state = useChartRoot(props, { entrance: false, heightFromData: true })\n  const load = useChartLoad(props)\n  const laid = load.placeholder || load.failed ? NO_CELLS : layout.cells\n  const cells = laid.map((cell, index) => ({ ...cell, index }))\n  const drawn = useLeavingItems(state.moves, cells, cellKey)\n  const shown = state.series.filter((key) => !state.hidden.includes(key))\n  const { status } = useChartLife(\n    props,\n    state,\n    load,\n    { rows: cells.length, shown: shown.length, drawn: cells.length },\n    { entrance: false, cascade: null },\n  )\n  const keys = cells.map(cellKey)\n  const pick = useChartPick(props, keys)\n  return {\n    state,\n    cells,\n    drawn,\n    status,\n    placeholder: load.placeholder,\n    picked: pick.picked,\n    selectable: pick.selectable,\n    togglePicked: (key) => {\n      if (indexOfKey(keys, key) !== null) pick.toggle(key)\n    },\n    activeProps: {\n      activeIndex: props.activeIndex,\n      defaultActiveIndex: props.defaultActiveIndex ?? null,\n      onActiveIndexChange: props.onActiveIndexChange,\n    },\n    datumText: (value) => writeDatum(value, state.valueText, state.messages.noValue),\n  }\n}\n\nfunction cellKey(cell: { key: string }) {\n  return cell.key\n}\n\n/** The cell under `point` of a grid `columns` by `rows` that fills the plot, by its place among `cells`, or null. */\nfunction cellAt(\n  point: PlotPoint,\n  cells: readonly GridCell[],\n  shape: CellShape,\n  columns: number,\n  rows: number,\n  direction: ReadingDirection,\n): number | null {\n  if (point.width === 0 || point.height === 0) return null\n  const { column, row } = cellUnder(\n    shape,\n    { x: point.x / point.width, y: point.y / point.height },\n    columns,\n    rows,\n    direction,\n  )\n  const index = cells.findIndex((cell) => cell.column === column && cell.row === row)\n  return index === -1 ? null : index\n}\n\n/** Where a cell's tooltip sits: over the middle of its top edge, or a hexagon's top point, opening above it. */\nfunction cellAnchor(\n  cell: GridCell,\n  shape: CellShape,\n  columns: number,\n  rows: number,\n  direction: ReadingDirection,\n): ChartPoint {\n  const box = cellBox(shape, cell, columns, rows)\n  const along = box.x + box.width / 2\n  return {\n    x: direction === 'rtl' ? 1 - along : along,\n    y: box.y,\n    side: 'top',\n  }\n}\n\n/** What the cells' parts read, provided by `CellsChartFrame`. */\ninterface CellsContextValue {\n  /** Each part's `data-slot` prefix and `cellLayerVariables`' name: `heatmap-chart`. */\n  slot: string\n  /** The cells still in the data. */\n  cells: readonly GridStop[]\n  /** The cells drawn, the leaving ones too. */\n  drawn: readonly (GridStop & { leaving: boolean })[]\n  shape: CellShape\n  columns: number\n  rows: number\n  /** The key of the value that colours the cells. */\n  value: string\n  /** The values at the legend steps' edges, lowest first. */\n  edges: readonly number[]\n  /** The legend step brought forward, whose cells come forward, or null. */\n  emphasis: number | null\n  /** A cell's fill, or null for a cell with no value. */\n  fillOf: (stop: GridStop) => CellFill | null\n  /** A cell's name, such as its day. */\n  nameText: (stop: GridStop) => string\n  datumText: (value: unknown) => string\n}\n\nconst CellsContext = createContext<CellsContextValue | null>(null)\n\nfunction useCells() {\n  const cells = use(CellsContext)\n  if (!cells)\n    throw new Error(\n      'A chart’s cells go inside a chart of cells, such as a `HeatmapChart`.',\n    )\n  return cells\n}\n\n/** The value of a cell, or null for none. */\nfunction useCellValue() {\n  const { value } = useCells()\n  return (stop: GridStop) => numberOf(stop.datum?.[value])\n}\n\n/** What the legend of a colour's steps reads, from the chart it sits in. */\ninterface StepLegendContextValue {\n  /** Its `data-slot` prefix: `heatmap-chart`. */\n  slot: string\n  label: ReactNode\n  /** The values at the steps' edges, lowest first: one more than the steps. */\n  edges: readonly number[]\n  fillOf: (step: number) => CellFill | null\n  valueText: (value: number) => string\n  textWidth: (text: string) => number\n  /** The step brought forward, or null. */\n  emphasis: number | null\n  setEmphasis: (step: number | null) => void\n}\n\nconst StepLegendContext = createContext<StepLegendContextValue | null>(null)\n\nfunction useStepLegend() {\n  const legend = use(StepLegendContext)\n  if (!legend)\n    throw new Error(\n      'A legend of steps goes inside a chart whose colour steps, such as a `HeatmapChart`.',\n    )\n  return legend\n}\n\n/**\n * The `<figure>` of a chart of cells, on the root's frame: its reader, the\n * focus by the cells' places for `activeIndex`, the axes' names, the cells'\n * context and its placeholder. With `scrolls`, it scrolls sideways once a\n * column would be narrower than a cell can be pointed at, as a year of weeks\n * does, rather than squeeze them.\n */\nfunction CellsChartFrame({\n  chart,\n  reader,\n  cells,\n  axes,\n  scrolls,\n  description,\n  empty,\n  placeholder,\n  className,\n  style,\n  children,\n  ...props\n}: Omit<ComponentProps<'figure'>, 'ref'> & {\n  chart: CellsChart\n  reader: ChartReader\n  cells: CellsContextValue\n  /** The names along the top or bottom, and down the sides. */\n  axes: { x: CellAxis; y: CellAxis }\n  scrolls: boolean\n  description?: string\n  empty?: ReactNode\n  placeholder: ReactNode\n  ref?: Ref<HTMLElement>\n}) {\n  const { state, status } = chart\n  const root: ChartRootValue = {\n    ...state,\n    status,\n    reader,\n    markerOf: () => null,\n    selectable: chart.selectable,\n    picked: chart.picked === null ? null : { kind: 'x', key: chart.picked },\n    togglePicked: (target) => {\n      if (target.kind !== 'node') chart.togglePicked(target.key)\n    },\n  }\n  const { focusProps, toldRef } = useIndexFocus(reader.items, chart.activeProps)\n  // It scrolls only while it shows its cells, so a note in their place stays in view. It takes\n  // the opposite direction to the page, so it opens at its end, the latest column, from the\n  // first paint, and stays there as it narrows; its parts take the page's direction again.\n  const least = gridAcross(cells.shape, cells.columns, cells.rows) * LEAST_COLUMN\n  const most = mostWidth(cells.shape, cells.columns, cells.rows)\n  const scroller = scrolls && (status === 'ready' || status === 'hidden')\n  // Whether it overflows: until it is measured, it is taken to, so the axes that hold still\n  // hide what passes under them from the first paint.\n  const [fits, setFits] = useState(false)\n  const figure = state.root\n  useLayoutEffect(() => {\n    const frame = figure.current\n    if (!scroller || !frame) return\n    const measure = () => setFits(frame.scrollWidth <= frame.clientWidth)\n    measure()\n    const observer = new ResizeObserver(measure)\n    observer.observe(frame)\n    return () => observer.disconnect()\n  }, [scroller, figure, least])\n  // A new range opens at its end again.\n  const last = chart.cells.at(-1)?.key\n  useLayoutEffect(() => {\n    if (scroller) figure.current?.scrollTo({ left: 0, behavior: 'instant' })\n  }, [scroller, last, figure])\n  const overflows = scroller && !fits\n  return (\n    <ChartFrame\n      root={root}\n      focus={focusProps}\n      slot={cells.slot}\n      description={description}\n      empty={empty}\n      measuring={false}\n      inset={0}\n      data-scroller={scroller ? '' : undefined}\n      data-scrolls={overflows ? '' : undefined}\n      className={cn(\n        scroller &&\n          'scrollbar-thin grid-cols-[auto_minmax(var(--plot-least),1fr)_auto] overflow-x-auto overflow-y-hidden [grid-template-areas:\"top_top_top\"_\"._top-axis_.\"_\"end-axis_plot_start-axis\"_\"._bottom-axis_.\"_\"bottom_bottom_bottom\"]',\n        scroller &&\n          (state.direction === 'rtl'\n            ? '[direction:ltr] *:[direction:rtl]'\n            : '[direction:rtl] *:[direction:ltr]'),\n        // Cells that keep their shape stop widening at their widest, and room either side centres\n        // the chart. That room is flexible, so the names and the legend never take it.\n        most !== null &&\n          (scroller\n            ? 'grid-cols-[minmax(0,1fr)_auto_minmax(var(--plot-least),var(--plot-most))_auto_minmax(0,1fr)] [grid-template-areas:\"top_top_top_top_top\"_\"._._top-axis_._.\"_\"._end-axis_plot_start-axis_.\"_\"._._bottom-axis_._.\"_\"bottom_bottom_bottom_bottom_bottom\"]'\n            : 'grid-cols-[minmax(0,1fr)_auto_minmax(0,var(--plot-most))_auto_minmax(0,1fr)] [grid-template-areas:\"top_top_top_top_top\"_\"._._top-axis_._.\"_\"._start-axis_plot_end-axis_.\"_\"._._bottom-axis_._.\"_\"bottom_bottom_bottom_bottom_bottom\"]'),\n        className,\n      )}\n      style={\n        {\n          '--plot-least': scroller ? `${least}px` : undefined,\n          '--plot-most': most === null ? undefined : `${most}px`,\n          ...style,\n        } as CSSProperties\n      }\n      {...props}\n    >\n      <ChartAxesContext value={cellAxes(chart, axes)}>\n        <CellsContext value={cells}>\n          <IndexActive items={reader.items} active={chart.activeProps} toldRef={toldRef}>\n            {children}\n            {placeholder}\n          </IndexActive>\n        </CellsContext>\n      </ChartAxesContext>\n      {scroller && <ScrollCorners direction={state.direction} />}\n    </ChartFrame>\n  )\n}\n\n/**\n * What the shared axes read of a chart of cells: no frame, since no axis of\n * the grid reads a scale, and each axis's names, which wait for the cells as\n * the cells wait for the data.\n */\nfunction cellAxes(chart: CellsChart, axes: { x: CellAxis; y: CellAxis }): ChartAxesValue {\n  const laidOut = chart.status === 'ready' || chart.status === 'hidden'\n  const keys = chart.cells.map(cellKey)\n  const names = (axis: 'x' | 'y', keepInside: boolean): AxisNames => {\n    const own = axes[axis]\n    const shown = laidOut ? own.names : []\n    return {\n      all: shown,\n      current: shown,\n      nameOf: (target: ChartTarget) => {\n        const index = indexOfKey(keys, targetKey(target))\n        return index === null ? null : (chart.cells[index]?.[axis] ?? null)\n      },\n      format: own.format,\n      keepInside,\n    }\n  }\n  return {\n    frame: null,\n    orientation: 'vertical',\n    inset: 0,\n    // The rows are each a name's height or more, so they centre freely.\n    names: { x: names('x', true), y: names('y', false) },\n    summaryValues: () => [],\n    percent: false,\n  }\n}\n\n/** The corners beside the axes along the top and bottom of a chart that scrolls sideways, which hold still with the axes down its sides, so the names passing under them hide there too. */\nfunction ScrollCorners({ direction }: { direction: ReadingDirection }) {\n  return (['top', 'bottom'] as const).flatMap((row) =>\n    (['start', 'end'] as const).map((side) => (\n      <span\n        key={`${row}-${side}`}\n        aria-hidden\n        className={cn(\n          'pointer-events-none group-data-scrolls/chart:sticky group-data-scrolls/chart:z-40 group-data-scrolls/chart:bg-(--chart-surface,var(--card))',\n          row === 'top' ? '[grid-row:top-axis]' : '[grid-row:bottom-axis]',\n          side === 'start' ? '[grid-column:start-axis]' : '[grid-column:end-axis]',\n          stickTo(side, direction),\n        )}\n      />\n    )),\n  )\n}\n\n/** How many cells wide a grid is: its columns, and half a cell more for hexagons' odd rows. */\nfunction gridAcross(shape: CellShape, columns: number, rows: number) {\n  return 1 / cellBox(shape, { column: 0, row: 0 }, columns, rows).width\n}\n\n/** The tallest a grid's plot grows, in px: a cell's most for each row, up to the plot's most. */\nfunction mostHeight(rows: number) {\n  return Math.min(MOST_HEIGHT, rows * MOST_CELL)\n}\n\n/**\n * The widest the plot of cells that keep their shape grows, in px: as wide\n * as its tallest. Null for square cells, which widen instead.\n */\nfunction mostWidth(shape: CellShape, columns: number, rows: number): number | null {\n  if (shape === 'square') return null\n  return mostHeight(rows) * gridAspect(shape, columns, rows)\n}\n\n/**\n * Holds the plot to its cells' shape from the first paint. Square cells\n * stay square up to a height, or a cell's, then widen, and are no shorter\n * than a row a pointer can find; hexagons keep theirs at any width, and the\n * frame stops them widening (`mostWidth`).\n */\nfunction CellGridSizer({\n  shape,\n  columns,\n  rows,\n}: {\n  shape: CellShape\n  columns: number\n  rows: number\n}) {\n  return (\n    <div\n      aria-hidden\n      className='pointer-events-none w-full min-w-0 [grid-area:plot]'\n      style={\n        shape === 'square'\n          ? {\n              aspectRatio: `${columns} / ${rows}`,\n              maxHeight: mostHeight(rows),\n              minHeight: rows * LEAST_CELL,\n            }\n          : { aspectRatio: gridAspect(shape, columns, rows) }\n      }\n    />\n  )\n}\n\n/**\n * The room between cells: the chart's `--<slot>-gap`, 2px by default, or\n * less where the cells are small, so a cell never shrinks to its gap.\n */\nfunction cellGap(box: CellBox) {\n  return `min(var(--cells-gap, 2px), ${box.width * 100}cqw * 0.15, ${box.height * 100}cqh * 0.15)`\n}\n\n/**\n * Where a cell is drawn in its layer, as CSS lengths, inside its box by the\n * room between cells: half of it each side. A hexagon gives up as much\n * room across its slanted edges as across its upright ones, so it keeps\n * its shape: `2/√3` of it down.\n */\nfunction cellPlace(shape: CellShape, box: CellBox) {\n  const down = shape === 'hex' ? 2 / Math.sqrt(3) : 1\n  return {\n    gap: cellGap(box),\n    start: `calc(${box.x * 100}cqw + var(--cell-gap) / 2)`,\n    top: `calc(${box.y * 100}cqh + var(--cell-gap) * ${down / 2})`,\n    width: `calc(${box.width * 100}cqw - var(--cell-gap))`,\n    height: `calc(${box.height * 100}cqh - var(--cell-gap) * ${down})`,\n  }\n}\n\n/*\n * A hexagon's outline, pointy-top, in its box. Its corners round as square\n * cells' do, by the shape tokens: a corner of radius ρ starts ρ/√3 along\n * each edge, at most half way, so the round shape turns them almost into\n * circles, as it turns square cells into circles. A browser without CSS\n * `shape()` draws them sharp.\n */\nconst HEX_SHARP = 'polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%)'\n// ρ is a third of --control-radius-xs, as square cells' corners are: these are ρ/√3 along an edge, across and down.\nconst HEX_X = 'min(calc(var(--control-radius-xs) / 6), 25%)'\nconst HEX_SLANT = 'min(calc(var(--control-radius-xs) / 10.3923), 12.5%)'\nconst HEX_UPRIGHT = 'min(calc(var(--control-radius-xs) / 5.1962), 25%)'\nconst HEX_ROUND = `shape(from calc(50% + ${HEX_X}) ${HEX_SLANT}, line to calc(100% - ${HEX_X}) calc(25% - ${HEX_SLANT}), curve to 100% calc(25% + ${HEX_UPRIGHT}) with 100% 25%, line to 100% calc(75% - ${HEX_UPRIGHT}), curve to calc(100% - ${HEX_X}) calc(75% + ${HEX_SLANT}) with 100% 75%, line to calc(50% + ${HEX_X}) calc(100% - ${HEX_SLANT}), curve to calc(50% - ${HEX_X}) calc(100% - ${HEX_SLANT}) with 50% 100%, line to ${HEX_X} calc(75% + ${HEX_SLANT}), curve to 0% calc(75% - ${HEX_UPRIGHT}) with 0% 75%, line to 0% calc(25% + ${HEX_UPRIGHT}), curve to ${HEX_X} calc(25% - ${HEX_SLANT}) with 0% 25%, line to calc(50% - ${HEX_X}) ${HEX_SLANT}, curve to calc(50% + ${HEX_X}) ${HEX_SLANT} with 50% 0%, close)`\n\n/** Clips an element to a hexagon: rounded where the browser can, from `cellLayerVariables`. */\nconst hexClipClassName =\n  '[clip-path:var(--hex-sharp)] supports-[clip-path:shape(from_0_0,line_to_1px_1px)]:[clip-path:var(--hex-round)]'\n\n/** A cell's colour, and how strong it is, which forced colours keep as its opacity. */\ninterface CellFill {\n  color: string\n  strength: number\n}\n\n/** The colour of a step `strength` strong, in the colour of `key`, over the page's muted fill. */\nfunction stepColor(key: string, strength: number): string {\n  return `color-mix(in oklab, ${seriesColor(key)} ${Math.round(strength * 100)}%, var(--muted))`\n}\n\n/** The fill of a step among `steps`, in the colour of `key`; none for no step. */\nfunction stepFill(key: string, step: number | null, steps: number): CellFill | null {\n  if (step === null) return null\n  const strength = stepStrength(step, steps)\n  return { color: stepColor(key, strength), strength }\n}\n\n/**\n * What the cells write on themselves: each cell's value by its key, and the\n * least room a cell is drawn at that the widest fits, so the values show on\n * every cell or on none, never on some cells of a size.\n */\ninterface CellLabels {\n  textOf: ReadonlyMap<string, string>\n  /** The least width and height, in px. */\n  room: { width: number; height: number }\n}\n\n/** No values written on the cells: one object, so what compares it sees no change. */\nconst NO_LABELS: CellLabels = {\n  textOf: new Map(),\n  room: { width: 0, height: 0 },\n}\n\n/** The values the cells write on themselves, while `on`, worked out once for the grid. */\nfunction useCellLabels(on: boolean): CellLabels {\n  const { textWidth, locale, format, valueText } = useChartRootValue()\n  const { cells, shape, value } = useCells()\n  return useMemo(\n    () => {\n      if (!on) return NO_LABELS\n      const textOf = new Map<string, string>()\n      for (const stop of cells) {\n        const number = numberOf(stop.datum?.[value])\n        if (number !== null) textOf.set(stop.key, valueText(number))\n      }\n      const widest = Math.max(0, ...[...new Set(textOf.values())].map(textWidth))\n      return {\n        textOf,\n        room: labelRoom(shape, widest + 2 * LABEL_PAD, LABEL_HEIGHT),\n      }\n    },\n    // `valueText` is made from `locale` and `format` on every render of the root.\n    // oxlint-disable-next-line react-hooks/exhaustive-deps\n    [on, cells, shape, value, textWidth, locale, format],\n  )\n}\n\n/** The least room a layer's cells write their values in, which `CellText` reads. */\nfunction labelRoomVariables({ room }: CellLabels) {\n  return {\n    '--cells-label-width': `${room.width}px`,\n    '--cells-label-height': `${room.height}px`,\n  } as CSSProperties\n}\n\n/**\n * The cells: one layer of the plot, a cell for each column and row, in its\n * colour, and a dashed outline where there is no value, or a hollow\n * hexagon. While a cell is lit, the layer steps back as one, a single\n * filter whatever the number of cells, and the lit cell is drawn again over\n * it, bright and outlined; hexagons around it are drawn again too, in\n * rings that step back less the nearer they are, a filter each. Pointing\n * at a step of the legend brings its cells forward the same way. When the\n * pointer leaves, the copies fade as the layer comes back, so nothing\n * blinks. With `label`, each cell writes its value where it fits.\n */\nfunction CellGridCells({\n  label = false,\n  className,\n  style,\n  ...props\n}: Omit<ComponentProps<'div'>, 'children'> & {\n  label?: boolean\n}) {\n  const { status, direction } = useChartRootValue()\n  const grid = useCells()\n  const valueOf = useCellValue()\n  const labels = useCellLabels(label)\n  const { spotlit } = useChartActive()\n  const lit = spotlit === null ? undefined : grid.cells[spotlit]\n  // The last cell lit and the last step brought forward, kept while their copies fade.\n  const [held, setHeld] = useState<{ lit: string | null; step: number | null }>({\n    lit: null,\n    step: null,\n  })\n  if (lit && lit.key !== held.lit) setHeld({ ...held, lit: lit.key })\n  if (grid.emphasis !== null && grid.emphasis !== held.step) {\n    setHeld({ ...held, step: grid.emphasis })\n  }\n  if (status === 'empty') return null\n  const brought =\n    held.step === null\n      ? []\n      : grid.cells.filter((stop) => stepOf(valueOf(stop), grid.edges) === held.step)\n  const dim = lit !== undefined || grid.emphasis !== null\n  const shown = grid.cells.find((stop) => stop.key === held.lit)\n  // The rings between the lit cell and the rest, nearest first; square cells have none.\n  const rings = Array.from({ length: SPOTLIGHT_RINGS - 1 }, (_, at) =>\n    shown\n      ? grid.cells.filter((stop) => spotlightRing(grid.shape, shown, stop) === at + 1)\n      : [],\n  )\n  return (\n    <>\n      <CellLayer\n        dim={dim}\n        labels={labels}\n        className={className}\n        style={style}\n        {...props}\n      />\n      {rings.map(\n        (ring, at) =>\n          ring.length > 0 && (\n            <div\n              // oxlint-disable-next-line react/no-array-index-key -- a ring is its distance\n              key={at}\n              data-slot={`${grid.slot}-ring`}\n              data-off={lit === undefined ? '' : undefined}\n              data-dim=''\n              aria-hidden\n              className={cn(\n                plotLayerClassName,\n                stepBackLayerClassName,\n                'z-11 transition-opacity duration-(--motion-layout-duration) ease-(--motion-layout-fade-easing) starting:opacity-0 data-off:opacity-0',\n              )}\n              style={\n                {\n                  ...cellLayerVariables(grid.slot),\n                  ...labelRoomVariables(labels),\n                  // Each ring keeps more of its colour the nearer it is, between the lit cell's and the rest's.\n                  '--mark-step': (at + 1) / SPOTLIGHT_RINGS,\n                } as CSSProperties\n              }\n            >\n              {ring.map((stop) => (\n                <CellGridCell\n                  // By its step from the lit cell, so moving the light moves each copy rather than making new ones.\n                  key={shown ? hexStepKey(shown, stop) : stop.key}\n                  {...cellProps(grid, stop, labels)}\n                  leaving={false}\n                  still\n                />\n              ))}\n            </div>\n          ),\n      )}\n      <div\n        data-slot={`${grid.slot}-lit`}\n        data-off={grid.emphasis === null ? '' : undefined}\n        aria-hidden\n        className={cn(\n          plotLayerClassName,\n          'z-11 transition-opacity duration-(--motion-layout-duration) ease-(--motion-layout-fade-easing) data-off:opacity-0',\n        )}\n        style={{\n          ...cellLayerVariables(grid.slot),\n          ...labelRoomVariables(labels),\n        }}\n      >\n        {brought.map((stop) => (\n          <CellGridCell\n            key={stop.key}\n            {...cellProps(grid, stop, labels)}\n            leaving={false}\n            still\n          />\n        ))}\n      </div>\n      {shown && (\n        <LitCell\n          {...cellProps(grid, shown, labels)}\n          labels={labels}\n          on={lit !== undefined}\n          direction={direction}\n        />\n      )}\n    </>\n  )\n}\n\n/** A cell's props, as plain values, so a cell whose colour is the same redraws nothing. */\nfunction cellProps(grid: CellsContextValue, stop: GridStop, labels: CellLabels) {\n  const fill = grid.fillOf(stop)\n  return {\n    slot: grid.slot,\n    shape: grid.shape,\n    column: stop.column,\n    row: stop.row,\n    columns: grid.columns,\n    rows: grid.rows,\n    color: fill?.color ?? null,\n    strength: fill?.strength ?? 0,\n    label: labels.textOf.get(stop.key),\n  }\n}\n\n/**\n * How much of the `draw` role the wave waits and the room between cells:\n * the chart's own variables, such as `--heatmap-chart-wave` and\n * `--heatmap-chart-gap`, set on its layer of cells for the cells inside,\n * with a hexagon's outline.\n */\nfunction cellLayerVariables(slot: string) {\n  return {\n    '--cells-wave': `var(--${slot}-wave, 0.6)`,\n    '--cells-gap': `var(--${slot}-gap, 2px)`,\n    '--hex-sharp': HEX_SHARP,\n    '--hex-round': HEX_ROUND,\n  } as CSSProperties\n}\n\n/**\n * The layer of every cell, which steps back as one while `dim`. Memoised,\n * so moving from cell to cell redraws none of it.\n */\nconst CellLayer = memo(function CellLayer({\n  dim,\n  labels,\n  className,\n  style,\n  ...props\n}: Omit<ComponentProps<'div'>, 'children'> & {\n  dim: boolean\n  labels: CellLabels\n}) {\n  const grid = useCells()\n  return (\n    <div\n      data-slot={`${grid.slot}-cells`}\n      data-dim={dim ? '' : undefined}\n      aria-hidden\n      className={cn(plotLayerClassName, 'z-10', stepBackLayerClassName, className)}\n      style={\n        {\n          ...cellLayerVariables(grid.slot),\n          ...labelRoomVariables(labels),\n          ...style,\n        } as CSSProperties\n      }\n      {...props}\n    >\n      {grid.drawn.map((stop) => (\n        <CellGridCell\n          key={stop.key}\n          {...cellProps(grid, stop, labels)}\n          leaving={stop.leaving}\n        />\n      ))}\n    </div>\n  )\n})\n\n/**\n * The lit cell, drawn over the rest, bright and outlined: one element that\n * moves to each cell lit with a transform, so lighting a cell lays nothing\n * out, and fades on the `layout` role as the cells come back. A hexagon's\n * outline is a hexagon of its own behind it, as square cells' outline is\n * clear of them by a pixel.\n */\nfunction LitCell({\n  slot,\n  shape,\n  column,\n  row,\n  columns,\n  rows,\n  color,\n  label,\n  labels,\n  on,\n  direction,\n}: {\n  slot: string\n  shape: CellShape\n  column: number\n  row: number\n  columns: number\n  rows: number\n  color: string | null\n  strength: number\n  label?: string\n  labels: CellLabels\n  on: boolean\n  direction: 'ltr' | 'rtl'\n}) {\n  const place = cellPlace(shape, cellBox(shape, { column, row }, columns, rows))\n  const sign = direction === 'rtl' ? -1 : 1\n  const hex = shape === 'hex'\n  // A hexagon's outline: 2px wide, clear of the cell by 1px, as square cells' is.\n  const out = hex ? 3 : 0\n  return (\n    <div\n      aria-hidden\n      className={cn(plotLayerClassName, 'z-11')}\n      style={{ ...cellLayerVariables(slot), ...labelRoomVariables(labels) }}\n    >\n      <span\n        data-slot={`${slot}-lit-cell`}\n        data-off={on ? undefined : ''}\n        data-empty={color === null ? '' : undefined}\n        className={cn(\n          'absolute start-0 top-0 transition-opacity duration-(--motion-layout-duration) ease-(--motion-layout-fade-easing) data-off:opacity-0',\n          hex\n            ? cn('bg-foreground forced-colors:bg-[Highlight]', hexClipClassName)\n            : 'outline-foreground rounded-[min(calc(var(--control-radius-xs)/3),50%)] bg-(--cell-fill) outline-2 outline-offset-1 data-empty:bg-transparent forced-colors:bg-[CanvasText] forced-colors:outline-[Highlight] forced-colors:data-empty:bg-transparent',\n        )}\n        style={\n          {\n            '--cell-fill': color ?? undefined,\n            '--cell-gap': place.gap,\n            '--label-on': color ?? undefined,\n            width: `calc(${place.width} + ${2 * out}px)`,\n            height: `calc(${place.height} + ${(4 * out) / Math.sqrt(3)}px)`,\n            transform: `translate(calc(${sign} * (${place.start} - ${out}px)), calc(${place.top} - ${(2 * out) / Math.sqrt(3)}px))`,\n          } as CSSProperties\n        }\n      >\n        {hex ? (\n          // The 1px clear of the cell, then the cell: hexagons 2px and 3px inside the outline.\n          <span\n            className={cn(\n              'absolute inset-x-0.5 inset-y-[calc(4px/sqrt(3))] bg-(--chart-surface,var(--card)) forced-colors:bg-[Canvas]',\n              hexClipClassName,\n            )}\n          >\n            <span\n              className={cn(\n                'absolute inset-x-px inset-y-[calc(2px/sqrt(3))] bg-(--cell-fill) in-data-empty:bg-transparent forced-colors:bg-[CanvasText] forced-colors:in-data-empty:bg-transparent',\n                hexClipClassName,\n              )}\n            >\n              <CellText text={label} still />\n            </span>\n          </span>\n        ) : (\n          <CellText text={label} still />\n        )}\n      </span>\n    </div>\n  )\n}\n\n/**\n * A cell's value, written on it while the cell is drawn at least its\n * layer's `--cells-label-width` by `--cells-label-height`: a box that is the cell's size while it has the room and\n * none without, so the browser decides as the plot resizes, and the first\n * paint is right. It reads on the cell's colour, `--label-on`, and fades in\n * on the cell's wave when the value changes.\n */\nfunction CellText({\n  text,\n  still = false,\n}: {\n  text: string | undefined\n  still?: boolean\n}) {\n  if (text === undefined) return null\n  return (\n    <span\n      className='absolute start-0 top-0 h-full overflow-hidden'\n      style={{\n        width: 'clamp(0px, (100% - var(--cells-label-width)) * 1000, 100%)',\n      }}\n    >\n      <span\n        className='absolute inset-x-0 top-0 flex items-center justify-center overflow-hidden'\n        style={{\n          height: 'clamp(0px, (100% - var(--cells-label-height)) * 1000, 100%)',\n        }}\n      >\n        <span\n          key={text}\n          className={cn(\n            'leading-none font-medium whitespace-nowrap tabular-nums',\n            labelOnClassName,\n            !still &&\n              'transition-none group-data-mounted/chart:[transition:opacity_var(--cell-span)_var(--motion-draw-fade-easing)_var(--cell-delay)] group-data-mounted/chart:starting:opacity-0 motion-reduce:group-data-mounted/chart:[transition:opacity_var(--motion-draw-duration)_var(--motion-draw-fade-easing)]',\n          )}\n        >\n          {text}\n        </span>\n      </span>\n    </span>\n  )\n}\n\n/**\n * One cell, at `column` and `row` of a grid `columns` by `rows`, in its\n * `fill`, or with none, a dashed outline, or a hollow hexagon. Its colour\n * fades on the `draw` role, later and quicker the further `along` it is,\n * its column by default, so a new range sweeps across and every cell lands\n * within one `draw`. One that arrives fades in the same way, over one that\n * leaves from its place, which waits below until the new one has landed. A\n * `still` one, a copy over the rest, is simply there. Memoised, so lighting\n * a cell redraws none of them.\n */\nconst CellGridCell = memo(function CellGridCell({\n  slot,\n  shape,\n  column,\n  row,\n  columns,\n  rows,\n  color,\n  strength,\n  leaving,\n  still = false,\n  along: given,\n  image,\n  forced,\n  label,\n}: {\n  slot: string\n  shape: CellShape\n  column: number\n  row: number\n  columns: number\n  rows: number\n  /** The cell's colour, or none for a cell with no value. */\n  color: string | null\n  strength: number\n  leaving: boolean\n  still?: boolean\n  /** How far along the wave the cell is, from 0 to 1; its column's place by default. */\n  along?: number\n  /** A pattern drawn over the colour, from `patternImage`. */\n  image?: string\n  /** The cell's colour under forced colours, a class; the text colour, as strong as its fill, by default. */\n  forced?: string\n  /** The value it writes on itself where its layer's room fits it (`useCellLabels`), if any. */\n  label?: string\n}) {\n  const along = given ?? (columns <= 1 ? 0 : column / (columns - 1))\n  // The pattern shown before this one, kept while it fades out as the new one fades in.\n  const [patterns, setPatterns] = useState<{ now?: string; was?: string }>({\n    now: image,\n  })\n  if (patterns.now !== image) setPatterns({ now: image, was: patterns.now })\n  const shown =\n    color === null ? [] : [patterns.was, image].filter((one) => one !== undefined)\n  const hex = shape === 'hex'\n  const place = cellPlace(shape, cellBox(shape, { column, row }, columns, rows))\n  return (\n    <span\n      data-slot={`${slot}-cell`}\n      data-leaving={leaving ? '' : undefined}\n      data-still={still ? '' : undefined}\n      data-empty={color === null ? '' : undefined}\n      className={cn(\n        'absolute z-1 bg-(--cell-fill) transition-none group-data-mounted/chart:[transition:background-color_var(--cell-span)_var(--motion-draw-fade-easing)_var(--cell-delay),opacity_var(--cell-span)_var(--motion-draw-fade-easing)_var(--cell-delay)] motion-reduce:group-data-mounted/chart:[transition:background-color_var(--motion-draw-duration)_var(--motion-draw-fade-easing),opacity_var(--motion-draw-duration)_var(--motion-draw-fade-easing)] group-data-mounted/chart:starting:opacity-0 data-still:transition-none!',\n        // A cell that leaves waits under the one arriving in its place, then goes.\n        'data-leaving:z-0 data-leaving:opacity-0 group-data-mounted/chart:data-leaving:[transition:opacity_var(--motion-exit-duration)_var(--motion-exit-fade-easing)_var(--motion-draw-duration)]',\n        // Forced colours take the fills away, so each cell is the text colour, as strong as its fill:\n        // the page over it where it is weaker, so a value written on it keeps its contrast.\n        \"forced-colors:bg-[CanvasText] forced-colors:before:absolute forced-colors:before:inset-0 forced-colors:before:rounded-[inherit] forced-colors:before:bg-[Canvas] forced-colors:before:opacity-[calc(1-var(--cell-strength))] forced-colors:before:content-[''] forced-colors:data-empty:before:hidden\",\n        hex\n          ? cn(\n              // A hexagon with no value is hollow: its outline is the cell, and a hexagon inside it the page.\n              'data-empty:bg-border forced-colors:data-empty:bg-[GrayText]',\n              hexClipClassName,\n            )\n          : 'rounded-[min(calc(var(--control-radius-xs)/3),50%)] data-empty:bg-transparent data-empty:outline-1 data-empty:-outline-offset-1 data-empty:outline-border data-empty:outline-dashed forced-colors:data-empty:bg-transparent forced-colors:data-empty:outline-[GrayText]',\n        forced,\n      )}\n      style={\n        {\n          '--cell-fill': color ?? undefined,\n          '--cell-strength': strength,\n          '--label-on': color ?? undefined,\n          // The wave: a cell further along waits longer and fades quicker, so all land within one `draw`.\n          '--cell-delay': `calc(var(--motion-draw-duration) * var(--cells-wave) * ${along})`,\n          '--cell-span': `calc(var(--motion-draw-duration) * (1 - var(--cells-wave) * ${along}))`,\n          '--cell-gap': place.gap,\n          insetInlineStart: place.start,\n          top: place.top,\n          width: place.width,\n          height: place.height,\n        } as CSSProperties\n      }\n    >\n      {hex && color === null && (\n        // 1px in across its upright edges, and as far across its slanted ones.\n        <span\n          className={cn(\n            'absolute inset-x-px inset-y-[calc(2px/sqrt(3))] bg-(--chart-surface,var(--card)) forced-colors:bg-[Canvas]',\n            hexClipClassName,\n          )}\n        />\n      )}\n      {/* A pattern can't fade into another, so each is a layer of its own that fades in or out on the cell's wave. */}\n      {shown.map((pattern) => (\n        <span\n          key={pattern}\n          data-off={pattern === image ? undefined : ''}\n          className='absolute inset-0 rounded-[inherit] transition-none group-data-mounted/chart:[transition:opacity_var(--cell-span)_var(--motion-draw-fade-easing)_var(--cell-delay)] motion-reduce:group-data-mounted/chart:[transition:opacity_var(--motion-draw-duration)_var(--motion-draw-fade-easing)] group-data-mounted/chart:starting:opacity-0 data-off:opacity-0 in-data-still:transition-none!'\n          style={{ background: pattern }}\n        />\n      ))}\n      <CellText text={label} still={still} />\n    </span>\n  )\n})\n\n/**\n * A cell's tooltip: its name, such as its day, and its value beside a\n * swatch of its colour.\n */\nfunction CellGridTooltipContent({ stop, name }: { stop: GridStop; name: ReactNode }) {\n  const { id } = useChartRootValue()\n  const grid = useCells()\n  const fill = grid.fillOf(stop)\n  return (\n    // The tooltip sits outside the chart, so it carries the chart's id for its colours.\n    <div data-chart={id} className='grid min-w-36 gap-1'>\n      <div className='font-medium'>{grid.nameText(stop)}</div>\n      <div className='flex items-center gap-2'>\n        <span\n          aria-hidden\n          className={cn(\n            'size-2 shrink-0 rounded-[calc(var(--control-radius-xs)/4)]',\n            fill === null\n              ? 'border-background/50 border border-dashed forced-colors:border-[CanvasText]'\n              : 'bg-(--cell-fill) forced-colors:bg-[CanvasText]',\n          )}\n          style={\n            fill === null ? undefined : ({ '--cell-fill': fill.color } as CSSProperties)\n          }\n        />\n        <span className='text-background/75 min-w-0 flex-1 truncate forced-colors:text-[CanvasText]'>\n          {name}\n        </span>\n        {/* A value with a unit reads in its own order whatever the page's direction. */}\n        <span dir='auto' className='font-medium tabular-nums'>\n          {grid.datumText(stop.datum?.[grid.value])}\n        </span>\n      </div>\n    </div>\n  )\n}\n\n/**\n * The colour's steps, from the lowest to the highest, with the value at\n * each edge, under or over the plot. Pointing at a step brings its cells\n * forward. A screen reader reads each step's range.\n */\nfunction CellStepLegend({\n  position = 'bottom',\n  className,\n  ...props\n}: Omit<ComponentProps<'div'>, 'children'> & { position?: 'top' | 'bottom' }) {\n  const { status } = useChartRootValue()\n  const legend = useStepLegend()\n  const { edges, label } = legend\n  const steps = edges.length - 1\n  if (status !== 'ready' || steps < 1) return null\n  return (\n    <div\n      data-slot={`${legend.slot}-legend`}\n      className={cn(\n        'flex flex-wrap items-center justify-end gap-x-3 gap-y-1',\n        // While the chart scrolls sideways, it stays in view at the width the chart shows.\n        'group-data-scrolls/chart:sticky group-data-scrolls/chart:inset-x-0 group-data-scrolls/chart:w-[100cqw]',\n        position === 'top' ? 'pb-3 [grid-area:top]' : 'pt-3 [grid-area:bottom]',\n        className,\n      )}\n      {...props}\n    >\n      <span className='text-muted-foreground font-medium'>{label}</span>\n      <ul\n        aria-label={typeof label === 'string' ? label : undefined}\n        className='flex max-w-full min-w-0 items-start'\n        onPointerLeave={() => legend.setEmphasis(null)}\n      >\n        {Array.from({ length: steps }, (_, step) => {\n          const from = legend.valueText(edges[step]!)\n          const to = legend.valueText(edges[step + 1]!)\n          // Wide enough that the values at its two edges never meet.\n          const width = Math.max(\n            32,\n            legend.textWidth(from) / (step === 0 ? 1 : 2) +\n              legend.textWidth(to) / (step === steps - 1 ? 1 : 2) +\n              LEGEND_GAP,\n          )\n          const fill = legend.fillOf(step)\n          return (\n            <li\n              // oxlint-disable-next-line react/no-array-index-key -- a step is its place\n              key={step}\n              className='group/step relative flex flex-col items-stretch gap-1 px-px pb-4'\n              // Narrower when the chart is, down to a swatch that still reads.\n              style={{ width, flex: '0 1 auto', minWidth: 12 }}\n              onPointerEnter={() => legend.setEmphasis(step)}\n            >\n              <span\n                aria-hidden\n                className='h-2.5 rounded-[min(calc(var(--control-radius-xs)/3),50%)] bg-(--cell-fill) transition-[background-color] duration-(--motion-draw-duration) ease-(--motion-draw-fade-easing) forced-colors:bg-[CanvasText] forced-colors:opacity-(--cell-strength)'\n                style={\n                  {\n                    '--cell-fill': fill?.color,\n                    '--cell-strength': fill?.strength,\n                  } as CSSProperties\n                }\n              />\n              <span className='sr-only'>\n                {from} – {to}\n              </span>\n              {/* The value at the step's start, and at the last step's end too. */}\n              {/* A signed value reads in its own order whatever the page's direction. */}\n              <span\n                aria-hidden\n                dir='auto'\n                // The first sits from the legend's start, so it stays inside it; the rest centre on their edge.\n                className={cn(\n                  'text-muted-foreground absolute start-0 bottom-0 whitespace-nowrap tabular-nums',\n                  // In a narrow chart, only the two ends are written; a screen reader still reads every step.\n                  step > 0 && '-translate-x-1/2 rtl:translate-x-1/2 @max-md/chart:hidden',\n                )}\n              >\n                {from}\n              </span>\n              {step === steps - 1 && (\n                <span\n                  aria-hidden\n                  dir='auto'\n                  className='text-muted-foreground absolute end-0 bottom-0 whitespace-nowrap tabular-nums'\n                >\n                  {to}\n                </span>\n              )}\n            </li>\n          )\n        })}\n      </ul>\n    </div>\n  )\n}\n\n/**\n * The placeholder while the data loads: the grid's cells, breathing slowly,\n * where the cells will land, in the box the cells take, the whole plot by\n * default.\n */\nfunction CellGridPlaceholder({\n  slot,\n  shape,\n  columns,\n  rows,\n  className,\n  style,\n}: {\n  slot: string\n  shape: CellShape\n  columns: number\n  rows: number\n  className?: string\n  style?: CSSProperties\n}) {\n  return (\n    <div\n      data-slot={`${slot}-placeholder`}\n      aria-hidden\n      style={cellLayerVariables(slot)}\n      className={cn(\n        plotLayerClassName,\n        'z-10 transition-opacity duration-(--motion-enter-duration) ease-(--motion-enter-easing) group-data-mounted/chart:starting:opacity-0',\n      )}\n    >\n      <div\n        className={cn('absolute inset-0', placeholderBreatheClassName, className)}\n        style={style}\n      >\n        {Array.from({ length: columns * rows }, (_, at) => {\n          const place = cellPlace(\n            shape,\n            cellBox(\n              shape,\n              { column: at % columns, row: Math.floor(at / columns) },\n              columns,\n              rows,\n            ),\n          )\n          return (\n            <span\n              // oxlint-disable-next-line react/no-array-index-key -- a cell is its place\n              key={at}\n              className={cn(\n                'absolute',\n                shape === 'hex'\n                  ? hexClipClassName\n                  : 'rounded-[min(calc(var(--control-radius-xs)/3),50%)]',\n                placeholderFillClassName,\n              )}\n              style={\n                {\n                  '--cell-gap': place.gap,\n                  insetInlineStart: place.start,\n                  top: place.top,\n                  width: place.width,\n                  height: place.height,\n                } as CSSProperties\n              }\n            />\n          )\n        })}\n      </div>\n    </div>\n  )\n}\n\nexport {\n  type CellAt,\n  type CellAxis,\n  cellAnchor,\n  cellAt,\n  type CellFill,\n  CellGridCell,\n  CellGridCells,\n  type CellGridLayout,\n  CellGridPlaceholder,\n  CellGridSizer,\n  CellGridTooltipContent,\n  cellLayerVariables,\n  type CellsChart,\n  CellsChartFrame,\n  type CellsContextValue,\n  CellStepLegend,\n  laidOutCells,\n  lineNames,\n  StepLegendContext,\n  type StepLegendContextValue,\n  stepFill,\n  useCellsChart,\n  useCellValue,\n}\n",
      "type": "registry:lib",
      "target": "@lib/chart-cells.tsx"
    }
  ],
  "type": "registry:lib"
}