import { t as e } from "./utils-BC9GT6Pr.js";
import { t } from "./dist-CAMgZsY0.js";
import { forwardRef as n, useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
//#region src/react/primitives/data-field.tsx
var u = n(({ label: t, className: n, children: r, ...i }, a) => /* @__PURE__ */ l("div", {
	ref: a,
	className: e("rounded-lg border border-border-glass bg-glass px-3 py-2", n),
	...i,
	children: [/* @__PURE__ */ c("p", {
		className: "text-foreground-tertiary text-[11px] font-semibold tracking-wide uppercase",
		children: t
	}), /* @__PURE__ */ c("div", {
		className: "mt-1 min-w-0 break-words text-sm text-foreground-secondary",
		children: r
	})]
}));
u.displayName = "DataField";
var d = n(({ columns: t = 3, className: n, children: r, ...i }, a) => /* @__PURE__ */ c("div", {
	ref: a,
	className: e("grid gap-3", t === 2 && "md:grid-cols-2", t === 3 && "md:grid-cols-2 xl:grid-cols-3", t === 4 && "md:grid-cols-2 xl:grid-cols-4", n),
	...i,
	children: r
}));
d.displayName = "MetadataGrid";
//#endregion
//#region src/react/primitives/section-panel.tsx
var f = n(({ title: t, icon: n, variant: r = "glass", headerRight: i, className: a, children: o, ...s }, u) => /* @__PURE__ */ l("div", {
	ref: u,
	className: e("rounded-xl border", r === "glass" ? "border-border-glass bg-glass" : "border-border bg-card text-card-foreground shadow-sm", a),
	...s,
	children: [/* @__PURE__ */ l("div", {
		className: "flex items-center gap-3 border-b border-inherit px-4 py-3",
		children: [
			n && /* @__PURE__ */ c("div", {
				className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-foreground/[0.06] text-foreground-secondary [&>svg]:size-4",
				children: n
			}),
			/* @__PURE__ */ c("h3", {
				className: "text-foreground text-sm font-semibold",
				children: t
			}),
			i && /* @__PURE__ */ c("div", {
				className: "ml-auto",
				children: i
			})
		]
	}), /* @__PURE__ */ c("div", {
		className: "p-4",
		children: o
	})]
}));
f.displayName = "SectionPanel";
//#endregion
//#region src/react/primitives/score-ring.tsx
var p = n(({ score: t, size: n = 132, radius: r = 56, strokeWidth: i = 6, stroke: a = "currentColor", trackStroke: o = "var(--border-2)", className: s, children: u, style: d, ...f }, p) => {
	let m = Math.max(0, Math.min(100, t)), h = 2 * Math.PI * r, g = h - m / 100 * h, _ = n / 2;
	return /* @__PURE__ */ l("div", {
		ref: p,
		className: e("relative inline-flex items-center justify-center", s),
		style: {
			...d,
			width: n,
			height: n
		},
		...f,
		children: [/* @__PURE__ */ l("svg", {
			width: n,
			height: n,
			viewBox: `0 0 ${n} ${n}`,
			className: "-rotate-90",
			"aria-hidden": "true",
			children: [/* @__PURE__ */ c("circle", {
				cx: _,
				cy: _,
				r,
				fill: "none",
				stroke: o,
				strokeWidth: i
			}), /* @__PURE__ */ c("circle", {
				cx: _,
				cy: _,
				r,
				fill: "none",
				stroke: a,
				strokeWidth: i,
				strokeLinecap: "round",
				strokeDasharray: h,
				strokeDashoffset: g,
				className: "transition-[stroke-dashoffset] duration-500 ease-out"
			})]
		}), u && /* @__PURE__ */ c("div", {
			className: "absolute inset-0 flex items-center justify-center",
			children: u
		})]
	});
});
p.displayName = "ScoreRing";
//#endregion
//#region src/react/primitives/dashboard-metric-card.tsx
var m = t("flex items-center justify-center rounded-lg shrink-0", {
	variants: {
		tone: {
			amber: "bg-amber-10 text-[var(--color-amber-text)]",
			cyan: "bg-cyan-10 text-[var(--color-cyan-text)]",
			emerald: "bg-emerald-10 text-[var(--color-emerald-text)]",
			violet: "bg-violet-10 text-[var(--color-violet-text)]",
			rose: "bg-rose-10 text-[var(--color-rose-text)]",
			orange: "bg-primary/15 text-[var(--color-primary-text)]",
			glass: "bg-foreground/[0.08] text-foreground-secondary"
		},
		size: {
			sm: "h-8 w-8 [&>svg]:size-4",
			md: "h-9 w-9 [&>svg]:size-5",
			lg: "h-10 w-10 [&>svg]:size-5"
		}
	},
	defaultVariants: {
		tone: "glass",
		size: "md"
	}
}), h = n(({ icon: t, label: n, value: r, detail: i, trend: a, tone: o = "glass", iconSize: s = "md", className: u, ...d }, f) => /* @__PURE__ */ l("div", {
	ref: f,
	className: e("flex flex-col gap-3 rounded-xl border border-border-glass bg-glass p-4", u),
	...d,
	children: [
		/* @__PURE__ */ l("div", {
			className: "flex items-start justify-between",
			children: [/* @__PURE__ */ c("p", {
				className: "text-foreground-tertiary text-[10px] font-semibold tracking-wider uppercase",
				children: n
			}), t && /* @__PURE__ */ c("div", {
				className: m({
					tone: o,
					size: s
				}),
				children: t
			})]
		}),
		/* @__PURE__ */ c("p", {
			className: "text-foreground text-2xl font-bold tabular-nums",
			children: r
		}),
		(i || a) && /* @__PURE__ */ l("div", {
			className: "flex items-center gap-2",
			children: [i && /* @__PURE__ */ c("span", {
				className: "text-foreground-secondary text-sm",
				children: i
			}), a && /* @__PURE__ */ c("span", {
				className: "text-xs font-semibold",
				children: a
			})]
		})
	]
}));
h.displayName = "DashboardMetricCard";
//#endregion
//#region src/react/primitives/chat-drawer.tsx
var g = n(({ open: t, onClose: n, title: r, icon: o, messages: u, input: d, width: f = "500px", className: p, ...m }, h) => {
	let g = a(null);
	return i(() => {
		t && g.current && (g.current.scrollTop = g.current.scrollHeight);
	}, [t, u]), i(() => {
		if (!t) return;
		let e = (e) => {
			e.key === "Escape" && n();
		};
		return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
	}, [t, n]), /* @__PURE__ */ l(s, { children: [t && /* @__PURE__ */ c("div", {
		className: "fixed inset-0 z-40 bg-black/40 backdrop-blur-sm",
		onClick: n,
		"aria-hidden": "true"
	}), t && /* @__PURE__ */ l("div", {
		ref: h,
		role: "dialog",
		"aria-modal": !0,
		"aria-label": r,
		className: e("fixed inset-y-0 right-0 z-50 flex flex-col border-l border-border-glass bg-background shadow-xl", p),
		style: { width: f },
		...m,
		children: [
			/* @__PURE__ */ l("div", {
				className: "flex shrink-0 items-center gap-3 border-b border-border-glass px-4 py-3",
				children: [
					o && /* @__PURE__ */ c("div", {
						className: "flex h-8 w-8 items-center justify-center rounded-lg bg-primary/15 text-[hsl(var(--primary))] [&>svg]:size-4",
						children: o
					}),
					/* @__PURE__ */ c("h2", {
						className: "flex-1 text-sm font-semibold text-foreground",
						children: r
					}),
					/* @__PURE__ */ c("button", {
						type: "button",
						onClick: n,
						className: "flex h-8 w-8 items-center justify-center rounded-lg text-foreground-tertiary transition-colors hover:bg-foreground/[0.06] hover:text-foreground",
						"aria-label": "Close",
						children: /* @__PURE__ */ c("svg", {
							className: "h-4 w-4",
							viewBox: "0 0 24 24",
							fill: "none",
							stroke: "currentColor",
							strokeWidth: "2",
							strokeLinecap: "round",
							strokeLinejoin: "round",
							"aria-hidden": "true",
							children: /* @__PURE__ */ c("path", { d: "M18 6L6 18M6 6l12 12" })
						})
					})
				]
			}),
			/* @__PURE__ */ c("div", {
				ref: g,
				className: "flex-1 overflow-y-auto px-4 py-4",
				children: u
			}),
			/* @__PURE__ */ c("div", {
				className: "shrink-0 border-t border-border-glass px-4 py-3",
				children: d
			})
		]
	})] });
});
g.displayName = "ChatDrawer";
//#endregion
//#region src/react/primitives/chat-input.tsx
var _ = n(({ onSubmit: t, loading: n = !1, submitLabel: i = "Send", className: o, formClassName: s, onInput: u, onKeyDown: d, disabled: f, ...p }, m) => {
	let h = a(null), g = n || f === !0, _ = r(() => {
		let e = h.current;
		e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, 200)}px`);
	}, []), v = r((e) => {
		if (d?.(e), !e.defaultPrevented && e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
			e.preventDefault();
			let n = h.current?.value.trim();
			n && t && !g && (t(n), h.current && (h.current.value = "", _()));
		}
	}, [
		d,
		t,
		g,
		_
	]), y = r((e) => {
		u?.(e), _();
	}, [u, _]), b = r((e) => {
		e.preventDefault();
		let n = h.current?.value.trim();
		n && t && !g && (t(n), h.current && (h.current.value = "", _()));
	}, [
		t,
		g,
		_
	]), x = r((e) => {
		h.current = e, typeof m == "function" ? m(e) : m && (m.current = e);
	}, [m]);
	return /* @__PURE__ */ l("form", {
		onSubmit: b,
		className: e("flex items-end gap-2", s),
		children: [/* @__PURE__ */ c("textarea", {
			ref: x,
			rows: 1,
			placeholder: "Type a message...",
			...p,
			onInput: y,
			onKeyDown: v,
			disabled: g,
			className: e("flex-1 resize-none rounded-lg border border-border-glass bg-glass px-3 py-2 text-sm text-foreground placeholder:text-foreground-tertiary focus:outline-none focus:ring-2 focus:ring-primary/50 disabled:opacity-50", o)
		}), /* @__PURE__ */ c("button", {
			type: "submit",
			disabled: g,
			"aria-label": i,
			className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-40",
			children: n ? /* @__PURE__ */ c("svg", {
				className: "h-4 w-4 animate-spin",
				viewBox: "0 0 24 24",
				fill: "none",
				"aria-hidden": "true",
				children: /* @__PURE__ */ c("circle", {
					cx: "12",
					cy: "12",
					r: "10",
					stroke: "currentColor",
					strokeWidth: "3",
					strokeDasharray: "31.42 31.42",
					strokeLinecap: "round"
				})
			}) : /* @__PURE__ */ c("svg", {
				className: "h-4 w-4",
				viewBox: "0 0 24 24",
				fill: "none",
				stroke: "currentColor",
				strokeWidth: "2",
				strokeLinecap: "round",
				strokeLinejoin: "round",
				"aria-hidden": "true",
				children: /* @__PURE__ */ c("path", { d: "M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z" })
			})
		})]
	});
});
_.displayName = "ChatInput";
//#endregion
//#region src/react/primitives/chart-frame.tsx
function v({ children: t, minHeight: n = 200, className: s, style: l, ...u }) {
	let d = a(null), [f, p] = o(null), m = r(() => {
		if (!d.current) return;
		let { width: e, height: t } = d.current.getBoundingClientRect(), n = Math.floor(e), r = Math.floor(t);
		p((e) => e && e.width === n && e.height === r ? e : {
			width: n,
			height: r
		});
	}, []);
	return i(() => {
		let e = d.current;
		if (!e) return;
		if (m(), typeof globalThis.ResizeObserver != "function") return window.addEventListener("resize", m), () => window.removeEventListener("resize", m);
		let t = new globalThis.ResizeObserver(m);
		return t.observe(e), () => t.disconnect();
	}, [m]), /* @__PURE__ */ c("div", {
		ref: d,
		className: e("w-full", s),
		style: {
			minHeight: n,
			...l
		},
		...u,
		children: f ? t(f) : null
	});
}
v.displayName = "ChartFrame";
//#endregion
//#region src/react/primitives/query-boundary.tsx
function y() {
	return /* @__PURE__ */ c("svg", {
		className: "h-5 w-5 animate-spin text-foreground-tertiary",
		viewBox: "0 0 24 24",
		fill: "none",
		"aria-hidden": "true",
		children: /* @__PURE__ */ c("circle", {
			cx: "12",
			cy: "12",
			r: "10",
			stroke: "currentColor",
			strokeWidth: "3",
			strokeDasharray: "31.42 31.42",
			strokeLinecap: "round"
		})
	});
}
function b({ isLoading: t, isError: n, error: r, isEmpty: i, loadingMessage: a = "Loading...", errorMessage: o, emptyMessage: u = "No data available", emptyIcon: d, className: f, children: p }) {
	if (t) return /* @__PURE__ */ l("div", {
		className: e("flex min-h-[220px] flex-col items-center justify-center gap-3 text-foreground-tertiary", f),
		children: [/* @__PURE__ */ c(y, {}), /* @__PURE__ */ c("p", {
			className: "text-sm",
			children: a
		})]
	});
	if (n) {
		let t = o ?? (r instanceof Error ? r.message : String(r ?? "An error occurred"));
		return /* @__PURE__ */ c("div", {
			role: "alert",
			"aria-live": "polite",
			className: e("rounded-lg border border-accent-rose/25 bg-accent-rose/5 px-4 py-3 text-sm text-accent-rose", f),
			children: t
		});
	}
	return i ? /* @__PURE__ */ l("div", {
		className: e("flex min-h-[220px] flex-col items-center justify-center gap-2 text-foreground-tertiary", f),
		children: [d && /* @__PURE__ */ c("div", {
			className: "text-foreground-muted [&>svg]:size-10",
			children: d
		}), /* @__PURE__ */ c("p", {
			className: "text-sm",
			children: u
		})]
	}) : /* @__PURE__ */ c(s, { children: p });
}
//#endregion
export { h as a, f as c, g as i, u as l, v as n, m as o, _ as r, p as s, b as t, d as u };

//# sourceMappingURL=primitives-Cya96raJ.js.map