@timbal-ai/timbal-react 0.6.1 → 0.7.1
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 +55 -0
- package/README.md +35 -5
- package/dist/app.cjs +2291 -741
- package/dist/app.d.cts +5 -2
- package/dist/app.d.ts +5 -2
- package/dist/app.esm.js +58 -5
- package/dist/button-CIKzUrJI.d.cts +18 -0
- package/dist/button-CIKzUrJI.d.ts +18 -0
- package/dist/chart-artifact-C2m891nx.d.cts +756 -0
- package/dist/chart-artifact-CqqhdSR9.d.ts +756 -0
- package/dist/{chat-CWtQWDtJ.d.cts → chat-Bed4FQSl.d.cts} +10 -0
- package/dist/{chat-CWtQWDtJ.d.ts → chat-Bed4FQSl.d.ts} +10 -0
- package/dist/chat.cjs +876 -562
- package/dist/chat.d.cts +3 -3
- package/dist/chat.d.ts +3 -3
- package/dist/chat.esm.js +3 -3
- package/dist/{chunk-4TCJQSIX.esm.js → chunk-2XZ3S4OP.esm.js} +14 -3
- package/dist/{chunk-WLTW56MC.esm.js → chunk-3WCG6ZRL.esm.js} +2 -2
- package/dist/chunk-7U2N6XZA.esm.js +2296 -0
- package/dist/{chunk-OVHR7J3J.esm.js → chunk-EQC5JEDZ.esm.js} +38 -11
- package/dist/{chunk-YJQLLFKP.esm.js → chunk-RY3LB3JN.esm.js} +817 -507
- package/dist/{chunk-IYENDIRY.esm.js → chunk-TDIJHV4I.esm.js} +1 -1
- package/dist/{chunk-OFHLFNJH.esm.js → chunk-Z27GBSOT.esm.js} +3 -1
- package/dist/index.cjs +2596 -1019
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.esm.js +57 -7
- package/dist/{layout-CQWngNQ7.d.ts → layout-BTJyU8wd.d.ts} +1 -1
- package/dist/{layout-B9VayJhZ.d.cts → layout-C2G-FcER.d.cts} +1 -1
- package/dist/studio.cjs +1131 -788
- package/dist/studio.d.cts +2 -2
- package/dist/studio.d.ts +2 -2
- package/dist/studio.esm.js +6 -6
- package/dist/styles.css +8 -4
- package/dist/{timbal-v2-button-F4-z7m33.d.ts → timbal-v2-button-CNfdwGq4.d.cts} +1 -1
- package/dist/{timbal-v2-button-F4-z7m33.d.cts → timbal-v2-button-CNfdwGq4.d.ts} +1 -1
- package/dist/ui.cjs +12 -3
- package/dist/ui.d.cts +5 -16
- package/dist/ui.d.ts +5 -16
- package/dist/ui.esm.js +2 -2
- package/dist/{welcome--80i_O0p.d.cts → welcome-COOb05a5.d.cts} +5 -4
- package/dist/{welcome-BOizSp5h.d.ts → welcome-DE08m9ca.d.ts} +5 -4
- package/package.json +2 -1
- package/vite/local-dev.mjs +45 -3
- package/dist/chart-artifact-C71dk4xI.d.ts +0 -329
- package/dist/chart-artifact-CPEpOmtV.d.cts +0 -329
- package/dist/chunk-M4V6Q6XO.esm.js +0 -1082
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_react29 = require("react");
|
|
902
|
+
var import_react30 = require("@assistant-ui/react");
|
|
903
903
|
var import_lucide_react8 = require("lucide-react");
|
|
904
|
-
var
|
|
904
|
+
var import_react31 = require("motion/react");
|
|
905
905
|
|
|
906
906
|
// src/chat/attachment.tsx
|
|
907
907
|
var import_react5 = require("react");
|
|
@@ -1066,6 +1066,10 @@ var TIMBAL_V2_SWITCH_THUMB = cn(
|
|
|
1066
1066
|
TIMBAL_V2_ELEVATED_GRADIENT,
|
|
1067
1067
|
"border border-border/80 shadow-sm"
|
|
1068
1068
|
);
|
|
1069
|
+
var TIMBAL_V2_ELEVATED_SURFACE = cn(
|
|
1070
|
+
TIMBAL_V2_ELEVATED_GRADIENT,
|
|
1071
|
+
"border border-border shadow-card"
|
|
1072
|
+
);
|
|
1069
1073
|
var TIMBAL_V2_SECONDARY_CHROME = [
|
|
1070
1074
|
TIMBAL_V2_ELEVATED_GRADIENT,
|
|
1071
1075
|
"border border-border shadow-card",
|
|
@@ -1073,6 +1077,11 @@ var TIMBAL_V2_SECONDARY_CHROME = [
|
|
|
1073
1077
|
"hover:from-secondary-fill-hover-from hover:to-secondary-fill-hover-to",
|
|
1074
1078
|
"active:from-secondary-fill-active-from active:to-secondary-fill-active-to"
|
|
1075
1079
|
].join(" ");
|
|
1080
|
+
var TIMBAL_V2_LOGO_TILE = cn(
|
|
1081
|
+
"bg-gradient-to-b from-white to-neutral-100",
|
|
1082
|
+
"border border-neutral-200",
|
|
1083
|
+
"shadow-[0_1px_2px_-0.5px_rgba(0,0,0,0.08)]"
|
|
1084
|
+
);
|
|
1076
1085
|
|
|
1077
1086
|
// src/ui/dialog.tsx
|
|
1078
1087
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
@@ -1254,7 +1263,7 @@ var TimbalV2Button = React.forwardRef(function TimbalV2Button2({
|
|
|
1254
1263
|
isIconOnly = false,
|
|
1255
1264
|
isLoading = false,
|
|
1256
1265
|
fullWidth = false,
|
|
1257
|
-
shape = "pill",
|
|
1266
|
+
shape: _shape = "pill",
|
|
1258
1267
|
asChild = false,
|
|
1259
1268
|
className,
|
|
1260
1269
|
disabled,
|
|
@@ -1264,7 +1273,7 @@ var TimbalV2Button = React.forwardRef(function TimbalV2Button2({
|
|
|
1264
1273
|
}, ref) {
|
|
1265
1274
|
const isDisabled = disabled || isLoading;
|
|
1266
1275
|
const sizeClass = isIconOnly ? TIMBAL_V2_SIZE_ICON[size] : TIMBAL_V2_SIZE_HEIGHT[size];
|
|
1267
|
-
const radiusClass =
|
|
1276
|
+
const radiusClass = "rounded-full";
|
|
1268
1277
|
const sharedRootClass = cn(
|
|
1269
1278
|
"relative box-border inline-flex items-center justify-center gap-2 whitespace-nowrap border-0 text-sm font-normal shadow-none transition duration-200 ease-in-out",
|
|
1270
1279
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-1 focus-visible:ring-offset-background",
|
|
@@ -1513,293 +1522,625 @@ var import_react_markdown = require("@assistant-ui/react-markdown");
|
|
|
1513
1522
|
var import_remark_gfm = __toESM(require("remark-gfm"), 1);
|
|
1514
1523
|
var import_remark_math = __toESM(require("remark-math"), 1);
|
|
1515
1524
|
var import_rehype_katex = __toESM(require("rehype-katex"), 1);
|
|
1516
|
-
var
|
|
1525
|
+
var import_react19 = require("react");
|
|
1517
1526
|
var import_lucide_react4 = require("lucide-react");
|
|
1518
1527
|
|
|
1519
1528
|
// src/chat/syntax-highlighter.tsx
|
|
1520
|
-
var
|
|
1529
|
+
var import_react18 = require("react");
|
|
1521
1530
|
var import_core = require("shiki/core");
|
|
1522
1531
|
var import_javascript = require("shiki/engine/javascript");
|
|
1523
1532
|
|
|
1524
1533
|
// src/artifacts/registry.tsx
|
|
1525
|
-
var
|
|
1534
|
+
var import_react17 = require("react");
|
|
1526
1535
|
|
|
1527
1536
|
// src/artifacts/chart-artifact.tsx
|
|
1537
|
+
var import_react9 = require("react");
|
|
1538
|
+
|
|
1539
|
+
// src/charts/line-area-chart.tsx
|
|
1540
|
+
var import_react8 = require("react");
|
|
1541
|
+
|
|
1542
|
+
// src/charts/use-chart-width.ts
|
|
1528
1543
|
var import_react7 = require("react");
|
|
1544
|
+
function useChartWidth(initial = 640) {
|
|
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
|
+
}
|
|
1529
1559
|
|
|
1530
|
-
// src/
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1560
|
+
// src/charts/geometry.ts
|
|
1561
|
+
function toNum(value) {
|
|
1562
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
1563
|
+
return Number.isFinite(n) ? n : 0;
|
|
1564
|
+
}
|
|
1565
|
+
function monotoneLinePath(points) {
|
|
1566
|
+
const n = points.length;
|
|
1567
|
+
if (n === 0) return "";
|
|
1568
|
+
if (n === 1) return `M ${points[0].x},${points[0].y}`;
|
|
1569
|
+
if (n === 2) {
|
|
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}`;
|
|
1583
|
+
}
|
|
1584
|
+
return d;
|
|
1585
|
+
}
|
|
1586
|
+
function monotoneAreaPath(points, baseY) {
|
|
1587
|
+
if (points.length === 0) return "";
|
|
1588
|
+
const line = monotoneLinePath(points);
|
|
1589
|
+
const last = points[points.length - 1];
|
|
1590
|
+
const first = points[0];
|
|
1591
|
+
return `${line} L ${last.x},${baseY} L ${first.x},${baseY} Z`;
|
|
1592
|
+
}
|
|
1593
|
+
function monotoneTangents(points) {
|
|
1594
|
+
const n = points.length;
|
|
1595
|
+
const slopes = new Array(n - 1);
|
|
1596
|
+
for (let i = 0; i < n - 1; i++) {
|
|
1597
|
+
const dx = points[i + 1].x - points[i].x || 1;
|
|
1598
|
+
slopes[i] = (points[i + 1].y - points[i].y) / dx;
|
|
1599
|
+
}
|
|
1600
|
+
const tangents = new Array(n);
|
|
1601
|
+
tangents[0] = slopes[0];
|
|
1602
|
+
tangents[n - 1] = slopes[n - 2];
|
|
1603
|
+
for (let i = 1; i < n - 1; i++) {
|
|
1604
|
+
const s0 = slopes[i - 1];
|
|
1605
|
+
const s1 = slopes[i];
|
|
1606
|
+
if (s0 * s1 <= 0) {
|
|
1607
|
+
tangents[i] = 0;
|
|
1608
|
+
} else {
|
|
1609
|
+
tangents[i] = (s0 + s1) / 2;
|
|
1550
1610
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1611
|
+
}
|
|
1612
|
+
for (let i = 0; i < n - 1; i++) {
|
|
1613
|
+
const s = slopes[i];
|
|
1614
|
+
if (s === 0) {
|
|
1615
|
+
tangents[i] = 0;
|
|
1616
|
+
tangents[i + 1] = 0;
|
|
1617
|
+
continue;
|
|
1618
|
+
}
|
|
1619
|
+
const a = tangents[i] / s;
|
|
1620
|
+
const b = tangents[i + 1] / s;
|
|
1621
|
+
const h = Math.hypot(a, b);
|
|
1622
|
+
if (h > 3) {
|
|
1623
|
+
const t = 3 / h;
|
|
1624
|
+
tangents[i] = t * a * s;
|
|
1625
|
+
tangents[i + 1] = t * b * s;
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
return tangents;
|
|
1629
|
+
}
|
|
1630
|
+
function niceTicks(min, max, count = 4) {
|
|
1631
|
+
if (!Number.isFinite(min) || !Number.isFinite(max) || max === min) {
|
|
1632
|
+
return [min || 0];
|
|
1633
|
+
}
|
|
1634
|
+
const step = niceStep((max - min) / count);
|
|
1635
|
+
const start = Math.floor(min / step) * step;
|
|
1636
|
+
const out = [];
|
|
1637
|
+
for (let v = start; v <= max + step / 2; v += step) {
|
|
1638
|
+
out.push(round(v));
|
|
1639
|
+
}
|
|
1640
|
+
return out;
|
|
1641
|
+
}
|
|
1642
|
+
function niceStep(raw) {
|
|
1643
|
+
const exp = Math.floor(Math.log10(Math.abs(raw) || 1));
|
|
1644
|
+
const base = Math.pow(10, exp);
|
|
1645
|
+
const norm = raw / base;
|
|
1646
|
+
let nice = 1;
|
|
1647
|
+
if (norm >= 5) nice = 5;
|
|
1648
|
+
else if (norm >= 2) nice = 2;
|
|
1649
|
+
return nice * base;
|
|
1650
|
+
}
|
|
1651
|
+
function round(v) {
|
|
1652
|
+
return Math.round(v * 1e6) / 1e6;
|
|
1653
|
+
}
|
|
1654
|
+
function formatCompact(value, unit) {
|
|
1655
|
+
const abs = Math.abs(value);
|
|
1656
|
+
let s;
|
|
1657
|
+
if (abs >= 1e6) s = `${round(value / 1e6)}M`;
|
|
1658
|
+
else if (abs >= 1e3) s = `${round(value / 1e3)}k`;
|
|
1659
|
+
else s = String(round(value));
|
|
1660
|
+
return unit ? `${s}${unit}` : s;
|
|
1661
|
+
}
|
|
1553
1662
|
|
|
1554
|
-
// src/
|
|
1555
|
-
var
|
|
1556
|
-
var
|
|
1557
|
-
artifact
|
|
1558
|
-
}) => {
|
|
1559
|
-
const { type: _t, chartType = "bar", data = [] } = artifact;
|
|
1560
|
-
const xKey = artifact.xKey ?? inferXKey(data);
|
|
1561
|
-
const dataKeys = (0, import_react7.useMemo)(() => {
|
|
1562
|
-
if (Array.isArray(artifact.dataKey)) return artifact.dataKey;
|
|
1563
|
-
if (typeof artifact.dataKey === "string") return [artifact.dataKey];
|
|
1564
|
-
return inferDataKeys(data, xKey);
|
|
1565
|
-
}, [artifact.dataKey, data, xKey]);
|
|
1566
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ArtifactCard, { title: artifact.title, kind: "chart", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "aui-artifact-chart p-3", children: [
|
|
1567
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1568
|
-
ChartSvg,
|
|
1569
|
-
{
|
|
1570
|
-
chartType,
|
|
1571
|
-
data,
|
|
1572
|
-
xKey,
|
|
1573
|
-
dataKeys,
|
|
1574
|
-
unit: artifact.unit
|
|
1575
|
-
}
|
|
1576
|
-
),
|
|
1577
|
-
dataKeys.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Legend, { dataKeys })
|
|
1578
|
-
] }) });
|
|
1579
|
-
};
|
|
1580
|
-
var COLORS = [
|
|
1663
|
+
// src/charts/line-area-chart.tsx
|
|
1664
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1665
|
+
var CHART_PALETTE = [
|
|
1581
1666
|
"var(--primary, #6366f1)",
|
|
1582
|
-
"#
|
|
1667
|
+
"#10b981",
|
|
1583
1668
|
"#f59e0b",
|
|
1584
|
-
"#ef4444",
|
|
1585
1669
|
"#06b6d4",
|
|
1586
|
-
"#a855f7"
|
|
1670
|
+
"#a855f7",
|
|
1671
|
+
"#ef4444"
|
|
1587
1672
|
];
|
|
1588
|
-
var
|
|
1589
|
-
var
|
|
1590
|
-
var
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
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
|
+
var LineAreaChart = ({
|
|
1676
|
+
data = [],
|
|
1677
|
+
xKey: xKeyProp,
|
|
1678
|
+
series: seriesProp,
|
|
1679
|
+
variant = "area",
|
|
1680
|
+
height = 240,
|
|
1681
|
+
unit,
|
|
1682
|
+
yMax,
|
|
1683
|
+
layout = "default",
|
|
1684
|
+
showGrid = true,
|
|
1685
|
+
showXAxis: showXAxisProp,
|
|
1686
|
+
showYAxis: showYAxisProp,
|
|
1687
|
+
showLegend: showLegendProp,
|
|
1688
|
+
showTooltip = true,
|
|
1689
|
+
formatValue,
|
|
1690
|
+
formatX,
|
|
1691
|
+
className,
|
|
1692
|
+
ariaLabel = "Chart"
|
|
1693
|
+
}) => {
|
|
1694
|
+
const uid = (0, import_react8.useId)();
|
|
1695
|
+
const { ref, width } = useChartWidth();
|
|
1696
|
+
const [active, setActive] = (0, import_react8.useState)(null);
|
|
1697
|
+
const [grown, setGrown] = (0, import_react8.useState)(false);
|
|
1698
|
+
const xKey = xKeyProp ?? inferXKey(data);
|
|
1699
|
+
const series = (0, import_react8.useMemo)(
|
|
1700
|
+
() => resolveSeries(seriesProp, data, xKey),
|
|
1701
|
+
[seriesProp, data, xKey]
|
|
1702
|
+
);
|
|
1703
|
+
const pad = layout === "flush" ? PAD_FLUSH : PAD_DEFAULT;
|
|
1704
|
+
const showXAxis = showXAxisProp ?? layout !== "flush";
|
|
1705
|
+
const showYAxis = showYAxisProp ?? layout !== "flush";
|
|
1706
|
+
const showLegend = showLegendProp ?? (layout !== "flush" && series.length > 1);
|
|
1707
|
+
(0, import_react8.useEffect)(() => {
|
|
1708
|
+
const t = requestAnimationFrame(() => setGrown(true));
|
|
1709
|
+
return () => cancelAnimationFrame(t);
|
|
1710
|
+
}, []);
|
|
1711
|
+
const innerW = Math.max(0, width - pad.left - pad.right);
|
|
1712
|
+
const innerH = Math.max(0, height - pad.top - pad.bottom);
|
|
1713
|
+
const { minV, maxV } = (0, import_react8.useMemo)(() => {
|
|
1714
|
+
let lo = 0;
|
|
1715
|
+
let hi = yMax ?? 0;
|
|
1716
|
+
for (const s of series) {
|
|
1717
|
+
for (const d of data) {
|
|
1718
|
+
const v = toNum(d[s.dataKey]);
|
|
1719
|
+
if (v > hi && yMax == null) hi = v;
|
|
1720
|
+
if (v < lo) lo = v;
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
if (hi === lo) hi = lo + 1;
|
|
1724
|
+
return { minV: lo, maxV: yMax != null ? yMax : hi * 1.08 };
|
|
1725
|
+
}, [series, data, yMax]);
|
|
1726
|
+
const ticks = (0, import_react8.useMemo)(() => niceTicks(minV, maxV, 4), [minV, maxV]);
|
|
1727
|
+
if (data.length === 0 || series.length === 0) {
|
|
1728
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChartEmpty, { className, height });
|
|
1597
1729
|
}
|
|
1598
|
-
const
|
|
1599
|
-
const innerH = H - PAD.top - PAD.bottom;
|
|
1600
|
-
const all = dataKeys.flatMap((k) => data.map((d) => toNum(d[k])));
|
|
1601
|
-
const maxV = Math.max(0, ...all);
|
|
1602
|
-
const minV = Math.min(0, ...all);
|
|
1603
|
-
const range = maxV - minV || 1;
|
|
1604
|
-
const yScale = (v) => PAD.top + innerH - (v - minV) / range * innerH;
|
|
1730
|
+
const yScale = (v) => pad.top + innerH - (v - minV) / (maxV - minV || 1) * innerH;
|
|
1605
1731
|
const xCount = data.length;
|
|
1606
1732
|
const xStep = xCount > 1 ? innerW / (xCount - 1) : innerW;
|
|
1607
|
-
const xPos = (i) =>
|
|
1608
|
-
const
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1733
|
+
const xPos = (i) => variant === "bar" ? pad.left + innerW * (i + 0.5) / xCount : pad.left + i * xStep;
|
|
1734
|
+
const baseY = yScale(Math.max(0, minV));
|
|
1735
|
+
const fmtV = (v) => formatValue ? formatValue(v) : formatCompact(v, unit);
|
|
1736
|
+
const fmtX = (i) => formatX ? formatX(data[i]?.[xKey], i) : String(data[i]?.[xKey] ?? i);
|
|
1737
|
+
const onMove = (event) => {
|
|
1738
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
1739
|
+
const px2 = event.clientX - rect.left - pad.left;
|
|
1740
|
+
const i = Math.round(px2 / (xStep || 1));
|
|
1741
|
+
setActive(Math.max(0, Math.min(xCount - 1, i)));
|
|
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",
|
|
1747
|
+
{
|
|
1748
|
+
width,
|
|
1749
|
+
height,
|
|
1750
|
+
role: "img",
|
|
1751
|
+
"aria-label": ariaLabel,
|
|
1752
|
+
className: "block overflow-visible",
|
|
1753
|
+
children: [
|
|
1754
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("defs", { children: [
|
|
1755
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("clipPath", { id: `${uid}-grow`, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1756
|
+
"rect",
|
|
1757
|
+
{
|
|
1758
|
+
x: pad.left,
|
|
1759
|
+
y: 0,
|
|
1760
|
+
height,
|
|
1761
|
+
width: grown ? innerW : 0,
|
|
1762
|
+
style: { transition: "width 900ms cubic-bezier(0.22,1,0.36,1)" }
|
|
1763
|
+
}
|
|
1764
|
+
) }),
|
|
1765
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("linearGradient", { id: `${uid}-gridfade`, x1: "0%", x2: "100%", y1: "0", y2: "0", children: [
|
|
1766
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("stop", { offset: "0%", stopColor: "white", stopOpacity: 0 }),
|
|
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)(
|
|
1619
1801
|
"line",
|
|
1620
1802
|
{
|
|
1621
|
-
x1:
|
|
1622
|
-
x2:
|
|
1803
|
+
x1: pad.left,
|
|
1804
|
+
x2: width - pad.right,
|
|
1623
1805
|
y1: yScale(t),
|
|
1624
1806
|
y2: yScale(t),
|
|
1625
1807
|
stroke: "currentColor",
|
|
1626
|
-
strokeOpacity: 0.
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
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)(
|
|
1630
1815
|
"text",
|
|
1631
1816
|
{
|
|
1632
|
-
x:
|
|
1817
|
+
x: pad.left - 8,
|
|
1633
1818
|
y: yScale(t),
|
|
1634
1819
|
textAnchor: "end",
|
|
1635
1820
|
dominantBaseline: "middle",
|
|
1636
|
-
className: "fill-muted-foreground text-[10px]",
|
|
1637
|
-
children:
|
|
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",
|
|
1847
|
+
{
|
|
1848
|
+
d: monotoneLinePath(pts),
|
|
1849
|
+
fill: "none",
|
|
1850
|
+
stroke: color,
|
|
1851
|
+
strokeWidth: 2,
|
|
1852
|
+
strokeLinecap: "round",
|
|
1853
|
+
strokeLinejoin: "round"
|
|
1854
|
+
}
|
|
1855
|
+
)
|
|
1856
|
+
] }, s.dataKey);
|
|
1857
|
+
}) }),
|
|
1858
|
+
showTooltip && active != null && variant !== "bar" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("g", { pointerEvents: "none", children: [
|
|
1859
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1860
|
+
"line",
|
|
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",
|
|
1875
|
+
{
|
|
1876
|
+
cx: xPos(active),
|
|
1877
|
+
cy: yScale(toNum(data[active]?.[s.dataKey])),
|
|
1878
|
+
r: 4,
|
|
1879
|
+
fill: color,
|
|
1880
|
+
stroke: "var(--background, #fff)",
|
|
1881
|
+
strokeWidth: 2
|
|
1882
|
+
},
|
|
1883
|
+
s.dataKey
|
|
1884
|
+
);
|
|
1885
|
+
})
|
|
1886
|
+
] }),
|
|
1887
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1888
|
+
"rect",
|
|
1889
|
+
{
|
|
1890
|
+
x: pad.left,
|
|
1891
|
+
y: pad.top,
|
|
1892
|
+
width: innerW,
|
|
1893
|
+
height: innerH,
|
|
1894
|
+
fill: "transparent",
|
|
1895
|
+
style: { cursor: "crosshair" },
|
|
1896
|
+
onMouseMove: onMove,
|
|
1897
|
+
onMouseLeave: () => setActive(null)
|
|
1638
1898
|
}
|
|
1639
1899
|
)
|
|
1640
|
-
]
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
xPos,
|
|
1659
|
-
yScale,
|
|
1660
|
-
color: COLORS[ki % COLORS.length]
|
|
1661
|
-
},
|
|
1662
|
-
k
|
|
1663
|
-
)),
|
|
1664
|
-
chartType === "area" && dataKeys.map((k, ki) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1665
|
-
Area,
|
|
1666
|
-
{
|
|
1667
|
-
data,
|
|
1668
|
-
dataKey: k,
|
|
1669
|
-
xPos,
|
|
1670
|
-
yScale,
|
|
1671
|
-
baseY: yScale(Math.max(0, minV)),
|
|
1672
|
-
color: COLORS[ki % COLORS.length]
|
|
1673
|
-
},
|
|
1674
|
-
k
|
|
1675
|
-
))
|
|
1676
|
-
]
|
|
1677
|
-
}
|
|
1678
|
-
);
|
|
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
|
+
}))
|
|
1914
|
+
}
|
|
1915
|
+
),
|
|
1916
|
+
showLegend ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChartLegend, { series }) : null
|
|
1917
|
+
] });
|
|
1679
1918
|
};
|
|
1680
1919
|
function renderBars(args) {
|
|
1681
|
-
const { data,
|
|
1682
|
-
const groupWidth = innerW / xCount * 0.
|
|
1683
|
-
const barWidth = groupWidth /
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
const
|
|
1688
|
-
const
|
|
1689
|
-
const x = xPos(i) - groupWidth / 2 + ki * barWidth;
|
|
1920
|
+
const { data, series, xCount, xPos, yScale, baseY, innerW } = args;
|
|
1921
|
+
const groupWidth = innerW / xCount * 0.66;
|
|
1922
|
+
const barWidth = groupWidth / series.length;
|
|
1923
|
+
return series.flatMap(
|
|
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;
|
|
1690
1928
|
const top = Math.min(y, baseY);
|
|
1691
|
-
const
|
|
1692
|
-
return /* @__PURE__ */ (0,
|
|
1929
|
+
const h = Math.max(1, Math.abs(y - baseY));
|
|
1930
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1693
1931
|
"rect",
|
|
1694
1932
|
{
|
|
1695
1933
|
x,
|
|
1696
1934
|
y: top,
|
|
1697
1935
|
width: Math.max(1, barWidth - 2),
|
|
1698
|
-
height:
|
|
1699
|
-
rx:
|
|
1700
|
-
fill:
|
|
1936
|
+
height: h,
|
|
1937
|
+
rx: 3,
|
|
1938
|
+
fill: color
|
|
1701
1939
|
},
|
|
1702
|
-
`${
|
|
1940
|
+
`${s.dataKey}-${i}`
|
|
1703
1941
|
);
|
|
1704
1942
|
})
|
|
1705
1943
|
);
|
|
1706
1944
|
}
|
|
1707
|
-
var
|
|
1708
|
-
const
|
|
1709
|
-
return /* @__PURE__ */ (0,
|
|
1710
|
-
"
|
|
1945
|
+
var ChartTooltip = ({ x, width, title, rows }) => {
|
|
1946
|
+
const flip = x > width - 160;
|
|
1947
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1948
|
+
"div",
|
|
1711
1949
|
{
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
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
|
+
]
|
|
1718
1971
|
}
|
|
1719
1972
|
);
|
|
1720
1973
|
};
|
|
1721
|
-
var
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
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)(
|
|
1985
|
+
"div",
|
|
1986
|
+
{
|
|
1987
|
+
className: cn(
|
|
1988
|
+
"flex w-full items-center justify-center text-xs text-muted-foreground",
|
|
1989
|
+
className
|
|
1990
|
+
),
|
|
1991
|
+
style: { height },
|
|
1992
|
+
children: "No data yet"
|
|
1993
|
+
}
|
|
1994
|
+
);
|
|
1995
|
+
function inferXKey(data) {
|
|
1996
|
+
if (data.length === 0) return "x";
|
|
1997
|
+
for (const k of Object.keys(data[0])) {
|
|
1998
|
+
if (typeof data[0][k] !== "number") return k;
|
|
1999
|
+
}
|
|
2000
|
+
return Object.keys(data[0])[0] ?? "x";
|
|
2001
|
+
}
|
|
2002
|
+
function resolveSeries(seriesProp, data, xKey) {
|
|
2003
|
+
if (seriesProp && seriesProp.length > 0) {
|
|
2004
|
+
return seriesProp.map((s) => typeof s === "string" ? { dataKey: s } : s);
|
|
2005
|
+
}
|
|
2006
|
+
if (data.length === 0) return [];
|
|
2007
|
+
return Object.keys(data[0]).filter((k) => k !== xKey && typeof data[0][k] === "number").map((dataKey) => ({ dataKey }));
|
|
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);
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
// src/artifacts/artifact-card.tsx
|
|
2020
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2021
|
+
var ArtifactCard = ({ title, kind, className, bodyClassName, toolbar, children }) => {
|
|
2022
|
+
const hasHeader = Boolean(title || toolbar);
|
|
2023
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
2024
|
+
"div",
|
|
2025
|
+
{
|
|
2026
|
+
className: cn(
|
|
2027
|
+
"aui-artifact-root my-3 overflow-hidden rounded-xl border border-border/60 bg-background shadow-sm",
|
|
2028
|
+
className
|
|
2029
|
+
),
|
|
2030
|
+
"data-artifact-kind": kind,
|
|
2031
|
+
children: [
|
|
2032
|
+
hasHeader && /* @__PURE__ */ (0, import_jsx_runtime10.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: [
|
|
2033
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "aui-artifact-title flex-1 truncate text-xs font-semibold text-foreground/80", children: title }),
|
|
2034
|
+
!title && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "flex-1" }),
|
|
2035
|
+
toolbar
|
|
2036
|
+
] }),
|
|
2037
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: cn("aui-artifact-body", bodyClassName), children })
|
|
2038
|
+
]
|
|
2039
|
+
}
|
|
2040
|
+
);
|
|
1729
2041
|
};
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
2042
|
+
|
|
2043
|
+
// src/artifacts/chart-artifact.tsx
|
|
2044
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2045
|
+
var ChartArtifactView = ({
|
|
2046
|
+
artifact,
|
|
2047
|
+
embedded = false,
|
|
2048
|
+
height = 300
|
|
2049
|
+
}) => {
|
|
2050
|
+
const plot = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ChartArtifactPlot, { artifact, height });
|
|
2051
|
+
if (embedded) {
|
|
2052
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "aui-artifact-chart w-full", children: plot });
|
|
2053
|
+
}
|
|
2054
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ArtifactCard, { title: artifact.title, kind: "chart", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "aui-artifact-chart pt-2", children: plot }) });
|
|
2055
|
+
};
|
|
2056
|
+
function ChartArtifactPlot({
|
|
2057
|
+
artifact,
|
|
2058
|
+
height
|
|
2059
|
+
}) {
|
|
2060
|
+
const { chartType = "bar", data = [] } = artifact;
|
|
2061
|
+
const xKey = artifact.xKey ?? inferXKey2(data);
|
|
2062
|
+
const series = (0, import_react9.useMemo)(() => {
|
|
2063
|
+
const keys = Array.isArray(artifact.dataKey) ? artifact.dataKey : typeof artifact.dataKey === "string" ? [artifact.dataKey] : inferDataKeys(data, xKey);
|
|
2064
|
+
return keys.map((dataKey) => ({ dataKey }));
|
|
2065
|
+
}, [artifact.dataKey, data, xKey]);
|
|
2066
|
+
if (chartType === "pie") {
|
|
2067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PieChart, { data, xKey, dataKey: series[0]?.dataKey ?? "value" }) });
|
|
2068
|
+
}
|
|
2069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2070
|
+
LineAreaChart,
|
|
1738
2071
|
{
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
const end = acc / total * Math.PI * 2;
|
|
1748
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1749
|
-
PieSlice,
|
|
1750
|
-
{
|
|
1751
|
-
cx,
|
|
1752
|
-
cy,
|
|
1753
|
-
r,
|
|
1754
|
-
start,
|
|
1755
|
-
end,
|
|
1756
|
-
color: COLORS[i % COLORS.length],
|
|
1757
|
-
label: String(d[xKey] ?? i)
|
|
1758
|
-
},
|
|
1759
|
-
i
|
|
1760
|
-
);
|
|
1761
|
-
})
|
|
2072
|
+
data,
|
|
2073
|
+
xKey,
|
|
2074
|
+
series,
|
|
2075
|
+
layout: "flush",
|
|
2076
|
+
height,
|
|
2077
|
+
variant: chartType === "line" ? "line" : chartType === "area" ? "area" : "bar",
|
|
2078
|
+
unit: artifact.unit,
|
|
2079
|
+
ariaLabel: typeof artifact.title === "string" ? artifact.title : "Chart"
|
|
1762
2080
|
}
|
|
1763
2081
|
);
|
|
2082
|
+
}
|
|
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
|
+
] });
|
|
1764
2133
|
};
|
|
1765
|
-
var PieSlice = ({ cx, cy, r, start, end, color
|
|
2134
|
+
var PieSlice = ({ cx, cy, r, start, end, color }) => {
|
|
1766
2135
|
const x1 = cx + Math.sin(start) * r;
|
|
1767
2136
|
const y1 = cy - Math.cos(start) * r;
|
|
1768
2137
|
const x2 = cx + Math.sin(end) * r;
|
|
1769
2138
|
const y2 = cy - Math.cos(end) * r;
|
|
1770
2139
|
const large = end - start > Math.PI ? 1 : 0;
|
|
1771
2140
|
const path = `M ${cx} ${cy} L ${x1} ${y1} A ${r} ${r} 0 ${large} 1 ${x2} ${y2} Z`;
|
|
1772
|
-
|
|
1773
|
-
const lx = cx + Math.sin(mid) * (r * 0.65);
|
|
1774
|
-
const ly = cy - Math.cos(mid) * (r * 0.65);
|
|
1775
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("g", { children: [
|
|
1776
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: path, fill: color, stroke: "var(--background, #fff)", strokeWidth: 1 }),
|
|
1777
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1778
|
-
"text",
|
|
1779
|
-
{
|
|
1780
|
-
x: lx,
|
|
1781
|
-
y: ly,
|
|
1782
|
-
textAnchor: "middle",
|
|
1783
|
-
dominantBaseline: "middle",
|
|
1784
|
-
className: "fill-white text-[10px] font-semibold",
|
|
1785
|
-
children: label
|
|
1786
|
-
}
|
|
1787
|
-
)
|
|
1788
|
-
] });
|
|
2141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: path, fill: color, stroke: "var(--background, #fff)", strokeWidth: 1.5 });
|
|
1789
2142
|
};
|
|
1790
|
-
|
|
1791
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1792
|
-
"span",
|
|
1793
|
-
{
|
|
1794
|
-
className: "inline-block size-2 rounded-sm",
|
|
1795
|
-
style: { background: COLORS[i % COLORS.length] },
|
|
1796
|
-
"aria-hidden": true
|
|
1797
|
-
}
|
|
1798
|
-
),
|
|
1799
|
-
k
|
|
1800
|
-
] }, k)) });
|
|
1801
|
-
var EmptyState = () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "aui-artifact-chart-empty flex h-32 items-center justify-center text-xs text-muted-foreground", children: "No data" });
|
|
1802
|
-
function inferXKey(data) {
|
|
2143
|
+
function inferXKey2(data) {
|
|
1803
2144
|
if (data.length === 0) return "x";
|
|
1804
2145
|
for (const k of Object.keys(data[0])) {
|
|
1805
2146
|
if (typeof data[0][k] !== "number") return k;
|
|
@@ -1812,41 +2153,10 @@ function inferDataKeys(data, xKey) {
|
|
|
1812
2153
|
(k) => k !== xKey && typeof data[0][k] === "number"
|
|
1813
2154
|
);
|
|
1814
2155
|
}
|
|
1815
|
-
function toNum(value) {
|
|
1816
|
-
const n = typeof value === "number" ? value : Number(value);
|
|
1817
|
-
return Number.isFinite(n) ? n : 0;
|
|
1818
|
-
}
|
|
1819
|
-
function niceTicks(min, max, count = 4) {
|
|
1820
|
-
if (max === min) return [min];
|
|
1821
|
-
const range = max - min;
|
|
1822
|
-
const step = niceStep(range / count);
|
|
1823
|
-
const start = Math.floor(min / step) * step;
|
|
1824
|
-
const out = [];
|
|
1825
|
-
for (let v = start; v <= max + step / 2; v += step) {
|
|
1826
|
-
out.push(round(v));
|
|
1827
|
-
}
|
|
1828
|
-
return out;
|
|
1829
|
-
}
|
|
1830
|
-
function niceStep(raw) {
|
|
1831
|
-
const exp = Math.floor(Math.log10(Math.abs(raw))) || 0;
|
|
1832
|
-
const base = Math.pow(10, exp);
|
|
1833
|
-
const norm = raw / base;
|
|
1834
|
-
let nice = 1;
|
|
1835
|
-
if (norm >= 5) nice = 5;
|
|
1836
|
-
else if (norm >= 2) nice = 2;
|
|
1837
|
-
return nice * base;
|
|
1838
|
-
}
|
|
1839
|
-
function round(v) {
|
|
1840
|
-
return Math.round(v * 1e6) / 1e6;
|
|
1841
|
-
}
|
|
1842
|
-
function formatTick(v, unit) {
|
|
1843
|
-
const s = Math.abs(v) >= 1e3 ? `${(v / 1e3).toFixed(1)}k` : String(round(v));
|
|
1844
|
-
return unit ? `${s}${unit}` : s;
|
|
1845
|
-
}
|
|
1846
2156
|
|
|
1847
2157
|
// src/artifacts/question-artifact.tsx
|
|
1848
|
-
var
|
|
1849
|
-
var
|
|
2158
|
+
var import_react10 = require("react");
|
|
2159
|
+
var import_react11 = require("@assistant-ui/react");
|
|
1850
2160
|
var import_lucide_react3 = require("lucide-react");
|
|
1851
2161
|
|
|
1852
2162
|
// src/design/classes.ts
|
|
@@ -1961,12 +2271,12 @@ var studioQuestionOptionSelectedClass = cn(
|
|
|
1961
2271
|
);
|
|
1962
2272
|
|
|
1963
2273
|
// src/artifacts/question-artifact.tsx
|
|
1964
|
-
var
|
|
2274
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1965
2275
|
function optionKey(option, index) {
|
|
1966
2276
|
const id = option.id?.trim();
|
|
1967
2277
|
return id ? id : `__option-${index}`;
|
|
1968
2278
|
}
|
|
1969
|
-
var OptionRadio = ({ selected }) => /* @__PURE__ */ (0,
|
|
2279
|
+
var OptionRadio = ({ selected }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1970
2280
|
"span",
|
|
1971
2281
|
{
|
|
1972
2282
|
className: cn(
|
|
@@ -1974,18 +2284,18 @@ var OptionRadio = ({ selected }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx
|
|
|
1974
2284
|
selected ? "border-foreground bg-foreground text-background" : "border-border bg-background"
|
|
1975
2285
|
),
|
|
1976
2286
|
"aria-hidden": true,
|
|
1977
|
-
children: selected ? /* @__PURE__ */ (0,
|
|
2287
|
+
children: selected ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react3.CheckIcon, { className: "size-2.5 stroke-[3]" }) : null
|
|
1978
2288
|
}
|
|
1979
2289
|
);
|
|
1980
2290
|
var QuestionArtifactView = ({
|
|
1981
2291
|
artifact
|
|
1982
2292
|
}) => {
|
|
1983
|
-
const runtime = (0,
|
|
1984
|
-
const [selected, setSelected] = (0,
|
|
1985
|
-
const [submittedIds, setSubmittedIds] = (0,
|
|
2293
|
+
const runtime = (0, import_react11.useThreadRuntime)();
|
|
2294
|
+
const [selected, setSelected] = (0, import_react10.useState)([]);
|
|
2295
|
+
const [submittedIds, setSubmittedIds] = (0, import_react10.useState)(null);
|
|
1986
2296
|
const isMulti = artifact.multi === true;
|
|
1987
2297
|
const isDisabled = submittedIds !== null;
|
|
1988
|
-
const send = (0,
|
|
2298
|
+
const send = (0, import_react10.useCallback)(
|
|
1989
2299
|
(keys) => {
|
|
1990
2300
|
if (keys.length === 0) return;
|
|
1991
2301
|
const labels = artifact.options.map((option, index) => ({ option, key: optionKey(option, index) })).filter(({ key }) => keys.includes(key)).map(({ option }) => option.label);
|
|
@@ -1997,7 +2307,7 @@ var QuestionArtifactView = ({
|
|
|
1997
2307
|
},
|
|
1998
2308
|
[artifact.options, runtime]
|
|
1999
2309
|
);
|
|
2000
|
-
const onPick = (0,
|
|
2310
|
+
const onPick = (0, import_react10.useCallback)(
|
|
2001
2311
|
(key) => {
|
|
2002
2312
|
if (isDisabled) return;
|
|
2003
2313
|
if (!isMulti) {
|
|
@@ -2010,15 +2320,15 @@ var QuestionArtifactView = ({
|
|
|
2010
2320
|
},
|
|
2011
2321
|
[isDisabled, isMulti, send]
|
|
2012
2322
|
);
|
|
2013
|
-
const onConfirm = (0,
|
|
2323
|
+
const onConfirm = (0, import_react10.useCallback)(() => {
|
|
2014
2324
|
send(selected);
|
|
2015
2325
|
}, [selected, send]);
|
|
2016
|
-
return /* @__PURE__ */ (0,
|
|
2017
|
-
artifact.prompt ? /* @__PURE__ */ (0,
|
|
2018
|
-
/* @__PURE__ */ (0,
|
|
2326
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: studioArtifactShellClass, "data-artifact-kind": "question", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "px-2.5 py-2", children: [
|
|
2327
|
+
artifact.prompt ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "mb-2 text-sm font-normal leading-snug text-foreground", children: artifact.prompt }) : null,
|
|
2328
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex flex-col gap-0.5", role: "list", children: artifact.options.map((option, index) => {
|
|
2019
2329
|
const key = optionKey(option, index);
|
|
2020
2330
|
const isSelected = submittedIds ? submittedIds.includes(key) : isMulti && selected.includes(key);
|
|
2021
|
-
return /* @__PURE__ */ (0,
|
|
2331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
2022
2332
|
"button",
|
|
2023
2333
|
{
|
|
2024
2334
|
type: "button",
|
|
@@ -2030,17 +2340,17 @@ var QuestionArtifactView = ({
|
|
|
2030
2340
|
isDisabled && (isSelected ? "cursor-default" : "cursor-not-allowed opacity-50")
|
|
2031
2341
|
),
|
|
2032
2342
|
children: [
|
|
2033
|
-
/* @__PURE__ */ (0,
|
|
2034
|
-
/* @__PURE__ */ (0,
|
|
2035
|
-
/* @__PURE__ */ (0,
|
|
2036
|
-
option.description ? /* @__PURE__ */ (0,
|
|
2343
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(OptionRadio, { selected: isSelected }),
|
|
2344
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "min-w-0 flex-1 text-left", children: [
|
|
2345
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "block font-normal text-foreground", children: option.label }),
|
|
2346
|
+
option.description ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: option.description }) : null
|
|
2037
2347
|
] })
|
|
2038
2348
|
]
|
|
2039
2349
|
},
|
|
2040
2350
|
key
|
|
2041
2351
|
);
|
|
2042
2352
|
}) }),
|
|
2043
|
-
isMulti && !submittedIds ? /* @__PURE__ */ (0,
|
|
2353
|
+
isMulti && !submittedIds ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mt-2 flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2044
2354
|
TimbalV2Button,
|
|
2045
2355
|
{
|
|
2046
2356
|
type: "button",
|
|
@@ -2055,12 +2365,12 @@ var QuestionArtifactView = ({
|
|
|
2055
2365
|
};
|
|
2056
2366
|
|
|
2057
2367
|
// src/artifacts/html-artifact.tsx
|
|
2058
|
-
var
|
|
2368
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2059
2369
|
var HtmlArtifactView = ({ artifact }) => {
|
|
2060
2370
|
const sandboxed = artifact.sandboxed !== false;
|
|
2061
2371
|
const sandbox = sandboxed ? "allow-scripts allow-same-origin allow-forms allow-modals allow-popups allow-pointer-lock" : void 0;
|
|
2062
2372
|
const height = artifact.height ?? "320px";
|
|
2063
|
-
return /* @__PURE__ */ (0,
|
|
2373
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ArtifactCard, { title: artifact.title, kind: "html", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2064
2374
|
"iframe",
|
|
2065
2375
|
{
|
|
2066
2376
|
title: artifact.title ?? "HTML artifact",
|
|
@@ -2073,7 +2383,7 @@ var HtmlArtifactView = ({ artifact }) => {
|
|
|
2073
2383
|
};
|
|
2074
2384
|
|
|
2075
2385
|
// src/artifacts/json-artifact.tsx
|
|
2076
|
-
var
|
|
2386
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2077
2387
|
var JsonArtifactView = ({
|
|
2078
2388
|
artifact
|
|
2079
2389
|
}) => {
|
|
@@ -2085,16 +2395,16 @@ var JsonArtifactView = ({
|
|
|
2085
2395
|
} catch {
|
|
2086
2396
|
body = String(data);
|
|
2087
2397
|
}
|
|
2088
|
-
return /* @__PURE__ */ (0,
|
|
2398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ArtifactCard, { title, kind: "json", children: /* @__PURE__ */ (0, import_jsx_runtime14.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 }) });
|
|
2089
2399
|
};
|
|
2090
2400
|
|
|
2091
2401
|
// src/artifacts/table-artifact.tsx
|
|
2092
|
-
var
|
|
2402
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2093
2403
|
var TableArtifactView = ({ artifact }) => {
|
|
2094
2404
|
const rows = artifact.rows ?? [];
|
|
2095
2405
|
const columns = artifact.columns ?? deriveColumns(rows);
|
|
2096
|
-
return /* @__PURE__ */ (0,
|
|
2097
|
-
/* @__PURE__ */ (0,
|
|
2406
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ArtifactCard, { title: artifact.title, kind: "table", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "aui-artifact-table-wrap overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("table", { className: "aui-artifact-table w-full border-collapse text-sm", children: [
|
|
2407
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("tr", { className: "border-b border-border/40 bg-muted/20", children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2098
2408
|
"th",
|
|
2099
2409
|
{
|
|
2100
2410
|
className: "px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-muted-foreground",
|
|
@@ -2102,11 +2412,11 @@ var TableArtifactView = ({ artifact }) => {
|
|
|
2102
2412
|
},
|
|
2103
2413
|
col.key
|
|
2104
2414
|
)) }) }),
|
|
2105
|
-
/* @__PURE__ */ (0,
|
|
2415
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("tbody", { children: rows.map((row, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2106
2416
|
"tr",
|
|
2107
2417
|
{
|
|
2108
2418
|
className: "border-b border-border/30 transition-colors last:border-b-0 hover:bg-muted/20",
|
|
2109
|
-
children: columns.map((col) => /* @__PURE__ */ (0,
|
|
2419
|
+
children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2110
2420
|
"td",
|
|
2111
2421
|
{
|
|
2112
2422
|
className: "px-3 py-2 align-top text-foreground/85",
|
|
@@ -2139,7 +2449,7 @@ function formatCell(value) {
|
|
|
2139
2449
|
}
|
|
2140
2450
|
|
|
2141
2451
|
// src/artifacts/ui/ui-artifact.tsx
|
|
2142
|
-
var
|
|
2452
|
+
var import_react16 = require("react");
|
|
2143
2453
|
|
|
2144
2454
|
// src/artifacts/ui/types.ts
|
|
2145
2455
|
function isUiBinding(value) {
|
|
@@ -2192,38 +2502,38 @@ function resolveBindable(value, state) {
|
|
|
2192
2502
|
}
|
|
2193
2503
|
|
|
2194
2504
|
// src/artifacts/ui/registry.tsx
|
|
2195
|
-
var
|
|
2196
|
-
var
|
|
2197
|
-
var UiStateContext = (0,
|
|
2198
|
-
var UiDispatchContext = (0,
|
|
2505
|
+
var import_react12 = require("react");
|
|
2506
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2507
|
+
var UiStateContext = (0, import_react12.createContext)({});
|
|
2508
|
+
var UiDispatchContext = (0, import_react12.createContext)(() => {
|
|
2199
2509
|
});
|
|
2200
|
-
var UiStateProvider = ({ state, dispatch, children }) => /* @__PURE__ */ (0,
|
|
2510
|
+
var UiStateProvider = ({ state, dispatch, children }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(UiStateContext.Provider, { value: state, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(UiDispatchContext.Provider, { value: dispatch, children }) });
|
|
2201
2511
|
function useUiState() {
|
|
2202
|
-
return (0,
|
|
2512
|
+
return (0, import_react12.useContext)(UiStateContext);
|
|
2203
2513
|
}
|
|
2204
2514
|
function useUiDispatch() {
|
|
2205
|
-
return (0,
|
|
2515
|
+
return (0, import_react12.useContext)(UiDispatchContext);
|
|
2206
2516
|
}
|
|
2207
|
-
var UiEventContext = (0,
|
|
2517
|
+
var UiEventContext = (0, import_react12.createContext)(
|
|
2208
2518
|
null
|
|
2209
2519
|
);
|
|
2210
|
-
var UiEventProvider = ({ onEvent, children }) => /* @__PURE__ */ (0,
|
|
2520
|
+
var UiEventProvider = ({ onEvent, children }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(UiEventContext.Provider, { value: onEvent, children });
|
|
2211
2521
|
function useUiEventEmitter() {
|
|
2212
|
-
return (0,
|
|
2522
|
+
return (0, import_react12.useContext)(UiEventContext);
|
|
2213
2523
|
}
|
|
2214
|
-
var UiCustomNodeRegistryContext = (0,
|
|
2524
|
+
var UiCustomNodeRegistryContext = (0, import_react12.createContext)({});
|
|
2215
2525
|
function useUiCustomNodeRegistry() {
|
|
2216
|
-
return (0,
|
|
2526
|
+
return (0, import_react12.useContext)(UiCustomNodeRegistryContext);
|
|
2217
2527
|
}
|
|
2218
2528
|
|
|
2219
2529
|
// src/artifacts/ui/nodes.tsx
|
|
2220
|
-
var
|
|
2221
|
-
var
|
|
2222
|
-
var
|
|
2530
|
+
var import_react13 = require("react");
|
|
2531
|
+
var import_react14 = require("motion/react");
|
|
2532
|
+
var import_react15 = require("@assistant-ui/react");
|
|
2223
2533
|
|
|
2224
2534
|
// src/ui/button.tsx
|
|
2225
2535
|
var import_class_variance_authority = require("class-variance-authority");
|
|
2226
|
-
var
|
|
2536
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2227
2537
|
var LEGACY_SIZE_TO_V2 = {
|
|
2228
2538
|
default: "md",
|
|
2229
2539
|
xs: "xs",
|
|
@@ -2273,7 +2583,7 @@ function Button({
|
|
|
2273
2583
|
const v2Variant = TIMBAL_V2_FROM_LEGACY_BUTTON[variant ?? "default"];
|
|
2274
2584
|
const v2Size = LEGACY_SIZE_TO_V2[size ?? "default"];
|
|
2275
2585
|
const isIconOnly = typeof size === "string" && size.startsWith("icon");
|
|
2276
|
-
return /* @__PURE__ */ (0,
|
|
2586
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2277
2587
|
TimbalV2Button,
|
|
2278
2588
|
{
|
|
2279
2589
|
"data-slot": "button",
|
|
@@ -2281,7 +2591,7 @@ function Button({
|
|
|
2281
2591
|
"data-size": size,
|
|
2282
2592
|
variant: v2Variant,
|
|
2283
2593
|
size: v2Size,
|
|
2284
|
-
shape: "
|
|
2594
|
+
shape: "pill",
|
|
2285
2595
|
isIconOnly,
|
|
2286
2596
|
asChild,
|
|
2287
2597
|
className: cn(buttonVariants({ variant, size, className })),
|
|
@@ -2291,29 +2601,29 @@ function Button({
|
|
|
2291
2601
|
}
|
|
2292
2602
|
|
|
2293
2603
|
// src/artifacts/ui/nodes.tsx
|
|
2294
|
-
var
|
|
2604
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2295
2605
|
var UiNodeView = ({ node }) => {
|
|
2296
2606
|
switch (node.kind) {
|
|
2297
2607
|
case "box":
|
|
2298
|
-
return /* @__PURE__ */ (0,
|
|
2608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BoxNode, { node });
|
|
2299
2609
|
case "text":
|
|
2300
|
-
return /* @__PURE__ */ (0,
|
|
2610
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TextNode, { node });
|
|
2301
2611
|
case "heading":
|
|
2302
|
-
return /* @__PURE__ */ (0,
|
|
2612
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(HeadingNode, { node });
|
|
2303
2613
|
case "badge":
|
|
2304
|
-
return /* @__PURE__ */ (0,
|
|
2614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(BadgeNode, { node });
|
|
2305
2615
|
case "button":
|
|
2306
|
-
return /* @__PURE__ */ (0,
|
|
2616
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ButtonNode, { node });
|
|
2307
2617
|
case "toggle":
|
|
2308
|
-
return /* @__PURE__ */ (0,
|
|
2618
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ToggleNode, { node });
|
|
2309
2619
|
case "slider":
|
|
2310
|
-
return /* @__PURE__ */ (0,
|
|
2620
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SliderNode, { node });
|
|
2311
2621
|
case "tooltip":
|
|
2312
|
-
return /* @__PURE__ */ (0,
|
|
2622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TooltipNode, { node });
|
|
2313
2623
|
case "draggable":
|
|
2314
|
-
return /* @__PURE__ */ (0,
|
|
2624
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DraggableNode, { node });
|
|
2315
2625
|
case "custom":
|
|
2316
|
-
return /* @__PURE__ */ (0,
|
|
2626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CustomNode, { node });
|
|
2317
2627
|
default:
|
|
2318
2628
|
return null;
|
|
2319
2629
|
}
|
|
@@ -2321,9 +2631,9 @@ var UiNodeView = ({ node }) => {
|
|
|
2321
2631
|
function useActionRunner() {
|
|
2322
2632
|
const state = useUiState();
|
|
2323
2633
|
const dispatch = useUiDispatch();
|
|
2324
|
-
const runtime = (0,
|
|
2634
|
+
const runtime = (0, import_react15.useThreadRuntime)();
|
|
2325
2635
|
const emit = useUiEventEmitter();
|
|
2326
|
-
return (0,
|
|
2636
|
+
return (0, import_react13.useCallback)(
|
|
2327
2637
|
(actions) => {
|
|
2328
2638
|
if (!actions) return;
|
|
2329
2639
|
const list = Array.isArray(actions) ? actions : [actions];
|
|
@@ -2373,7 +2683,7 @@ var JUSTIFY_CLS = {
|
|
|
2373
2683
|
};
|
|
2374
2684
|
var BoxNode = ({ node }) => {
|
|
2375
2685
|
const dir = node.direction ?? "col";
|
|
2376
|
-
return /* @__PURE__ */ (0,
|
|
2686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2377
2687
|
"div",
|
|
2378
2688
|
{
|
|
2379
2689
|
className: cn(
|
|
@@ -2388,7 +2698,7 @@ var BoxNode = ({ node }) => {
|
|
|
2388
2698
|
gap: node.gap !== void 0 ? `${node.gap * 0.25}rem` : void 0,
|
|
2389
2699
|
padding: node.padding !== void 0 ? `${node.padding * 0.25}rem` : void 0
|
|
2390
2700
|
},
|
|
2391
|
-
children: node.children?.map((child, i) => /* @__PURE__ */ (0,
|
|
2701
|
+
children: node.children?.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(UiNodeView, { node: child }, child.id ?? i))
|
|
2392
2702
|
}
|
|
2393
2703
|
);
|
|
2394
2704
|
};
|
|
@@ -2407,7 +2717,7 @@ var TEXT_WEIGHT = {
|
|
|
2407
2717
|
var TextNode = ({ node }) => {
|
|
2408
2718
|
const state = useUiState();
|
|
2409
2719
|
const value = resolveBindable(node.value, state);
|
|
2410
|
-
return /* @__PURE__ */ (0,
|
|
2720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2411
2721
|
"span",
|
|
2412
2722
|
{
|
|
2413
2723
|
className: cn(
|
|
@@ -2438,13 +2748,13 @@ var HeadingNode = ({ node }) => {
|
|
|
2438
2748
|
);
|
|
2439
2749
|
switch (level) {
|
|
2440
2750
|
case 1:
|
|
2441
|
-
return /* @__PURE__ */ (0,
|
|
2751
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h1", { className: cls, children: value });
|
|
2442
2752
|
case 2:
|
|
2443
|
-
return /* @__PURE__ */ (0,
|
|
2753
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h2", { className: cls, children: value });
|
|
2444
2754
|
case 3:
|
|
2445
|
-
return /* @__PURE__ */ (0,
|
|
2755
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h3", { className: cls, children: value });
|
|
2446
2756
|
case 4:
|
|
2447
|
-
return /* @__PURE__ */ (0,
|
|
2757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("h4", { className: cls, children: value });
|
|
2448
2758
|
}
|
|
2449
2759
|
};
|
|
2450
2760
|
var BADGE_TONE = {
|
|
@@ -2457,7 +2767,7 @@ var BADGE_TONE = {
|
|
|
2457
2767
|
var BadgeNode = ({ node }) => {
|
|
2458
2768
|
const state = useUiState();
|
|
2459
2769
|
const value = String(resolveBindable(node.value, state) ?? "");
|
|
2460
|
-
return /* @__PURE__ */ (0,
|
|
2770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2461
2771
|
"span",
|
|
2462
2772
|
{
|
|
2463
2773
|
className: cn(
|
|
@@ -2474,7 +2784,7 @@ var ButtonNode = ({ node }) => {
|
|
|
2474
2784
|
const run = useActionRunner();
|
|
2475
2785
|
const label = String(resolveBindable(node.label, state) ?? "");
|
|
2476
2786
|
const disabled = node.disabled !== void 0 ? Boolean(resolveBindable(node.disabled, state)) : false;
|
|
2477
|
-
return /* @__PURE__ */ (0,
|
|
2787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2478
2788
|
Button,
|
|
2479
2789
|
{
|
|
2480
2790
|
variant: node.variant ?? "default",
|
|
@@ -2496,7 +2806,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2496
2806
|
dispatch({ type: "toggle", path: node.binding });
|
|
2497
2807
|
run(node.onChange);
|
|
2498
2808
|
};
|
|
2499
|
-
return /* @__PURE__ */ (0,
|
|
2809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2500
2810
|
"label",
|
|
2501
2811
|
{
|
|
2502
2812
|
className: cn(
|
|
@@ -2504,7 +2814,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2504
2814
|
node.className
|
|
2505
2815
|
),
|
|
2506
2816
|
children: [
|
|
2507
|
-
/* @__PURE__ */ (0,
|
|
2817
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2508
2818
|
"button",
|
|
2509
2819
|
{
|
|
2510
2820
|
type: "button",
|
|
@@ -2515,7 +2825,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2515
2825
|
"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-[background,box-shadow,border-color] duration-200",
|
|
2516
2826
|
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")
|
|
2517
2827
|
),
|
|
2518
|
-
children: /* @__PURE__ */ (0,
|
|
2828
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2519
2829
|
"span",
|
|
2520
2830
|
{
|
|
2521
2831
|
className: cn(
|
|
@@ -2528,7 +2838,7 @@ var ToggleNode = ({ node }) => {
|
|
|
2528
2838
|
)
|
|
2529
2839
|
}
|
|
2530
2840
|
),
|
|
2531
|
-
label && /* @__PURE__ */ (0,
|
|
2841
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-foreground/85", children: label })
|
|
2532
2842
|
]
|
|
2533
2843
|
}
|
|
2534
2844
|
);
|
|
@@ -2548,12 +2858,12 @@ var SliderNode = ({ node }) => {
|
|
|
2548
2858
|
const next = Number(e.target.value);
|
|
2549
2859
|
dispatch({ type: "set", path: node.binding, value: next });
|
|
2550
2860
|
};
|
|
2551
|
-
return /* @__PURE__ */ (0,
|
|
2552
|
-
(label || showValue) && /* @__PURE__ */ (0,
|
|
2553
|
-
label && /* @__PURE__ */ (0,
|
|
2554
|
-
showValue && /* @__PURE__ */ (0,
|
|
2861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: cn("aui-ui-slider flex flex-col gap-1", node.className), children: [
|
|
2862
|
+
(label || showValue) && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center justify-between text-xs text-muted-foreground", children: [
|
|
2863
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: label }),
|
|
2864
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "font-mono", children: value })
|
|
2555
2865
|
] }),
|
|
2556
|
-
/* @__PURE__ */ (0,
|
|
2866
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2557
2867
|
"input",
|
|
2558
2868
|
{
|
|
2559
2869
|
type: "range",
|
|
@@ -2575,9 +2885,9 @@ var SliderNode = ({ node }) => {
|
|
|
2575
2885
|
var TooltipNode = ({ node }) => {
|
|
2576
2886
|
const state = useUiState();
|
|
2577
2887
|
const content = String(resolveBindable(node.content, state) ?? "");
|
|
2578
|
-
return /* @__PURE__ */ (0,
|
|
2579
|
-
/* @__PURE__ */ (0,
|
|
2580
|
-
/* @__PURE__ */ (0,
|
|
2888
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Tooltip, { children: [
|
|
2889
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: cn("aui-ui-tooltip-trigger inline-flex", node.className), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(UiNodeView, { node: node.child }) }) }),
|
|
2890
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(TooltipContent, { side: node.side ?? "top", children: content })
|
|
2581
2891
|
] }) });
|
|
2582
2892
|
};
|
|
2583
2893
|
var DraggableNode = ({ node }) => {
|
|
@@ -2585,8 +2895,8 @@ var DraggableNode = ({ node }) => {
|
|
|
2585
2895
|
const snapBack = node.snapBack ?? true;
|
|
2586
2896
|
const axis = node.axis ?? "both";
|
|
2587
2897
|
const dragProp = axis === "both" ? true : axis;
|
|
2588
|
-
return /* @__PURE__ */ (0,
|
|
2589
|
-
|
|
2898
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2899
|
+
import_react14.motion.div,
|
|
2590
2900
|
{
|
|
2591
2901
|
drag: dragProp,
|
|
2592
2902
|
dragMomentum: false,
|
|
@@ -2597,7 +2907,7 @@ var DraggableNode = ({ node }) => {
|
|
|
2597
2907
|
"aui-ui-draggable inline-block cursor-grab touch-none",
|
|
2598
2908
|
node.className
|
|
2599
2909
|
),
|
|
2600
|
-
children: /* @__PURE__ */ (0,
|
|
2910
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(UiNodeView, { node: node.child })
|
|
2601
2911
|
}
|
|
2602
2912
|
);
|
|
2603
2913
|
};
|
|
@@ -2607,8 +2917,8 @@ var CustomNode = ({ node }) => {
|
|
|
2607
2917
|
const Renderer = registry[node.name];
|
|
2608
2918
|
if (!Renderer) return null;
|
|
2609
2919
|
const resolvedProps = resolveProps(node.props ?? {}, state);
|
|
2610
|
-
const children = node.children?.map((child, i) => /* @__PURE__ */ (0,
|
|
2611
|
-
return /* @__PURE__ */ (0,
|
|
2920
|
+
const children = node.children?.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(UiNodeView, { node: child }, child.id ?? i));
|
|
2921
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Renderer, { props: resolvedProps, children });
|
|
2612
2922
|
};
|
|
2613
2923
|
function resolveProps(props, state) {
|
|
2614
2924
|
const out = {};
|
|
@@ -2619,17 +2929,17 @@ function resolveProps(props, state) {
|
|
|
2619
2929
|
}
|
|
2620
2930
|
|
|
2621
2931
|
// src/artifacts/ui/ui-artifact.tsx
|
|
2622
|
-
var
|
|
2932
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2623
2933
|
var UiArtifactView = ({ artifact }) => {
|
|
2624
|
-
const [state, dispatch] = (0,
|
|
2934
|
+
const [state, dispatch] = (0, import_react16.useReducer)(
|
|
2625
2935
|
uiStateReducer,
|
|
2626
2936
|
artifact.initialState ?? {}
|
|
2627
2937
|
);
|
|
2628
|
-
return /* @__PURE__ */ (0,
|
|
2938
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ArtifactCard, { title: artifact.title, kind: "ui", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(UiStateProvider, { state, dispatch, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "aui-ui-root p-3", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(UiNodeView, { node: artifact.root }) }) }) });
|
|
2629
2939
|
};
|
|
2630
2940
|
|
|
2631
2941
|
// src/artifacts/registry.tsx
|
|
2632
|
-
var
|
|
2942
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2633
2943
|
var defaultArtifactRenderers = {
|
|
2634
2944
|
chart: ChartArtifactView,
|
|
2635
2945
|
question: QuestionArtifactView,
|
|
@@ -2638,25 +2948,25 @@ var defaultArtifactRenderers = {
|
|
|
2638
2948
|
table: TableArtifactView,
|
|
2639
2949
|
ui: UiArtifactView
|
|
2640
2950
|
};
|
|
2641
|
-
var ArtifactRegistryContext = (0,
|
|
2951
|
+
var ArtifactRegistryContext = (0, import_react17.createContext)(
|
|
2642
2952
|
defaultArtifactRenderers
|
|
2643
2953
|
);
|
|
2644
2954
|
var ArtifactRegistryProvider = ({ renderers, override, children }) => {
|
|
2645
|
-
const merged = (0,
|
|
2955
|
+
const merged = (0, import_react17.useMemo)(() => {
|
|
2646
2956
|
if (!renderers) return defaultArtifactRenderers;
|
|
2647
2957
|
if (override) return renderers;
|
|
2648
2958
|
return { ...defaultArtifactRenderers, ...renderers };
|
|
2649
2959
|
}, [renderers, override]);
|
|
2650
|
-
return /* @__PURE__ */ (0,
|
|
2960
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ArtifactRegistryContext.Provider, { value: merged, children });
|
|
2651
2961
|
};
|
|
2652
2962
|
function useArtifactRegistry() {
|
|
2653
|
-
return (0,
|
|
2963
|
+
return (0, import_react17.useContext)(ArtifactRegistryContext);
|
|
2654
2964
|
}
|
|
2655
2965
|
var ArtifactView = ({ artifact }) => {
|
|
2656
2966
|
const registry = useArtifactRegistry();
|
|
2657
2967
|
const Renderer = registry[artifact.type] ?? registry.json;
|
|
2658
2968
|
if (!Renderer) return null;
|
|
2659
|
-
return /* @__PURE__ */ (0,
|
|
2969
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Renderer, { artifact });
|
|
2660
2970
|
};
|
|
2661
2971
|
|
|
2662
2972
|
// src/artifacts/parse.ts
|
|
@@ -2732,7 +3042,7 @@ var import_c = __toESM(require("shiki/langs/c.mjs"), 1);
|
|
|
2732
3042
|
var import_cpp = __toESM(require("shiki/langs/cpp.mjs"), 1);
|
|
2733
3043
|
var import_vitesse_dark = __toESM(require("shiki/themes/vitesse-dark.mjs"), 1);
|
|
2734
3044
|
var import_vitesse_light = __toESM(require("shiki/themes/vitesse-light.mjs"), 1);
|
|
2735
|
-
var
|
|
3045
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2736
3046
|
var SHIKI_THEME_DARK = "vitesse-dark";
|
|
2737
3047
|
var SHIKI_THEME_LIGHT = "vitesse-light";
|
|
2738
3048
|
var highlighterPromise = null;
|
|
@@ -2770,8 +3080,8 @@ var ShikiSyntaxHighlighter = ({
|
|
|
2770
3080
|
language,
|
|
2771
3081
|
code
|
|
2772
3082
|
}) => {
|
|
2773
|
-
const [html, setHtml] = (0,
|
|
2774
|
-
(0,
|
|
3083
|
+
const [html, setHtml] = (0, import_react18.useState)(null);
|
|
3084
|
+
(0, import_react18.useEffect)(() => {
|
|
2775
3085
|
let cancelled = false;
|
|
2776
3086
|
(async () => {
|
|
2777
3087
|
try {
|
|
@@ -2801,13 +3111,13 @@ var ShikiSyntaxHighlighter = ({
|
|
|
2801
3111
|
try {
|
|
2802
3112
|
const parsed = JSON.parse(code);
|
|
2803
3113
|
if (isArtifact(parsed)) {
|
|
2804
|
-
return /* @__PURE__ */ (0,
|
|
3114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ArtifactView, { artifact: parsed });
|
|
2805
3115
|
}
|
|
2806
3116
|
} catch {
|
|
2807
3117
|
}
|
|
2808
3118
|
}
|
|
2809
3119
|
if (html) {
|
|
2810
|
-
return /* @__PURE__ */ (0,
|
|
3120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2811
3121
|
"div",
|
|
2812
3122
|
{
|
|
2813
3123
|
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",
|
|
@@ -2815,14 +3125,14 @@ var ShikiSyntaxHighlighter = ({
|
|
|
2815
3125
|
}
|
|
2816
3126
|
);
|
|
2817
3127
|
}
|
|
2818
|
-
return /* @__PURE__ */ (0,
|
|
3128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Pre, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Code2, { children: code }) });
|
|
2819
3129
|
};
|
|
2820
3130
|
var syntax_highlighter_default = ShikiSyntaxHighlighter;
|
|
2821
3131
|
|
|
2822
3132
|
// src/chat/markdown-text.tsx
|
|
2823
|
-
var
|
|
3133
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2824
3134
|
var MarkdownTextImpl = () => {
|
|
2825
|
-
return /* @__PURE__ */ (0,
|
|
3135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2826
3136
|
import_react_markdown.MarkdownTextPrimitive,
|
|
2827
3137
|
{
|
|
2828
3138
|
remarkPlugins: [import_remark_gfm.default, import_remark_math.default],
|
|
@@ -2835,7 +3145,7 @@ var MarkdownTextImpl = () => {
|
|
|
2835
3145
|
}
|
|
2836
3146
|
);
|
|
2837
3147
|
};
|
|
2838
|
-
var MarkdownText = (0,
|
|
3148
|
+
var MarkdownText = (0, import_react19.memo)(MarkdownTextImpl);
|
|
2839
3149
|
var CodeHeader = ({ language, code }) => {
|
|
2840
3150
|
const { isCopied, copyToClipboard } = useCopyToClipboard();
|
|
2841
3151
|
if (isArtifactFenceLanguage(language)) return null;
|
|
@@ -2843,20 +3153,20 @@ var CodeHeader = ({ language, code }) => {
|
|
|
2843
3153
|
if (!code || isCopied) return;
|
|
2844
3154
|
copyToClipboard(code);
|
|
2845
3155
|
};
|
|
2846
|
-
return /* @__PURE__ */ (0,
|
|
2847
|
-
/* @__PURE__ */ (0,
|
|
2848
|
-
/* @__PURE__ */ (0,
|
|
3156
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.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: [
|
|
3157
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "flex items-center gap-2 text-xs font-semibold tracking-wide text-muted-foreground/80 uppercase", children: [
|
|
3158
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "inline-block h-2 w-2 rounded-full bg-primary/40" }),
|
|
2849
3159
|
language
|
|
2850
3160
|
] }),
|
|
2851
|
-
/* @__PURE__ */ (0,
|
|
3161
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
2852
3162
|
TooltipIconButton,
|
|
2853
3163
|
{
|
|
2854
3164
|
tooltip: isCopied ? "Copied!" : "Copy",
|
|
2855
3165
|
onClick: onCopy,
|
|
2856
3166
|
className: "transition-colors hover:text-foreground",
|
|
2857
3167
|
children: [
|
|
2858
|
-
!isCopied && /* @__PURE__ */ (0,
|
|
2859
|
-
isCopied && /* @__PURE__ */ (0,
|
|
3168
|
+
!isCopied && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react4.CopyIcon, { className: "h-3.5 w-3.5" }),
|
|
3169
|
+
isCopied && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react4.CheckIcon, { className: "h-3.5 w-3.5 text-emerald-500" })
|
|
2860
3170
|
]
|
|
2861
3171
|
}
|
|
2862
3172
|
)
|
|
@@ -2865,7 +3175,7 @@ var CodeHeader = ({ language, code }) => {
|
|
|
2865
3175
|
var useCopyToClipboard = ({
|
|
2866
3176
|
copiedDuration = 3e3
|
|
2867
3177
|
} = {}) => {
|
|
2868
|
-
const [isCopied, setIsCopied] = (0,
|
|
3178
|
+
const [isCopied, setIsCopied] = (0, import_react19.useState)(false);
|
|
2869
3179
|
const copyToClipboard = (value) => {
|
|
2870
3180
|
if (!value) return;
|
|
2871
3181
|
navigator.clipboard.writeText(value).then(() => {
|
|
@@ -2876,7 +3186,7 @@ var useCopyToClipboard = ({
|
|
|
2876
3186
|
return { isCopied, copyToClipboard };
|
|
2877
3187
|
};
|
|
2878
3188
|
var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownComponents)({
|
|
2879
|
-
h1: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3189
|
+
h1: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2880
3190
|
"h1",
|
|
2881
3191
|
{
|
|
2882
3192
|
className: cn(
|
|
@@ -2886,7 +3196,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2886
3196
|
...props
|
|
2887
3197
|
}
|
|
2888
3198
|
),
|
|
2889
|
-
h2: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3199
|
+
h2: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2890
3200
|
"h2",
|
|
2891
3201
|
{
|
|
2892
3202
|
className: cn(
|
|
@@ -2896,7 +3206,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2896
3206
|
...props
|
|
2897
3207
|
}
|
|
2898
3208
|
),
|
|
2899
|
-
h3: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3209
|
+
h3: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2900
3210
|
"h3",
|
|
2901
3211
|
{
|
|
2902
3212
|
className: cn(
|
|
@@ -2906,7 +3216,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2906
3216
|
...props
|
|
2907
3217
|
}
|
|
2908
3218
|
),
|
|
2909
|
-
h4: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3219
|
+
h4: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2910
3220
|
"h4",
|
|
2911
3221
|
{
|
|
2912
3222
|
className: cn(
|
|
@@ -2916,7 +3226,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2916
3226
|
...props
|
|
2917
3227
|
}
|
|
2918
3228
|
),
|
|
2919
|
-
h5: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3229
|
+
h5: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2920
3230
|
"h5",
|
|
2921
3231
|
{
|
|
2922
3232
|
className: cn(
|
|
@@ -2926,7 +3236,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2926
3236
|
...props
|
|
2927
3237
|
}
|
|
2928
3238
|
),
|
|
2929
|
-
h6: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3239
|
+
h6: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2930
3240
|
"h6",
|
|
2931
3241
|
{
|
|
2932
3242
|
className: cn(
|
|
@@ -2936,7 +3246,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2936
3246
|
...props
|
|
2937
3247
|
}
|
|
2938
3248
|
),
|
|
2939
|
-
p: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3249
|
+
p: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2940
3250
|
"p",
|
|
2941
3251
|
{
|
|
2942
3252
|
className: cn(
|
|
@@ -2946,7 +3256,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2946
3256
|
...props
|
|
2947
3257
|
}
|
|
2948
3258
|
),
|
|
2949
|
-
a: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3259
|
+
a: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2950
3260
|
"a",
|
|
2951
3261
|
{
|
|
2952
3262
|
className: cn(
|
|
@@ -2958,7 +3268,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2958
3268
|
...props
|
|
2959
3269
|
}
|
|
2960
3270
|
),
|
|
2961
|
-
blockquote: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3271
|
+
blockquote: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2962
3272
|
"blockquote",
|
|
2963
3273
|
{
|
|
2964
3274
|
className: cn(
|
|
@@ -2968,7 +3278,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2968
3278
|
...props
|
|
2969
3279
|
}
|
|
2970
3280
|
),
|
|
2971
|
-
ul: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3281
|
+
ul: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2972
3282
|
"ul",
|
|
2973
3283
|
{
|
|
2974
3284
|
className: cn(
|
|
@@ -2978,7 +3288,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2978
3288
|
...props
|
|
2979
3289
|
}
|
|
2980
3290
|
),
|
|
2981
|
-
ol: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3291
|
+
ol: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2982
3292
|
"ol",
|
|
2983
3293
|
{
|
|
2984
3294
|
className: cn(
|
|
@@ -2988,7 +3298,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2988
3298
|
...props
|
|
2989
3299
|
}
|
|
2990
3300
|
),
|
|
2991
|
-
hr: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3301
|
+
hr: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2992
3302
|
"hr",
|
|
2993
3303
|
{
|
|
2994
3304
|
className: cn(
|
|
@@ -2998,14 +3308,14 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
2998
3308
|
...props
|
|
2999
3309
|
}
|
|
3000
3310
|
),
|
|
3001
|
-
table: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3311
|
+
table: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "my-4 w-full overflow-x-auto rounded-lg border border-border/50", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3002
3312
|
"table",
|
|
3003
3313
|
{
|
|
3004
3314
|
className: cn("aui-md-table w-full border-collapse text-sm", className),
|
|
3005
3315
|
...props
|
|
3006
3316
|
}
|
|
3007
3317
|
) }),
|
|
3008
|
-
th: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3318
|
+
th: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3009
3319
|
"th",
|
|
3010
3320
|
{
|
|
3011
3321
|
className: cn(
|
|
@@ -3015,7 +3325,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3015
3325
|
...props
|
|
3016
3326
|
}
|
|
3017
3327
|
),
|
|
3018
|
-
td: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3328
|
+
td: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3019
3329
|
"td",
|
|
3020
3330
|
{
|
|
3021
3331
|
className: cn(
|
|
@@ -3025,7 +3335,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3025
3335
|
...props
|
|
3026
3336
|
}
|
|
3027
3337
|
),
|
|
3028
|
-
tr: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3338
|
+
tr: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3029
3339
|
"tr",
|
|
3030
3340
|
{
|
|
3031
3341
|
className: cn(
|
|
@@ -3035,8 +3345,8 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3035
3345
|
...props
|
|
3036
3346
|
}
|
|
3037
3347
|
),
|
|
3038
|
-
li: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3039
|
-
sup: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3348
|
+
li: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("li", { className: cn("aui-md-li leading-[1.7]", className), ...props }),
|
|
3349
|
+
sup: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3040
3350
|
"sup",
|
|
3041
3351
|
{
|
|
3042
3352
|
className: cn(
|
|
@@ -3046,7 +3356,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3046
3356
|
...props
|
|
3047
3357
|
}
|
|
3048
3358
|
),
|
|
3049
|
-
pre: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3359
|
+
pre: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3050
3360
|
"pre",
|
|
3051
3361
|
{
|
|
3052
3362
|
className: cn(
|
|
@@ -3058,7 +3368,7 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3058
3368
|
),
|
|
3059
3369
|
code: function Code({ className, ...props }) {
|
|
3060
3370
|
const isCodeBlock = (0, import_react_markdown.useIsMarkdownCodeBlock)();
|
|
3061
|
-
return /* @__PURE__ */ (0,
|
|
3371
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3062
3372
|
"code",
|
|
3063
3373
|
{
|
|
3064
3374
|
className: cn(
|
|
@@ -3069,20 +3379,20 @@ var defaultComponents = (0, import_react_markdown.unstable_memoizeMarkdownCompon
|
|
|
3069
3379
|
}
|
|
3070
3380
|
);
|
|
3071
3381
|
},
|
|
3072
|
-
strong: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3073
|
-
em: ({ className, ...props }) => /* @__PURE__ */ (0,
|
|
3382
|
+
strong: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("strong", { className: cn("font-semibold text-foreground", className), ...props }),
|
|
3383
|
+
em: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("em", { className: cn("italic", className), ...props }),
|
|
3074
3384
|
CodeHeader
|
|
3075
3385
|
});
|
|
3076
3386
|
|
|
3077
3387
|
// src/chat/tool-fallback.tsx
|
|
3078
|
-
var
|
|
3388
|
+
var import_react23 = require("react");
|
|
3079
3389
|
var import_lucide_react5 = require("lucide-react");
|
|
3080
|
-
var
|
|
3390
|
+
var import_react24 = require("@assistant-ui/react");
|
|
3081
3391
|
|
|
3082
3392
|
// src/ui/shimmer.tsx
|
|
3083
|
-
var
|
|
3084
|
-
var
|
|
3085
|
-
var
|
|
3393
|
+
var import_react20 = require("motion/react");
|
|
3394
|
+
var import_react21 = require("react");
|
|
3395
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3086
3396
|
var ShimmerComponent = ({
|
|
3087
3397
|
children,
|
|
3088
3398
|
as: Component = "p",
|
|
@@ -3090,14 +3400,14 @@ var ShimmerComponent = ({
|
|
|
3090
3400
|
duration = 2,
|
|
3091
3401
|
spread = 2
|
|
3092
3402
|
}) => {
|
|
3093
|
-
const MotionComponent =
|
|
3403
|
+
const MotionComponent = import_react20.motion.create(
|
|
3094
3404
|
Component
|
|
3095
3405
|
);
|
|
3096
|
-
const dynamicSpread = (0,
|
|
3406
|
+
const dynamicSpread = (0, import_react21.useMemo)(
|
|
3097
3407
|
() => (children?.length ?? 0) * spread,
|
|
3098
3408
|
[children, spread]
|
|
3099
3409
|
);
|
|
3100
|
-
return /* @__PURE__ */ (0,
|
|
3410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3101
3411
|
MotionComponent,
|
|
3102
3412
|
{
|
|
3103
3413
|
animate: { backgroundPosition: "0% center" },
|
|
@@ -3120,11 +3430,11 @@ var ShimmerComponent = ({
|
|
|
3120
3430
|
}
|
|
3121
3431
|
);
|
|
3122
3432
|
};
|
|
3123
|
-
var Shimmer = (0,
|
|
3433
|
+
var Shimmer = (0, import_react21.memo)(ShimmerComponent);
|
|
3124
3434
|
|
|
3125
3435
|
// src/chat/motion.tsx
|
|
3126
|
-
var
|
|
3127
|
-
var
|
|
3436
|
+
var import_react22 = require("motion/react");
|
|
3437
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3128
3438
|
var luxuryEase = [0.16, 1, 0.3, 1];
|
|
3129
3439
|
var TOOL_ENTER_MS = 0.78;
|
|
3130
3440
|
var TOOL_EXIT_MS = 0.28;
|
|
@@ -3150,10 +3460,10 @@ function toolMotionState(reduced, entering, variant) {
|
|
|
3150
3460
|
return entering ? { opacity: 0, y: 14, filter: "blur(10px)" } : { opacity: 1, y: 0, filter: "blur(0px)" };
|
|
3151
3461
|
}
|
|
3152
3462
|
function ToolMotion({ children, className, motionKey }) {
|
|
3153
|
-
const reduced = (0,
|
|
3463
|
+
const reduced = (0, import_react22.useReducedMotion)() ?? false;
|
|
3154
3464
|
const { enter, exit } = toolPresenceTransition(reduced);
|
|
3155
|
-
return /* @__PURE__ */ (0,
|
|
3156
|
-
|
|
3465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3466
|
+
import_react22.motion.div,
|
|
3157
3467
|
{
|
|
3158
3468
|
className: cn("aui-tool-motion w-full min-w-0", className),
|
|
3159
3469
|
initial: toolMotionState(reduced, true, "settled"),
|
|
@@ -3172,11 +3482,11 @@ function ToolPresence({
|
|
|
3172
3482
|
className,
|
|
3173
3483
|
variant = "settled"
|
|
3174
3484
|
}) {
|
|
3175
|
-
const reduced = (0,
|
|
3485
|
+
const reduced = (0, import_react22.useReducedMotion)() ?? false;
|
|
3176
3486
|
const { enter, exit } = toolPresenceTransition(reduced);
|
|
3177
3487
|
const enterTransition = variant === "executing" ? { duration: reduced ? 0.3 : 0.52, ease: luxuryEase } : enter;
|
|
3178
|
-
return /* @__PURE__ */ (0,
|
|
3179
|
-
|
|
3488
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react22.AnimatePresence, { mode: "wait", initial: true, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3489
|
+
import_react22.motion.div,
|
|
3180
3490
|
{
|
|
3181
3491
|
className: cn("aui-tool-presence w-full min-w-0", className),
|
|
3182
3492
|
initial: toolMotionState(reduced, true, variant),
|
|
@@ -3196,8 +3506,8 @@ function ToolBodyPresence({
|
|
|
3196
3506
|
children,
|
|
3197
3507
|
className
|
|
3198
3508
|
}) {
|
|
3199
|
-
const reduced = (0,
|
|
3200
|
-
return /* @__PURE__ */ (0,
|
|
3509
|
+
const reduced = (0, import_react22.useReducedMotion)() ?? false;
|
|
3510
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3201
3511
|
"div",
|
|
3202
3512
|
{
|
|
3203
3513
|
className: cn(
|
|
@@ -3205,7 +3515,7 @@ function ToolBodyPresence({
|
|
|
3205
3515
|
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)]"
|
|
3206
3516
|
),
|
|
3207
3517
|
style: { gridTemplateRows: open ? "1fr" : "0fr" },
|
|
3208
|
-
children: /* @__PURE__ */ (0,
|
|
3518
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3209
3519
|
"div",
|
|
3210
3520
|
{
|
|
3211
3521
|
className: cn(
|
|
@@ -3221,7 +3531,7 @@ function ToolBodyPresence({
|
|
|
3221
3531
|
}
|
|
3222
3532
|
|
|
3223
3533
|
// src/chat/tool-fallback.tsx
|
|
3224
|
-
var
|
|
3534
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3225
3535
|
function detectRunning({
|
|
3226
3536
|
status,
|
|
3227
3537
|
result,
|
|
@@ -3235,7 +3545,7 @@ function detectRunning({
|
|
|
3235
3545
|
}
|
|
3236
3546
|
function useToolRunning(props) {
|
|
3237
3547
|
const { isRunning: streamRunning } = useTimbalRuntime();
|
|
3238
|
-
const partStatus = (0,
|
|
3548
|
+
const partStatus = (0, import_react24.useAuiState)((s) => s.part.status);
|
|
3239
3549
|
return detectRunning({
|
|
3240
3550
|
status: partStatus ?? props.status,
|
|
3241
3551
|
result: props.result,
|
|
@@ -3253,8 +3563,8 @@ function formatToolResult(result) {
|
|
|
3253
3563
|
return String(result);
|
|
3254
3564
|
}
|
|
3255
3565
|
}
|
|
3256
|
-
var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__ */ (0,
|
|
3257
|
-
action ? shimmer ? /* @__PURE__ */ (0,
|
|
3566
|
+
var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "inline-flex min-w-0 max-w-full items-baseline gap-1", children: [
|
|
3567
|
+
action ? shimmer ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3258
3568
|
Shimmer,
|
|
3259
3569
|
{
|
|
3260
3570
|
as: "span",
|
|
@@ -3263,10 +3573,10 @@ var TimelineActionLabel = ({ action, detail, shimmer = false }) => /* @__PURE__
|
|
|
3263
3573
|
spread: 2.5,
|
|
3264
3574
|
children: action
|
|
3265
3575
|
}
|
|
3266
|
-
) : /* @__PURE__ */ (0,
|
|
3267
|
-
detail ? /* @__PURE__ */ (0,
|
|
3576
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: studioTimelineActionClass, children: action }) : null,
|
|
3577
|
+
detail ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: studioTimelineDetailClass, children: detail }) : null
|
|
3268
3578
|
] });
|
|
3269
|
-
var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0,
|
|
3579
|
+
var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3270
3580
|
import_lucide_react5.ChevronRightIcon,
|
|
3271
3581
|
{
|
|
3272
3582
|
className: studioTimelineChevronClass(expanded),
|
|
@@ -3274,9 +3584,9 @@ var TimelineHoverChevron = ({ expanded }) => /* @__PURE__ */ (0, import_jsx_runt
|
|
|
3274
3584
|
}
|
|
3275
3585
|
);
|
|
3276
3586
|
var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
3277
|
-
const [open, setOpen] = (0,
|
|
3587
|
+
const [open, setOpen] = (0, import_react23.useState)(false);
|
|
3278
3588
|
const detail = formatToolLabel(toolName);
|
|
3279
|
-
const formattedArgs = (0,
|
|
3589
|
+
const formattedArgs = (0, import_react23.useMemo)(() => {
|
|
3280
3590
|
if (!argsText || argsText === "{}") return null;
|
|
3281
3591
|
try {
|
|
3282
3592
|
return JSON.stringify(JSON.parse(argsText), null, 2);
|
|
@@ -3284,17 +3594,17 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3284
3594
|
return argsText;
|
|
3285
3595
|
}
|
|
3286
3596
|
}, [argsText]);
|
|
3287
|
-
const formattedResult = (0,
|
|
3597
|
+
const formattedResult = (0, import_react23.useMemo)(() => {
|
|
3288
3598
|
if (result === void 0 || result === null) return null;
|
|
3289
3599
|
return formatToolResult(result);
|
|
3290
3600
|
}, [result]);
|
|
3291
3601
|
const hasBody = Boolean(formattedArgs || formattedResult);
|
|
3292
3602
|
const action = isError ? "Failed" : "Used";
|
|
3293
3603
|
if (!hasBody) {
|
|
3294
|
-
return /* @__PURE__ */ (0,
|
|
3604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "aui-tool-row w-full min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TimelineActionLabel, { action, detail }) });
|
|
3295
3605
|
}
|
|
3296
|
-
return /* @__PURE__ */ (0,
|
|
3297
|
-
/* @__PURE__ */ (0,
|
|
3606
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "aui-tool-row w-full min-w-0", children: [
|
|
3607
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3298
3608
|
"button",
|
|
3299
3609
|
{
|
|
3300
3610
|
type: "button",
|
|
@@ -3302,7 +3612,7 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3302
3612
|
"aria-expanded": open,
|
|
3303
3613
|
"aria-label": `${action} ${detail}`,
|
|
3304
3614
|
className: studioTimelineRowButtonClass,
|
|
3305
|
-
children: /* @__PURE__ */ (0,
|
|
3615
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
3306
3616
|
"span",
|
|
3307
3617
|
{
|
|
3308
3618
|
className: cn(
|
|
@@ -3311,37 +3621,37 @@ var ToolPanel = ({ toolName, argsText, result, isError }) => {
|
|
|
3311
3621
|
"text-foreground"
|
|
3312
3622
|
),
|
|
3313
3623
|
children: [
|
|
3314
|
-
/* @__PURE__ */ (0,
|
|
3315
|
-
/* @__PURE__ */ (0,
|
|
3624
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TimelineActionLabel, { action, detail }),
|
|
3625
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TimelineHoverChevron, { expanded: open })
|
|
3316
3626
|
]
|
|
3317
3627
|
}
|
|
3318
3628
|
)
|
|
3319
3629
|
}
|
|
3320
3630
|
),
|
|
3321
|
-
/* @__PURE__ */ (0,
|
|
3631
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
3322
3632
|
ToolBodyPresence,
|
|
3323
3633
|
{
|
|
3324
3634
|
open,
|
|
3325
3635
|
className: cn(studioTimelineBodyPadClass, "gap-2"),
|
|
3326
3636
|
children: [
|
|
3327
|
-
formattedArgs ? /* @__PURE__ */ (0,
|
|
3637
|
+
formattedArgs ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3328
3638
|
"div",
|
|
3329
3639
|
{
|
|
3330
3640
|
className: cn(
|
|
3331
3641
|
studioComposerIoWellClass,
|
|
3332
3642
|
"max-h-48 overflow-auto px-2.5 py-2"
|
|
3333
3643
|
),
|
|
3334
|
-
children: /* @__PURE__ */ (0,
|
|
3644
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("pre", { className: "whitespace-pre-wrap break-words font-mono text-[11px] font-normal leading-relaxed text-foreground", children: formattedArgs })
|
|
3335
3645
|
}
|
|
3336
3646
|
) : null,
|
|
3337
|
-
formattedResult ? /* @__PURE__ */ (0,
|
|
3647
|
+
formattedResult ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3338
3648
|
"div",
|
|
3339
3649
|
{
|
|
3340
3650
|
className: cn(
|
|
3341
3651
|
studioComposerIoWellClass,
|
|
3342
3652
|
"max-h-48 overflow-auto px-2.5 py-2"
|
|
3343
3653
|
),
|
|
3344
|
-
children: /* @__PURE__ */ (0,
|
|
3654
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("pre", { className: "whitespace-pre-wrap break-words font-mono text-[11px] font-normal leading-relaxed text-foreground", children: formattedResult })
|
|
3345
3655
|
}
|
|
3346
3656
|
) : null
|
|
3347
3657
|
]
|
|
@@ -3358,20 +3668,20 @@ var ToolFallbackImpl = ({
|
|
|
3358
3668
|
const isRunning = useToolRunning({ status, result });
|
|
3359
3669
|
const isError = status?.type === "incomplete" && status.reason !== "cancelled";
|
|
3360
3670
|
const presenceKey = isRunning ? "running" : isError ? "error" : "complete";
|
|
3361
|
-
return /* @__PURE__ */ (0,
|
|
3671
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3362
3672
|
ToolPresence,
|
|
3363
3673
|
{
|
|
3364
3674
|
presenceKey,
|
|
3365
3675
|
variant: isRunning ? "executing" : "settled",
|
|
3366
3676
|
className: "py-0.5",
|
|
3367
|
-
children: isRunning ? /* @__PURE__ */ (0,
|
|
3677
|
+
children: isRunning ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "aui-tool-running", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3368
3678
|
TimelineActionLabel,
|
|
3369
3679
|
{
|
|
3370
3680
|
action: "Using",
|
|
3371
3681
|
detail: formatToolLabel(toolName),
|
|
3372
3682
|
shimmer: true
|
|
3373
3683
|
}
|
|
3374
|
-
) }) : /* @__PURE__ */ (0,
|
|
3684
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3375
3685
|
ToolPanel,
|
|
3376
3686
|
{
|
|
3377
3687
|
toolName,
|
|
@@ -3383,13 +3693,13 @@ var ToolFallbackImpl = ({
|
|
|
3383
3693
|
}
|
|
3384
3694
|
);
|
|
3385
3695
|
};
|
|
3386
|
-
var ToolFallback = (0,
|
|
3696
|
+
var ToolFallback = (0, import_react23.memo)(
|
|
3387
3697
|
ToolFallbackImpl
|
|
3388
3698
|
);
|
|
3389
3699
|
ToolFallback.displayName = "ToolFallback";
|
|
3390
3700
|
|
|
3391
3701
|
// src/artifacts/tool-artifact.tsx
|
|
3392
|
-
var
|
|
3702
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3393
3703
|
var ToolArtifactFallback = (props) => {
|
|
3394
3704
|
const registry = useArtifactRegistry();
|
|
3395
3705
|
const isRunning = useToolRunning({
|
|
@@ -3401,24 +3711,24 @@ var ToolArtifactFallback = (props) => {
|
|
|
3401
3711
|
if (artifact) {
|
|
3402
3712
|
const Renderer = registry[artifact.type];
|
|
3403
3713
|
if (Renderer) {
|
|
3404
|
-
return /* @__PURE__ */ (0,
|
|
3714
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3405
3715
|
ToolMotion,
|
|
3406
3716
|
{
|
|
3407
3717
|
motionKey: `artifact-${artifact.type}`,
|
|
3408
3718
|
className: "aui-tool-artifact",
|
|
3409
|
-
children: /* @__PURE__ */ (0,
|
|
3719
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Renderer, { artifact })
|
|
3410
3720
|
}
|
|
3411
3721
|
);
|
|
3412
3722
|
}
|
|
3413
3723
|
}
|
|
3414
3724
|
}
|
|
3415
|
-
return /* @__PURE__ */ (0,
|
|
3725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ToolFallback, { ...props });
|
|
3416
3726
|
};
|
|
3417
3727
|
|
|
3418
3728
|
// src/chat/composer.tsx
|
|
3419
|
-
var
|
|
3729
|
+
var import_react25 = require("@assistant-ui/react");
|
|
3420
3730
|
var import_lucide_react6 = require("lucide-react");
|
|
3421
|
-
var
|
|
3731
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3422
3732
|
var Composer = ({
|
|
3423
3733
|
placeholder = "Send a message...",
|
|
3424
3734
|
showAttachments,
|
|
@@ -3429,10 +3739,10 @@ var Composer = ({
|
|
|
3429
3739
|
}) => {
|
|
3430
3740
|
const attachmentsEnabled = useTimbalAttachmentsEnabled();
|
|
3431
3741
|
const attachUi = showAttachments !== false && attachmentsEnabled;
|
|
3432
|
-
const shell = /* @__PURE__ */ (0,
|
|
3433
|
-
attachUi && /* @__PURE__ */ (0,
|
|
3434
|
-
/* @__PURE__ */ (0,
|
|
3435
|
-
/* @__PURE__ */ (0,
|
|
3742
|
+
const shell = /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
3743
|
+
attachUi && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ComposerAttachments, {}),
|
|
3744
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ComposerInput, { placeholder, autoFocus: !noAutoFocus }),
|
|
3745
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3436
3746
|
ComposerToolbar,
|
|
3437
3747
|
{
|
|
3438
3748
|
showAttachments: attachUi,
|
|
@@ -3441,15 +3751,15 @@ var Composer = ({
|
|
|
3441
3751
|
}
|
|
3442
3752
|
)
|
|
3443
3753
|
] });
|
|
3444
|
-
return /* @__PURE__ */ (0,
|
|
3445
|
-
|
|
3754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3755
|
+
import_react25.ComposerPrimitive.Root,
|
|
3446
3756
|
{
|
|
3447
3757
|
className: cn(
|
|
3448
3758
|
"aui-composer-root relative flex w-full flex-col",
|
|
3449
3759
|
className
|
|
3450
3760
|
),
|
|
3451
|
-
children: attachUi ? /* @__PURE__ */ (0,
|
|
3452
|
-
|
|
3761
|
+
children: attachUi ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3762
|
+
import_react25.ComposerPrimitive.AttachmentDropzone,
|
|
3453
3763
|
{
|
|
3454
3764
|
className: cn(
|
|
3455
3765
|
studioComposeInputShellClass,
|
|
@@ -3457,7 +3767,7 @@ var Composer = ({
|
|
|
3457
3767
|
),
|
|
3458
3768
|
children: shell
|
|
3459
3769
|
}
|
|
3460
|
-
) : /* @__PURE__ */ (0,
|
|
3770
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: studioComposeInputShellClass, children: shell })
|
|
3461
3771
|
}
|
|
3462
3772
|
);
|
|
3463
3773
|
};
|
|
@@ -3465,7 +3775,7 @@ var ComposerInput = ({
|
|
|
3465
3775
|
placeholder,
|
|
3466
3776
|
autoFocus
|
|
3467
3777
|
}) => {
|
|
3468
|
-
const composer = (0,
|
|
3778
|
+
const composer = (0, import_react25.useComposerRuntime)();
|
|
3469
3779
|
const onKeyDown = (e) => {
|
|
3470
3780
|
if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
|
|
3471
3781
|
e.preventDefault();
|
|
@@ -3477,8 +3787,8 @@ var ComposerInput = ({
|
|
|
3477
3787
|
el.style.height = "auto";
|
|
3478
3788
|
el.style.height = `${Math.min(el.scrollHeight, 240)}px`;
|
|
3479
3789
|
};
|
|
3480
|
-
return /* @__PURE__ */ (0,
|
|
3481
|
-
|
|
3790
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3791
|
+
import_react25.ComposerPrimitive.Input,
|
|
3482
3792
|
{
|
|
3483
3793
|
placeholder,
|
|
3484
3794
|
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",
|
|
@@ -3491,17 +3801,17 @@ var ComposerInput = ({
|
|
|
3491
3801
|
);
|
|
3492
3802
|
};
|
|
3493
3803
|
var ComposerToolbar = ({ showAttachments, toolbar, sendTooltip }) => {
|
|
3494
|
-
return /* @__PURE__ */ (0,
|
|
3495
|
-
/* @__PURE__ */ (0,
|
|
3496
|
-
showAttachments && /* @__PURE__ */ (0,
|
|
3804
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.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: [
|
|
3805
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3806
|
+
showAttachments && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ComposerAddAttachment, {}),
|
|
3497
3807
|
toolbar
|
|
3498
3808
|
] }),
|
|
3499
|
-
/* @__PURE__ */ (0,
|
|
3809
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ComposerSendOrCancel, { sendTooltip })
|
|
3500
3810
|
] });
|
|
3501
3811
|
};
|
|
3502
3812
|
var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
3503
|
-
return /* @__PURE__ */ (0,
|
|
3504
|
-
/* @__PURE__ */ (0,
|
|
3813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
3814
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react25.AuiIf, { condition: (s) => !s.thread.isRunning, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react25.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3505
3815
|
TooltipIconButton,
|
|
3506
3816
|
{
|
|
3507
3817
|
tooltip: sendTooltip,
|
|
@@ -3509,34 +3819,34 @@ var ComposerSendOrCancel = ({ sendTooltip }) => {
|
|
|
3509
3819
|
type: "submit",
|
|
3510
3820
|
className: "aui-composer-send shrink-0 disabled:opacity-30",
|
|
3511
3821
|
"aria-label": "Send message",
|
|
3512
|
-
children: /* @__PURE__ */ (0,
|
|
3822
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react6.ArrowUpIcon, { className: "aui-composer-send-icon size-4" })
|
|
3513
3823
|
}
|
|
3514
3824
|
) }) }),
|
|
3515
|
-
/* @__PURE__ */ (0,
|
|
3825
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react25.AuiIf, { condition: (s) => s.thread.isRunning, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_react25.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3516
3826
|
TooltipIconButton,
|
|
3517
3827
|
{
|
|
3518
3828
|
tooltip: "Stop generating",
|
|
3519
3829
|
variant: "primary",
|
|
3520
3830
|
className: "aui-composer-cancel shrink-0",
|
|
3521
3831
|
"aria-label": "Stop generating",
|
|
3522
|
-
children: /* @__PURE__ */ (0,
|
|
3832
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react6.SquareIcon, { className: "aui-composer-cancel-icon size-3 fill-current" })
|
|
3523
3833
|
}
|
|
3524
3834
|
) }) })
|
|
3525
3835
|
] });
|
|
3526
3836
|
};
|
|
3527
3837
|
|
|
3528
3838
|
// src/chat/suggestions.tsx
|
|
3529
|
-
var
|
|
3530
|
-
var
|
|
3839
|
+
var import_react26 = require("react");
|
|
3840
|
+
var import_react27 = require("@assistant-ui/react");
|
|
3531
3841
|
var import_lucide_react7 = require("lucide-react");
|
|
3532
|
-
var
|
|
3842
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3533
3843
|
var Suggestions = ({
|
|
3534
3844
|
suggestions,
|
|
3535
3845
|
className
|
|
3536
3846
|
}) => {
|
|
3537
3847
|
const items = useResolvedSuggestions(suggestions);
|
|
3538
3848
|
if (!items || items.length === 0) return null;
|
|
3539
|
-
return /* @__PURE__ */ (0,
|
|
3849
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3540
3850
|
"div",
|
|
3541
3851
|
{
|
|
3542
3852
|
className: cn(
|
|
@@ -3545,17 +3855,17 @@ var Suggestions = ({
|
|
|
3545
3855
|
),
|
|
3546
3856
|
role: "list",
|
|
3547
3857
|
"aria-label": "Suggested prompts",
|
|
3548
|
-
children: items.map((suggestion, i) => /* @__PURE__ */ (0,
|
|
3858
|
+
children: items.map((suggestion, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(SuggestionRow, { suggestion }, (suggestion.prompt ?? suggestion.title) + i))
|
|
3549
3859
|
}
|
|
3550
3860
|
);
|
|
3551
3861
|
};
|
|
3552
3862
|
var SuggestionRow = ({ suggestion }) => {
|
|
3553
|
-
const runtime = (0,
|
|
3863
|
+
const runtime = (0, import_react27.useThreadRuntime)();
|
|
3554
3864
|
const onClick = () => {
|
|
3555
3865
|
const text = suggestion.prompt ?? suggestion.title;
|
|
3556
3866
|
runtime.append({ role: "user", content: [{ type: "text", text }] });
|
|
3557
3867
|
};
|
|
3558
|
-
return /* @__PURE__ */ (0,
|
|
3868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
3559
3869
|
"button",
|
|
3560
3870
|
{
|
|
3561
3871
|
type: "button",
|
|
@@ -3563,20 +3873,20 @@ var SuggestionRow = ({ suggestion }) => {
|
|
|
3563
3873
|
onClick,
|
|
3564
3874
|
className: cn("aui-thread-suggestion", studioListRowButtonClass),
|
|
3565
3875
|
children: [
|
|
3566
|
-
/* @__PURE__ */ (0,
|
|
3567
|
-
/* @__PURE__ */ (0,
|
|
3568
|
-
/* @__PURE__ */ (0,
|
|
3569
|
-
suggestion.description && /* @__PURE__ */ (0,
|
|
3876
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "aui-thread-suggestion-icon shrink-0 text-muted-foreground", children: suggestion.icon ?? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_lucide_react7.ArrowUpIcon, { className: "size-4", strokeWidth: 1.75, "aria-hidden": true }) }),
|
|
3877
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "aui-thread-suggestion-text min-w-0 flex-1 text-left", children: [
|
|
3878
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "aui-thread-suggestion-text-1 block truncate text-sm font-normal text-foreground", children: suggestion.title }),
|
|
3879
|
+
suggestion.description && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "aui-thread-suggestion-text-2 mt-0.5 block truncate text-xs text-muted-foreground", children: suggestion.description })
|
|
3570
3880
|
] })
|
|
3571
3881
|
]
|
|
3572
3882
|
}
|
|
3573
3883
|
);
|
|
3574
3884
|
};
|
|
3575
3885
|
function useResolvedSuggestions(source) {
|
|
3576
|
-
const [resolved, setResolved] = (0,
|
|
3886
|
+
const [resolved, setResolved] = (0, import_react26.useState)(
|
|
3577
3887
|
() => Array.isArray(source) ? source : void 0
|
|
3578
3888
|
);
|
|
3579
|
-
(0,
|
|
3889
|
+
(0, import_react26.useEffect)(() => {
|
|
3580
3890
|
if (!source) {
|
|
3581
3891
|
setResolved(void 0);
|
|
3582
3892
|
return;
|
|
@@ -3595,7 +3905,7 @@ function useResolvedSuggestions(source) {
|
|
|
3595
3905
|
cancelled = true;
|
|
3596
3906
|
};
|
|
3597
3907
|
}, [source]);
|
|
3598
|
-
return (0,
|
|
3908
|
+
return (0, import_react26.useMemo)(() => resolved, [resolved]);
|
|
3599
3909
|
}
|
|
3600
3910
|
|
|
3601
3911
|
// src/design/theme-sanity.ts
|
|
@@ -3668,21 +3978,22 @@ function scheduleThemeSanityCheck() {
|
|
|
3668
3978
|
}
|
|
3669
3979
|
|
|
3670
3980
|
// src/chat/thread-variant.tsx
|
|
3671
|
-
var
|
|
3672
|
-
var ThreadVariantContext = (0,
|
|
3981
|
+
var import_react28 = require("react");
|
|
3982
|
+
var ThreadVariantContext = (0, import_react28.createContext)("default");
|
|
3673
3983
|
var ThreadVariantProvider = ThreadVariantContext.Provider;
|
|
3674
3984
|
function useThreadVariant() {
|
|
3675
|
-
return (0,
|
|
3985
|
+
return (0, import_react28.useContext)(ThreadVariantContext);
|
|
3676
3986
|
}
|
|
3677
3987
|
|
|
3678
3988
|
// src/chat/thread.tsx
|
|
3679
|
-
var
|
|
3989
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3680
3990
|
var Thread = ({
|
|
3681
3991
|
className,
|
|
3682
3992
|
variant = "default",
|
|
3683
3993
|
maxWidth: maxWidthProp,
|
|
3684
3994
|
welcome,
|
|
3685
3995
|
suggestions,
|
|
3996
|
+
showWelcomeSuggestions,
|
|
3686
3997
|
composerPlaceholder,
|
|
3687
3998
|
components,
|
|
3688
3999
|
artifacts,
|
|
@@ -3698,17 +4009,17 @@ var Thread = ({
|
|
|
3698
4009
|
const EditComposerSlot = components?.EditComposer ?? EditComposer;
|
|
3699
4010
|
const ScrollToBottomSlot = components?.ScrollToBottom ?? ThreadScrollToBottom;
|
|
3700
4011
|
const SuggestionsSlot = components?.Suggestions ?? Suggestions;
|
|
3701
|
-
(0,
|
|
4012
|
+
(0, import_react29.useEffect)(() => {
|
|
3702
4013
|
scheduleThemeSanityCheck();
|
|
3703
4014
|
}, []);
|
|
3704
|
-
return /* @__PURE__ */ (0,
|
|
4015
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ThreadVariantProvider, { value: variant, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3705
4016
|
ArtifactRegistryProvider,
|
|
3706
4017
|
{
|
|
3707
4018
|
renderers: artifacts?.renderers,
|
|
3708
4019
|
override: artifacts?.override,
|
|
3709
|
-
children: /* @__PURE__ */ (0,
|
|
3710
|
-
}), children: /* @__PURE__ */ (0,
|
|
3711
|
-
|
|
4020
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(UiEventProvider, { onEvent: onArtifactEvent ?? (() => {
|
|
4021
|
+
}), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4022
|
+
import_react30.ThreadPrimitive.Root,
|
|
3712
4023
|
{
|
|
3713
4024
|
className: cn(
|
|
3714
4025
|
"aui-root aui-thread-root @container flex h-full flex-col bg-transparent",
|
|
@@ -3717,8 +4028,8 @@ var Thread = ({
|
|
|
3717
4028
|
),
|
|
3718
4029
|
style: { ["--thread-max-width"]: maxWidth },
|
|
3719
4030
|
"data-thread-variant": variant,
|
|
3720
|
-
children: /* @__PURE__ */ (0,
|
|
3721
|
-
|
|
4031
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4032
|
+
import_react30.ThreadPrimitive.Viewport,
|
|
3722
4033
|
{
|
|
3723
4034
|
turnAnchor: "bottom",
|
|
3724
4035
|
className: cn(
|
|
@@ -3726,16 +4037,17 @@ var Thread = ({
|
|
|
3726
4037
|
isPanel ? "px-2 pt-2" : "px-4 pt-4"
|
|
3727
4038
|
),
|
|
3728
4039
|
children: [
|
|
3729
|
-
/* @__PURE__ */ (0,
|
|
4040
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3730
4041
|
WelcomeSlot,
|
|
3731
4042
|
{
|
|
3732
4043
|
config: welcome,
|
|
3733
4044
|
suggestions,
|
|
4045
|
+
showWelcomeSuggestions,
|
|
3734
4046
|
Suggestions: SuggestionsSlot
|
|
3735
4047
|
}
|
|
3736
4048
|
),
|
|
3737
|
-
/* @__PURE__ */ (0,
|
|
3738
|
-
|
|
4049
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4050
|
+
import_react30.ThreadPrimitive.Messages,
|
|
3739
4051
|
{
|
|
3740
4052
|
components: {
|
|
3741
4053
|
UserMessage: UserMessageSlot,
|
|
@@ -3744,14 +4056,14 @@ var Thread = ({
|
|
|
3744
4056
|
}
|
|
3745
4057
|
}
|
|
3746
4058
|
),
|
|
3747
|
-
/* @__PURE__ */ (0,
|
|
3748
|
-
|
|
4059
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4060
|
+
import_react30.ThreadPrimitive.ViewportFooter,
|
|
3749
4061
|
{
|
|
3750
4062
|
className: cn(
|
|
3751
4063
|
"aui-thread-viewport-footer sticky bottom-0 z-10 mt-auto w-full isolate pt-2",
|
|
3752
4064
|
isPanel ? "bg-card pb-2" : "bg-background pb-4 md:pb-6"
|
|
3753
4065
|
),
|
|
3754
|
-
children: /* @__PURE__ */ (0,
|
|
4066
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3755
4067
|
"div",
|
|
3756
4068
|
{
|
|
3757
4069
|
className: cn(
|
|
@@ -3759,8 +4071,8 @@ var Thread = ({
|
|
|
3759
4071
|
isPanel ? "gap-2" : "gap-4"
|
|
3760
4072
|
),
|
|
3761
4073
|
children: [
|
|
3762
|
-
/* @__PURE__ */ (0,
|
|
3763
|
-
/* @__PURE__ */ (0,
|
|
4074
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ScrollToBottomSlot, {}),
|
|
4075
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ComposerSlot, { placeholder })
|
|
3764
4076
|
]
|
|
3765
4077
|
}
|
|
3766
4078
|
)
|
|
@@ -3775,13 +4087,13 @@ var Thread = ({
|
|
|
3775
4087
|
) });
|
|
3776
4088
|
};
|
|
3777
4089
|
var ThreadScrollToBottom = () => {
|
|
3778
|
-
return /* @__PURE__ */ (0,
|
|
4090
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ThreadPrimitive.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3779
4091
|
TooltipIconButton,
|
|
3780
4092
|
{
|
|
3781
4093
|
tooltip: "Scroll to bottom",
|
|
3782
4094
|
variant: "secondary",
|
|
3783
4095
|
className: "aui-thread-scroll-to-bottom absolute -top-12 z-10 self-center disabled:invisible",
|
|
3784
|
-
children: /* @__PURE__ */ (0,
|
|
4096
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react8.ArrowDownIcon, { className: "size-4" })
|
|
3785
4097
|
}
|
|
3786
4098
|
) });
|
|
3787
4099
|
};
|
|
@@ -3811,16 +4123,18 @@ var welcomeIcon = {
|
|
|
3811
4123
|
var ThreadWelcome = ({
|
|
3812
4124
|
config,
|
|
3813
4125
|
suggestions,
|
|
4126
|
+
showWelcomeSuggestions: showWelcomeSuggestionsProp,
|
|
3814
4127
|
Suggestions: SuggestionsSlot = Suggestions
|
|
3815
4128
|
}) => {
|
|
3816
|
-
const isEmpty = (0,
|
|
4129
|
+
const isEmpty = (0, import_react30.useThread)((s) => s.messages.length === 0);
|
|
3817
4130
|
const isPanel = useThreadVariant() === "panel";
|
|
4131
|
+
const showWelcomeSuggestions = showWelcomeSuggestionsProp ?? !isPanel;
|
|
3818
4132
|
if (!isEmpty) return null;
|
|
3819
4133
|
const defaultHeading = isPanel ? "Ask about this page" : "How can I help you today?";
|
|
3820
4134
|
const defaultSubheading = isPanel ? "The assistant can use dashboard context from your app." : "Send a message to start a conversation.";
|
|
3821
|
-
return /* @__PURE__ */ (0,
|
|
3822
|
-
/* @__PURE__ */ (0,
|
|
3823
|
-
|
|
4135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "aui-thread-welcome-root mx-auto my-auto flex w-full max-w-(--thread-max-width) grow flex-col", children: [
|
|
4136
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4137
|
+
import_react31.motion.div,
|
|
3824
4138
|
{
|
|
3825
4139
|
className: cn(
|
|
3826
4140
|
"aui-thread-welcome-message flex flex-col items-center justify-center text-center",
|
|
@@ -3830,9 +4144,9 @@ var ThreadWelcome = ({
|
|
|
3830
4144
|
initial: "initial",
|
|
3831
4145
|
animate: "animate",
|
|
3832
4146
|
children: [
|
|
3833
|
-
config?.icon && /* @__PURE__ */ (0,
|
|
3834
|
-
/* @__PURE__ */ (0,
|
|
3835
|
-
|
|
4147
|
+
config?.icon && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react31.motion.div, { variants: welcomeIcon, className: isPanel ? "mb-3" : "mb-5", children: config.icon }),
|
|
4148
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4149
|
+
import_react31.motion.h1,
|
|
3836
4150
|
{
|
|
3837
4151
|
variants: welcomeItem,
|
|
3838
4152
|
className: cn(
|
|
@@ -3842,8 +4156,8 @@ var ThreadWelcome = ({
|
|
|
3842
4156
|
children: config?.heading ?? defaultHeading
|
|
3843
4157
|
}
|
|
3844
4158
|
),
|
|
3845
|
-
/* @__PURE__ */ (0,
|
|
3846
|
-
|
|
4159
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4160
|
+
import_react31.motion.p,
|
|
3847
4161
|
{
|
|
3848
4162
|
variants: welcomeItem,
|
|
3849
4163
|
className: "aui-thread-welcome-message-inner mt-1.5 text-muted-foreground text-sm",
|
|
@@ -3853,16 +4167,16 @@ var ThreadWelcome = ({
|
|
|
3853
4167
|
]
|
|
3854
4168
|
}
|
|
3855
4169
|
) }),
|
|
3856
|
-
|
|
4170
|
+
showWelcomeSuggestions && suggestions ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "aui-thread-welcome-suggestions mx-auto w-full max-w-(--thread-max-width) px-2", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SuggestionsSlot, { suggestions }) }) : null
|
|
3857
4171
|
] });
|
|
3858
4172
|
};
|
|
3859
4173
|
var MessageError = () => {
|
|
3860
|
-
return /* @__PURE__ */ (0,
|
|
4174
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.MessagePrimitive.Error, { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.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_runtime29.jsx)(import_react30.ErrorPrimitive.Message, { className: "aui-message-error-message line-clamp-2" }) }) });
|
|
3861
4175
|
};
|
|
3862
4176
|
var AssistantMessage = () => {
|
|
3863
4177
|
const isPanel = useThreadVariant() === "panel";
|
|
3864
|
-
return /* @__PURE__ */ (0,
|
|
3865
|
-
|
|
4178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4179
|
+
import_react30.MessagePrimitive.Root,
|
|
3866
4180
|
{
|
|
3867
4181
|
className: cn(
|
|
3868
4182
|
"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",
|
|
@@ -3870,7 +4184,7 @@ var AssistantMessage = () => {
|
|
|
3870
4184
|
),
|
|
3871
4185
|
"data-role": "assistant",
|
|
3872
4186
|
children: [
|
|
3873
|
-
/* @__PURE__ */ (0,
|
|
4187
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3874
4188
|
"div",
|
|
3875
4189
|
{
|
|
3876
4190
|
className: cn(
|
|
@@ -3878,8 +4192,8 @@ var AssistantMessage = () => {
|
|
|
3878
4192
|
isPanel ? "px-1 text-sm" : "px-2"
|
|
3879
4193
|
),
|
|
3880
4194
|
children: [
|
|
3881
|
-
/* @__PURE__ */ (0,
|
|
3882
|
-
|
|
4195
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4196
|
+
import_react30.MessagePrimitive.Parts,
|
|
3883
4197
|
{
|
|
3884
4198
|
components: {
|
|
3885
4199
|
Text: MarkdownText,
|
|
@@ -3889,11 +4203,11 @@ var AssistantMessage = () => {
|
|
|
3889
4203
|
}
|
|
3890
4204
|
}
|
|
3891
4205
|
),
|
|
3892
|
-
/* @__PURE__ */ (0,
|
|
4206
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(MessageError, {})
|
|
3893
4207
|
]
|
|
3894
4208
|
}
|
|
3895
4209
|
),
|
|
3896
|
-
/* @__PURE__ */ (0,
|
|
4210
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "aui-assistant-message-footer mt-1 mb-3 ml-1 flex", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(AssistantActionBar, {}) })
|
|
3897
4211
|
]
|
|
3898
4212
|
}
|
|
3899
4213
|
);
|
|
@@ -3906,36 +4220,36 @@ var ASSISTANT_ACTION_ICON_CLASS = cn(
|
|
|
3906
4220
|
"[&>span:first-child]:group-hover/tbv2:bg-ghost-fill-hover"
|
|
3907
4221
|
);
|
|
3908
4222
|
var AssistantActionBar = () => {
|
|
3909
|
-
return /* @__PURE__ */ (0,
|
|
3910
|
-
|
|
4223
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4224
|
+
import_react30.ActionBarPrimitive.Root,
|
|
3911
4225
|
{
|
|
3912
4226
|
hideWhenRunning: true,
|
|
3913
4227
|
autohide: "never",
|
|
3914
4228
|
className: "aui-assistant-action-bar-root flex items-center gap-0 bg-transparent px-0 py-0.5 text-muted-foreground/60",
|
|
3915
4229
|
children: [
|
|
3916
|
-
/* @__PURE__ */ (0,
|
|
4230
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ActionBarPrimitive.Copy, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3917
4231
|
TooltipIconButton,
|
|
3918
4232
|
{
|
|
3919
4233
|
tooltip: "Copy",
|
|
3920
4234
|
variant: "ghost",
|
|
3921
4235
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
3922
4236
|
children: [
|
|
3923
|
-
/* @__PURE__ */ (0,
|
|
3924
|
-
/* @__PURE__ */ (0,
|
|
4237
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.AuiIf, { condition: (s) => s.message.isCopied, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react8.CheckIcon, { className: "size-3" }) }),
|
|
4238
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.AuiIf, { condition: (s) => !s.message.isCopied, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react8.CopyIcon, { className: "size-3" }) })
|
|
3925
4239
|
]
|
|
3926
4240
|
}
|
|
3927
4241
|
) }),
|
|
3928
|
-
/* @__PURE__ */ (0,
|
|
4242
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ActionBarPrimitive.Reload, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3929
4243
|
TooltipIconButton,
|
|
3930
4244
|
{
|
|
3931
4245
|
tooltip: "Regenerate",
|
|
3932
4246
|
variant: "ghost",
|
|
3933
4247
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
3934
|
-
children: /* @__PURE__ */ (0,
|
|
4248
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react8.RefreshCwIcon, { className: "size-3" })
|
|
3935
4249
|
}
|
|
3936
4250
|
) }),
|
|
3937
|
-
/* @__PURE__ */ (0,
|
|
3938
|
-
/* @__PURE__ */ (0,
|
|
4251
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_react30.ActionBarMorePrimitive.Root, { children: [
|
|
4252
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ActionBarMorePrimitive.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3939
4253
|
TooltipIconButton,
|
|
3940
4254
|
{
|
|
3941
4255
|
tooltip: "More",
|
|
@@ -3944,17 +4258,17 @@ var AssistantActionBar = () => {
|
|
|
3944
4258
|
ASSISTANT_ACTION_ICON_CLASS,
|
|
3945
4259
|
"data-[state=open]:text-muted-foreground/80"
|
|
3946
4260
|
),
|
|
3947
|
-
children: /* @__PURE__ */ (0,
|
|
4261
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react8.MoreHorizontalIcon, { className: "size-3" })
|
|
3948
4262
|
}
|
|
3949
4263
|
) }),
|
|
3950
|
-
/* @__PURE__ */ (0,
|
|
3951
|
-
|
|
4264
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4265
|
+
import_react30.ActionBarMorePrimitive.Content,
|
|
3952
4266
|
{
|
|
3953
4267
|
side: "bottom",
|
|
3954
4268
|
align: "start",
|
|
3955
4269
|
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",
|
|
3956
|
-
children: /* @__PURE__ */ (0,
|
|
3957
|
-
/* @__PURE__ */ (0,
|
|
4270
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ActionBarPrimitive.ExportMarkdown, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_react30.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: [
|
|
4271
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react8.DownloadIcon, { className: "size-4 shrink-0" }),
|
|
3958
4272
|
"Export as Markdown"
|
|
3959
4273
|
] }) })
|
|
3960
4274
|
}
|
|
@@ -3965,12 +4279,12 @@ var AssistantActionBar = () => {
|
|
|
3965
4279
|
);
|
|
3966
4280
|
};
|
|
3967
4281
|
var UserMessageText = () => {
|
|
3968
|
-
return /* @__PURE__ */ (0,
|
|
4282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "whitespace-pre-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.MessagePartPrimitive.Text, { smooth: false }) });
|
|
3969
4283
|
};
|
|
3970
4284
|
var UserMessage = () => {
|
|
3971
4285
|
const isPanel = useThreadVariant() === "panel";
|
|
3972
|
-
return /* @__PURE__ */ (0,
|
|
3973
|
-
|
|
4286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4287
|
+
import_react30.MessagePrimitive.Root,
|
|
3974
4288
|
{
|
|
3975
4289
|
className: cn(
|
|
3976
4290
|
"aui-user-message-root mx-auto flex w-full max-w-(--thread-max-width) flex-col items-end gap-2",
|
|
@@ -3978,9 +4292,9 @@ var UserMessage = () => {
|
|
|
3978
4292
|
),
|
|
3979
4293
|
"data-role": "user",
|
|
3980
4294
|
children: [
|
|
3981
|
-
/* @__PURE__ */ (0,
|
|
3982
|
-
/* @__PURE__ */ (0,
|
|
3983
|
-
|
|
4295
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(UserMessageAttachments, {}),
|
|
4296
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4297
|
+
import_react31.motion.div,
|
|
3984
4298
|
{
|
|
3985
4299
|
className: cn(
|
|
3986
4300
|
"aui-user-message-content relative inline-block max-w-[85%] rounded-2xl bg-bubble-user text-bubble-user-foreground",
|
|
@@ -3990,8 +4304,8 @@ var UserMessage = () => {
|
|
|
3990
4304
|
animate: { opacity: 1, y: 0, scale: 1 },
|
|
3991
4305
|
transition: { duration: 0.65, ease: luxuryEase },
|
|
3992
4306
|
children: [
|
|
3993
|
-
/* @__PURE__ */ (0,
|
|
3994
|
-
/* @__PURE__ */ (0,
|
|
4307
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.MessagePrimitive.Parts, { components: { Text: UserMessageText } }),
|
|
4308
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.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_runtime29.jsx)(UserActionBar, {}) })
|
|
3995
4309
|
]
|
|
3996
4310
|
}
|
|
3997
4311
|
)
|
|
@@ -4000,42 +4314,42 @@ var UserMessage = () => {
|
|
|
4000
4314
|
);
|
|
4001
4315
|
};
|
|
4002
4316
|
var UserActionBar = () => {
|
|
4003
|
-
return /* @__PURE__ */ (0,
|
|
4004
|
-
|
|
4317
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4318
|
+
import_react30.ActionBarPrimitive.Root,
|
|
4005
4319
|
{
|
|
4006
4320
|
hideWhenRunning: true,
|
|
4007
4321
|
autohide: "always",
|
|
4008
4322
|
className: "aui-user-action-bar-root flex flex-col items-end",
|
|
4009
|
-
children: /* @__PURE__ */ (0,
|
|
4323
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ActionBarPrimitive.Edit, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4010
4324
|
TooltipIconButton,
|
|
4011
4325
|
{
|
|
4012
4326
|
tooltip: "Edit",
|
|
4013
4327
|
variant: "ghost",
|
|
4014
4328
|
className: ASSISTANT_ACTION_ICON_CLASS,
|
|
4015
|
-
children: /* @__PURE__ */ (0,
|
|
4329
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react8.PencilIcon, { className: "size-3" })
|
|
4016
4330
|
}
|
|
4017
4331
|
) })
|
|
4018
4332
|
}
|
|
4019
4333
|
);
|
|
4020
4334
|
};
|
|
4021
4335
|
var EditComposer = () => {
|
|
4022
|
-
return /* @__PURE__ */ (0,
|
|
4023
|
-
/* @__PURE__ */ (0,
|
|
4024
|
-
|
|
4336
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.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_runtime29.jsxs)(import_react30.ComposerPrimitive.Root, { className: "aui-edit-composer-root ml-auto flex w-full max-w-[85%] flex-col rounded-2xl bg-muted", children: [
|
|
4337
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4338
|
+
import_react30.ComposerPrimitive.Input,
|
|
4025
4339
|
{
|
|
4026
4340
|
className: "aui-edit-composer-input min-h-14 w-full resize-none bg-transparent p-4 text-foreground text-sm outline-none",
|
|
4027
4341
|
autoFocus: true
|
|
4028
4342
|
}
|
|
4029
4343
|
),
|
|
4030
|
-
/* @__PURE__ */ (0,
|
|
4031
|
-
/* @__PURE__ */ (0,
|
|
4032
|
-
/* @__PURE__ */ (0,
|
|
4344
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "aui-edit-composer-footer mx-3 mb-3 flex items-center gap-2 self-end", children: [
|
|
4345
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ComposerPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TimbalV2Button, { variant: "ghost", size: "sm", children: "Cancel" }) }),
|
|
4346
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react30.ComposerPrimitive.Send, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TimbalV2Button, { variant: "primary", size: "sm", children: "Update" }) })
|
|
4033
4347
|
] })
|
|
4034
4348
|
] }) });
|
|
4035
4349
|
};
|
|
4036
4350
|
|
|
4037
4351
|
// src/chat/chat.tsx
|
|
4038
|
-
var
|
|
4352
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
4039
4353
|
function TimbalChat({
|
|
4040
4354
|
workforceId,
|
|
4041
4355
|
baseUrl,
|
|
@@ -4046,7 +4360,7 @@ function TimbalChat({
|
|
|
4046
4360
|
debug,
|
|
4047
4361
|
...threadProps
|
|
4048
4362
|
}) {
|
|
4049
|
-
return /* @__PURE__ */ (0,
|
|
4363
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4050
4364
|
TimbalRuntimeProvider,
|
|
4051
4365
|
{
|
|
4052
4366
|
workforceId,
|
|
@@ -4056,14 +4370,14 @@ function TimbalChat({
|
|
|
4056
4370
|
attachmentsUploadUrl,
|
|
4057
4371
|
attachmentsAccept,
|
|
4058
4372
|
debug,
|
|
4059
|
-
children: /* @__PURE__ */ (0,
|
|
4373
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Thread, { ...threadProps })
|
|
4060
4374
|
}
|
|
4061
4375
|
);
|
|
4062
4376
|
}
|
|
4063
4377
|
|
|
4064
4378
|
// src/chat/workforce-selector.tsx
|
|
4065
4379
|
var import_lucide_react9 = require("lucide-react");
|
|
4066
|
-
var
|
|
4380
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
4067
4381
|
var WorkforceSelector = ({
|
|
4068
4382
|
workforces,
|
|
4069
4383
|
value,
|
|
@@ -4074,7 +4388,7 @@ var WorkforceSelector = ({
|
|
|
4074
4388
|
}) => {
|
|
4075
4389
|
if (workforces.length === 0) return null;
|
|
4076
4390
|
if (hideWhenSingle && workforces.length === 1) return null;
|
|
4077
|
-
return /* @__PURE__ */ (0,
|
|
4391
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
4078
4392
|
"div",
|
|
4079
4393
|
{
|
|
4080
4394
|
className: cn(
|
|
@@ -4085,7 +4399,7 @@ var WorkforceSelector = ({
|
|
|
4085
4399
|
className
|
|
4086
4400
|
),
|
|
4087
4401
|
children: [
|
|
4088
|
-
/* @__PURE__ */ (0,
|
|
4402
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
4089
4403
|
"select",
|
|
4090
4404
|
{
|
|
4091
4405
|
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",
|
|
@@ -4093,15 +4407,15 @@ var WorkforceSelector = ({
|
|
|
4093
4407
|
onChange: (e) => onChange(e.target.value),
|
|
4094
4408
|
"aria-label": placeholder,
|
|
4095
4409
|
children: [
|
|
4096
|
-
!value && /* @__PURE__ */ (0,
|
|
4410
|
+
!value && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("option", { value: "", children: placeholder }),
|
|
4097
4411
|
workforces.map((w) => {
|
|
4098
4412
|
const id = idOf(w);
|
|
4099
|
-
return /* @__PURE__ */ (0,
|
|
4413
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("option", { value: id, children: w.name ?? id }, id);
|
|
4100
4414
|
})
|
|
4101
4415
|
]
|
|
4102
4416
|
}
|
|
4103
4417
|
),
|
|
4104
|
-
/* @__PURE__ */ (0,
|
|
4418
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4105
4419
|
import_lucide_react9.ChevronDownIcon,
|
|
4106
4420
|
{
|
|
4107
4421
|
className: "aui-workforce-selector-icon pointer-events-none absolute right-3 size-3.5 text-muted-foreground/70",
|
|
@@ -4117,22 +4431,22 @@ function idOf(item) {
|
|
|
4117
4431
|
}
|
|
4118
4432
|
|
|
4119
4433
|
// src/hooks/use-workforces.ts
|
|
4120
|
-
var
|
|
4434
|
+
var import_react32 = require("react");
|
|
4121
4435
|
function useWorkforces(options = {}) {
|
|
4122
4436
|
const { baseUrl = "/api", fetch: fetchFn, pickInitial, enabled = true } = options;
|
|
4123
|
-
const [workforces, setWorkforces] = (0,
|
|
4124
|
-
const [selectedId, setSelectedId] = (0,
|
|
4125
|
-
const [isLoading, setIsLoading] = (0,
|
|
4126
|
-
const [error, setError] = (0,
|
|
4127
|
-
const fetchFnRef = (0,
|
|
4128
|
-
(0,
|
|
4437
|
+
const [workforces, setWorkforces] = (0, import_react32.useState)([]);
|
|
4438
|
+
const [selectedId, setSelectedId] = (0, import_react32.useState)("");
|
|
4439
|
+
const [isLoading, setIsLoading] = (0, import_react32.useState)(enabled);
|
|
4440
|
+
const [error, setError] = (0, import_react32.useState)(null);
|
|
4441
|
+
const fetchFnRef = (0, import_react32.useRef)(fetchFn ?? authFetch);
|
|
4442
|
+
(0, import_react32.useEffect)(() => {
|
|
4129
4443
|
fetchFnRef.current = fetchFn ?? authFetch;
|
|
4130
4444
|
}, [fetchFn]);
|
|
4131
|
-
const pickInitialRef = (0,
|
|
4132
|
-
(0,
|
|
4445
|
+
const pickInitialRef = (0, import_react32.useRef)(pickInitial);
|
|
4446
|
+
(0, import_react32.useEffect)(() => {
|
|
4133
4447
|
pickInitialRef.current = pickInitial;
|
|
4134
4448
|
}, [pickInitial]);
|
|
4135
|
-
const load = (0,
|
|
4449
|
+
const load = (0, import_react32.useMemo)(() => {
|
|
4136
4450
|
return async () => {
|
|
4137
4451
|
if (!enabled) {
|
|
4138
4452
|
setIsLoading(false);
|
|
@@ -4157,10 +4471,10 @@ function useWorkforces(options = {}) {
|
|
|
4157
4471
|
}
|
|
4158
4472
|
};
|
|
4159
4473
|
}, [baseUrl, enabled]);
|
|
4160
|
-
(0,
|
|
4474
|
+
(0, import_react32.useEffect)(() => {
|
|
4161
4475
|
load();
|
|
4162
4476
|
}, [load]);
|
|
4163
|
-
const selected = (0,
|
|
4477
|
+
const selected = (0, import_react32.useMemo)(
|
|
4164
4478
|
() => workforces.find((w) => idOf2(w) === selectedId),
|
|
4165
4479
|
[workforces, selectedId]
|
|
4166
4480
|
);
|
|
@@ -4212,7 +4526,9 @@ var studioChromeShellStyle = {
|
|
|
4212
4526
|
"--studio-inset-left-collapsed": SIDEBAR_INSET_COLLAPSED
|
|
4213
4527
|
};
|
|
4214
4528
|
var STORAGE_KEYS = {
|
|
4215
|
-
sidebarCollapsed: "timbal-studio-sidebar-collapsed"
|
|
4529
|
+
sidebarCollapsed: "timbal-studio-sidebar-collapsed",
|
|
4530
|
+
/** Used by `ModeToggle` in uncontrolled mode (`localStorage`). */
|
|
4531
|
+
theme: "timbal-theme"
|
|
4216
4532
|
};
|
|
4217
4533
|
var DOM_IDS = {
|
|
4218
4534
|
sidebarRuntimeAnchor: "timbal-studio-sidebar-runtime-anchor",
|
|
@@ -4220,7 +4536,7 @@ var DOM_IDS = {
|
|
|
4220
4536
|
};
|
|
4221
4537
|
|
|
4222
4538
|
// src/studio/shell/chat-shell.tsx
|
|
4223
|
-
var
|
|
4539
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
4224
4540
|
var TimbalChatShell = ({
|
|
4225
4541
|
workforceId,
|
|
4226
4542
|
brand,
|
|
@@ -4238,7 +4554,7 @@ var TimbalChatShell = ({
|
|
|
4238
4554
|
});
|
|
4239
4555
|
const effectiveId = workforceId ?? selectedId;
|
|
4240
4556
|
const showSelector = !hideWorkforceSelector && !workforceId && workforces.length > 0;
|
|
4241
|
-
return /* @__PURE__ */ (0,
|
|
4557
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
4242
4558
|
"div",
|
|
4243
4559
|
{
|
|
4244
4560
|
className: cn(
|
|
@@ -4247,7 +4563,7 @@ var TimbalChatShell = ({
|
|
|
4247
4563
|
),
|
|
4248
4564
|
style: studioChromeShellStyle,
|
|
4249
4565
|
children: [
|
|
4250
|
-
/* @__PURE__ */ (0,
|
|
4566
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4251
4567
|
"div",
|
|
4252
4568
|
{
|
|
4253
4569
|
className: cn(
|
|
@@ -4257,7 +4573,7 @@ var TimbalChatShell = ({
|
|
|
4257
4573
|
"aria-hidden": true
|
|
4258
4574
|
}
|
|
4259
4575
|
),
|
|
4260
|
-
/* @__PURE__ */ (0,
|
|
4576
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
4261
4577
|
"header",
|
|
4262
4578
|
{
|
|
4263
4579
|
className: cn(
|
|
@@ -4266,9 +4582,9 @@ var TimbalChatShell = ({
|
|
|
4266
4582
|
),
|
|
4267
4583
|
style: { minHeight: "var(--studio-topbar-height)" },
|
|
4268
4584
|
children: [
|
|
4269
|
-
/* @__PURE__ */ (0,
|
|
4585
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
4270
4586
|
brand,
|
|
4271
|
-
showSelector && /* @__PURE__ */ (0,
|
|
4587
|
+
showSelector && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4272
4588
|
WorkforceSelector,
|
|
4273
4589
|
{
|
|
4274
4590
|
workforces,
|
|
@@ -4277,11 +4593,11 @@ var TimbalChatShell = ({
|
|
|
4277
4593
|
}
|
|
4278
4594
|
)
|
|
4279
4595
|
] }),
|
|
4280
|
-
/* @__PURE__ */ (0,
|
|
4596
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "flex shrink-0 items-center gap-1", children: headerActions })
|
|
4281
4597
|
]
|
|
4282
4598
|
}
|
|
4283
4599
|
),
|
|
4284
|
-
/* @__PURE__ */ (0,
|
|
4600
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4285
4601
|
TimbalChat,
|
|
4286
4602
|
{
|
|
4287
4603
|
workforceId: effectiveId,
|
|
@@ -4298,9 +4614,9 @@ var TimbalChatShell = ({
|
|
|
4298
4614
|
};
|
|
4299
4615
|
|
|
4300
4616
|
// src/studio/shell/studio-shell.tsx
|
|
4301
|
-
var
|
|
4617
|
+
var import_react47 = require("react");
|
|
4302
4618
|
var import_lucide_react13 = require("lucide-react");
|
|
4303
|
-
var
|
|
4619
|
+
var import_react48 = require("motion/react");
|
|
4304
4620
|
|
|
4305
4621
|
// src/design/sidebar-motion.ts
|
|
4306
4622
|
var STUDIO_SIDEBAR_EASE_ENTER = [0, 0, 0.2, 1];
|
|
@@ -4371,16 +4687,16 @@ function studioSidebarBackdropTransition(reduced) {
|
|
|
4371
4687
|
}
|
|
4372
4688
|
|
|
4373
4689
|
// src/hooks/use-sidebar-collapse-phase.ts
|
|
4374
|
-
var
|
|
4690
|
+
var import_react33 = require("react");
|
|
4375
4691
|
var WIDTH_OVERLAP_FRAC = 0.7;
|
|
4376
4692
|
function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
4377
|
-
const [widthCollapsed, setWidthCollapsed] = (0,
|
|
4378
|
-
const [entriesVisible, setEntriesVisible] = (0,
|
|
4379
|
-
const collapsedTarget = (0,
|
|
4380
|
-
const isFirstRender = (0,
|
|
4381
|
-
const widthTimerRef = (0,
|
|
4382
|
-
const revealTimerRef = (0,
|
|
4383
|
-
(0,
|
|
4693
|
+
const [widthCollapsed, setWidthCollapsed] = (0, import_react33.useState)(collapsed);
|
|
4694
|
+
const [entriesVisible, setEntriesVisible] = (0, import_react33.useState)(true);
|
|
4695
|
+
const collapsedTarget = (0, import_react33.useRef)(collapsed);
|
|
4696
|
+
const isFirstRender = (0, import_react33.useRef)(true);
|
|
4697
|
+
const widthTimerRef = (0, import_react33.useRef)(null);
|
|
4698
|
+
const revealTimerRef = (0, import_react33.useRef)(null);
|
|
4699
|
+
(0, import_react33.useEffect)(() => {
|
|
4384
4700
|
collapsedTarget.current = collapsed;
|
|
4385
4701
|
}, [collapsed]);
|
|
4386
4702
|
const clearWidthTimer = () => {
|
|
@@ -4395,7 +4711,7 @@ function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
|
4395
4711
|
revealTimerRef.current = null;
|
|
4396
4712
|
}
|
|
4397
4713
|
};
|
|
4398
|
-
const applyWidthTarget = (0,
|
|
4714
|
+
const applyWidthTarget = (0, import_react33.useCallback)(() => {
|
|
4399
4715
|
const willExpand = !collapsedTarget.current;
|
|
4400
4716
|
setWidthCollapsed(collapsedTarget.current);
|
|
4401
4717
|
clearRevealTimer();
|
|
@@ -4406,7 +4722,7 @@ function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
|
4406
4722
|
);
|
|
4407
4723
|
}
|
|
4408
4724
|
}, [reducedMotion]);
|
|
4409
|
-
(0,
|
|
4725
|
+
(0, import_react33.useEffect)(() => {
|
|
4410
4726
|
clearWidthTimer();
|
|
4411
4727
|
clearRevealTimer();
|
|
4412
4728
|
if (reducedMotion) {
|
|
@@ -4430,10 +4746,10 @@ function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
|
4430
4746
|
clearRevealTimer();
|
|
4431
4747
|
};
|
|
4432
4748
|
}, [collapsed, reducedMotion, applyWidthTarget]);
|
|
4433
|
-
const onEntriesBlurOutComplete = (0,
|
|
4749
|
+
const onEntriesBlurOutComplete = (0, import_react33.useCallback)(() => {
|
|
4434
4750
|
applyWidthTarget();
|
|
4435
4751
|
}, [applyWidthTarget]);
|
|
4436
|
-
const onPanelWidthComplete = (0,
|
|
4752
|
+
const onPanelWidthComplete = (0, import_react33.useCallback)(() => {
|
|
4437
4753
|
clearRevealTimer();
|
|
4438
4754
|
setEntriesVisible(true);
|
|
4439
4755
|
}, []);
|
|
@@ -4448,15 +4764,15 @@ function useSidebarCollapsePhase(collapsed, reducedMotion) {
|
|
|
4448
4764
|
}
|
|
4449
4765
|
|
|
4450
4766
|
// src/studio/sidebar/sidebar-backdrop.tsx
|
|
4451
|
-
var
|
|
4452
|
-
var
|
|
4767
|
+
var import_react34 = require("motion/react");
|
|
4768
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
4453
4769
|
var StudioSidebarBackdrop = ({
|
|
4454
4770
|
open,
|
|
4455
4771
|
onClose
|
|
4456
4772
|
}) => {
|
|
4457
|
-
const reducedMotion = (0,
|
|
4458
|
-
return /* @__PURE__ */ (0,
|
|
4459
|
-
|
|
4773
|
+
const reducedMotion = (0, import_react34.useReducedMotion)();
|
|
4774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_react34.AnimatePresence, { children: open ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
4775
|
+
import_react34.motion.button,
|
|
4460
4776
|
{
|
|
4461
4777
|
type: "button",
|
|
4462
4778
|
className: "fixed inset-0 z-40 bg-foreground/30 backdrop-blur-[2px] md:hidden",
|
|
@@ -4471,36 +4787,36 @@ var StudioSidebarBackdrop = ({
|
|
|
4471
4787
|
};
|
|
4472
4788
|
|
|
4473
4789
|
// src/studio/sidebar/sidebar-context.tsx
|
|
4474
|
-
var
|
|
4475
|
-
var StudioSidebarContext = (0,
|
|
4790
|
+
var import_react35 = require("react");
|
|
4791
|
+
var StudioSidebarContext = (0, import_react35.createContext)({
|
|
4476
4792
|
collapsed: false,
|
|
4477
4793
|
isMobile: false,
|
|
4478
4794
|
isCollapsedRail: false,
|
|
4479
4795
|
iconOnlyLayout: false
|
|
4480
4796
|
});
|
|
4481
4797
|
function useStudioSidebarLayout() {
|
|
4482
|
-
return (0,
|
|
4798
|
+
return (0, import_react35.useContext)(StudioSidebarContext);
|
|
4483
4799
|
}
|
|
4484
4800
|
|
|
4485
4801
|
// src/studio/sidebar/sidebar.tsx
|
|
4486
|
-
var
|
|
4487
|
-
var
|
|
4802
|
+
var import_react41 = require("react");
|
|
4803
|
+
var import_react42 = require("motion/react");
|
|
4488
4804
|
|
|
4489
4805
|
// src/studio/sidebar/sidebar-entries.tsx
|
|
4490
|
-
var
|
|
4491
|
-
var
|
|
4806
|
+
var import_react36 = require("motion/react");
|
|
4807
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
4492
4808
|
var StudioSidebarEntries = ({
|
|
4493
4809
|
visible,
|
|
4494
4810
|
onBlurOutComplete,
|
|
4495
4811
|
children,
|
|
4496
4812
|
className
|
|
4497
4813
|
}) => {
|
|
4498
|
-
const reducedMotion = (0,
|
|
4814
|
+
const reducedMotion = (0, import_react36.useReducedMotion)();
|
|
4499
4815
|
if (reducedMotion) {
|
|
4500
|
-
return visible ? /* @__PURE__ */ (0,
|
|
4816
|
+
return visible ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: cn("flex min-h-0 flex-1 flex-col", className), children }) : null;
|
|
4501
4817
|
}
|
|
4502
|
-
return /* @__PURE__ */ (0,
|
|
4503
|
-
|
|
4818
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4819
|
+
import_react36.motion.div,
|
|
4504
4820
|
{
|
|
4505
4821
|
className: cn("flex min-h-0 flex-1 flex-col", className),
|
|
4506
4822
|
initial: false,
|
|
@@ -4523,11 +4839,11 @@ var StudioSidebarEntries = ({
|
|
|
4523
4839
|
var import_lucide_react10 = require("lucide-react");
|
|
4524
4840
|
|
|
4525
4841
|
// src/auth/provider.tsx
|
|
4526
|
-
var
|
|
4527
|
-
var
|
|
4528
|
-
var SessionContext = (0,
|
|
4842
|
+
var import_react37 = require("react");
|
|
4843
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
4844
|
+
var SessionContext = (0, import_react37.createContext)(void 0);
|
|
4529
4845
|
var useOptionalSession = () => {
|
|
4530
|
-
const context = (0,
|
|
4846
|
+
const context = (0, import_react37.useContext)(SessionContext);
|
|
4531
4847
|
return context ?? null;
|
|
4532
4848
|
};
|
|
4533
4849
|
|
|
@@ -4554,35 +4870,35 @@ function studioSidebarNavItemClasses(iconOnly, isActive) {
|
|
|
4554
4870
|
}
|
|
4555
4871
|
|
|
4556
4872
|
// src/studio/sidebar/sidebar-entry-motion.tsx
|
|
4557
|
-
var
|
|
4558
|
-
var
|
|
4873
|
+
var import_react38 = require("motion/react");
|
|
4874
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
4559
4875
|
var StudioSidebarEntryMotion = ({
|
|
4560
4876
|
children,
|
|
4561
4877
|
className
|
|
4562
4878
|
}) => {
|
|
4563
|
-
const reducedMotion = (0,
|
|
4879
|
+
const reducedMotion = (0, import_react38.useReducedMotion)();
|
|
4564
4880
|
if (reducedMotion) {
|
|
4565
|
-
return /* @__PURE__ */ (0,
|
|
4881
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className, children });
|
|
4566
4882
|
}
|
|
4567
|
-
return /* @__PURE__ */ (0,
|
|
4883
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_react38.motion.div, { variants: studioSidebarEntryItemVariants, className: cn(className), children });
|
|
4568
4884
|
};
|
|
4569
4885
|
|
|
4570
4886
|
// src/studio/sidebar/sidebar-tooltip.tsx
|
|
4571
|
-
var
|
|
4887
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
4572
4888
|
var StudioSidebarTooltip = ({
|
|
4573
4889
|
label,
|
|
4574
4890
|
enabled,
|
|
4575
4891
|
children
|
|
4576
4892
|
}) => {
|
|
4577
|
-
if (!enabled) return /* @__PURE__ */ (0,
|
|
4578
|
-
return /* @__PURE__ */ (0,
|
|
4579
|
-
/* @__PURE__ */ (0,
|
|
4580
|
-
/* @__PURE__ */ (0,
|
|
4893
|
+
if (!enabled) return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
|
|
4894
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(Tooltip, { children: [
|
|
4895
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(TooltipTrigger, { asChild: true, children }),
|
|
4896
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(TooltipContent, { side: "right", className: "text-xs", children: label })
|
|
4581
4897
|
] });
|
|
4582
4898
|
};
|
|
4583
4899
|
|
|
4584
4900
|
// src/studio/sidebar/sidebar-footer.tsx
|
|
4585
|
-
var
|
|
4901
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
4586
4902
|
function userInitials(name, email) {
|
|
4587
4903
|
const fromName = name.trim().split(/\s+/).map((part) => part.charAt(0)).join("").slice(0, 2).toUpperCase();
|
|
4588
4904
|
if (fromName) return fromName;
|
|
@@ -4600,32 +4916,32 @@ var StudioSidebarFooter = ({
|
|
|
4600
4916
|
session?.logout();
|
|
4601
4917
|
onSignOut?.();
|
|
4602
4918
|
};
|
|
4603
|
-
return /* @__PURE__ */ (0,
|
|
4919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(StudioSidebarEntryMotion, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
4604
4920
|
"footer",
|
|
4605
4921
|
{
|
|
4606
4922
|
className: cn(
|
|
4607
4923
|
"mt-auto w-full shrink-0 py-2.5",
|
|
4608
4924
|
iconOnlyLayout ? studioSidebarCollapsedRailInsetClass : "px-2.5"
|
|
4609
4925
|
),
|
|
4610
|
-
children: user ? /* @__PURE__ */ (0,
|
|
4611
|
-
iconOnlyLayout ? /* @__PURE__ */ (0,
|
|
4612
|
-
user.user_photo_url ? /* @__PURE__ */ (0,
|
|
4613
|
-
/* @__PURE__ */ (0,
|
|
4614
|
-
] }) }) : /* @__PURE__ */ (0,
|
|
4615
|
-
/* @__PURE__ */ (0,
|
|
4616
|
-
user.user_photo_url ? /* @__PURE__ */ (0,
|
|
4617
|
-
/* @__PURE__ */ (0,
|
|
4926
|
+
children: user ? /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
4927
|
+
iconOnlyLayout ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: studioSidebarCollapsedRailChipRowClass, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Avatar, { size: "sm", className: "size-8", children: [
|
|
4928
|
+
user.user_photo_url ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(AvatarImage, { src: user.user_photo_url, alt: user.user_name }) : null,
|
|
4929
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(AvatarFallback, { className: "text-[10px]", children: userInitials(user.user_name, user.user_email) })
|
|
4930
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex min-w-0 items-center gap-2.5", children: [
|
|
4931
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Avatar, { size: "sm", children: [
|
|
4932
|
+
user.user_photo_url ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(AvatarImage, { src: user.user_photo_url, alt: user.user_name }) : null,
|
|
4933
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(AvatarFallback, { children: userInitials(user.user_name, user.user_email) })
|
|
4618
4934
|
] }),
|
|
4619
|
-
/* @__PURE__ */ (0,
|
|
4620
|
-
/* @__PURE__ */ (0,
|
|
4621
|
-
/* @__PURE__ */ (0,
|
|
4935
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "min-w-0 flex-1", children: [
|
|
4936
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "truncate text-sm font-medium text-foreground", children: user.user_name }),
|
|
4937
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "truncate text-xs text-muted-foreground", children: user.user_email })
|
|
4622
4938
|
] })
|
|
4623
4939
|
] }),
|
|
4624
|
-
/* @__PURE__ */ (0,
|
|
4940
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
4625
4941
|
"div",
|
|
4626
4942
|
{
|
|
4627
4943
|
className: iconOnlyLayout ? studioSidebarCollapsedRailChipRowClass : void 0,
|
|
4628
|
-
children: /* @__PURE__ */ (0,
|
|
4944
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(StudioSidebarTooltip, { label: "Sign out", enabled: showTooltips, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
4629
4945
|
"button",
|
|
4630
4946
|
{
|
|
4631
4947
|
type: "button",
|
|
@@ -4636,28 +4952,28 @@ var StudioSidebarFooter = ({
|
|
|
4636
4952
|
),
|
|
4637
4953
|
"aria-label": "Sign out",
|
|
4638
4954
|
children: [
|
|
4639
|
-
/* @__PURE__ */ (0,
|
|
4955
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_lucide_react10.LogOut, { className: "size-3.5 shrink-0" }),
|
|
4640
4956
|
!iconOnlyLayout ? "Sign out" : null
|
|
4641
4957
|
]
|
|
4642
4958
|
}
|
|
4643
4959
|
) })
|
|
4644
4960
|
}
|
|
4645
4961
|
)
|
|
4646
|
-
] }) : !iconOnlyLayout && emptyCaption ? /* @__PURE__ */ (0,
|
|
4962
|
+
] }) : !iconOnlyLayout && emptyCaption ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "px-1 text-xs text-muted-foreground", children: emptyCaption }) : null
|
|
4647
4963
|
}
|
|
4648
4964
|
) });
|
|
4649
4965
|
};
|
|
4650
4966
|
|
|
4651
4967
|
// src/studio/sidebar/sidebar-header.tsx
|
|
4652
4968
|
var import_lucide_react11 = require("lucide-react");
|
|
4653
|
-
var
|
|
4969
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
4654
4970
|
var sidebarHeaderClass = "flex h-12 shrink-0 items-center px-2";
|
|
4655
4971
|
var toggleButtonClass = cn(
|
|
4656
4972
|
"flex shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors",
|
|
4657
4973
|
"hover:bg-muted hover:text-foreground",
|
|
4658
4974
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/15"
|
|
4659
4975
|
);
|
|
4660
|
-
var SidebarToggleButton = ({ ariaLabel, expanded, onClick, children }) => /* @__PURE__ */ (0,
|
|
4976
|
+
var SidebarToggleButton = ({ ariaLabel, expanded, onClick, children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4661
4977
|
"button",
|
|
4662
4978
|
{
|
|
4663
4979
|
type: "button",
|
|
@@ -4671,7 +4987,7 @@ var SidebarToggleButton = ({ ariaLabel, expanded, onClick, children }) => /* @__
|
|
|
4671
4987
|
var CollapsedBrandToggle = ({
|
|
4672
4988
|
onExpand,
|
|
4673
4989
|
brand
|
|
4674
|
-
}) => /* @__PURE__ */ (0,
|
|
4990
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: studioSidebarCollapsedRailChipRowClass, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(StudioSidebarTooltip, { label: "Expand sidebar", enabled: true, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
4675
4991
|
"button",
|
|
4676
4992
|
{
|
|
4677
4993
|
type: "button",
|
|
@@ -4683,7 +4999,7 @@ var CollapsedBrandToggle = ({
|
|
|
4683
4999
|
"group relative inline-flex size-8 items-center justify-center overflow-hidden rounded-lg"
|
|
4684
5000
|
),
|
|
4685
5001
|
children: [
|
|
4686
|
-
/* @__PURE__ */ (0,
|
|
5002
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4687
5003
|
"span",
|
|
4688
5004
|
{
|
|
4689
5005
|
"aria-hidden": true,
|
|
@@ -4695,7 +5011,7 @@ var CollapsedBrandToggle = ({
|
|
|
4695
5011
|
children: brand
|
|
4696
5012
|
}
|
|
4697
5013
|
),
|
|
4698
|
-
/* @__PURE__ */ (0,
|
|
5014
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4699
5015
|
import_lucide_react11.ChevronRight,
|
|
4700
5016
|
{
|
|
4701
5017
|
"aria-hidden": true,
|
|
@@ -4717,40 +5033,40 @@ var StudioSidebarHeader = ({
|
|
|
4717
5033
|
brand
|
|
4718
5034
|
}) => {
|
|
4719
5035
|
if (isMobile) {
|
|
4720
|
-
return /* @__PURE__ */ (0,
|
|
5036
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("header", { className: cn(sidebarHeaderClass, "justify-between gap-2 pr-2"), children: [
|
|
4721
5037
|
brand,
|
|
4722
|
-
/* @__PURE__ */ (0,
|
|
5038
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4723
5039
|
SidebarToggleButton,
|
|
4724
5040
|
{
|
|
4725
5041
|
ariaLabel: "Close menu",
|
|
4726
5042
|
expanded: mobileOpen,
|
|
4727
5043
|
onClick: onToggle,
|
|
4728
|
-
children: /* @__PURE__ */ (0,
|
|
5044
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_lucide_react11.X, { className: "size-3.5" })
|
|
4729
5045
|
}
|
|
4730
5046
|
)
|
|
4731
5047
|
] });
|
|
4732
5048
|
}
|
|
4733
5049
|
if (isCollapsedRail) {
|
|
4734
|
-
return /* @__PURE__ */ (0,
|
|
5050
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4735
5051
|
"header",
|
|
4736
5052
|
{
|
|
4737
5053
|
className: cn(
|
|
4738
5054
|
"flex h-12 shrink-0 items-center",
|
|
4739
5055
|
studioSidebarCollapsedRailInsetClass
|
|
4740
5056
|
),
|
|
4741
|
-
children: /* @__PURE__ */ (0,
|
|
5057
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CollapsedBrandToggle, { onExpand: onToggle, brand })
|
|
4742
5058
|
}
|
|
4743
5059
|
);
|
|
4744
5060
|
}
|
|
4745
|
-
return /* @__PURE__ */ (0,
|
|
5061
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("header", { className: cn(sidebarHeaderClass, "justify-between gap-1 pr-2"), children: [
|
|
4746
5062
|
brand,
|
|
4747
|
-
/* @__PURE__ */ (0,
|
|
5063
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4748
5064
|
SidebarToggleButton,
|
|
4749
5065
|
{
|
|
4750
5066
|
ariaLabel: "Collapse sidebar",
|
|
4751
5067
|
expanded: true,
|
|
4752
5068
|
onClick: onToggle,
|
|
4753
|
-
children: /* @__PURE__ */ (0,
|
|
5069
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_lucide_react11.ChevronLeft, { className: "size-4" })
|
|
4754
5070
|
}
|
|
4755
5071
|
)
|
|
4756
5072
|
] });
|
|
@@ -4769,7 +5085,7 @@ function workforceItemInitial(w) {
|
|
|
4769
5085
|
}
|
|
4770
5086
|
|
|
4771
5087
|
// src/studio/sidebar/sidebar-nav.tsx
|
|
4772
|
-
var
|
|
5088
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
4773
5089
|
var StudioSidebarNav = ({
|
|
4774
5090
|
workforces,
|
|
4775
5091
|
selectedId,
|
|
@@ -4778,7 +5094,7 @@ var StudioSidebarNav = ({
|
|
|
4778
5094
|
showTooltips
|
|
4779
5095
|
}) => {
|
|
4780
5096
|
if (workforces.length === 0) return null;
|
|
4781
|
-
return /* @__PURE__ */ (0,
|
|
5097
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4782
5098
|
"nav",
|
|
4783
5099
|
{
|
|
4784
5100
|
className: cn(
|
|
@@ -4790,11 +5106,11 @@ var StudioSidebarNav = ({
|
|
|
4790
5106
|
const id = workforceItemId(w);
|
|
4791
5107
|
const isActive = id === selectedId;
|
|
4792
5108
|
const label = workforceItemLabel(w);
|
|
4793
|
-
return /* @__PURE__ */ (0,
|
|
5109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4794
5110
|
StudioSidebarEntryMotion,
|
|
4795
5111
|
{
|
|
4796
5112
|
className: iconOnlyLayout ? studioSidebarCollapsedRailChipRowClass : void 0,
|
|
4797
|
-
children: /* @__PURE__ */ (0,
|
|
5113
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(StudioSidebarTooltip, { label, enabled: showTooltips, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4798
5114
|
"button",
|
|
4799
5115
|
{
|
|
4800
5116
|
type: "button",
|
|
@@ -4805,7 +5121,7 @@ var StudioSidebarNav = ({
|
|
|
4805
5121
|
studioSidebarNavItemClasses(iconOnlyLayout, isActive),
|
|
4806
5122
|
iconOnlyLayout && "inline-flex"
|
|
4807
5123
|
),
|
|
4808
|
-
children: iconOnlyLayout ? /* @__PURE__ */ (0,
|
|
5124
|
+
children: iconOnlyLayout ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "text-xs font-semibold leading-none", children: workforceItemInitial(w) }) : /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "min-w-0 truncate", children: label })
|
|
4809
5125
|
}
|
|
4810
5126
|
) })
|
|
4811
5127
|
},
|
|
@@ -4818,7 +5134,7 @@ var StudioSidebarNav = ({
|
|
|
4818
5134
|
|
|
4819
5135
|
// src/studio/sidebar/timbal-mark.tsx
|
|
4820
5136
|
var import_shaders_react = require("@paper-design/shaders-react");
|
|
4821
|
-
var
|
|
5137
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
4822
5138
|
var DEFAULT_SIZE = 64;
|
|
4823
5139
|
var TRANSPARENT_BACK = "#00000000";
|
|
4824
5140
|
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=";
|
|
@@ -4827,14 +5143,14 @@ function TimbalMark({
|
|
|
4827
5143
|
size = DEFAULT_SIZE,
|
|
4828
5144
|
src = TIMBAL_SYMBOL_DATA_URI
|
|
4829
5145
|
}) {
|
|
4830
|
-
return /* @__PURE__ */ (0,
|
|
5146
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4831
5147
|
"div",
|
|
4832
5148
|
{
|
|
4833
5149
|
className: cn("relative shrink-0 bg-transparent", className),
|
|
4834
5150
|
style: { width: size, height: size },
|
|
4835
5151
|
role: "img",
|
|
4836
5152
|
"aria-label": "Timbal",
|
|
4837
|
-
children: /* @__PURE__ */ (0,
|
|
5153
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4838
5154
|
import_shaders_react.LiquidMetal,
|
|
4839
5155
|
{
|
|
4840
5156
|
width: size,
|
|
@@ -4866,14 +5182,14 @@ function TimbalMark({
|
|
|
4866
5182
|
}
|
|
4867
5183
|
|
|
4868
5184
|
// src/studio/sidebar/shell-inset-bridge-context.tsx
|
|
4869
|
-
var
|
|
5185
|
+
var import_react40 = require("react");
|
|
4870
5186
|
|
|
4871
5187
|
// src/layout/shell-inset-context.tsx
|
|
4872
|
-
var
|
|
4873
|
-
var ShellInsetContext = (0,
|
|
5188
|
+
var import_react39 = require("react");
|
|
5189
|
+
var ShellInsetContext = (0, import_react39.createContext)(null);
|
|
4874
5190
|
var ShellInsetProvider = ShellInsetContext.Provider;
|
|
4875
5191
|
function useShellInsetReporter() {
|
|
4876
|
-
return (0,
|
|
5192
|
+
return (0, import_react39.useContext)(ShellInsetContext);
|
|
4877
5193
|
}
|
|
4878
5194
|
|
|
4879
5195
|
// src/studio/sidebar/shell-inset-bridge-context.tsx
|
|
@@ -4882,7 +5198,7 @@ var StudioSidebarShellInsetBridge = ({
|
|
|
4882
5198
|
}) => {
|
|
4883
5199
|
const reportInset = useShellInsetReporter();
|
|
4884
5200
|
const { isMobile, isCollapsedRail } = useStudioSidebarLayout();
|
|
4885
|
-
(0,
|
|
5201
|
+
(0, import_react40.useLayoutEffect)(() => {
|
|
4886
5202
|
const insetPx = isMobile ? 0 : isCollapsedRail ? SIDEBAR_INSET_PX_COLLAPSED : SIDEBAR_INSET_PX_EXPANDED;
|
|
4887
5203
|
reportInset?.(insetPx);
|
|
4888
5204
|
onInsetChange?.(insetPx);
|
|
@@ -4891,7 +5207,7 @@ var StudioSidebarShellInsetBridge = ({
|
|
|
4891
5207
|
};
|
|
4892
5208
|
|
|
4893
5209
|
// src/studio/sidebar/sidebar.tsx
|
|
4894
|
-
var
|
|
5210
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
4895
5211
|
var DEFAULT_BREAKPOINT_PX = 768;
|
|
4896
5212
|
function readPersistedCollapsed(key) {
|
|
4897
5213
|
if (!key || typeof window === "undefined") return false;
|
|
@@ -4924,7 +5240,7 @@ var StudioSidebarPanel = ({
|
|
|
4924
5240
|
brand,
|
|
4925
5241
|
emptyCaption = null
|
|
4926
5242
|
}) => {
|
|
4927
|
-
const reducedMotion = (0,
|
|
5243
|
+
const reducedMotion = (0, import_react42.useReducedMotion)();
|
|
4928
5244
|
const isCollapsedRail = widthCollapsed && !isMobile;
|
|
4929
5245
|
const iconOnlyLayout = studioSidebarIconOnlyLayout(isMobile, isCollapsedRail);
|
|
4930
5246
|
const isDrawerOpen = isMobile && mobileOpen;
|
|
@@ -4941,9 +5257,9 @@ var StudioSidebarPanel = ({
|
|
|
4941
5257
|
onCollapsedChange(!collapsed);
|
|
4942
5258
|
};
|
|
4943
5259
|
const panelWidthPx = isMobile ? SIDEBAR_MOBILE_PX : widthCollapsed ? SIDEBAR_WIDTH_COLLAPSED_PX : SIDEBAR_WIDTH_PX;
|
|
4944
|
-
const brandNode = brand ?? /* @__PURE__ */ (0,
|
|
4945
|
-
const panel = /* @__PURE__ */ (0,
|
|
4946
|
-
|
|
5260
|
+
const brandNode = brand ?? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(TimbalMark, { size: 32 });
|
|
5261
|
+
const panel = /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
5262
|
+
import_react42.motion.div,
|
|
4947
5263
|
{
|
|
4948
5264
|
"data-sidebar-collapsed": isCollapsedRail ? "" : void 0,
|
|
4949
5265
|
className: cn(
|
|
@@ -4957,7 +5273,7 @@ var StudioSidebarPanel = ({
|
|
|
4957
5273
|
style: { willChange: entriesVisible ? void 0 : "width" },
|
|
4958
5274
|
onAnimationComplete: isMobile || entriesVisible ? void 0 : () => onPanelWidthComplete(),
|
|
4959
5275
|
children: [
|
|
4960
|
-
/* @__PURE__ */ (0,
|
|
5276
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4961
5277
|
StudioSidebarHeader,
|
|
4962
5278
|
{
|
|
4963
5279
|
isCollapsedRail,
|
|
@@ -4967,13 +5283,13 @@ var StudioSidebarPanel = ({
|
|
|
4967
5283
|
brand: brandNode
|
|
4968
5284
|
}
|
|
4969
5285
|
),
|
|
4970
|
-
/* @__PURE__ */ (0,
|
|
5286
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
4971
5287
|
StudioSidebarEntries,
|
|
4972
5288
|
{
|
|
4973
5289
|
visible: entriesVisible,
|
|
4974
5290
|
onBlurOutComplete: onEntriesBlurOutComplete,
|
|
4975
5291
|
children: [
|
|
4976
|
-
/* @__PURE__ */ (0,
|
|
5292
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4977
5293
|
"div",
|
|
4978
5294
|
{
|
|
4979
5295
|
id: DOM_IDS.sidebarRuntimeAnchor,
|
|
@@ -4983,7 +5299,7 @@ var StudioSidebarPanel = ({
|
|
|
4983
5299
|
)
|
|
4984
5300
|
}
|
|
4985
5301
|
),
|
|
4986
|
-
/* @__PURE__ */ (0,
|
|
5302
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4987
5303
|
StudioSidebarNav,
|
|
4988
5304
|
{
|
|
4989
5305
|
workforces,
|
|
@@ -4993,8 +5309,8 @@ var StudioSidebarPanel = ({
|
|
|
4993
5309
|
showTooltips: isCollapsedRail
|
|
4994
5310
|
}
|
|
4995
5311
|
),
|
|
4996
|
-
workforces.length === 0 ? /* @__PURE__ */ (0,
|
|
4997
|
-
/* @__PURE__ */ (0,
|
|
5312
|
+
workforces.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "min-h-0 flex-1" }) : null,
|
|
5313
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
4998
5314
|
StudioSidebarFooter,
|
|
4999
5315
|
{
|
|
5000
5316
|
iconOnlyLayout,
|
|
@@ -5010,8 +5326,8 @@ var StudioSidebarPanel = ({
|
|
|
5010
5326
|
}
|
|
5011
5327
|
);
|
|
5012
5328
|
if (isMobile) {
|
|
5013
|
-
return /* @__PURE__ */ (0,
|
|
5014
|
-
|
|
5329
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
5330
|
+
import_react42.motion.aside,
|
|
5015
5331
|
{
|
|
5016
5332
|
className: "fixed inset-y-0 left-0 z-[60] flex",
|
|
5017
5333
|
"aria-label": "Studio navigation",
|
|
@@ -5026,7 +5342,7 @@ var StudioSidebarPanel = ({
|
|
|
5026
5342
|
}
|
|
5027
5343
|
);
|
|
5028
5344
|
}
|
|
5029
|
-
return /* @__PURE__ */ (0,
|
|
5345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
5030
5346
|
"aside",
|
|
5031
5347
|
{
|
|
5032
5348
|
className: "absolute inset-y-0 left-0 z-[60] flex py-[var(--studio-sidebar-gap)] pl-[var(--studio-sidebar-gap)]",
|
|
@@ -5048,51 +5364,51 @@ var StudioSidebar = ({
|
|
|
5048
5364
|
onMobileOpenChange: onMobileOpenChangeProp,
|
|
5049
5365
|
onInsetChange
|
|
5050
5366
|
}) => {
|
|
5051
|
-
const reducedMotion = (0,
|
|
5367
|
+
const reducedMotion = (0, import_react42.useReducedMotion)();
|
|
5052
5368
|
const fetched = useWorkforces({ enabled: workforcesProp === void 0 });
|
|
5053
5369
|
const workforces = workforcesProp ?? fetched.workforces;
|
|
5054
|
-
const [internalSelected, setInternalSelected] = (0,
|
|
5370
|
+
const [internalSelected, setInternalSelected] = (0, import_react41.useState)(
|
|
5055
5371
|
selectedIdProp ?? ""
|
|
5056
5372
|
);
|
|
5057
|
-
(0,
|
|
5373
|
+
(0, import_react41.useEffect)(() => {
|
|
5058
5374
|
if (selectedIdProp !== void 0) return;
|
|
5059
5375
|
if (internalSelected) return;
|
|
5060
5376
|
const first = workforces[0]?.id ?? workforces[0]?.uid ?? workforces[0]?.name;
|
|
5061
5377
|
if (first) setInternalSelected(first);
|
|
5062
5378
|
}, [workforces, selectedIdProp, internalSelected]);
|
|
5063
5379
|
const selectedId = selectedIdProp ?? internalSelected ?? workforces[0]?.id ?? workforces[0]?.uid ?? workforces[0]?.name ?? "";
|
|
5064
|
-
const handleSelect = (0,
|
|
5380
|
+
const handleSelect = (0, import_react41.useCallback)(
|
|
5065
5381
|
(id) => {
|
|
5066
5382
|
if (selectedIdProp === void 0) setInternalSelected(id);
|
|
5067
5383
|
onSelect?.(id);
|
|
5068
5384
|
},
|
|
5069
5385
|
[selectedIdProp, onSelect]
|
|
5070
5386
|
);
|
|
5071
|
-
const [collapsed, setCollapsed] = (0,
|
|
5387
|
+
const [collapsed, setCollapsed] = (0, import_react41.useState)(() => {
|
|
5072
5388
|
const persisted = readPersistedCollapsed(persistKey);
|
|
5073
5389
|
return persisted || defaultCollapsed;
|
|
5074
5390
|
});
|
|
5075
|
-
const handleCollapsedChange = (0,
|
|
5391
|
+
const handleCollapsedChange = (0, import_react41.useCallback)(
|
|
5076
5392
|
(next) => {
|
|
5077
5393
|
setCollapsed(next);
|
|
5078
5394
|
writePersistedCollapsed(persistKey, next);
|
|
5079
5395
|
},
|
|
5080
5396
|
[persistKey]
|
|
5081
5397
|
);
|
|
5082
|
-
const [isMobile, setIsMobile] = (0,
|
|
5398
|
+
const [isMobile, setIsMobile] = (0, import_react41.useState)(() => {
|
|
5083
5399
|
if (typeof window === "undefined") return false;
|
|
5084
5400
|
return window.innerWidth < mobileBreakpointPx;
|
|
5085
5401
|
});
|
|
5086
|
-
(0,
|
|
5402
|
+
(0, import_react41.useEffect)(() => {
|
|
5087
5403
|
if (typeof window === "undefined") return;
|
|
5088
5404
|
const onResize = () => setIsMobile(window.innerWidth < mobileBreakpointPx);
|
|
5089
5405
|
onResize();
|
|
5090
5406
|
window.addEventListener("resize", onResize);
|
|
5091
5407
|
return () => window.removeEventListener("resize", onResize);
|
|
5092
5408
|
}, [mobileBreakpointPx]);
|
|
5093
|
-
const [internalMobileOpen, setInternalMobileOpen] = (0,
|
|
5409
|
+
const [internalMobileOpen, setInternalMobileOpen] = (0, import_react41.useState)(false);
|
|
5094
5410
|
const mobileOpen = mobileOpenProp ?? internalMobileOpen;
|
|
5095
|
-
const setMobileOpen = (0,
|
|
5411
|
+
const setMobileOpen = (0, import_react41.useCallback)(
|
|
5096
5412
|
(next) => {
|
|
5097
5413
|
if (mobileOpenProp === void 0) setInternalMobileOpen(next);
|
|
5098
5414
|
onMobileOpenChangeProp?.(next);
|
|
@@ -5109,7 +5425,7 @@ var StudioSidebar = ({
|
|
|
5109
5425
|
const entriesVisible = isMobile || phaseEntriesVisible;
|
|
5110
5426
|
const isCollapsedRail = widthCollapsed && !isMobile;
|
|
5111
5427
|
const iconOnlyLayout = studioSidebarIconOnlyLayout(isMobile, isCollapsedRail);
|
|
5112
|
-
const contextValue = (0,
|
|
5428
|
+
const contextValue = (0, import_react41.useMemo)(
|
|
5113
5429
|
() => ({
|
|
5114
5430
|
collapsed: effectiveCollapsed,
|
|
5115
5431
|
isMobile,
|
|
@@ -5118,9 +5434,9 @@ var StudioSidebar = ({
|
|
|
5118
5434
|
}),
|
|
5119
5435
|
[effectiveCollapsed, isMobile, isCollapsedRail, iconOnlyLayout]
|
|
5120
5436
|
);
|
|
5121
|
-
return /* @__PURE__ */ (0,
|
|
5122
|
-
/* @__PURE__ */ (0,
|
|
5123
|
-
/* @__PURE__ */ (0,
|
|
5437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(StudioSidebarContext.Provider, { value: contextValue, children: [
|
|
5438
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(StudioSidebarShellInsetBridge, { onInsetChange }),
|
|
5439
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
5124
5440
|
StudioSidebarPanel,
|
|
5125
5441
|
{
|
|
5126
5442
|
workforces,
|
|
@@ -5143,26 +5459,26 @@ var StudioSidebar = ({
|
|
|
5143
5459
|
};
|
|
5144
5460
|
|
|
5145
5461
|
// src/studio/sidebar/sidebar-runtime-portal.tsx
|
|
5146
|
-
var
|
|
5462
|
+
var import_react43 = require("react");
|
|
5147
5463
|
var import_react_dom = require("react-dom");
|
|
5148
5464
|
var import_lucide_react12 = require("lucide-react");
|
|
5149
|
-
var
|
|
5150
|
-
var
|
|
5465
|
+
var import_react44 = require("@assistant-ui/react");
|
|
5466
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
5151
5467
|
var StudioSidebarRuntimePortal = ({
|
|
5152
5468
|
label = "New chat"
|
|
5153
5469
|
}) => {
|
|
5154
5470
|
const { iconOnlyLayout } = useStudioSidebarLayout();
|
|
5155
|
-
const hasMessages = (0,
|
|
5471
|
+
const hasMessages = (0, import_react44.useThread)((s) => s.messages.length > 0);
|
|
5156
5472
|
const { clear } = useTimbalRuntime();
|
|
5157
|
-
const [anchor, setAnchor] = (0,
|
|
5158
|
-
const startNewChat = (0,
|
|
5473
|
+
const [anchor, setAnchor] = (0, import_react43.useState)(null);
|
|
5474
|
+
const startNewChat = (0, import_react43.useCallback)(() => {
|
|
5159
5475
|
clear();
|
|
5160
5476
|
}, [clear]);
|
|
5161
|
-
(0,
|
|
5477
|
+
(0, import_react43.useLayoutEffect)(() => {
|
|
5162
5478
|
setAnchor(document.getElementById(DOM_IDS.sidebarRuntimeAnchor));
|
|
5163
5479
|
}, []);
|
|
5164
5480
|
if (!anchor || !hasMessages) return null;
|
|
5165
|
-
const button = /* @__PURE__ */ (0,
|
|
5481
|
+
const button = /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
5166
5482
|
"button",
|
|
5167
5483
|
{
|
|
5168
5484
|
type: "button",
|
|
@@ -5170,24 +5486,24 @@ var StudioSidebarRuntimePortal = ({
|
|
|
5170
5486
|
"aria-label": label,
|
|
5171
5487
|
className: studioSidebarNavItemClasses(iconOnlyLayout, false),
|
|
5172
5488
|
children: [
|
|
5173
|
-
/* @__PURE__ */ (0,
|
|
5174
|
-
!iconOnlyLayout ? /* @__PURE__ */ (0,
|
|
5489
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_lucide_react12.MessageSquarePlus, { className: "size-3.5 shrink-0" }),
|
|
5490
|
+
!iconOnlyLayout ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "min-w-0 truncate", children: label }) : null
|
|
5175
5491
|
]
|
|
5176
5492
|
}
|
|
5177
5493
|
);
|
|
5178
5494
|
return (0, import_react_dom.createPortal)(
|
|
5179
|
-
iconOnlyLayout ? /* @__PURE__ */ (0,
|
|
5180
|
-
/* @__PURE__ */ (0,
|
|
5181
|
-
/* @__PURE__ */ (0,
|
|
5495
|
+
iconOnlyLayout ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Tooltip, { children: [
|
|
5496
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(TooltipTrigger, { asChild: true, children: button }),
|
|
5497
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(TooltipContent, { side: "right", className: "text-xs", children: label })
|
|
5182
5498
|
] }) : button,
|
|
5183
5499
|
anchor
|
|
5184
5500
|
);
|
|
5185
5501
|
};
|
|
5186
5502
|
|
|
5187
5503
|
// src/studio/sidebar/welcome.tsx
|
|
5188
|
-
var
|
|
5189
|
-
var
|
|
5190
|
-
var
|
|
5504
|
+
var import_react45 = require("motion/react");
|
|
5505
|
+
var import_react46 = require("@assistant-ui/react");
|
|
5506
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
5191
5507
|
var welcomeStagger2 = {
|
|
5192
5508
|
initial: {},
|
|
5193
5509
|
animate: {
|
|
@@ -5212,34 +5528,34 @@ var welcomeIcon2 = {
|
|
|
5212
5528
|
}
|
|
5213
5529
|
};
|
|
5214
5530
|
var StudioWelcome = ({ config, icon }) => {
|
|
5215
|
-
const isEmpty = (0,
|
|
5531
|
+
const isEmpty = (0, import_react46.useThread)((s) => s.messages.length === 0);
|
|
5216
5532
|
if (!isEmpty) return null;
|
|
5217
|
-
const iconNode = icon ?? /* @__PURE__ */ (0,
|
|
5533
|
+
const iconNode = icon ?? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
5218
5534
|
TimbalMark,
|
|
5219
5535
|
{
|
|
5220
5536
|
size: 112,
|
|
5221
5537
|
className: "max-md:scale-[0.58] max-md:origin-center"
|
|
5222
5538
|
}
|
|
5223
5539
|
);
|
|
5224
|
-
return /* @__PURE__ */ (0,
|
|
5225
|
-
|
|
5540
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.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_runtime44.jsx)("div", { className: "aui-thread-welcome-center flex w-full grow flex-col items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
5541
|
+
import_react45.motion.div,
|
|
5226
5542
|
{
|
|
5227
5543
|
className: "aui-thread-welcome-message flex flex-col items-center justify-center px-2 text-center sm:px-4",
|
|
5228
5544
|
variants: welcomeStagger2,
|
|
5229
5545
|
initial: "initial",
|
|
5230
5546
|
animate: "animate",
|
|
5231
5547
|
children: [
|
|
5232
|
-
/* @__PURE__ */ (0,
|
|
5233
|
-
/* @__PURE__ */ (0,
|
|
5234
|
-
|
|
5548
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react45.motion.div, { variants: welcomeIcon2, className: "mb-4 md:mb-5", children: iconNode }),
|
|
5549
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
5550
|
+
import_react45.motion.h1,
|
|
5235
5551
|
{
|
|
5236
5552
|
variants: welcomeItem2,
|
|
5237
5553
|
className: "aui-thread-welcome-message-inner text-xl font-semibold sm:text-2xl",
|
|
5238
5554
|
children: config?.heading ?? "How can I help you today?"
|
|
5239
5555
|
}
|
|
5240
5556
|
),
|
|
5241
|
-
/* @__PURE__ */ (0,
|
|
5242
|
-
|
|
5557
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
5558
|
+
import_react45.motion.p,
|
|
5243
5559
|
{
|
|
5244
5560
|
variants: welcomeItem2,
|
|
5245
5561
|
className: "aui-thread-welcome-message-inner mt-2 text-muted-foreground",
|
|
@@ -5252,8 +5568,8 @@ var StudioWelcome = ({ config, icon }) => {
|
|
|
5252
5568
|
};
|
|
5253
5569
|
|
|
5254
5570
|
// src/studio/shell/studio-shell.tsx
|
|
5255
|
-
var
|
|
5256
|
-
var
|
|
5571
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
5572
|
+
var import_react49 = require("react");
|
|
5257
5573
|
var DEFAULT_BREAKPOINT_PX2 = 768;
|
|
5258
5574
|
function readPersistedCollapsed2(key) {
|
|
5259
5575
|
if (!key || typeof window === "undefined") return false;
|
|
@@ -5273,9 +5589,9 @@ function writePersistedCollapsed2(key, collapsed) {
|
|
|
5273
5589
|
function makeComposerWithPortal(BaseComposer) {
|
|
5274
5590
|
const Resolved = BaseComposer ?? Composer;
|
|
5275
5591
|
return function StudioComposerWithSidebar(props) {
|
|
5276
|
-
return /* @__PURE__ */ (0,
|
|
5277
|
-
/* @__PURE__ */ (0,
|
|
5278
|
-
/* @__PURE__ */ (0,
|
|
5592
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
|
|
5593
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(StudioSidebarRuntimePortal, {}),
|
|
5594
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Resolved, { ...props })
|
|
5279
5595
|
] });
|
|
5280
5596
|
};
|
|
5281
5597
|
}
|
|
@@ -5295,7 +5611,7 @@ var TimbalStudioShell = ({
|
|
|
5295
5611
|
components,
|
|
5296
5612
|
...chatProps
|
|
5297
5613
|
}) => {
|
|
5298
|
-
const reducedMotion = (0,
|
|
5614
|
+
const reducedMotion = (0, import_react48.useReducedMotion)();
|
|
5299
5615
|
const shouldFetchWorkforces = !workforceId && workforcesProp === void 0;
|
|
5300
5616
|
const fetched = useWorkforces({
|
|
5301
5617
|
enabled: shouldFetchWorkforces,
|
|
@@ -5303,36 +5619,36 @@ var TimbalStudioShell = ({
|
|
|
5303
5619
|
baseUrl: workforcesBaseUrl
|
|
5304
5620
|
});
|
|
5305
5621
|
const workforces = workforcesProp ?? fetched.workforces;
|
|
5306
|
-
const [internalSelected, setInternalSelected] = (0,
|
|
5622
|
+
const [internalSelected, setInternalSelected] = (0, import_react47.useState)(
|
|
5307
5623
|
workforceId ?? ""
|
|
5308
5624
|
);
|
|
5309
|
-
(0,
|
|
5625
|
+
(0, import_react47.useEffect)(() => {
|
|
5310
5626
|
if (workforceId) return;
|
|
5311
5627
|
if (internalSelected) return;
|
|
5312
5628
|
const first = workforces[0]?.id ?? workforces[0]?.uid ?? workforces[0]?.name;
|
|
5313
5629
|
if (first) setInternalSelected(first);
|
|
5314
5630
|
}, [workforces, workforceId, internalSelected]);
|
|
5315
5631
|
const activeWorkforceId = workforceId ?? internalSelected ?? fetched.selectedId ?? "";
|
|
5316
|
-
const [collapsed, setCollapsed] = (0,
|
|
5632
|
+
const [collapsed, setCollapsed] = (0, import_react47.useState)(() => {
|
|
5317
5633
|
const persisted = readPersistedCollapsed2(persistKey);
|
|
5318
5634
|
return persisted || defaultCollapsed;
|
|
5319
5635
|
});
|
|
5320
|
-
const [isMobile, setIsMobile] = (0,
|
|
5636
|
+
const [isMobile, setIsMobile] = (0, import_react47.useState)(() => {
|
|
5321
5637
|
if (typeof window === "undefined") return false;
|
|
5322
5638
|
return window.innerWidth < mobileBreakpointPx;
|
|
5323
5639
|
});
|
|
5324
|
-
const [mobileSidebarOpen, setMobileSidebarOpen] = (0,
|
|
5325
|
-
(0,
|
|
5640
|
+
const [mobileSidebarOpen, setMobileSidebarOpen] = (0, import_react47.useState)(false);
|
|
5641
|
+
(0, import_react47.useEffect)(() => {
|
|
5326
5642
|
if (typeof window === "undefined") return;
|
|
5327
5643
|
const onResize = () => setIsMobile(window.innerWidth < mobileBreakpointPx);
|
|
5328
5644
|
onResize();
|
|
5329
5645
|
window.addEventListener("resize", onResize);
|
|
5330
5646
|
return () => window.removeEventListener("resize", onResize);
|
|
5331
5647
|
}, [mobileBreakpointPx]);
|
|
5332
|
-
(0,
|
|
5648
|
+
(0, import_react47.useEffect)(() => {
|
|
5333
5649
|
if (!isMobile) setMobileSidebarOpen(false);
|
|
5334
5650
|
}, [isMobile]);
|
|
5335
|
-
(0,
|
|
5651
|
+
(0, import_react47.useEffect)(() => {
|
|
5336
5652
|
if (!mobileSidebarOpen) return;
|
|
5337
5653
|
const onKeyDown = (e) => {
|
|
5338
5654
|
if (e.key === "Escape") setMobileSidebarOpen(false);
|
|
@@ -5356,21 +5672,21 @@ var TimbalStudioShell = ({
|
|
|
5356
5672
|
layoutDirection
|
|
5357
5673
|
);
|
|
5358
5674
|
const desktopInsetPx = widthCollapsed ? SIDEBAR_INSET_PX_COLLAPSED : SIDEBAR_INSET_PX_EXPANDED;
|
|
5359
|
-
const onCollapsedChange = (0,
|
|
5675
|
+
const onCollapsedChange = (0, import_react47.useCallback)(
|
|
5360
5676
|
(next) => {
|
|
5361
5677
|
setCollapsed(next);
|
|
5362
5678
|
writePersistedCollapsed2(persistKey, next);
|
|
5363
5679
|
},
|
|
5364
5680
|
[persistKey]
|
|
5365
5681
|
);
|
|
5366
|
-
const handleSelectWorkforce = (0,
|
|
5682
|
+
const handleSelectWorkforce = (0, import_react47.useCallback)(
|
|
5367
5683
|
(id) => {
|
|
5368
5684
|
if (!workforceId) setInternalSelected(id);
|
|
5369
5685
|
if (isMobile) setMobileSidebarOpen(false);
|
|
5370
5686
|
},
|
|
5371
5687
|
[workforceId, isMobile]
|
|
5372
5688
|
);
|
|
5373
|
-
const sidebarContext = (0,
|
|
5689
|
+
const sidebarContext = (0, import_react47.useMemo)(
|
|
5374
5690
|
() => ({
|
|
5375
5691
|
collapsed: effectiveCollapsed,
|
|
5376
5692
|
isMobile,
|
|
@@ -5379,12 +5695,12 @@ var TimbalStudioShell = ({
|
|
|
5379
5695
|
}),
|
|
5380
5696
|
[effectiveCollapsed, isMobile, isCollapsedRail, iconOnlyLayout]
|
|
5381
5697
|
);
|
|
5382
|
-
const resolvedComponents = (0,
|
|
5698
|
+
const resolvedComponents = (0, import_react47.useMemo)(() => {
|
|
5383
5699
|
const next = { Welcome: StudioWelcome, ...components };
|
|
5384
5700
|
next.Composer = makeComposerWithPortal(components?.Composer);
|
|
5385
5701
|
return next;
|
|
5386
5702
|
}, [components]);
|
|
5387
|
-
return /* @__PURE__ */ (0,
|
|
5703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(StudioSidebarContext.Provider, { value: sidebarContext, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
5388
5704
|
"div",
|
|
5389
5705
|
{
|
|
5390
5706
|
className: cn(
|
|
@@ -5393,14 +5709,14 @@ var TimbalStudioShell = ({
|
|
|
5393
5709
|
),
|
|
5394
5710
|
style: studioChromeShellStyle,
|
|
5395
5711
|
children: [
|
|
5396
|
-
/* @__PURE__ */ (0,
|
|
5712
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
5397
5713
|
"div",
|
|
5398
5714
|
{
|
|
5399
5715
|
className: "pointer-events-none absolute inset-0 z-0 bg-background",
|
|
5400
5716
|
"aria-hidden": true
|
|
5401
5717
|
}
|
|
5402
5718
|
),
|
|
5403
|
-
/* @__PURE__ */ (0,
|
|
5719
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
5404
5720
|
"div",
|
|
5405
5721
|
{
|
|
5406
5722
|
className: cn(
|
|
@@ -5410,14 +5726,14 @@ var TimbalStudioShell = ({
|
|
|
5410
5726
|
"aria-hidden": true
|
|
5411
5727
|
}
|
|
5412
5728
|
),
|
|
5413
|
-
/* @__PURE__ */ (0,
|
|
5729
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
5414
5730
|
StudioSidebarBackdrop,
|
|
5415
5731
|
{
|
|
5416
5732
|
open: isMobile && mobileSidebarOpen,
|
|
5417
5733
|
onClose: () => setMobileSidebarOpen(false)
|
|
5418
5734
|
}
|
|
5419
5735
|
),
|
|
5420
|
-
/* @__PURE__ */ (0,
|
|
5736
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
5421
5737
|
StudioSidebarPanel,
|
|
5422
5738
|
{
|
|
5423
5739
|
workforces,
|
|
@@ -5436,8 +5752,8 @@ var TimbalStudioShell = ({
|
|
|
5436
5752
|
emptyCaption: sidebarEmptyCaption
|
|
5437
5753
|
}
|
|
5438
5754
|
),
|
|
5439
|
-
/* @__PURE__ */ (0,
|
|
5440
|
-
|
|
5755
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
5756
|
+
import_react48.motion.header,
|
|
5441
5757
|
{
|
|
5442
5758
|
className: cn(
|
|
5443
5759
|
"absolute top-0 right-0 z-40 flex items-start justify-between gap-2",
|
|
@@ -5448,7 +5764,7 @@ var TimbalStudioShell = ({
|
|
|
5448
5764
|
animate: { left: isMobile ? 0 : desktopInsetPx },
|
|
5449
5765
|
transition: layoutTransition,
|
|
5450
5766
|
children: [
|
|
5451
|
-
/* @__PURE__ */ (0,
|
|
5767
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
5452
5768
|
"div",
|
|
5453
5769
|
{
|
|
5454
5770
|
className: cn(
|
|
@@ -5456,7 +5772,7 @@ var TimbalStudioShell = ({
|
|
|
5456
5772
|
studioTopbarPillHeightClass
|
|
5457
5773
|
),
|
|
5458
5774
|
children: [
|
|
5459
|
-
isMobile && !mobileSidebarOpen ? /* @__PURE__ */ (0,
|
|
5775
|
+
isMobile && !mobileSidebarOpen ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
5460
5776
|
TimbalV2Button,
|
|
5461
5777
|
{
|
|
5462
5778
|
variant: "secondary",
|
|
@@ -5466,19 +5782,19 @@ var TimbalStudioShell = ({
|
|
|
5466
5782
|
onClick: () => setMobileSidebarOpen(true),
|
|
5467
5783
|
"aria-label": "Open menu",
|
|
5468
5784
|
"aria-expanded": false,
|
|
5469
|
-
children: /* @__PURE__ */ (0,
|
|
5785
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react13.Menu, { className: "size-4" })
|
|
5470
5786
|
}
|
|
5471
5787
|
) : null,
|
|
5472
5788
|
headerStart
|
|
5473
5789
|
]
|
|
5474
5790
|
}
|
|
5475
5791
|
),
|
|
5476
|
-
headerActions ? /* @__PURE__ */ (0,
|
|
5792
|
+
headerActions ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "flex shrink-0 items-center gap-1", children: headerActions }) : null
|
|
5477
5793
|
]
|
|
5478
5794
|
}
|
|
5479
5795
|
),
|
|
5480
|
-
/* @__PURE__ */ (0,
|
|
5481
|
-
|
|
5796
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
5797
|
+
import_react48.motion.main,
|
|
5482
5798
|
{
|
|
5483
5799
|
className: cn(
|
|
5484
5800
|
"relative z-10 flex h-full min-w-0 flex-col",
|
|
@@ -5488,7 +5804,7 @@ var TimbalStudioShell = ({
|
|
|
5488
5804
|
initial: false,
|
|
5489
5805
|
animate: { paddingLeft: isMobile ? 12 : desktopInsetPx },
|
|
5490
5806
|
transition: layoutTransition,
|
|
5491
|
-
children: activeWorkforceId ? /* @__PURE__ */ (0,
|
|
5807
|
+
children: activeWorkforceId ? /* @__PURE__ */ (0, import_react49.createElement)(
|
|
5492
5808
|
TimbalChat,
|
|
5493
5809
|
{
|
|
5494
5810
|
...chatProps,
|
|
@@ -5507,9 +5823,29 @@ var TimbalStudioShell = ({
|
|
|
5507
5823
|
};
|
|
5508
5824
|
|
|
5509
5825
|
// src/studio/sidebar/mode-toggle.tsx
|
|
5510
|
-
var
|
|
5826
|
+
var import_react50 = require("react");
|
|
5511
5827
|
var import_lucide_react14 = require("lucide-react");
|
|
5512
|
-
var
|
|
5828
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
5829
|
+
function readStoredTheme() {
|
|
5830
|
+
if (typeof window === "undefined") return null;
|
|
5831
|
+
try {
|
|
5832
|
+
const value = window.localStorage.getItem(STORAGE_KEYS.theme);
|
|
5833
|
+
return value === "dark" || value === "light" ? value : null;
|
|
5834
|
+
} catch {
|
|
5835
|
+
return null;
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
function writeStoredTheme(theme) {
|
|
5839
|
+
if (typeof window === "undefined") return;
|
|
5840
|
+
try {
|
|
5841
|
+
window.localStorage.setItem(STORAGE_KEYS.theme, theme);
|
|
5842
|
+
} catch {
|
|
5843
|
+
}
|
|
5844
|
+
}
|
|
5845
|
+
function applyDarkClass(isDark) {
|
|
5846
|
+
if (typeof document === "undefined") return;
|
|
5847
|
+
document.documentElement.classList.toggle("dark", isDark);
|
|
5848
|
+
}
|
|
5513
5849
|
var ModeToggle = ({
|
|
5514
5850
|
theme,
|
|
5515
5851
|
setTheme,
|
|
@@ -5517,24 +5853,31 @@ var ModeToggle = ({
|
|
|
5517
5853
|
label = "Toggle theme"
|
|
5518
5854
|
}) => {
|
|
5519
5855
|
const isControlled = theme !== void 0;
|
|
5520
|
-
const [internalIsDark, setInternalIsDark] = (0,
|
|
5521
|
-
(0,
|
|
5856
|
+
const [internalIsDark, setInternalIsDark] = (0, import_react50.useState)(false);
|
|
5857
|
+
(0, import_react50.useLayoutEffect)(() => {
|
|
5522
5858
|
if (isControlled) return;
|
|
5523
|
-
|
|
5859
|
+
const stored = readStoredTheme();
|
|
5860
|
+
if (stored) {
|
|
5861
|
+
const isDark2 = stored === "dark";
|
|
5862
|
+
applyDarkClass(isDark2);
|
|
5863
|
+
setInternalIsDark(isDark2);
|
|
5864
|
+
return;
|
|
5865
|
+
}
|
|
5524
5866
|
setInternalIsDark(document.documentElement.classList.contains("dark"));
|
|
5525
5867
|
}, [isControlled]);
|
|
5526
5868
|
const isDark = isControlled ? theme === "dark" : internalIsDark;
|
|
5527
|
-
const onClick = (0,
|
|
5869
|
+
const onClick = (0, import_react50.useCallback)(() => {
|
|
5528
5870
|
const next = isDark ? "light" : "dark";
|
|
5529
5871
|
if (setTheme) {
|
|
5530
5872
|
setTheme(next);
|
|
5531
5873
|
return;
|
|
5532
5874
|
}
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5875
|
+
const isDarkNext = next === "dark";
|
|
5876
|
+
applyDarkClass(isDarkNext);
|
|
5877
|
+
writeStoredTheme(isDarkNext ? "dark" : "light");
|
|
5878
|
+
setInternalIsDark(isDarkNext);
|
|
5536
5879
|
}, [isDark, setTheme]);
|
|
5537
|
-
return /* @__PURE__ */ (0,
|
|
5880
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
5538
5881
|
TimbalV2Button,
|
|
5539
5882
|
{
|
|
5540
5883
|
variant: "secondary",
|
|
@@ -5550,20 +5893,20 @@ var ModeToggle = ({
|
|
|
5550
5893
|
"aria-label": label,
|
|
5551
5894
|
title: label,
|
|
5552
5895
|
children: [
|
|
5553
|
-
/* @__PURE__ */ (0,
|
|
5554
|
-
/* @__PURE__ */ (0,
|
|
5555
|
-
/* @__PURE__ */ (0,
|
|
5896
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_lucide_react14.Sun, { className: "size-3.5 scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90" }),
|
|
5897
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_lucide_react14.Moon, { className: "absolute size-3.5 scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0" }),
|
|
5898
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "sr-only", children: label })
|
|
5556
5899
|
]
|
|
5557
5900
|
}
|
|
5558
5901
|
);
|
|
5559
5902
|
};
|
|
5560
5903
|
|
|
5561
5904
|
// src/studio/mode-switch.tsx
|
|
5562
|
-
var
|
|
5905
|
+
var import_react53 = require("react");
|
|
5563
5906
|
|
|
5564
5907
|
// src/ui/pill-segmented-tabs.tsx
|
|
5565
|
-
var
|
|
5566
|
-
var
|
|
5908
|
+
var import_react51 = require("react");
|
|
5909
|
+
var import_react52 = require("motion/react");
|
|
5567
5910
|
|
|
5568
5911
|
// src/design/pill-segmented-classes.ts
|
|
5569
5912
|
var pillSegmentedTrackBase = "inline-flex w-fit max-w-max shrink-0 self-start items-center rounded-full";
|
|
@@ -5596,7 +5939,7 @@ var pillSegmentedActiveIndicatorClass = cn(
|
|
|
5596
5939
|
);
|
|
5597
5940
|
|
|
5598
5941
|
// src/ui/pill-segmented-tabs.tsx
|
|
5599
|
-
var
|
|
5942
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
5600
5943
|
var PillTab = ({
|
|
5601
5944
|
tabKey,
|
|
5602
5945
|
label,
|
|
@@ -5607,10 +5950,10 @@ var PillTab = ({
|
|
|
5607
5950
|
segmentClassName,
|
|
5608
5951
|
animateIndicator
|
|
5609
5952
|
}) => {
|
|
5610
|
-
const handlePress = (0,
|
|
5953
|
+
const handlePress = (0, import_react51.useCallback)(() => {
|
|
5611
5954
|
if (!disabled) onSelect(tabKey);
|
|
5612
5955
|
}, [disabled, onSelect, tabKey]);
|
|
5613
|
-
return /* @__PURE__ */ (0,
|
|
5956
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
5614
5957
|
"button",
|
|
5615
5958
|
{
|
|
5616
5959
|
type: "button",
|
|
@@ -5623,15 +5966,15 @@ var PillTab = ({
|
|
|
5623
5966
|
!disabled && (isActive ? "text-foreground" : "text-muted-foreground hover:text-foreground")
|
|
5624
5967
|
),
|
|
5625
5968
|
children: [
|
|
5626
|
-
isActive && animateIndicator ? /* @__PURE__ */ (0,
|
|
5627
|
-
|
|
5969
|
+
isActive && animateIndicator ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
5970
|
+
import_react52.motion.div,
|
|
5628
5971
|
{
|
|
5629
5972
|
layoutId,
|
|
5630
5973
|
className: pillSegmentedActiveIndicatorClass,
|
|
5631
5974
|
transition: { type: "spring", duration: 0.3, bounce: 0.15 }
|
|
5632
5975
|
}
|
|
5633
|
-
) : isActive ? /* @__PURE__ */ (0,
|
|
5634
|
-
/* @__PURE__ */ (0,
|
|
5976
|
+
) : isActive ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: pillSegmentedActiveIndicatorClass, "aria-hidden": true }) : null,
|
|
5977
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "relative z-10 whitespace-nowrap", children: label })
|
|
5635
5978
|
]
|
|
5636
5979
|
}
|
|
5637
5980
|
);
|
|
@@ -5645,13 +5988,13 @@ var PillSegmentedTabs = ({
|
|
|
5645
5988
|
layoutId: layoutIdProp,
|
|
5646
5989
|
"aria-label": ariaLabel
|
|
5647
5990
|
}) => {
|
|
5648
|
-
const reactId = (0,
|
|
5991
|
+
const reactId = (0, import_react51.useId)();
|
|
5649
5992
|
const layoutId = layoutIdProp ?? `pill-segmented-${reactId.replace(/:/g, "")}`;
|
|
5650
|
-
const reducedMotion = (0,
|
|
5993
|
+
const reducedMotion = (0, import_react52.useReducedMotion)();
|
|
5651
5994
|
const isFlush = trackVariant === "flush";
|
|
5652
5995
|
const trackClass = isFlush ? pillSegmentedTrackFlushClass : pillSegmentedTrackClass;
|
|
5653
5996
|
const segmentClassName = isFlush ? pillSegmentedFlushSegmentClass : pillSegmentedSegmentClass;
|
|
5654
|
-
return /* @__PURE__ */ (0,
|
|
5997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { role: "group", "aria-label": ariaLabel, className: cn(trackClass, className), children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
5655
5998
|
PillTab,
|
|
5656
5999
|
{
|
|
5657
6000
|
tabKey: tab.key,
|
|
@@ -5666,15 +6009,15 @@ var PillSegmentedTabs = ({
|
|
|
5666
6009
|
tab.key
|
|
5667
6010
|
)) });
|
|
5668
6011
|
};
|
|
5669
|
-
var MemoPillSegmentedTabs = (0,
|
|
6012
|
+
var MemoPillSegmentedTabs = (0, import_react51.memo)(PillSegmentedTabs);
|
|
5670
6013
|
|
|
5671
6014
|
// src/studio/mode-switch.tsx
|
|
5672
|
-
var
|
|
6015
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
5673
6016
|
var STUDIO_NAV_MODE = {
|
|
5674
6017
|
BUILD: "build",
|
|
5675
6018
|
OPERATE: "operate"
|
|
5676
6019
|
};
|
|
5677
|
-
var StudioModeSwitch = (0,
|
|
6020
|
+
var StudioModeSwitch = (0, import_react53.memo)(
|
|
5678
6021
|
function StudioModeSwitch2({
|
|
5679
6022
|
value,
|
|
5680
6023
|
onChange,
|
|
@@ -5683,14 +6026,14 @@ var StudioModeSwitch = (0, import_react51.memo)(
|
|
|
5683
6026
|
manageLabel = "Manage",
|
|
5684
6027
|
"aria-label": ariaLabel = "Studio mode"
|
|
5685
6028
|
}) {
|
|
5686
|
-
const tabs = (0,
|
|
6029
|
+
const tabs = (0, import_react53.useMemo)(
|
|
5687
6030
|
() => [
|
|
5688
6031
|
{ key: STUDIO_NAV_MODE.BUILD, label: buildLabel },
|
|
5689
6032
|
{ key: STUDIO_NAV_MODE.OPERATE, label: manageLabel }
|
|
5690
6033
|
],
|
|
5691
6034
|
[buildLabel, manageLabel]
|
|
5692
6035
|
);
|
|
5693
|
-
const handleChange = (0,
|
|
6036
|
+
const handleChange = (0, import_react53.useCallback)(
|
|
5694
6037
|
(key) => {
|
|
5695
6038
|
if (key === STUDIO_NAV_MODE.BUILD || key === STUDIO_NAV_MODE.OPERATE) {
|
|
5696
6039
|
onChange(key);
|
|
@@ -5698,14 +6041,14 @@ var StudioModeSwitch = (0, import_react51.memo)(
|
|
|
5698
6041
|
},
|
|
5699
6042
|
[onChange]
|
|
5700
6043
|
);
|
|
5701
|
-
return /* @__PURE__ */ (0,
|
|
6044
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
5702
6045
|
"div",
|
|
5703
6046
|
{
|
|
5704
6047
|
"data-tour": "studio-mode-switch",
|
|
5705
6048
|
"data-studio-chrome-align": "mode-switch",
|
|
5706
6049
|
id: "studio-chrome-mode-switch",
|
|
5707
6050
|
className,
|
|
5708
|
-
children: /* @__PURE__ */ (0,
|
|
6051
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
5709
6052
|
PillSegmentedTabs,
|
|
5710
6053
|
{
|
|
5711
6054
|
value,
|