import { a as attr, f as stringify, g as derived } from './dev-BNpEUZI3.js';

//#region src/lib/components/shell/Sparkline.svelte
function Sparkline($$renderer, $$props) {
	$$renderer.component(($$renderer) => {
		/**
		* Props for {@link Sparkline}.
		*/
		/** Data points (oldest to newest). Min 2 points to render. */
		/** Stroke width in px. Defaults to 1.5. */
		/** Total width in px. Defaults to 120. */
		/** Total height in px. Defaults to 32. */
		/**
		* Stroke colour CSS variable name (without `--`). Defaults to
		* `accent`. Pass `'success'`, `'warning'`, `'danger'`, `'info'`,
		* `'text-dim'` to retint.
		*/
		/** When true, fills the area under the line with a soft gradient. */
		/** Accessible summary for screen readers. */
		let { points, strokeWidth = 1.5, width = 120, height = 32, tone = "accent", fill = true, ariaLabel = "Activity trend" } = $$props;
		/** Safe copy without reactive proxy gotchas. */
		const safePoints = derived(() => Array.isArray(points) ? points : []);
		const geometry = derived(() => buildGeometry(safePoints(), width, height, strokeWidth));
		function buildGeometry(data, w, h, sw) {
			if (data.length < 2) return {
				pathD: "",
				areaD: "",
				lastX: 0,
				lastY: h / 2,
				min: 0,
				max: 0
			};
			const pad = sw;
			const usableW = Math.max(1, w - pad * 2);
			const usableH = Math.max(1, h - pad * 2);
			const min = Math.min(...data);
			const max = Math.max(...data);
			const span = max - min || 1;
			const step = usableW / (data.length - 1);
			const pts = data.map((v, i) => {
				return {
					x: pad + step * i,
					y: pad + usableH - (v - min) / span * usableH
				};
			});
			const pathD = pts.map((p, i) => `${i === 0 ? "M" : "L"}${p.x.toFixed(2)},${p.y.toFixed(2)}`).join(" ");
			const areaD = `${pathD} L${pts[pts.length - 1].x.toFixed(2)},${(h - pad).toFixed(2)} L${pts[0].x.toFixed(2)},${(h - pad).toFixed(2)} Z`;
			const last = pts[pts.length - 1];
			return {
				pathD,
				areaD,
				lastX: last.x,
				lastY: last.y,
				min,
				max
			};
		}
		const gradId = `spark-grad-${Math.random().toString(36).slice(2, 8)}`;
		const stroke = derived(() => `var(--${tone})`);
		const fillColor = derived(() => `var(--${tone}-soft, var(--${tone}))`);
		if (safePoints().length < 2) {
			$$renderer.push("<!--[0-->");
			$$renderer.push(`<svg class="sparkline is-empty svelte-v8wd7u"${attr("width", width)}${attr("height", height)}${attr("viewBox", `0 0 ${stringify(width)} ${stringify(height)}`)}${attr("aria-label", ariaLabel)} role="img"><line x1="0"${attr("y1", height / 2)}${attr("x2", width)}${attr("y2", height / 2)} stroke="var(--border)" stroke-dasharray="2 3" stroke-width="1"></line></svg>`);
		} else {
			$$renderer.push("<!--[-1-->");
			$$renderer.push(`<svg class="sparkline svelte-v8wd7u"${attr("width", width)}${attr("height", height)}${attr("viewBox", `0 0 ${stringify(width)} ${stringify(height)}`)}${attr("aria-label", ariaLabel)} role="img">`);
			if (fill) {
				$$renderer.push("<!--[0-->");
				$$renderer.push(`<defs><linearGradient${attr("id", gradId)} x1="0" y1="0" x2="0" y2="1"><stop offset="0%"${attr("stop-color", fillColor())} stop-opacity="0.5"></stop><stop offset="100%"${attr("stop-color", fillColor())} stop-opacity="0"></stop></linearGradient></defs><path${attr("d", geometry().areaD)}${attr("fill", `url(#${gradId})`)}></path>`);
			} else $$renderer.push("<!--[-1-->");
			$$renderer.push(`<!--]--><path${attr("d", geometry().pathD)} fill="none"${attr("stroke", stroke())}${attr("stroke-width", strokeWidth)} stroke-linejoin="round" stroke-linecap="round"></path><circle${attr("cx", geometry().lastX)}${attr("cy", geometry().lastY)}${attr("r", strokeWidth + .5)}${attr("fill", stroke())}></circle></svg>`);
		}
		$$renderer.push(`<!--]-->`);
	});
}

export { Sparkline as S };
//# sourceMappingURL=Sparkline-BJ-GuhRd.js.map
