@aigentyc/chat-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +156 -0
  3. package/dist/JsonRenderResult-Ftw4AKwb.d.cts +18 -0
  4. package/dist/JsonRenderResult-Ftw4AKwb.d.ts +18 -0
  5. package/dist/JsonRenderResult-GQOYPLVH.cjs +15 -0
  6. package/dist/JsonRenderResult-GQOYPLVH.cjs.map +1 -0
  7. package/dist/JsonRenderResult-ZFJ6VWMS.js +6 -0
  8. package/dist/JsonRenderResult-ZFJ6VWMS.js.map +1 -0
  9. package/dist/SlotsContext-CBtt36al.d.ts +148 -0
  10. package/dist/SlotsContext-CHvISDJT.d.cts +148 -0
  11. package/dist/VisualizationRenderer-FNFYNN66.js +5 -0
  12. package/dist/VisualizationRenderer-FNFYNN66.js.map +1 -0
  13. package/dist/VisualizationRenderer-VKMZXRUX.cjs +20 -0
  14. package/dist/VisualizationRenderer-VKMZXRUX.cjs.map +1 -0
  15. package/dist/ai-elements.cjs +4608 -0
  16. package/dist/ai-elements.cjs.map +1 -0
  17. package/dist/ai-elements.d.cts +897 -0
  18. package/dist/ai-elements.d.ts +897 -0
  19. package/dist/ai-elements.js +4363 -0
  20. package/dist/ai-elements.js.map +1 -0
  21. package/dist/chunk-3MP2EGEJ.cjs +270 -0
  22. package/dist/chunk-3MP2EGEJ.cjs.map +1 -0
  23. package/dist/chunk-3RW7O444.js +26 -0
  24. package/dist/chunk-3RW7O444.js.map +1 -0
  25. package/dist/chunk-42ARGQXE.js +51 -0
  26. package/dist/chunk-42ARGQXE.js.map +1 -0
  27. package/dist/chunk-4FBVV64J.js +257 -0
  28. package/dist/chunk-4FBVV64J.js.map +1 -0
  29. package/dist/chunk-4QT25AXI.js +21 -0
  30. package/dist/chunk-4QT25AXI.js.map +1 -0
  31. package/dist/chunk-525KS5HM.cjs +30 -0
  32. package/dist/chunk-525KS5HM.cjs.map +1 -0
  33. package/dist/chunk-5F3O3ZJH.js +299 -0
  34. package/dist/chunk-5F3O3ZJH.js.map +1 -0
  35. package/dist/chunk-5QSXB6UL.cjs +259 -0
  36. package/dist/chunk-5QSXB6UL.cjs.map +1 -0
  37. package/dist/chunk-5T4FJ2SR.js +664 -0
  38. package/dist/chunk-5T4FJ2SR.js.map +1 -0
  39. package/dist/chunk-7BNYTOTE.cjs +67 -0
  40. package/dist/chunk-7BNYTOTE.cjs.map +1 -0
  41. package/dist/chunk-AWAJOSFP.cjs +96 -0
  42. package/dist/chunk-AWAJOSFP.cjs.map +1 -0
  43. package/dist/chunk-BKDV2H6Z.js +224 -0
  44. package/dist/chunk-BKDV2H6Z.js.map +1 -0
  45. package/dist/chunk-FQN6OBGN.cjs +171 -0
  46. package/dist/chunk-FQN6OBGN.cjs.map +1 -0
  47. package/dist/chunk-FYPJSHCL.js +190 -0
  48. package/dist/chunk-FYPJSHCL.js.map +1 -0
  49. package/dist/chunk-J2H6MLQF.cjs +680 -0
  50. package/dist/chunk-J2H6MLQF.cjs.map +1 -0
  51. package/dist/chunk-J2K7EJYP.cjs +198 -0
  52. package/dist/chunk-J2K7EJYP.cjs.map +1 -0
  53. package/dist/chunk-JI5KCSOI.cjs +23 -0
  54. package/dist/chunk-JI5KCSOI.cjs.map +1 -0
  55. package/dist/chunk-JOO6C3XT.cjs +44 -0
  56. package/dist/chunk-JOO6C3XT.cjs.map +1 -0
  57. package/dist/chunk-KBGPBUTI.cjs +78 -0
  58. package/dist/chunk-KBGPBUTI.cjs.map +1 -0
  59. package/dist/chunk-MT2AMINB.js +75 -0
  60. package/dist/chunk-MT2AMINB.js.map +1 -0
  61. package/dist/chunk-MZQKGNWF.js +4 -0
  62. package/dist/chunk-MZQKGNWF.js.map +1 -0
  63. package/dist/chunk-NG7OTWXQ.cjs +226 -0
  64. package/dist/chunk-NG7OTWXQ.cjs.map +1 -0
  65. package/dist/chunk-NPJKLYLV.js +68 -0
  66. package/dist/chunk-NPJKLYLV.js.map +1 -0
  67. package/dist/chunk-NW2ESHRV.js +685 -0
  68. package/dist/chunk-NW2ESHRV.js.map +1 -0
  69. package/dist/chunk-NWF735F5.js +1631 -0
  70. package/dist/chunk-NWF735F5.js.map +1 -0
  71. package/dist/chunk-NYQSM3EB.cjs +305 -0
  72. package/dist/chunk-NYQSM3EB.cjs.map +1 -0
  73. package/dist/chunk-OU7OROOE.cjs +1643 -0
  74. package/dist/chunk-OU7OROOE.cjs.map +1 -0
  75. package/dist/chunk-PS3U7T37.js +42 -0
  76. package/dist/chunk-PS3U7T37.js.map +1 -0
  77. package/dist/chunk-Q7T3VAJV.cjs +687 -0
  78. package/dist/chunk-Q7T3VAJV.cjs.map +1 -0
  79. package/dist/chunk-QYCEHFAB.js +265 -0
  80. package/dist/chunk-QYCEHFAB.js.map +1 -0
  81. package/dist/chunk-RPDJXB3U.js +676 -0
  82. package/dist/chunk-RPDJXB3U.js.map +1 -0
  83. package/dist/chunk-UKEL7FWS.js +64 -0
  84. package/dist/chunk-UKEL7FWS.js.map +1 -0
  85. package/dist/chunk-VS3NZ7FX.js +164 -0
  86. package/dist/chunk-VS3NZ7FX.js.map +1 -0
  87. package/dist/chunk-WZLWAVSS.cjs +73 -0
  88. package/dist/chunk-WZLWAVSS.cjs.map +1 -0
  89. package/dist/chunk-X5YEOOPK.cjs +758 -0
  90. package/dist/chunk-X5YEOOPK.cjs.map +1 -0
  91. package/dist/chunk-X7R334SB.cjs +5 -0
  92. package/dist/chunk-X7R334SB.cjs.map +1 -0
  93. package/dist/chunk-XXNDL5SJ.cjs +432 -0
  94. package/dist/chunk-XXNDL5SJ.cjs.map +1 -0
  95. package/dist/chunk-YQELMJW5.js +429 -0
  96. package/dist/chunk-YQELMJW5.js.map +1 -0
  97. package/dist/components.cjs +551 -0
  98. package/dist/components.cjs.map +1 -0
  99. package/dist/components.d.cts +181 -0
  100. package/dist/components.d.ts +181 -0
  101. package/dist/components.js +483 -0
  102. package/dist/components.js.map +1 -0
  103. package/dist/core.cjs +283 -0
  104. package/dist/core.cjs.map +1 -0
  105. package/dist/core.d.cts +455 -0
  106. package/dist/core.d.ts +455 -0
  107. package/dist/core.js +241 -0
  108. package/dist/core.js.map +1 -0
  109. package/dist/hooks.cjs +324 -0
  110. package/dist/hooks.cjs.map +1 -0
  111. package/dist/hooks.d.cts +163 -0
  112. package/dist/hooks.d.ts +163 -0
  113. package/dist/hooks.js +277 -0
  114. package/dist/hooks.js.map +1 -0
  115. package/dist/i18n.cjs +26 -0
  116. package/dist/i18n.cjs.map +1 -0
  117. package/dist/i18n.d.cts +50 -0
  118. package/dist/i18n.d.ts +50 -0
  119. package/dist/i18n.js +5 -0
  120. package/dist/i18n.js.map +1 -0
  121. package/dist/index.cjs +466 -0
  122. package/dist/index.cjs.map +1 -0
  123. package/dist/index.d.cts +80 -0
  124. package/dist/index.d.ts +80 -0
  125. package/dist/index.js +438 -0
  126. package/dist/index.js.map +1 -0
  127. package/dist/interaction-tracker-D9P1Oq4j.d.cts +83 -0
  128. package/dist/interaction-tracker-D9P1Oq4j.d.ts +83 -0
  129. package/dist/json-render.cjs +23 -0
  130. package/dist/json-render.cjs.map +1 -0
  131. package/dist/json-render.d.cts +857 -0
  132. package/dist/json-render.d.ts +857 -0
  133. package/dist/json-render.js +6 -0
  134. package/dist/json-render.js.map +1 -0
  135. package/dist/live-chat-transport-4XLOIPOE.js +4 -0
  136. package/dist/live-chat-transport-4XLOIPOE.js.map +1 -0
  137. package/dist/live-chat-transport-ALVRGWX7.cjs +13 -0
  138. package/dist/live-chat-transport-ALVRGWX7.cjs.map +1 -0
  139. package/dist/select-B4l9yoyn.d.cts +99 -0
  140. package/dist/select-B4l9yoyn.d.ts +99 -0
  141. package/dist/styles.css +2 -0
  142. package/dist/theme.cjs +18 -0
  143. package/dist/theme.cjs.map +1 -0
  144. package/dist/theme.d.cts +55 -0
  145. package/dist/theme.d.ts +55 -0
  146. package/dist/theme.js +5 -0
  147. package/dist/theme.js.map +1 -0
  148. package/dist/tools.cjs +32 -0
  149. package/dist/tools.cjs.map +1 -0
  150. package/dist/tools.d.cts +117 -0
  151. package/dist/tools.d.ts +117 -0
  152. package/dist/tools.js +11 -0
  153. package/dist/tools.js.map +1 -0
  154. package/dist/types-DKJ_-nbG.d.cts +349 -0
  155. package/dist/types-DKJ_-nbG.d.ts +349 -0
  156. package/dist/ui.cjs +667 -0
  157. package/dist/ui.cjs.map +1 -0
  158. package/dist/ui.d.cts +95 -0
  159. package/dist/ui.d.ts +95 -0
  160. package/dist/ui.js +414 -0
  161. package/dist/ui.js.map +1 -0
  162. package/package.json +255 -0
@@ -0,0 +1,664 @@
1
+ "use client";
2
+ import { cn } from './chunk-3RW7O444.js';
3
+ import * as RechartsPrimitive from 'recharts';
4
+ import { ComposedChart, CartesianGrid, XAxis, YAxis, Bar, Line, Area, RadarChart, PolarGrid, PolarAngleAxis, Radar, AreaChart, PieChart, Pie, Cell, BarChart, LineChart } from 'recharts';
5
+ import * as React from 'react';
6
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
+ import { Check, TrendingUp, TrendingDown, Minus, X, Star } from 'lucide-react';
8
+
9
+ var THEMES = { light: "", dark: ".dark" };
10
+ var ChartContext = React.createContext(null);
11
+ function useChart() {
12
+ const context = React.useContext(ChartContext);
13
+ if (!context) {
14
+ throw new Error("useChart must be used within a <ChartContainer />");
15
+ }
16
+ return context;
17
+ }
18
+ var ChartContainer = React.forwardRef(({ id, className, children, config, ...props }, ref) => {
19
+ const uniqueId = React.useId();
20
+ const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
21
+ return /* @__PURE__ */ jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs(
22
+ "div",
23
+ {
24
+ "data-chart": chartId,
25
+ ref,
26
+ className: cn(
27
+ "flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",
28
+ className
29
+ ),
30
+ ...props,
31
+ children: [
32
+ /* @__PURE__ */ jsx(ChartStyle, { id: chartId, config }),
33
+ /* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, { children })
34
+ ]
35
+ }
36
+ ) });
37
+ });
38
+ ChartContainer.displayName = "Chart";
39
+ var ChartStyle = ({ id, config }) => {
40
+ const colorConfig = Object.entries(config).filter(
41
+ ([, config2]) => config2.theme || config2.color
42
+ );
43
+ if (!colorConfig.length) {
44
+ return null;
45
+ }
46
+ return /* @__PURE__ */ jsx(
47
+ "style",
48
+ {
49
+ dangerouslySetInnerHTML: {
50
+ __html: Object.entries(THEMES).map(
51
+ ([theme, prefix]) => `
52
+ ${prefix} [data-chart=${id}] {
53
+ ${colorConfig.map(([key, itemConfig]) => {
54
+ const color = itemConfig.theme?.[theme] || itemConfig.color;
55
+ return color ? ` --color-${key}: ${color};` : null;
56
+ }).join("\n")}
57
+ }
58
+ `
59
+ ).join("\n")
60
+ }
61
+ }
62
+ );
63
+ };
64
+ var ChartTooltip = RechartsPrimitive.Tooltip;
65
+ var ChartTooltipContent = React.forwardRef(
66
+ ({
67
+ active,
68
+ payload,
69
+ className,
70
+ indicator = "dot",
71
+ hideLabel = false,
72
+ hideIndicator = false,
73
+ label,
74
+ labelFormatter,
75
+ labelClassName,
76
+ formatter,
77
+ color,
78
+ nameKey,
79
+ labelKey
80
+ }, ref) => {
81
+ const { config } = useChart();
82
+ const tooltipLabel = React.useMemo(() => {
83
+ if (hideLabel || !payload?.length) {
84
+ return null;
85
+ }
86
+ const [item] = payload;
87
+ const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
88
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
89
+ const value = !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;
90
+ if (labelFormatter) {
91
+ return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
92
+ }
93
+ if (!value) {
94
+ return null;
95
+ }
96
+ return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: value });
97
+ }, [
98
+ label,
99
+ labelFormatter,
100
+ payload,
101
+ hideLabel,
102
+ labelClassName,
103
+ config,
104
+ labelKey
105
+ ]);
106
+ if (!active || !payload?.length) {
107
+ return null;
108
+ }
109
+ const nestLabel = payload.length === 1 && indicator !== "dot";
110
+ return /* @__PURE__ */ jsxs(
111
+ "div",
112
+ {
113
+ ref,
114
+ className: cn(
115
+ "grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
116
+ className
117
+ ),
118
+ children: [
119
+ !nestLabel ? tooltipLabel : null,
120
+ /* @__PURE__ */ jsx("div", { className: "grid gap-1.5", children: payload.filter((item) => item.type !== "none").map((item, index) => {
121
+ const key = `${nameKey || item.name || item.dataKey || "value"}`;
122
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
123
+ const indicatorColor = color || item.payload.fill || item.color;
124
+ return /* @__PURE__ */ jsx(
125
+ "div",
126
+ {
127
+ className: cn(
128
+ "flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
129
+ indicator === "dot" && "items-center"
130
+ ),
131
+ children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxs(Fragment, { children: [
132
+ itemConfig?.icon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx(
133
+ "div",
134
+ {
135
+ className: cn(
136
+ "shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",
137
+ {
138
+ "h-2.5 w-2.5": indicator === "dot",
139
+ "w-1": indicator === "line",
140
+ "w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
141
+ "my-0.5": nestLabel && indicator === "dashed"
142
+ }
143
+ ),
144
+ style: {
145
+ "--color-bg": indicatorColor,
146
+ "--color-border": indicatorColor
147
+ }
148
+ }
149
+ ),
150
+ /* @__PURE__ */ jsxs(
151
+ "div",
152
+ {
153
+ className: cn(
154
+ "flex flex-1 justify-between leading-none",
155
+ nestLabel ? "items-end" : "items-center"
156
+ ),
157
+ children: [
158
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
159
+ nestLabel ? tooltipLabel : null,
160
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: itemConfig?.label || item.name })
161
+ ] }),
162
+ item.value && /* @__PURE__ */ jsx("span", { className: "font-mono font-medium tabular-nums text-foreground", children: item.value.toLocaleString() })
163
+ ]
164
+ }
165
+ )
166
+ ] })
167
+ },
168
+ item.dataKey
169
+ );
170
+ }) })
171
+ ]
172
+ }
173
+ );
174
+ }
175
+ );
176
+ ChartTooltipContent.displayName = "ChartTooltip";
177
+ var ChartLegend = RechartsPrimitive.Legend;
178
+ var ChartLegendContent = React.forwardRef(
179
+ ({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }, ref) => {
180
+ const { config } = useChart();
181
+ if (!payload?.length) {
182
+ return null;
183
+ }
184
+ return /* @__PURE__ */ jsx(
185
+ "div",
186
+ {
187
+ ref,
188
+ className: cn(
189
+ "flex items-center justify-center gap-4",
190
+ verticalAlign === "top" ? "pb-3" : "pt-3",
191
+ className
192
+ ),
193
+ children: payload.filter((item) => item.type !== "none").map((item) => {
194
+ const key = `${nameKey || item.dataKey || "value"}`;
195
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
196
+ return /* @__PURE__ */ jsxs(
197
+ "div",
198
+ {
199
+ className: cn(
200
+ "flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"
201
+ ),
202
+ children: [
203
+ itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsx(
204
+ "div",
205
+ {
206
+ className: "h-2 w-2 shrink-0 rounded-[2px]",
207
+ style: {
208
+ backgroundColor: item.color
209
+ }
210
+ }
211
+ ),
212
+ itemConfig?.label
213
+ ]
214
+ },
215
+ item.value
216
+ );
217
+ })
218
+ }
219
+ );
220
+ }
221
+ );
222
+ ChartLegendContent.displayName = "ChartLegend";
223
+ function getPayloadConfigFromPayload(config, payload, key) {
224
+ if (typeof payload !== "object" || payload === null) {
225
+ return void 0;
226
+ }
227
+ const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
228
+ let configLabelKey = key;
229
+ if (key in payload && typeof payload[key] === "string") {
230
+ configLabelKey = payload[key];
231
+ } else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
232
+ configLabelKey = payloadPayload[key];
233
+ }
234
+ return configLabelKey in config ? config[configLabelKey] : config[key];
235
+ }
236
+ var CHART_COLORS = [
237
+ "var(--ac-chart-1, hsl(221, 83%, 53%))",
238
+ "var(--ac-chart-2, hsl(142, 71%, 45%))",
239
+ "var(--ac-chart-3, hsl(38, 92%, 50%))",
240
+ "var(--ac-chart-4, hsl(0, 84%, 60%))",
241
+ "var(--ac-chart-5, hsl(262, 83%, 58%))",
242
+ "var(--ac-chart-6, hsl(173, 80%, 40%))",
243
+ "var(--ac-chart-7, hsl(330, 81%, 60%))",
244
+ "var(--ac-chart-8, hsl(25, 95%, 53%))"
245
+ ];
246
+ function formatValue(value, formatter) {
247
+ switch (formatter) {
248
+ case "currency":
249
+ return `$${value.toLocaleString()}`;
250
+ case "percent":
251
+ return `${value}%`;
252
+ case "compact": {
253
+ if (value >= 1e6) return `${(value / 1e6).toFixed(1)}M`;
254
+ if (value >= 1e3) return `${(value / 1e3).toFixed(1)}K`;
255
+ return value.toLocaleString();
256
+ }
257
+ default:
258
+ return value.toLocaleString();
259
+ }
260
+ }
261
+ function buildChartConfig(series) {
262
+ const cfg = {};
263
+ for (let i = 0; i < series.length; i++) {
264
+ const s = series[i];
265
+ cfg[s.dataKey] = {
266
+ label: s.label,
267
+ color: s.color || CHART_COLORS[i % CHART_COLORS.length]
268
+ };
269
+ }
270
+ return cfg;
271
+ }
272
+ function shouldShowLegend(config, series) {
273
+ if (config?.showLegend !== void 0) return config.showLegend;
274
+ return (series?.length ?? 0) > 1;
275
+ }
276
+ function RenderLineChart({ spec }) {
277
+ const series = spec.config?.series ?? [];
278
+ const chartConfig = buildChartConfig(series);
279
+ const xKey = spec.config?.xAxis ?? "name";
280
+ const showGrid = spec.config?.showGrid !== false;
281
+ return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: "h-[300px] w-full", children: /* @__PURE__ */ jsxs(LineChart, { data: spec.data, accessibilityLayer: true, children: [
282
+ showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3", className: "stroke-muted" }),
283
+ /* @__PURE__ */ jsx(XAxis, { dataKey: xKey, className: "text-xs", tickLine: false, axisLine: false }),
284
+ /* @__PURE__ */ jsx(
285
+ YAxis,
286
+ {
287
+ className: "text-xs",
288
+ tickLine: false,
289
+ axisLine: false,
290
+ tickFormatter: (v) => formatValue(v, spec.config?.valueFormatter)
291
+ }
292
+ ),
293
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
294
+ shouldShowLegend(spec.config, series) && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }),
295
+ series.map((s) => /* @__PURE__ */ jsx(
296
+ Line,
297
+ {
298
+ type: "monotone",
299
+ dataKey: s.dataKey,
300
+ stroke: `var(--color-${s.dataKey})`,
301
+ strokeWidth: 2,
302
+ dot: { r: 3 },
303
+ activeDot: { r: 5 }
304
+ },
305
+ s.dataKey
306
+ ))
307
+ ] }) });
308
+ }
309
+ function RenderBarChart({ spec }) {
310
+ const series = spec.config?.series ?? [];
311
+ const chartConfig = buildChartConfig(series);
312
+ const xKey = spec.config?.xAxis ?? "name";
313
+ const showGrid = spec.config?.showGrid !== false;
314
+ const stacked = spec.config?.stacked ?? false;
315
+ return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: "h-[300px] w-full", children: /* @__PURE__ */ jsxs(BarChart, { data: spec.data, accessibilityLayer: true, children: [
316
+ showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3", className: "stroke-muted" }),
317
+ /* @__PURE__ */ jsx(XAxis, { dataKey: xKey, className: "text-xs", tickLine: false, axisLine: false }),
318
+ /* @__PURE__ */ jsx(
319
+ YAxis,
320
+ {
321
+ className: "text-xs",
322
+ tickLine: false,
323
+ axisLine: false,
324
+ tickFormatter: (v) => formatValue(v, spec.config?.valueFormatter)
325
+ }
326
+ ),
327
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
328
+ shouldShowLegend(spec.config, series) && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }),
329
+ series.map((s) => /* @__PURE__ */ jsx(
330
+ Bar,
331
+ {
332
+ dataKey: s.dataKey,
333
+ fill: `var(--color-${s.dataKey})`,
334
+ radius: [4, 4, 0, 0],
335
+ stackId: stacked ? "stack" : void 0
336
+ },
337
+ s.dataKey
338
+ ))
339
+ ] }) });
340
+ }
341
+ function RenderPieChart({ spec }) {
342
+ const series = spec.config?.series ?? [];
343
+ const valueKey = series[0]?.dataKey ?? "value";
344
+ const chartConfig = buildChartConfig(series);
345
+ const data = (spec.data ?? []).map((d, i) => ({
346
+ ...d,
347
+ fill: CHART_COLORS[i % CHART_COLORS.length]
348
+ }));
349
+ return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: "h-[300px] w-full", children: /* @__PURE__ */ jsxs(PieChart, { accessibilityLayer: true, children: [
350
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, { nameKey: "name" }) }),
351
+ /* @__PURE__ */ jsx(
352
+ Pie,
353
+ {
354
+ data,
355
+ dataKey: valueKey,
356
+ nameKey: "name",
357
+ cx: "50%",
358
+ cy: "50%",
359
+ outerRadius: 100,
360
+ label: ({ percent }) => `${((percent ?? 0) * 100).toFixed(0)}%`,
361
+ labelLine: false,
362
+ children: data.map((_entry, i) => /* @__PURE__ */ jsx(Cell, { fill: CHART_COLORS[i % CHART_COLORS.length] }, `cell-${i}`))
363
+ }
364
+ ),
365
+ shouldShowLegend(spec.config, series) && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, { nameKey: "name" }) })
366
+ ] }) });
367
+ }
368
+ function RenderAreaChart({ spec }) {
369
+ const series = spec.config?.series ?? [];
370
+ const chartConfig = buildChartConfig(series);
371
+ const xKey = spec.config?.xAxis ?? "name";
372
+ const showGrid = spec.config?.showGrid !== false;
373
+ const stacked = spec.config?.stacked ?? false;
374
+ return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: "h-[300px] w-full", children: /* @__PURE__ */ jsxs(AreaChart, { data: spec.data, accessibilityLayer: true, children: [
375
+ /* @__PURE__ */ jsx("defs", { children: series.map((s) => /* @__PURE__ */ jsxs("linearGradient", { id: `fill-${s.dataKey}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
376
+ /* @__PURE__ */ jsx("stop", { offset: "5%", stopColor: `var(--color-${s.dataKey})`, stopOpacity: 0.3 }),
377
+ /* @__PURE__ */ jsx("stop", { offset: "95%", stopColor: `var(--color-${s.dataKey})`, stopOpacity: 0.05 })
378
+ ] }, s.dataKey)) }),
379
+ showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3", className: "stroke-muted" }),
380
+ /* @__PURE__ */ jsx(XAxis, { dataKey: xKey, className: "text-xs", tickLine: false, axisLine: false }),
381
+ /* @__PURE__ */ jsx(
382
+ YAxis,
383
+ {
384
+ className: "text-xs",
385
+ tickLine: false,
386
+ axisLine: false,
387
+ tickFormatter: (v) => formatValue(v, spec.config?.valueFormatter)
388
+ }
389
+ ),
390
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
391
+ shouldShowLegend(spec.config, series) && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }),
392
+ series.map((s) => /* @__PURE__ */ jsx(
393
+ Area,
394
+ {
395
+ type: "monotone",
396
+ dataKey: s.dataKey,
397
+ stroke: `var(--color-${s.dataKey})`,
398
+ fill: `url(#fill-${s.dataKey})`,
399
+ strokeWidth: 2,
400
+ stackId: stacked ? "stack" : void 0
401
+ },
402
+ s.dataKey
403
+ ))
404
+ ] }) });
405
+ }
406
+ function RenderRadarChart({ spec }) {
407
+ const series = spec.config?.series ?? [];
408
+ const chartConfig = buildChartConfig(series);
409
+ const xKey = spec.config?.xAxis ?? "name";
410
+ return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: "h-[300px] w-full", children: /* @__PURE__ */ jsxs(RadarChart, { data: spec.data, cx: "50%", cy: "50%", outerRadius: "80%", accessibilityLayer: true, children: [
411
+ /* @__PURE__ */ jsx(PolarGrid, { className: "stroke-muted" }),
412
+ /* @__PURE__ */ jsx(PolarAngleAxis, { dataKey: xKey, className: "text-xs" }),
413
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
414
+ shouldShowLegend(spec.config, series) && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }),
415
+ series.map((s) => /* @__PURE__ */ jsx(
416
+ Radar,
417
+ {
418
+ name: s.label,
419
+ dataKey: s.dataKey,
420
+ stroke: `var(--color-${s.dataKey})`,
421
+ fill: `var(--color-${s.dataKey})`,
422
+ fillOpacity: 0.2
423
+ },
424
+ s.dataKey
425
+ ))
426
+ ] }) });
427
+ }
428
+ function RenderComposedChart({ spec }) {
429
+ const series = spec.config?.series ?? [];
430
+ const chartConfig = buildChartConfig(series);
431
+ const xKey = spec.config?.xAxis ?? "name";
432
+ const showGrid = spec.config?.showGrid !== false;
433
+ return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: "h-[300px] w-full", children: /* @__PURE__ */ jsxs(ComposedChart, { data: spec.data, accessibilityLayer: true, children: [
434
+ showGrid && /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3", className: "stroke-muted" }),
435
+ /* @__PURE__ */ jsx(XAxis, { dataKey: xKey, className: "text-xs", tickLine: false, axisLine: false }),
436
+ /* @__PURE__ */ jsx(
437
+ YAxis,
438
+ {
439
+ className: "text-xs",
440
+ tickLine: false,
441
+ axisLine: false,
442
+ tickFormatter: (v) => formatValue(v, spec.config?.valueFormatter)
443
+ }
444
+ ),
445
+ /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
446
+ shouldShowLegend(spec.config, series) && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }),
447
+ series.map((s) => {
448
+ const color = `var(--color-${s.dataKey})`;
449
+ switch (s.type) {
450
+ case "area":
451
+ return /* @__PURE__ */ jsx(
452
+ Area,
453
+ {
454
+ type: "monotone",
455
+ dataKey: s.dataKey,
456
+ stroke: color,
457
+ fill: color,
458
+ fillOpacity: 0.15,
459
+ strokeWidth: 2
460
+ },
461
+ s.dataKey
462
+ );
463
+ case "line":
464
+ return /* @__PURE__ */ jsx(
465
+ Line,
466
+ {
467
+ type: "monotone",
468
+ dataKey: s.dataKey,
469
+ stroke: color,
470
+ strokeWidth: 2,
471
+ dot: { r: 3 }
472
+ },
473
+ s.dataKey
474
+ );
475
+ case "bar":
476
+ default:
477
+ return /* @__PURE__ */ jsx(
478
+ Bar,
479
+ {
480
+ dataKey: s.dataKey,
481
+ fill: color,
482
+ radius: [4, 4, 0, 0]
483
+ },
484
+ s.dataKey
485
+ );
486
+ }
487
+ })
488
+ ] }) });
489
+ }
490
+ function RenderMetricCards({ spec }) {
491
+ const metrics = spec.metrics ?? [];
492
+ if (metrics.length === 0) return null;
493
+ return /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 md:grid-cols-3 gap-3", children: metrics.map((m, i) => /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-4 space-y-1.5", children: [
494
+ /* @__PURE__ */ jsxs("div", { className: "flex items-baseline gap-1", children: [
495
+ /* @__PURE__ */ jsx("span", { className: "text-2xl font-bold tracking-tight", children: m.value }),
496
+ m.unit && /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: m.unit })
497
+ ] }),
498
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-muted-foreground", children: m.label }),
499
+ m.trend && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
500
+ m.trendDirection === "up" && /* @__PURE__ */ jsx(TrendingUp, { className: "h-3.5 w-3.5 text-emerald-500" }),
501
+ m.trendDirection === "down" && /* @__PURE__ */ jsx(TrendingDown, { className: "h-3.5 w-3.5 text-red-500" }),
502
+ m.trendDirection === "neutral" && /* @__PURE__ */ jsx(Minus, { className: "h-3.5 w-3.5 text-muted-foreground" }),
503
+ /* @__PURE__ */ jsx(
504
+ "span",
505
+ {
506
+ className: `text-xs font-medium ${m.trendDirection === "up" ? "text-emerald-500" : m.trendDirection === "down" ? "text-red-500" : "text-muted-foreground"}`,
507
+ children: m.trend
508
+ }
509
+ )
510
+ ] }),
511
+ m.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground/70", children: m.description })
512
+ ] }, i)) });
513
+ }
514
+ function RenderComparison({ spec }) {
515
+ const items = spec.items ?? [];
516
+ const fields = spec.comparisonFields ?? [];
517
+ if (items.length === 0 || fields.length === 0) return null;
518
+ function renderCellValue(value, type) {
519
+ if (type === "boolean" || typeof value === "boolean") {
520
+ return value ? /* @__PURE__ */ jsx(Check, { className: "h-4 w-4 text-emerald-500 mx-auto" }) : /* @__PURE__ */ jsx(X, { className: "h-4 w-4 text-red-400 mx-auto" });
521
+ }
522
+ if (type === "rating" && typeof value === "number") {
523
+ return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center gap-0.5", children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ jsx(
524
+ Star,
525
+ {
526
+ className: `h-3.5 w-3.5 ${i < value ? "fill-amber-400 text-amber-400" : "text-muted-foreground/30"}`
527
+ },
528
+ i
529
+ )) });
530
+ }
531
+ return /* @__PURE__ */ jsx("span", { className: "text-sm", children: String(value) });
532
+ }
533
+ return /* @__PURE__ */ jsx("div", { className: "overflow-x-auto rounded-lg border", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-sm", children: [
534
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "border-b bg-muted/50", children: [
535
+ /* @__PURE__ */ jsx("th", { className: "px-3 py-2 text-left font-medium text-muted-foreground" }),
536
+ items.map((item, i) => /* @__PURE__ */ jsx(
537
+ "th",
538
+ {
539
+ className: `px-3 py-2 text-center font-semibold ${item.highlight ? "bg-primary/5 border-t-2 border-t-primary" : ""}`,
540
+ children: item.name
541
+ },
542
+ i
543
+ ))
544
+ ] }) }),
545
+ /* @__PURE__ */ jsx("tbody", { children: fields.map((field, fi) => /* @__PURE__ */ jsxs("tr", { className: fi % 2 === 0 ? "" : "bg-muted/20", children: [
546
+ /* @__PURE__ */ jsx("td", { className: "px-3 py-2 font-medium text-muted-foreground whitespace-nowrap", children: field.label }),
547
+ items.map((item, ii) => /* @__PURE__ */ jsx(
548
+ "td",
549
+ {
550
+ className: `px-3 py-2 text-center ${item.highlight ? "bg-primary/5" : ""}`,
551
+ children: field.key in item.features ? renderCellValue(item.features[field.key], field.type) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/40", children: "-" })
552
+ },
553
+ ii
554
+ ))
555
+ ] }, field.key)) })
556
+ ] }) });
557
+ }
558
+ function RenderTimeline({ spec }) {
559
+ const events = spec.events ?? [];
560
+ if (events.length === 0) return null;
561
+ return /* @__PURE__ */ jsxs("div", { className: "relative pl-6 space-y-6", children: [
562
+ /* @__PURE__ */ jsx("div", { className: "absolute left-[9px] top-2 bottom-2 w-px bg-border" }),
563
+ events.map((event, i) => {
564
+ const status = event.status ?? "upcoming";
565
+ return /* @__PURE__ */ jsxs("div", { className: "relative flex gap-4", children: [
566
+ /* @__PURE__ */ jsx("div", { className: "absolute -left-6 top-0.5 flex items-center justify-center", children: /* @__PURE__ */ jsx(
567
+ "div",
568
+ {
569
+ className: `h-[18px] w-[18px] rounded-full border-2 ${status === "completed" ? "border-emerald-500 bg-emerald-500" : status === "current" ? "border-blue-500 bg-blue-500 animate-pulse" : "border-muted-foreground/40 bg-background"}`,
570
+ children: status === "completed" && /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5 text-white m-auto" })
571
+ }
572
+ ) }),
573
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0 pb-1", children: [
574
+ event.date && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mb-0.5", children: event.date }),
575
+ /* @__PURE__ */ jsx(
576
+ "p",
577
+ {
578
+ className: `text-sm font-medium ${status === "upcoming" ? "text-muted-foreground" : ""}`,
579
+ children: event.title
580
+ }
581
+ ),
582
+ event.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground/70 mt-0.5", children: event.description })
583
+ ] })
584
+ ] }, i);
585
+ })
586
+ ] });
587
+ }
588
+ function RenderProgress({ spec }) {
589
+ const goals = spec.goals ?? [];
590
+ if (goals.length === 0) return null;
591
+ return /* @__PURE__ */ jsx("div", { className: "space-y-4", children: goals.map((goal, i) => {
592
+ const pct = goal.target > 0 ? Math.min(goal.current / goal.target * 100, 100) : 0;
593
+ const barColor = pct >= 75 ? "bg-emerald-500" : pct >= 40 ? "bg-amber-500" : "bg-red-500";
594
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
595
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between text-sm", children: [
596
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: goal.label }),
597
+ /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground tabular-nums", children: [
598
+ goal.current.toLocaleString(),
599
+ goal.unit ? ` ${goal.unit}` : "",
600
+ " / ",
601
+ goal.target.toLocaleString(),
602
+ goal.unit ? ` ${goal.unit}` : ""
603
+ ] })
604
+ ] }),
605
+ /* @__PURE__ */ jsx("div", { className: "h-2.5 w-full rounded-full bg-muted overflow-hidden", children: /* @__PURE__ */ jsx(
606
+ "div",
607
+ {
608
+ className: `h-full rounded-full transition-all ${barColor}`,
609
+ style: { width: `${pct}%` }
610
+ }
611
+ ) }),
612
+ /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground text-right tabular-nums", children: [
613
+ pct.toFixed(0),
614
+ "%"
615
+ ] })
616
+ ] }, i);
617
+ }) });
618
+ }
619
+ function renderContent(spec) {
620
+ switch (spec.type) {
621
+ case "line_chart":
622
+ return spec.data?.length ? /* @__PURE__ */ jsx(RenderLineChart, { spec }) : null;
623
+ case "bar_chart":
624
+ return spec.data?.length ? /* @__PURE__ */ jsx(RenderBarChart, { spec }) : null;
625
+ case "pie_chart":
626
+ return spec.data?.length ? /* @__PURE__ */ jsx(RenderPieChart, { spec }) : null;
627
+ case "area_chart":
628
+ return spec.data?.length ? /* @__PURE__ */ jsx(RenderAreaChart, { spec }) : null;
629
+ case "radar_chart":
630
+ return spec.data?.length ? /* @__PURE__ */ jsx(RenderRadarChart, { spec }) : null;
631
+ case "composed_chart":
632
+ return spec.data?.length ? /* @__PURE__ */ jsx(RenderComposedChart, { spec }) : null;
633
+ case "metric_cards":
634
+ return /* @__PURE__ */ jsx(RenderMetricCards, { spec });
635
+ case "comparison":
636
+ return /* @__PURE__ */ jsx(RenderComparison, { spec });
637
+ case "timeline":
638
+ return /* @__PURE__ */ jsx(RenderTimeline, { spec });
639
+ case "progress":
640
+ return /* @__PURE__ */ jsx(RenderProgress, { spec });
641
+ default:
642
+ return /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
643
+ "Unsupported visualization type: ",
644
+ String(spec.type)
645
+ ] });
646
+ }
647
+ }
648
+ function VisualizationRenderer({ spec }) {
649
+ if (!spec || !spec.type) {
650
+ return null;
651
+ }
652
+ return /* @__PURE__ */ jsxs("div", { className: "w-full space-y-3", children: [
653
+ (spec.title || spec.description) && /* @__PURE__ */ jsxs("div", { children: [
654
+ spec.title && /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: spec.title }),
655
+ spec.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: spec.description })
656
+ ] }),
657
+ renderContent(spec)
658
+ ] });
659
+ }
660
+ var VisualizationRenderer_default = VisualizationRenderer;
661
+
662
+ export { VisualizationRenderer, VisualizationRenderer_default };
663
+ //# sourceMappingURL=chunk-5T4FJ2SR.js.map
664
+ //# sourceMappingURL=chunk-5T4FJ2SR.js.map