@apteva/apteva-kit 0.1.109 → 0.1.111
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/dist/index.js +349 -131
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +283 -65
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1440,6 +1440,217 @@ function Table({ widget, onAction }) {
|
|
|
1440
1440
|
// src/components/Widgets/widget-library/Form.tsx
|
|
1441
1441
|
|
|
1442
1442
|
|
|
1443
|
+
function CustomSelect({
|
|
1444
|
+
name,
|
|
1445
|
+
value,
|
|
1446
|
+
options,
|
|
1447
|
+
placeholder,
|
|
1448
|
+
required,
|
|
1449
|
+
onChange
|
|
1450
|
+
}) {
|
|
1451
|
+
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
1452
|
+
const ref = _react.useRef.call(void 0, null);
|
|
1453
|
+
const selected = _optionalChain([options, 'optionalAccess', _18 => _18.find, 'call', _19 => _19((o) => o.value === value)]);
|
|
1454
|
+
_react.useEffect.call(void 0, () => {
|
|
1455
|
+
if (!open) return;
|
|
1456
|
+
const handler = (e) => {
|
|
1457
|
+
if (ref.current && !ref.current.contains(e.target)) setOpen(false);
|
|
1458
|
+
};
|
|
1459
|
+
document.addEventListener("mousedown", handler);
|
|
1460
|
+
return () => document.removeEventListener("mousedown", handler);
|
|
1461
|
+
}, [open]);
|
|
1462
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref, className: "apteva-select relative", children: [
|
|
1463
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1464
|
+
"select",
|
|
1465
|
+
{
|
|
1466
|
+
name,
|
|
1467
|
+
value,
|
|
1468
|
+
required,
|
|
1469
|
+
onChange: () => {
|
|
1470
|
+
},
|
|
1471
|
+
tabIndex: -1,
|
|
1472
|
+
className: "absolute inset-0 opacity-0 pointer-events-none",
|
|
1473
|
+
"aria-hidden": true,
|
|
1474
|
+
children: [
|
|
1475
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: "" }),
|
|
1476
|
+
_optionalChain([options, 'optionalAccess', _20 => _20.map, 'call', _21 => _21((o) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: o.value, children: o.label }, o.value))])
|
|
1477
|
+
]
|
|
1478
|
+
}
|
|
1479
|
+
),
|
|
1480
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1481
|
+
"button",
|
|
1482
|
+
{
|
|
1483
|
+
type: "button",
|
|
1484
|
+
onClick: () => setOpen(!open),
|
|
1485
|
+
className: "apteva-select-trigger w-full flex items-center justify-between px-3 py-2 rounded-lg border transition-colors text-left",
|
|
1486
|
+
children: [
|
|
1487
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: selected ? "apteva-select-value" : "apteva-select-placeholder", children: selected ? selected.label : placeholder || "Select..." }),
|
|
1488
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1489
|
+
"svg",
|
|
1490
|
+
{
|
|
1491
|
+
className: `apteva-select-chevron w-4 h-4 flex-shrink-0 transition-transform ${open ? "rotate-180" : ""}`,
|
|
1492
|
+
fill: "none",
|
|
1493
|
+
stroke: "currentColor",
|
|
1494
|
+
viewBox: "0 0 24 24",
|
|
1495
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" })
|
|
1496
|
+
}
|
|
1497
|
+
)
|
|
1498
|
+
]
|
|
1499
|
+
}
|
|
1500
|
+
),
|
|
1501
|
+
open && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-select-dropdown absolute z-50 w-full mt-1 rounded-lg border shadow-lg overflow-hidden", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "max-h-48 overflow-y-auto py-1", children: [
|
|
1502
|
+
_optionalChain([options, 'optionalAccess', _22 => _22.map, 'call', _23 => _23((opt) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1503
|
+
"button",
|
|
1504
|
+
{
|
|
1505
|
+
type: "button",
|
|
1506
|
+
onClick: () => {
|
|
1507
|
+
onChange(opt.value);
|
|
1508
|
+
setOpen(false);
|
|
1509
|
+
},
|
|
1510
|
+
className: `apteva-select-option w-full text-left px-3 py-2 text-sm transition-colors ${opt.value === value ? "apteva-select-option-active" : ""}`,
|
|
1511
|
+
children: opt.label
|
|
1512
|
+
},
|
|
1513
|
+
opt.value
|
|
1514
|
+
))]),
|
|
1515
|
+
(!options || options.length === 0) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "px-3 py-2 text-sm apteva-select-placeholder", children: "No options" })
|
|
1516
|
+
] }) })
|
|
1517
|
+
] });
|
|
1518
|
+
}
|
|
1519
|
+
function CustomDatePicker({
|
|
1520
|
+
name,
|
|
1521
|
+
value,
|
|
1522
|
+
placeholder,
|
|
1523
|
+
required,
|
|
1524
|
+
onChange
|
|
1525
|
+
}) {
|
|
1526
|
+
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
1527
|
+
const ref = _react.useRef.call(void 0, null);
|
|
1528
|
+
const parseDate = (v) => {
|
|
1529
|
+
if (v) {
|
|
1530
|
+
const [y, m, d] = v.split("-").map(Number);
|
|
1531
|
+
return { year: y, month: m - 1, day: d };
|
|
1532
|
+
}
|
|
1533
|
+
const now = /* @__PURE__ */ new Date();
|
|
1534
|
+
return { year: now.getFullYear(), month: now.getMonth(), day: 0 };
|
|
1535
|
+
};
|
|
1536
|
+
const parsed = parseDate(value);
|
|
1537
|
+
const [viewYear, setViewYear] = _react.useState.call(void 0, parsed.year);
|
|
1538
|
+
const [viewMonth, setViewMonth] = _react.useState.call(void 0, parsed.month);
|
|
1539
|
+
_react.useEffect.call(void 0, () => {
|
|
1540
|
+
if (!open) return;
|
|
1541
|
+
const handler = (e) => {
|
|
1542
|
+
if (ref.current && !ref.current.contains(e.target)) setOpen(false);
|
|
1543
|
+
};
|
|
1544
|
+
document.addEventListener("mousedown", handler);
|
|
1545
|
+
return () => document.removeEventListener("mousedown", handler);
|
|
1546
|
+
}, [open]);
|
|
1547
|
+
_react.useEffect.call(void 0, () => {
|
|
1548
|
+
if (value) {
|
|
1549
|
+
const p = parseDate(value);
|
|
1550
|
+
setViewYear(p.year);
|
|
1551
|
+
setViewMonth(p.month);
|
|
1552
|
+
}
|
|
1553
|
+
}, [value]);
|
|
1554
|
+
const daysInMonth = new Date(viewYear, viewMonth + 1, 0).getDate();
|
|
1555
|
+
const firstDayOfWeek = new Date(viewYear, viewMonth, 1).getDay();
|
|
1556
|
+
const startOffset = (firstDayOfWeek + 6) % 7;
|
|
1557
|
+
const prevMonth = () => {
|
|
1558
|
+
if (viewMonth === 0) {
|
|
1559
|
+
setViewMonth(11);
|
|
1560
|
+
setViewYear(viewYear - 1);
|
|
1561
|
+
} else setViewMonth(viewMonth - 1);
|
|
1562
|
+
};
|
|
1563
|
+
const nextMonth = () => {
|
|
1564
|
+
if (viewMonth === 11) {
|
|
1565
|
+
setViewMonth(0);
|
|
1566
|
+
setViewYear(viewYear + 1);
|
|
1567
|
+
} else setViewMonth(viewMonth + 1);
|
|
1568
|
+
};
|
|
1569
|
+
const selectDay = (day) => {
|
|
1570
|
+
const m = String(viewMonth + 1).padStart(2, "0");
|
|
1571
|
+
const d = String(day).padStart(2, "0");
|
|
1572
|
+
onChange(`${viewYear}-${m}-${d}`);
|
|
1573
|
+
setOpen(false);
|
|
1574
|
+
};
|
|
1575
|
+
const formatDisplay = (v) => {
|
|
1576
|
+
if (!v) return "";
|
|
1577
|
+
const [y, m, d] = v.split("-");
|
|
1578
|
+
return `${d}/${m}/${y}`;
|
|
1579
|
+
};
|
|
1580
|
+
const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
1581
|
+
const dayLabels = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];
|
|
1582
|
+
const isSelected = (day) => {
|
|
1583
|
+
if (!value) return false;
|
|
1584
|
+
const p = parseDate(value);
|
|
1585
|
+
return p.year === viewYear && p.month === viewMonth && p.day === day;
|
|
1586
|
+
};
|
|
1587
|
+
const isToday = (day) => {
|
|
1588
|
+
const now = /* @__PURE__ */ new Date();
|
|
1589
|
+
return now.getFullYear() === viewYear && now.getMonth() === viewMonth && now.getDate() === day;
|
|
1590
|
+
};
|
|
1591
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref, className: "apteva-datepicker relative", children: [
|
|
1592
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1593
|
+
"input",
|
|
1594
|
+
{
|
|
1595
|
+
type: "text",
|
|
1596
|
+
name,
|
|
1597
|
+
value,
|
|
1598
|
+
required,
|
|
1599
|
+
onChange: () => {
|
|
1600
|
+
},
|
|
1601
|
+
tabIndex: -1,
|
|
1602
|
+
className: "absolute inset-0 opacity-0 pointer-events-none",
|
|
1603
|
+
"aria-hidden": true
|
|
1604
|
+
}
|
|
1605
|
+
),
|
|
1606
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1607
|
+
"button",
|
|
1608
|
+
{
|
|
1609
|
+
type: "button",
|
|
1610
|
+
onClick: () => setOpen(!open),
|
|
1611
|
+
className: "apteva-datepicker-trigger w-full flex items-center justify-between px-3 py-2 rounded-lg border transition-colors text-left",
|
|
1612
|
+
children: [
|
|
1613
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: value ? "apteva-datepicker-value" : "apteva-select-placeholder", children: value ? formatDisplay(value) : placeholder || "Select date..." }),
|
|
1614
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "apteva-select-chevron w-4 h-4 flex-shrink-0", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" }) })
|
|
1615
|
+
]
|
|
1616
|
+
}
|
|
1617
|
+
),
|
|
1618
|
+
open && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-datepicker-dropdown absolute z-50 mt-1 rounded-lg border shadow-lg overflow-hidden", children: [
|
|
1619
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-datepicker-header flex items-center justify-between px-3 py-2", children: [
|
|
1620
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", onClick: prevMonth, className: "apteva-datepicker-nav p-1 rounded transition-colors", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }) }),
|
|
1621
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "apteva-datepicker-title text-sm font-semibold", children: [
|
|
1622
|
+
monthNames[viewMonth],
|
|
1623
|
+
" ",
|
|
1624
|
+
viewYear
|
|
1625
|
+
] }),
|
|
1626
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", onClick: nextMonth, className: "apteva-datepicker-nav p-1 rounded transition-colors", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) }) })
|
|
1627
|
+
] }),
|
|
1628
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "grid grid-cols-7 px-2", children: dayLabels.map((d) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-datepicker-daylabel text-center text-xs font-medium py-1", children: d }, d)) }),
|
|
1629
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-7 px-2 pb-2", children: [
|
|
1630
|
+
Array.from({ length: startOffset }).map((_, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {}, `empty-${i}`)),
|
|
1631
|
+
Array.from({ length: daysInMonth }).map((_, i) => {
|
|
1632
|
+
const day = i + 1;
|
|
1633
|
+
const sel = isSelected(day);
|
|
1634
|
+
const today = isToday(day);
|
|
1635
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1636
|
+
"button",
|
|
1637
|
+
{
|
|
1638
|
+
type: "button",
|
|
1639
|
+
onClick: () => selectDay(day),
|
|
1640
|
+
className: [
|
|
1641
|
+
"apteva-datepicker-day text-center text-sm py-1 rounded transition-colors",
|
|
1642
|
+
sel ? "apteva-datepicker-day-selected" : "",
|
|
1643
|
+
today && !sel ? "apteva-datepicker-day-today" : ""
|
|
1644
|
+
].join(" "),
|
|
1645
|
+
children: day
|
|
1646
|
+
},
|
|
1647
|
+
day
|
|
1648
|
+
);
|
|
1649
|
+
})
|
|
1650
|
+
] })
|
|
1651
|
+
] })
|
|
1652
|
+
] });
|
|
1653
|
+
}
|
|
1443
1654
|
function Form({ widget, onAction }) {
|
|
1444
1655
|
const { title, fields } = widget.props;
|
|
1445
1656
|
const fileInputRefs = _react.useRef.call(void 0, {});
|
|
@@ -1454,12 +1665,12 @@ function Form({ widget, onAction }) {
|
|
|
1454
1665
|
});
|
|
1455
1666
|
return initial;
|
|
1456
1667
|
});
|
|
1457
|
-
const handleChange = (name, value) => {
|
|
1668
|
+
const handleChange = _react.useCallback.call(void 0, (name, value) => {
|
|
1458
1669
|
setFormData((prev) => ({ ...prev, [name]: value }));
|
|
1459
|
-
};
|
|
1670
|
+
}, []);
|
|
1460
1671
|
const handleSubmit = (e) => {
|
|
1461
1672
|
e.preventDefault();
|
|
1462
|
-
if (_optionalChain([widget, 'access',
|
|
1673
|
+
if (_optionalChain([widget, 'access', _24 => _24.actions, 'optionalAccess', _25 => _25[0]]) && onAction) {
|
|
1463
1674
|
onAction({
|
|
1464
1675
|
type: widget.actions[0].type,
|
|
1465
1676
|
payload: { ...widget.actions[0].payload, formData },
|
|
@@ -1469,12 +1680,11 @@ function Form({ widget, onAction }) {
|
|
|
1469
1680
|
}
|
|
1470
1681
|
};
|
|
1471
1682
|
const renderField = (field) => {
|
|
1472
|
-
const baseInputClass = "w-full px-3 py-2 rounded-lg border transition-colors
|
|
1683
|
+
const baseInputClass = "apteva-input w-full px-3 py-2 rounded-lg border transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent";
|
|
1473
1684
|
switch (field.type) {
|
|
1474
1685
|
case "text":
|
|
1475
1686
|
case "password":
|
|
1476
1687
|
case "number":
|
|
1477
|
-
case "date":
|
|
1478
1688
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1479
1689
|
"input",
|
|
1480
1690
|
{
|
|
@@ -1487,6 +1697,17 @@ function Form({ widget, onAction }) {
|
|
|
1487
1697
|
className: baseInputClass
|
|
1488
1698
|
}
|
|
1489
1699
|
);
|
|
1700
|
+
case "date":
|
|
1701
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1702
|
+
CustomDatePicker,
|
|
1703
|
+
{
|
|
1704
|
+
name: field.name,
|
|
1705
|
+
value: formData[field.name] || "",
|
|
1706
|
+
placeholder: field.placeholder,
|
|
1707
|
+
required: field.required,
|
|
1708
|
+
onChange: (v) => handleChange(field.name, v)
|
|
1709
|
+
}
|
|
1710
|
+
);
|
|
1490
1711
|
case "textarea":
|
|
1491
1712
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1492
1713
|
"textarea",
|
|
@@ -1501,22 +1722,19 @@ function Form({ widget, onAction }) {
|
|
|
1501
1722
|
}
|
|
1502
1723
|
);
|
|
1503
1724
|
case "select":
|
|
1504
|
-
return /* @__PURE__ */ _jsxruntime.
|
|
1505
|
-
|
|
1725
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1726
|
+
CustomSelect,
|
|
1506
1727
|
{
|
|
1507
1728
|
name: field.name,
|
|
1508
1729
|
value: formData[field.name] || "",
|
|
1509
|
-
|
|
1730
|
+
options: field.options,
|
|
1731
|
+
placeholder: field.placeholder,
|
|
1510
1732
|
required: field.required,
|
|
1511
|
-
|
|
1512
|
-
children: [
|
|
1513
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: "", children: field.placeholder || "Select..." }),
|
|
1514
|
-
_optionalChain([field, 'access', _20 => _20.options, 'optionalAccess', _21 => _21.map, 'call', _22 => _22((opt) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: opt.value, children: opt.label }, opt.value))])
|
|
1515
|
-
]
|
|
1733
|
+
onChange: (v) => handleChange(field.name, v)
|
|
1516
1734
|
}
|
|
1517
1735
|
);
|
|
1518
1736
|
case "checkbox":
|
|
1519
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "flex items-center gap-2 cursor-pointer", children: [
|
|
1737
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "apteva-checkbox flex items-center gap-2 cursor-pointer", children: [
|
|
1520
1738
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1521
1739
|
"input",
|
|
1522
1740
|
{
|
|
@@ -1524,10 +1742,10 @@ function Form({ widget, onAction }) {
|
|
|
1524
1742
|
name: field.name,
|
|
1525
1743
|
checked: formData[field.name] || false,
|
|
1526
1744
|
onChange: (e) => handleChange(field.name, e.target.checked),
|
|
1527
|
-
className: "w-4 h-4 rounded
|
|
1745
|
+
className: "w-4 h-4 rounded"
|
|
1528
1746
|
}
|
|
1529
1747
|
),
|
|
1530
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", {
|
|
1748
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: field.label })
|
|
1531
1749
|
] });
|
|
1532
1750
|
case "file": {
|
|
1533
1751
|
const files = formData[field.name] || [];
|
|
@@ -1560,19 +1778,19 @@ function Form({ widget, onAction }) {
|
|
|
1560
1778
|
"button",
|
|
1561
1779
|
{
|
|
1562
1780
|
type: "button",
|
|
1563
|
-
onClick: () => _optionalChain([fileInputRefs, 'access',
|
|
1564
|
-
className: "apteva-file-drop w-full px-3 py-3 rounded-lg border-2 border-dashed transition-colors cursor-pointer
|
|
1781
|
+
onClick: () => _optionalChain([fileInputRefs, 'access', _26 => _26.current, 'access', _27 => _27[field.name], 'optionalAccess', _28 => _28.click, 'call', _29 => _29()]),
|
|
1782
|
+
className: "apteva-file-drop w-full px-3 py-3 rounded-lg border-2 border-dashed transition-colors cursor-pointer !text-sm",
|
|
1565
1783
|
children: field.placeholder || "Click to add files"
|
|
1566
1784
|
}
|
|
1567
1785
|
),
|
|
1568
1786
|
files.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "space-y-1", children: files.map((file, idx) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1569
1787
|
"li",
|
|
1570
1788
|
{
|
|
1571
|
-
className: "apteva-file-item-row flex items-center justify-between px-2 py-1.5 rounded-lg
|
|
1789
|
+
className: "apteva-file-item-row flex items-center justify-between px-2 py-1.5 rounded-lg !text-sm",
|
|
1572
1790
|
children: [
|
|
1573
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "
|
|
1791
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "truncate mr-2", children: [
|
|
1574
1792
|
file.name,
|
|
1575
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "
|
|
1793
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "ml-1", style: { opacity: 0.6 }, children: [
|
|
1576
1794
|
"(",
|
|
1577
1795
|
(file.size / 1024).toFixed(0),
|
|
1578
1796
|
" KB)"
|
|
@@ -1583,7 +1801,7 @@ function Form({ widget, onAction }) {
|
|
|
1583
1801
|
{
|
|
1584
1802
|
type: "button",
|
|
1585
1803
|
onClick: () => handleChange(field.name, files.filter((_, i) => i !== idx)),
|
|
1586
|
-
className: "apteva-file-remove-btn
|
|
1804
|
+
className: "apteva-file-remove-btn transition-colors flex-shrink-0",
|
|
1587
1805
|
children: "\u2715"
|
|
1588
1806
|
}
|
|
1589
1807
|
)
|
|
@@ -1597,14 +1815,14 @@ function Form({ widget, onAction }) {
|
|
|
1597
1815
|
return null;
|
|
1598
1816
|
}
|
|
1599
1817
|
};
|
|
1600
|
-
const submitAction = _optionalChain([widget, 'access',
|
|
1601
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: handleSubmit, className: "border
|
|
1818
|
+
const submitAction = _optionalChain([widget, 'access', _30 => _30.actions, 'optionalAccess', _31 => _31.find, 'call', _32 => _32((a) => a.type === "submit")]) || _optionalChain([widget, 'access', _33 => _33.actions, 'optionalAccess', _34 => _34[0]]);
|
|
1819
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: handleSubmit, className: "border rounded-xl overflow-hidden", children: [
|
|
1602
1820
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "p-4", children: [
|
|
1603
|
-
title && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "!text-lg font-semibold
|
|
1821
|
+
title && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "!text-lg font-semibold mb-4", children: title }),
|
|
1604
1822
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-3", children: fields.map((field) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: field.type === "checkbox" ? "" : "space-y-1", children: [
|
|
1605
|
-
field.type !== "checkbox" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "block !text-sm font-medium
|
|
1823
|
+
field.type !== "checkbox" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "apteva-field-label block !text-sm font-medium", children: [
|
|
1606
1824
|
field.label,
|
|
1607
|
-
field.required && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", {
|
|
1825
|
+
field.required && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { color: "var(--aw-danger)" }, className: "ml-1", children: "*" })
|
|
1608
1826
|
] }),
|
|
1609
1827
|
renderField(field)
|
|
1610
1828
|
] }, field.name)) })
|
|
@@ -1613,7 +1831,7 @@ function Form({ widget, onAction }) {
|
|
|
1613
1831
|
"button",
|
|
1614
1832
|
{
|
|
1615
1833
|
type: "submit",
|
|
1616
|
-
className: "px-3 py-1.5 !text-sm rounded-lg font-medium transition-colors
|
|
1834
|
+
className: "px-3 py-1.5 !text-sm rounded-lg font-medium transition-colors",
|
|
1617
1835
|
children: submitAction.label || "Submit"
|
|
1618
1836
|
}
|
|
1619
1837
|
) })
|
|
@@ -1657,7 +1875,7 @@ function StepIcon({ type, status }) {
|
|
|
1657
1875
|
if (type === "recurring" || type === "repeat") {
|
|
1658
1876
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: iconClass, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" }) });
|
|
1659
1877
|
}
|
|
1660
|
-
if (type === "agent" || _optionalChain([type, 'optionalAccess',
|
|
1878
|
+
if (type === "agent" || _optionalChain([type, 'optionalAccess', _35 => _35.startsWith, 'call', _36 => _36("@")])) {
|
|
1661
1879
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: iconClass, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z" }) });
|
|
1662
1880
|
}
|
|
1663
1881
|
if (type === "email" || type === "mail") {
|
|
@@ -1753,7 +1971,7 @@ function getStepColorClass(step, stepType) {
|
|
|
1753
1971
|
if (stepType === "time" || stepType === "schedule" || stepType === "clock") {
|
|
1754
1972
|
return STEP_COLOR_CLASSES.blue;
|
|
1755
1973
|
}
|
|
1756
|
-
if (stepType === "agent" || _optionalChain([stepType, 'optionalAccess',
|
|
1974
|
+
if (stepType === "agent" || _optionalChain([stepType, 'optionalAccess', _37 => _37.startsWith, 'call', _38 => _38("@")])) {
|
|
1757
1975
|
return STEP_COLOR_CLASSES.purple;
|
|
1758
1976
|
}
|
|
1759
1977
|
if (stepType === "email" || stepType === "slack" || stepType === "message" || stepType === "notification") {
|
|
@@ -1870,7 +2088,7 @@ function Kpi({ widget, onAction }) {
|
|
|
1870
2088
|
widget.actions && widget.actions.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex gap-2 mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700", children: widget.actions.map((action, idx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1871
2089
|
"button",
|
|
1872
2090
|
{
|
|
1873
|
-
onClick: () => _optionalChain([onAction, 'optionalCall',
|
|
2091
|
+
onClick: () => _optionalChain([onAction, 'optionalCall', _39 => _39({
|
|
1874
2092
|
type: action.type,
|
|
1875
2093
|
payload: action.payload,
|
|
1876
2094
|
widgetId: widget.id,
|
|
@@ -1997,7 +2215,7 @@ function LiveView({ widget }) {
|
|
|
1997
2215
|
setRefreshKey((k) => k + 1);
|
|
1998
2216
|
}, []);
|
|
1999
2217
|
const handleFullscreen = _react.useCallback.call(void 0, () => {
|
|
2000
|
-
_optionalChain([iframeRef, 'access',
|
|
2218
|
+
_optionalChain([iframeRef, 'access', _40 => _40.current, 'optionalAccess', _41 => _41.requestFullscreen, 'optionalCall', _42 => _42()]);
|
|
2001
2219
|
}, []);
|
|
2002
2220
|
const handleOpenExternal = _react.useCallback.call(void 0, () => {
|
|
2003
2221
|
window.open(src, "_blank", "noopener,noreferrer");
|
|
@@ -2152,7 +2370,7 @@ function Widgets({
|
|
|
2152
2370
|
}) {
|
|
2153
2371
|
_react.useEffect.call(void 0, () => {
|
|
2154
2372
|
widgets.forEach((widget) => {
|
|
2155
|
-
_optionalChain([onWidgetMount, 'optionalCall',
|
|
2373
|
+
_optionalChain([onWidgetMount, 'optionalCall', _43 => _43(widget.id)]);
|
|
2156
2374
|
});
|
|
2157
2375
|
}, [widgets, onWidgetMount]);
|
|
2158
2376
|
const layoutClasses = {
|
|
@@ -2563,8 +2781,8 @@ function PersistentWidgetRef({ widget }) {
|
|
|
2563
2781
|
|
|
2564
2782
|
function Message({ message, onAction, enableWidgets, onWidgetRender, persistentWidgetIds, toolCallStyle = "card" }) {
|
|
2565
2783
|
const isUser = message.role === "user";
|
|
2566
|
-
const contentSegments = _optionalChain([message, 'access',
|
|
2567
|
-
const isStreaming = _optionalChain([message, 'access',
|
|
2784
|
+
const contentSegments = _optionalChain([message, 'access', _44 => _44.metadata, 'optionalAccess', _45 => _45.content_segments]);
|
|
2785
|
+
const isStreaming = _optionalChain([message, 'access', _46 => _46.metadata, 'optionalAccess', _47 => _47.isStreaming]) === true;
|
|
2568
2786
|
const hasContent = message.content || contentSegments && contentSegments.length > 0;
|
|
2569
2787
|
const reportedWidgetsRef = _react.useRef.call(void 0, /* @__PURE__ */ new Set());
|
|
2570
2788
|
const parsedWidgets = _react.useMemo.call(void 0, () => {
|
|
@@ -2644,7 +2862,7 @@ function Message({ message, onAction, enableWidgets, onWidgetRender, persistentW
|
|
|
2644
2862
|
}
|
|
2645
2863
|
return elements.length > 0 ? elements : null;
|
|
2646
2864
|
};
|
|
2647
|
-
const attachments = _optionalChain([message, 'access',
|
|
2865
|
+
const attachments = _optionalChain([message, 'access', _48 => _48.metadata, 'optionalAccess', _49 => _49.attachments]) || [];
|
|
2648
2866
|
const hasAttachments = attachments.length > 0;
|
|
2649
2867
|
const renderAttachments = () => {
|
|
2650
2868
|
if (!hasAttachments) return null;
|
|
@@ -2825,8 +3043,8 @@ function Message({ message, onAction, enableWidgets, onWidgetRender, persistentW
|
|
|
2825
3043
|
};
|
|
2826
3044
|
const renderMessageWidgets = () => {
|
|
2827
3045
|
if (!message.widgets || message.widgets.length === 0) return null;
|
|
2828
|
-
const inlineWidgets = message.widgets.filter((w) => !_optionalChain([persistentWidgetIds, 'optionalAccess',
|
|
2829
|
-
const persistentRefs = message.widgets.filter((w) => _optionalChain([persistentWidgetIds, 'optionalAccess',
|
|
3046
|
+
const inlineWidgets = message.widgets.filter((w) => !_optionalChain([persistentWidgetIds, 'optionalAccess', _50 => _50.has, 'call', _51 => _51(w.id)]));
|
|
3047
|
+
const persistentRefs = message.widgets.filter((w) => _optionalChain([persistentWidgetIds, 'optionalAccess', _52 => _52.has, 'call', _53 => _53(w.id)]));
|
|
2830
3048
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2831
3049
|
persistentRefs.map((w) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PersistentWidgetRef, { widget: w }) }, `ref-${w.id}`)),
|
|
2832
3050
|
inlineWidgets.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-widget-standalone", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Widgets, { widgets: inlineWidgets, onAction, layout: "stack" }) })
|
|
@@ -3133,7 +3351,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
3133
3351
|
setFileError(errors.join(", "));
|
|
3134
3352
|
setTimeout(() => setFileError(null), 5e3);
|
|
3135
3353
|
}
|
|
3136
|
-
_optionalChain([onFileUpload, 'optionalCall',
|
|
3354
|
+
_optionalChain([onFileUpload, 'optionalCall', _54 => _54(e.target.files)]);
|
|
3137
3355
|
setShowMenu(false);
|
|
3138
3356
|
e.target.value = "";
|
|
3139
3357
|
}
|
|
@@ -3205,15 +3423,15 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
3205
3423
|
{
|
|
3206
3424
|
className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
3207
3425
|
style: {
|
|
3208
|
-
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
3209
|
-
bottom: window.innerHeight - (_nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
3426
|
+
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _55 => _55.current, 'optionalAccess', _56 => _56.getBoundingClientRect, 'call', _57 => _57(), 'access', _58 => _58.left]), () => ( 0)),
|
|
3427
|
+
bottom: window.innerHeight - (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.getBoundingClientRect, 'call', _61 => _61(), 'access', _62 => _62.top]), () => ( 0))) + 8
|
|
3210
3428
|
},
|
|
3211
3429
|
children: [
|
|
3212
3430
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3213
3431
|
"button",
|
|
3214
3432
|
{
|
|
3215
3433
|
onClick: () => {
|
|
3216
|
-
_optionalChain([fileInputRef, 'access',
|
|
3434
|
+
_optionalChain([fileInputRef, 'access', _63 => _63.current, 'optionalAccess', _64 => _64.click, 'call', _65 => _65()]);
|
|
3217
3435
|
setShowMenu(false);
|
|
3218
3436
|
},
|
|
3219
3437
|
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left",
|
|
@@ -3334,8 +3552,8 @@ function CommandComposer({
|
|
|
3334
3552
|
}
|
|
3335
3553
|
};
|
|
3336
3554
|
const handleNewCommand = () => {
|
|
3337
|
-
_optionalChain([onReset, 'optionalCall',
|
|
3338
|
-
_optionalChain([inputRef, 'access',
|
|
3555
|
+
_optionalChain([onReset, 'optionalCall', _66 => _66()]);
|
|
3556
|
+
_optionalChain([inputRef, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.focus, 'call', _69 => _69()]);
|
|
3339
3557
|
};
|
|
3340
3558
|
const handleInputChange = (value) => {
|
|
3341
3559
|
setInput(value);
|
|
@@ -3449,15 +3667,15 @@ function CommandComposer({
|
|
|
3449
3667
|
{
|
|
3450
3668
|
className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
3451
3669
|
style: {
|
|
3452
|
-
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
3453
|
-
top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
3670
|
+
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _70 => _70.current, 'optionalAccess', _71 => _71.getBoundingClientRect, 'call', _72 => _72(), 'access', _73 => _73.left]), () => ( 0)),
|
|
3671
|
+
top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _74 => _74.current, 'optionalAccess', _75 => _75.getBoundingClientRect, 'call', _76 => _76(), 'access', _77 => _77.bottom]), () => ( 0))) + 8
|
|
3454
3672
|
},
|
|
3455
3673
|
children: [
|
|
3456
3674
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3457
3675
|
"button",
|
|
3458
3676
|
{
|
|
3459
3677
|
onClick: () => {
|
|
3460
|
-
_optionalChain([fileInputRef, 'access',
|
|
3678
|
+
_optionalChain([fileInputRef, 'access', _78 => _78.current, 'optionalAccess', _79 => _79.click, 'call', _80 => _80()]);
|
|
3461
3679
|
setShowMenu(false);
|
|
3462
3680
|
},
|
|
3463
3681
|
className: "w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left",
|
|
@@ -3610,8 +3828,8 @@ var AptevaClient = class {
|
|
|
3610
3828
|
constructor(config) {
|
|
3611
3829
|
__publicField(this, "config");
|
|
3612
3830
|
this.config = {
|
|
3613
|
-
apiUrl: _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
3614
|
-
apiKey: _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
3831
|
+
apiUrl: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _81 => _81.apiUrl]), () => ( "")),
|
|
3832
|
+
apiKey: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _82 => _82.apiKey]), () => ( ""))
|
|
3615
3833
|
};
|
|
3616
3834
|
}
|
|
3617
3835
|
/**
|
|
@@ -3688,7 +3906,7 @@ var AptevaClient = class {
|
|
|
3688
3906
|
const error = await response.json().catch(() => ({ error: "Request failed" }));
|
|
3689
3907
|
throw new Error(error.error || `Request failed with status ${response.status}`);
|
|
3690
3908
|
}
|
|
3691
|
-
const reader = _optionalChain([response, 'access',
|
|
3909
|
+
const reader = _optionalChain([response, 'access', _83 => _83.body, 'optionalAccess', _84 => _84.getReader, 'call', _85 => _85()]);
|
|
3692
3910
|
if (!reader) {
|
|
3693
3911
|
throw new Error("Response body is not readable");
|
|
3694
3912
|
}
|
|
@@ -3706,7 +3924,7 @@ var AptevaClient = class {
|
|
|
3706
3924
|
if (line.startsWith("data: ")) {
|
|
3707
3925
|
const data = line.slice(6);
|
|
3708
3926
|
if (data === "[DONE]") {
|
|
3709
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3927
|
+
_optionalChain([onComplete, 'optionalCall', _86 => _86(threadId)]);
|
|
3710
3928
|
return;
|
|
3711
3929
|
}
|
|
3712
3930
|
try {
|
|
@@ -3721,10 +3939,10 @@ var AptevaClient = class {
|
|
|
3721
3939
|
}
|
|
3722
3940
|
}
|
|
3723
3941
|
}
|
|
3724
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3942
|
+
_optionalChain([onComplete, 'optionalCall', _87 => _87(threadId)]);
|
|
3725
3943
|
} catch (error) {
|
|
3726
3944
|
const err = error instanceof Error ? error : new Error("Unknown error");
|
|
3727
|
-
_optionalChain([onError, 'optionalCall',
|
|
3945
|
+
_optionalChain([onError, 'optionalCall', _88 => _88(err)]);
|
|
3728
3946
|
throw err;
|
|
3729
3947
|
}
|
|
3730
3948
|
}
|
|
@@ -3947,7 +4165,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3947
4165
|
}, [apiUrl, apiKey]);
|
|
3948
4166
|
_react.useEffect.call(void 0, () => {
|
|
3949
4167
|
if (threadId) {
|
|
3950
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4168
|
+
_optionalChain([onThreadChange, 'optionalCall', _89 => _89(threadId)]);
|
|
3951
4169
|
}
|
|
3952
4170
|
}, [threadId, onThreadChange]);
|
|
3953
4171
|
_react.useEffect.call(void 0, () => {
|
|
@@ -3965,7 +4183,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3965
4183
|
}, [showSettingsMenu]);
|
|
3966
4184
|
const handleModeChange = (newMode) => {
|
|
3967
4185
|
setMode(newMode);
|
|
3968
|
-
_optionalChain([onModeChange, 'optionalCall',
|
|
4186
|
+
_optionalChain([onModeChange, 'optionalCall', _90 => _90(newMode)]);
|
|
3969
4187
|
if (newMode === "command") {
|
|
3970
4188
|
setCommandState("idle");
|
|
3971
4189
|
setCommandResult(null);
|
|
@@ -3974,8 +4192,8 @@ ${widgetContext}` : widgetContext;
|
|
|
3974
4192
|
};
|
|
3975
4193
|
const defaultPlaceholder = mode === "chat" ? "Type a message..." : "Enter your command...";
|
|
3976
4194
|
const handleWidgetAction = _react.useCallback.call(void 0, (action) => {
|
|
3977
|
-
_optionalChain([onAction, 'optionalCall',
|
|
3978
|
-
if (action.type === "submit" && _optionalChain([action, 'access',
|
|
4195
|
+
_optionalChain([onAction, 'optionalCall', _91 => _91(action)]);
|
|
4196
|
+
if (action.type === "submit" && _optionalChain([action, 'access', _92 => _92.payload, 'optionalAccess', _93 => _93.formData])) {
|
|
3979
4197
|
const formData = action.payload.formData;
|
|
3980
4198
|
const lines = [];
|
|
3981
4199
|
for (const [key, value] of Object.entries(formData)) {
|
|
@@ -4014,7 +4232,7 @@ ${widgetContext}` : widgetContext;
|
|
|
4014
4232
|
metadata: hasFiles ? { attachments } : void 0
|
|
4015
4233
|
};
|
|
4016
4234
|
setMessages((prev) => [...prev, userMessage]);
|
|
4017
|
-
_optionalChain([onMessageSent, 'optionalCall',
|
|
4235
|
+
_optionalChain([onMessageSent, 'optionalCall', _94 => _94(userMessage)]);
|
|
4018
4236
|
}
|
|
4019
4237
|
setIsLoading(true);
|
|
4020
4238
|
try {
|
|
@@ -4082,7 +4300,7 @@ ${widgetContext}` : widgetContext;
|
|
|
4082
4300
|
responseThreadId = chunk.thread_id;
|
|
4083
4301
|
if (!currentThreadId) {
|
|
4084
4302
|
setCurrentThreadId(chunk.thread_id);
|
|
4085
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4303
|
+
_optionalChain([onThreadChange, 'optionalCall', _95 => _95(chunk.thread_id)]);
|
|
4086
4304
|
}
|
|
4087
4305
|
}
|
|
4088
4306
|
break;
|
|
@@ -4114,7 +4332,7 @@ ${widgetContext}` : widgetContext;
|
|
|
4114
4332
|
contentSegments.push({ type: "tool", id: chunk.tool_id, name: displayName, status: "preparing" });
|
|
4115
4333
|
toolInputBuffers[chunk.tool_id] = "";
|
|
4116
4334
|
setChatToolName(displayName);
|
|
4117
|
-
_optionalChain([onToolCall, 'optionalCall',
|
|
4335
|
+
_optionalChain([onToolCall, 'optionalCall', _96 => _96(chunk.tool_name, chunk.tool_id)]);
|
|
4118
4336
|
updateMessage();
|
|
4119
4337
|
}
|
|
4120
4338
|
break;
|
|
@@ -4174,7 +4392,7 @@ ${widgetContext}` : widgetContext;
|
|
|
4174
4392
|
toolSegment.result = chunk.content;
|
|
4175
4393
|
toolSegment.status = "completed";
|
|
4176
4394
|
toolSegment.isReceiving = false;
|
|
4177
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
4395
|
+
_optionalChain([onToolResult, 'optionalCall', _97 => _97(toolSegment.name, chunk.content)]);
|
|
4178
4396
|
}
|
|
4179
4397
|
setChatToolName(null);
|
|
4180
4398
|
updateMessage();
|
|
@@ -4218,7 +4436,7 @@ ${widgetContext}` : widgetContext;
|
|
|
4218
4436
|
});
|
|
4219
4437
|
if (threadId2 && threadId2 !== currentThreadId) {
|
|
4220
4438
|
setCurrentThreadId(threadId2);
|
|
4221
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4439
|
+
_optionalChain([onThreadChange, 'optionalCall', _98 => _98(threadId2)]);
|
|
4222
4440
|
}
|
|
4223
4441
|
setIsLoading(false);
|
|
4224
4442
|
setCurrentRequestId(null);
|
|
@@ -4242,7 +4460,7 @@ ${widgetContext}` : widgetContext;
|
|
|
4242
4460
|
setIsLoading(false);
|
|
4243
4461
|
setCurrentRequestId(null);
|
|
4244
4462
|
setChatToolName(null);
|
|
4245
|
-
_optionalChain([onError, 'optionalCall',
|
|
4463
|
+
_optionalChain([onError, 'optionalCall', _99 => _99(error)]);
|
|
4246
4464
|
}
|
|
4247
4465
|
);
|
|
4248
4466
|
}
|
|
@@ -4255,7 +4473,7 @@ ${widgetContext}` : widgetContext;
|
|
|
4255
4473
|
metadata: { error: true }
|
|
4256
4474
|
};
|
|
4257
4475
|
setMessages((prev) => [...prev, errorMessage]);
|
|
4258
|
-
_optionalChain([onError, 'optionalCall',
|
|
4476
|
+
_optionalChain([onError, 'optionalCall', _100 => _100(error instanceof Error ? error : new Error("Unknown error"))]);
|
|
4259
4477
|
} finally {
|
|
4260
4478
|
setIsLoading(false);
|
|
4261
4479
|
}
|
|
@@ -4301,7 +4519,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4301
4519
|
const error = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
4302
4520
|
setCommandError(error);
|
|
4303
4521
|
setCommandState("error");
|
|
4304
|
-
_optionalChain([onError, 'optionalCall',
|
|
4522
|
+
_optionalChain([onError, 'optionalCall', _101 => _101(error)]);
|
|
4305
4523
|
}
|
|
4306
4524
|
}
|
|
4307
4525
|
return;
|
|
@@ -4334,12 +4552,12 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4334
4552
|
setCommandResult(result);
|
|
4335
4553
|
setCommandState("success");
|
|
4336
4554
|
setProgress(100);
|
|
4337
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4555
|
+
_optionalChain([onComplete, 'optionalCall', _102 => _102(result)]);
|
|
4338
4556
|
},
|
|
4339
4557
|
(error) => {
|
|
4340
4558
|
setCommandError(error);
|
|
4341
4559
|
setCommandState("error");
|
|
4342
|
-
_optionalChain([onError, 'optionalCall',
|
|
4560
|
+
_optionalChain([onError, 'optionalCall', _103 => _103(error)]);
|
|
4343
4561
|
}
|
|
4344
4562
|
);
|
|
4345
4563
|
} else {
|
|
@@ -4352,7 +4570,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4352
4570
|
setCommandResult(result);
|
|
4353
4571
|
setCommandState("success");
|
|
4354
4572
|
setProgress(100);
|
|
4355
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4573
|
+
_optionalChain([onComplete, 'optionalCall', _104 => _104(result)]);
|
|
4356
4574
|
}
|
|
4357
4575
|
} else {
|
|
4358
4576
|
const commandInstruction = `CRITICAL COMMAND MODE: Maximum 10 words per response. Execute the command immediately. Make reasonable assumptions based on context. Use sensible defaults for missing details. DO NOT ask questions unless something is truly impossible without user input (e.g., missing required password). State what you're doing or the result. Examples: "Analyzing customer data from last quarter..." or "Created 5 new database entries successfully" or "Search complete: found 12 matching results". NO greetings, NO filler words, NO clarification requests. Action/result only.`;
|
|
@@ -4382,16 +4600,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4382
4600
|
const displayName = chunk.tool_display_name || chunk.tool_name;
|
|
4383
4601
|
lastToolName = chunk.tool_name;
|
|
4384
4602
|
setCurrentToolName(displayName);
|
|
4385
|
-
_optionalChain([onToolCall, 'optionalCall',
|
|
4603
|
+
_optionalChain([onToolCall, 'optionalCall', _105 => _105(chunk.tool_name, chunk.tool_id || "")]);
|
|
4386
4604
|
accumulatedContent = "";
|
|
4387
4605
|
setStreamedContent("");
|
|
4388
4606
|
} else if (chunk.type === "tool_result") {
|
|
4389
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
4607
|
+
_optionalChain([onToolResult, 'optionalCall', _106 => _106(lastToolName, chunk.content)]);
|
|
4390
4608
|
setCurrentToolName(null);
|
|
4391
4609
|
} else if (chunk.type === "thread_id" && chunk.thread_id) {
|
|
4392
4610
|
if (!currentThreadId) {
|
|
4393
4611
|
setCurrentThreadId(chunk.thread_id);
|
|
4394
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4612
|
+
_optionalChain([onThreadChange, 'optionalCall', _107 => _107(chunk.thread_id)]);
|
|
4395
4613
|
}
|
|
4396
4614
|
} else if (chunk.type === "request_id" && chunk.request_id) {
|
|
4397
4615
|
setCurrentRequestId(chunk.request_id);
|
|
@@ -4407,13 +4625,13 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4407
4625
|
setCommandState("success");
|
|
4408
4626
|
setProgress(100);
|
|
4409
4627
|
setCurrentRequestId(null);
|
|
4410
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4628
|
+
_optionalChain([onComplete, 'optionalCall', _108 => _108(result)]);
|
|
4411
4629
|
},
|
|
4412
4630
|
(error) => {
|
|
4413
4631
|
setCommandError(error);
|
|
4414
4632
|
setCommandState("error");
|
|
4415
4633
|
setCurrentRequestId(null);
|
|
4416
|
-
_optionalChain([onError, 'optionalCall',
|
|
4634
|
+
_optionalChain([onError, 'optionalCall', _109 => _109(error)]);
|
|
4417
4635
|
}
|
|
4418
4636
|
);
|
|
4419
4637
|
} else {
|
|
@@ -4433,14 +4651,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4433
4651
|
setCommandResult(result);
|
|
4434
4652
|
setCommandState("success");
|
|
4435
4653
|
setProgress(100);
|
|
4436
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4654
|
+
_optionalChain([onComplete, 'optionalCall', _110 => _110(result)]);
|
|
4437
4655
|
}
|
|
4438
4656
|
}
|
|
4439
4657
|
} catch (err) {
|
|
4440
4658
|
const error = err instanceof Error ? err : new Error("Unknown error");
|
|
4441
4659
|
setCommandError(error);
|
|
4442
4660
|
setCommandState("error");
|
|
4443
|
-
_optionalChain([onError, 'optionalCall',
|
|
4661
|
+
_optionalChain([onError, 'optionalCall', _111 => _111(error)]);
|
|
4444
4662
|
}
|
|
4445
4663
|
};
|
|
4446
4664
|
const resetCommand = () => {
|
|
@@ -4539,8 +4757,8 @@ ${planToExecute}`;
|
|
|
4539
4757
|
executeCommand(text, files);
|
|
4540
4758
|
},
|
|
4541
4759
|
state: commandState,
|
|
4542
|
-
response: _optionalChain([commandResult, 'optionalAccess',
|
|
4543
|
-
error: _optionalChain([commandError, 'optionalAccess',
|
|
4760
|
+
response: _optionalChain([commandResult, 'optionalAccess', _112 => _112.data, 'optionalAccess', _113 => _113.summary]) || _optionalChain([commandResult, 'optionalAccess', _114 => _114.message]),
|
|
4761
|
+
error: _optionalChain([commandError, 'optionalAccess', _115 => _115.message]),
|
|
4544
4762
|
plan,
|
|
4545
4763
|
streamedContent,
|
|
4546
4764
|
toolName: currentToolName,
|
|
@@ -4708,13 +4926,13 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4708
4926
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
4709
4927
|
setError(error2);
|
|
4710
4928
|
setState("error");
|
|
4711
|
-
_optionalChain([onError, 'optionalCall',
|
|
4929
|
+
_optionalChain([onError, 'optionalCall', _116 => _116(error2)]);
|
|
4712
4930
|
});
|
|
4713
4931
|
} catch (err) {
|
|
4714
4932
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
4715
4933
|
setError(error2);
|
|
4716
4934
|
setState("error");
|
|
4717
|
-
_optionalChain([onError, 'optionalCall',
|
|
4935
|
+
_optionalChain([onError, 'optionalCall', _117 => _117(error2)]);
|
|
4718
4936
|
}
|
|
4719
4937
|
}
|
|
4720
4938
|
return;
|
|
@@ -4725,7 +4943,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4725
4943
|
setStreamedContent("");
|
|
4726
4944
|
setCommand("");
|
|
4727
4945
|
setUploadedFiles([]);
|
|
4728
|
-
_optionalChain([onStart, 'optionalCall',
|
|
4946
|
+
_optionalChain([onStart, 'optionalCall', _118 => _118()]);
|
|
4729
4947
|
try {
|
|
4730
4948
|
if (useMock) {
|
|
4731
4949
|
if (enableStreaming) {
|
|
@@ -4736,16 +4954,16 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4736
4954
|
if (chunk.type === "token" && chunk.content) {
|
|
4737
4955
|
accumulatedContent += chunk.content;
|
|
4738
4956
|
setStreamedContent(accumulatedContent);
|
|
4739
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
4957
|
+
_optionalChain([onChunk, 'optionalCall', _119 => _119(chunk.content)]);
|
|
4740
4958
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
4741
4959
|
setProgress(estimatedProgress);
|
|
4742
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
4960
|
+
_optionalChain([onProgress, 'optionalCall', _120 => _120(estimatedProgress)]);
|
|
4743
4961
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
4744
4962
|
const widget = chunk.widget;
|
|
4745
4963
|
setResult((prev) => ({
|
|
4746
4964
|
success: true,
|
|
4747
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
4748
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
4965
|
+
data: _optionalChain([prev, 'optionalAccess', _121 => _121.data]) || {},
|
|
4966
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _122 => _122.widgets]) || [], widget],
|
|
4749
4967
|
message: accumulatedContent || "Command executed successfully"
|
|
4750
4968
|
}));
|
|
4751
4969
|
}
|
|
@@ -4765,19 +4983,19 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4765
4983
|
setResult(result2);
|
|
4766
4984
|
setState("success");
|
|
4767
4985
|
setProgress(100);
|
|
4768
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4986
|
+
_optionalChain([onComplete, 'optionalCall', _123 => _123(result2)]);
|
|
4769
4987
|
},
|
|
4770
4988
|
(error2) => {
|
|
4771
4989
|
setError(error2);
|
|
4772
4990
|
setState("error");
|
|
4773
|
-
_optionalChain([onError, 'optionalCall',
|
|
4991
|
+
_optionalChain([onError, 'optionalCall', _124 => _124(error2)]);
|
|
4774
4992
|
}
|
|
4775
4993
|
);
|
|
4776
4994
|
} else {
|
|
4777
4995
|
const progressInterval = setInterval(() => {
|
|
4778
4996
|
setProgress((prev) => {
|
|
4779
4997
|
const next = Math.min(prev + 10, 90);
|
|
4780
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
4998
|
+
_optionalChain([onProgress, 'optionalCall', _125 => _125(next)]);
|
|
4781
4999
|
return next;
|
|
4782
5000
|
});
|
|
4783
5001
|
}, 200);
|
|
@@ -4801,7 +5019,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4801
5019
|
setResult(result2);
|
|
4802
5020
|
setState("success");
|
|
4803
5021
|
setProgress(100);
|
|
4804
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5022
|
+
_optionalChain([onComplete, 'optionalCall', _126 => _126(result2)]);
|
|
4805
5023
|
}
|
|
4806
5024
|
} else {
|
|
4807
5025
|
if (enableStreaming) {
|
|
@@ -4847,16 +5065,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4847
5065
|
if (chunk.type === "token" && chunk.content) {
|
|
4848
5066
|
accumulatedContent += chunk.content;
|
|
4849
5067
|
setStreamedContent(accumulatedContent);
|
|
4850
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
5068
|
+
_optionalChain([onChunk, 'optionalCall', _127 => _127(chunk.content)]);
|
|
4851
5069
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
4852
5070
|
setProgress(estimatedProgress);
|
|
4853
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
5071
|
+
_optionalChain([onProgress, 'optionalCall', _128 => _128(estimatedProgress)]);
|
|
4854
5072
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
4855
5073
|
const widget = chunk.widget;
|
|
4856
5074
|
setResult((prev) => ({
|
|
4857
5075
|
success: true,
|
|
4858
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
4859
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
5076
|
+
data: _optionalChain([prev, 'optionalAccess', _129 => _129.data]) || {},
|
|
5077
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _130 => _130.widgets]) || [], widget],
|
|
4860
5078
|
message: accumulatedContent || "Command executed successfully"
|
|
4861
5079
|
}));
|
|
4862
5080
|
}
|
|
@@ -4876,20 +5094,20 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4876
5094
|
setResult(result2);
|
|
4877
5095
|
setState("success");
|
|
4878
5096
|
setProgress(100);
|
|
4879
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5097
|
+
_optionalChain([onComplete, 'optionalCall', _131 => _131(result2)]);
|
|
4880
5098
|
},
|
|
4881
5099
|
(error2) => {
|
|
4882
5100
|
const err = error2 instanceof Error ? error2 : new Error("Unknown error");
|
|
4883
5101
|
setError(err);
|
|
4884
5102
|
setState("error");
|
|
4885
|
-
_optionalChain([onError, 'optionalCall',
|
|
5103
|
+
_optionalChain([onError, 'optionalCall', _132 => _132(err)]);
|
|
4886
5104
|
}
|
|
4887
5105
|
);
|
|
4888
5106
|
} else {
|
|
4889
5107
|
const progressInterval = setInterval(() => {
|
|
4890
5108
|
setProgress((prev) => {
|
|
4891
5109
|
const next = Math.min(prev + 10, 90);
|
|
4892
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
5110
|
+
_optionalChain([onProgress, 'optionalCall', _133 => _133(next)]);
|
|
4893
5111
|
return next;
|
|
4894
5112
|
});
|
|
4895
5113
|
}, 200);
|
|
@@ -4945,14 +5163,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4945
5163
|
setResult(result2);
|
|
4946
5164
|
setState("success");
|
|
4947
5165
|
setProgress(100);
|
|
4948
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5166
|
+
_optionalChain([onComplete, 'optionalCall', _134 => _134(result2)]);
|
|
4949
5167
|
}
|
|
4950
5168
|
}
|
|
4951
5169
|
} catch (err) {
|
|
4952
5170
|
const error2 = err instanceof Error ? err : new Error("Unknown error");
|
|
4953
5171
|
setError(error2);
|
|
4954
5172
|
setState("error");
|
|
4955
|
-
_optionalChain([onError, 'optionalCall',
|
|
5173
|
+
_optionalChain([onError, 'optionalCall', _135 => _135(error2)]);
|
|
4956
5174
|
}
|
|
4957
5175
|
};
|
|
4958
5176
|
const resetCommand = () => {
|
|
@@ -4985,14 +5203,14 @@ ${planToExecute}`;
|
|
|
4985
5203
|
};
|
|
4986
5204
|
const handleFileSelect = async (e) => {
|
|
4987
5205
|
if (e.target.files && e.target.files.length > 0) {
|
|
4988
|
-
_optionalChain([onFileUpload, 'optionalCall',
|
|
5206
|
+
_optionalChain([onFileUpload, 'optionalCall', _136 => _136(e.target.files)]);
|
|
4989
5207
|
const files = [];
|
|
4990
5208
|
for (let i = 0; i < e.target.files.length; i++) {
|
|
4991
5209
|
const file = e.target.files[i];
|
|
4992
5210
|
const reader = new FileReader();
|
|
4993
5211
|
await new Promise((resolve) => {
|
|
4994
5212
|
reader.onload = (event) => {
|
|
4995
|
-
if (_optionalChain([event, 'access',
|
|
5213
|
+
if (_optionalChain([event, 'access', _137 => _137.target, 'optionalAccess', _138 => _138.result])) {
|
|
4996
5214
|
const fullDataUrl = event.target.result;
|
|
4997
5215
|
const base64Data = fullDataUrl.split(",")[1];
|
|
4998
5216
|
if (file.type.startsWith("image/")) {
|
|
@@ -5086,7 +5304,7 @@ ${planToExecute}`;
|
|
|
5086
5304
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5087
5305
|
"button",
|
|
5088
5306
|
{
|
|
5089
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
5307
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _139 => _139.current, 'optionalAccess', _140 => _140.click, 'call', _141 => _141()]),
|
|
5090
5308
|
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-neutral-500 dark:!text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800",
|
|
5091
5309
|
title: "Attach file",
|
|
5092
5310
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M8.4 2.8L4.4 6.8C3.736 7.464 3.736 8.536 4.4 9.2C5.064 9.864 6.136 9.864 6.8 9.2L11.6 4.4C12.704 3.296 12.704 1.504 11.6 0.4C10.496 -0.704 8.704 -0.704 7.6 0.4L2.8 5.2C1.256 6.744 1.256 9.256 2.8 10.8C4.344 12.344 6.856 12.344 8.4 10.8L12.4 6.8", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round", transform: "translate(1.6, 2.4)" }) })
|
|
@@ -5305,7 +5523,7 @@ ${planToExecute}`;
|
|
|
5305
5523
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className: "w-5 h-5 text-red-600 mt-0.5 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
5306
5524
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
5307
5525
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-semibold text-red-800 dark:text-red-400", children: "Error" }),
|
|
5308
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess',
|
|
5526
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-red-700 dark:text-red-300 text-sm mt-1", children: _optionalChain([error, 'optionalAccess', _142 => _142.message]) })
|
|
5309
5527
|
] })
|
|
5310
5528
|
] }) }),
|
|
5311
5529
|
allowInput && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -5333,7 +5551,7 @@ ${planToExecute}`;
|
|
|
5333
5551
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
|
|
5334
5552
|
] })
|
|
5335
5553
|
] }),
|
|
5336
|
-
_optionalChain([result, 'access',
|
|
5554
|
+
_optionalChain([result, 'access', _143 => _143.data, 'optionalAccess', _144 => _144.summary]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "text-neutral-700 dark:text-neutral-300 text-sm leading-relaxed whitespace-pre-line", children: result.data.summary }),
|
|
5337
5555
|
result.widgets && result.widgets.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "space-y-3", children: result.widgets.map((widget) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5338
5556
|
WidgetRenderer,
|
|
5339
5557
|
{
|
|
@@ -5384,7 +5602,7 @@ ${planToExecute}`;
|
|
|
5384
5602
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5385
5603
|
"button",
|
|
5386
5604
|
{
|
|
5387
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
5605
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _145 => _145.current, 'optionalAccess', _146 => _146.click, 'call', _147 => _147()]),
|
|
5388
5606
|
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0 !text-neutral-500 dark:!text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800",
|
|
5389
5607
|
title: "Attach file",
|
|
5390
5608
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M8.4 2.8L4.4 6.8C3.736 7.464 3.736 8.536 4.4 9.2C5.064 9.864 6.136 9.864 6.8 9.2L11.6 4.4C12.704 3.296 12.704 1.504 11.6 0.4C10.496 -0.704 8.704 -0.704 7.6 0.4L2.8 5.2C1.256 6.744 1.256 9.256 2.8 10.8C4.344 12.344 6.856 12.344 8.4 10.8L12.4 6.8", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round", transform: "translate(1.6, 2.4)" }) })
|
|
@@ -5570,25 +5788,25 @@ function Prompt({
|
|
|
5570
5788
|
const newValue = e.target.value;
|
|
5571
5789
|
if (!maxLength || newValue.length <= maxLength) {
|
|
5572
5790
|
setValue(newValue);
|
|
5573
|
-
_optionalChain([onChange, 'optionalCall',
|
|
5791
|
+
_optionalChain([onChange, 'optionalCall', _148 => _148(newValue)]);
|
|
5574
5792
|
}
|
|
5575
5793
|
};
|
|
5576
5794
|
const handleSubmit = async () => {
|
|
5577
5795
|
if (value.length < minLength) return;
|
|
5578
|
-
_optionalChain([onSubmit, 'optionalCall',
|
|
5796
|
+
_optionalChain([onSubmit, 'optionalCall', _149 => _149(value)]);
|
|
5579
5797
|
setIsLoading(true);
|
|
5580
5798
|
try {
|
|
5581
5799
|
if (useMock) {
|
|
5582
5800
|
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
5583
5801
|
const mockResult = `Enhanced version: ${value} [AI-generated content]`;
|
|
5584
|
-
_optionalChain([onResult, 'optionalCall',
|
|
5802
|
+
_optionalChain([onResult, 'optionalCall', _150 => _150(mockResult)]);
|
|
5585
5803
|
setValue("");
|
|
5586
5804
|
} else {
|
|
5587
5805
|
const response = await aptevaClient.chat({
|
|
5588
5806
|
agent_id: agentId,
|
|
5589
5807
|
message: value
|
|
5590
5808
|
});
|
|
5591
|
-
_optionalChain([onResult, 'optionalCall',
|
|
5809
|
+
_optionalChain([onResult, 'optionalCall', _151 => _151(response.message)]);
|
|
5592
5810
|
setValue("");
|
|
5593
5811
|
}
|
|
5594
5812
|
} catch (error) {
|
|
@@ -5683,7 +5901,7 @@ function Stream({
|
|
|
5683
5901
|
}, [autoStart]);
|
|
5684
5902
|
const startStreaming = async () => {
|
|
5685
5903
|
setIsStreaming(true);
|
|
5686
|
-
_optionalChain([onStart, 'optionalCall',
|
|
5904
|
+
_optionalChain([onStart, 'optionalCall', _152 => _152()]);
|
|
5687
5905
|
try {
|
|
5688
5906
|
if (useMock) {
|
|
5689
5907
|
const mockText = "This is a simulated streaming response from the AI agent. In a real implementation, this would stream data from your backend API. The text appears word by word to simulate the streaming effect. You can customize the typing speed and styling based on your needs.";
|
|
@@ -5691,13 +5909,13 @@ function Stream({
|
|
|
5691
5909
|
mockText,
|
|
5692
5910
|
(chunk) => {
|
|
5693
5911
|
setText((prev) => prev + chunk);
|
|
5694
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
5912
|
+
_optionalChain([onChunk, 'optionalCall', _153 => _153(chunk)]);
|
|
5695
5913
|
},
|
|
5696
5914
|
typingSpeed
|
|
5697
5915
|
);
|
|
5698
5916
|
setIsComplete(true);
|
|
5699
5917
|
setIsStreaming(false);
|
|
5700
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5918
|
+
_optionalChain([onComplete, 'optionalCall', _154 => _154(text + mockText)]);
|
|
5701
5919
|
} else {
|
|
5702
5920
|
let accumulatedText = "";
|
|
5703
5921
|
await aptevaClient.chatStream(
|
|
@@ -5710,24 +5928,24 @@ function Stream({
|
|
|
5710
5928
|
if (chunk.type === "token" && chunk.content) {
|
|
5711
5929
|
accumulatedText += chunk.content;
|
|
5712
5930
|
setText(accumulatedText);
|
|
5713
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
5931
|
+
_optionalChain([onChunk, 'optionalCall', _155 => _155(chunk.content)]);
|
|
5714
5932
|
}
|
|
5715
5933
|
},
|
|
5716
5934
|
() => {
|
|
5717
5935
|
setIsComplete(true);
|
|
5718
5936
|
setIsStreaming(false);
|
|
5719
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5937
|
+
_optionalChain([onComplete, 'optionalCall', _156 => _156(accumulatedText)]);
|
|
5720
5938
|
},
|
|
5721
5939
|
(error) => {
|
|
5722
5940
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
5723
|
-
_optionalChain([onError, 'optionalCall',
|
|
5941
|
+
_optionalChain([onError, 'optionalCall', _157 => _157(err)]);
|
|
5724
5942
|
setIsStreaming(false);
|
|
5725
5943
|
}
|
|
5726
5944
|
);
|
|
5727
5945
|
}
|
|
5728
5946
|
} catch (error) {
|
|
5729
5947
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
5730
|
-
_optionalChain([onError, 'optionalCall',
|
|
5948
|
+
_optionalChain([onError, 'optionalCall', _158 => _158(err)]);
|
|
5731
5949
|
setIsStreaming(false);
|
|
5732
5950
|
}
|
|
5733
5951
|
};
|
|
@@ -5819,7 +6037,7 @@ function ThreadList({
|
|
|
5819
6037
|
}) {
|
|
5820
6038
|
const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
|
|
5821
6039
|
const filteredThreads = threads.filter(
|
|
5822
|
-
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access',
|
|
6040
|
+
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access', _159 => _159.preview, 'optionalAccess', _160 => _160.toLowerCase, 'call', _161 => _161(), 'access', _162 => _162.includes, 'call', _163 => _163(searchQuery.toLowerCase())])
|
|
5823
6041
|
);
|
|
5824
6042
|
const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
|
|
5825
6043
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
|
|
@@ -5841,8 +6059,8 @@ function ThreadList({
|
|
|
5841
6059
|
{
|
|
5842
6060
|
thread,
|
|
5843
6061
|
isActive: thread.id === currentThreadId,
|
|
5844
|
-
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
5845
|
-
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall',
|
|
6062
|
+
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _164 => _164(thread.id)]),
|
|
6063
|
+
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _165 => _165(thread.id)])
|
|
5846
6064
|
},
|
|
5847
6065
|
thread.id
|
|
5848
6066
|
))
|
|
@@ -5904,7 +6122,7 @@ function Threads({
|
|
|
5904
6122
|
threads.slice(0, 5).map((thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5905
6123
|
"button",
|
|
5906
6124
|
{
|
|
5907
|
-
onClick: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
6125
|
+
onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _166 => _166(thread.id)]),
|
|
5908
6126
|
className: cn(
|
|
5909
6127
|
"px-4 py-2 whitespace-nowrap font-medium transition-colors",
|
|
5910
6128
|
thread.id === currentThreadId ? "border-b-2 border-apteva-500 text-apteva-500" : "text-neutral-600 hover:text-neutral-900"
|
|
@@ -6089,7 +6307,7 @@ function TabsLayout({ node, renderNode }) {
|
|
|
6089
6307
|
var STRUCTURAL_KEYS = /* @__PURE__ */ new Set(["type", "id", "layout", "props", "children", "actions", "metadata", "isStreaming"]);
|
|
6090
6308
|
function normalizeNode(n) {
|
|
6091
6309
|
let node = { ...n };
|
|
6092
|
-
if (node.type === "widget" && _optionalChain([node, 'access',
|
|
6310
|
+
if (node.type === "widget" && _optionalChain([node, 'access', _167 => _167.props, 'optionalAccess', _168 => _168.widget])) {
|
|
6093
6311
|
node.type = node.props.widget;
|
|
6094
6312
|
const { widget: _, ...rest } = node.props;
|
|
6095
6313
|
node.props = rest;
|
|
@@ -6227,10 +6445,10 @@ function AutoInterface({
|
|
|
6227
6445
|
].filter(Boolean).join("\n\n");
|
|
6228
6446
|
const updateInterface = _react.useCallback.call(void 0, (newSpec) => {
|
|
6229
6447
|
setInterfaceSpec(newSpec);
|
|
6230
|
-
_optionalChain([onInterfaceChange, 'optionalCall',
|
|
6448
|
+
_optionalChain([onInterfaceChange, 'optionalCall', _169 => _169(newSpec)]);
|
|
6231
6449
|
}, [onInterfaceChange]);
|
|
6232
6450
|
const handleAction = _react.useCallback.call(void 0, (action) => {
|
|
6233
|
-
_optionalChain([onAction, 'optionalCall',
|
|
6451
|
+
_optionalChain([onAction, 'optionalCall', _170 => _170(action)]);
|
|
6234
6452
|
if (chatRef.current) {
|
|
6235
6453
|
chatRef.current.sendMessage(
|
|
6236
6454
|
`[Action: ${action.type} on widget ${action.widgetId || "unknown"}. Payload: ${JSON.stringify(action.payload)}]`
|
|
@@ -6238,7 +6456,7 @@ function AutoInterface({
|
|
|
6238
6456
|
}
|
|
6239
6457
|
}, [onAction]);
|
|
6240
6458
|
const handleMessageComplete = _react.useCallback.call(void 0, (result) => {
|
|
6241
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
6459
|
+
if (!_optionalChain([result, 'optionalAccess', _171 => _171.data])) return;
|
|
6242
6460
|
const text = typeof result.data === "string" ? result.data : result.data.message || "";
|
|
6243
6461
|
console.log("[AutoInterface] Chat message complete, text (" + text.length + " chars):", text.substring(0, 300));
|
|
6244
6462
|
const parsed = parseInterfaceFromText(text);
|
|
@@ -6278,7 +6496,7 @@ function AutoInterface({
|
|
|
6278
6496
|
}).catch((err) => {
|
|
6279
6497
|
if (cancelled) return;
|
|
6280
6498
|
console.error("[AutoInterface] Initial generation failed:", err);
|
|
6281
|
-
_optionalChain([onError, 'optionalCall',
|
|
6499
|
+
_optionalChain([onError, 'optionalCall', _172 => _172(err instanceof Error ? err : new Error(String(err)))]);
|
|
6282
6500
|
setIsGenerating(false);
|
|
6283
6501
|
});
|
|
6284
6502
|
return () => {
|
|
@@ -6444,7 +6662,7 @@ function useInterfaceAI({
|
|
|
6444
6662
|
}
|
|
6445
6663
|
const sendMessage = _react.useCallback.call(void 0, async (message) => {
|
|
6446
6664
|
accumulatedTextRef.current = "";
|
|
6447
|
-
_optionalChain([onStreamStart, 'optionalCall',
|
|
6665
|
+
_optionalChain([onStreamStart, 'optionalCall', _173 => _173()]);
|
|
6448
6666
|
const systemPrompt = [
|
|
6449
6667
|
generateInterfaceContext(),
|
|
6450
6668
|
context || ""
|
|
@@ -6467,27 +6685,27 @@ function useInterfaceAI({
|
|
|
6467
6685
|
accumulatedTextRef.current += chunk.content || "";
|
|
6468
6686
|
const parsed = parseInterfaceFromText(accumulatedTextRef.current);
|
|
6469
6687
|
if (parsed) {
|
|
6470
|
-
_optionalChain([onInterface, 'optionalCall',
|
|
6688
|
+
_optionalChain([onInterface, 'optionalCall', _174 => _174(parsed)]);
|
|
6471
6689
|
}
|
|
6472
6690
|
const updates = parseUpdatesFromText(accumulatedTextRef.current);
|
|
6473
6691
|
if (updates.length > 0) {
|
|
6474
|
-
_optionalChain([onUpdates, 'optionalCall',
|
|
6692
|
+
_optionalChain([onUpdates, 'optionalCall', _175 => _175(updates)]);
|
|
6475
6693
|
}
|
|
6476
6694
|
}
|
|
6477
6695
|
},
|
|
6478
6696
|
// onComplete
|
|
6479
6697
|
() => {
|
|
6480
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6698
|
+
_optionalChain([onStreamEnd, 'optionalCall', _176 => _176()]);
|
|
6481
6699
|
},
|
|
6482
6700
|
// onError
|
|
6483
6701
|
(error) => {
|
|
6484
|
-
_optionalChain([onError, 'optionalCall',
|
|
6485
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6702
|
+
_optionalChain([onError, 'optionalCall', _177 => _177(error)]);
|
|
6703
|
+
_optionalChain([onStreamEnd, 'optionalCall', _178 => _178()]);
|
|
6486
6704
|
}
|
|
6487
6705
|
);
|
|
6488
6706
|
} catch (error) {
|
|
6489
|
-
_optionalChain([onError, 'optionalCall',
|
|
6490
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6707
|
+
_optionalChain([onError, 'optionalCall', _179 => _179(error instanceof Error ? error : new Error("Unknown error"))]);
|
|
6708
|
+
_optionalChain([onStreamEnd, 'optionalCall', _180 => _180()]);
|
|
6491
6709
|
}
|
|
6492
6710
|
}, [agentId, context, onInterface, onUpdates, onError, onStreamStart, onStreamEnd]);
|
|
6493
6711
|
return {
|