{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "line-chart",
  "type": "registry:item",
  "title": "Line Chart",
  "description": "A price chart: an area under a line, with the high, low and a crosshair that follows the pointer and shows the value under it.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "display"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/line-chart.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/line-chart.js",
      "content": "// Generated by zubra from line-chart.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { emit } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"line-chart\";\n\nexport default $define(tag, {\n  props: {\n    \"points\": { attribute: \"points\", default: [], required: false },\n    \"label\": { attribute: \"label\", default: \"Price\", required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [],\n  events: [\"pointhover\"],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (line-chart) to ([data-zb-slotted=\\\"line-chart\\\"]) {\\n  :scope { display: block; position: relative; }\\n  svg { display: block; width: 100%; height: 14rem; }\\n  .area { fill: var(--primary, #4f5df5); opacity: 0.12; }\\n  .line { fill: none; stroke: var(--primary, #4f5df5); stroke-width: 2; vector-effect: non-scaling-stroke; }\\n  .grid { stroke: var(--border, #d9dce3); stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }\\n  .cross { stroke: var(--muted-foreground, #667085); vector-effect: non-scaling-stroke; }\\n  .dot { fill: var(--card, #ffffff); stroke: var(--primary, #4f5df5); stroke-width: 2; vector-effect: non-scaling-stroke; }\\n  .labels { position: absolute; inset: 0 auto 0 0; display: flex; flex-direction: column; justify-content: space-between; padding: 0.2rem 0; font-size: 0.7rem; color: var(--muted-foreground, #667085); pointer-events: none; font-variant-numeric: tabular-nums; }\\n  .tip { position: absolute; top: 0.25rem; right: 0.25rem; padding: 0.2rem 0.5rem; border-radius: calc(var(--radius, 0.625rem) * 0.64); background: var(--foreground, #1d2130); color: var(--card, #ffffff); font-size: 0.8125rem; font-weight: 700; font-variant-numeric: tabular-nums; }\\n}\\n}\\n\",\n  template: \"\\n  <svg preserveAspectRatio=\\\"none\\\" role=\\\"img\\\">\\n    <line class=\\\"grid\\\" x1=\\\"0\\\" y1=\\\"12\\\" y2=\\\"12\\\"></line>\\n    <line class=\\\"grid\\\" x1=\\\"0\\\"></line>\\n    <path class=\\\"area\\\"></path>\\n    <path class=\\\"line\\\"></path>\\n    <!--[--><!--]-->\\n  </svg>\\n  <div class=\\\"labels\\\" aria-hidden=\\\"true\\\"><span class=\\\"high\\\"></span><span class=\\\"low\\\"></span></div>\\n  <!--[--><!--]-->\\n\",\n  setup($p, $emit) {\n    const emit = $emit;\nfunction __zubraAssign(signal, value) { signal.set(value); return value }\nfunction __zubraUpdate(signal, delta, prefix) { const old = signal.get(); signal.set(old + delta); return prefix ? old + delta : old }\n                                       \n\n  const W = 600\n  const H = 220\n  const hover = __zubraState(-1)\n  const low = __zubraComputed(() => (Math.min(...$p.points)))\n  const high = __zubraComputed(() => (Math.max(...$p.points)))\n  const span = __zubraComputed(() => (high.get() - low.get() || 1))\n  const x = (index) => (index / Math.max(1, $p.points.length - 1)) * W\n  const y = (value) => H - 12 - ((value - low.get()) / span.get()) * (H - 24)\n  const line = __zubraComputed(() => ($p.points.map((value, index) => `${index ? \"L\" : \"M\"}${x(index).toFixed(1)},${y(value).toFixed(1)}`).join(\"\")))\n  const area = __zubraComputed(() => ($p.points.length ? `${line.get()}L${W},${H}L0,${H}Z` : \"\"))\n  const shown = __zubraComputed(() => (hover.get() >= 0 && hover.get() < $p.points.length ? hover.get() : -1))\n\n  function move(event) {\n    const box = event.currentTarget.getBoundingClientRect()\n    const index = Math.round(((event.clientX - box.left) / box.width) * ($p.points.length - 1))\n    const next = Math.max(0, Math.min($p.points.length - 1, index))\n    if (next === hover.get()) return\n    __zubraAssign(hover, next)\n    emit('pointhover', next)\n  }\n  function leave() {\n    __zubraAssign(hover, -1)\n    emit('pointhover', -1)\n  }\n    return [\n      { path: [0], attribute: \"viewBox\", value: () => (`0 0 ${W} ${H}`) },\n      { path: [0], attribute: \"aria-label\", value: () => (`${$p.label}: ${$p.points.length} points from ${low.get().toFixed(2)} to ${high.get().toFixed(2)}`) },\n      { path: [0], on: \"pointermove\", handler: () => $r(move) },\n      { path: [0], on: \"pointerleave\", handler: () => $r(leave) },\n      { path: [0, 0], attribute: \"x2\", value: () => $r(W) },\n      { path: [0, 1], attribute: \"x2\", value: () => $r(W) },\n      { path: [0, 1], attribute: \"y1\", value: () => ($r(H) - 12) },\n      { path: [0, 1], attribute: \"y2\", value: () => ($r(H) - 12) },\n      { path: [0, 2], attribute: \"d\", value: () => $r(area) },\n      { path: [0, 3], attribute: \"d\", value: () => $r(line) },\n      { path: [0, 4], when: () => ($r(shown) >= 0), blocks: [{ template: \"\\n      <line class=\\\"cross\\\" y1=\\\"0\\\"></line>\\n      <circle class=\\\"dot\\\" r=\\\"4\\\"></circle>\\n    \", parts: () => [{ path: [0], attribute: \"x1\", value: () => (x(shown.get())) }, { path: [0], attribute: \"x2\", value: () => (x(shown.get())) }, { path: [0], attribute: \"y2\", value: () => $r(H) }, { path: [1], attribute: \"cx\", value: () => (x(shown.get())) }, { path: [1], attribute: \"cy\", value: () => (y($p.points[shown.get()])) }] }, null] },\n      { path: [1, 0], text: () => $t((high.get().toFixed(2))) },\n      { path: [1, 1], text: () => $t((low.get().toFixed(2))) },\n      { path: [2], when: () => ($r(shown) >= 0), blocks: [{ template: \"<span class=\\\"tip\\\"></span>\", parts: () => [{ path: [0], text: () => $t(($p.points[shown.get()].toFixed(2))) }] }, null] },\n    ];\n  },\n});\n"
    }
  ]
}
