@timbal-ai/timbal-react 1.0.0 → 1.2.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.
- package/CHANGELOG.md +35 -0
- package/README.md +55 -8
- package/dist/app.cjs +2369 -1189
- package/dist/app.d.cts +8 -4
- package/dist/app.d.ts +8 -4
- package/dist/app.esm.js +32 -7
- package/dist/{chart-artifact-DOkwSTjQ.d.cts → chart-artifact-E58ve76I.d.cts} +279 -12
- package/dist/{chart-artifact-CBo9x8Ch.d.ts → chart-artifact-_PEJgCpQ.d.ts} +279 -12
- package/dist/{chat-Bed4FQSl.d.cts → chat-ClmzWzCX.d.cts} +33 -4
- package/dist/{chat-Bed4FQSl.d.ts → chat-ClmzWzCX.d.ts} +33 -4
- package/dist/chat.cjs +1446 -776
- package/dist/chat.d.cts +1 -1
- package/dist/chat.d.ts +1 -1
- package/dist/chat.esm.js +3 -3
- package/dist/{chunk-YEFBANNF.esm.js → chunk-4VULP3CJ.esm.js} +242 -288
- package/dist/{chunk-RZ6QC6RG.esm.js → chunk-AGJKK6R7.esm.js} +2 -2
- package/dist/{chunk-FOD67Z6G.esm.js → chunk-BMXFXLVV.esm.js} +341 -12
- package/dist/chunk-FEYZUVBM.esm.js +52 -0
- package/dist/{chunk-C6IXFM4T.esm.js → chunk-MTYXREHK.esm.js} +4 -4
- package/dist/{chunk-AYHOVAMI.esm.js → chunk-NAMKO2MU.esm.js} +1 -1
- package/dist/{chunk-SNLXVG7H.esm.js → chunk-UY7AKWJL.esm.js} +1108 -656
- package/dist/{chunk-GLPOVYEA.esm.js → chunk-XDIY2WSL.esm.js} +669 -279
- package/dist/index.cjs +2967 -1824
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.esm.js +41 -11
- package/dist/pill-segmented-tabs-BsIOW1Lo.d.cts +528 -0
- package/dist/pill-segmented-tabs-BsIOW1Lo.d.ts +528 -0
- package/dist/studio.cjs +1685 -1015
- package/dist/studio.d.cts +2 -2
- package/dist/studio.d.ts +2 -2
- package/dist/studio.esm.js +5 -5
- package/dist/styles.css +24 -0
- package/dist/ui.cjs +387 -49
- package/dist/ui.d.cts +71 -491
- package/dist/ui.d.ts +71 -491
- package/dist/ui.esm.js +26 -6
- package/dist/{welcome-COOb05a5.d.cts → welcome-BFGRoNfK.d.cts} +1 -1
- package/dist/{welcome-DE08m9ca.d.ts → welcome-DXqsGTwH.d.ts} +1 -1
- package/package.json +7 -3
- package/vite/local-dev.d.ts +5 -1
- package/vite/local-dev.mjs +17 -13
package/dist/studio.cjs
CHANGED
|
@@ -898,10 +898,10 @@ function findParentIdFromAuiParent(messages, auiParentId) {
|
|
|
898
898
|
}
|
|
899
899
|
|
|
900
900
|
// src/chat/thread.tsx
|
|
901
|
-
var
|
|
902
|
-
var
|
|
901
|
+
var import_react30 = require("react");
|
|
902
|
+
var import_react31 = require("@assistant-ui/react");
|
|
903
903
|
var import_lucide_react8 = require("lucide-react");
|
|
904
|
-
var
|
|
904
|
+
var import_react32 = require("motion/react");
|
|
905
905
|
|
|
906
906
|
// src/chat/attachment.tsx
|
|
907
907
|
var import_react5 = require("react");
|
|
@@ -1058,6 +1058,33 @@ var TIMBAL_V2_SHADOW = {
|
|
|
1058
1058
|
ghost: "",
|
|
1059
1059
|
link: ""
|
|
1060
1060
|
};
|
|
1061
|
+
var TIMBAL_V2_PRIMARY_SURFACE = cn(
|
|
1062
|
+
TIMBAL_V2_PRIMARY_GRADIENT,
|
|
1063
|
+
TIMBAL_V2_SHADOW.primary,
|
|
1064
|
+
TIMBAL_V2_BORDER.primary
|
|
1065
|
+
);
|
|
1066
|
+
var TIMBAL_V2_PRIMARY_PILL_ROOT = cn(
|
|
1067
|
+
"relative box-border inline-flex items-center justify-center overflow-hidden rounded-full border-0 bg-transparent p-0 font-normal shadow-none transition duration-200 ease-in-out",
|
|
1068
|
+
TIMBAL_V2_SHADOW.primary,
|
|
1069
|
+
TIMBAL_V2_BORDER.primary
|
|
1070
|
+
);
|
|
1071
|
+
var TIMBAL_V2_PRIMARY_PILL_FILL_LAYER = cn(
|
|
1072
|
+
"pointer-events-none absolute inset-0 transition duration-200 ease-in-out",
|
|
1073
|
+
"bg-gradient-to-b from-primary-fill-from to-primary-fill-to",
|
|
1074
|
+
"group-hover/avatar:from-primary-fill-hover-from group-hover/avatar:to-primary-fill-hover-to",
|
|
1075
|
+
"group-active/avatar:from-primary-fill-active-from group-active/avatar:to-primary-fill-active-to"
|
|
1076
|
+
);
|
|
1077
|
+
var TIMBAL_V2_SECONDARY_PILL_ROOT = cn(
|
|
1078
|
+
"relative box-border inline-flex items-center justify-center overflow-hidden rounded-full bg-transparent p-0 font-normal shadow-none transition duration-200 ease-in-out",
|
|
1079
|
+
TIMBAL_V2_SHADOW.secondary,
|
|
1080
|
+
TIMBAL_V2_BORDER.secondary
|
|
1081
|
+
);
|
|
1082
|
+
var TIMBAL_V2_SECONDARY_PILL_FILL_LAYER = cn(
|
|
1083
|
+
"pointer-events-none absolute inset-0 transition duration-200 ease-in-out",
|
|
1084
|
+
TIMBAL_V2_ELEVATED_GRADIENT,
|
|
1085
|
+
"group-hover/avatar:from-secondary-fill-hover-from group-hover/avatar:to-secondary-fill-hover-to",
|
|
1086
|
+
"group-active/avatar:from-secondary-fill-active-from group-active/avatar:to-secondary-fill-active-to"
|
|
1087
|
+
);
|
|
1061
1088
|
var TIMBAL_V2_SWITCH_TRACK_OFF = cn(
|
|
1062
1089
|
TIMBAL_V2_ELEVATED_GRADIENT,
|
|
1063
1090
|
"border border-border shadow-card"
|
|
@@ -1167,25 +1194,71 @@ function DialogTitle({
|
|
|
1167
1194
|
}
|
|
1168
1195
|
|
|
1169
1196
|
// src/ui/avatar.tsx
|
|
1197
|
+
var React = __toESM(require("react"), 1);
|
|
1170
1198
|
var import_radix_ui3 = require("radix-ui");
|
|
1171
1199
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1200
|
+
var AVATAR_PRIMARY_FALLBACK_CLASS = cn(
|
|
1201
|
+
TIMBAL_V2_SECONDARY_PILL_ROOT,
|
|
1202
|
+
TIMBAL_V2_LABEL.secondary,
|
|
1203
|
+
"font-medium"
|
|
1204
|
+
);
|
|
1205
|
+
var AVATAR_SECONDARY_FILL_STYLE = {
|
|
1206
|
+
backgroundImage: "linear-gradient(to bottom, var(--elevated-from), var(--elevated-to))"
|
|
1207
|
+
};
|
|
1208
|
+
var AvatarChromeContext = React.createContext(
|
|
1209
|
+
null
|
|
1210
|
+
);
|
|
1211
|
+
function useAvatarChrome() {
|
|
1212
|
+
return React.useContext(AvatarChromeContext);
|
|
1213
|
+
}
|
|
1214
|
+
function isBrandedVariant(variant) {
|
|
1215
|
+
return variant === "secondary" || variant === "primary" || variant === "chart";
|
|
1216
|
+
}
|
|
1217
|
+
var AVATAR_SIZE_CLASS = {
|
|
1218
|
+
default: "size-8",
|
|
1219
|
+
sm: "size-6",
|
|
1220
|
+
lg: "size-10"
|
|
1221
|
+
};
|
|
1172
1222
|
function Avatar({
|
|
1173
1223
|
className,
|
|
1174
1224
|
size = "default",
|
|
1225
|
+
variant: rootVariant,
|
|
1226
|
+
children,
|
|
1175
1227
|
...props
|
|
1176
1228
|
}) {
|
|
1177
|
-
|
|
1229
|
+
const [chrome, setChrome] = React.useState(rootVariant ?? "muted");
|
|
1230
|
+
React.useLayoutEffect(() => {
|
|
1231
|
+
if (rootVariant !== void 0) {
|
|
1232
|
+
setChrome(rootVariant);
|
|
1233
|
+
}
|
|
1234
|
+
}, [rootVariant]);
|
|
1235
|
+
const branded = isBrandedVariant(chrome);
|
|
1236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AvatarChromeContext.Provider, { value: { chrome, setChrome }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1178
1237
|
import_radix_ui3.Avatar.Root,
|
|
1179
1238
|
{
|
|
1180
1239
|
"data-slot": "avatar",
|
|
1181
1240
|
"data-size": size,
|
|
1241
|
+
"data-variant": branded ? "secondary" : chrome,
|
|
1182
1242
|
className: cn(
|
|
1183
|
-
"group/avatar relative
|
|
1243
|
+
"group/avatar relative shrink-0 select-none",
|
|
1244
|
+
AVATAR_SIZE_CLASS[size],
|
|
1245
|
+
branded ? TIMBAL_V2_SECONDARY_PILL_ROOT : "flex overflow-hidden rounded-full",
|
|
1184
1246
|
className
|
|
1185
1247
|
),
|
|
1186
|
-
...props
|
|
1248
|
+
...props,
|
|
1249
|
+
children: [
|
|
1250
|
+
branded ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1251
|
+
"span",
|
|
1252
|
+
{
|
|
1253
|
+
"aria-hidden": true,
|
|
1254
|
+
className: TIMBAL_V2_SECONDARY_PILL_FILL_LAYER,
|
|
1255
|
+
style: AVATAR_SECONDARY_FILL_STYLE
|
|
1256
|
+
}
|
|
1257
|
+
) : null,
|
|
1258
|
+
children
|
|
1259
|
+
]
|
|
1187
1260
|
}
|
|
1188
|
-
);
|
|
1261
|
+
) });
|
|
1189
1262
|
}
|
|
1190
1263
|
function AvatarImage({
|
|
1191
1264
|
className,
|
|
@@ -1195,24 +1268,44 @@ function AvatarImage({
|
|
|
1195
1268
|
import_radix_ui3.Avatar.Image,
|
|
1196
1269
|
{
|
|
1197
1270
|
"data-slot": "avatar-image",
|
|
1198
|
-
className: cn(
|
|
1271
|
+
className: cn(
|
|
1272
|
+
"relative z-10 aspect-square size-full rounded-full object-cover",
|
|
1273
|
+
className
|
|
1274
|
+
),
|
|
1199
1275
|
...props
|
|
1200
1276
|
}
|
|
1201
1277
|
);
|
|
1202
1278
|
}
|
|
1203
1279
|
function AvatarFallback({
|
|
1204
1280
|
className,
|
|
1281
|
+
variant = "muted",
|
|
1282
|
+
seed: _seed,
|
|
1283
|
+
children,
|
|
1284
|
+
style,
|
|
1205
1285
|
...props
|
|
1206
1286
|
}) {
|
|
1287
|
+
const chromeCtx = useAvatarChrome();
|
|
1288
|
+
React.useLayoutEffect(() => {
|
|
1289
|
+
chromeCtx?.setChrome(variant);
|
|
1290
|
+
}, [chromeCtx, variant]);
|
|
1291
|
+
const branded = isBrandedVariant(variant);
|
|
1207
1292
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1208
1293
|
import_radix_ui3.Avatar.Fallback,
|
|
1209
1294
|
{
|
|
1210
1295
|
"data-slot": "avatar-fallback",
|
|
1296
|
+
"data-variant": branded ? "secondary" : variant,
|
|
1211
1297
|
className: cn(
|
|
1212
|
-
"
|
|
1298
|
+
"relative z-10 flex size-full items-center justify-center rounded-full",
|
|
1299
|
+
branded ? cn(
|
|
1300
|
+
"bg-transparent font-medium",
|
|
1301
|
+
TIMBAL_V2_LABEL.secondary,
|
|
1302
|
+
"text-sm group-data-[size=sm]/avatar:text-xs"
|
|
1303
|
+
) : "bg-muted font-normal text-muted-foreground text-sm group-data-[size=sm]/avatar:text-xs",
|
|
1213
1304
|
className
|
|
1214
1305
|
),
|
|
1215
|
-
|
|
1306
|
+
style,
|
|
1307
|
+
...props,
|
|
1308
|
+
children
|
|
1216
1309
|
}
|
|
1217
1310
|
);
|
|
1218
1311
|
}
|
|
@@ -1221,7 +1314,7 @@ function AvatarFallback({
|
|
|
1221
1314
|
var import_react4 = require("react");
|
|
1222
1315
|
|
|
1223
1316
|
// src/ui/timbal-v2-button.tsx
|
|
1224
|
-
var
|
|
1317
|
+
var React2 = __toESM(require("react"), 1);
|
|
1225
1318
|
var import_radix_ui4 = require("radix-ui");
|
|
1226
1319
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1227
1320
|
var TIMBAL_V2_FILL_AS_CHILD = {
|
|
@@ -1257,7 +1350,7 @@ var TIMBAL_V2_LABEL_AS_CHILD = {
|
|
|
1257
1350
|
...TIMBAL_V2_LABEL,
|
|
1258
1351
|
link: "text-foreground underline decoration-foreground/25 underline-offset-2 hover:decoration-foreground/45"
|
|
1259
1352
|
};
|
|
1260
|
-
var TimbalV2Button =
|
|
1353
|
+
var TimbalV2Button = React2.forwardRef(function TimbalV2Button2({
|
|
1261
1354
|
variant = "secondary",
|
|
1262
1355
|
size = "sm",
|
|
1263
1356
|
isIconOnly = false,
|
|
@@ -1522,131 +1615,329 @@ var import_react_markdown = require("@assistant-ui/react-markdown");
|
|
|
1522
1615
|
var import_remark_gfm = __toESM(require("remark-gfm"), 1);
|
|
1523
1616
|
var import_remark_math = __toESM(require("remark-math"), 1);
|
|
1524
1617
|
var import_rehype_katex = __toESM(require("rehype-katex"), 1);
|
|
1525
|
-
var
|
|
1618
|
+
var import_react20 = require("react");
|
|
1526
1619
|
var import_lucide_react4 = require("lucide-react");
|
|
1527
1620
|
|
|
1528
1621
|
// src/chat/syntax-highlighter.tsx
|
|
1529
|
-
var
|
|
1622
|
+
var import_react19 = require("react");
|
|
1530
1623
|
var import_core = require("shiki/core");
|
|
1531
1624
|
var import_javascript = require("shiki/engine/javascript");
|
|
1532
1625
|
|
|
1533
1626
|
// src/artifacts/registry.tsx
|
|
1534
|
-
var
|
|
1627
|
+
var import_react18 = require("react");
|
|
1535
1628
|
|
|
1536
1629
|
// src/artifacts/chart-artifact.tsx
|
|
1537
|
-
var
|
|
1630
|
+
var import_react10 = require("react");
|
|
1538
1631
|
|
|
1539
1632
|
// src/charts/line-area-chart.tsx
|
|
1540
|
-
var import_react8 = require("react");
|
|
1541
|
-
|
|
1542
|
-
// src/charts/use-chart-width.ts
|
|
1543
1633
|
var import_react7 = require("react");
|
|
1544
|
-
|
|
1545
|
-
const ref = (0, import_react7.useRef)(null);
|
|
1546
|
-
const [width, setWidth] = (0, import_react7.useState)(initial);
|
|
1547
|
-
(0, import_react7.useEffect)(() => {
|
|
1548
|
-
const el = ref.current;
|
|
1549
|
-
if (!el || typeof ResizeObserver === "undefined") return;
|
|
1550
|
-
const ro = new ResizeObserver((entries) => {
|
|
1551
|
-
const w = entries[0]?.contentRect.width;
|
|
1552
|
-
if (w && w > 0) setWidth(w);
|
|
1553
|
-
});
|
|
1554
|
-
ro.observe(el);
|
|
1555
|
-
return () => ro.disconnect();
|
|
1556
|
-
}, []);
|
|
1557
|
-
return { ref, width };
|
|
1558
|
-
}
|
|
1634
|
+
var import_recharts = require("recharts");
|
|
1559
1635
|
|
|
1560
|
-
// src/
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
if (
|
|
1569
|
-
|
|
1570
|
-
return `M ${points[0].x},${points[0].y} L ${points[1].x},${points[1].y}`;
|
|
1571
|
-
}
|
|
1572
|
-
const tangents = monotoneTangents(points);
|
|
1573
|
-
let d = `M ${points[0].x},${points[0].y}`;
|
|
1574
|
-
for (let i = 0; i < n - 1; i++) {
|
|
1575
|
-
const p0 = points[i];
|
|
1576
|
-
const p1 = points[i + 1];
|
|
1577
|
-
const dx = (p1.x - p0.x) / 3;
|
|
1578
|
-
const c1x = p0.x + dx;
|
|
1579
|
-
const c1y = p0.y + dx * tangents[i];
|
|
1580
|
-
const c2x = p1.x - dx;
|
|
1581
|
-
const c2y = p1.y - dx * tangents[i + 1];
|
|
1582
|
-
d += ` C ${c1x},${c1y} ${c2x},${c2y} ${p1.x},${p1.y}`;
|
|
1636
|
+
// src/ui/chart.tsx
|
|
1637
|
+
var React3 = __toESM(require("react"), 1);
|
|
1638
|
+
var RechartsPrimitive = __toESM(require("recharts"), 1);
|
|
1639
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1640
|
+
var THEMES = { light: "", dark: ".dark" };
|
|
1641
|
+
var ChartContext = React3.createContext(null);
|
|
1642
|
+
function useChart() {
|
|
1643
|
+
const context = React3.useContext(ChartContext);
|
|
1644
|
+
if (!context) {
|
|
1645
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
1583
1646
|
}
|
|
1584
|
-
return
|
|
1585
|
-
}
|
|
1586
|
-
function
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
}
|
|
1593
|
-
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1647
|
+
return context;
|
|
1648
|
+
}
|
|
1649
|
+
function ChartContainer({
|
|
1650
|
+
id,
|
|
1651
|
+
className,
|
|
1652
|
+
children,
|
|
1653
|
+
config,
|
|
1654
|
+
...props
|
|
1655
|
+
}) {
|
|
1656
|
+
const uniqueId = React3.useId();
|
|
1657
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
1658
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1659
|
+
"div",
|
|
1660
|
+
{
|
|
1661
|
+
"data-slot": "chart",
|
|
1662
|
+
"data-chart": chartId,
|
|
1663
|
+
className: cn(
|
|
1664
|
+
"[&_.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-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 flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
1665
|
+
className
|
|
1666
|
+
),
|
|
1667
|
+
...props,
|
|
1668
|
+
children: [
|
|
1669
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChartStyle, { id: chartId, config }),
|
|
1670
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RechartsPrimitive.ResponsiveContainer, { children })
|
|
1671
|
+
]
|
|
1672
|
+
}
|
|
1673
|
+
) });
|
|
1674
|
+
}
|
|
1675
|
+
var ChartStyle = ({ id, config }) => {
|
|
1676
|
+
const colorConfig = Object.entries(config).filter(
|
|
1677
|
+
([, c]) => c.theme || c.color
|
|
1678
|
+
);
|
|
1679
|
+
if (!colorConfig.length) {
|
|
1680
|
+
return null;
|
|
1599
1681
|
}
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1683
|
+
"style",
|
|
1684
|
+
{
|
|
1685
|
+
dangerouslySetInnerHTML: {
|
|
1686
|
+
__html: Object.entries(THEMES).map(
|
|
1687
|
+
([theme, prefix]) => `
|
|
1688
|
+
${prefix} [data-chart=${id}] {
|
|
1689
|
+
${colorConfig.map(([key, itemConfig]) => {
|
|
1690
|
+
const color = itemConfig.theme?.[theme] || itemConfig.color;
|
|
1691
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
1692
|
+
}).join("\n")}
|
|
1693
|
+
}
|
|
1694
|
+
`
|
|
1695
|
+
).join("\n")
|
|
1696
|
+
}
|
|
1610
1697
|
}
|
|
1698
|
+
);
|
|
1699
|
+
};
|
|
1700
|
+
var ChartTooltip = RechartsPrimitive.Tooltip;
|
|
1701
|
+
function ChartTooltipContent({
|
|
1702
|
+
active,
|
|
1703
|
+
payload,
|
|
1704
|
+
className,
|
|
1705
|
+
indicator = "dot",
|
|
1706
|
+
hideLabel = false,
|
|
1707
|
+
hideIndicator = false,
|
|
1708
|
+
label,
|
|
1709
|
+
labelFormatter,
|
|
1710
|
+
labelClassName,
|
|
1711
|
+
formatter,
|
|
1712
|
+
color,
|
|
1713
|
+
nameKey,
|
|
1714
|
+
labelKey
|
|
1715
|
+
}) {
|
|
1716
|
+
const { config } = useChart();
|
|
1717
|
+
const tooltipLabel = React3.useMemo(() => {
|
|
1718
|
+
if (hideLabel || !payload?.length) {
|
|
1719
|
+
return null;
|
|
1720
|
+
}
|
|
1721
|
+
const [item] = payload;
|
|
1722
|
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
|
|
1723
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
1724
|
+
const value = !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;
|
|
1725
|
+
if (labelFormatter) {
|
|
1726
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
|
|
1727
|
+
}
|
|
1728
|
+
if (!value) {
|
|
1729
|
+
return null;
|
|
1730
|
+
}
|
|
1731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: cn("font-medium", labelClassName), children: value });
|
|
1732
|
+
}, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
|
|
1733
|
+
if (!active || !payload?.length) {
|
|
1734
|
+
return null;
|
|
1611
1735
|
}
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1736
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
1737
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1738
|
+
"div",
|
|
1739
|
+
{
|
|
1740
|
+
className: cn(
|
|
1741
|
+
"border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",
|
|
1742
|
+
"animate-in fade-in-0 zoom-in-95 duration-150",
|
|
1743
|
+
className
|
|
1744
|
+
),
|
|
1745
|
+
children: [
|
|
1746
|
+
!nestLabel ? tooltipLabel : null,
|
|
1747
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "grid gap-1.5", children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
1748
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
1749
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
1750
|
+
const indicatorColor = color || item.payload?.fill || item.color;
|
|
1751
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1752
|
+
"div",
|
|
1753
|
+
{
|
|
1754
|
+
className: cn(
|
|
1755
|
+
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
|
|
1756
|
+
indicator === "dot" && "items-center"
|
|
1757
|
+
),
|
|
1758
|
+
children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
1759
|
+
itemConfig?.icon ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1760
|
+
"div",
|
|
1761
|
+
{
|
|
1762
|
+
className: cn(
|
|
1763
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
1764
|
+
{
|
|
1765
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
1766
|
+
"w-1": indicator === "line",
|
|
1767
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
1768
|
+
"my-0.5": nestLabel && indicator === "dashed"
|
|
1769
|
+
}
|
|
1770
|
+
),
|
|
1771
|
+
style: {
|
|
1772
|
+
"--color-bg": indicatorColor,
|
|
1773
|
+
"--color-border": indicatorColor
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
),
|
|
1777
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1778
|
+
"div",
|
|
1779
|
+
{
|
|
1780
|
+
className: cn(
|
|
1781
|
+
"flex flex-1 justify-between leading-none",
|
|
1782
|
+
nestLabel ? "items-end" : "items-center"
|
|
1783
|
+
),
|
|
1784
|
+
children: [
|
|
1785
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "grid gap-1.5", children: [
|
|
1786
|
+
nestLabel ? tooltipLabel : null,
|
|
1787
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-muted-foreground", children: itemConfig?.label || item.name })
|
|
1788
|
+
] }),
|
|
1789
|
+
item.value != null && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-foreground font-mono font-medium tabular-nums", children: typeof item.value === "number" ? item.value.toLocaleString() : String(item.value) })
|
|
1790
|
+
]
|
|
1791
|
+
}
|
|
1792
|
+
)
|
|
1793
|
+
] })
|
|
1794
|
+
},
|
|
1795
|
+
`${item.dataKey ?? index}`
|
|
1796
|
+
);
|
|
1797
|
+
}) })
|
|
1798
|
+
]
|
|
1626
1799
|
}
|
|
1800
|
+
);
|
|
1801
|
+
}
|
|
1802
|
+
var ChartLegend = RechartsPrimitive.Legend;
|
|
1803
|
+
function ChartLegendContent({
|
|
1804
|
+
className,
|
|
1805
|
+
hideIcon = false,
|
|
1806
|
+
payload,
|
|
1807
|
+
verticalAlign = "bottom",
|
|
1808
|
+
nameKey
|
|
1809
|
+
}) {
|
|
1810
|
+
const { config } = useChart();
|
|
1811
|
+
if (!payload?.length) {
|
|
1812
|
+
return null;
|
|
1627
1813
|
}
|
|
1628
|
-
return
|
|
1814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1815
|
+
"div",
|
|
1816
|
+
{
|
|
1817
|
+
className: cn(
|
|
1818
|
+
"flex items-center justify-center gap-4",
|
|
1819
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
1820
|
+
className
|
|
1821
|
+
),
|
|
1822
|
+
children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
1823
|
+
const key = `${nameKey || item.dataKey || "value"}`;
|
|
1824
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
1825
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1826
|
+
"div",
|
|
1827
|
+
{
|
|
1828
|
+
className: "[&>svg]:text-muted-foreground flex min-w-0 max-w-[8rem] items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3",
|
|
1829
|
+
children: [
|
|
1830
|
+
itemConfig?.icon && !hideIcon ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(itemConfig.icon, {}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1831
|
+
"div",
|
|
1832
|
+
{
|
|
1833
|
+
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
1834
|
+
style: { backgroundColor: item.color }
|
|
1835
|
+
}
|
|
1836
|
+
),
|
|
1837
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "min-w-0 truncate", children: itemConfig?.label ?? (item.value != null ? String(item.value) : null) })
|
|
1838
|
+
]
|
|
1839
|
+
},
|
|
1840
|
+
`${item.value ?? index}`
|
|
1841
|
+
);
|
|
1842
|
+
})
|
|
1843
|
+
}
|
|
1844
|
+
);
|
|
1629
1845
|
}
|
|
1630
|
-
function
|
|
1631
|
-
if (
|
|
1632
|
-
return
|
|
1846
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
1847
|
+
if (typeof payload !== "object" || payload === null) {
|
|
1848
|
+
return void 0;
|
|
1633
1849
|
}
|
|
1634
|
-
const
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1850
|
+
const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
|
|
1851
|
+
let configLabelKey = key;
|
|
1852
|
+
if (key in payload && typeof payload[key] === "string") {
|
|
1853
|
+
configLabelKey = payload[key];
|
|
1854
|
+
} else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
|
|
1855
|
+
configLabelKey = payloadPayload[key];
|
|
1639
1856
|
}
|
|
1640
|
-
return
|
|
1857
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
// src/charts/chart-gradient-utils.ts
|
|
1861
|
+
function barGradientId(scopeId, dataKey) {
|
|
1862
|
+
return `bar-${scopeId}-${sanitizeId(dataKey)}`;
|
|
1641
1863
|
}
|
|
1642
|
-
function
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1864
|
+
function pieGradientId(scopeId, key) {
|
|
1865
|
+
return `pie-${scopeId}-${sanitizeId(key)}`;
|
|
1866
|
+
}
|
|
1867
|
+
function sanitizeId(key) {
|
|
1868
|
+
return key.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1869
|
+
}
|
|
1870
|
+
function truncateLabel(text, maxChars = 14) {
|
|
1871
|
+
const s = String(text ?? "");
|
|
1872
|
+
if (s.length <= maxChars) return s;
|
|
1873
|
+
if (maxChars <= 1) return "\u2026";
|
|
1874
|
+
return `${s.slice(0, maxChars - 1)}\u2026`;
|
|
1875
|
+
}
|
|
1876
|
+
function estimateYAxisWidth(labels, { min = 48, max = 112, charWidth = 6.5 } = {}) {
|
|
1877
|
+
if (labels.length === 0) return min;
|
|
1878
|
+
const longest = labels.reduce((a, b) => a.length >= b.length ? a : b, "");
|
|
1879
|
+
return Math.min(max, Math.max(min, Math.ceil(longest.length * charWidth) + 12));
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
// src/charts/chart-axis-tick.tsx
|
|
1883
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1884
|
+
var ChartAxisTick = ({
|
|
1885
|
+
x = 0,
|
|
1886
|
+
y = 0,
|
|
1887
|
+
payload,
|
|
1888
|
+
textAnchor = "end",
|
|
1889
|
+
maxChars = 14,
|
|
1890
|
+
clipTicks = true
|
|
1891
|
+
}) => {
|
|
1892
|
+
const raw = String(payload?.value ?? "");
|
|
1893
|
+
const label = clipTicks ? truncateLabel(raw, maxChars) : raw;
|
|
1894
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("g", { transform: `translate(${x},${y})`, children: [
|
|
1895
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("title", { children: raw }),
|
|
1896
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1897
|
+
"text",
|
|
1898
|
+
{
|
|
1899
|
+
textAnchor,
|
|
1900
|
+
fill: "currentColor",
|
|
1901
|
+
className: "fill-muted-foreground",
|
|
1902
|
+
dominantBaseline: "middle",
|
|
1903
|
+
children: label
|
|
1904
|
+
}
|
|
1905
|
+
)
|
|
1906
|
+
] });
|
|
1907
|
+
};
|
|
1908
|
+
|
|
1909
|
+
// src/charts/chart-gradients.tsx
|
|
1910
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1911
|
+
var BarGradientDefs = ({
|
|
1912
|
+
scopeId,
|
|
1913
|
+
dataKeys,
|
|
1914
|
+
horizontal
|
|
1915
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("defs", { children: dataKeys.map((dataKey) => {
|
|
1916
|
+
const id = barGradientId(scopeId, dataKey);
|
|
1917
|
+
const color = `var(--color-${dataKey})`;
|
|
1918
|
+
if (horizontal) {
|
|
1919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "1", y2: "0", children: [
|
|
1920
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "0%", stopColor: color, stopOpacity: 1 }),
|
|
1921
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "100%", stopColor: color, stopOpacity: 0.55 })
|
|
1922
|
+
] }, dataKey);
|
|
1923
|
+
}
|
|
1924
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
1925
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "0%", stopColor: color, stopOpacity: 1 }),
|
|
1926
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "100%", stopColor: color, stopOpacity: 0.55 })
|
|
1927
|
+
] }, dataKey);
|
|
1928
|
+
}) });
|
|
1929
|
+
var PieGradientDefs = ({ scopeId, slices }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("defs", { children: slices.map(({ key, color }) => {
|
|
1930
|
+
const id = pieGradientId(scopeId, key);
|
|
1931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "1", y2: "1", children: [
|
|
1932
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "0%", stopColor: color, stopOpacity: 1 }),
|
|
1933
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("stop", { offset: "100%", stopColor: color, stopOpacity: 0.65 })
|
|
1934
|
+
] }, key);
|
|
1935
|
+
}) });
|
|
1936
|
+
|
|
1937
|
+
// src/charts/geometry.ts
|
|
1938
|
+
function toNum(value) {
|
|
1939
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
1940
|
+
return Number.isFinite(n) ? n : 0;
|
|
1650
1941
|
}
|
|
1651
1942
|
function round(v) {
|
|
1652
1943
|
return Math.round(v * 1e6) / 1e6;
|
|
@@ -1660,18 +1951,53 @@ function formatCompact(value, unit) {
|
|
|
1660
1951
|
return unit ? `${s}${unit}` : s;
|
|
1661
1952
|
}
|
|
1662
1953
|
|
|
1954
|
+
// src/charts/line-area-chart-utils.ts
|
|
1955
|
+
function resolveChartMargin(options) {
|
|
1956
|
+
const { flush, showXAxis, showYAxis } = options;
|
|
1957
|
+
if (!flush) {
|
|
1958
|
+
return { top: 8, right: 12, bottom: 0, left: 0 };
|
|
1959
|
+
}
|
|
1960
|
+
const anyAxis = showXAxis || showYAxis;
|
|
1961
|
+
if (!anyAxis) {
|
|
1962
|
+
return { top: 8, right: 12, bottom: 8, left: 12 };
|
|
1963
|
+
}
|
|
1964
|
+
return {
|
|
1965
|
+
top: 8,
|
|
1966
|
+
right: 12,
|
|
1967
|
+
bottom: showXAxis ? 24 : 8,
|
|
1968
|
+
left: showYAxis ? 8 : 12
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
function flushBarCategoryGap(flush, showCategoryAxis) {
|
|
1972
|
+
return flush && showCategoryAxis ? "0%" : void 0;
|
|
1973
|
+
}
|
|
1974
|
+
function flushLineAreaEdgeToEdge(flush, variant, showXAxis, showYAxis) {
|
|
1975
|
+
return flush && (variant === "line" || variant === "area") && showXAxis && !showYAxis;
|
|
1976
|
+
}
|
|
1977
|
+
function resolveTooltipCategory(label, payload, xKey, data, formatX) {
|
|
1978
|
+
const row = payload?.[0]?.payload;
|
|
1979
|
+
if (row && xKey in row) {
|
|
1980
|
+
const idx = data.indexOf(row);
|
|
1981
|
+
return formatX(row[xKey], idx >= 0 ? idx : 0);
|
|
1982
|
+
}
|
|
1983
|
+
if (label != null && label !== "") {
|
|
1984
|
+
const idx = typeof label === "number" ? label : data.findIndex((r) => r[xKey] === label || String(r[xKey]) === String(label));
|
|
1985
|
+
return formatX(label, idx >= 0 ? idx : 0);
|
|
1986
|
+
}
|
|
1987
|
+
return "";
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1663
1990
|
// src/charts/line-area-chart.tsx
|
|
1664
|
-
var
|
|
1991
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1992
|
+
var INDEX_X_KEY = "__index";
|
|
1665
1993
|
var CHART_PALETTE = [
|
|
1666
|
-
"var(--
|
|
1667
|
-
"#
|
|
1668
|
-
"#
|
|
1669
|
-
"#
|
|
1670
|
-
"#
|
|
1671
|
-
"#
|
|
1994
|
+
"var(--chart-1, #4f46e5)",
|
|
1995
|
+
"var(--chart-2, #3b82f6)",
|
|
1996
|
+
"var(--chart-3, #0ea5e9)",
|
|
1997
|
+
"var(--chart-4, #6366f1)",
|
|
1998
|
+
"var(--chart-5, #60a5fa)",
|
|
1999
|
+
"var(--chart-6, #2563eb)"
|
|
1672
2000
|
];
|
|
1673
|
-
var PAD_DEFAULT = { top: 12, right: 16, bottom: 26, left: 44 };
|
|
1674
|
-
var PAD_FLUSH = { top: 20, right: 0, bottom: 8, left: 0 };
|
|
1675
2001
|
var LineAreaChart = ({
|
|
1676
2002
|
data = [],
|
|
1677
2003
|
xKey: xKeyProp,
|
|
@@ -1680,347 +2006,698 @@ var LineAreaChart = ({
|
|
|
1680
2006
|
height = 240,
|
|
1681
2007
|
unit,
|
|
1682
2008
|
yMax,
|
|
2009
|
+
curve = "monotone",
|
|
2010
|
+
stacked = false,
|
|
2011
|
+
dots = false,
|
|
2012
|
+
orientation = "vertical",
|
|
2013
|
+
barRadius = 4,
|
|
2014
|
+
gridLines,
|
|
1683
2015
|
layout = "default",
|
|
1684
2016
|
showGrid = true,
|
|
1685
2017
|
showXAxis: showXAxisProp,
|
|
1686
2018
|
showYAxis: showYAxisProp,
|
|
1687
2019
|
showLegend: showLegendProp,
|
|
1688
2020
|
showTooltip = true,
|
|
2021
|
+
tooltipIndicator = "dot",
|
|
1689
2022
|
formatValue,
|
|
1690
2023
|
formatX,
|
|
2024
|
+
clipTicks = true,
|
|
1691
2025
|
className,
|
|
1692
2026
|
ariaLabel = "Chart"
|
|
1693
2027
|
}) => {
|
|
1694
|
-
const
|
|
1695
|
-
const { ref, width } = useChartWidth();
|
|
1696
|
-
const [active, setActive] = (0, import_react8.useState)(null);
|
|
1697
|
-
const [grown, setGrown] = (0, import_react8.useState)(false);
|
|
2028
|
+
const gradientScopeId = (0, import_react7.useId)().replace(/:/g, "");
|
|
1698
2029
|
const xKey = xKeyProp ?? inferXKey(data);
|
|
1699
|
-
const series = (
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
const
|
|
1704
|
-
const
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
2030
|
+
const series = resolveSeries(seriesProp, data, xKey);
|
|
2031
|
+
const flush = layout === "flush";
|
|
2032
|
+
const horizontal = orientation === "horizontal" && variant === "bar";
|
|
2033
|
+
const showXAxis = showXAxisProp ?? !flush;
|
|
2034
|
+
const showYAxis = showYAxisProp ?? !flush;
|
|
2035
|
+
const showLegend = showLegendProp ?? (!flush && series.length > 1);
|
|
2036
|
+
const grid = gridLines ?? (horizontal ? "vertical" : "horizontal");
|
|
2037
|
+
if (data.length === 0 || series.length === 0) {
|
|
2038
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartEmpty, { className, height, ariaLabel });
|
|
2039
|
+
}
|
|
2040
|
+
const config = {};
|
|
2041
|
+
series.forEach((s, i) => {
|
|
2042
|
+
config[s.dataKey] = {
|
|
2043
|
+
label: s.label ?? s.dataKey,
|
|
2044
|
+
color: s.color ?? CHART_PALETTE[i % CHART_PALETTE.length]
|
|
2045
|
+
};
|
|
2046
|
+
});
|
|
2047
|
+
const valueFmt = (v) => formatValue ? formatValue(toNum(v)) : formatCompact(toNum(v), unit);
|
|
2048
|
+
const xFmt = (v, i) => formatX ? formatX(v, i) : String(v ?? "");
|
|
2049
|
+
const margin = resolveChartMargin({ flush, showXAxis, showYAxis });
|
|
2050
|
+
const flushCategoryXAxisProps = flush && showXAxis && flushLineAreaEdgeToEdge(flush, variant, showXAxis, showYAxis) ? { scale: "point", padding: "no-gap", interval: 0 } : flush && showXAxis && variant === "bar" ? { interval: 0 } : {};
|
|
2051
|
+
const useIndexX = flushLineAreaEdgeToEdge(flush, variant, showXAxis, showYAxis);
|
|
2052
|
+
const chartData = useIndexX ? data.map((row, i) => ({ ...row, [INDEX_X_KEY]: i })) : data;
|
|
2053
|
+
const chartXKey = useIndexX ? INDEX_X_KEY : xKey;
|
|
2054
|
+
const categoryTick = (textAnchor) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartAxisTick, { textAnchor, clipTicks });
|
|
2055
|
+
const showVGrid = showGrid && (grid === "vertical" || grid === "both");
|
|
2056
|
+
const showHGrid = showGrid && (grid === "horizontal" || grid === "both");
|
|
2057
|
+
const tooltipEl = showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2058
|
+
ChartTooltip,
|
|
2059
|
+
{
|
|
2060
|
+
cursor: variant === "bar",
|
|
2061
|
+
content: ({ active, payload, label }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2062
|
+
ChartTooltipContent,
|
|
2063
|
+
{
|
|
2064
|
+
active,
|
|
2065
|
+
payload,
|
|
2066
|
+
label,
|
|
2067
|
+
indicator: tooltipIndicator,
|
|
2068
|
+
labelFormatter: (_value, items) => {
|
|
2069
|
+
const category = resolveTooltipCategory(label, items, xKey, data, xFmt);
|
|
2070
|
+
return category || null;
|
|
2071
|
+
},
|
|
2072
|
+
formatter: (value, name, item) => {
|
|
2073
|
+
const key = String(item.dataKey ?? name ?? "value");
|
|
2074
|
+
const seriesLabel = config[key]?.label ?? name;
|
|
2075
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-1 items-center justify-between leading-none", children: [
|
|
2076
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-muted-foreground", children: seriesLabel }),
|
|
2077
|
+
value != null ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-foreground font-mono font-medium tabular-nums", children: valueFmt(value) }) : null
|
|
2078
|
+
] });
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
)
|
|
2082
|
+
}
|
|
2083
|
+
) : null;
|
|
2084
|
+
const legendEl = showLegend ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartLegend, { content: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartLegendContent, {}) }) : null;
|
|
2085
|
+
const gridEl = showGrid && grid !== "none" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts.CartesianGrid, { vertical: showVGrid, horizontal: showHGrid, strokeDasharray: "4 4" }) : null;
|
|
2086
|
+
const yDomain = yMax != null ? [0, yMax] : void 0;
|
|
2087
|
+
if (variant === "bar") {
|
|
2088
|
+
const dataKeys = series.map((s) => s.dataKey);
|
|
2089
|
+
const barDefs = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(BarGradientDefs, { scopeId: gradientScopeId, dataKeys, horizontal });
|
|
2090
|
+
const bars = series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2091
|
+
import_recharts.Bar,
|
|
2092
|
+
{
|
|
2093
|
+
dataKey: s.dataKey,
|
|
2094
|
+
fill: `url(#${barGradientId(gradientScopeId, s.dataKey)})`,
|
|
2095
|
+
radius: barCornerRadius(barRadius, horizontal, stacked),
|
|
2096
|
+
stackId: stacked ? "stack" : void 0,
|
|
2097
|
+
isAnimationActive: true
|
|
2098
|
+
},
|
|
2099
|
+
s.dataKey
|
|
2100
|
+
));
|
|
2101
|
+
if (horizontal) {
|
|
2102
|
+
const categoryLabels = data.map((row, i) => xFmt(row[xKey], i));
|
|
2103
|
+
const yAxisWidth = showYAxis ? estimateYAxisWidth(
|
|
2104
|
+
clipTicks ? categoryLabels.map((l) => l.slice(0, 14)) : categoryLabels
|
|
2105
|
+
) : 0;
|
|
2106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2107
|
+
import_recharts.BarChart,
|
|
2108
|
+
{
|
|
2109
|
+
accessibilityLayer: true,
|
|
2110
|
+
data,
|
|
2111
|
+
layout: "vertical",
|
|
2112
|
+
margin,
|
|
2113
|
+
barCategoryGap: flushBarCategoryGap(flush, showYAxis),
|
|
2114
|
+
children: [
|
|
2115
|
+
barDefs,
|
|
2116
|
+
gridEl,
|
|
2117
|
+
showXAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2118
|
+
import_recharts.XAxis,
|
|
2119
|
+
{
|
|
2120
|
+
type: "number",
|
|
2121
|
+
tickLine: false,
|
|
2122
|
+
axisLine: false,
|
|
2123
|
+
tickMargin: 8,
|
|
2124
|
+
tickFormatter: (v) => valueFmt(v),
|
|
2125
|
+
domain: yDomain
|
|
2126
|
+
}
|
|
2127
|
+
) : null,
|
|
2128
|
+
showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2129
|
+
import_recharts.YAxis,
|
|
2130
|
+
{
|
|
2131
|
+
type: "category",
|
|
2132
|
+
dataKey: xKey,
|
|
2133
|
+
tickLine: false,
|
|
2134
|
+
axisLine: false,
|
|
2135
|
+
tickMargin: 8,
|
|
2136
|
+
width: yAxisWidth,
|
|
2137
|
+
minTickGap: 16,
|
|
2138
|
+
tick: categoryTick("end")
|
|
2139
|
+
}
|
|
2140
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts.YAxis, { type: "category", dataKey: xKey, hide: true, width: 0 }),
|
|
2141
|
+
tooltipEl,
|
|
2142
|
+
legendEl,
|
|
2143
|
+
bars
|
|
2144
|
+
]
|
|
2145
|
+
}
|
|
2146
|
+
) });
|
|
2147
|
+
}
|
|
2148
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartShell, { config, height, className, ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2149
|
+
import_recharts.BarChart,
|
|
2150
|
+
{
|
|
2151
|
+
accessibilityLayer: true,
|
|
2152
|
+
data,
|
|
2153
|
+
margin,
|
|
2154
|
+
barCategoryGap: flushBarCategoryGap(flush, showXAxis),
|
|
2155
|
+
children: [
|
|
2156
|
+
barDefs,
|
|
2157
|
+
gridEl,
|
|
2158
|
+
showXAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2159
|
+
import_recharts.XAxis,
|
|
2160
|
+
{
|
|
2161
|
+
dataKey: xKey,
|
|
2162
|
+
tickLine: false,
|
|
2163
|
+
axisLine: false,
|
|
2164
|
+
tickMargin: 8,
|
|
2165
|
+
minTickGap: 16,
|
|
2166
|
+
tick: categoryTick("middle"),
|
|
2167
|
+
...flushCategoryXAxisProps
|
|
2168
|
+
}
|
|
2169
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts.XAxis, { dataKey: xKey, hide: true }),
|
|
2170
|
+
showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2171
|
+
import_recharts.YAxis,
|
|
2172
|
+
{
|
|
2173
|
+
tickLine: false,
|
|
2174
|
+
axisLine: false,
|
|
2175
|
+
tickMargin: 8,
|
|
2176
|
+
width: 44,
|
|
2177
|
+
tickFormatter: (v) => valueFmt(v),
|
|
2178
|
+
domain: yDomain
|
|
2179
|
+
}
|
|
2180
|
+
) : null,
|
|
2181
|
+
tooltipEl,
|
|
2182
|
+
legendEl,
|
|
2183
|
+
bars
|
|
2184
|
+
]
|
|
2185
|
+
}
|
|
2186
|
+
) });
|
|
2187
|
+
}
|
|
2188
|
+
const lineAreaAxes = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
2189
|
+
showXAxis && useIndexX ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2190
|
+
import_recharts.XAxis,
|
|
2191
|
+
{
|
|
2192
|
+
type: "number",
|
|
2193
|
+
dataKey: INDEX_X_KEY,
|
|
2194
|
+
domain: [0, Math.max(0, chartData.length - 1)],
|
|
2195
|
+
allowDecimals: false,
|
|
2196
|
+
ticks: chartData.map((_, i) => i),
|
|
2197
|
+
tickLine: false,
|
|
2198
|
+
axisLine: false,
|
|
2199
|
+
tickMargin: 8,
|
|
2200
|
+
tickFormatter: (i) => {
|
|
2201
|
+
const row = chartData[Number(i)];
|
|
2202
|
+
return row ? xFmt(row[xKey], Number(i)) : "";
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
) : showXAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2206
|
+
import_recharts.XAxis,
|
|
2207
|
+
{
|
|
2208
|
+
dataKey: xKey,
|
|
2209
|
+
tickLine: false,
|
|
2210
|
+
axisLine: false,
|
|
2211
|
+
tickMargin: 8,
|
|
2212
|
+
minTickGap: flush ? 8 : 24,
|
|
2213
|
+
tickFormatter: (v, i) => xFmt(v, i),
|
|
2214
|
+
...flushCategoryXAxisProps
|
|
2215
|
+
}
|
|
2216
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts.XAxis, { dataKey: chartXKey, hide: true }),
|
|
2217
|
+
showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2218
|
+
import_recharts.YAxis,
|
|
2219
|
+
{
|
|
2220
|
+
tickLine: false,
|
|
2221
|
+
axisLine: false,
|
|
2222
|
+
tickMargin: 8,
|
|
2223
|
+
width: 44,
|
|
2224
|
+
tickFormatter: (v) => valueFmt(v),
|
|
2225
|
+
domain: yDomain
|
|
2226
|
+
}
|
|
2227
|
+
) : null
|
|
2228
|
+
] });
|
|
2229
|
+
const chartA11y = flush ? {} : { accessibilityLayer: true };
|
|
2230
|
+
if (variant === "area") {
|
|
2231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2232
|
+
ChartShell,
|
|
2233
|
+
{
|
|
2234
|
+
config,
|
|
2235
|
+
height,
|
|
2236
|
+
className,
|
|
2237
|
+
ariaLabel,
|
|
2238
|
+
flush,
|
|
2239
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_recharts.AreaChart, { ...chartA11y, data: chartData, margin, children: [
|
|
2240
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("defs", { children: series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("linearGradient", { id: `fill-${s.dataKey}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
2241
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("stop", { offset: "5%", stopColor: `var(--color-${s.dataKey})`, stopOpacity: 0.3 }),
|
|
2242
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("stop", { offset: "95%", stopColor: `var(--color-${s.dataKey})`, stopOpacity: 0.04 })
|
|
2243
|
+
] }, s.dataKey)) }),
|
|
2244
|
+
gridEl,
|
|
2245
|
+
lineAreaAxes,
|
|
2246
|
+
tooltipEl,
|
|
2247
|
+
legendEl,
|
|
2248
|
+
series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2249
|
+
import_recharts.Area,
|
|
2250
|
+
{
|
|
2251
|
+
dataKey: s.dataKey,
|
|
2252
|
+
type: curve,
|
|
2253
|
+
stackId: stacked ? "stack" : void 0,
|
|
2254
|
+
stroke: `var(--color-${s.dataKey})`,
|
|
2255
|
+
strokeWidth: 2,
|
|
2256
|
+
fill: `url(#fill-${s.dataKey})`,
|
|
2257
|
+
dot: dots === true ? { r: 3 } : false,
|
|
2258
|
+
activeDot: { r: 4 },
|
|
2259
|
+
isAnimationActive: true
|
|
2260
|
+
},
|
|
2261
|
+
s.dataKey
|
|
2262
|
+
))
|
|
2263
|
+
] })
|
|
1721
2264
|
}
|
|
2265
|
+
);
|
|
2266
|
+
}
|
|
2267
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2268
|
+
ChartShell,
|
|
2269
|
+
{
|
|
2270
|
+
config,
|
|
2271
|
+
height,
|
|
2272
|
+
className,
|
|
2273
|
+
ariaLabel,
|
|
2274
|
+
flush,
|
|
2275
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_recharts.LineChart, { ...chartA11y, data: chartData, margin, children: [
|
|
2276
|
+
gridEl,
|
|
2277
|
+
lineAreaAxes,
|
|
2278
|
+
tooltipEl,
|
|
2279
|
+
legendEl,
|
|
2280
|
+
series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2281
|
+
import_recharts.Line,
|
|
2282
|
+
{
|
|
2283
|
+
dataKey: s.dataKey,
|
|
2284
|
+
type: curve,
|
|
2285
|
+
stroke: `var(--color-${s.dataKey})`,
|
|
2286
|
+
strokeWidth: 2,
|
|
2287
|
+
dot: dots === true ? { r: 3 } : false,
|
|
2288
|
+
activeDot: { r: 4 },
|
|
2289
|
+
isAnimationActive: true
|
|
2290
|
+
},
|
|
2291
|
+
s.dataKey
|
|
2292
|
+
))
|
|
2293
|
+
] })
|
|
1722
2294
|
}
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
2295
|
+
);
|
|
2296
|
+
};
|
|
2297
|
+
var ChartShell = ({ config, height, className, ariaLabel, flush = false, children }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2298
|
+
ChartContainer,
|
|
2299
|
+
{
|
|
2300
|
+
config,
|
|
2301
|
+
role: "img",
|
|
2302
|
+
"aria-label": ariaLabel,
|
|
2303
|
+
className: cn(
|
|
2304
|
+
"aspect-auto w-full",
|
|
2305
|
+
flush && "justify-start [&_.recharts-responsive-container]:!mx-0 [&_.recharts-responsive-container]:w-full",
|
|
2306
|
+
className
|
|
2307
|
+
),
|
|
2308
|
+
style: { height },
|
|
2309
|
+
children
|
|
2310
|
+
}
|
|
2311
|
+
);
|
|
2312
|
+
var ChartEmpty = ({
|
|
2313
|
+
className,
|
|
2314
|
+
height,
|
|
2315
|
+
ariaLabel
|
|
2316
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2317
|
+
"div",
|
|
2318
|
+
{
|
|
2319
|
+
className: cn(
|
|
2320
|
+
"flex w-full items-center justify-center text-xs text-muted-foreground",
|
|
2321
|
+
className
|
|
2322
|
+
),
|
|
2323
|
+
style: { height },
|
|
2324
|
+
role: "img",
|
|
2325
|
+
"aria-label": ariaLabel,
|
|
2326
|
+
children: "No data yet"
|
|
2327
|
+
}
|
|
2328
|
+
);
|
|
2329
|
+
function barCornerRadius(r, horizontal, stacked) {
|
|
2330
|
+
if (stacked) return r;
|
|
2331
|
+
return horizontal ? [0, r, r, 0] : [r, r, 0, 0];
|
|
2332
|
+
}
|
|
2333
|
+
function inferXKey(data) {
|
|
2334
|
+
if (data.length === 0) return "x";
|
|
2335
|
+
for (const k of Object.keys(data[0])) {
|
|
2336
|
+
if (typeof data[0][k] !== "number") return k;
|
|
2337
|
+
}
|
|
2338
|
+
return Object.keys(data[0])[0] ?? "x";
|
|
2339
|
+
}
|
|
2340
|
+
function resolveSeries(seriesProp, data, xKey) {
|
|
2341
|
+
if (seriesProp && seriesProp.length > 0) {
|
|
2342
|
+
return seriesProp.map((s) => typeof s === "string" ? { dataKey: s } : s);
|
|
2343
|
+
}
|
|
2344
|
+
if (data.length === 0) return [];
|
|
2345
|
+
return Object.keys(data[0]).filter((k) => k !== xKey && typeof data[0][k] === "number").map((dataKey) => ({ dataKey }));
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
// src/charts/pie-chart.tsx
|
|
2349
|
+
var import_react8 = require("react");
|
|
2350
|
+
var import_recharts2 = require("recharts");
|
|
2351
|
+
|
|
2352
|
+
// src/charts/chart-center-label.tsx
|
|
2353
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2354
|
+
var CENTER_BOX_W = 96;
|
|
2355
|
+
var CENTER_BOX_H = 52;
|
|
2356
|
+
var ChartCenterLabel = ({ cx, cy, value, label }) => {
|
|
2357
|
+
const hasValue = value != null && value !== "";
|
|
2358
|
+
const hasLabel = label != null && label !== "";
|
|
2359
|
+
if (!hasValue && !hasLabel) return null;
|
|
2360
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2361
|
+
"foreignObject",
|
|
2362
|
+
{
|
|
2363
|
+
x: cx - CENTER_BOX_W / 2,
|
|
2364
|
+
y: cy - CENTER_BOX_H / 2,
|
|
2365
|
+
width: CENTER_BOX_W,
|
|
2366
|
+
height: CENTER_BOX_H,
|
|
2367
|
+
className: "overflow-visible",
|
|
2368
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "pointer-events-none flex h-full flex-col items-center justify-center gap-0.5 text-center", children: [
|
|
2369
|
+
hasValue ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-2xl font-normal leading-none tabular-nums text-foreground", children: value }) : null,
|
|
2370
|
+
hasLabel ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "text-[11px] leading-none text-muted-foreground", children: label }) : null
|
|
2371
|
+
] })
|
|
2372
|
+
}
|
|
2373
|
+
);
|
|
2374
|
+
};
|
|
2375
|
+
|
|
2376
|
+
// src/charts/pie-chart.tsx
|
|
2377
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2378
|
+
var PieChart = ({
|
|
2379
|
+
data,
|
|
2380
|
+
nameKey: nameKeyProp,
|
|
2381
|
+
dataKey = "value",
|
|
2382
|
+
innerRadius = 0,
|
|
2383
|
+
colors,
|
|
2384
|
+
height = 260,
|
|
2385
|
+
showLegend = true,
|
|
2386
|
+
showLabels = false,
|
|
2387
|
+
showTooltip = true,
|
|
2388
|
+
tooltipIndicator = "dot",
|
|
2389
|
+
centerValue,
|
|
2390
|
+
centerLabel,
|
|
2391
|
+
className,
|
|
2392
|
+
ariaLabel = "Pie chart"
|
|
2393
|
+
}) => {
|
|
2394
|
+
const gradientScopeId = (0, import_react8.useId)().replace(/:/g, "");
|
|
2395
|
+
const nameKey = nameKeyProp ?? inferNameKey(data, dataKey);
|
|
2396
|
+
const palette = colors ?? CHART_PALETTE;
|
|
2397
|
+
if (data.length === 0) {
|
|
2398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(PieEmpty, { className, height, ariaLabel });
|
|
2399
|
+
}
|
|
2400
|
+
const slices = data.map((d, i) => ({
|
|
2401
|
+
name: String(d[nameKey] ?? i),
|
|
2402
|
+
value: toNum(d[dataKey]),
|
|
2403
|
+
fill: palette[i % palette.length]
|
|
2404
|
+
}));
|
|
2405
|
+
const config = {};
|
|
2406
|
+
for (const s of slices) config[s.name] = { label: s.name };
|
|
2407
|
+
const innerPct = innerRadius > 0 ? `${Math.round(innerRadius * 75)}%` : 0;
|
|
2408
|
+
const hasCenter = innerRadius > 0 && (centerValue != null || centerLabel != null);
|
|
2409
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2410
|
+
ChartContainer,
|
|
2411
|
+
{
|
|
2412
|
+
config,
|
|
2413
|
+
role: "img",
|
|
2414
|
+
"aria-label": ariaLabel,
|
|
2415
|
+
className: cn("aspect-auto w-full", className),
|
|
2416
|
+
style: { height },
|
|
2417
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_recharts2.PieChart, { children: [
|
|
2418
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2419
|
+
PieGradientDefs,
|
|
2420
|
+
{
|
|
2421
|
+
scopeId: gradientScopeId,
|
|
2422
|
+
slices: slices.map((s) => ({ key: s.name, color: s.fill }))
|
|
2423
|
+
}
|
|
2424
|
+
),
|
|
2425
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2426
|
+
ChartTooltip,
|
|
2427
|
+
{
|
|
2428
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChartTooltipContent, { nameKey: "name", indicator: tooltipIndicator, hideLabel: true })
|
|
2429
|
+
}
|
|
2430
|
+
),
|
|
2431
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2432
|
+
import_recharts2.Pie,
|
|
2433
|
+
{
|
|
2434
|
+
data: slices,
|
|
2435
|
+
dataKey: "value",
|
|
2436
|
+
nameKey: "name",
|
|
2437
|
+
innerRadius: innerPct,
|
|
2438
|
+
outerRadius: "75%",
|
|
2439
|
+
paddingAngle: innerRadius > 0 ? 2 : 0,
|
|
2440
|
+
strokeWidth: 2,
|
|
2441
|
+
label: showLabels,
|
|
2442
|
+
isAnimationActive: true,
|
|
2443
|
+
children: [
|
|
2444
|
+
slices.map((s) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_recharts2.Cell, { fill: `url(#${pieGradientId(gradientScopeId, s.name)})` }, s.name)),
|
|
2445
|
+
hasCenter && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2446
|
+
import_recharts2.Label,
|
|
2447
|
+
{
|
|
2448
|
+
position: "center",
|
|
2449
|
+
content: ({ viewBox }) => {
|
|
2450
|
+
if (!viewBox || !("cx" in viewBox)) return null;
|
|
2451
|
+
const { cx, cy } = viewBox;
|
|
2452
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2453
|
+
ChartCenterLabel,
|
|
2454
|
+
{
|
|
2455
|
+
cx,
|
|
2456
|
+
cy,
|
|
2457
|
+
value: centerValue,
|
|
2458
|
+
label: centerLabel
|
|
2459
|
+
}
|
|
2460
|
+
);
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
)
|
|
2464
|
+
]
|
|
2465
|
+
}
|
|
2466
|
+
),
|
|
2467
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChartLegend, { content: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChartLegendContent, { nameKey: "name" }) })
|
|
2468
|
+
] })
|
|
2469
|
+
}
|
|
2470
|
+
);
|
|
2471
|
+
};
|
|
2472
|
+
var PieEmpty = ({
|
|
2473
|
+
className,
|
|
2474
|
+
height,
|
|
2475
|
+
ariaLabel
|
|
2476
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2477
|
+
"div",
|
|
2478
|
+
{
|
|
2479
|
+
className: cn("flex w-full items-center justify-center text-xs text-muted-foreground", className),
|
|
2480
|
+
style: { height },
|
|
2481
|
+
role: "img",
|
|
2482
|
+
"aria-label": ariaLabel,
|
|
2483
|
+
children: "No data yet"
|
|
2484
|
+
}
|
|
2485
|
+
);
|
|
2486
|
+
function inferNameKey(data, dataKey) {
|
|
2487
|
+
if (data.length === 0) return "name";
|
|
2488
|
+
for (const k of Object.keys(data[0])) {
|
|
2489
|
+
if (k !== dataKey && typeof data[0][k] !== "number") return k;
|
|
2490
|
+
}
|
|
2491
|
+
return Object.keys(data[0]).find((k) => k !== dataKey) ?? "name";
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
// src/charts/radial-chart.tsx
|
|
2495
|
+
var import_react9 = require("react");
|
|
2496
|
+
var import_recharts3 = require("recharts");
|
|
2497
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2498
|
+
var RadialChart = ({
|
|
2499
|
+
data,
|
|
2500
|
+
nameKey: nameKeyProp,
|
|
2501
|
+
dataKey = "value",
|
|
2502
|
+
maxValue,
|
|
2503
|
+
colors,
|
|
2504
|
+
height = 260,
|
|
2505
|
+
ringWidth = 16,
|
|
2506
|
+
ringGap = 4,
|
|
2507
|
+
showLegend = true,
|
|
2508
|
+
centerValue,
|
|
2509
|
+
centerLabel,
|
|
2510
|
+
className,
|
|
2511
|
+
ariaLabel = "Radial chart"
|
|
2512
|
+
}) => {
|
|
2513
|
+
const gradientScopeId = (0, import_react9.useId)().replace(/:/g, "");
|
|
2514
|
+
const nameKey = nameKeyProp ?? inferNameKey2(data, dataKey);
|
|
2515
|
+
const palette = colors ?? CHART_PALETTE;
|
|
2516
|
+
if (data.length === 0) {
|
|
2517
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(RadialEmpty, { className, height, ariaLabel });
|
|
1729
2518
|
}
|
|
1730
|
-
const
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
const
|
|
1736
|
-
const
|
|
1737
|
-
const
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
};
|
|
1743
|
-
const labelIdx = pickXLabels(xCount, innerW);
|
|
1744
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { ref, className: cn("relative w-full", className), style: { height }, children: [
|
|
1745
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1746
|
-
"svg",
|
|
2519
|
+
const rows = data.map((d, i) => ({
|
|
2520
|
+
name: String(d[nameKey] ?? i),
|
|
2521
|
+
value: toNum(d[dataKey]),
|
|
2522
|
+
fill: palette[i % palette.length]
|
|
2523
|
+
}));
|
|
2524
|
+
const max = maxValue ?? Math.max(...rows.map((r) => r.value), 1);
|
|
2525
|
+
const config = {};
|
|
2526
|
+
for (const r of rows) config[r.name] = { label: r.name };
|
|
2527
|
+
const hasCenter = centerValue != null || centerLabel != null;
|
|
2528
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: cn("flex w-full flex-col items-center gap-3", className), children: [
|
|
2529
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2530
|
+
ChartContainer,
|
|
1747
2531
|
{
|
|
1748
|
-
|
|
1749
|
-
height,
|
|
2532
|
+
config,
|
|
1750
2533
|
role: "img",
|
|
1751
2534
|
"aria-label": ariaLabel,
|
|
1752
|
-
className: "
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "8%", stopColor: "white", stopOpacity: 1 }),
|
|
1768
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "92%", stopColor: "white", stopOpacity: 1 }),
|
|
1769
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "100%", stopColor: "white", stopOpacity: 0 })
|
|
1770
|
-
] }),
|
|
1771
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("mask", { id: `${uid}-gridmask`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1772
|
-
"rect",
|
|
1773
|
-
{
|
|
1774
|
-
x: pad.left,
|
|
1775
|
-
y: pad.top,
|
|
1776
|
-
width: innerW,
|
|
1777
|
-
height: innerH,
|
|
1778
|
-
fill: `url(#${uid}-gridfade)`
|
|
1779
|
-
}
|
|
1780
|
-
) }),
|
|
1781
|
-
series.map((s, i) => {
|
|
1782
|
-
const color = s.color ?? CHART_PALETTE[i % CHART_PALETTE.length];
|
|
1783
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1784
|
-
"linearGradient",
|
|
1785
|
-
{
|
|
1786
|
-
id: `${uid}-fill-${i}`,
|
|
1787
|
-
x1: "0",
|
|
1788
|
-
x2: "0",
|
|
1789
|
-
y1: "0",
|
|
1790
|
-
y2: "1",
|
|
1791
|
-
children: [
|
|
1792
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "0%", style: { stopColor: color, stopOpacity: 0.28 } }),
|
|
1793
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "100%", style: { stopColor: color, stopOpacity: 0 } })
|
|
1794
|
-
]
|
|
1795
|
-
},
|
|
1796
|
-
s.dataKey
|
|
1797
|
-
);
|
|
1798
|
-
})
|
|
1799
|
-
] }),
|
|
1800
|
-
showGrid && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("g", { mask: `url(#${uid}-gridmask)`, children: ticks.map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1801
|
-
"line",
|
|
1802
|
-
{
|
|
1803
|
-
x1: pad.left,
|
|
1804
|
-
x2: width - pad.right,
|
|
1805
|
-
y1: yScale(t),
|
|
1806
|
-
y2: yScale(t),
|
|
1807
|
-
stroke: "currentColor",
|
|
1808
|
-
strokeOpacity: 0.14,
|
|
1809
|
-
strokeDasharray: "4 4",
|
|
1810
|
-
className: "text-muted-foreground"
|
|
1811
|
-
},
|
|
1812
|
-
i
|
|
1813
|
-
)) }),
|
|
1814
|
-
showYAxis && ticks.map((t, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1815
|
-
"text",
|
|
1816
|
-
{
|
|
1817
|
-
x: pad.left - 8,
|
|
1818
|
-
y: yScale(t),
|
|
1819
|
-
textAnchor: "end",
|
|
1820
|
-
dominantBaseline: "middle",
|
|
1821
|
-
className: "fill-muted-foreground text-[10px] tabular-nums",
|
|
1822
|
-
children: fmtV(t)
|
|
1823
|
-
},
|
|
1824
|
-
i
|
|
1825
|
-
)),
|
|
1826
|
-
showXAxis && labelIdx.map((i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1827
|
-
"text",
|
|
1828
|
-
{
|
|
1829
|
-
x: xPos(i),
|
|
1830
|
-
y: height - pad.bottom + 16,
|
|
1831
|
-
textAnchor: i === 0 ? "start" : i === xCount - 1 ? "end" : "middle",
|
|
1832
|
-
className: "fill-muted-foreground text-[10px] tabular-nums",
|
|
1833
|
-
children: fmtX(i)
|
|
1834
|
-
},
|
|
1835
|
-
i
|
|
1836
|
-
)),
|
|
1837
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("g", { clipPath: `url(#${uid}-grow)`, children: variant === "bar" ? renderBars({ data, series, xCount, xPos, yScale, baseY, innerW, uid }) : series.map((s, si) => {
|
|
1838
|
-
const color = s.color ?? CHART_PALETTE[si % CHART_PALETTE.length];
|
|
1839
|
-
const pts = data.map((d, i) => ({
|
|
1840
|
-
x: xPos(i),
|
|
1841
|
-
y: yScale(toNum(d[s.dataKey]))
|
|
1842
|
-
}));
|
|
1843
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("g", { children: [
|
|
1844
|
-
variant === "area" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("path", { d: monotoneAreaPath(pts, baseY), fill: `url(#${uid}-fill-${si})` }),
|
|
1845
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1846
|
-
"path",
|
|
2535
|
+
className: "aspect-auto w-full",
|
|
2536
|
+
style: { height: height - (showLegend ? 32 : 0) },
|
|
2537
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2538
|
+
import_recharts3.RadialBarChart,
|
|
2539
|
+
{
|
|
2540
|
+
data: rows,
|
|
2541
|
+
startAngle: 90,
|
|
2542
|
+
endAngle: -270,
|
|
2543
|
+
innerRadius: "30%",
|
|
2544
|
+
outerRadius: "100%",
|
|
2545
|
+
barSize: ringWidth,
|
|
2546
|
+
barGap: ringGap,
|
|
2547
|
+
children: [
|
|
2548
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2549
|
+
PieGradientDefs,
|
|
1847
2550
|
{
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
stroke: color,
|
|
1851
|
-
strokeWidth: 2,
|
|
1852
|
-
strokeLinecap: "round",
|
|
1853
|
-
strokeLinejoin: "round"
|
|
2551
|
+
scopeId: gradientScopeId,
|
|
2552
|
+
slices: rows.map((r) => ({ key: r.name, color: r.fill }))
|
|
1854
2553
|
}
|
|
1855
|
-
)
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
{
|
|
1862
|
-
x1: xPos(active),
|
|
1863
|
-
x2: xPos(active),
|
|
1864
|
-
y1: pad.top,
|
|
1865
|
-
y2: pad.top + innerH,
|
|
1866
|
-
stroke: "currentColor",
|
|
1867
|
-
strokeOpacity: 0.25,
|
|
1868
|
-
className: "text-foreground"
|
|
1869
|
-
}
|
|
1870
|
-
),
|
|
1871
|
-
series.map((s, si) => {
|
|
1872
|
-
const color = s.color ?? CHART_PALETTE[si % CHART_PALETTE.length];
|
|
1873
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1874
|
-
"circle",
|
|
2554
|
+
),
|
|
2555
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_recharts3.PolarAngleAxis, { type: "number", domain: [0, max], tick: false, axisLine: false }),
|
|
2556
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChartTooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChartTooltipContent, { nameKey: "name", hideLabel: true }) }),
|
|
2557
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_recharts3.RadialBar, { dataKey: "value", background: true, cornerRadius: ringWidth / 2, isAnimationActive: true, children: rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_recharts3.Cell, { fill: `url(#${pieGradientId(gradientScopeId, r.name)})` }, r.name)) }),
|
|
2558
|
+
hasCenter && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_recharts3.PolarRadiusAxis, { tick: false, tickLine: false, axisLine: false, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2559
|
+
import_recharts3.Label,
|
|
1875
2560
|
{
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
style: { cursor: "crosshair" },
|
|
1896
|
-
onMouseMove: onMove,
|
|
1897
|
-
onMouseLeave: () => setActive(null)
|
|
1898
|
-
}
|
|
1899
|
-
)
|
|
1900
|
-
]
|
|
1901
|
-
}
|
|
1902
|
-
),
|
|
1903
|
-
showTooltip && active != null && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1904
|
-
ChartTooltip,
|
|
1905
|
-
{
|
|
1906
|
-
x: xPos(active),
|
|
1907
|
-
width,
|
|
1908
|
-
title: fmtX(active),
|
|
1909
|
-
rows: series.map((s, si) => ({
|
|
1910
|
-
color: s.color ?? CHART_PALETTE[si % CHART_PALETTE.length],
|
|
1911
|
-
label: s.label ?? s.dataKey,
|
|
1912
|
-
value: fmtV(toNum(data[active]?.[s.dataKey]))
|
|
1913
|
-
}))
|
|
2561
|
+
position: "center",
|
|
2562
|
+
content: ({ viewBox }) => {
|
|
2563
|
+
if (!viewBox || !("cx" in viewBox)) return null;
|
|
2564
|
+
const { cx, cy } = viewBox;
|
|
2565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2566
|
+
ChartCenterLabel,
|
|
2567
|
+
{
|
|
2568
|
+
cx,
|
|
2569
|
+
cy,
|
|
2570
|
+
value: centerValue,
|
|
2571
|
+
label: centerLabel
|
|
2572
|
+
}
|
|
2573
|
+
);
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
) })
|
|
2577
|
+
]
|
|
2578
|
+
}
|
|
2579
|
+
)
|
|
1914
2580
|
}
|
|
1915
2581
|
),
|
|
1916
|
-
showLegend
|
|
2582
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
2583
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "inline-block size-2.5 rounded-[3px]", style: { background: r.fill } }),
|
|
2584
|
+
r.name
|
|
2585
|
+
] }, r.name)) })
|
|
1917
2586
|
] });
|
|
1918
2587
|
};
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
(s, si) => data.map((d, i) => {
|
|
1925
|
-
const color = s.color ?? CHART_PALETTE[si % CHART_PALETTE.length];
|
|
1926
|
-
const y = yScale(toNum(d[s.dataKey]));
|
|
1927
|
-
const x = xPos(i) - groupWidth / 2 + si * barWidth;
|
|
1928
|
-
const top = Math.min(y, baseY);
|
|
1929
|
-
const h = Math.max(1, Math.abs(y - baseY));
|
|
1930
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1931
|
-
"rect",
|
|
1932
|
-
{
|
|
1933
|
-
x,
|
|
1934
|
-
y: top,
|
|
1935
|
-
width: Math.max(1, barWidth - 2),
|
|
1936
|
-
height: h,
|
|
1937
|
-
rx: 3,
|
|
1938
|
-
fill: color
|
|
1939
|
-
},
|
|
1940
|
-
`${s.dataKey}-${i}`
|
|
1941
|
-
);
|
|
1942
|
-
})
|
|
1943
|
-
);
|
|
1944
|
-
}
|
|
1945
|
-
var ChartTooltip = ({ x, width, title, rows }) => {
|
|
1946
|
-
const flip = x > width - 160;
|
|
1947
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1948
|
-
"div",
|
|
1949
|
-
{
|
|
1950
|
-
className: "pointer-events-none absolute top-2 z-10 min-w-[8rem] rounded-lg border border-border bg-popover/95 px-2.5 py-2 text-popover-foreground shadow-card-elevated backdrop-blur-sm",
|
|
1951
|
-
style: {
|
|
1952
|
-
left: flip ? void 0 : Math.min(x + 12, width - 8),
|
|
1953
|
-
right: flip ? Math.max(width - x + 12, 8) : void 0
|
|
1954
|
-
},
|
|
1955
|
-
children: [
|
|
1956
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mb-1.5 text-[11px] text-muted-foreground", children: title }),
|
|
1957
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-col gap-1", children: rows.map((r) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
|
|
1958
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground", children: [
|
|
1959
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1960
|
-
"span",
|
|
1961
|
-
{
|
|
1962
|
-
className: "inline-block size-2 rounded-full",
|
|
1963
|
-
style: { background: r.color }
|
|
1964
|
-
}
|
|
1965
|
-
),
|
|
1966
|
-
r.label
|
|
1967
|
-
] }),
|
|
1968
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xs font-medium tabular-nums text-foreground", children: r.value })
|
|
1969
|
-
] }, r.label)) })
|
|
1970
|
-
]
|
|
1971
|
-
}
|
|
1972
|
-
);
|
|
1973
|
-
};
|
|
1974
|
-
var ChartLegend = ({ series }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 pl-10 text-xs text-muted-foreground", children: series.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
1975
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1976
|
-
"span",
|
|
1977
|
-
{
|
|
1978
|
-
className: "inline-block size-2 rounded-sm",
|
|
1979
|
-
style: { background: s.color ?? CHART_PALETTE[i % CHART_PALETTE.length] }
|
|
1980
|
-
}
|
|
1981
|
-
),
|
|
1982
|
-
s.label ?? s.dataKey
|
|
1983
|
-
] }, s.dataKey)) });
|
|
1984
|
-
var ChartEmpty = ({ className, height }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2588
|
+
var RadialEmpty = ({
|
|
2589
|
+
className,
|
|
2590
|
+
height,
|
|
2591
|
+
ariaLabel
|
|
2592
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1985
2593
|
"div",
|
|
1986
2594
|
{
|
|
1987
|
-
className: cn(
|
|
1988
|
-
"flex w-full items-center justify-center text-xs text-muted-foreground",
|
|
1989
|
-
className
|
|
1990
|
-
),
|
|
2595
|
+
className: cn("flex w-full items-center justify-center text-xs text-muted-foreground", className),
|
|
1991
2596
|
style: { height },
|
|
2597
|
+
role: "img",
|
|
2598
|
+
"aria-label": ariaLabel,
|
|
1992
2599
|
children: "No data yet"
|
|
1993
2600
|
}
|
|
1994
2601
|
);
|
|
1995
|
-
function
|
|
1996
|
-
if (data.length === 0) return "
|
|
2602
|
+
function inferNameKey2(data, dataKey) {
|
|
2603
|
+
if (data.length === 0) return "name";
|
|
2604
|
+
for (const k of Object.keys(data[0])) {
|
|
2605
|
+
if (k !== dataKey && typeof data[0][k] !== "number") return k;
|
|
2606
|
+
}
|
|
2607
|
+
return Object.keys(data[0]).find((k) => k !== dataKey) ?? "name";
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2610
|
+
// src/charts/radar-chart.tsx
|
|
2611
|
+
var import_recharts4 = require("recharts");
|
|
2612
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2613
|
+
var RadarChart = ({
|
|
2614
|
+
data,
|
|
2615
|
+
nameKey: nameKeyProp,
|
|
2616
|
+
series: seriesProp,
|
|
2617
|
+
maxValue,
|
|
2618
|
+
height = 280,
|
|
2619
|
+
showLegend = true,
|
|
2620
|
+
fill = true,
|
|
2621
|
+
className,
|
|
2622
|
+
ariaLabel = "Radar chart"
|
|
2623
|
+
}) => {
|
|
2624
|
+
const nameKey = nameKeyProp ?? inferNameKey3(data);
|
|
2625
|
+
const series = resolveSeries2(seriesProp, data, nameKey);
|
|
2626
|
+
if (data.length < 3 || series.length === 0) {
|
|
2627
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2628
|
+
"div",
|
|
2629
|
+
{
|
|
2630
|
+
className: cn("flex items-center justify-center text-xs text-muted-foreground", className),
|
|
2631
|
+
style: { height },
|
|
2632
|
+
role: "img",
|
|
2633
|
+
"aria-label": ariaLabel,
|
|
2634
|
+
children: "Radar needs at least 3 axes"
|
|
2635
|
+
}
|
|
2636
|
+
);
|
|
2637
|
+
}
|
|
2638
|
+
const config = {};
|
|
2639
|
+
series.forEach((s, i) => {
|
|
2640
|
+
config[s.dataKey] = {
|
|
2641
|
+
label: s.label ?? s.dataKey,
|
|
2642
|
+
color: s.color ?? CHART_PALETTE[i % CHART_PALETTE.length]
|
|
2643
|
+
};
|
|
2644
|
+
});
|
|
2645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2646
|
+
ChartContainer,
|
|
2647
|
+
{
|
|
2648
|
+
config,
|
|
2649
|
+
role: "img",
|
|
2650
|
+
"aria-label": ariaLabel,
|
|
2651
|
+
className: cn("mx-auto aspect-square", className),
|
|
2652
|
+
style: { height },
|
|
2653
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_recharts4.RadarChart, { data, outerRadius: "70%", children: [
|
|
2654
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartTooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartTooltipContent, { indicator: "line" }) }),
|
|
2655
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_recharts4.PolarGrid, {}),
|
|
2656
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2657
|
+
import_recharts4.PolarAngleAxis,
|
|
2658
|
+
{
|
|
2659
|
+
dataKey: nameKey,
|
|
2660
|
+
tick: { fontSize: 10, fill: "var(--color-muted-foreground)" }
|
|
2661
|
+
}
|
|
2662
|
+
),
|
|
2663
|
+
series.map((s) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2664
|
+
import_recharts4.Radar,
|
|
2665
|
+
{
|
|
2666
|
+
dataKey: s.dataKey,
|
|
2667
|
+
stroke: `var(--color-${s.dataKey})`,
|
|
2668
|
+
fill: `var(--color-${s.dataKey})`,
|
|
2669
|
+
fillOpacity: fill ? 0.18 : 0,
|
|
2670
|
+
strokeWidth: 2,
|
|
2671
|
+
dot: { r: 2.5, fillOpacity: 1 },
|
|
2672
|
+
isAnimationActive: true
|
|
2673
|
+
},
|
|
2674
|
+
s.dataKey
|
|
2675
|
+
)),
|
|
2676
|
+
showLegend && series.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartLegend, { content: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartLegendContent, {}) })
|
|
2677
|
+
] })
|
|
2678
|
+
}
|
|
2679
|
+
);
|
|
2680
|
+
};
|
|
2681
|
+
function inferNameKey3(data) {
|
|
2682
|
+
if (data.length === 0) return "name";
|
|
1997
2683
|
for (const k of Object.keys(data[0])) {
|
|
1998
2684
|
if (typeof data[0][k] !== "number") return k;
|
|
1999
2685
|
}
|
|
2000
|
-
return Object.keys(data[0])[0] ?? "
|
|
2686
|
+
return Object.keys(data[0])[0] ?? "name";
|
|
2001
2687
|
}
|
|
2002
|
-
function
|
|
2688
|
+
function resolveSeries2(seriesProp, data, nameKey) {
|
|
2003
2689
|
if (seriesProp && seriesProp.length > 0) {
|
|
2004
2690
|
return seriesProp.map((s) => typeof s === "string" ? { dataKey: s } : s);
|
|
2005
2691
|
}
|
|
2006
2692
|
if (data.length === 0) return [];
|
|
2007
|
-
return Object.keys(data[0]).filter((k) => k !==
|
|
2008
|
-
}
|
|
2009
|
-
function pickXLabels(count, innerW) {
|
|
2010
|
-
if (count <= 1) return [0];
|
|
2011
|
-
const maxLabels = Math.max(2, Math.min(count, Math.floor(innerW / 64) + 1));
|
|
2012
|
-
if (maxLabels >= count) return Array.from({ length: count }, (_, i) => i);
|
|
2013
|
-
const out = /* @__PURE__ */ new Set([0, count - 1]);
|
|
2014
|
-
const step = (count - 1) / (maxLabels - 1);
|
|
2015
|
-
for (let i = 1; i < maxLabels - 1; i++) out.add(Math.round(i * step));
|
|
2016
|
-
return [...out].sort((a, b) => a - b);
|
|
2693
|
+
return Object.keys(data[0]).filter((k) => k !== nameKey && typeof data[0][k] === "number").map((dataKey) => ({ dataKey }));
|
|
2017
2694
|
}
|
|
2018
2695
|
|
|
2019
2696
|
// src/artifacts/artifact-card.tsx
|
|
2020
|
-
var
|
|
2697
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2021
2698
|
var ArtifactCard = ({ title, kind, className, bodyClassName, toolbar, children }) => {
|
|
2022
2699
|
const hasHeader = Boolean(title || toolbar);
|
|
2023
|
-
return /* @__PURE__ */ (0,
|
|
2700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2024
2701
|
"div",
|
|
2025
2702
|
{
|
|
2026
2703
|
className: cn(
|
|
@@ -2029,29 +2706,29 @@ var ArtifactCard = ({ title, kind, className, bodyClassName, toolbar, children }
|
|
|
2029
2706
|
),
|
|
2030
2707
|
"data-artifact-kind": kind,
|
|
2031
2708
|
children: [
|
|
2032
|
-
hasHeader && /* @__PURE__ */ (0,
|
|
2033
|
-
title && /* @__PURE__ */ (0,
|
|
2034
|
-
!title && /* @__PURE__ */ (0,
|
|
2709
|
+
hasHeader && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "aui-artifact-header flex items-center gap-2 border-b border-border/40 bg-muted/30 px-3 py-1.5", children: [
|
|
2710
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "aui-artifact-title flex-1 truncate text-xs font-semibold text-foreground/80", children: title }),
|
|
2711
|
+
!title && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "flex-1" }),
|
|
2035
2712
|
toolbar
|
|
2036
2713
|
] }),
|
|
2037
|
-
/* @__PURE__ */ (0,
|
|
2714
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: cn("aui-artifact-body", bodyClassName), children })
|
|
2038
2715
|
]
|
|
2039
2716
|
}
|
|
2040
2717
|
);
|
|
2041
2718
|
};
|
|
2042
2719
|
|
|
2043
2720
|
// src/artifacts/chart-artifact.tsx
|
|
2044
|
-
var
|
|
2721
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2045
2722
|
var ChartArtifactView = ({
|
|
2046
2723
|
artifact,
|
|
2047
2724
|
embedded = false,
|
|
2048
2725
|
height = 300
|
|
2049
2726
|
}) => {
|
|
2050
|
-
const plot = /* @__PURE__ */ (0,
|
|
2727
|
+
const plot = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChartArtifactPlot, { artifact, height });
|
|
2051
2728
|
if (embedded) {
|
|
2052
|
-
return /* @__PURE__ */ (0,
|
|
2729
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "aui-artifact-chart w-full", children: plot });
|
|
2053
2730
|
}
|
|
2054
|
-
return /* @__PURE__ */ (0,
|
|
2731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ArtifactCard, { title: artifact.title, kind: "chart", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "aui-artifact-chart pt-2", children: plot }) });
|
|
2055
2732
|
};
|
|
2056
2733
|
function ChartArtifactPlot({
|
|
2057
2734
|
artifact,
|
|
@@ -2059,14 +2736,59 @@ function ChartArtifactPlot({
|
|
|
2059
2736
|
}) {
|
|
2060
2737
|
const { chartType = "bar", data = [] } = artifact;
|
|
2061
2738
|
const xKey = artifact.xKey ?? inferXKey2(data);
|
|
2062
|
-
const series = (0,
|
|
2739
|
+
const series = (0, import_react10.useMemo)(() => {
|
|
2740
|
+
if (artifact.series && artifact.series.length > 0) {
|
|
2741
|
+
return artifact.series.map((s) => ({
|
|
2742
|
+
dataKey: s.dataKey,
|
|
2743
|
+
label: s.label,
|
|
2744
|
+
color: s.color
|
|
2745
|
+
}));
|
|
2746
|
+
}
|
|
2063
2747
|
const keys = Array.isArray(artifact.dataKey) ? artifact.dataKey : typeof artifact.dataKey === "string" ? [artifact.dataKey] : inferDataKeys(data, xKey);
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2748
|
+
const colors = artifact.colors;
|
|
2749
|
+
return keys.map((dataKey, i) => ({
|
|
2750
|
+
dataKey,
|
|
2751
|
+
color: colors?.[i]
|
|
2752
|
+
}));
|
|
2753
|
+
}, [artifact.series, artifact.dataKey, artifact.colors, data, xKey]);
|
|
2754
|
+
const aria = typeof artifact.title === "string" ? artifact.title : "Chart";
|
|
2755
|
+
if (chartType === "pie" || chartType === "donut") {
|
|
2756
|
+
const total = data.reduce((sum, d) => sum + toNum(d[series[0]?.dataKey ?? "value"]), 0);
|
|
2757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2758
|
+
PieChart,
|
|
2759
|
+
{
|
|
2760
|
+
data,
|
|
2761
|
+
nameKey: xKey,
|
|
2762
|
+
dataKey: series[0]?.dataKey ?? "value",
|
|
2763
|
+
innerRadius: chartType === "donut" ? 0.6 : 0,
|
|
2764
|
+
colors: artifact.colors,
|
|
2765
|
+
height,
|
|
2766
|
+
unit: artifact.unit,
|
|
2767
|
+
centerValue: chartType === "donut" ? formatCompact(total, artifact.unit) : void 0,
|
|
2768
|
+
centerLabel: chartType === "donut" ? "Total" : void 0,
|
|
2769
|
+
ariaLabel: aria
|
|
2770
|
+
}
|
|
2771
|
+
) });
|
|
2068
2772
|
}
|
|
2069
|
-
|
|
2773
|
+
if (chartType === "radial") {
|
|
2774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2775
|
+
RadialChart,
|
|
2776
|
+
{
|
|
2777
|
+
data,
|
|
2778
|
+
nameKey: xKey,
|
|
2779
|
+
dataKey: series[0]?.dataKey ?? "value",
|
|
2780
|
+
colors: artifact.colors,
|
|
2781
|
+
height,
|
|
2782
|
+
ariaLabel: aria
|
|
2783
|
+
}
|
|
2784
|
+
) });
|
|
2785
|
+
}
|
|
2786
|
+
if (chartType === "radar") {
|
|
2787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RadarChart, { data, nameKey: xKey, series, height, ariaLabel: aria }) });
|
|
2788
|
+
}
|
|
2789
|
+
const horizontal = chartType === "horizontalBar";
|
|
2790
|
+
const showAxes = artifact.showAxes === true;
|
|
2791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2070
2792
|
LineAreaChart,
|
|
2071
2793
|
{
|
|
2072
2794
|
data,
|
|
@@ -2075,71 +2797,19 @@ function ChartArtifactPlot({
|
|
|
2075
2797
|
layout: "flush",
|
|
2076
2798
|
height,
|
|
2077
2799
|
variant: chartType === "line" ? "line" : chartType === "area" ? "area" : "bar",
|
|
2800
|
+
orientation: horizontal ? "horizontal" : "vertical",
|
|
2801
|
+
stacked: artifact.stacked,
|
|
2802
|
+
curve: artifact.curve,
|
|
2803
|
+
dots: artifact.dots,
|
|
2804
|
+
tooltipIndicator: artifact.tooltipIndicator,
|
|
2805
|
+
showXAxis: showAxes,
|
|
2806
|
+
showYAxis: showAxes && horizontal,
|
|
2807
|
+
showLegend: artifact.legend ?? series.length > 1,
|
|
2078
2808
|
unit: artifact.unit,
|
|
2079
|
-
ariaLabel:
|
|
2809
|
+
ariaLabel: aria
|
|
2080
2810
|
}
|
|
2081
2811
|
);
|
|
2082
2812
|
}
|
|
2083
|
-
var PIE_W = 320;
|
|
2084
|
-
var PIE_H = 220;
|
|
2085
|
-
var PieChart = ({ data, xKey, dataKey }) => {
|
|
2086
|
-
if (data.length === 0) {
|
|
2087
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex h-32 items-center justify-center text-xs text-muted-foreground", children: "No data" });
|
|
2088
|
-
}
|
|
2089
|
-
const cx = PIE_W / 2;
|
|
2090
|
-
const cy = PIE_H / 2;
|
|
2091
|
-
const r = Math.min(PIE_W, PIE_H) / 2 - 16;
|
|
2092
|
-
const total = data.reduce((sum, d) => sum + toNum(d[dataKey]), 0) || 1;
|
|
2093
|
-
let acc = 0;
|
|
2094
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-col items-center gap-3", children: [
|
|
2095
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2096
|
-
"svg",
|
|
2097
|
-
{
|
|
2098
|
-
viewBox: `0 0 ${PIE_W} ${PIE_H}`,
|
|
2099
|
-
className: "w-full max-w-[20rem]",
|
|
2100
|
-
role: "img",
|
|
2101
|
-
"aria-label": "Pie chart",
|
|
2102
|
-
children: data.map((d, i) => {
|
|
2103
|
-
const value = toNum(d[dataKey]);
|
|
2104
|
-
const start = acc / total * Math.PI * 2;
|
|
2105
|
-
acc += value;
|
|
2106
|
-
const end = acc / total * Math.PI * 2;
|
|
2107
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2108
|
-
PieSlice,
|
|
2109
|
-
{
|
|
2110
|
-
cx,
|
|
2111
|
-
cy,
|
|
2112
|
-
r,
|
|
2113
|
-
start,
|
|
2114
|
-
end,
|
|
2115
|
-
color: CHART_PALETTE[i % CHART_PALETTE.length]
|
|
2116
|
-
},
|
|
2117
|
-
i
|
|
2118
|
-
);
|
|
2119
|
-
})
|
|
2120
|
-
}
|
|
2121
|
-
),
|
|
2122
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex flex-wrap items-center justify-center gap-x-3 gap-y-1 text-xs text-muted-foreground", children: data.map((d, i) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
2123
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2124
|
-
"span",
|
|
2125
|
-
{
|
|
2126
|
-
className: "inline-block size-2 rounded-sm",
|
|
2127
|
-
style: { background: CHART_PALETTE[i % CHART_PALETTE.length] }
|
|
2128
|
-
}
|
|
2129
|
-
),
|
|
2130
|
-
String(d[xKey] ?? i)
|
|
2131
|
-
] }, i)) })
|
|
2132
|
-
] });
|
|
2133
|
-
};
|
|
2134
|
-
var PieSlice = ({ cx, cy, r, start, end, color }) => {
|
|
2135
|
-
const x1 = cx + Math.sin(start) * r;
|
|
2136
|
-
const y1 = cy - Math.cos(start) * r;
|
|
2137
|
-
const x2 = cx + Math.sin(end) * r;
|
|
2138
|
-
const y2 = cy - Math.cos(end) * r;
|
|
2139
|
-
const large = end - start > Math.PI ? 1 : 0;
|
|
2140
|
-
const path = `M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${large} 1 ${x2} ${y2} Z`;
|
|
2141
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: path, fill: color, stroke: "var(--background, #fff)", strokeWidth: 1.5 });
|
|
2142
|
-
};
|
|
2143
2813
|
function inferXKey2(data) {
|
|
2144
2814
|
if (data.length === 0) return "x";
|
|
2145
2815
|
for (const k of Object.keys(data[0])) {
|
|
@@ -2155,8 +2825,8 @@ function inferDataKeys(data, xKey) {
|
|
|
2155
2825
|
}
|
|
2156
2826
|
|
|
2157
2827
|
// src/artifacts/question-artifact.tsx
|
|
2158
|
-
var
|
|
2159
|
-
var
|
|
2828
|
+
var import_react11 = require("react");
|
|
2829
|
+
var import_react12 = require("@assistant-ui/react");
|
|
2160
2830
|
var import_lucide_react3 = require("lucide-react");
|
|
2161
2831
|
|
|
2162
2832
|
// src/design/classes.ts
|
|
@@ -2271,12 +2941,12 @@ var studioQuestionOptionSelectedClass = cn(
|
|
|
2271
2941
|
);
|
|
2272
2942
|
|
|
2273
2943
|
// src/artifacts/question-artifact.tsx
|
|
2274
|
-
var
|
|
2944
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2275
2945
|
function optionKey(option, index) {
|
|
2276
2946
|
const id = option.id?.trim();
|
|
2277
2947
|
return id ? id : `__option-${index}`;
|
|
2278
2948
|
}
|
|
2279
|
-
var OptionRadio = ({ selected }) => /* @__PURE__ */ (0,
|
|
2949
|
+
var OptionRadio = ({ selected }) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2280
2950
|
"span",
|
|
2281
2951
|
{
|
|
2282
2952
|
className: cn(
|
|
@@ -2284,18 +2954,18 @@ var OptionRadio = ({ selected }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx
|
|
|
2284
2954
|
selected ? "border-foreground bg-foreground text-background" : "border-border bg-background"
|
|
2285
2955
|
),
|
|
2286
2956
|
"aria-hidden": true,
|
|
2287
|
-
children: selected ? /* @__PURE__ */ (0,
|
|
2957
|
+
children: selected ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react3.CheckIcon, { className: "size-2.5 stroke-[3]" }) : null
|
|
2288
2958
|
}
|
|
2289
2959
|
);
|
|
2290
2960
|
var QuestionArtifactView = ({
|
|
2291
2961
|
artifact
|
|
2292
2962
|
}) => {
|
|
2293
|
-
const runtime = (0,
|
|
2294
|
-
const [selected, setSelected] = (0,
|
|
2295
|
-
const [submittedIds, setSubmittedIds] = (0,
|
|
2963
|
+
const runtime = (0, import_react12.useThreadRuntime)();
|
|
2964
|
+
const [selected, setSelected] = (0, import_react11.useState)([]);
|
|
2965
|
+
const [submittedIds, setSubmittedIds] = (0, import_react11.useState)(null);
|
|
2296
2966
|
const isMulti = artifact.multi === true;
|
|
2297
2967
|
const isDisabled = submittedIds !== null;
|
|
2298
|
-
const send = (0,
|
|
2968
|
+
const send = (0, import_react11.useCallback)(
|
|
2299
2969
|
(keys) => {
|
|
2300
2970
|
if (keys.length === 0) return;
|
|
2301
2971
|
const labels = artifact.options.map((option, index) => ({ option, key: optionKey(option, index) })).filter(({ key }) => keys.includes(key)).map(({ option }) => option.label);
|
|
@@ -2307,7 +2977,7 @@ var QuestionArtifactView = ({
|
|
|
2307
2977
|
},
|
|
2308
2978
|
[artifact.options, runtime]
|
|
2309
2979
|
);
|
|
2310
|
-
const onPick = (0,
|
|
2980
|
+
const onPick = (0, import_react11.useCallback)(
|
|
2311
2981
|
(key) => {
|
|
2312
2982
|
if (isDisabled) return;
|
|
2313
2983
|
if (!isMulti) {
|
|
@@ -2320,15 +2990,15 @@ var QuestionArtifactView = ({
|
|
|
2320
2990
|
},
|
|
2321
2991
|
[isDisabled, isMulti, send]
|
|
2322
2992
|
);
|
|
2323
|
-
const onConfirm = (0,
|
|
2993
|
+
const onConfirm = (0, import_react11.useCallback)(() => {
|
|
2324
2994
|
send(selected);
|
|
2325
2995
|
}, [selected, send]);
|
|
2326
|
-
return /* @__PURE__ */ (0,
|
|
2327
|
-
artifact.prompt ? /* @__PURE__ */ (0,
|
|
2328
|
-
/* @__PURE__ */ (0,
|
|
2996
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: studioArtifactShellClass, "data-artifact-kind": "question", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "px-2.5 py-2", children: [
|
|
2997
|
+
artifact.prompt ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "mb-2 text-sm font-normal leading-snug text-foreground", children: artifact.prompt }) : null,
|
|
2998
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "flex flex-col gap-0.5", role: "list", children: artifact.options.map((option, index) => {
|
|
2329
2999
|
const key = optionKey(option, index);
|
|
2330
3000
|
const isSelected = submittedIds ? submittedIds.includes(key) : isMulti && selected.includes(key);
|
|
2331
|
-
return /* @__PURE__ */ (0,
|
|
3001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
2332
3002
|
"button",
|
|
2333
3003
|
{
|
|
2334
3004
|
type: "button",
|
|
@@ -2340,17 +3010,17 @@ var QuestionArtifactView = ({
|
|
|
2340
3010
|
isDisabled && (isSelected ? "cursor-default" : "cursor-not-allowed opacity-50")
|
|
2341
3011
|
),
|
|
2342
3012
|
children: [
|
|
2343
|
-
/* @__PURE__ */ (0,
|
|
2344
|
-
/* @__PURE__ */ (0,
|
|
2345
|
-
/* @__PURE__ */ (0,
|
|
2346
|
-
option.description ? /* @__PURE__ */ (0,
|
|
3013
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(OptionRadio, { selected: isSelected }),
|
|
3014
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "min-w-0 flex-1 text-left", children: [
|
|
3015
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "block font-normal text-foreground", children: option.label }),
|
|
3016
|
+
option.description ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: option.description }) : null
|
|
2347
3017
|
] })
|
|
2348
3018
|
]
|
|
2349
3019
|
},
|
|
2350
3020
|
key
|
|
2351
3021
|
);
|
|
2352
3022
|
}) }),
|
|
2353
|
-
isMulti && !submittedIds ? /* @__PURE__ */ (0,
|
|
3023
|
+
isMulti && !submittedIds ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "mt-2 flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2354
3024
|
TimbalV2Button,
|
|
2355
3025
|
{
|
|
2356
3026
|
type: "button",
|
|
@@ -2365,12 +3035,12 @@ var QuestionArtifactView = ({
|
|
|
2365
3035
|
};
|
|
2366
3036
|
|
|
2367
3037
|
// src/artifacts/html-artifact.tsx
|
|
2368
|
-
var
|
|
3038
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2369
3039
|
var HtmlArtifactView = ({ artifact }) => {
|
|
2370
3040
|
const sandboxed = artifact.sandboxed !== false;
|
|
2371
3041
|
const sandbox = sandboxed ? "allow-scripts allow-same-origin allow-forms allow-modals allow-popups allow-pointer-lock" : void 0;
|
|
2372
3042
|
const height = artifact.height ?? "320px";
|
|
2373
|
-
return /* @__PURE__ */ (0,
|
|
3043
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ArtifactCard, { title: artifact.title, kind: "html", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2374
3044
|
"iframe",
|
|
2375
3045
|
{
|
|
2376
3046
|
title: artifact.title ?? "HTML artifact",
|
|
@@ -2383,7 +3053,7 @@ var HtmlArtifactView = ({ artifact }) => {
|
|
|
2383
3053
|
};
|
|
2384
3054
|
|
|
2385
3055
|
// src/artifacts/json-artifact.tsx
|
|
2386
|
-
var
|
|
3056
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2387
3057
|
var JsonArtifactView = ({
|
|
2388
3058
|
artifact
|
|
2389
3059
|
}) => {
|
|
@@ -2395,16 +3065,16 @@ var JsonArtifactView = ({
|
|
|
2395
3065
|
} catch {
|
|
2396
3066
|
body = String(data);
|
|
2397
3067
|
}
|
|
2398
|
-
return /* @__PURE__ */ (0,
|
|
3068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ArtifactCard, { title, kind: "json", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("pre", { className: "aui-artifact-json m-0 max-h-[420px] overflow-auto p-3 font-mono text-[12px] leading-relaxed text-foreground/85", children: body }) });
|
|
2399
3069
|
};
|
|
2400
3070
|
|
|
2401
3071
|
// src/artifacts/table-artifact.tsx
|
|
2402
|
-
var
|
|
3072
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2403
3073
|
var TableArtifactView = ({ artifact }) => {
|
|
2404
3074
|
const rows = artifact.rows ?? [];
|
|
2405
3075
|
const columns = artifact.columns ?? deriveColumns(rows);
|
|
2406
|
-
return /* @__PURE__ */ (0,
|
|
2407
|
-
/* @__PURE__ */ (0,
|
|
3076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ArtifactCard, { title: artifact.title, kind: "table", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "aui-artifact-table-wrap overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("table", { className: "aui-artifact-table w-full border-collapse text-sm", children: [
|
|
3077
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("tr", { className: "border-b border-border/40 bg-muted/20", children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2408
3078
|
"th",
|
|
2409
3079
|
{
|
|
2410
3080
|
className: "px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",
|
|
@@ -2412,11 +3082,11 @@ var TableArtifactView = ({ artifact }) => {
|
|
|
2412
3082
|
},
|
|
2413
3083
|
col.key
|
|
2414
3084
|
)) }) }),
|
|
2415
|
-
/* @__PURE__ */ (0,
|
|
3085
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("tbody", { children: rows.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2416
3086
|
"tr",
|
|
2417
3087
|
{
|
|
2418
3088
|
className: "border-b border-border/30 transition-colors last:border-b-0 hover:bg-muted/20",
|
|
2419
|
-
children: columns.map((col) => /* @__PURE__ */ (0,
|
|
3089
|
+
children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2420
3090
|
"td",
|
|
2421
3091
|
{
|
|
2422
3092
|
className: "px-3 py-2 align-top text-foreground/85",
|
|
@@ -2449,7 +3119,7 @@ function formatCell(value) {
|
|
|
2449
3119
|
}
|
|
2450
3120
|
|
|
2451
3121
|
// src/artifacts/ui/ui-artifact.tsx
|
|
2452
|
-
var
|
|
3122
|
+
var import_react17 = require("react");
|
|
2453
3123
|
|
|
2454
3124
|
// src/artifacts/ui/types.ts
|
|
2455
3125
|
function isUiBinding(value) {
|
|
@@ -2502,38 +3172,38 @@ function resolveBindable(value, state) {
|
|
|
2502
3172
|
}
|
|
2503
3173
|
|
|
2504
3174
|
// src/artifacts/ui/registry.tsx
|
|
2505
|
-
var
|
|
2506
|
-
var
|
|
2507
|
-
var UiStateContext = (0,
|
|
2508
|
-
var UiDispatchContext = (0,
|
|
3175
|
+
var import_react13 = require("react");
|
|
3176
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3177
|
+
var UiStateContext = (0, import_react13.createContext)({});
|
|
3178
|
+
var UiDispatchContext = (0, import_react13.createContext)(() => {
|
|
2509
3179
|
});
|
|
2510
|
-
var UiStateProvider = ({ state, dispatch, children }) => /* @__PURE__ */ (0,
|
|
3180
|
+
var UiStateProvider = ({ state, dispatch, children }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(UiStateContext.Provider, { value: state, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(UiDispatchContext.Provider, { value: dispatch, children }) });
|
|
2511
3181
|
function useUiState() {
|
|
2512
|
-
return (0,
|
|
3182
|
+
return (0, import_react13.useContext)(UiStateContext);
|
|
2513
3183
|
}
|
|
2514
3184
|
function useUiDispatch() {
|
|
2515
|
-
return (0,
|
|
3185
|
+
return (0, import_react13.useContext)(UiDispatchContext);
|
|
2516
3186
|
}
|
|
2517
|
-
var UiEventContext = (0,
|
|
3187
|
+
var UiEventContext = (0, import_react13.createContext)(
|
|
2518
3188
|
null
|
|
2519
3189
|
);
|
|
2520
|
-
var UiEventProvider = ({ onEvent, children }) => /* @__PURE__ */ (0,
|
|
3190
|
+
var UiEventProvider = ({ onEvent, children }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(UiEventContext.Provider, { value: onEvent, children });
|
|
2521
3191
|
function useUiEventEmitter() {
|
|
2522
|
-
return (0,
|
|
3192
|
+
return (0, import_react13.useContext)(UiEventContext);
|
|
2523
3193
|
}
|
|
2524
|
-
var UiCustomNodeRegistryContext = (0,
|
|
3194
|
+
var UiCustomNodeRegistryContext = (0, import_react13.createContext)({});
|
|
2525
3195
|
function useUiCustomNodeRegistry() {
|
|
2526
|
-
return (0,
|
|
3196
|
+
return (0, import_react13.useContext)(UiCustomNodeRegistryContext);
|
|
2527
3197
|
}
|
|
2528
3198
|
|
|
2529
3199
|
// src/artifacts/ui/nodes.tsx
|
|
2530
|
-
var
|
|
2531
|
-
var
|
|
2532
|
-
var
|
|
3200
|
+
var import_react14 = require("react");
|
|
3201
|
+
var import_react15 = require("motion/react");
|
|
3202
|
+
var import_react16 = require("@assistant-ui/react");
|
|
2533
3203
|
|
|
2534
3204
|
// src/ui/button.tsx
|
|
2535
3205
|
var import_class_variance_authority = require("class-variance-authority");
|
|
2536
|
-
var
|
|
3206
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2537
3207
|
var LEGACY_SIZE_TO_V2 = {
|
|
2538
3208
|
default: "md",
|
|
2539
3209
|
xs: "xs",
|
|
@@ -2583,7 +3253,7 @@ function Button({
|
|
|
2583
3253
|
const v2Variant = TIMBAL_V2_FROM_LEGACY_BUTTON[variant ?? "default"];
|
|
2584
3254
|
const v2Size = LEGACY_SIZE_TO_V2[size ?? "default"];
|
|
2585
3255
|
const isIconOnly = typeof size === "string" && size.startsWith("icon");
|
|
2586
|
-
return /* @__PURE__ */ (0,
|
|
3256
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2587
3257
|
TimbalV2Button,
|
|
2588
3258
|
{
|
|
2589
3259
|
"data-slot": "button",
|
|
@@ -2601,29 +3271,29 @@ function Button({
|
|
|
2601
3271
|
}
|
|
2602
3272
|
|
|
2603
3273
|
// src/artifacts/ui/nodes.tsx
|
|
2604
|
-
var
|
|
3274
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2605
3275
|
var UiNodeView = ({ node }) => {
|
|
2606
3276
|
switch (node.kind) {
|
|
2607
3277
|
case "box":
|
|
2608
|
-
return /* @__PURE__ */ (0,
|
|
3278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(BoxNode, { node });
|
|
2609
3279
|
case "text":
|
|
2610
|
-
return /* @__PURE__ */ (0,
|
|
3280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TextNode, { node });
|
|
2611
3281
|
case "heading":
|
|
2612
|
-
return /* @__PURE__ */ (0,
|
|
3282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(HeadingNode, { node });
|
|
2613
3283
|
case "badge":
|
|
2614
|
-
return /* @__PURE__ */ (0,
|
|
3284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(BadgeNode, { node });
|
|
2615
3285
|
case "button":
|
|
2616
|
-
return /* @__PURE__ */ (0,
|
|
3286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ButtonNode, { node });
|
|
2617
3287
|
case "toggle":
|
|
2618
|
-
return /* @__PURE__ */ (0,
|
|
3288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ToggleNode, { node });
|
|
2619
3289
|
case "slider":
|
|
2620
|
-
return /* @__PURE__ */ (0,
|
|
3290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SliderNode, { node });
|
|
2621
3291
|
case "tooltip":
|
|
2622
|
-
return /* @__PURE__ */ (0,
|
|
3292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipNode, { node });
|
|
2623
3293
|
case "draggable":
|
|
2624
|
-
return /* @__PURE__ */ (0,
|
|
3294
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DraggableNode, { node });
|
|
2625
3295
|
case "custom":
|
|
2626
|
-
return /* @__PURE__ */ (0,
|
|
3296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CustomNode, { node });
|
|
2627
3297
|
default:
|
|
2628
3298
|
return null;
|
|
2629
3299
|
}
|
|
@@ -2631,9 +3301,9 @@ var UiNodeView = ({ node }) => {
|
|
|
2631
3301
|
function useActionRunner() {
|
|
2632
3302
|
const state = useUiState();
|
|
2633
3303
|
const dispatch = useUiDispatch();
|
|
2634
|
-
const runtime = (0,
|
|
3304
|
+
const runtime = (0, import_react16.useThreadRuntime)();
|
|
2635
3305
|
const emit = useUiEventEmitter();
|
|
2636
|
-
return (0,
|
|
3306
|
+
return (0, import_react14.useCallback)(
|
|
2637
3307
|
(actions) => {
|
|
2638
3308
|
if (!actions) return;
|
|
2639
3309
|
const list = Array.isArray(actions) ? actions : [actions];
|
|
@@ -2683,7 +3353,7 @@ var JUSTIFY_CLS = {
|
|
|
2683
3353
|
};
|
|
2684
3354
|
var BoxNode = ({ node }) => {
|
|
2685
3355
|
const dir = node.direction ?? "col";
|
|
2686
|
-
return /* @__PURE__ */ (0,
|
|
3356
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2687
3357
|
"div",
|
|
2688
3358
|
{
|
|
2689
3359
|
className: cn(
|
|
@@ -2698,7 +3368,7 @@ var BoxNode = ({ node }) => {
|
|
|
2698
3368
|
gap: node.gap !== void 0 ? `${node.gap * 0.25}rem` : void 0,
|
|
2699
3369
|
padding: node.padding !== void 0 ? `${node.padding * 0.25}rem` : void 0
|
|
2700
3370
|
},
|
|
2701
|
-
children: node.children?.map((child, i) => /* @__PURE__ */ (0,
|
|
3371
|
+
children: node.children?.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UiNodeView, { node: child }, child.id ?? i))
|
|
2702
3372
|
}
|
|
2703
3373
|
);
|
|
2704
3374
|
};
|
|
@@ -2717,7 +3387,7 @@ var TEXT_WEIGHT = {
|
|
|
2717
3387
|
var TextNode = ({ node }) => {
|
|
2718
3388
|
const state = useUiState();
|
|
2719
3389
|
const value = resolveBindable(node.value, state);
|
|
2720
|
-
return /* @__PURE__ */ (0,
|
|
3390
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2721
3391
|
"span",
|
|
2722
3392
|
{
|
|
2723
3393
|
className: cn(
|
|
@@ -2748,13 +3418,13 @@ var HeadingNode = ({ node }) => {
|
|
|
2748
3418
|
);
|
|
2749
3419
|
switch (level) {
|
|
2750
3420
|
case 1:
|
|
2751
|
-
return /* @__PURE__ */ (0,
|
|
3421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h1", { className: cls, children: value });
|
|
2752
3422
|
case 2:
|
|
2753
|
-
return /* @__PURE__ */ (0,
|
|
3423
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h2", { className: cls, children: value });
|
|
2754
3424
|
case 3:
|
|
2755
|
-
return /* @__PURE__ */ (0,
|
|
3425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h3", { className: cls, children: value });
|
|
2756
3426
|
case 4:
|
|
2757
|
-
return /* @__PURE__ */ (0,
|
|
3427
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h4", { className: cls, children: value });
|
|
2758
3428
|
}
|
|
2759
3429
|
};
|
|
2760
3430
|
var BADGE_TONE = {
|
|
@@ -2767,7 +3437,7 @@ var BADGE_TONE = {
|
|
|
2767
3437
|
var BadgeNode = ({ node }) => {
|
|
2768
3438
|
const state = useUiState();
|
|
2769
3439
|
const value = String(resolveBindable(node.value, state) ?? "");
|
|
2770
|
-
return /* @__PURE__ */ (0,
|
|
3440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2771
3441
|
"span",
|
|
2772
3442
|
{
|
|
2773
3443
|
className: cn(
|
|
@@ -2784,7 +3454,7 @@ var ButtonNode = ({ node }) => {
|
|
|
2784
3454
|
const run = useActionRunner();
|
|
2785
3455
|
const label = String(resolveBindable(node.label, state) ?? "");
|
|
2786
3456
|
const disabled = node.disabled !== void 0 ? Boolean(resolveBindable(node.disabled, state)) : false;
|
|
2787
|
-
return /* @__PURE__ */ (0,
|
|
3457
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2788
3458
|
Button,
|
|
2789
3459
|
{
|
|
2790
3460
|
variant: node.variant ?? "default",
|
|
@@ -2806,7 +3476,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2806
3476
|
dispatch({ type: "toggle", path: node.binding });
|
|
2807
3477
|
run(node.onChange);
|
|
2808
3478
|
};
|
|
2809
|
-
return /* @__PURE__ */ (0,
|
|
3479
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
2810
3480
|
"label",
|
|
2811
3481
|
{
|
|
2812
3482
|
className: cn(
|
|
@@ -2814,7 +3484,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2814
3484
|
node.className
|
|
2815
3485
|
),
|
|
2816
3486
|
children: [
|
|
2817
|
-
/* @__PURE__ */ (0,
|
|
3487
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2818
3488
|
"button",
|
|
2819
3489
|
{
|
|
2820
3490
|
type: "button",
|
|
@@ -2825,7 +3495,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2825
3495
|
"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-[background,box-shadow,border-color] duration-200",
|
|
2826
3496
|
value ? "border-foreground/15 bg-gradient-to-b from-primary-fill-from to-primary-fill-to shadow-card" : cn(TIMBAL_V2_SWITCH_TRACK_OFF, "hover:from-secondary-fill-hover-from hover:to-secondary-fill-hover-to")
|
|
2827
3497
|
),
|
|
2828
|
-
children: /* @__PURE__ */ (0,
|
|
3498
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2829
3499
|
"span",
|
|
2830
3500
|
{
|
|
2831
3501
|
className: cn(
|
|
@@ -2838,7 +3508,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2838
3508
|
)
|
|
2839
3509
|
}
|
|
2840
3510
|
),
|
|
2841
|
-
label && /* @__PURE__ */ (0,
|
|
3511
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-foreground/85", children: label })
|
|
2842
3512
|
]
|
|
2843
3513
|
}
|
|
2844
3514
|
);
|
|
@@ -2858,12 +3528,12 @@ var SliderNode = ({ node }) => {
|
|
|
2858
3528
|
const next = Number(e.target.value);
|
|
2859
3529
|
dispatch({ type: "set", path: node.binding, value: next });
|
|
2860
3530
|
};
|
|
2861
|
-
return /* @__PURE__ */ (0,
|
|
2862
|
-
(label || showValue) && /* @__PURE__ */ (0,
|
|
2863
|
-
label && /* @__PURE__ */ (0,
|
|
2864
|
-
showValue && /* @__PURE__ */ (0,
|
|
3531
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: cn("aui-ui-slider flex flex-col gap-1", node.className), children: [
|
|
3532
|
+
(label || showValue) && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center justify-between text-xs text-muted-foreground", children: [
|
|
3533
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: label }),
|
|
3534
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-mono", children: value })
|
|
2865
3535
|
] }),
|
|
2866
|
-
/* @__PURE__ */ (0,
|
|
3536
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2867
3537
|
"input",
|
|
2868
3538
|
{
|
|
2869
3539
|
type: "range",
|
|
@@ -2885,9 +3555,9 @@ var SliderNode = ({ node }) => {
|
|
|
2885
3555
|
var TooltipNode = ({ node }) => {
|
|
2886
3556
|
const state = useUiState();
|
|
2887
3557
|
const content = String(resolveBindable(node.content, state) ?? "");
|
|
2888
|
-
return /* @__PURE__ */ (0,
|
|
2889
|
-
/* @__PURE__ */ (0,
|
|
2890
|
-
/* @__PURE__ */ (0,
|
|
3558
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Tooltip, { children: [
|
|
3559
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: cn("aui-ui-tooltip-trigger inline-flex", node.className), children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UiNodeView, { node: node.child }) }) }),
|
|
3560
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipContent, { side: node.side ?? "top", children: content })
|
|
2891
3561
|
] }) });
|
|
2892
3562
|
};
|
|
2893
3563
|
var DraggableNode = ({ node }) => {
|
|
@@ -2895,8 +3565,8 @@ var DraggableNode = ({ node }) => {
|
|
|
2895
3565
|
const snapBack = node.snapBack ?? true;
|
|
2896
3566
|
const axis = node.axis ?? "both";
|
|
2897
3567
|
const dragProp = axis === "both" ? true : axis;
|
|
2898
|
-
return /* @__PURE__ */ (0,
|
|
2899
|
-
|
|
3568
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3569
|
+
import_react15.motion.div,
|
|
2900
3570
|
{
|
|
2901
3571
|
drag: dragProp,
|
|
2902
3572
|
dragMomentum: false,
|
|
@@ -2907,7 +3577,7 @@ var DraggableNode = ({ node }) => {
|
|
|
2907
3577
|
"aui-ui-draggable inline-block cursor-grab touch-none",
|
|
2908
3578
|
node.className
|
|
2909
3579
|
),
|
|
2910
|
-
children: /* @__PURE__ */ (0,
|
|
3580
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UiNodeView, { node: node.child })
|
|
2911
3581
|
}
|
|
2912
3582
|
);
|
|
2913
3583
|
};
|
|
@@ -2917,8 +3587,8 @@ var CustomNode = ({ node }) => {
|
|
|
2917
3587
|
const Renderer = registry[node.name];
|
|
2918
3588
|
if (!Renderer) return null;
|
|
2919
3589
|
const resolvedProps = resolveProps(node.props ?? {}, state);
|
|
2920
|
-
const children = node.children?.map((child, i) => /* @__PURE__ */ (0,
|
|
2921
|
-
return /* @__PURE__ */ (0,
|
|
3590
|
+
const children = node.children?.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UiNodeView, { node: child }, child.id ?? i));
|
|
3591
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Renderer, { props: resolvedProps, children });
|
|
2922
3592
|
};
|
|
2923
3593
|
function resolveProps(props, state) {
|
|
2924
3594
|
const out = {};
|
|
@@ -2929,17 +3599,17 @@ function resolveProps(props, state) {
|
|
|
2929
3599
|
}
|
|
2930
3600
|
|
|
2931
3601
|
// src/artifacts/ui/ui-artifact.tsx
|
|
2932
|
-
var
|
|
3602
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2933
3603
|
var UiArtifactView = ({ artifact }) => {
|
|
2934
|
-
const [state, dispatch] = (0,
|
|
3604
|
+
const [state, dispatch] = (0, import_react17.useReducer)(
|
|
2935
3605
|
uiStateReducer,
|
|
2936
3606
|
artifact.initialState ?? {}
|
|
2937
3607
|
);
|
|
2938
|
-
return /* @__PURE__ */ (0,
|
|
3608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ArtifactCard, { title: artifact.title, kind: "ui", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(UiStateProvider, { state, dispatch, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "aui-ui-root p-3", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(UiNodeView, { node: artifact.root }) }) }) });
|
|
2939
3609
|
};
|
|
2940
3610
|
|
|
2941
3611
|
// src/artifacts/registry.tsx
|
|
2942
|
-
var
|
|
3612
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2943
3613
|
var defaultArtifactRenderers = {
|
|
2944
3614
|
chart: ChartArtifactView,
|
|
2945
3615
|
question: QuestionArtifactView,
|
|
@@ -2948,25 +3618,25 @@ var defaultArtifactRenderers = {
|
|
|
2948
3618
|
table: TableArtifactView,
|
|
2949
3619
|
ui: UiArtifactView
|
|
2950
3620
|
};
|
|
2951
|
-
var ArtifactRegistryContext = (0,
|
|
3621
|
+
var ArtifactRegistryContext = (0, import_react18.createContext)(
|
|
2952
3622
|
defaultArtifactRenderers
|
|
2953
3623
|
);
|
|
2954
3624
|
var ArtifactRegistryProvider = ({ renderers, override, children }) => {
|
|
2955
|
-
const merged = (0,
|
|
3625
|
+
const merged = (0, import_react18.useMemo)(() => {
|
|
2956
3626
|
if (!renderers) return defaultArtifactRenderers;
|
|
2957
3627
|
if (override) return renderers;
|
|
2958
3628
|
return { ...defaultArtifactRenderers, ...renderers };
|
|
2959
3629
|
}, [renderers, override]);
|
|
2960
|
-
return /* @__PURE__ */ (0,
|
|
3630
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ArtifactRegistryContext.Provider, { value: merged, children });
|
|
2961
3631
|
};
|
|
2962
3632
|
function useArtifactRegistry() {
|
|
2963
|
-
return (0,
|
|
3633
|
+
return (0, import_react18.useContext)(ArtifactRegistryContext);
|
|
2964
3634
|
}
|
|
2965
3635
|
var ArtifactView = ({ artifact }) => {
|
|
2966
3636
|
const registry = useArtifactRegistry();
|
|
2967
3637
|
const Renderer = registry[artifact.type] ?? registry.json;
|
|
2968
3638
|
if (!Renderer) return null;
|
|
2969
|
-
return /* @__PURE__ */ (0,
|
|
3639
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Renderer, { artifact });
|
|
2970
3640
|
};
|
|
2971
3641
|
|
|
2972
3642
|
// src/artifacts/parse.ts
|
|
@@ -3042,7 +3712,7 @@ var import_c = __toESM(require("shiki/langs/c.mjs"), 1);
|
|
|
3042
3712
|
var import_cpp = __toESM(require("shiki/langs/cpp.mjs"), 1);
|
|
3043
3713
|
var import_vitesse_dark = __toESM(require("shiki/themes/vitesse-dark.mjs"), 1);
|
|
3044
3714
|
var import_vitesse_light = __toESM(require("shiki/themes/vitesse-light.mjs"), 1);
|
|
3045
|
-
var
|
|
3715
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3046
3716
|
var SHIKI_THEME_DARK = "vitesse-dark";
|
|
3047
3717
|
var SHIKI_THEME_LIGHT = "vitesse-light";
|
|
3048
3718
|
var highlighterPromise = null;
|
|
@@ -3080,8 +3750,8 @@ var ShikiSyntaxHighlighter = ({
|
|
|
3080
3750
|
language,
|
|
3081
3751
|
code
|
|
3082
3752
|
}) => {
|
|
3083
|
-
const [html, setHtml] = (0,
|
|
3084
|
-
(0,
|
|
3753
|
+
const [html, setHtml] = (0, import_react19.useState)(null);
|
|
3754
|
+
(0, import_react19.useEffect)(() => {
|
|
3085
3755
|
let cancelled = false;
|
|
3086
3756
|
(async () => {
|
|
3087
3757
|
try {
|
|
@@ -3111,13 +3781,13 @@ var ShikiSyntaxHighlighter = ({
|
|
|
3111
3781
|
try {
|
|
3112
3782
|
const parsed = JSON.parse(code);
|
|
3113
3783
|
if (isArtifact(parsed)) {
|
|
3114
|
-
return /* @__PURE__ */ (0,
|
|
3784
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ArtifactView, { artifact: parsed });
|
|
3115
3785
|
}
|
|
3116
3786
|
} catch {
|
|
3117
3787
|
}
|
|
3118
3788
|
}
|
|
3119
3789
|
if (html) {
|
|
3120
|
-
return /* @__PURE__ */ (0,
|
|
3790
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3121
3791
|
"div",
|
|
3122
3792
|
{
|
|
3123
3793
|
className: "shiki-wrapper [&>pre]:!m-0 [&>pre]:!rounded-t-none [&>pre]:!rounded-b-lg [&>pre]:!border [&>pre]:!border-t-0 [&>pre]:!border-border/50 [&>pre]:!p-3 [&>pre]:!text-xs [&>pre]:!leading-relaxed [&>pre]:overflow-x-auto",
|
|
@@ -3125,14 +3795,14 @@ var ShikiSyntaxHighlighter = ({
|
|
|
3125
3795
|
}
|
|
3126
3796
|
);
|
|
3127
3797
|
}
|
|
3128
|
-
return /* @__PURE__ */ (0,
|
|
3798
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Pre, { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Code2, { children: code }) });
|
|
3129
3799
|
};
|
|
3130
3800
|
var syntax_highlighter_default = ShikiSyntaxHighlighter;
|
|
3131
3801
|
|
|
3132
3802
|
// src/chat/markdown-text.tsx
|
|
3133
|
-
var
|
|
3803
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3134
3804
|
var MarkdownTextImpl = () => {
|
|
3135
|
-
return /* @__PURE__ */ (0,
|
|
3805
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3136
3806
|
import_react_markdown.MarkdownTextPrimitive,
|
|
3137
3807
|
{
|
|
3138
3808
|
remarkPlugins: [import_remark_gfm.default, import_remark_math.default],
|
|
@@ -3145,7 +3815,7 @@ var MarkdownTextImpl = () => {
|
|
|
3145
3815
|
}
|
|
3146
3816
|
);
|
|
3147
3817
|
};
|
|
3148
|
-
var MarkdownText = (0,
|
|
3818
|
+
var MarkdownText = (0, import_react20.memo)(MarkdownTextImpl);
|
|
3149
3819
|
var CodeHeader = ({ language, code }) => {
|
|
3150
3820
|
const { isCopied, copyToClipboard } = useCopyToClipboard();
|
|
3151
3821
|
if (isArtifactFenceLanguage(language)) return null;
|
|
@@ -3153,20 +3823,20 @@ var CodeHeader = ({ language, code }) => {
|
|
|
3153
3823
|
if (!code || isCopied) return;
|
|
3154
3824
|
copyToClipboard(code);
|
|
3155
3825
|
};
|
|
3156
|
-
return /* @__PURE__ */ (0,
|
|
3157
|
-
/* @__PURE__ */ (0,
|
|
3158
|
-
/* @__PURE__ */ (0,
|
|
3826
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "aui-code-header flex items-center justify-between rounded-t-lg border border-b-0 border-border/50 bg-code-header-bg px-4 py-2", children: [
|
|
3827
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { className: "flex items-center gap-2 text-xs font-semibold tracking-wide text-muted-foreground/80 uppercase", children: [
|
|
3828
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/40" }),
|
|
3159
3829
|
language
|
|
3160
3830
|
] }),
|
|
3161
|
-
/* @__PURE__ */ (0,
|
|
3831
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3162
3832
|
TooltipIconButton,
|
|
3163
3833
|
{
|
|
3164
3834
|
tooltip: isCopied ? "Copied!" : "Copy",
|
|
3165
3835
|
onClick: onCopy,
|
|
3166
3836
|
className: "transition-colors hover:text-foreground",
|
|
3167
3837
|
children: [
|
|
3168
|
-
!isCopied && /* @__PURE__ */ (0,
|
|
3169
|
-
isCopied && /* @__PURE__ */ (0,
|
|
3838
|
+
!isCopied && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react4.CopyIcon, { className: "h-3.5 w-3.5" }),
|
|
3839
|
+
isCopied && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react4.CheckIcon, { className: "h-3.5 w-3.5 text-emerald-500" })
|
|
3170
3840
|
]
|
|
3171
3841
|
}
|
|
3172
3842
|
)
|
|
@@ -3175,7 +3845,7 @@ var CodeHeader = ({ language, code }) => {
|
|
|
3175
3845
|
var useCopyToClipboard = ({
|
|
3176
3846
|
copiedDuration = 3e3
|
|
3177
3847
|
} = {}) => {
|
|
3178
|
-
const [isCopied, setIsCopied] = (0,
|
|
3848
|
+
const [isCopied, setIsCopied] = (0, import_react20.useState)(false);
|
|
3179
3849
|
const copyToClipboard = (value) => {
|
|
3180
3850
|
if (!value) return;
|
|
3181
3851
|
navigator.clipboard.writeText(value).then(() => {
|
|
@@ -3186,7 +3856,7 @@ var useCopyToClipboard = ({
|
|
|
3186
3856
|
return { isCopied, copyToClipboard };
|
|
3187
3857
|
};
|
|
3188
3858
|
var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownComponents)({
|
|
3189
|
-
h1: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3859
|
+
h1: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3190
3860
|
"h1",
|
|
3191
3861
|
{
|
|
3192
3862
|
className: cn(
|
|
@@ -3196,7 +3866,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3196
3866
|
...props
|
|
3197
3867
|
}
|
|
3198
3868
|
),
|
|
3199
|
-
h2: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3869
|
+
h2: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3200
3870
|
"h2",
|
|
3201
3871
|
{
|
|
3202
3872
|
className: cn(
|
|
@@ -3206,7 +3876,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3206
3876
|
...props
|
|
3207
3877
|
}
|
|
3208
3878
|
),
|
|
3209
|
-
h3: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3879
|
+
h3: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3210
3880
|
"h3",
|
|
3211
3881
|
{
|
|
3212
3882
|
className: cn(
|
|
@@ -3216,7 +3886,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3216
3886
|
...props
|
|
3217
3887
|
}
|
|
3218
3888
|
),
|
|
3219
|
-
h4: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3889
|
+
h4: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3220
3890
|
"h4",
|
|
3221
3891
|
{
|
|
3222
3892
|
className: cn(
|
|
@@ -3226,7 +3896,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3226
3896
|
...props
|
|
3227
3897
|
}
|
|
3228
3898
|
),
|
|
3229
|
-
h5: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3899
|
+
h5: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3230
3900
|
"h5",
|
|
3231
3901
|
{
|
|
3232
3902
|
className: cn(
|
|
@@ -3236,7 +3906,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3236
3906
|
...props
|
|
3237
3907
|
}
|
|
3238
3908
|
),
|
|
3239
|
-
h6: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3909
|
+
h6: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3240
3910
|
"h6",
|
|
3241
3911
|
{
|
|
3242
3912
|
className: cn(
|
|
@@ -3246,7 +3916,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3246
3916
|
...props
|
|
3247
3917
|
}
|
|
3248
3918
|
),
|
|
3249
|
-
p: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3919
|
+
p: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3250
3920
|
"p",
|
|
3251
3921
|
{
|
|
3252
3922
|
className: cn(
|
|
@@ -3256,7 +3926,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3256
3926
|
...props
|
|
3257
3927
|
}
|
|
3258
3928
|
),
|
|
3259
|
-
a: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3929
|
+
a: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3260
3930
|
"a",
|
|
3261
3931
|
{
|
|
3262
3932
|
className: cn(
|
|
@@ -3268,7 +3938,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3268
3938
|
...props
|
|
3269
3939
|
}
|
|
3270
3940
|
),
|
|
3271
|
-
blockquote: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3941
|
+
blockquote: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3272
3942
|
"blockquote",
|
|
3273
3943
|
{
|
|
3274
3944
|
className: cn(
|
|
@@ -3278,7 +3948,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3278
3948
|
...props
|
|
3279
3949
|
}
|
|
3280
3950
|
),
|
|
3281
|
-
ul: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3951
|
+
ul: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3282
3952
|
"ul",
|
|
3283
3953
|
{
|
|
3284
3954
|
className: cn(
|
|
@@ -3288,7 +3958,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3288
3958
|
...props
|
|
3289
3959
|
}
|
|
3290
3960
|
),
|
|
3291
|
-
ol: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3961
|
+
ol: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3292
3962
|
"ol",
|
|
3293
3963
|
{
|
|
3294
3964
|
className: cn(
|
|
@@ -3298,7 +3968,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3298
3968
|
...props
|
|
3299
3969
|
}
|
|
3300
3970
|
),
|
|
3301
|
-
hr: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3971
|
+
hr: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3302
3972
|
"hr",
|
|
3303
3973
|
{
|
|
3304
3974
|
className: cn(
|
|
@@ -3308,14 +3978,14 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3308
3978
|
...props
|
|
3309
3979
|
}
|
|
3310
3980
|
),
|
|
3311
|
-
table: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3981
|
+
table: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "my-4 w-full overflow-x-auto rounded-lg border border-border/50", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3312
3982
|
"table",
|
|
3313
3983
|
{
|
|
3314
3984
|
className: cn("aui-md-table w-full border-collapse text-sm", className),
|
|
3315
3985
|
...props
|
|
3316
3986
|
}
|
|
3317
3987
|
) }),
|
|
3318
|
-
th: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3988
|
+
th: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3319
3989
|
"th",
|
|
3320
3990
|
{
|
|
3321
3991
|
className: cn(
|
|
@@ -3325,7 +3995,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3325
3995
|
...props
|
|
3326
3996
|
}
|
|
3327
3997
|
),
|
|
3328
|
-
td: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3998
|
+
td: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3329
3999
|
"td",
|
|
3330
4000
|
{
|
|
3331
4001
|
className: cn(
|
|
@@ -3335,7 +4005,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3335
4005
|
...props
|
|
3336
4006
|
}
|
|
3337
4007
|
),
|
|
3338
|
-
tr: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
4008
|
+
tr: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3339
4009
|
"tr",
|
|
3340
4010
|
{
|
|
3341
4011
|
className: cn(
|
|
@@ -3345,8 +4015,8 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3345
4015
|
...props
|
|
3346
4016
|
}
|
|
3347
4017
|
),
|
|
3348
|
-
li: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3349
|
-
sup: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
4018
|
+
li: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("li", { className: cn("aui-md-li leading-[1.7]", className), ...props }),
|
|
4019
|
+
sup: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3350
4020
|
"sup",
|
|
3351
4021
|
{
|
|
3352
4022
|
className: cn(
|
|
@@ -3356,7 +4026,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3356
4026
|
...props
|
|
3357
4027
|
}
|
|
3358
4028
|
),
|
|
3359
|
-
pre: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
4029
|
+
pre: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3360
4030
|
"pre",
|
|
3361
4031
|
{
|
|
3362
4032
|
className: cn(
|
|
@@ -3368,7 +4038,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3368
4038
|
),
|
|
3369
4039
|
code: function Code({ className, ...props }) {
|
|
3370
4040
|
const isCodeBlock = (0, import_react_markdown.useIsMarkdownCodeBlock)();
|
|
3371
|
-
return /* @__PURE__ */ (0,
|
|
4041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3372
4042
|
"code",
|
|
3373
4043
|
{
|
|
3374
4044
|
className: cn(
|
|
@@ -3379,20 +4049,20 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3379
4049
|
}
|
|
3380
4050
|
);
|
|
3381
4051
|
},
|
|
3382
|
-
strong: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3383
|
-
em: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
4052
|
+
strong: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("strong", { className: cn("font-semibold text-foreground", className), ...props }),
|
|
4053
|
+
em: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("em", { className: cn("italic", className), ...props }),
|
|
3384
4054
|
CodeHeader
|
|
3385
4055
|
});
|
|
3386
4056
|
|
|
3387
4057
|
// src/chat/tool-fallback.tsx
|
|
3388
|
-
var
|
|
4058
|
+
var import_react24 = require("react");
|
|
3389
4059
|
var import_lucide_react5 = require("lucide-react");
|
|
3390
|
-
var
|
|
4060
|
+
var import_react25 = require("@assistant-ui/react");
|
|
3391
4061
|
|
|
3392
4062
|
// src/ui/shimmer.tsx
|
|
3393
|
-
var
|
|
3394
|
-
var
|
|
3395
|
-
var
|
|
4063
|
+
var import_react21 = require("motion/react");
|
|
4064
|
+
var import_react22 = require("react");
|
|
4065
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3396
4066
|
var ShimmerComponent = ({
|
|
3397
4067
|
children,
|
|
3398
4068
|
as: Component = "p",
|
|
@@ -3400,14 +4070,14 @@ var ShimmerComponent = ({
|
|
|
3400
4070
|
duration = 2,
|
|
3401
4071
|
spread = 2
|
|
3402
4072
|
}) => {
|
|
3403
|
-
const MotionComponent =
|
|
4073
|
+
const MotionComponent = import_react21.motion.create(
|
|
3404
4074
|
Component
|
|
3405
4075
|
);
|
|
3406
|
-
const dynamicSpread = (0,
|
|
4076
|
+
const dynamicSpread = (0, import_react22.useMemo)(
|
|
3407
4077
|
() => (children?.length ?? 0) * spread,
|
|
3408
4078
|
[children, spread]
|
|
3409
4079
|
);
|
|
3410
|
-
return /* @__PURE__ */ (0,
|
|
4080
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3411
4081
|
MotionComponent,
|
|
3412
4082
|
{
|
|
3413
4083
|
animate: { backgroundPosition: "0% center" },
|
|
@@ -3430,11 +4100,11 @@ var ShimmerComponent = ({
|
|
|
3430
4100
|
}
|
|
3431
4101
|
);
|
|
3432
4102
|
};
|
|
3433
|
-
var Shimmer = (0,
|
|
4103
|
+
var Shimmer = (0, import_react22.memo)(ShimmerComponent);
|
|
3434
4104
|
|
|
3435
4105
|
// src/chat/motion.tsx
|
|
3436
|
-
var
|
|
3437
|
-
var
|
|
4106
|
+
var import_react23 = require("motion/react");
|
|
4107
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3438
4108
|
var luxuryEase = [0.16, 1, 0.3, 1];
|
|
3439
4109
|
var TOOL_ENTER_MS = 0.78;
|
|
3440
4110
|
var TOOL_EXIT_MS = 0.28;
|
|
@@ -3460,10 +4130,10 @@ function toolMotionState(reduced, entering, variant) {
|
|
|
3460
4130
|
return entering ? { opacity: 0, y: 14, filter: "blur(10px)" } : { opacity: 1, y: 0, filter: "blur(0px)" };
|
|
3461
4131
|
}
|
|
3462
4132
|
function ToolMotion({ children, className, motionKey }) {
|
|
3463
|
-
const reduced = (0,
|
|
4133
|
+
const reduced = (0, import_react23.useReducedMotion)() ?? false;
|
|
3464
4134
|
const { enter, exit } = toolPresenceTransition(reduced);
|
|
3465
|
-
return /* @__PURE__ */ (0,
|
|
3466
|
-
|
|
4135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4136
|
+
import_react23.motion.div,
|
|
3467
4137
|
{
|
|
3468
4138
|
className: cn("aui-tool-motion w-full min-w-0", className),
|
|
3469
4139
|
initial: toolMotionState(reduced, true, "settled"),
|
|
@@ -3482,11 +4152,11 @@ function ToolPresence({
|
|
|
3482
4152
|
className,
|
|
3483
4153
|
variant = "settled"
|
|
3484
4154
|
}) {
|
|
3485
|
-
const reduced = (0,
|
|
4155
|
+
const reduced = (0, import_react23.useReducedMotion)() ?? false;
|
|
3486
4156
|
const { enter, exit } = toolPresenceTransition(reduced);
|
|
3487
4157
|
const enterTransition = variant === "executing" ? { duration: reduced ? 0.3 : 0.52, ease: luxuryEase } : enter;
|
|
3488
|
-
return /* @__PURE__ */ (0,
|
|
3489
|
-
|
|
4158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react23.AnimatePresence, { mode: "wait", initial: true, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4159
|
+
import_react23.motion.div,
|
|
3490
4160
|
{
|
|
3491
4161
|
className: cn("aui-tool-presence w-full min-w-0", className),
|
|
3492
4162
|
initial: toolMotionState(reduced, true, variant),
|
|
@@ -3506,8 +4176,8 @@ function ToolBodyPresence({
|
|
|
3506
4176
|
children,
|
|
3507
4177
|
className
|
|
3508
4178
|
}) {
|
|
3509
|
-
const reduced = (0,
|
|
3510
|
-
return /* @__PURE__ */ (0,
|
|
4179
|
+
const reduced = (0, import_react23.useReducedMotion)() ?? false;
|
|
4180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3511
4181
|
"div",
|
|
3512
4182
|
{
|
|
3513
4183
|
className: cn(
|
|
@@ -3515,7 +4185,7 @@ function ToolBodyPresence({
|
|
|
3515
4185
|
open ? reduced ? "duration-200 ease-out" : "duration-[340ms] ease-[cubic-bezier(0.16,1,0.3,1)]" : reduced ? "duration-150 ease-[cubic-bezier(0.4,0,0.2,1)]" : "duration-200 ease-[cubic-bezier(0.4,0,0.2,1)]"
|
|
3516
4186
|
),
|
|
3517
4187
|
style: { gridTemplateRows: open ? "1fr" : "0fr" },
|
|
3518
|
-
children: /* @__PURE__ */ (0,
|
|
4188
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3519
4189
|
"div",
|
|
3520
4190
|
{
|
|
3521
4191
|
className: cn(
|
|
@@ -3531,7 +4201,7 @@ function ToolBodyPresence({
|
|
|
3531
4201
|
}
|
|
3532
4202
|
|
|
3533
4203
|
// src/chat/tool-fallback.tsx
|
|
3534
|
-
var
|
|
4204
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3535
4205
|
function detectRunning({
|
|
3536
4206
|
status,
|
|
3537
4207
|
result,
|
|
@@ -3545,7 +4215,7 @@ function detectRunning({
|
|
|
3545
4215
|
}
|
|
3546
4216
|
function useToolRunning(props) {
|
|
3547
4217
|
const { isRunning: streamRunning } = useTimbalRuntime();
|
|
3548
|
-
const partStatus = (0,
|
|
4218
|
+
const partStatus = (0, import_react25.useAuiState)((s) => s.part.status);
|
|
3549
4219
|
return detectRunning({
|
|
3550
4220
|
status: partStatus ?? props.status,
|
|
3551
4221
|
result: props.result,
|
|
@@ -3563,8 +4233,8 @@ function formatToolResult(result) {
|
|
|
3563
4233
|
return String(result);
|
|
3564
4234
|
}
|
|
3565
4235
|
}
|
|
3566
|
-
var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__ */ (0,
|
|
3567
|
-
action ? shimmer ? /* @__PURE__ */ (0,
|
|
4236
|
+
var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("span", { className: "inline-flex min-w-0 max-w-full items-baseline gap-1", children: [
|
|
4237
|
+
action ? shimmer ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3568
4238
|
Shimmer,
|
|
3569
4239
|
{
|
|
3570
4240
|
as: "span",
|
|
@@ -3573,10 +4243,10 @@ var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__
|
|
|
3573
4243
|
spread: 2.5,
|
|
3574
4244
|
children: action
|
|
3575
4245
|
}
|
|
3576
|
-
) : /* @__PURE__ */ (0,
|
|
3577
|
-
detail ? /* @__PURE__ */ (0,
|
|
4246
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: studioTimelineActionClass, children: action }) : null,
|
|
4247
|
+
detail ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: studioTimelineDetailClass, children: detail }) : null
|
|
3578
4248
|
] });
|
|
3579
|
-
var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0,
|
|
4249
|
+
var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3580
4250
|
import_lucide_react5.ChevronRightIcon,
|
|
3581
4251
|
{
|
|
3582
4252
|
className: studioTimelineChevronClass(expanded),
|
|
@@ -3584,9 +4254,9 @@ var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0, import_jsx_runt
|
|
|
3584
4254
|
}
|
|
3585
4255
|
);
|
|
3586
4256
|
var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
3587
|
-
const [open, setOpen] = (0,
|
|
4257
|
+
const [open, setOpen] = (0, import_react24.useState)(false);
|
|
3588
4258
|
const detail = formatToolLabel(toolName);
|
|
3589
|
-
const formattedArgs = (0,
|
|
4259
|
+
const formattedArgs = (0, import_react24.useMemo)(() => {
|
|
3590
4260
|
if (!argsText || argsText === "{}") return null;
|
|
3591
4261
|
try {
|
|
3592
4262
|
return JSON.stringify(JSON.parse(argsText), null, 2);
|
|
@@ -3594,17 +4264,17 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3594
4264
|
return argsText;
|
|
3595
4265
|
}
|
|
3596
4266
|
}, [argsText]);
|
|
3597
|
-
const formattedResult = (0,
|
|
4267
|
+
const formattedResult = (0, import_react24.useMemo)(() => {
|
|
3598
4268
|
if (result === void 0 || result === null) return null;
|
|
3599
4269
|
return formatToolResult(result);
|
|
3600
4270
|
}, [result]);
|
|
3601
4271
|
const hasBody = Boolean(formattedArgs || formattedResult);
|
|
3602
4272
|
const action = isError ? "Failed" : "Used";
|
|
3603
4273
|
if (!hasBody) {
|
|
3604
|
-
return /* @__PURE__ */ (0,
|
|
4274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "aui-tool-row w-full min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TimelineActionLabel, { action, detail }) });
|
|
3605
4275
|
}
|
|
3606
|
-
return /* @__PURE__ */ (0,
|
|
3607
|
-
/* @__PURE__ */ (0,
|
|
4276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "aui-tool-row w-full min-w-0", children: [
|
|
4277
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3608
4278
|
"button",
|
|
3609
4279
|
{
|
|
3610
4280
|
type: "button",
|
|
@@ -3612,7 +4282,7 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3612
4282
|
"aria-expanded": open,
|
|
3613
4283
|
"aria-label": `${action} ${detail}`,
|
|
3614
4284
|
className: studioTimelineRowButtonClass,
|
|
3615
|
-
children: /* @__PURE__ */ (0,
|
|
4285
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
3616
4286
|
"span",
|
|
3617
4287
|
{
|
|
3618
4288
|
className: cn(
|
|
@@ -3621,37 +4291,37 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3621
4291
|
"text-foreground"
|
|
3622
4292
|
),
|
|
3623
4293
|
children: [
|
|
3624
|
-
/* @__PURE__ */ (0,
|
|
3625
|
-
/* @__PURE__ */ (0,
|
|
4294
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TimelineActionLabel, { action, detail }),
|
|
4295
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TimelineHoverChevron, { expanded: open })
|
|
3626
4296
|
]
|
|
3627
4297
|
}
|
|
3628
4298
|
)
|
|
3629
4299
|
}
|
|
3630
4300
|
),
|
|
3631
|
-
/* @__PURE__ */ (0,
|
|
4301
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
3632
4302
|
ToolBodyPresence,
|
|
3633
4303
|
{
|
|
3634
4304
|
open,
|
|
3635
4305
|
className: cn(studioTimelineBodyPadClass, "gap-2"),
|
|
3636
4306
|
children: [
|
|
3637
|
-
formattedArgs ? /* @__PURE__ */ (0,
|
|
4307
|
+
formattedArgs ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3638
4308
|
"div",
|
|
3639
4309
|
{
|
|
3640
4310
|
className: cn(
|
|
3641
4311
|
studioComposerIoWellClass,
|
|
3642
4312
|
"max-h-48 overflow-auto px-2.5 py-2"
|
|
3643
4313
|
),
|
|
3644
|
-
children: /* @__PURE__ */ (0,
|
|
4314
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("pre", { className: "whitespace-pre-wrap break-words font-mono text-[11px] font-normal leading-relaxed text-foreground", children: formattedArgs })
|
|
3645
4315
|
}
|
|
3646
4316
|
) : null,
|
|
3647
|
-
formattedResult ? /* @__PURE__ */ (0,
|
|
4317
|
+
formattedResult ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3648
4318
|
"div",
|
|
3649
4319
|
{
|
|
3650
4320
|
className: cn(
|
|
3651
4321
|
studioComposerIoWellClass,
|
|
3652
4322
|
"max-h-48 overflow-auto px-2.5 py-2"
|
|
3653
4323
|
),
|
|
3654
|
-
children: /* @__PURE__ */ (0,
|
|
4324
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("pre", { className: "whitespace-pre-wrap break-words font-mono text-[11px] font-normal leading-relaxed text-foreground", children: formattedResult })
|
|
3655
4325
|
}
|
|
3656
4326
|
) : null
|
|
3657
4327
|
]
|
|
@@ -3668,20 +4338,20 @@ var ToolFallbackImpl = ({
|
|
|
3668
4338
|
const isRunning = useToolRunning({ status, result });
|
|
3669
4339
|
const isError = status?.type === "incomplete" && status.reason !== "cancelled";
|
|
3670
4340
|
const presenceKey = isRunning ? "running" : isError ? "error" : "complete";
|
|
3671
|
-
return /* @__PURE__ */ (0,
|
|
4341
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3672
4342
|
ToolPresence,
|
|
3673
4343
|
{
|
|
3674
4344
|
presenceKey,
|
|
3675
4345
|
variant: isRunning ? "executing" : "settled",
|
|
3676
4346
|
className: "py-0.5",
|
|
3677
|
-
children: isRunning ? /* @__PURE__ */ (0,
|
|
4347
|
+
children: isRunning ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "aui-tool-running", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3678
4348
|
TimelineActionLabel,
|
|
3679
4349
|
{
|
|
3680
4350
|
action: "Using",
|
|
3681
4351
|
detail: formatToolLabel(toolName),
|
|
3682
4352
|
shimmer: true
|
|
3683
4353
|
}
|
|
3684
|
-
) }) : /* @__PURE__ */ (0,
|
|
4354
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3685
4355
|
ToolPanel,
|
|
3686
4356
|
{
|
|
3687
4357
|
toolName,
|
|
@@ -3693,13 +4363,13 @@ var ToolFallbackImpl = ({
|
|
|
3693
4363
|
}
|
|
3694
4364
|
);
|
|
3695
4365
|
};
|
|
3696
|
-
var ToolFallback = (0,
|
|
4366
|
+
var ToolFallback = (0, import_react24.memo)(
|
|
3697
4367
|
ToolFallbackImpl
|
|
3698
4368
|
);
|
|
3699
4369
|
ToolFallback.displayName = "ToolFallback";
|
|
3700
4370
|
|
|
3701
4371
|
// src/artifacts/tool-artifact.tsx
|
|
3702
|
-
var
|
|
4372
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
3703
4373
|
var ToolArtifactFallback = (props) => {
|
|
3704
4374
|
const registry = useArtifactRegistry();
|
|
3705
4375
|
const isRunning = useToolRunning({
|
|
@@ -3711,24 +4381,24 @@ var ToolArtifactFallback = (props) => {
|
|
|
3711
4381
|
if (artifact) {
|
|
3712
4382
|
const Renderer = registry[artifact.type];
|
|
3713
4383
|
if (Renderer) {
|
|
3714
|
-
return /* @__PURE__ */ (0,
|
|
4384
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3715
4385
|
ToolMotion,
|
|
3716
4386
|
{
|
|
3717
4387
|
motionKey: `artifact-${artifact.type}`,
|
|
3718
4388
|
className: "aui-tool-artifact",
|
|
3719
|
-
children: /* @__PURE__ */ (0,
|
|
4389
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Renderer, { artifact })
|
|
3720
4390
|
}
|
|
3721
4391
|
);
|
|
3722
4392
|
}
|
|
3723
4393
|
}
|
|
3724
4394
|
}
|
|
3725
|
-
return /* @__PURE__ */ (0,
|
|
4395
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ToolFallback, { ...props });
|
|
3726
4396
|
};
|
|
3727
4397
|
|
|
3728
4398
|
// src/chat/composer.tsx
|
|
3729
|
-
var
|
|
4399
|
+
var import_react26 = require("@assistant-ui/react");
|
|
3730
4400
|
var import_lucide_react6 = require("lucide-react");
|
|
3731
|
-
var
|
|
4401
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
3732
4402
|
var Composer = ({
|
|
3733
4403
|
placeholder = "Send a message...",
|
|
3734
4404
|
showAttachments,
|
|
@@ -3739,10 +4409,10 @@ var Composer = ({
|
|
|
3739
4409
|
}) => {
|
|
3740
4410
|
const attachmentsEnabled = useTimbalAttachmentsEnabled();
|
|
3741
4411
|
const attachUi = showAttachments !== false && attachmentsEnabled;
|
|
3742
|
-
const shell = /* @__PURE__ */ (0,
|
|
3743
|
-
attachUi && /* @__PURE__ */ (0,
|
|
3744
|
-
/* @__PURE__ */ (0,
|
|
3745
|
-
/* @__PURE__ */ (0,
|
|
4412
|
+
const shell = /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
4413
|
+
attachUi && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComposerAttachments, {}),
|
|
4414
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComposerInput, { placeholder, autoFocus: !noAutoFocus }),
|
|
4415
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3746
4416
|
ComposerToolbar,
|
|
3747
4417
|
{
|
|
3748
4418
|
showAttachments: attachUi,
|
|
@@ -3751,15 +4421,15 @@ var Composer = ({
|
|
|
3751
4421
|
}
|
|
3752
4422
|
)
|
|
3753
4423
|
] });
|
|
3754
|
-
return /* @__PURE__ */ (0,
|
|
3755
|
-
|
|
4424
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4425
|
+
import_react26.ComposerPrimitive.Root,
|
|
3756
4426
|
{
|
|
3757
4427
|
className: cn(
|
|
3758
4428
|
"aui-composer-root relative flex w-full flex-col",
|
|
3759
4429
|
className
|
|
3760
4430
|
),
|
|
3761
|
-
children: attachUi ? /* @__PURE__ */ (0,
|
|
3762
|
-
|
|
4431
|
+
children: attachUi ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4432
|
+
import_react26.ComposerPrimitive.AttachmentDropzone,
|
|
3763
4433
|
{
|
|
3764
4434
|
className: cn(
|
|
3765
4435
|
studioComposeInputShellClass,
|
|
@@ -3767,7 +4437,7 @@ var Composer = ({
|
|
|
3767
4437
|
),
|
|
3768
4438
|
children: shell
|
|
3769
4439
|
}
|
|
3770
|
-
) : /* @__PURE__ */ (0,
|
|
4440
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: studioComposeInputShellClass, children: shell })
|
|
3771
4441
|
}
|
|
3772
4442
|
);
|
|
3773
4443
|
};
|
|
@@ -3775,7 +4445,7 @@ var ComposerInput = ({
|
|
|
3775
4445
|
placeholder,
|
|
3776
4446
|
autoFocus
|
|
3777
4447
|
}) => {
|
|
3778
|
-
const composer = (0,
|
|
4448
|
+
const composer = (0, import_react26.useComposerRuntime)();
|
|
3779
4449
|
const onKeyDown = (e) => {
|
|
3780
4450
|
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
|
|
3781
4451
|
e.preventDefault();
|
|
@@ -3787,8 +4457,8 @@ var ComposerInput = ({
|
|
|
3787
4457
|
el.style.height = "auto";
|
|
3788
4458
|
el.style.height = `${Math.min(el.scrollHeight, 240)}px`;
|
|
3789
4459
|
};
|
|
3790
|
-
return /* @__PURE__ */ (0,
|
|
3791
|
-
|
|
4460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4461
|
+
import_react26.ComposerPrimitive.Input,
|
|
3792
4462
|
{
|
|
3793
4463
|
placeholder,
|
|
3794
4464
|
className: "aui-composer-input max-h-60 min-h-14 w-full resize-none bg-composer-bg px-3 pt-3 pb-1 text-sm outline-none placeholder:text-muted-foreground/70 focus-visible:ring-0",
|
|
@@ -3801,17 +4471,17 @@ var ComposerInput = ({
|
|
|
3801
4471
|
);
|
|
3802
4472
|
};
|
|
3803
4473
|
var ComposerToolbar = ({ showAttachments, toolbar, sendTooltip }) => {
|
|
3804
|
-
return /* @__PURE__ */ (0,
|
|
3805
|
-
/* @__PURE__ */ (0,
|
|
3806
|
-
showAttachments && /* @__PURE__ */ (0,
|
|
4474
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "aui-composer-action-wrapper relative z-[1] flex items-center justify-between gap-1 bg-composer-bg px-2.5 pb-2.5", children: [
|
|
4475
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
4476
|
+
showAttachments && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComposerAddAttachment, {}),
|
|
3807
4477
|
toolbar
|
|
3808
4478
|
] }),
|
|
3809
|
-
/* @__PURE__ */ (0,
|
|
4479
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ComposerSendOrCancel, { sendTooltip })
|
|
3810
4480
|
] });
|
|
3811
4481
|
};
|
|
3812
4482
|
var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
3813
|
-
return /* @__PURE__ */ (0,
|
|
3814
|
-
/* @__PURE__ */ (0,
|
|
4483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
4484
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react26.AuiIf, { condition: (s) => !s.thread.isRunning, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react26.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3815
4485
|
TooltipIconButton,
|
|
3816
4486
|
{
|
|
3817
4487
|
tooltip: sendTooltip,
|
|
@@ -3819,34 +4489,34 @@ var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
|
3819
4489
|
type: "submit",
|
|
3820
4490
|
className: "aui-composer-send shrink-0 disabled:opacity-30",
|
|
3821
4491
|
"aria-label": "Send message",
|
|
3822
|
-
children: /* @__PURE__ */ (0,
|
|
4492
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_lucide_react6.ArrowUpIcon, { className: "aui-composer-send-icon size-4" })
|
|
3823
4493
|
}
|
|
3824
4494
|
) }) }),
|
|
3825
|
-
/* @__PURE__ */ (0,
|
|
4495
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react26.AuiIf, { condition: (s) => s.thread.isRunning, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react26.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3826
4496
|
TooltipIconButton,
|
|
3827
4497
|
{
|
|
3828
4498
|
tooltip: "Stop generating",
|
|
3829
4499
|
variant: "primary",
|
|
3830
4500
|
className: "aui-composer-cancel shrink-0",
|
|
3831
4501
|
"aria-label": "Stop generating",
|
|
3832
|
-
children: /* @__PURE__ */ (0,
|
|
4502
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_lucide_react6.SquareIcon, { className: "aui-composer-cancel-icon size-3 fill-current" })
|
|
3833
4503
|
}
|
|
3834
4504
|
) }) })
|
|
3835
4505
|
] });
|
|
3836
4506
|
};
|
|
3837
4507
|
|
|
3838
4508
|
// src/chat/suggestions.tsx
|
|
3839
|
-
var
|
|
3840
|
-
var
|
|
4509
|
+
var import_react27 = require("react");
|
|
4510
|
+
var import_react28 = require("@assistant-ui/react");
|
|
3841
4511
|
var import_lucide_react7 = require("lucide-react");
|
|
3842
|
-
var
|
|
4512
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
3843
4513
|
var Suggestions = ({
|
|
3844
4514
|
suggestions,
|
|
3845
4515
|
className
|
|
3846
4516
|
}) => {
|
|
3847
4517
|
const items = useResolvedSuggestions(suggestions);
|
|
3848
4518
|
if (!items || items.length === 0) return null;
|
|
3849
|
-
return /* @__PURE__ */ (0,
|
|
4519
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3850
4520
|
"div",
|
|
3851
4521
|
{
|
|
3852
4522
|
className: cn(
|
|
@@ -3855,17 +4525,17 @@ var Suggestions = ({
|
|
|
3855
4525
|
),
|
|
3856
4526
|
role: "list",
|
|
3857
4527
|
"aria-label": "Suggested prompts",
|
|
3858
|
-
children: items.map((suggestion, i) => /* @__PURE__ */ (0,
|
|
4528
|
+
children: items.map((suggestion, i) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SuggestionRow, { suggestion }, (suggestion.prompt ?? suggestion.title) + i))
|
|
3859
4529
|
}
|
|
3860
4530
|
);
|
|
3861
4531
|
};
|
|
3862
4532
|
var SuggestionRow = ({ suggestion }) => {
|
|
3863
|
-
const runtime = (0,
|
|
4533
|
+
const runtime = (0, import_react28.useThreadRuntime)();
|
|
3864
4534
|
const onClick = () => {
|
|
3865
4535
|
const text = suggestion.prompt ?? suggestion.title;
|
|
3866
4536
|
runtime.append({ role: "user", content: [{ type: "text", text }] });
|
|
3867
4537
|
};
|
|
3868
|
-
return /* @__PURE__ */ (0,
|
|
4538
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
3869
4539
|
"button",
|
|
3870
4540
|
{
|
|
3871
4541
|
type: "button",
|
|
@@ -3873,20 +4543,20 @@ var SuggestionRow = ({ suggestion }) => {
|
|
|
3873
4543
|
onClick,
|
|
3874
4544
|
className: cn("aui-thread-suggestion", studioListRowButtonClass),
|
|
3875
4545
|
children: [
|
|
3876
|
-
/* @__PURE__ */ (0,
|
|
3877
|
-
/* @__PURE__ */ (0,
|
|
3878
|
-
/* @__PURE__ */ (0,
|
|
3879
|
-
suggestion.description && /* @__PURE__ */ (0,
|
|
4546
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "aui-thread-suggestion-icon shrink-0 text-muted-foreground", children: suggestion.icon ?? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react7.ArrowUpIcon, { className: "size-4", strokeWidth: 1.75, "aria-hidden": true }) }),
|
|
4547
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("span", { className: "aui-thread-suggestion-text min-w-0 flex-1 text-left", children: [
|
|
4548
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "aui-thread-suggestion-text-1 block truncate text-sm font-normal text-foreground", children: suggestion.title }),
|
|
4549
|
+
suggestion.description && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "aui-thread-suggestion-text-2 mt-0.5 block truncate text-xs text-muted-foreground", children: suggestion.description })
|
|
3880
4550
|
] })
|
|
3881
4551
|
]
|
|
3882
4552
|
}
|
|
3883
4553
|
);
|
|
3884
4554
|
};
|
|
3885
4555
|
function useResolvedSuggestions(source) {
|
|
3886
|
-
const [resolved, setResolved] = (0,
|
|
4556
|
+
const [resolved, setResolved] = (0, import_react27.useState)(
|
|
3887
4557
|
() => Array.isArray(source) ? source : void 0
|
|
3888
4558
|
);
|
|
3889
|
-
(0,
|
|
4559
|
+
(0, import_react27.useEffect)(() => {
|
|
3890
4560
|
if (!source) {
|
|
3891
4561
|
setResolved(void 0);
|
|
3892
4562
|
return;
|
|
@@ -3905,7 +4575,7 @@ function useResolvedSuggestions(source) {
|
|
|
3905
4575
|
cancelled = true;
|
|
3906
4576
|
};
|
|
3907
4577
|
}, [source]);
|
|
3908
|
-
return (0,
|
|
4578
|
+
return (0, import_react27.useMemo)(() => resolved, [resolved]);
|
|
3909
4579
|
}
|
|
3910
4580
|
|
|
3911
4581
|
// src/design/theme-sanity.ts
|
|
@@ -3978,15 +4648,15 @@ function scheduleThemeSanityCheck() {
|
|
|
3978
4648
|
}
|
|
3979
4649
|
|
|
3980
4650
|
// src/chat/thread-variant.tsx
|
|
3981
|
-
var
|
|
3982
|
-
var ThreadVariantContext = (0,
|
|
4651
|
+
var import_react29 = require("react");
|
|
4652
|
+
var ThreadVariantContext = (0, import_react29.createContext)("default");
|
|
3983
4653
|
var ThreadVariantProvider = ThreadVariantContext.Provider;
|
|
3984
4654
|
function useThreadVariant() {
|
|
3985
|
-
return (0,
|
|
4655
|
+
return (0, import_react29.useContext)(ThreadVariantContext);
|
|
3986
4656
|
}
|
|
3987
4657
|
|
|
3988
4658
|
// src/chat/thread.tsx
|
|
3989
|
-
var
|
|
4659
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
3990
4660
|
var Thread = ({
|
|
3991
4661
|
className,
|
|
3992
4662
|
variant = "default",
|
|
@@ -4009,17 +4679,17 @@ var Thread = ({
|
|
|
4009
4679
|
const EditComposerSlot = components?.EditComposer ?? EditComposer;
|
|
4010
4680
|
const ScrollToBottomSlot = components?.ScrollToBottom ?? ThreadScrollToBottom;
|
|
4011
4681
|
const SuggestionsSlot = components?.Suggestions ?? Suggestions;
|
|
4012
|
-
(0,
|
|
4682
|
+
(0, import_react30.useEffect)(() => {
|
|
4013
4683
|
scheduleThemeSanityCheck();
|
|
4014
4684
|
}, []);
|
|
4015
|
-
return /* @__PURE__ */ (0,
|
|
4685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ThreadVariantProvider, { value: variant, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4016
4686
|
ArtifactRegistryProvider,
|
|
4017
4687
|
{
|
|
4018
4688
|
renderers: artifacts?.renderers,
|
|
4019
4689
|
override: artifacts?.override,
|
|
4020
|
-
children: /* @__PURE__ */ (0,
|
|
4021
|
-
}), children: /* @__PURE__ */ (0,
|
|
4022
|
-
|
|
4690
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(UiEventProvider, { onEvent: onArtifactEvent ?? (() => {
|
|
4691
|
+
}), children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4692
|
+
import_react31.ThreadPrimitive.Root,
|
|
4023
4693
|
{
|
|
4024
4694
|
className: cn(
|
|
4025
4695
|
"aui-root aui-thread-root @container flex h-full flex-col bg-transparent",
|
|
@@ -4028,8 +4698,8 @@ var Thread = ({
|
|
|
4028
4698
|
),
|
|
4029
4699
|
style: { ["--thread-max-width"]: maxWidth },
|
|
4030
4700
|
"data-thread-variant": variant,
|
|
4031
|
-
children: /* @__PURE__ */ (0,
|
|
4032
|
-
|
|
4701
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4702
|
+
import_react31.ThreadPrimitive.Viewport,
|
|
4033
4703
|
{
|
|
4034
4704
|
turnAnchor: "bottom",
|
|
4035
4705
|
className: cn(
|
|
@@ -4037,7 +4707,7 @@ var Thread = ({
|
|
|
4037
4707
|
isPanel ? "px-2 pt-2" : "px-4 pt-4"
|
|
4038
4708
|
),
|
|
4039
4709
|
children: [
|
|
4040
|
-
/* @__PURE__ */ (0,
|
|
4710
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4041
4711
|
WelcomeSlot,
|
|
4042
4712
|
{
|
|
4043
4713
|
config: welcome,
|
|
@@ -4046,8 +4716,8 @@ var Thread = ({
|
|
|
4046
4716
|
Suggestions: SuggestionsSlot
|
|
4047
4717
|
}
|
|
4048
4718
|
),
|
|
4049
|
-
/* @__PURE__ */ (0,
|
|
4050
|
-
|
|
4719
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4720
|
+
import_react31.ThreadPrimitive.Messages,
|
|
4051
4721
|
{
|
|
4052
4722
|
components: {
|
|
4053
4723
|
UserMessage: UserMessageSlot,
|
|
@@ -4056,14 +4726,14 @@ var Thread = ({
|
|
|
4056
4726
|
}
|
|
4057
4727
|
}
|
|
4058
4728
|
),
|
|
4059
|
-
/* @__PURE__ */ (0,
|
|
4060
|
-
|
|
4729
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4730
|
+
import_react31.ThreadPrimitive.ViewportFooter,
|
|
4061
4731
|
{
|
|
4062
4732
|
className: cn(
|
|
4063
4733
|
"aui-thread-viewport-footer sticky bottom-0 z-10 mt-auto w-full isolate pt-2",
|
|
4064
4734
|
isPanel ? "bg-card pb-2" : "bg-background pb-4 md:pb-6"
|
|
4065
4735
|
),
|
|
4066
|
-
children: /* @__PURE__ */ (0,
|
|
4736
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4067
4737
|
"div",
|
|
4068
4738
|
{
|
|
4069
4739
|
className: cn(
|
|
@@ -4071,8 +4741,8 @@ var Thread = ({
|
|
|
4071
4741
|
isPanel ? "gap-2" : "gap-4"
|
|
4072
4742
|
),
|
|
4073
4743
|
children: [
|
|
4074
|
-
/* @__PURE__ */ (0,
|
|
4075
|
-
/* @__PURE__ */ (0,
|
|
4744
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ScrollToBottomSlot, {}),
|
|
4745
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ComposerSlot, { placeholder })
|
|
4076
4746
|
]
|
|
4077
4747
|
}
|
|
4078
4748
|
)
|
|
@@ -4087,13 +4757,13 @@ var Thread = ({
|
|
|
4087
4757
|
) });
|
|
4088
4758
|
};
|
|
4089
4759
|
var ThreadScrollToBottom = () => {
|
|
4090
|
-
return /* @__PURE__ */ (0,
|
|
4760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ThreadPrimitive.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4091
4761
|
TooltipIconButton,
|
|
4092
4762
|
{
|
|
4093
4763
|
tooltip: "Scroll to bottom",
|
|
4094
4764
|
variant: "secondary",
|
|
4095
4765
|
className: "aui-thread-scroll-to-bottom absolute -top-12 z-10 self-center disabled:invisible",
|
|
4096
|
-
children: /* @__PURE__ */ (0,
|
|
4766
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.ArrowDownIcon, { className: "size-4" })
|
|
4097
4767
|
}
|
|
4098
4768
|
) });
|
|
4099
4769
|
};
|
|
@@ -4126,15 +4796,15 @@ var ThreadWelcome = ({
|
|
|
4126
4796
|
showWelcomeSuggestions: showWelcomeSuggestionsProp,
|
|
4127
4797
|
Suggestions: SuggestionsSlot = Suggestions
|
|
4128
4798
|
}) => {
|
|
4129
|
-
const isEmpty = (0,
|
|
4799
|
+
const isEmpty = (0, import_react31.useThread)((s) => s.messages.length === 0);
|
|
4130
4800
|
const isPanel = useThreadVariant() === "panel";
|
|
4131
4801
|
const showWelcomeSuggestions = showWelcomeSuggestionsProp ?? !isPanel;
|
|
4132
4802
|
if (!isEmpty) return null;
|
|
4133
4803
|
const defaultHeading = isPanel ? "Ask about this page" : "How can I help you today?";
|
|
4134
4804
|
const defaultSubheading = isPanel ? "The assistant can use dashboard context from your app." : "Send a message to start a conversation.";
|
|
4135
|
-
return /* @__PURE__ */ (0,
|
|
4136
|
-
/* @__PURE__ */ (0,
|
|
4137
|
-
|
|
4805
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: [
|
|
4806
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4807
|
+
import_react32.motion.div,
|
|
4138
4808
|
{
|
|
4139
4809
|
className: cn(
|
|
4140
4810
|
"aui-thread-welcome-message flex flex-col items-center justify-center text-center",
|
|
@@ -4144,9 +4814,9 @@ var ThreadWelcome = ({
|
|
|
4144
4814
|
initial: "initial",
|
|
4145
4815
|
animate: "animate",
|
|
4146
4816
|
children: [
|
|
4147
|
-
config?.icon && /* @__PURE__ */ (0,
|
|
4148
|
-
/* @__PURE__ */ (0,
|
|
4149
|
-
|
|
4817
|
+
config?.icon && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react32.motion.div, { variants: welcomeIcon, className: isPanel ? "mb-3" : "mb-5", children: config.icon }),
|
|
4818
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4819
|
+
import_react32.motion.h1,
|
|
4150
4820
|
{
|
|
4151
4821
|
variants: welcomeItem,
|
|
4152
4822
|
className: cn(
|
|
@@ -4156,8 +4826,8 @@ var ThreadWelcome = ({
|
|
|
4156
4826
|
children: config?.heading ?? defaultHeading
|
|
4157
4827
|
}
|
|
4158
4828
|
),
|
|
4159
|
-
/* @__PURE__ */ (0,
|
|
4160
|
-
|
|
4829
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4830
|
+
import_react32.motion.p,
|
|
4161
4831
|
{
|
|
4162
4832
|
variants: welcomeItem,
|
|
4163
4833
|
className: "aui-thread-welcome-message-inner mt-1.5 text-muted-foreground text-sm",
|
|
@@ -4167,16 +4837,16 @@ var ThreadWelcome = ({
|
|
|
4167
4837
|
]
|
|
4168
4838
|
}
|
|
4169
4839
|
) }),
|
|
4170
|
-
showWelcomeSuggestions && suggestions ? /* @__PURE__ */ (0,
|
|
4840
|
+
showWelcomeSuggestions && suggestions ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "aui-thread-welcome-suggestions mx-auto w-full max-w-(--thread-max-width) px-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(SuggestionsSlot, { suggestions }) }) : null
|
|
4171
4841
|
] });
|
|
4172
4842
|
};
|
|
4173
4843
|
var MessageError = () => {
|
|
4174
|
-
return /* @__PURE__ */ (0,
|
|
4844
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.MessagePrimitive.Error, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ErrorPrimitive.Root, { className: "aui-message-error-root mt-2 rounded-md border border-destructive bg-destructive/10 p-3 text-destructive text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ErrorPrimitive.Message, { className: "aui-message-error-message line-clamp-2" }) }) });
|
|
4175
4845
|
};
|
|
4176
4846
|
var AssistantMessage = () => {
|
|
4177
4847
|
const isPanel = useThreadVariant() === "panel";
|
|
4178
|
-
return /* @__PURE__ */ (0,
|
|
4179
|
-
|
|
4848
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4849
|
+
import_react31.MessagePrimitive.Root,
|
|
4180
4850
|
{
|
|
4181
4851
|
className: cn(
|
|
4182
4852
|
"aui-assistant-message-root fade-in slide-in-from-bottom-1 relative mx-auto w-full max-w-(--thread-max-width) animate-in duration-150",
|
|
@@ -4184,7 +4854,7 @@ var AssistantMessage = () => {
|
|
|
4184
4854
|
),
|
|
4185
4855
|
"data-role": "assistant",
|
|
4186
4856
|
children: [
|
|
4187
|
-
/* @__PURE__ */ (0,
|
|
4857
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4188
4858
|
"div",
|
|
4189
4859
|
{
|
|
4190
4860
|
className: cn(
|
|
@@ -4192,8 +4862,8 @@ var AssistantMessage = () => {
|
|
|
4192
4862
|
isPanel ? "px-1 text-sm" : "px-2"
|
|
4193
4863
|
),
|
|
4194
4864
|
children: [
|
|
4195
|
-
/* @__PURE__ */ (0,
|
|
4196
|
-
|
|
4865
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4866
|
+
import_react31.MessagePrimitive.Parts,
|
|
4197
4867
|
{
|
|
4198
4868
|
components: {
|
|
4199
4869
|
Text: MarkdownText,
|
|
@@ -4203,11 +4873,11 @@ var AssistantMessage = () => {
|
|
|
4203
4873
|
}
|
|
4204
4874
|
}
|
|
4205
4875
|
),
|
|
4206
|
-
/* @__PURE__ */ (0,
|
|
4876
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(MessageError, {})
|
|
4207
4877
|
]
|
|
4208
4878
|
}
|
|
4209
4879
|
),
|
|
4210
|
-
/* @__PURE__ */ (0,
|
|
4880
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "aui-assistant-message-footer mt-1 mb-3 ml-1 flex", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(AssistantActionBar, {}) })
|
|
4211
4881
|
]
|
|
4212
4882
|
}
|
|
4213
4883
|
);
|
|
@@ -4220,36 +4890,36 @@ var ASSISTANT_ACTION_ICON_CLASS = cn(
|
|
|
4220
4890
|
"[&>span:first-child]:group-hover/tbv2:bg-ghost-fill-hover"
|
|
4221
4891
|
);
|
|
4222
4892
|
var AssistantActionBar = () => {
|
|
4223
|
-
return /* @__PURE__ */ (0,
|
|
4224
|
-
|
|
4893
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4894
|
+
import_react31.ActionBarPrimitive.Root,
|
|
4225
4895
|
{
|
|
4226
4896
|
hideWhenRunning: true,
|
|
4227
4897
|
autohide: "never",
|
|
4228
4898
|
className: "aui-assistant-action-bar-root flex items-center gap-0 bg-transparent px-0 py-0.5 text-muted-foreground/60",
|
|
4229
4899
|
children: [
|
|
4230
|
-
/* @__PURE__ */ (0,
|
|
4900
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarPrimitive.Copy, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4231
4901
|
TooltipIconButton,
|
|
4232
4902
|
{
|
|
4233
4903
|
tooltip: "Copy",
|
|
4234
4904
|
variant: "ghost",
|
|
4235
4905
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
4236
4906
|
children: [
|
|
4237
|
-
/* @__PURE__ */ (0,
|
|
4238
|
-
/* @__PURE__ */ (0,
|
|
4907
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.AuiIf, { condition: (s) => s.message.isCopied, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.CheckIcon, { className: "size-3" }) }),
|
|
4908
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.AuiIf, { condition: (s) => !s.message.isCopied, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.CopyIcon, { className: "size-3" }) })
|
|
4239
4909
|
]
|
|
4240
4910
|
}
|
|
4241
4911
|
) }),
|
|
4242
|
-
/* @__PURE__ */ (0,
|
|
4912
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarPrimitive.Reload, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4243
4913
|
TooltipIconButton,
|
|
4244
4914
|
{
|
|
4245
4915
|
tooltip: "Regenerate",
|
|
4246
4916
|
variant: "ghost",
|
|
4247
4917
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
4248
|
-
children: /* @__PURE__ */ (0,
|
|
4918
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.RefreshCwIcon, { className: "size-3" })
|
|
4249
4919
|
}
|
|
4250
4920
|
) }),
|
|
4251
|
-
/* @__PURE__ */ (0,
|
|
4252
|
-
/* @__PURE__ */ (0,
|
|
4921
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_react31.ActionBarMorePrimitive.Root, { children: [
|
|
4922
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarMorePrimitive.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4253
4923
|
TooltipIconButton,
|
|
4254
4924
|
{
|
|
4255
4925
|
tooltip: "More",
|
|
@@ -4258,17 +4928,17 @@ var AssistantActionBar = () => {
|
|
|
4258
4928
|
ASSISTANT_ACTION_ICON_CLASS,
|
|
4259
4929
|
"data-[state=open]:text-muted-foreground/80"
|
|
4260
4930
|
),
|
|
4261
|
-
children: /* @__PURE__ */ (0,
|
|
4931
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.MoreHorizontalIcon, { className: "size-3" })
|
|
4262
4932
|
}
|
|
4263
4933
|
) }),
|
|
4264
|
-
/* @__PURE__ */ (0,
|
|
4265
|
-
|
|
4934
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4935
|
+
import_react31.ActionBarMorePrimitive.Content,
|
|
4266
4936
|
{
|
|
4267
4937
|
side: "bottom",
|
|
4268
4938
|
align: "start",
|
|
4269
4939
|
className: "aui-action-bar-more-content z-50 min-w-36 overflow-hidden rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-card-elevated",
|
|
4270
|
-
children: /* @__PURE__ */ (0,
|
|
4271
|
-
/* @__PURE__ */ (0,
|
|
4940
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarPrimitive.ExportMarkdown, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_react31.ActionBarMorePrimitive.Item, { className: "aui-action-bar-more-item flex cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-none hover:bg-muted focus:bg-muted", children: [
|
|
4941
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.DownloadIcon, { className: "size-4 shrink-0" }),
|
|
4272
4942
|
"Export as Markdown"
|
|
4273
4943
|
] }) })
|
|
4274
4944
|
}
|
|
@@ -4279,12 +4949,12 @@ var AssistantActionBar = () => {
|
|
|
4279
4949
|
);
|
|
4280
4950
|
};
|
|
4281
4951
|
var UserMessageText = () => {
|
|
4282
|
-
return /* @__PURE__ */ (0,
|
|
4952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "whitespace-pre-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.MessagePartPrimitive.Text, { smooth: false }) });
|
|
4283
4953
|
};
|
|
4284
4954
|
var UserMessage = () => {
|
|
4285
4955
|
const isPanel = useThreadVariant() === "panel";
|
|
4286
|
-
return /* @__PURE__ */ (0,
|
|
4287
|
-
|
|
4956
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4957
|
+
import_react31.MessagePrimitive.Root,
|
|
4288
4958
|
{
|
|
4289
4959
|
className: cn(
|
|
4290
4960
|
"aui-user-message-root mx-auto flex w-full max-w-(--thread-max-width) flex-col items-end gap-2",
|
|
@@ -4292,9 +4962,9 @@ var UserMessage = () => {
|
|
|
4292
4962
|
),
|
|
4293
4963
|
"data-role": "user",
|
|
4294
4964
|
children: [
|
|
4295
|
-
/* @__PURE__ */ (0,
|
|
4296
|
-
/* @__PURE__ */ (0,
|
|
4297
|
-
|
|
4965
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(UserMessageAttachments, {}),
|
|
4966
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
4967
|
+
import_react32.motion.div,
|
|
4298
4968
|
{
|
|
4299
4969
|
className: cn(
|
|
4300
4970
|
"aui-user-message-content relative inline-block max-w-[85%] rounded-2xl bg-bubble-user text-bubble-user-foreground",
|
|
@@ -4304,8 +4974,8 @@ var UserMessage = () => {
|
|
|
4304
4974
|
animate: { opacity: 1, y: 0, scale: 1 },
|
|
4305
4975
|
transition: { duration: 0.65, ease: luxuryEase },
|
|
4306
4976
|
children: [
|
|
4307
|
-
/* @__PURE__ */ (0,
|
|
4308
|
-
/* @__PURE__ */ (0,
|
|
4977
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.MessagePrimitive.Parts, { components: { Text: UserMessageText } }),
|
|
4978
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(UserActionBar, {}) })
|
|
4309
4979
|
]
|
|
4310
4980
|
}
|
|
4311
4981
|
)
|
|
@@ -4314,42 +4984,42 @@ var UserMessage = () => {
|
|
|
4314
4984
|
);
|
|
4315
4985
|
};
|
|
4316
4986
|
var UserActionBar = () => {
|
|
4317
|
-
return /* @__PURE__ */ (0,
|
|
4318
|
-
|
|
4987
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4988
|
+
import_react31.ActionBarPrimitive.Root,
|
|
4319
4989
|
{
|
|
4320
4990
|
hideWhenRunning: true,
|
|
4321
4991
|
autohide: "always",
|
|
4322
4992
|
className: "aui-user-action-bar-root flex flex-col items-end",
|
|
4323
|
-
children: /* @__PURE__ */ (0,
|
|
4993
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ActionBarPrimitive.Edit, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4324
4994
|
TooltipIconButton,
|
|
4325
4995
|
{
|
|
4326
4996
|
tooltip: "Edit",
|
|
4327
4997
|
variant: "ghost",
|
|
4328
4998
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
4329
|
-
children: /* @__PURE__ */ (0,
|
|
4999
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_lucide_react8.PencilIcon, { className: "size-3" })
|
|
4330
5000
|
}
|
|
4331
5001
|
) })
|
|
4332
5002
|
}
|
|
4333
5003
|
);
|
|
4334
5004
|
};
|
|
4335
5005
|
var EditComposer = () => {
|
|
4336
|
-
return /* @__PURE__ */ (0,
|
|
4337
|
-
/* @__PURE__ */ (0,
|
|
4338
|
-
|
|
5006
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.MessagePrimitive.Root, { className: "aui-edit-composer-wrapper mx-auto flex w-full max-w-(--thread-max-width) flex-col px-2 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_react31.ComposerPrimitive.Root, { className: "aui-edit-composer-root ml-auto flex w-full max-w-[85%] flex-col rounded-2xl bg-muted", children: [
|
|
5007
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
5008
|
+
import_react31.ComposerPrimitive.Input,
|
|
4339
5009
|
{
|
|
4340
5010
|
className: "aui-edit-composer-input min-h-14 w-full resize-none bg-transparent p-4 text-foreground text-sm outline-none",
|
|
4341
5011
|
autoFocus: true
|
|
4342
5012
|
}
|
|
4343
5013
|
),
|
|
4344
|
-
/* @__PURE__ */ (0,
|
|
4345
|
-
/* @__PURE__ */ (0,
|
|
4346
|
-
/* @__PURE__ */ (0,
|
|
5014
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "aui-edit-composer-footer mx-3 mb-3 flex items-center gap-2 self-end", children: [
|
|
5015
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(TimbalV2Button, { variant: "ghost", size: "sm", children: "Cancel" }) }),
|
|
5016
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react31.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(TimbalV2Button, { variant: "primary", size: "sm", children: "Update" }) })
|
|
4347
5017
|
] })
|
|
4348
5018
|
] }) });
|
|
4349
5019
|
};
|
|
4350
5020
|
|
|
4351
5021
|
// src/chat/chat.tsx
|
|
4352
|
-
var
|
|
5022
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
4353
5023
|
function TimbalChat({
|
|
4354
5024
|
workforceId,
|
|
4355
5025
|
baseUrl,
|
|
@@ -4360,7 +5030,7 @@ function TimbalChat({
|
|
|
4360
5030
|
debug,
|
|
4361
5031
|
...threadProps
|
|
4362
5032
|
}) {
|
|
4363
|
-
return /* @__PURE__ */ (0,
|
|
5033
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
4364
5034
|
TimbalRuntimeProvider,
|
|
4365
5035
|
{
|
|
4366
5036
|
workforceId,
|
|
@@ -4370,7 +5040,7 @@ function TimbalChat({
|
|
|
4370
5040
|
attachmentsUploadUrl,
|
|
4371
5041
|
attachmentsAccept,
|
|
4372
5042
|
debug,
|
|
4373
|
-
children: /* @__PURE__ */ (0,
|
|
5043
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Thread, { ...threadProps })
|
|
4374
5044
|
}
|
|
4375
5045
|
);
|
|
4376
5046
|
}
|
|
@@ -4399,7 +5069,7 @@ var overlayListPanelClass = cn(
|
|
|
4399
5069
|
);
|
|
4400
5070
|
|
|
4401
5071
|
// src/chat/workforce-selector.tsx
|
|
4402
|
-
var
|
|
5072
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
4403
5073
|
var WorkforceSelector = ({
|
|
4404
5074
|
workforces,
|
|
4405
5075
|
value,
|
|
@@ -4410,7 +5080,7 @@ var WorkforceSelector = ({
|
|
|
4410
5080
|
}) => {
|
|
4411
5081
|
if (workforces.length === 0) return null;
|
|
4412
5082
|
if (hideWhenSingle && workforces.length === 1) return null;
|
|
4413
|
-
return /* @__PURE__ */ (0,
|
|
5083
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
4414
5084
|
"div",
|
|
4415
5085
|
{
|
|
4416
5086
|
className: cn(
|
|
@@ -4421,7 +5091,7 @@ var WorkforceSelector = ({
|
|
|
4421
5091
|
className
|
|
4422
5092
|
),
|
|
4423
5093
|
children: [
|
|
4424
|
-
/* @__PURE__ */ (0,
|
|
5094
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
4425
5095
|
"select",
|
|
4426
5096
|
{
|
|
4427
5097
|
className: "aui-workforce-selector-input h-full cursor-pointer appearance-none rounded-full border-none bg-transparent pr-8 pl-3.5 text-sm font-medium text-foreground outline-none focus:outline-none",
|
|
@@ -4429,15 +5099,15 @@ var WorkforceSelector = ({
|
|
|
4429
5099
|
onChange: (e) => onChange(e.target.value),
|
|
4430
5100
|
"aria-label": placeholder,
|
|
4431
5101
|
children: [
|
|
4432
|
-
!value && /* @__PURE__ */ (0,
|
|
5102
|
+
!value && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("option", { value: "", children: placeholder }),
|
|
4433
5103
|
workforces.map((w) => {
|
|
4434
5104
|
const id = idOf(w);
|
|
4435
|
-
return /* @__PURE__ */ (0,
|
|
5105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("option", { value: id, children: w.name ?? id }, id);
|
|
4436
5106
|
})
|
|
4437
5107
|
]
|
|
4438
5108
|
}
|
|
4439
5109
|
),
|
|
4440
|
-
/* @__PURE__ */ (0,
|
|
5110
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
4441
5111
|
import_lucide_react9.ChevronDownIcon,
|
|
4442
5112
|
{
|
|
4443
5113
|
className: "aui-workforce-selector-icon pointer-events-none absolute right-3 size-3.5 text-muted-foreground/70",
|
|
@@ -4453,22 +5123,22 @@ function idOf(item) {
|
|
|
4453
5123
|
}
|
|
4454
5124
|
|
|
4455
5125
|
// src/hooks/use-workforces.ts
|
|
4456
|
-
var
|
|
5126
|
+
var import_react33 = require("react");
|
|
4457
5127
|
function useWorkforces(options = {}) {
|
|
4458
5128
|
const { baseUrl = "/api", fetch: fetchFn, pickInitial, enabled = true } = options;
|
|
4459
|
-
const [workforces, setWorkforces] = (0,
|
|
4460
|
-
const [selectedId, setSelectedId] = (0,
|
|
4461
|
-
const [isLoading, setIsLoading] = (0,
|
|
4462
|
-
const [error, setError] = (0,
|
|
4463
|
-
const fetchFnRef = (0,
|
|
4464
|
-
(0,
|
|
5129
|
+
const [workforces, setWorkforces] = (0, import_react33.useState)([]);
|
|
5130
|
+
const [selectedId, setSelectedId] = (0, import_react33.useState)("");
|
|
5131
|
+
const [isLoading, setIsLoading] = (0, import_react33.useState)(enabled);
|
|
5132
|
+
const [error, setError] = (0, import_react33.useState)(null);
|
|
5133
|
+
const fetchFnRef = (0, import_react33.useRef)(fetchFn ?? authFetch);
|
|
5134
|
+
(0, import_react33.useEffect)(() => {
|
|
4465
5135
|
fetchFnRef.current = fetchFn ?? authFetch;
|
|
4466
5136
|
}, [fetchFn]);
|
|
4467
|
-
const pickInitialRef = (0,
|
|
4468
|
-
(0,
|
|
5137
|
+
const pickInitialRef = (0, import_react33.useRef)(pickInitial);
|
|
5138
|
+
(0, import_react33.useEffect)(() => {
|
|
4469
5139
|
pickInitialRef.current = pickInitial;
|
|
4470
5140
|
}, [pickInitial]);
|
|
4471
|
-
const load = (0,
|
|
5141
|
+
const load = (0, import_react33.useMemo)(() => {
|
|
4472
5142
|
return async () => {
|
|
4473
5143
|
if (!enabled) {
|
|
4474
5144
|
setIsLoading(false);
|
|
@@ -4493,10 +5163,10 @@ function useWorkforces(options = {}) {
|
|
|
4493
5163
|
}
|
|
4494
5164
|
};
|
|
4495
5165
|
}, [baseUrl, enabled]);
|
|
4496
|
-
(0,
|
|
5166
|
+
(0, import_react33.useEffect)(() => {
|
|
4497
5167
|
load();
|
|
4498
5168
|
}, [load]);
|
|
4499
|
-
const selected = (0,
|
|
5169
|
+
const selected = (0, import_react33.useMemo)(
|
|
4500
5170
|
() => workforces.find((w) => idOf2(w) === selectedId),
|
|
4501
5171
|
[workforces, selectedId]
|
|
4502
5172
|
);
|
|
@@ -4560,7 +5230,7 @@ var DOM_IDS = {
|
|
|
4560
5230
|
};
|
|
4561
5231
|
|
|
4562
5232
|
// src/studio/shell/chat-shell.tsx
|
|
4563
|
-
var
|
|
5233
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
4564
5234
|
var TimbalChatShell = ({
|
|
4565
5235
|
workforceId,
|
|
4566
5236
|
brand,
|
|
@@ -4578,7 +5248,7 @@ var TimbalChatShell = ({
|
|
|
4578
5248
|
});
|
|
4579
5249
|
const effectiveId = workforceId ?? selectedId;
|
|
4580
5250
|
const showSelector = !hideWorkforceSelector && !workforceId && workforces.length > 0;
|
|
4581
|
-
return /* @__PURE__ */ (0,
|
|
5251
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
4582
5252
|
"div",
|
|
4583
5253
|
{
|
|
4584
5254
|
className: cn(
|
|
@@ -4587,7 +5257,7 @@ var TimbalChatShell = ({
|
|
|
4587
5257
|
),
|
|
4588
5258
|
style: studioChromeShellStyle,
|
|
4589
5259
|
children: [
|
|
4590
|
-
/* @__PURE__ */ (0,
|
|
5260
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4591
5261
|
"div",
|
|
4592
5262
|
{
|
|
4593
5263
|
className: cn(
|
|
@@ -4597,7 +5267,7 @@ var TimbalChatShell = ({
|
|
|
4597
5267
|
"aria-hidden": true
|
|
4598
5268
|
}
|
|
4599
5269
|
),
|
|
4600
|
-
/* @__PURE__ */ (0,
|
|
5270
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
4601
5271
|
"header",
|
|
4602
5272
|
{
|
|
4603
5273
|
className: cn(
|
|
@@ -4606,9 +5276,9 @@ var TimbalChatShell = ({
|
|
|
4606
5276
|
),
|
|
4607
5277
|
style: { minHeight: "var(--studio-topbar-height)" },
|
|
4608
5278
|
children: [
|
|
4609
|
-
/* @__PURE__ */ (0,
|
|
5279
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
4610
5280
|
brand,
|
|
4611
|
-
showSelector && /* @__PURE__ */ (0,
|
|
5281
|
+
showSelector && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4612
5282
|
WorkforceSelector,
|
|
4613
5283
|
{
|
|
4614
5284
|
workforces,
|
|
@@ -4617,11 +5287,11 @@ var TimbalChatShell = ({
|
|
|
4617
5287
|
}
|
|
4618
5288
|
)
|
|
4619
5289
|
] }),
|
|
4620
|
-
/* @__PURE__ */ (0,
|
|
5290
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "flex shrink-0 items-center gap-1", children: headerActions })
|
|
4621
5291
|
]
|
|
4622
5292
|
}
|
|
4623
5293
|
),
|
|
4624
|
-
/* @__PURE__ */ (0,
|
|
5294
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4625
5295
|
TimbalChat,
|
|
4626
5296
|
{
|
|
4627
5297
|
workforceId: effectiveId,
|
|
@@ -4638,9 +5308,9 @@ var TimbalChatShell = ({
|
|
|
4638
5308
|
};
|
|
4639
5309
|
|
|
4640
5310
|
// src/studio/shell/studio-shell.tsx
|
|
4641
|
-
var
|
|
5311
|
+
var import_react48 = require("react");
|
|
4642
5312
|
var import_lucide_react13 = require("lucide-react");
|
|
4643
|
-
var
|
|
5313
|
+
var import_react49 = require("motion/react");
|
|
4644
5314
|
|
|
4645
5315
|
// src/design/sidebar-motion.ts
|
|
4646
5316
|
var STUDIO_SIDEBAR_EASE_ENTER = [0, 0, 0.2, 1];
|
|
@@ -4711,16 +5381,16 @@ function studioSidebarBackdropTransition(reduced) {
|
|
|
4711
5381
|
}
|
|
4712
5382
|
|
|
4713
5383
|
// src/hooks/use-sidebar-collapse-phase.ts
|
|
4714
|
-
var
|
|
5384
|
+
var import_react34 = require("react");
|
|
4715
5385
|
var WIDTH_OVERLAP_FRAC = 0.7;
|
|
4716
5386
|
function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
4717
|
-
const [widthCollapsed, setWidthCollapsed] = (0,
|
|
4718
|
-
const [entriesVisible, setEntriesVisible] = (0,
|
|
4719
|
-
const collapsedTarget = (0,
|
|
4720
|
-
const isFirstRender = (0,
|
|
4721
|
-
const widthTimerRef = (0,
|
|
4722
|
-
const revealTimerRef = (0,
|
|
4723
|
-
(0,
|
|
5387
|
+
const [widthCollapsed, setWidthCollapsed] = (0, import_react34.useState)(collapsed);
|
|
5388
|
+
const [entriesVisible, setEntriesVisible] = (0, import_react34.useState)(true);
|
|
5389
|
+
const collapsedTarget = (0, import_react34.useRef)(collapsed);
|
|
5390
|
+
const isFirstRender = (0, import_react34.useRef)(true);
|
|
5391
|
+
const widthTimerRef = (0, import_react34.useRef)(null);
|
|
5392
|
+
const revealTimerRef = (0, import_react34.useRef)(null);
|
|
5393
|
+
(0, import_react34.useEffect)(() => {
|
|
4724
5394
|
collapsedTarget.current = collapsed;
|
|
4725
5395
|
}, [collapsed]);
|
|
4726
5396
|
const clearWidthTimer = () => {
|
|
@@ -4735,7 +5405,7 @@ function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
|
4735
5405
|
revealTimerRef.current = null;
|
|
4736
5406
|
}
|
|
4737
5407
|
};
|
|
4738
|
-
const applyWidthTarget = (0,
|
|
5408
|
+
const applyWidthTarget = (0, import_react34.useCallback)(() => {
|
|
4739
5409
|
const willExpand = !collapsedTarget.current;
|
|
4740
5410
|
setWidthCollapsed(collapsedTarget.current);
|
|
4741
5411
|
clearRevealTimer();
|
|
@@ -4746,7 +5416,7 @@ function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
|
4746
5416
|
);
|
|
4747
5417
|
}
|
|
4748
5418
|
}, [reducedMotion]);
|
|
4749
|
-
(0,
|
|
5419
|
+
(0, import_react34.useEffect)(() => {
|
|
4750
5420
|
clearWidthTimer();
|
|
4751
5421
|
clearRevealTimer();
|
|
4752
5422
|
if (reducedMotion) {
|
|
@@ -4770,10 +5440,10 @@ function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
|
4770
5440
|
clearRevealTimer();
|
|
4771
5441
|
};
|
|
4772
5442
|
}, [collapsed, reducedMotion, applyWidthTarget]);
|
|
4773
|
-
const onEntriesBlurOutComplete = (0,
|
|
5443
|
+
const onEntriesBlurOutComplete = (0, import_react34.useCallback)(() => {
|
|
4774
5444
|
applyWidthTarget();
|
|
4775
5445
|
}, [applyWidthTarget]);
|
|
4776
|
-
const onPanelWidthComplete = (0,
|
|
5446
|
+
const onPanelWidthComplete = (0, import_react34.useCallback)(() => {
|
|
4777
5447
|
clearRevealTimer();
|
|
4778
5448
|
setEntriesVisible(true);
|
|
4779
5449
|
}, []);
|
|
@@ -4788,15 +5458,15 @@ function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
|
4788
5458
|
}
|
|
4789
5459
|
|
|
4790
5460
|
// src/studio/sidebar/sidebar-backdrop.tsx
|
|
4791
|
-
var
|
|
4792
|
-
var
|
|
5461
|
+
var import_react35 = require("motion/react");
|
|
5462
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
4793
5463
|
var StudioSidebarBackdrop = ({
|
|
4794
5464
|
open,
|
|
4795
5465
|
onClose
|
|
4796
5466
|
}) => {
|
|
4797
|
-
const reducedMotion = (0,
|
|
4798
|
-
return /* @__PURE__ */ (0,
|
|
4799
|
-
|
|
5467
|
+
const reducedMotion = (0, import_react35.useReducedMotion)();
|
|
5468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_react35.AnimatePresence, { children: open ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
5469
|
+
import_react35.motion.button,
|
|
4800
5470
|
{
|
|
4801
5471
|
type: "button",
|
|
4802
5472
|
className: "fixed inset-0 z-40 bg-foreground/30 backdrop-blur-[2px] md:hidden",
|
|
@@ -4811,36 +5481,36 @@ var StudioSidebarBackdrop = ({
|
|
|
4811
5481
|
};
|
|
4812
5482
|
|
|
4813
5483
|
// src/studio/sidebar/sidebar-context.tsx
|
|
4814
|
-
var
|
|
4815
|
-
var StudioSidebarContext = (0,
|
|
5484
|
+
var import_react36 = require("react");
|
|
5485
|
+
var StudioSidebarContext = (0, import_react36.createContext)({
|
|
4816
5486
|
collapsed: false,
|
|
4817
5487
|
isMobile: false,
|
|
4818
5488
|
isCollapsedRail: false,
|
|
4819
5489
|
iconOnlyLayout: false
|
|
4820
5490
|
});
|
|
4821
5491
|
function useStudioSidebarLayout() {
|
|
4822
|
-
return (0,
|
|
5492
|
+
return (0, import_react36.useContext)(StudioSidebarContext);
|
|
4823
5493
|
}
|
|
4824
5494
|
|
|
4825
5495
|
// src/studio/sidebar/sidebar.tsx
|
|
4826
|
-
var
|
|
4827
|
-
var
|
|
5496
|
+
var import_react42 = require("react");
|
|
5497
|
+
var import_react43 = require("motion/react");
|
|
4828
5498
|
|
|
4829
5499
|
// src/studio/sidebar/sidebar-entries.tsx
|
|
4830
|
-
var
|
|
4831
|
-
var
|
|
5500
|
+
var import_react37 = require("motion/react");
|
|
5501
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
4832
5502
|
var StudioSidebarEntries = ({
|
|
4833
5503
|
visible,
|
|
4834
5504
|
onBlurOutComplete,
|
|
4835
5505
|
children,
|
|
4836
5506
|
className
|
|
4837
5507
|
}) => {
|
|
4838
|
-
const reducedMotion = (0,
|
|
5508
|
+
const reducedMotion = (0, import_react37.useReducedMotion)();
|
|
4839
5509
|
if (reducedMotion) {
|
|
4840
|
-
return visible ? /* @__PURE__ */ (0,
|
|
5510
|
+
return visible ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: cn("flex min-h-0 flex-1 flex-col", className), children }) : null;
|
|
4841
5511
|
}
|
|
4842
|
-
return /* @__PURE__ */ (0,
|
|
4843
|
-
|
|
5512
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
5513
|
+
import_react37.motion.div,
|
|
4844
5514
|
{
|
|
4845
5515
|
className: cn("flex min-h-0 flex-1 flex-col", className),
|
|
4846
5516
|
initial: false,
|
|
@@ -4863,11 +5533,11 @@ var StudioSidebarEntries = ({
|
|
|
4863
5533
|
var import_lucide_react10 = require("lucide-react");
|
|
4864
5534
|
|
|
4865
5535
|
// src/auth/provider.tsx
|
|
4866
|
-
var
|
|
4867
|
-
var
|
|
4868
|
-
var SessionContext = (0,
|
|
5536
|
+
var import_react38 = require("react");
|
|
5537
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
5538
|
+
var SessionContext = (0, import_react38.createContext)(void 0);
|
|
4869
5539
|
var useOptionalSession = () => {
|
|
4870
|
-
const context = (0,
|
|
5540
|
+
const context = (0, import_react38.useContext)(SessionContext);
|
|
4871
5541
|
return context ?? null;
|
|
4872
5542
|
};
|
|
4873
5543
|
|
|
@@ -4894,35 +5564,35 @@ function studioSidebarNavItemClasses(iconOnly, isActive) {
|
|
|
4894
5564
|
}
|
|
4895
5565
|
|
|
4896
5566
|
// src/studio/sidebar/sidebar-entry-motion.tsx
|
|
4897
|
-
var
|
|
4898
|
-
var
|
|
5567
|
+
var import_react39 = require("motion/react");
|
|
5568
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
4899
5569
|
var StudioSidebarEntryMotion = ({
|
|
4900
5570
|
children,
|
|
4901
5571
|
className
|
|
4902
5572
|
}) => {
|
|
4903
|
-
const reducedMotion = (0,
|
|
5573
|
+
const reducedMotion = (0, import_react39.useReducedMotion)();
|
|
4904
5574
|
if (reducedMotion) {
|
|
4905
|
-
return /* @__PURE__ */ (0,
|
|
5575
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className, children });
|
|
4906
5576
|
}
|
|
4907
|
-
return /* @__PURE__ */ (0,
|
|
5577
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_react39.motion.div, { variants: studioSidebarEntryItemVariants, className: cn(className), children });
|
|
4908
5578
|
};
|
|
4909
5579
|
|
|
4910
5580
|
// src/studio/sidebar/sidebar-tooltip.tsx
|
|
4911
|
-
var
|
|
5581
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
4912
5582
|
var StudioSidebarTooltip = ({
|
|
4913
5583
|
label,
|
|
4914
5584
|
enabled,
|
|
4915
5585
|
children
|
|
4916
5586
|
}) => {
|
|
4917
|
-
if (!enabled) return /* @__PURE__ */ (0,
|
|
4918
|
-
return /* @__PURE__ */ (0,
|
|
4919
|
-
/* @__PURE__ */ (0,
|
|
4920
|
-
/* @__PURE__ */ (0,
|
|
5587
|
+
if (!enabled) return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_jsx_runtime44.Fragment, { children });
|
|
5588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(Tooltip, { children: [
|
|
5589
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(TooltipTrigger, { asChild: true, children }),
|
|
5590
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(TooltipContent, { side: "right", className: "text-xs", children: label })
|
|
4921
5591
|
] });
|
|
4922
5592
|
};
|
|
4923
5593
|
|
|
4924
5594
|
// src/studio/sidebar/sidebar-footer.tsx
|
|
4925
|
-
var
|
|
5595
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
4926
5596
|
function userInitials(name, email) {
|
|
4927
5597
|
const fromName = name.trim().split(/\s+/).map((part) => part.charAt(0)).join("").slice(0, 2).toUpperCase();
|
|
4928
5598
|
if (fromName) return fromName;
|
|
@@ -4940,32 +5610,32 @@ var StudioSidebarFooter = ({
|
|
|
4940
5610
|
session?.logout();
|
|
4941
5611
|
onSignOut?.();
|
|
4942
5612
|
};
|
|
4943
|
-
return /* @__PURE__ */ (0,
|
|
5613
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(StudioSidebarEntryMotion, { children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
4944
5614
|
"footer",
|
|
4945
5615
|
{
|
|
4946
5616
|
className: cn(
|
|
4947
5617
|
"mt-auto w-full shrink-0 py-2.5",
|
|
4948
5618
|
iconOnlyLayout ? studioSidebarCollapsedRailInsetClass : "px-2.5"
|
|
4949
5619
|
),
|
|
4950
|
-
children: user ? /* @__PURE__ */ (0,
|
|
4951
|
-
iconOnlyLayout ? /* @__PURE__ */ (0,
|
|
4952
|
-
user.user_photo_url ? /* @__PURE__ */ (0,
|
|
4953
|
-
/* @__PURE__ */ (0,
|
|
4954
|
-
] }) }) : /* @__PURE__ */ (0,
|
|
4955
|
-
/* @__PURE__ */ (0,
|
|
4956
|
-
user.user_photo_url ? /* @__PURE__ */ (0,
|
|
4957
|
-
/* @__PURE__ */ (0,
|
|
5620
|
+
children: user ? /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
5621
|
+
iconOnlyLayout ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: studioSidebarCollapsedRailChipRowClass, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(Avatar, { size: "sm", className: "size-8", children: [
|
|
5622
|
+
user.user_photo_url ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(AvatarImage, { src: user.user_photo_url, alt: user.user_name }) : null,
|
|
5623
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(AvatarFallback, { className: "text-[10px]", children: userInitials(user.user_name, user.user_email) })
|
|
5624
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex min-w-0 items-center gap-2.5", children: [
|
|
5625
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(Avatar, { size: "sm", children: [
|
|
5626
|
+
user.user_photo_url ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(AvatarImage, { src: user.user_photo_url, alt: user.user_name }) : null,
|
|
5627
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(AvatarFallback, { children: userInitials(user.user_name, user.user_email) })
|
|
4958
5628
|
] }),
|
|
4959
|
-
/* @__PURE__ */ (0,
|
|
4960
|
-
/* @__PURE__ */ (0,
|
|
4961
|
-
/* @__PURE__ */ (0,
|
|
5629
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "min-w-0 flex-1", children: [
|
|
5630
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "truncate text-sm font-medium text-foreground", children: user.user_name }),
|
|
5631
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "truncate text-xs text-muted-foreground", children: user.user_email })
|
|
4962
5632
|
] })
|
|
4963
5633
|
] }),
|
|
4964
|
-
/* @__PURE__ */ (0,
|
|
5634
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
4965
5635
|
"div",
|
|
4966
5636
|
{
|
|
4967
5637
|
className: iconOnlyLayout ? studioSidebarCollapsedRailChipRowClass : void 0,
|
|
4968
|
-
children: /* @__PURE__ */ (0,
|
|
5638
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(StudioSidebarTooltip, { label: "Sign out", enabled: showTooltips, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
4969
5639
|
"button",
|
|
4970
5640
|
{
|
|
4971
5641
|
type: "button",
|
|
@@ -4976,28 +5646,28 @@ var StudioSidebarFooter = ({
|
|
|
4976
5646
|
),
|
|
4977
5647
|
"aria-label": "Sign out",
|
|
4978
5648
|
children: [
|
|
4979
|
-
/* @__PURE__ */ (0,
|
|
5649
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react10.LogOut, { className: "size-3.5 shrink-0" }),
|
|
4980
5650
|
!iconOnlyLayout ? "Sign out" : null
|
|
4981
5651
|
]
|
|
4982
5652
|
}
|
|
4983
5653
|
) })
|
|
4984
5654
|
}
|
|
4985
5655
|
)
|
|
4986
|
-
] }) : !iconOnlyLayout && emptyCaption ? /* @__PURE__ */ (0,
|
|
5656
|
+
] }) : !iconOnlyLayout && emptyCaption ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "px-1 text-xs text-muted-foreground", children: emptyCaption }) : null
|
|
4987
5657
|
}
|
|
4988
5658
|
) });
|
|
4989
5659
|
};
|
|
4990
5660
|
|
|
4991
5661
|
// src/studio/sidebar/sidebar-header.tsx
|
|
4992
5662
|
var import_lucide_react11 = require("lucide-react");
|
|
4993
|
-
var
|
|
5663
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
4994
5664
|
var sidebarHeaderClass = "flex h-12 shrink-0 items-center px-2";
|
|
4995
5665
|
var toggleButtonClass = cn(
|
|
4996
5666
|
"flex shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors",
|
|
4997
5667
|
"hover:bg-muted hover:text-foreground",
|
|
4998
5668
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/15"
|
|
4999
5669
|
);
|
|
5000
|
-
var SidebarToggleButton = ({ ariaLabel, expanded, onClick, children }) => /* @__PURE__ */ (0,
|
|
5670
|
+
var SidebarToggleButton = ({ ariaLabel, expanded, onClick, children }) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
5001
5671
|
"button",
|
|
5002
5672
|
{
|
|
5003
5673
|
type: "button",
|
|
@@ -5011,7 +5681,7 @@ var SidebarToggleButton = ({ ariaLabel, expanded, onClick, children }) => /* @__
|
|
|
5011
5681
|
var CollapsedBrandToggle = ({
|
|
5012
5682
|
onExpand,
|
|
5013
5683
|
brand
|
|
5014
|
-
}) => /* @__PURE__ */ (0,
|
|
5684
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: studioSidebarCollapsedRailChipRowClass, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(StudioSidebarTooltip, { label: "Expand sidebar", enabled: true, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
5015
5685
|
"button",
|
|
5016
5686
|
{
|
|
5017
5687
|
type: "button",
|
|
@@ -5023,7 +5693,7 @@ var CollapsedBrandToggle = ({
|
|
|
5023
5693
|
"group relative inline-flex size-8 items-center justify-center overflow-hidden rounded-lg"
|
|
5024
5694
|
),
|
|
5025
5695
|
children: [
|
|
5026
|
-
/* @__PURE__ */ (0,
|
|
5696
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
5027
5697
|
"span",
|
|
5028
5698
|
{
|
|
5029
5699
|
"aria-hidden": true,
|
|
@@ -5035,7 +5705,7 @@ var CollapsedBrandToggle = ({
|
|
|
5035
5705
|
children: brand
|
|
5036
5706
|
}
|
|
5037
5707
|
),
|
|
5038
|
-
/* @__PURE__ */ (0,
|
|
5708
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
5039
5709
|
import_lucide_react11.ChevronRight,
|
|
5040
5710
|
{
|
|
5041
5711
|
"aria-hidden": true,
|
|
@@ -5057,40 +5727,40 @@ var StudioSidebarHeader = ({
|
|
|
5057
5727
|
brand
|
|
5058
5728
|
}) => {
|
|
5059
5729
|
if (isMobile) {
|
|
5060
|
-
return /* @__PURE__ */ (0,
|
|
5730
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("header", { className: cn(sidebarHeaderClass, "justify-between gap-2 pr-2"), children: [
|
|
5061
5731
|
brand,
|
|
5062
|
-
/* @__PURE__ */ (0,
|
|
5732
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
5063
5733
|
SidebarToggleButton,
|
|
5064
5734
|
{
|
|
5065
5735
|
ariaLabel: "Close menu",
|
|
5066
5736
|
expanded: mobileOpen,
|
|
5067
5737
|
onClick: onToggle,
|
|
5068
|
-
children: /* @__PURE__ */ (0,
|
|
5738
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_lucide_react11.X, { className: "size-3.5" })
|
|
5069
5739
|
}
|
|
5070
5740
|
)
|
|
5071
5741
|
] });
|
|
5072
5742
|
}
|
|
5073
5743
|
if (isCollapsedRail) {
|
|
5074
|
-
return /* @__PURE__ */ (0,
|
|
5744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
5075
5745
|
"header",
|
|
5076
5746
|
{
|
|
5077
5747
|
className: cn(
|
|
5078
5748
|
"flex h-12 shrink-0 items-center",
|
|
5079
5749
|
studioSidebarCollapsedRailInsetClass
|
|
5080
5750
|
),
|
|
5081
|
-
children: /* @__PURE__ */ (0,
|
|
5751
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(CollapsedBrandToggle, { onExpand: onToggle, brand })
|
|
5082
5752
|
}
|
|
5083
5753
|
);
|
|
5084
5754
|
}
|
|
5085
|
-
return /* @__PURE__ */ (0,
|
|
5755
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("header", { className: cn(sidebarHeaderClass, "justify-between gap-1 pr-2"), children: [
|
|
5086
5756
|
brand,
|
|
5087
|
-
/* @__PURE__ */ (0,
|
|
5757
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
5088
5758
|
SidebarToggleButton,
|
|
5089
5759
|
{
|
|
5090
5760
|
ariaLabel: "Collapse sidebar",
|
|
5091
5761
|
expanded: true,
|
|
5092
5762
|
onClick: onToggle,
|
|
5093
|
-
children: /* @__PURE__ */ (0,
|
|
5763
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_lucide_react11.ChevronLeft, { className: "size-4" })
|
|
5094
5764
|
}
|
|
5095
5765
|
)
|
|
5096
5766
|
] });
|
|
@@ -5109,7 +5779,7 @@ function workforceItemInitial(w) {
|
|
|
5109
5779
|
}
|
|
5110
5780
|
|
|
5111
5781
|
// src/studio/sidebar/sidebar-nav.tsx
|
|
5112
|
-
var
|
|
5782
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
5113
5783
|
var StudioSidebarNav = ({
|
|
5114
5784
|
workforces,
|
|
5115
5785
|
selectedId,
|
|
@@ -5118,7 +5788,7 @@ var StudioSidebarNav = ({
|
|
|
5118
5788
|
showTooltips
|
|
5119
5789
|
}) => {
|
|
5120
5790
|
if (workforces.length === 0) return null;
|
|
5121
|
-
return /* @__PURE__ */ (0,
|
|
5791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
5122
5792
|
"nav",
|
|
5123
5793
|
{
|
|
5124
5794
|
className: cn(
|
|
@@ -5130,11 +5800,11 @@ var StudioSidebarNav = ({
|
|
|
5130
5800
|
const id = workforceItemId(w);
|
|
5131
5801
|
const isActive = id === selectedId;
|
|
5132
5802
|
const label = workforceItemLabel(w);
|
|
5133
|
-
return /* @__PURE__ */ (0,
|
|
5803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
5134
5804
|
StudioSidebarEntryMotion,
|
|
5135
5805
|
{
|
|
5136
5806
|
className: iconOnlyLayout ? studioSidebarCollapsedRailChipRowClass : void 0,
|
|
5137
|
-
children: /* @__PURE__ */ (0,
|
|
5807
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(StudioSidebarTooltip, { label, enabled: showTooltips, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
5138
5808
|
"button",
|
|
5139
5809
|
{
|
|
5140
5810
|
type: "button",
|
|
@@ -5145,7 +5815,7 @@ var StudioSidebarNav = ({
|
|
|
5145
5815
|
studioSidebarNavItemClasses(iconOnlyLayout, isActive),
|
|
5146
5816
|
iconOnlyLayout && "inline-flex"
|
|
5147
5817
|
),
|
|
5148
|
-
children: iconOnlyLayout ? /* @__PURE__ */ (0,
|
|
5818
|
+
children: iconOnlyLayout ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "text-xs font-semibold leading-none", children: workforceItemInitial(w) }) : /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "min-w-0 truncate", children: label })
|
|
5149
5819
|
}
|
|
5150
5820
|
) })
|
|
5151
5821
|
},
|
|
@@ -5158,7 +5828,7 @@ var StudioSidebarNav = ({
|
|
|
5158
5828
|
|
|
5159
5829
|
// src/studio/sidebar/timbal-mark.tsx
|
|
5160
5830
|
var import_shaders_react = require("@paper-design/shaders-react");
|
|
5161
|
-
var
|
|
5831
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
5162
5832
|
var DEFAULT_SIZE = 64;
|
|
5163
5833
|
var TRANSPARENT_BACK = "#00000000";
|
|
5164
5834
|
var TIMBAL_SYMBOL_DATA_URI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAH6ElEQVR4Aeyci7EcNRBFFxIBIgEygUiASCATyASIBOa4rFrZntmPPq1W93218o5nZyTd26dbmnX5fX3TjxyY4IDAmmCqurzdBJYomOKAwJpiqzoVWGJgigMCa4qt6lRgZWHAWKfAMjY8y3ACK0ukjXUKLGPDswwnsLJE2linwDI2PMtwAitLpI11Cixjw+/DxT4SWLHju0ydwHrP+p/euzzE1T8cKr492lsvgfWaXZj733Hp90fL9Pr1EPvn0QTWYcLoF8bS6Pdf/kjQAAnNv7RqVcW6do4q9ffxMe/HW5oXy323boF1zkvzEnDe3RZnS5X6fcRsBdbdRY6oTl1LAJ1s2NDdXaVq3QLr7kapUph8Pxv/iESiDVUqsG63sgQ0b1Rve/6QQEOrVG1DdrCGbFRrQzc5Zh9FlSKppkw5M1gYi8FTjHXaaalSJNTUKWYEC3P5spP3qeY667zsIadVqVpvNrCoUrTag+jHgIRm0z2ka7AGRpzqNG2jOnCeo7uiSi3RnQEszCVjydzRgfPaH1rRbFqlajMig0WVWmpubbThMRvzJVWq1hgVrFKlgKvWG/2YRHLxpBsNrOVLwCJySSBXT7qRwHKxBCwAiypFWzD09ZARwCpVysUScG318E+oUsv3Uleq3gPrqpd1512bO9GWsockqSYO0971zmBR/mnt6ve7k0RC87KvEV61bEewMNftEvCq8Q3XlSqF/obbbW/ZDSz2UWSs2yVgQvjQimb3VarWvgtYZCnm8uRXzz/6MXq3rM47gLXVEjCI9FKlqNCDurTtxjNYxdytloAB4aM6r65S3TK8grXtEtAZEZZ7Wmc362/3BlapUtsuAY0hDVGlau2ewApnbm30g+OyhySpHly210dewKL80/Zyr2+2JBKaQ+4hV4OFudtvVBv4KlUK/Q23+79lJVjso8jYUEvAk5CjFc0hq1StfQVYZCnm8uRXzyX6MXqbq/Nu5liDFX4JOAGgVCkq9MnHMU9ZgVXMDb8EfIYJ1TlNlaq1W4BFlcpoLss9rfY7zfFMsFSl0mD0pdBZYKXaqFa2so+iSpFU1el8hzPAwlgMzuQmeyl0k1ARdf/zrqiRYGGuq/+C9K4Zb11/v5g9JFCh/342+dEosDCWlslOljs0Z3vSfSnGvWCRpRmf+KhSGXW/BBUX9YCFuWQsmUtfGdo3h0g0q0odRjx6tYAFSFnNZXNOlX7kqT47HGgB67jtJnNv+nnkQCtYj/rUZ3LgFggsRdOTAwLLUzQCzUVgBQqmJykCy1M0As1FYAUKpicpAstTNALNRWAFCqYnKTPB8qRTczF2QGAZG55lOIGVJdLGOgWWseFZhhNYWSJtrFNgGRueZTiBlSXSM3We9C2wTkzRqX4HBFa/h+rhxAGBdWKKTvU7ILD6PVQPJw4IrBNTdKrfAYHV76F6OHFAYJ2Ysv+p9QoE1voYhJyBwAoZ1vWiBNb6GIScgcAKGdb1ogTW+hiEnIHAChnW9aIElk0M0o0isNKF3EawwLLxOd0oAitdyN8W/Ndxx9LfmnyMH/aFuX+EVXct7Lfjox+P9vZLFeu5ZcXcf59fGuYKKhRA8Xtmm0QJrGvbqFJd5l537foTKvN3xwzRf7y1vdKC9cSuUqW6zH0yhsePSaSfR0xMYH3qYvcS8Gl32/yNBPrqmC3vx1v/S2DdPRyyBNy72+aIKkUbOuEWsPg970MnsbizUqWGLAGLtbwzPNWpey91NWALWFd97Xh+qrmODSl7SJJqyjQzg0X5p00x1mmnJBKam79GeFVXRrAwd9oS8KrxC64rVQr904f3A9Z0qR8GYB9Fxk5bAj6M4usPtKJ5epWqZWcBiyzFXJ78av3Rj9G7pDpnAMt0CXBCaqlSVOglU4oMVjHXdAlYEsVPB6U6L6lS9TSigkWVWm5ubbTRMcs9zWi462GigaUqdR1r008igbVso2oasS8HYx9FlSKpvvx00ZkHYC2aUduwGIvBbXfveRd7KXSTUO4U7A4W5g79V3l3ETqfEHtIoEL/+RWLz+4MFsbSFltoOjzLHZrdP+nuCBZZmvGJjyVvG927gVWWADLXtFQsHAytVKmt9pC7gEWVwlz3S8BgANG9TZWqte8AVqlSmFzPPfoxiUSbrnPGAJ7BKkuAqtSMyE/u0ytYW21UB8aIfRRViqQa2K19Vx7BwlgMtndj3Ygs8+gmodbNYuDInsDCXH3ZOTC4K7vyAhbZSlvphfXYLHdoDrmHXA0WVWrLx+lOCnnSDa17JViYS8aSuZ1x2uZ2tKL5cZXaRs71RFeARZVKYe5ntrMxD12lar3WYJUqBVz1PKIfk0ipnnStwEqzBHyWISRQxifdmwVYqZaACiyqFK06ledwJlilSqVaAg50qFJp9lKH3tPXLLCymlv2kCTVqeFZTs4Ai/JPC+ThUykkEprDf43w1ImPF4wEC3MzLgGlSqH/o616GwUW+ygyNtMSgFY0q0qd5FEvWGQp5vLkd9J92FPozVidXw5oD1hZlwASiQr9sskZL2wBK+sSgO6UX3a2JEYrWCyBLePtfA/L387zN517C1imE7wYTKedOyCwnAdo1+kJrF0j53zeAst5gHadnsDaNXLO5y2wnAdo1+kJrF0j53zew8ByrlPTM3ZAYBkbnmU4gZUl0sY6BZax4VmGE1hZIm2sU2AZG55lOIGVJdLDdL7W0f8AAAD//x3VUCQAAAAGSURBVAMArsj7LTb9pqMAAAAASUVORK5CYII=";
|
|
@@ -5167,14 +5837,14 @@ function TimbalMark({
|
|
|
5167
5837
|
size = DEFAULT_SIZE,
|
|
5168
5838
|
src = TIMBAL_SYMBOL_DATA_URI
|
|
5169
5839
|
}) {
|
|
5170
|
-
return /* @__PURE__ */ (0,
|
|
5840
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
5171
5841
|
"div",
|
|
5172
5842
|
{
|
|
5173
5843
|
className: cn("relative shrink-0 bg-transparent", className),
|
|
5174
5844
|
style: { width: size, height: size },
|
|
5175
5845
|
role: "img",
|
|
5176
5846
|
"aria-label": "Timbal",
|
|
5177
|
-
children: /* @__PURE__ */ (0,
|
|
5847
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
5178
5848
|
import_shaders_react.LiquidMetal,
|
|
5179
5849
|
{
|
|
5180
5850
|
width: size,
|
|
@@ -5206,14 +5876,14 @@ function TimbalMark({
|
|
|
5206
5876
|
}
|
|
5207
5877
|
|
|
5208
5878
|
// src/studio/sidebar/shell-inset-bridge-context.tsx
|
|
5209
|
-
var
|
|
5879
|
+
var import_react41 = require("react");
|
|
5210
5880
|
|
|
5211
5881
|
// src/layout/shell-inset-context.tsx
|
|
5212
|
-
var
|
|
5213
|
-
var ShellInsetContext = (0,
|
|
5882
|
+
var import_react40 = require("react");
|
|
5883
|
+
var ShellInsetContext = (0, import_react40.createContext)(null);
|
|
5214
5884
|
var ShellInsetProvider = ShellInsetContext.Provider;
|
|
5215
5885
|
function useShellInsetReporter() {
|
|
5216
|
-
return (0,
|
|
5886
|
+
return (0, import_react40.useContext)(ShellInsetContext);
|
|
5217
5887
|
}
|
|
5218
5888
|
|
|
5219
5889
|
// src/studio/sidebar/shell-inset-bridge-context.tsx
|
|
@@ -5222,7 +5892,7 @@ var StudioSidebarShellInsetBridge = ({
|
|
|
5222
5892
|
}) => {
|
|
5223
5893
|
const reportInset = useShellInsetReporter();
|
|
5224
5894
|
const { isMobile, isCollapsedRail } = useStudioSidebarLayout();
|
|
5225
|
-
(0,
|
|
5895
|
+
(0, import_react41.useLayoutEffect)(() => {
|
|
5226
5896
|
const insetPx = isMobile ? 0 : isCollapsedRail ? SIDEBAR_INSET_PX_COLLAPSED : SIDEBAR_INSET_PX_EXPANDED;
|
|
5227
5897
|
reportInset?.(insetPx);
|
|
5228
5898
|
onInsetChange?.(insetPx);
|
|
@@ -5231,7 +5901,7 @@ var StudioSidebarShellInsetBridge = ({
|
|
|
5231
5901
|
};
|
|
5232
5902
|
|
|
5233
5903
|
// src/studio/sidebar/sidebar.tsx
|
|
5234
|
-
var
|
|
5904
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
5235
5905
|
var DEFAULT_BREAKPOINT_PX = 768;
|
|
5236
5906
|
function readPersistedCollapsed(key) {
|
|
5237
5907
|
if (!key || typeof window === "undefined") return false;
|
|
@@ -5264,7 +5934,7 @@ var StudioSidebarPanel = ({
|
|
|
5264
5934
|
brand,
|
|
5265
5935
|
emptyCaption = null
|
|
5266
5936
|
}) => {
|
|
5267
|
-
const reducedMotion = (0,
|
|
5937
|
+
const reducedMotion = (0, import_react43.useReducedMotion)();
|
|
5268
5938
|
const isCollapsedRail = widthCollapsed && !isMobile;
|
|
5269
5939
|
const iconOnlyLayout = studioSidebarIconOnlyLayout(isMobile, isCollapsedRail);
|
|
5270
5940
|
const isDrawerOpen = isMobile && mobileOpen;
|
|
@@ -5281,9 +5951,9 @@ var StudioSidebarPanel = ({
|
|
|
5281
5951
|
onCollapsedChange(!collapsed);
|
|
5282
5952
|
};
|
|
5283
5953
|
const panelWidthPx = isMobile ? SIDEBAR_MOBILE_PX : widthCollapsed ? SIDEBAR_WIDTH_COLLAPSED_PX : SIDEBAR_WIDTH_PX;
|
|
5284
|
-
const brandNode = brand ?? /* @__PURE__ */ (0,
|
|
5285
|
-
const panel = /* @__PURE__ */ (0,
|
|
5286
|
-
|
|
5954
|
+
const brandNode = brand ?? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(TimbalMark, { size: 32 });
|
|
5955
|
+
const panel = /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
|
|
5956
|
+
import_react43.motion.div,
|
|
5287
5957
|
{
|
|
5288
5958
|
"data-sidebar-collapsed": isCollapsedRail ? "" : void 0,
|
|
5289
5959
|
className: cn(
|
|
@@ -5297,7 +5967,7 @@ var StudioSidebarPanel = ({
|
|
|
5297
5967
|
style: { willChange: entriesVisible ? void 0 : "width" },
|
|
5298
5968
|
onAnimationComplete: isMobile || entriesVisible ? void 0 : () => onPanelWidthComplete(),
|
|
5299
5969
|
children: [
|
|
5300
|
-
/* @__PURE__ */ (0,
|
|
5970
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
5301
5971
|
StudioSidebarHeader,
|
|
5302
5972
|
{
|
|
5303
5973
|
isCollapsedRail,
|
|
@@ -5307,13 +5977,13 @@ var StudioSidebarPanel = ({
|
|
|
5307
5977
|
brand: brandNode
|
|
5308
5978
|
}
|
|
5309
5979
|
),
|
|
5310
|
-
/* @__PURE__ */ (0,
|
|
5980
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
|
|
5311
5981
|
StudioSidebarEntries,
|
|
5312
5982
|
{
|
|
5313
5983
|
visible: entriesVisible,
|
|
5314
5984
|
onBlurOutComplete: onEntriesBlurOutComplete,
|
|
5315
5985
|
children: [
|
|
5316
|
-
/* @__PURE__ */ (0,
|
|
5986
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
5317
5987
|
"div",
|
|
5318
5988
|
{
|
|
5319
5989
|
id: DOM_IDS.sidebarRuntimeAnchor,
|
|
@@ -5323,7 +5993,7 @@ var StudioSidebarPanel = ({
|
|
|
5323
5993
|
)
|
|
5324
5994
|
}
|
|
5325
5995
|
),
|
|
5326
|
-
/* @__PURE__ */ (0,
|
|
5996
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
5327
5997
|
StudioSidebarNav,
|
|
5328
5998
|
{
|
|
5329
5999
|
workforces,
|
|
@@ -5333,8 +6003,8 @@ var StudioSidebarPanel = ({
|
|
|
5333
6003
|
showTooltips: isCollapsedRail
|
|
5334
6004
|
}
|
|
5335
6005
|
),
|
|
5336
|
-
workforces.length === 0 ? /* @__PURE__ */ (0,
|
|
5337
|
-
/* @__PURE__ */ (0,
|
|
6006
|
+
workforces.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "min-h-0 flex-1" }) : null,
|
|
6007
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
5338
6008
|
StudioSidebarFooter,
|
|
5339
6009
|
{
|
|
5340
6010
|
iconOnlyLayout,
|
|
@@ -5350,8 +6020,8 @@ var StudioSidebarPanel = ({
|
|
|
5350
6020
|
}
|
|
5351
6021
|
);
|
|
5352
6022
|
if (isMobile) {
|
|
5353
|
-
return /* @__PURE__ */ (0,
|
|
5354
|
-
|
|
6023
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
6024
|
+
import_react43.motion.aside,
|
|
5355
6025
|
{
|
|
5356
6026
|
className: "fixed inset-y-0 left-0 z-[60] flex",
|
|
5357
6027
|
"aria-label": "Studio navigation",
|
|
@@ -5366,7 +6036,7 @@ var StudioSidebarPanel = ({
|
|
|
5366
6036
|
}
|
|
5367
6037
|
);
|
|
5368
6038
|
}
|
|
5369
|
-
return /* @__PURE__ */ (0,
|
|
6039
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
5370
6040
|
"aside",
|
|
5371
6041
|
{
|
|
5372
6042
|
className: "absolute inset-y-0 left-0 z-[60] flex py-[var(--studio-sidebar-gap)] pl-[var(--studio-sidebar-gap)]",
|
|
@@ -5388,51 +6058,51 @@ var StudioSidebar = ({
|
|
|
5388
6058
|
onMobileOpenChange: onMobileOpenChangeProp,
|
|
5389
6059
|
onInsetChange
|
|
5390
6060
|
}) => {
|
|
5391
|
-
const reducedMotion = (0,
|
|
6061
|
+
const reducedMotion = (0, import_react43.useReducedMotion)();
|
|
5392
6062
|
const fetched = useWorkforces({ enabled: workforcesProp === void 0 });
|
|
5393
6063
|
const workforces = workforcesProp ?? fetched.workforces;
|
|
5394
|
-
const [internalSelected, setInternalSelected] = (0,
|
|
6064
|
+
const [internalSelected, setInternalSelected] = (0, import_react42.useState)(
|
|
5395
6065
|
selectedIdProp ?? ""
|
|
5396
6066
|
);
|
|
5397
|
-
(0,
|
|
6067
|
+
(0, import_react42.useEffect)(() => {
|
|
5398
6068
|
if (selectedIdProp !== void 0) return;
|
|
5399
6069
|
if (internalSelected) return;
|
|
5400
6070
|
const first = workforces[0]?.id ?? workforces[0]?.uid ?? workforces[0]?.name;
|
|
5401
6071
|
if (first) setInternalSelected(first);
|
|
5402
6072
|
}, [workforces, selectedIdProp, internalSelected]);
|
|
5403
6073
|
const selectedId = selectedIdProp ?? internalSelected ?? workforces[0]?.id ?? workforces[0]?.uid ?? workforces[0]?.name ?? "";
|
|
5404
|
-
const handleSelect = (0,
|
|
6074
|
+
const handleSelect = (0, import_react42.useCallback)(
|
|
5405
6075
|
(id) => {
|
|
5406
6076
|
if (selectedIdProp === void 0) setInternalSelected(id);
|
|
5407
6077
|
onSelect?.(id);
|
|
5408
6078
|
},
|
|
5409
6079
|
[selectedIdProp, onSelect]
|
|
5410
6080
|
);
|
|
5411
|
-
const [collapsed, setCollapsed] = (0,
|
|
6081
|
+
const [collapsed, setCollapsed] = (0, import_react42.useState)(() => {
|
|
5412
6082
|
const persisted = readPersistedCollapsed(persistKey);
|
|
5413
6083
|
return persisted || defaultCollapsed;
|
|
5414
6084
|
});
|
|
5415
|
-
const handleCollapsedChange = (0,
|
|
6085
|
+
const handleCollapsedChange = (0, import_react42.useCallback)(
|
|
5416
6086
|
(next) => {
|
|
5417
6087
|
setCollapsed(next);
|
|
5418
6088
|
writePersistedCollapsed(persistKey, next);
|
|
5419
6089
|
},
|
|
5420
6090
|
[persistKey]
|
|
5421
6091
|
);
|
|
5422
|
-
const [isMobile, setIsMobile] = (0,
|
|
6092
|
+
const [isMobile, setIsMobile] = (0, import_react42.useState)(() => {
|
|
5423
6093
|
if (typeof window === "undefined") return false;
|
|
5424
6094
|
return window.innerWidth < mobileBreakpointPx;
|
|
5425
6095
|
});
|
|
5426
|
-
(0,
|
|
6096
|
+
(0, import_react42.useEffect)(() => {
|
|
5427
6097
|
if (typeof window === "undefined") return;
|
|
5428
6098
|
const onResize = () => setIsMobile(window.innerWidth < mobileBreakpointPx);
|
|
5429
6099
|
onResize();
|
|
5430
6100
|
window.addEventListener("resize", onResize);
|
|
5431
6101
|
return () => window.removeEventListener("resize", onResize);
|
|
5432
6102
|
}, [mobileBreakpointPx]);
|
|
5433
|
-
const [internalMobileOpen, setInternalMobileOpen] = (0,
|
|
6103
|
+
const [internalMobileOpen, setInternalMobileOpen] = (0, import_react42.useState)(false);
|
|
5434
6104
|
const mobileOpen = mobileOpenProp ?? internalMobileOpen;
|
|
5435
|
-
const setMobileOpen = (0,
|
|
6105
|
+
const setMobileOpen = (0, import_react42.useCallback)(
|
|
5436
6106
|
(next) => {
|
|
5437
6107
|
if (mobileOpenProp === void 0) setInternalMobileOpen(next);
|
|
5438
6108
|
onMobileOpenChangeProp?.(next);
|
|
@@ -5449,7 +6119,7 @@ var StudioSidebar = ({
|
|
|
5449
6119
|
const entriesVisible = isMobile || phaseEntriesVisible;
|
|
5450
6120
|
const isCollapsedRail = widthCollapsed && !isMobile;
|
|
5451
6121
|
const iconOnlyLayout = studioSidebarIconOnlyLayout(isMobile, isCollapsedRail);
|
|
5452
|
-
const contextValue = (0,
|
|
6122
|
+
const contextValue = (0, import_react42.useMemo)(
|
|
5453
6123
|
() => ({
|
|
5454
6124
|
collapsed: effectiveCollapsed,
|
|
5455
6125
|
isMobile,
|
|
@@ -5458,9 +6128,9 @@ var StudioSidebar = ({
|
|
|
5458
6128
|
}),
|
|
5459
6129
|
[effectiveCollapsed, isMobile, isCollapsedRail, iconOnlyLayout]
|
|
5460
6130
|
);
|
|
5461
|
-
return /* @__PURE__ */ (0,
|
|
5462
|
-
/* @__PURE__ */ (0,
|
|
5463
|
-
/* @__PURE__ */ (0,
|
|
6131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(StudioSidebarContext.Provider, { value: contextValue, children: [
|
|
6132
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(StudioSidebarShellInsetBridge, { onInsetChange }),
|
|
6133
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
5464
6134
|
StudioSidebarPanel,
|
|
5465
6135
|
{
|
|
5466
6136
|
workforces,
|
|
@@ -5483,26 +6153,26 @@ var StudioSidebar = ({
|
|
|
5483
6153
|
};
|
|
5484
6154
|
|
|
5485
6155
|
// src/studio/sidebar/sidebar-runtime-portal.tsx
|
|
5486
|
-
var
|
|
6156
|
+
var import_react44 = require("react");
|
|
5487
6157
|
var import_react_dom = require("react-dom");
|
|
5488
6158
|
var import_lucide_react12 = require("lucide-react");
|
|
5489
|
-
var
|
|
5490
|
-
var
|
|
6159
|
+
var import_react45 = require("@assistant-ui/react");
|
|
6160
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
5491
6161
|
var StudioSidebarRuntimePortal = ({
|
|
5492
6162
|
label = "New chat"
|
|
5493
6163
|
}) => {
|
|
5494
6164
|
const { iconOnlyLayout } = useStudioSidebarLayout();
|
|
5495
|
-
const hasMessages = (0,
|
|
6165
|
+
const hasMessages = (0, import_react45.useThread)((s) => s.messages.length > 0);
|
|
5496
6166
|
const { clear } = useTimbalRuntime();
|
|
5497
|
-
const [anchor, setAnchor] = (0,
|
|
5498
|
-
const startNewChat = (0,
|
|
6167
|
+
const [anchor, setAnchor] = (0, import_react44.useState)(null);
|
|
6168
|
+
const startNewChat = (0, import_react44.useCallback)(() => {
|
|
5499
6169
|
clear();
|
|
5500
6170
|
}, [clear]);
|
|
5501
|
-
(0,
|
|
6171
|
+
(0, import_react44.useLayoutEffect)(() => {
|
|
5502
6172
|
setAnchor(document.getElementById(DOM_IDS.sidebarRuntimeAnchor));
|
|
5503
6173
|
}, []);
|
|
5504
6174
|
if (!anchor || !hasMessages) return null;
|
|
5505
|
-
const button = /* @__PURE__ */ (0,
|
|
6175
|
+
const button = /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
5506
6176
|
"button",
|
|
5507
6177
|
{
|
|
5508
6178
|
type: "button",
|
|
@@ -5510,24 +6180,24 @@ var StudioSidebarRuntimePortal = ({
|
|
|
5510
6180
|
"aria-label": label,
|
|
5511
6181
|
className: studioSidebarNavItemClasses(iconOnlyLayout, false),
|
|
5512
6182
|
children: [
|
|
5513
|
-
/* @__PURE__ */ (0,
|
|
5514
|
-
!iconOnlyLayout ? /* @__PURE__ */ (0,
|
|
6183
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_lucide_react12.MessageSquarePlus, { className: "size-3.5 shrink-0" }),
|
|
6184
|
+
!iconOnlyLayout ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "min-w-0 truncate", children: label }) : null
|
|
5515
6185
|
]
|
|
5516
6186
|
}
|
|
5517
6187
|
);
|
|
5518
6188
|
return (0, import_react_dom.createPortal)(
|
|
5519
|
-
iconOnlyLayout ? /* @__PURE__ */ (0,
|
|
5520
|
-
/* @__PURE__ */ (0,
|
|
5521
|
-
/* @__PURE__ */ (0,
|
|
6189
|
+
iconOnlyLayout ? /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Tooltip, { children: [
|
|
6190
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(TooltipTrigger, { asChild: true, children: button }),
|
|
6191
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(TooltipContent, { side: "right", className: "text-xs", children: label })
|
|
5522
6192
|
] }) : button,
|
|
5523
6193
|
anchor
|
|
5524
6194
|
);
|
|
5525
6195
|
};
|
|
5526
6196
|
|
|
5527
6197
|
// src/studio/sidebar/welcome.tsx
|
|
5528
|
-
var
|
|
5529
|
-
var
|
|
5530
|
-
var
|
|
6198
|
+
var import_react46 = require("motion/react");
|
|
6199
|
+
var import_react47 = require("@assistant-ui/react");
|
|
6200
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
5531
6201
|
var welcomeStagger2 = {
|
|
5532
6202
|
initial: {},
|
|
5533
6203
|
animate: {
|
|
@@ -5552,34 +6222,34 @@ var welcomeIcon2 = {
|
|
|
5552
6222
|
}
|
|
5553
6223
|
};
|
|
5554
6224
|
var StudioWelcome = ({ config, icon }) => {
|
|
5555
|
-
const isEmpty = (0,
|
|
6225
|
+
const isEmpty = (0, import_react47.useThread)((s) => s.messages.length === 0);
|
|
5556
6226
|
if (!isEmpty) return null;
|
|
5557
|
-
const iconNode = icon ?? /* @__PURE__ */ (0,
|
|
6227
|
+
const iconNode = icon ?? /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
5558
6228
|
TimbalMark,
|
|
5559
6229
|
{
|
|
5560
6230
|
size: 112,
|
|
5561
6231
|
className: "max-md:scale-[0.58] max-md:origin-center"
|
|
5562
6232
|
}
|
|
5563
6233
|
);
|
|
5564
|
-
return /* @__PURE__ */ (0,
|
|
5565
|
-
|
|
6234
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
6235
|
+
import_react46.motion.div,
|
|
5566
6236
|
{
|
|
5567
6237
|
className: "aui-thread-welcome-message flex flex-col items-center justify-center px-2 text-center sm:px-4",
|
|
5568
6238
|
variants: welcomeStagger2,
|
|
5569
6239
|
initial: "initial",
|
|
5570
6240
|
animate: "animate",
|
|
5571
6241
|
children: [
|
|
5572
|
-
/* @__PURE__ */ (0,
|
|
5573
|
-
/* @__PURE__ */ (0,
|
|
5574
|
-
|
|
6242
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_react46.motion.div, { variants: welcomeIcon2, className: "mb-4 md:mb-5", children: iconNode }),
|
|
6243
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
6244
|
+
import_react46.motion.h1,
|
|
5575
6245
|
{
|
|
5576
6246
|
variants: welcomeItem2,
|
|
5577
6247
|
className: "aui-thread-welcome-message-inner text-xl font-semibold sm:text-2xl",
|
|
5578
6248
|
children: config?.heading ?? "How can I help you today?"
|
|
5579
6249
|
}
|
|
5580
6250
|
),
|
|
5581
|
-
/* @__PURE__ */ (0,
|
|
5582
|
-
|
|
6251
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
6252
|
+
import_react46.motion.p,
|
|
5583
6253
|
{
|
|
5584
6254
|
variants: welcomeItem2,
|
|
5585
6255
|
className: "aui-thread-welcome-message-inner mt-2 text-muted-foreground",
|
|
@@ -5592,8 +6262,8 @@ var StudioWelcome = ({ config, icon }) => {
|
|
|
5592
6262
|
};
|
|
5593
6263
|
|
|
5594
6264
|
// src/studio/shell/studio-shell.tsx
|
|
5595
|
-
var
|
|
5596
|
-
var
|
|
6265
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
6266
|
+
var import_react50 = require("react");
|
|
5597
6267
|
var DEFAULT_BREAKPOINT_PX2 = 768;
|
|
5598
6268
|
function readPersistedCollapsed2(key) {
|
|
5599
6269
|
if (!key || typeof window === "undefined") return false;
|
|
@@ -5613,9 +6283,9 @@ function writePersistedCollapsed2(key, collapsed) {
|
|
|
5613
6283
|
function makeComposerWithPortal(BaseComposer) {
|
|
5614
6284
|
const Resolved = BaseComposer ?? Composer;
|
|
5615
6285
|
return function StudioComposerWithSidebar(props) {
|
|
5616
|
-
return /* @__PURE__ */ (0,
|
|
5617
|
-
/* @__PURE__ */ (0,
|
|
5618
|
-
/* @__PURE__ */ (0,
|
|
6286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
|
|
6287
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(StudioSidebarRuntimePortal, {}),
|
|
6288
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Resolved, { ...props })
|
|
5619
6289
|
] });
|
|
5620
6290
|
};
|
|
5621
6291
|
}
|
|
@@ -5635,7 +6305,7 @@ var TimbalStudioShell = ({
|
|
|
5635
6305
|
components,
|
|
5636
6306
|
...chatProps
|
|
5637
6307
|
}) => {
|
|
5638
|
-
const reducedMotion = (0,
|
|
6308
|
+
const reducedMotion = (0, import_react49.useReducedMotion)();
|
|
5639
6309
|
const shouldFetchWorkforces = !workforceId && workforcesProp === void 0;
|
|
5640
6310
|
const fetched = useWorkforces({
|
|
5641
6311
|
enabled: shouldFetchWorkforces,
|
|
@@ -5643,36 +6313,36 @@ var TimbalStudioShell = ({
|
|
|
5643
6313
|
baseUrl: workforcesBaseUrl
|
|
5644
6314
|
});
|
|
5645
6315
|
const workforces = workforcesProp ?? fetched.workforces;
|
|
5646
|
-
const [internalSelected, setInternalSelected] = (0,
|
|
6316
|
+
const [internalSelected, setInternalSelected] = (0, import_react48.useState)(
|
|
5647
6317
|
workforceId ?? ""
|
|
5648
6318
|
);
|
|
5649
|
-
(0,
|
|
6319
|
+
(0, import_react48.useEffect)(() => {
|
|
5650
6320
|
if (workforceId) return;
|
|
5651
6321
|
if (internalSelected) return;
|
|
5652
6322
|
const first = workforces[0]?.id ?? workforces[0]?.uid ?? workforces[0]?.name;
|
|
5653
6323
|
if (first) setInternalSelected(first);
|
|
5654
6324
|
}, [workforces, workforceId, internalSelected]);
|
|
5655
6325
|
const activeWorkforceId = workforceId ?? internalSelected ?? fetched.selectedId ?? "";
|
|
5656
|
-
const [collapsed, setCollapsed] = (0,
|
|
6326
|
+
const [collapsed, setCollapsed] = (0, import_react48.useState)(() => {
|
|
5657
6327
|
const persisted = readPersistedCollapsed2(persistKey);
|
|
5658
6328
|
return persisted || defaultCollapsed;
|
|
5659
6329
|
});
|
|
5660
|
-
const [isMobile, setIsMobile] = (0,
|
|
6330
|
+
const [isMobile, setIsMobile] = (0, import_react48.useState)(() => {
|
|
5661
6331
|
if (typeof window === "undefined") return false;
|
|
5662
6332
|
return window.innerWidth < mobileBreakpointPx;
|
|
5663
6333
|
});
|
|
5664
|
-
const [mobileSidebarOpen, setMobileSidebarOpen] = (0,
|
|
5665
|
-
(0,
|
|
6334
|
+
const [mobileSidebarOpen, setMobileSidebarOpen] = (0, import_react48.useState)(false);
|
|
6335
|
+
(0, import_react48.useEffect)(() => {
|
|
5666
6336
|
if (typeof window === "undefined") return;
|
|
5667
6337
|
const onResize = () => setIsMobile(window.innerWidth < mobileBreakpointPx);
|
|
5668
6338
|
onResize();
|
|
5669
6339
|
window.addEventListener("resize", onResize);
|
|
5670
6340
|
return () => window.removeEventListener("resize", onResize);
|
|
5671
6341
|
}, [mobileBreakpointPx]);
|
|
5672
|
-
(0,
|
|
6342
|
+
(0, import_react48.useEffect)(() => {
|
|
5673
6343
|
if (!isMobile) setMobileSidebarOpen(false);
|
|
5674
6344
|
}, [isMobile]);
|
|
5675
|
-
(0,
|
|
6345
|
+
(0, import_react48.useEffect)(() => {
|
|
5676
6346
|
if (!mobileSidebarOpen) return;
|
|
5677
6347
|
const onKeyDown = (e) => {
|
|
5678
6348
|
if (e.key === "Escape") setMobileSidebarOpen(false);
|
|
@@ -5696,21 +6366,21 @@ var TimbalStudioShell = ({
|
|
|
5696
6366
|
layoutDirection
|
|
5697
6367
|
);
|
|
5698
6368
|
const desktopInsetPx = widthCollapsed ? SIDEBAR_INSET_PX_COLLAPSED : SIDEBAR_INSET_PX_EXPANDED;
|
|
5699
|
-
const onCollapsedChange = (0,
|
|
6369
|
+
const onCollapsedChange = (0, import_react48.useCallback)(
|
|
5700
6370
|
(next) => {
|
|
5701
6371
|
setCollapsed(next);
|
|
5702
6372
|
writePersistedCollapsed2(persistKey, next);
|
|
5703
6373
|
},
|
|
5704
6374
|
[persistKey]
|
|
5705
6375
|
);
|
|
5706
|
-
const handleSelectWorkforce = (0,
|
|
6376
|
+
const handleSelectWorkforce = (0, import_react48.useCallback)(
|
|
5707
6377
|
(id) => {
|
|
5708
6378
|
if (!workforceId) setInternalSelected(id);
|
|
5709
6379
|
if (isMobile) setMobileSidebarOpen(false);
|
|
5710
6380
|
},
|
|
5711
6381
|
[workforceId, isMobile]
|
|
5712
6382
|
);
|
|
5713
|
-
const sidebarContext = (0,
|
|
6383
|
+
const sidebarContext = (0, import_react48.useMemo)(
|
|
5714
6384
|
() => ({
|
|
5715
6385
|
collapsed: effectiveCollapsed,
|
|
5716
6386
|
isMobile,
|
|
@@ -5719,12 +6389,12 @@ var TimbalStudioShell = ({
|
|
|
5719
6389
|
}),
|
|
5720
6390
|
[effectiveCollapsed, isMobile, isCollapsedRail, iconOnlyLayout]
|
|
5721
6391
|
);
|
|
5722
|
-
const resolvedComponents = (0,
|
|
6392
|
+
const resolvedComponents = (0, import_react48.useMemo)(() => {
|
|
5723
6393
|
const next = { Welcome: StudioWelcome, ...components };
|
|
5724
6394
|
next.Composer = makeComposerWithPortal(components?.Composer);
|
|
5725
6395
|
return next;
|
|
5726
6396
|
}, [components]);
|
|
5727
|
-
return /* @__PURE__ */ (0,
|
|
6397
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(StudioSidebarContext.Provider, { value: sidebarContext, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
|
|
5728
6398
|
"div",
|
|
5729
6399
|
{
|
|
5730
6400
|
className: cn(
|
|
@@ -5733,14 +6403,14 @@ var TimbalStudioShell = ({
|
|
|
5733
6403
|
),
|
|
5734
6404
|
style: studioChromeShellStyle,
|
|
5735
6405
|
children: [
|
|
5736
|
-
/* @__PURE__ */ (0,
|
|
6406
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
5737
6407
|
"div",
|
|
5738
6408
|
{
|
|
5739
6409
|
className: "pointer-events-none absolute inset-0 z-0 bg-background",
|
|
5740
6410
|
"aria-hidden": true
|
|
5741
6411
|
}
|
|
5742
6412
|
),
|
|
5743
|
-
/* @__PURE__ */ (0,
|
|
6413
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
5744
6414
|
"div",
|
|
5745
6415
|
{
|
|
5746
6416
|
className: cn(
|
|
@@ -5750,14 +6420,14 @@ var TimbalStudioShell = ({
|
|
|
5750
6420
|
"aria-hidden": true
|
|
5751
6421
|
}
|
|
5752
6422
|
),
|
|
5753
|
-
/* @__PURE__ */ (0,
|
|
6423
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
5754
6424
|
StudioSidebarBackdrop,
|
|
5755
6425
|
{
|
|
5756
6426
|
open: isMobile && mobileSidebarOpen,
|
|
5757
6427
|
onClose: () => setMobileSidebarOpen(false)
|
|
5758
6428
|
}
|
|
5759
6429
|
),
|
|
5760
|
-
/* @__PURE__ */ (0,
|
|
6430
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
5761
6431
|
StudioSidebarPanel,
|
|
5762
6432
|
{
|
|
5763
6433
|
workforces,
|
|
@@ -5776,8 +6446,8 @@ var TimbalStudioShell = ({
|
|
|
5776
6446
|
emptyCaption: sidebarEmptyCaption
|
|
5777
6447
|
}
|
|
5778
6448
|
),
|
|
5779
|
-
/* @__PURE__ */ (0,
|
|
5780
|
-
|
|
6449
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
|
|
6450
|
+
import_react49.motion.header,
|
|
5781
6451
|
{
|
|
5782
6452
|
className: cn(
|
|
5783
6453
|
"absolute top-0 right-0 z-40 flex items-start justify-between gap-2",
|
|
@@ -5788,7 +6458,7 @@ var TimbalStudioShell = ({
|
|
|
5788
6458
|
animate: { left: isMobile ? 0 : desktopInsetPx },
|
|
5789
6459
|
transition: layoutTransition,
|
|
5790
6460
|
children: [
|
|
5791
|
-
/* @__PURE__ */ (0,
|
|
6461
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
|
|
5792
6462
|
"div",
|
|
5793
6463
|
{
|
|
5794
6464
|
className: cn(
|
|
@@ -5796,7 +6466,7 @@ var TimbalStudioShell = ({
|
|
|
5796
6466
|
studioTopbarPillHeightClass
|
|
5797
6467
|
),
|
|
5798
6468
|
children: [
|
|
5799
|
-
isMobile && !mobileSidebarOpen ? /* @__PURE__ */ (0,
|
|
6469
|
+
isMobile && !mobileSidebarOpen ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
5800
6470
|
TimbalV2Button,
|
|
5801
6471
|
{
|
|
5802
6472
|
variant: "secondary",
|
|
@@ -5806,19 +6476,19 @@ var TimbalStudioShell = ({
|
|
|
5806
6476
|
onClick: () => setMobileSidebarOpen(true),
|
|
5807
6477
|
"aria-label": "Open menu",
|
|
5808
6478
|
"aria-expanded": false,
|
|
5809
|
-
children: /* @__PURE__ */ (0,
|
|
6479
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_lucide_react13.Menu, { className: "size-4" })
|
|
5810
6480
|
}
|
|
5811
6481
|
) : null,
|
|
5812
6482
|
headerStart
|
|
5813
6483
|
]
|
|
5814
6484
|
}
|
|
5815
6485
|
),
|
|
5816
|
-
headerActions ? /* @__PURE__ */ (0,
|
|
6486
|
+
headerActions ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "flex shrink-0 items-center gap-1", children: headerActions }) : null
|
|
5817
6487
|
]
|
|
5818
6488
|
}
|
|
5819
6489
|
),
|
|
5820
|
-
/* @__PURE__ */ (0,
|
|
5821
|
-
|
|
6490
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
6491
|
+
import_react49.motion.main,
|
|
5822
6492
|
{
|
|
5823
6493
|
className: cn(
|
|
5824
6494
|
"relative z-10 flex h-full min-w-0 flex-col",
|
|
@@ -5828,7 +6498,7 @@ var TimbalStudioShell = ({
|
|
|
5828
6498
|
initial: false,
|
|
5829
6499
|
animate: { paddingLeft: isMobile ? 12 : desktopInsetPx },
|
|
5830
6500
|
transition: layoutTransition,
|
|
5831
|
-
children: activeWorkforceId ? /* @__PURE__ */ (0,
|
|
6501
|
+
children: activeWorkforceId ? /* @__PURE__ */ (0, import_react50.createElement)(
|
|
5832
6502
|
TimbalChat,
|
|
5833
6503
|
{
|
|
5834
6504
|
...chatProps,
|
|
@@ -5847,9 +6517,9 @@ var TimbalStudioShell = ({
|
|
|
5847
6517
|
};
|
|
5848
6518
|
|
|
5849
6519
|
// src/studio/sidebar/mode-toggle.tsx
|
|
5850
|
-
var
|
|
6520
|
+
var import_react51 = require("react");
|
|
5851
6521
|
var import_lucide_react14 = require("lucide-react");
|
|
5852
|
-
var
|
|
6522
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
5853
6523
|
function readStoredTheme() {
|
|
5854
6524
|
if (typeof window === "undefined") return null;
|
|
5855
6525
|
try {
|
|
@@ -5877,8 +6547,8 @@ var ModeToggle = ({
|
|
|
5877
6547
|
label = "Toggle theme"
|
|
5878
6548
|
}) => {
|
|
5879
6549
|
const isControlled = theme !== void 0;
|
|
5880
|
-
const [internalIsDark, setInternalIsDark] = (0,
|
|
5881
|
-
(0,
|
|
6550
|
+
const [internalIsDark, setInternalIsDark] = (0, import_react51.useState)(false);
|
|
6551
|
+
(0, import_react51.useLayoutEffect)(() => {
|
|
5882
6552
|
if (isControlled) return;
|
|
5883
6553
|
const stored = readStoredTheme();
|
|
5884
6554
|
if (stored) {
|
|
@@ -5890,7 +6560,7 @@ var ModeToggle = ({
|
|
|
5890
6560
|
setInternalIsDark(document.documentElement.classList.contains("dark"));
|
|
5891
6561
|
}, [isControlled]);
|
|
5892
6562
|
const isDark = isControlled ? theme === "dark" : internalIsDark;
|
|
5893
|
-
const onClick = (0,
|
|
6563
|
+
const onClick = (0, import_react51.useCallback)(() => {
|
|
5894
6564
|
const next = isDark ? "light" : "dark";
|
|
5895
6565
|
if (setTheme) {
|
|
5896
6566
|
setTheme(next);
|
|
@@ -5901,7 +6571,7 @@ var ModeToggle = ({
|
|
|
5901
6571
|
writeStoredTheme(isDarkNext ? "dark" : "light");
|
|
5902
6572
|
setInternalIsDark(isDarkNext);
|
|
5903
6573
|
}, [isDark, setTheme]);
|
|
5904
|
-
return /* @__PURE__ */ (0,
|
|
6574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
5905
6575
|
TimbalV2Button,
|
|
5906
6576
|
{
|
|
5907
6577
|
variant: "secondary",
|
|
@@ -5917,20 +6587,20 @@ var ModeToggle = ({
|
|
|
5917
6587
|
"aria-label": label,
|
|
5918
6588
|
title: label,
|
|
5919
6589
|
children: [
|
|
5920
|
-
/* @__PURE__ */ (0,
|
|
5921
|
-
/* @__PURE__ */ (0,
|
|
5922
|
-
/* @__PURE__ */ (0,
|
|
6590
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_lucide_react14.Sun, { className: "size-3.5 scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90" }),
|
|
6591
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_lucide_react14.Moon, { className: "absolute size-3.5 scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0" }),
|
|
6592
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "sr-only", children: label })
|
|
5923
6593
|
]
|
|
5924
6594
|
}
|
|
5925
6595
|
);
|
|
5926
6596
|
};
|
|
5927
6597
|
|
|
5928
6598
|
// src/studio/mode-switch.tsx
|
|
5929
|
-
var
|
|
6599
|
+
var import_react54 = require("react");
|
|
5930
6600
|
|
|
5931
6601
|
// src/ui/pill-segmented-tabs.tsx
|
|
5932
|
-
var
|
|
5933
|
-
var
|
|
6602
|
+
var import_react52 = require("react");
|
|
6603
|
+
var import_react53 = require("motion/react");
|
|
5934
6604
|
|
|
5935
6605
|
// src/design/pill-segmented-classes.ts
|
|
5936
6606
|
var pillSegmentedTrackBase = "inline-flex w-fit max-w-max shrink-0 self-start items-center rounded-full";
|
|
@@ -5963,7 +6633,7 @@ var pillSegmentedActiveIndicatorClass = cn(
|
|
|
5963
6633
|
);
|
|
5964
6634
|
|
|
5965
6635
|
// src/ui/pill-segmented-tabs.tsx
|
|
5966
|
-
var
|
|
6636
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
5967
6637
|
var PillTab = ({
|
|
5968
6638
|
tabKey,
|
|
5969
6639
|
label,
|
|
@@ -5974,10 +6644,10 @@ var PillTab = ({
|
|
|
5974
6644
|
segmentClassName,
|
|
5975
6645
|
animateIndicator
|
|
5976
6646
|
}) => {
|
|
5977
|
-
const handlePress = (0,
|
|
6647
|
+
const handlePress = (0, import_react52.useCallback)(() => {
|
|
5978
6648
|
if (!disabled) onSelect(tabKey);
|
|
5979
6649
|
}, [disabled, onSelect, tabKey]);
|
|
5980
|
-
return /* @__PURE__ */ (0,
|
|
6650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
5981
6651
|
"button",
|
|
5982
6652
|
{
|
|
5983
6653
|
type: "button",
|
|
@@ -5990,15 +6660,15 @@ var PillTab = ({
|
|
|
5990
6660
|
!disabled && (isActive ? "text-foreground" : "text-muted-foreground hover:text-foreground")
|
|
5991
6661
|
),
|
|
5992
6662
|
children: [
|
|
5993
|
-
isActive && animateIndicator ? /* @__PURE__ */ (0,
|
|
5994
|
-
|
|
6663
|
+
isActive && animateIndicator ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
6664
|
+
import_react53.motion.div,
|
|
5995
6665
|
{
|
|
5996
6666
|
layoutId,
|
|
5997
6667
|
className: pillSegmentedActiveIndicatorClass,
|
|
5998
6668
|
transition: { type: "spring", duration: 0.3, bounce: 0.15 }
|
|
5999
6669
|
}
|
|
6000
|
-
) : isActive ? /* @__PURE__ */ (0,
|
|
6001
|
-
/* @__PURE__ */ (0,
|
|
6670
|
+
) : isActive ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: pillSegmentedActiveIndicatorClass, "aria-hidden": true }) : null,
|
|
6671
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "relative z-10 whitespace-nowrap", children: label })
|
|
6002
6672
|
]
|
|
6003
6673
|
}
|
|
6004
6674
|
);
|
|
@@ -6012,13 +6682,13 @@ var PillSegmentedTabs = ({
|
|
|
6012
6682
|
layoutId: layoutIdProp,
|
|
6013
6683
|
"aria-label": ariaLabel
|
|
6014
6684
|
}) => {
|
|
6015
|
-
const reactId = (0,
|
|
6685
|
+
const reactId = (0, import_react52.useId)();
|
|
6016
6686
|
const layoutId = layoutIdProp ?? `pill-segmented-${reactId.replace(/:/g, "")}`;
|
|
6017
|
-
const reducedMotion = (0,
|
|
6687
|
+
const reducedMotion = (0, import_react53.useReducedMotion)();
|
|
6018
6688
|
const isFlush = trackVariant === "flush";
|
|
6019
6689
|
const trackClass = isFlush ? pillSegmentedTrackFlushClass : pillSegmentedTrackClass;
|
|
6020
6690
|
const segmentClassName = isFlush ? pillSegmentedFlushSegmentClass : pillSegmentedSegmentClass;
|
|
6021
|
-
return /* @__PURE__ */ (0,
|
|
6691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { role: "group", "aria-label": ariaLabel, className: cn(trackClass, className), children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
6022
6692
|
PillTab,
|
|
6023
6693
|
{
|
|
6024
6694
|
tabKey: tab.key,
|
|
@@ -6033,15 +6703,15 @@ var PillSegmentedTabs = ({
|
|
|
6033
6703
|
tab.key
|
|
6034
6704
|
)) });
|
|
6035
6705
|
};
|
|
6036
|
-
var MemoPillSegmentedTabs = (0,
|
|
6706
|
+
var MemoPillSegmentedTabs = (0, import_react52.memo)(PillSegmentedTabs);
|
|
6037
6707
|
|
|
6038
6708
|
// src/studio/mode-switch.tsx
|
|
6039
|
-
var
|
|
6709
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
6040
6710
|
var STUDIO_NAV_MODE = {
|
|
6041
6711
|
BUILD: "build",
|
|
6042
6712
|
OPERATE: "operate"
|
|
6043
6713
|
};
|
|
6044
|
-
var StudioModeSwitch = (0,
|
|
6714
|
+
var StudioModeSwitch = (0, import_react54.memo)(
|
|
6045
6715
|
function StudioModeSwitch2({
|
|
6046
6716
|
value,
|
|
6047
6717
|
onChange,
|
|
@@ -6050,14 +6720,14 @@ var StudioModeSwitch = (0, import_react53.memo)(
|
|
|
6050
6720
|
manageLabel = "Manage",
|
|
6051
6721
|
"aria-label": ariaLabel = "Studio mode"
|
|
6052
6722
|
}) {
|
|
6053
|
-
const tabs = (0,
|
|
6723
|
+
const tabs = (0, import_react54.useMemo)(
|
|
6054
6724
|
() => [
|
|
6055
6725
|
{ key: STUDIO_NAV_MODE.BUILD, label: buildLabel },
|
|
6056
6726
|
{ key: STUDIO_NAV_MODE.OPERATE, label: manageLabel }
|
|
6057
6727
|
],
|
|
6058
6728
|
[buildLabel, manageLabel]
|
|
6059
6729
|
);
|
|
6060
|
-
const handleChange = (0,
|
|
6730
|
+
const handleChange = (0, import_react54.useCallback)(
|
|
6061
6731
|
(key) => {
|
|
6062
6732
|
if (key === STUDIO_NAV_MODE.BUILD || key === STUDIO_NAV_MODE.OPERATE) {
|
|
6063
6733
|
onChange(key);
|
|
@@ -6065,14 +6735,14 @@ var StudioModeSwitch = (0, import_react53.memo)(
|
|
|
6065
6735
|
},
|
|
6066
6736
|
[onChange]
|
|
6067
6737
|
);
|
|
6068
|
-
return /* @__PURE__ */ (0,
|
|
6738
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
6069
6739
|
"div",
|
|
6070
6740
|
{
|
|
6071
6741
|
"data-tour": "studio-mode-switch",
|
|
6072
6742
|
"data-studio-chrome-align": "mode-switch",
|
|
6073
6743
|
id: "studio-chrome-mode-switch",
|
|
6074
6744
|
className,
|
|
6075
|
-
children: /* @__PURE__ */ (0,
|
|
6745
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
6076
6746
|
PillSegmentedTabs,
|
|
6077
6747
|
{
|
|
6078
6748
|
value,
|