@apteva/apteva-kit 0.1.110 → 0.1.112
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 +405 -132
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +338 -65
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1439,7 +1439,273 @@ function Table({ widget, onAction }) {
|
|
|
1439
1439
|
|
|
1440
1440
|
// src/components/Widgets/widget-library/Form.tsx
|
|
1441
1441
|
|
|
1442
|
-
|
|
1442
|
+
var _reactdom = require('react-dom');
|
|
1443
|
+
|
|
1444
|
+
function PortalDropdown({
|
|
1445
|
+
anchorRef,
|
|
1446
|
+
open,
|
|
1447
|
+
onClose,
|
|
1448
|
+
width,
|
|
1449
|
+
children
|
|
1450
|
+
}) {
|
|
1451
|
+
const dropdownRef = _react.useRef.call(void 0, null);
|
|
1452
|
+
const [pos, setPos] = _react.useState.call(void 0, { top: 0, left: 0, width: 0 });
|
|
1453
|
+
_react.useEffect.call(void 0, () => {
|
|
1454
|
+
if (!open || !anchorRef.current) return;
|
|
1455
|
+
const update = () => {
|
|
1456
|
+
const rect = anchorRef.current.getBoundingClientRect();
|
|
1457
|
+
setPos({
|
|
1458
|
+
top: rect.bottom + window.scrollY + 4,
|
|
1459
|
+
left: rect.left + window.scrollX,
|
|
1460
|
+
width: rect.width
|
|
1461
|
+
});
|
|
1462
|
+
};
|
|
1463
|
+
update();
|
|
1464
|
+
window.addEventListener("scroll", update, true);
|
|
1465
|
+
window.addEventListener("resize", update);
|
|
1466
|
+
return () => {
|
|
1467
|
+
window.removeEventListener("scroll", update, true);
|
|
1468
|
+
window.removeEventListener("resize", update);
|
|
1469
|
+
};
|
|
1470
|
+
}, [open, anchorRef]);
|
|
1471
|
+
_react.useEffect.call(void 0, () => {
|
|
1472
|
+
if (!open) return;
|
|
1473
|
+
const handler = (e) => {
|
|
1474
|
+
const target = e.target;
|
|
1475
|
+
if (dropdownRef.current && !dropdownRef.current.contains(target) && anchorRef.current && !anchorRef.current.contains(target)) {
|
|
1476
|
+
onClose();
|
|
1477
|
+
}
|
|
1478
|
+
};
|
|
1479
|
+
document.addEventListener("mousedown", handler);
|
|
1480
|
+
return () => document.removeEventListener("mousedown", handler);
|
|
1481
|
+
}, [open, onClose, anchorRef]);
|
|
1482
|
+
_react.useEffect.call(void 0, () => {
|
|
1483
|
+
if (!open) return;
|
|
1484
|
+
const handler = (e) => {
|
|
1485
|
+
if (e.key === "Escape") onClose();
|
|
1486
|
+
};
|
|
1487
|
+
document.addEventListener("keydown", handler);
|
|
1488
|
+
return () => document.removeEventListener("keydown", handler);
|
|
1489
|
+
}, [open, onClose]);
|
|
1490
|
+
if (!open) return null;
|
|
1491
|
+
return _reactdom.createPortal.call(void 0,
|
|
1492
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1493
|
+
"div",
|
|
1494
|
+
{
|
|
1495
|
+
ref: dropdownRef,
|
|
1496
|
+
className: "apteva-widget",
|
|
1497
|
+
style: {
|
|
1498
|
+
position: "absolute",
|
|
1499
|
+
top: pos.top,
|
|
1500
|
+
left: pos.left,
|
|
1501
|
+
width: width === "match" ? pos.width : void 0,
|
|
1502
|
+
zIndex: 99999
|
|
1503
|
+
},
|
|
1504
|
+
children
|
|
1505
|
+
}
|
|
1506
|
+
),
|
|
1507
|
+
document.body
|
|
1508
|
+
);
|
|
1509
|
+
}
|
|
1510
|
+
function CustomSelect({
|
|
1511
|
+
name,
|
|
1512
|
+
value,
|
|
1513
|
+
options,
|
|
1514
|
+
placeholder,
|
|
1515
|
+
required,
|
|
1516
|
+
onChange
|
|
1517
|
+
}) {
|
|
1518
|
+
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
1519
|
+
const triggerRef = _react.useRef.call(void 0, null);
|
|
1520
|
+
const selected = _optionalChain([options, 'optionalAccess', _18 => _18.find, 'call', _19 => _19((o) => o.value === value)]);
|
|
1521
|
+
const close = _react.useCallback.call(void 0, () => setOpen(false), []);
|
|
1522
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-select relative", children: [
|
|
1523
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1524
|
+
"select",
|
|
1525
|
+
{
|
|
1526
|
+
name,
|
|
1527
|
+
value,
|
|
1528
|
+
required,
|
|
1529
|
+
onChange: () => {
|
|
1530
|
+
},
|
|
1531
|
+
tabIndex: -1,
|
|
1532
|
+
className: "absolute inset-0 opacity-0 pointer-events-none",
|
|
1533
|
+
"aria-hidden": true,
|
|
1534
|
+
children: [
|
|
1535
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: "" }),
|
|
1536
|
+
_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))])
|
|
1537
|
+
]
|
|
1538
|
+
}
|
|
1539
|
+
),
|
|
1540
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1541
|
+
"button",
|
|
1542
|
+
{
|
|
1543
|
+
ref: triggerRef,
|
|
1544
|
+
type: "button",
|
|
1545
|
+
onClick: () => setOpen(!open),
|
|
1546
|
+
className: "apteva-select-trigger w-full flex items-center justify-between px-3 py-2 rounded-lg border transition-colors text-left",
|
|
1547
|
+
children: [
|
|
1548
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: selected ? "apteva-select-value" : "apteva-select-placeholder", children: selected ? selected.label : placeholder || "Select..." }),
|
|
1549
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1550
|
+
"svg",
|
|
1551
|
+
{
|
|
1552
|
+
className: `apteva-select-chevron w-4 h-4 flex-shrink-0 transition-transform ${open ? "rotate-180" : ""}`,
|
|
1553
|
+
fill: "none",
|
|
1554
|
+
stroke: "currentColor",
|
|
1555
|
+
viewBox: "0 0 24 24",
|
|
1556
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" })
|
|
1557
|
+
}
|
|
1558
|
+
)
|
|
1559
|
+
]
|
|
1560
|
+
}
|
|
1561
|
+
),
|
|
1562
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, PortalDropdown, { anchorRef: triggerRef, open, onClose: close, width: "match", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "apteva-select-dropdown 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: [
|
|
1563
|
+
_optionalChain([options, 'optionalAccess', _22 => _22.map, 'call', _23 => _23((opt) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1564
|
+
"button",
|
|
1565
|
+
{
|
|
1566
|
+
type: "button",
|
|
1567
|
+
onClick: () => {
|
|
1568
|
+
onChange(opt.value);
|
|
1569
|
+
close();
|
|
1570
|
+
},
|
|
1571
|
+
className: `apteva-select-option w-full text-left px-3 py-2 text-sm transition-colors ${opt.value === value ? "apteva-select-option-active" : ""}`,
|
|
1572
|
+
children: opt.label
|
|
1573
|
+
},
|
|
1574
|
+
opt.value
|
|
1575
|
+
))]),
|
|
1576
|
+
(!options || options.length === 0) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "px-3 py-2 text-sm apteva-select-placeholder", children: "No options" })
|
|
1577
|
+
] }) }) })
|
|
1578
|
+
] });
|
|
1579
|
+
}
|
|
1580
|
+
function CustomDatePicker({
|
|
1581
|
+
name,
|
|
1582
|
+
value,
|
|
1583
|
+
placeholder,
|
|
1584
|
+
required,
|
|
1585
|
+
onChange
|
|
1586
|
+
}) {
|
|
1587
|
+
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
1588
|
+
const triggerRef = _react.useRef.call(void 0, null);
|
|
1589
|
+
const close = _react.useCallback.call(void 0, () => setOpen(false), []);
|
|
1590
|
+
const parseDate = (v) => {
|
|
1591
|
+
if (v) {
|
|
1592
|
+
const [y, m, d] = v.split("-").map(Number);
|
|
1593
|
+
return { year: y, month: m - 1, day: d };
|
|
1594
|
+
}
|
|
1595
|
+
const now = /* @__PURE__ */ new Date();
|
|
1596
|
+
return { year: now.getFullYear(), month: now.getMonth(), day: 0 };
|
|
1597
|
+
};
|
|
1598
|
+
const parsed = parseDate(value);
|
|
1599
|
+
const [viewYear, setViewYear] = _react.useState.call(void 0, parsed.year);
|
|
1600
|
+
const [viewMonth, setViewMonth] = _react.useState.call(void 0, parsed.month);
|
|
1601
|
+
_react.useEffect.call(void 0, () => {
|
|
1602
|
+
if (value) {
|
|
1603
|
+
const p = parseDate(value);
|
|
1604
|
+
setViewYear(p.year);
|
|
1605
|
+
setViewMonth(p.month);
|
|
1606
|
+
}
|
|
1607
|
+
}, [value]);
|
|
1608
|
+
const daysInMonth = new Date(viewYear, viewMonth + 1, 0).getDate();
|
|
1609
|
+
const firstDayOfWeek = new Date(viewYear, viewMonth, 1).getDay();
|
|
1610
|
+
const startOffset = (firstDayOfWeek + 6) % 7;
|
|
1611
|
+
const prevMonth = () => {
|
|
1612
|
+
if (viewMonth === 0) {
|
|
1613
|
+
setViewMonth(11);
|
|
1614
|
+
setViewYear(viewYear - 1);
|
|
1615
|
+
} else setViewMonth(viewMonth - 1);
|
|
1616
|
+
};
|
|
1617
|
+
const nextMonth = () => {
|
|
1618
|
+
if (viewMonth === 11) {
|
|
1619
|
+
setViewMonth(0);
|
|
1620
|
+
setViewYear(viewYear + 1);
|
|
1621
|
+
} else setViewMonth(viewMonth + 1);
|
|
1622
|
+
};
|
|
1623
|
+
const selectDay = (day) => {
|
|
1624
|
+
const m = String(viewMonth + 1).padStart(2, "0");
|
|
1625
|
+
const d = String(day).padStart(2, "0");
|
|
1626
|
+
onChange(`${viewYear}-${m}-${d}`);
|
|
1627
|
+
close();
|
|
1628
|
+
};
|
|
1629
|
+
const formatDisplay = (v) => {
|
|
1630
|
+
if (!v) return "";
|
|
1631
|
+
const [y, m, d] = v.split("-");
|
|
1632
|
+
return `${d}/${m}/${y}`;
|
|
1633
|
+
};
|
|
1634
|
+
const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
1635
|
+
const dayLabels = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];
|
|
1636
|
+
const isSelected = (day) => {
|
|
1637
|
+
if (!value) return false;
|
|
1638
|
+
const p = parseDate(value);
|
|
1639
|
+
return p.year === viewYear && p.month === viewMonth && p.day === day;
|
|
1640
|
+
};
|
|
1641
|
+
const isToday = (day) => {
|
|
1642
|
+
const now = /* @__PURE__ */ new Date();
|
|
1643
|
+
return now.getFullYear() === viewYear && now.getMonth() === viewMonth && now.getDate() === day;
|
|
1644
|
+
};
|
|
1645
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-datepicker relative", children: [
|
|
1646
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1647
|
+
"input",
|
|
1648
|
+
{
|
|
1649
|
+
type: "text",
|
|
1650
|
+
name,
|
|
1651
|
+
value,
|
|
1652
|
+
required,
|
|
1653
|
+
onChange: () => {
|
|
1654
|
+
},
|
|
1655
|
+
tabIndex: -1,
|
|
1656
|
+
className: "absolute inset-0 opacity-0 pointer-events-none",
|
|
1657
|
+
"aria-hidden": true
|
|
1658
|
+
}
|
|
1659
|
+
),
|
|
1660
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1661
|
+
"button",
|
|
1662
|
+
{
|
|
1663
|
+
ref: triggerRef,
|
|
1664
|
+
type: "button",
|
|
1665
|
+
onClick: () => setOpen(!open),
|
|
1666
|
+
className: "apteva-datepicker-trigger w-full flex items-center justify-between px-3 py-2 rounded-lg border transition-colors text-left",
|
|
1667
|
+
children: [
|
|
1668
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: value ? "apteva-datepicker-value" : "apteva-select-placeholder", children: value ? formatDisplay(value) : placeholder || "Select date..." }),
|
|
1669
|
+
/* @__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" }) })
|
|
1670
|
+
]
|
|
1671
|
+
}
|
|
1672
|
+
),
|
|
1673
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, PortalDropdown, { anchorRef: triggerRef, open, onClose: close, width: "auto", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-datepicker-dropdown rounded-lg border shadow-lg overflow-hidden", children: [
|
|
1674
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "apteva-datepicker-header flex items-center justify-between px-3 py-2", children: [
|
|
1675
|
+
/* @__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" }) }) }),
|
|
1676
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "apteva-datepicker-title text-sm font-semibold", children: [
|
|
1677
|
+
monthNames[viewMonth],
|
|
1678
|
+
" ",
|
|
1679
|
+
viewYear
|
|
1680
|
+
] }),
|
|
1681
|
+
/* @__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" }) }) })
|
|
1682
|
+
] }),
|
|
1683
|
+
/* @__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)) }),
|
|
1684
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "grid grid-cols-7 px-2 pb-2", children: [
|
|
1685
|
+
Array.from({ length: startOffset }).map((_, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {}, `empty-${i}`)),
|
|
1686
|
+
Array.from({ length: daysInMonth }).map((_, i) => {
|
|
1687
|
+
const day = i + 1;
|
|
1688
|
+
const sel = isSelected(day);
|
|
1689
|
+
const today = isToday(day);
|
|
1690
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1691
|
+
"button",
|
|
1692
|
+
{
|
|
1693
|
+
type: "button",
|
|
1694
|
+
onClick: () => selectDay(day),
|
|
1695
|
+
className: [
|
|
1696
|
+
"apteva-datepicker-day text-center text-sm py-1 rounded transition-colors",
|
|
1697
|
+
sel ? "apteva-datepicker-day-selected" : "",
|
|
1698
|
+
today && !sel ? "apteva-datepicker-day-today" : ""
|
|
1699
|
+
].join(" "),
|
|
1700
|
+
children: day
|
|
1701
|
+
},
|
|
1702
|
+
day
|
|
1703
|
+
);
|
|
1704
|
+
})
|
|
1705
|
+
] })
|
|
1706
|
+
] }) })
|
|
1707
|
+
] });
|
|
1708
|
+
}
|
|
1443
1709
|
function Form({ widget, onAction }) {
|
|
1444
1710
|
const { title, fields } = widget.props;
|
|
1445
1711
|
const fileInputRefs = _react.useRef.call(void 0, {});
|
|
@@ -1454,12 +1720,12 @@ function Form({ widget, onAction }) {
|
|
|
1454
1720
|
});
|
|
1455
1721
|
return initial;
|
|
1456
1722
|
});
|
|
1457
|
-
const handleChange = (name, value) => {
|
|
1723
|
+
const handleChange = _react.useCallback.call(void 0, (name, value) => {
|
|
1458
1724
|
setFormData((prev) => ({ ...prev, [name]: value }));
|
|
1459
|
-
};
|
|
1725
|
+
}, []);
|
|
1460
1726
|
const handleSubmit = (e) => {
|
|
1461
1727
|
e.preventDefault();
|
|
1462
|
-
if (_optionalChain([widget, 'access',
|
|
1728
|
+
if (_optionalChain([widget, 'access', _24 => _24.actions, 'optionalAccess', _25 => _25[0]]) && onAction) {
|
|
1463
1729
|
onAction({
|
|
1464
1730
|
type: widget.actions[0].type,
|
|
1465
1731
|
payload: { ...widget.actions[0].payload, formData },
|
|
@@ -1469,12 +1735,11 @@ function Form({ widget, onAction }) {
|
|
|
1469
1735
|
}
|
|
1470
1736
|
};
|
|
1471
1737
|
const renderField = (field) => {
|
|
1472
|
-
const baseInputClass = "w-full px-3 py-2 rounded-lg border transition-colors
|
|
1738
|
+
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
1739
|
switch (field.type) {
|
|
1474
1740
|
case "text":
|
|
1475
1741
|
case "password":
|
|
1476
1742
|
case "number":
|
|
1477
|
-
case "date":
|
|
1478
1743
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1479
1744
|
"input",
|
|
1480
1745
|
{
|
|
@@ -1487,6 +1752,17 @@ function Form({ widget, onAction }) {
|
|
|
1487
1752
|
className: baseInputClass
|
|
1488
1753
|
}
|
|
1489
1754
|
);
|
|
1755
|
+
case "date":
|
|
1756
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1757
|
+
CustomDatePicker,
|
|
1758
|
+
{
|
|
1759
|
+
name: field.name,
|
|
1760
|
+
value: formData[field.name] || "",
|
|
1761
|
+
placeholder: field.placeholder,
|
|
1762
|
+
required: field.required,
|
|
1763
|
+
onChange: (v) => handleChange(field.name, v)
|
|
1764
|
+
}
|
|
1765
|
+
);
|
|
1490
1766
|
case "textarea":
|
|
1491
1767
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1492
1768
|
"textarea",
|
|
@@ -1501,22 +1777,19 @@ function Form({ widget, onAction }) {
|
|
|
1501
1777
|
}
|
|
1502
1778
|
);
|
|
1503
1779
|
case "select":
|
|
1504
|
-
return /* @__PURE__ */ _jsxruntime.
|
|
1505
|
-
|
|
1780
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1781
|
+
CustomSelect,
|
|
1506
1782
|
{
|
|
1507
1783
|
name: field.name,
|
|
1508
1784
|
value: formData[field.name] || "",
|
|
1509
|
-
|
|
1785
|
+
options: field.options,
|
|
1786
|
+
placeholder: field.placeholder,
|
|
1510
1787
|
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
|
-
]
|
|
1788
|
+
onChange: (v) => handleChange(field.name, v)
|
|
1516
1789
|
}
|
|
1517
1790
|
);
|
|
1518
1791
|
case "checkbox":
|
|
1519
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "flex items-center gap-2 cursor-pointer", children: [
|
|
1792
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "apteva-checkbox flex items-center gap-2 cursor-pointer", children: [
|
|
1520
1793
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1521
1794
|
"input",
|
|
1522
1795
|
{
|
|
@@ -1524,10 +1797,10 @@ function Form({ widget, onAction }) {
|
|
|
1524
1797
|
name: field.name,
|
|
1525
1798
|
checked: formData[field.name] || false,
|
|
1526
1799
|
onChange: (e) => handleChange(field.name, e.target.checked),
|
|
1527
|
-
className: "w-4 h-4 rounded
|
|
1800
|
+
className: "w-4 h-4 rounded"
|
|
1528
1801
|
}
|
|
1529
1802
|
),
|
|
1530
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", {
|
|
1803
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: field.label })
|
|
1531
1804
|
] });
|
|
1532
1805
|
case "file": {
|
|
1533
1806
|
const files = formData[field.name] || [];
|
|
@@ -1560,19 +1833,19 @@ function Form({ widget, onAction }) {
|
|
|
1560
1833
|
"button",
|
|
1561
1834
|
{
|
|
1562
1835
|
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
|
|
1836
|
+
onClick: () => _optionalChain([fileInputRefs, 'access', _26 => _26.current, 'access', _27 => _27[field.name], 'optionalAccess', _28 => _28.click, 'call', _29 => _29()]),
|
|
1837
|
+
className: "apteva-file-drop w-full px-3 py-3 rounded-lg border-2 border-dashed transition-colors cursor-pointer !text-sm",
|
|
1565
1838
|
children: field.placeholder || "Click to add files"
|
|
1566
1839
|
}
|
|
1567
1840
|
),
|
|
1568
1841
|
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
1842
|
"li",
|
|
1570
1843
|
{
|
|
1571
|
-
className: "apteva-file-item-row flex items-center justify-between px-2 py-1.5 rounded-lg
|
|
1844
|
+
className: "apteva-file-item-row flex items-center justify-between px-2 py-1.5 rounded-lg !text-sm",
|
|
1572
1845
|
children: [
|
|
1573
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "
|
|
1846
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "truncate mr-2", children: [
|
|
1574
1847
|
file.name,
|
|
1575
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "
|
|
1848
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "ml-1", style: { opacity: 0.6 }, children: [
|
|
1576
1849
|
"(",
|
|
1577
1850
|
(file.size / 1024).toFixed(0),
|
|
1578
1851
|
" KB)"
|
|
@@ -1583,7 +1856,7 @@ function Form({ widget, onAction }) {
|
|
|
1583
1856
|
{
|
|
1584
1857
|
type: "button",
|
|
1585
1858
|
onClick: () => handleChange(field.name, files.filter((_, i) => i !== idx)),
|
|
1586
|
-
className: "apteva-file-remove-btn
|
|
1859
|
+
className: "apteva-file-remove-btn transition-colors flex-shrink-0",
|
|
1587
1860
|
children: "\u2715"
|
|
1588
1861
|
}
|
|
1589
1862
|
)
|
|
@@ -1597,14 +1870,14 @@ function Form({ widget, onAction }) {
|
|
|
1597
1870
|
return null;
|
|
1598
1871
|
}
|
|
1599
1872
|
};
|
|
1600
|
-
const submitAction = _optionalChain([widget, 'access',
|
|
1601
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: handleSubmit, className: "border
|
|
1873
|
+
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]]);
|
|
1874
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit: handleSubmit, className: "border rounded-xl overflow-hidden", children: [
|
|
1602
1875
|
/* @__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
|
|
1876
|
+
title && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "!text-lg font-semibold mb-4", children: title }),
|
|
1604
1877
|
/* @__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
|
|
1878
|
+
field.type !== "checkbox" && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { className: "apteva-field-label block !text-sm font-medium", children: [
|
|
1606
1879
|
field.label,
|
|
1607
|
-
field.required && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", {
|
|
1880
|
+
field.required && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { color: "var(--aw-danger)" }, className: "ml-1", children: "*" })
|
|
1608
1881
|
] }),
|
|
1609
1882
|
renderField(field)
|
|
1610
1883
|
] }, field.name)) })
|
|
@@ -1613,7 +1886,7 @@ function Form({ widget, onAction }) {
|
|
|
1613
1886
|
"button",
|
|
1614
1887
|
{
|
|
1615
1888
|
type: "submit",
|
|
1616
|
-
className: "px-3 py-1.5 !text-sm rounded-lg font-medium transition-colors
|
|
1889
|
+
className: "px-3 py-1.5 !text-sm rounded-lg font-medium transition-colors",
|
|
1617
1890
|
children: submitAction.label || "Submit"
|
|
1618
1891
|
}
|
|
1619
1892
|
) })
|
|
@@ -1657,7 +1930,7 @@ function StepIcon({ type, status }) {
|
|
|
1657
1930
|
if (type === "recurring" || type === "repeat") {
|
|
1658
1931
|
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
1932
|
}
|
|
1660
|
-
if (type === "agent" || _optionalChain([type, 'optionalAccess',
|
|
1933
|
+
if (type === "agent" || _optionalChain([type, 'optionalAccess', _35 => _35.startsWith, 'call', _36 => _36("@")])) {
|
|
1661
1934
|
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
1935
|
}
|
|
1663
1936
|
if (type === "email" || type === "mail") {
|
|
@@ -1753,7 +2026,7 @@ function getStepColorClass(step, stepType) {
|
|
|
1753
2026
|
if (stepType === "time" || stepType === "schedule" || stepType === "clock") {
|
|
1754
2027
|
return STEP_COLOR_CLASSES.blue;
|
|
1755
2028
|
}
|
|
1756
|
-
if (stepType === "agent" || _optionalChain([stepType, 'optionalAccess',
|
|
2029
|
+
if (stepType === "agent" || _optionalChain([stepType, 'optionalAccess', _37 => _37.startsWith, 'call', _38 => _38("@")])) {
|
|
1757
2030
|
return STEP_COLOR_CLASSES.purple;
|
|
1758
2031
|
}
|
|
1759
2032
|
if (stepType === "email" || stepType === "slack" || stepType === "message" || stepType === "notification") {
|
|
@@ -1870,7 +2143,7 @@ function Kpi({ widget, onAction }) {
|
|
|
1870
2143
|
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
2144
|
"button",
|
|
1872
2145
|
{
|
|
1873
|
-
onClick: () => _optionalChain([onAction, 'optionalCall',
|
|
2146
|
+
onClick: () => _optionalChain([onAction, 'optionalCall', _39 => _39({
|
|
1874
2147
|
type: action.type,
|
|
1875
2148
|
payload: action.payload,
|
|
1876
2149
|
widgetId: widget.id,
|
|
@@ -1997,7 +2270,7 @@ function LiveView({ widget }) {
|
|
|
1997
2270
|
setRefreshKey((k) => k + 1);
|
|
1998
2271
|
}, []);
|
|
1999
2272
|
const handleFullscreen = _react.useCallback.call(void 0, () => {
|
|
2000
|
-
_optionalChain([iframeRef, 'access',
|
|
2273
|
+
_optionalChain([iframeRef, 'access', _40 => _40.current, 'optionalAccess', _41 => _41.requestFullscreen, 'optionalCall', _42 => _42()]);
|
|
2001
2274
|
}, []);
|
|
2002
2275
|
const handleOpenExternal = _react.useCallback.call(void 0, () => {
|
|
2003
2276
|
window.open(src, "_blank", "noopener,noreferrer");
|
|
@@ -2152,7 +2425,7 @@ function Widgets({
|
|
|
2152
2425
|
}) {
|
|
2153
2426
|
_react.useEffect.call(void 0, () => {
|
|
2154
2427
|
widgets.forEach((widget) => {
|
|
2155
|
-
_optionalChain([onWidgetMount, 'optionalCall',
|
|
2428
|
+
_optionalChain([onWidgetMount, 'optionalCall', _43 => _43(widget.id)]);
|
|
2156
2429
|
});
|
|
2157
2430
|
}, [widgets, onWidgetMount]);
|
|
2158
2431
|
const layoutClasses = {
|
|
@@ -2563,8 +2836,8 @@ function PersistentWidgetRef({ widget }) {
|
|
|
2563
2836
|
|
|
2564
2837
|
function Message({ message, onAction, enableWidgets, onWidgetRender, persistentWidgetIds, toolCallStyle = "card" }) {
|
|
2565
2838
|
const isUser = message.role === "user";
|
|
2566
|
-
const contentSegments = _optionalChain([message, 'access',
|
|
2567
|
-
const isStreaming = _optionalChain([message, 'access',
|
|
2839
|
+
const contentSegments = _optionalChain([message, 'access', _44 => _44.metadata, 'optionalAccess', _45 => _45.content_segments]);
|
|
2840
|
+
const isStreaming = _optionalChain([message, 'access', _46 => _46.metadata, 'optionalAccess', _47 => _47.isStreaming]) === true;
|
|
2568
2841
|
const hasContent = message.content || contentSegments && contentSegments.length > 0;
|
|
2569
2842
|
const reportedWidgetsRef = _react.useRef.call(void 0, /* @__PURE__ */ new Set());
|
|
2570
2843
|
const parsedWidgets = _react.useMemo.call(void 0, () => {
|
|
@@ -2644,7 +2917,7 @@ function Message({ message, onAction, enableWidgets, onWidgetRender, persistentW
|
|
|
2644
2917
|
}
|
|
2645
2918
|
return elements.length > 0 ? elements : null;
|
|
2646
2919
|
};
|
|
2647
|
-
const attachments = _optionalChain([message, 'access',
|
|
2920
|
+
const attachments = _optionalChain([message, 'access', _48 => _48.metadata, 'optionalAccess', _49 => _49.attachments]) || [];
|
|
2648
2921
|
const hasAttachments = attachments.length > 0;
|
|
2649
2922
|
const renderAttachments = () => {
|
|
2650
2923
|
if (!hasAttachments) return null;
|
|
@@ -2825,8 +3098,8 @@ function Message({ message, onAction, enableWidgets, onWidgetRender, persistentW
|
|
|
2825
3098
|
};
|
|
2826
3099
|
const renderMessageWidgets = () => {
|
|
2827
3100
|
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',
|
|
3101
|
+
const inlineWidgets = message.widgets.filter((w) => !_optionalChain([persistentWidgetIds, 'optionalAccess', _50 => _50.has, 'call', _51 => _51(w.id)]));
|
|
3102
|
+
const persistentRefs = message.widgets.filter((w) => _optionalChain([persistentWidgetIds, 'optionalAccess', _52 => _52.has, 'call', _53 => _53(w.id)]));
|
|
2830
3103
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2831
3104
|
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
3105
|
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 +3406,7 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
3133
3406
|
setFileError(errors.join(", "));
|
|
3134
3407
|
setTimeout(() => setFileError(null), 5e3);
|
|
3135
3408
|
}
|
|
3136
|
-
_optionalChain([onFileUpload, 'optionalCall',
|
|
3409
|
+
_optionalChain([onFileUpload, 'optionalCall', _54 => _54(e.target.files)]);
|
|
3137
3410
|
setShowMenu(false);
|
|
3138
3411
|
e.target.value = "";
|
|
3139
3412
|
}
|
|
@@ -3205,15 +3478,15 @@ function Composer({ onSendMessage, placeholder = "Type a message...", disabled =
|
|
|
3205
3478
|
{
|
|
3206
3479
|
className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
3207
3480
|
style: {
|
|
3208
|
-
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
3209
|
-
bottom: window.innerHeight - (_nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
3481
|
+
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _55 => _55.current, 'optionalAccess', _56 => _56.getBoundingClientRect, 'call', _57 => _57(), 'access', _58 => _58.left]), () => ( 0)),
|
|
3482
|
+
bottom: window.innerHeight - (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.getBoundingClientRect, 'call', _61 => _61(), 'access', _62 => _62.top]), () => ( 0))) + 8
|
|
3210
3483
|
},
|
|
3211
3484
|
children: [
|
|
3212
3485
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3213
3486
|
"button",
|
|
3214
3487
|
{
|
|
3215
3488
|
onClick: () => {
|
|
3216
|
-
_optionalChain([fileInputRef, 'access',
|
|
3489
|
+
_optionalChain([fileInputRef, 'access', _63 => _63.current, 'optionalAccess', _64 => _64.click, 'call', _65 => _65()]);
|
|
3217
3490
|
setShowMenu(false);
|
|
3218
3491
|
},
|
|
3219
3492
|
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 +3607,8 @@ function CommandComposer({
|
|
|
3334
3607
|
}
|
|
3335
3608
|
};
|
|
3336
3609
|
const handleNewCommand = () => {
|
|
3337
|
-
_optionalChain([onReset, 'optionalCall',
|
|
3338
|
-
_optionalChain([inputRef, 'access',
|
|
3610
|
+
_optionalChain([onReset, 'optionalCall', _66 => _66()]);
|
|
3611
|
+
_optionalChain([inputRef, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.focus, 'call', _69 => _69()]);
|
|
3339
3612
|
};
|
|
3340
3613
|
const handleInputChange = (value) => {
|
|
3341
3614
|
setInput(value);
|
|
@@ -3449,15 +3722,15 @@ function CommandComposer({
|
|
|
3449
3722
|
{
|
|
3450
3723
|
className: "apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",
|
|
3451
3724
|
style: {
|
|
3452
|
-
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
3453
|
-
top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access',
|
|
3725
|
+
left: _nullishCoalesce(_optionalChain([menuButtonRef, 'access', _70 => _70.current, 'optionalAccess', _71 => _71.getBoundingClientRect, 'call', _72 => _72(), 'access', _73 => _73.left]), () => ( 0)),
|
|
3726
|
+
top: (_nullishCoalesce(_optionalChain([menuButtonRef, 'access', _74 => _74.current, 'optionalAccess', _75 => _75.getBoundingClientRect, 'call', _76 => _76(), 'access', _77 => _77.bottom]), () => ( 0))) + 8
|
|
3454
3727
|
},
|
|
3455
3728
|
children: [
|
|
3456
3729
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3457
3730
|
"button",
|
|
3458
3731
|
{
|
|
3459
3732
|
onClick: () => {
|
|
3460
|
-
_optionalChain([fileInputRef, 'access',
|
|
3733
|
+
_optionalChain([fileInputRef, 'access', _78 => _78.current, 'optionalAccess', _79 => _79.click, 'call', _80 => _80()]);
|
|
3461
3734
|
setShowMenu(false);
|
|
3462
3735
|
},
|
|
3463
3736
|
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 +3883,8 @@ var AptevaClient = class {
|
|
|
3610
3883
|
constructor(config) {
|
|
3611
3884
|
__publicField(this, "config");
|
|
3612
3885
|
this.config = {
|
|
3613
|
-
apiUrl: _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
3614
|
-
apiKey: _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
3886
|
+
apiUrl: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _81 => _81.apiUrl]), () => ( "")),
|
|
3887
|
+
apiKey: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _82 => _82.apiKey]), () => ( ""))
|
|
3615
3888
|
};
|
|
3616
3889
|
}
|
|
3617
3890
|
/**
|
|
@@ -3688,7 +3961,7 @@ var AptevaClient = class {
|
|
|
3688
3961
|
const error = await response.json().catch(() => ({ error: "Request failed" }));
|
|
3689
3962
|
throw new Error(error.error || `Request failed with status ${response.status}`);
|
|
3690
3963
|
}
|
|
3691
|
-
const reader = _optionalChain([response, 'access',
|
|
3964
|
+
const reader = _optionalChain([response, 'access', _83 => _83.body, 'optionalAccess', _84 => _84.getReader, 'call', _85 => _85()]);
|
|
3692
3965
|
if (!reader) {
|
|
3693
3966
|
throw new Error("Response body is not readable");
|
|
3694
3967
|
}
|
|
@@ -3706,7 +3979,7 @@ var AptevaClient = class {
|
|
|
3706
3979
|
if (line.startsWith("data: ")) {
|
|
3707
3980
|
const data = line.slice(6);
|
|
3708
3981
|
if (data === "[DONE]") {
|
|
3709
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3982
|
+
_optionalChain([onComplete, 'optionalCall', _86 => _86(threadId)]);
|
|
3710
3983
|
return;
|
|
3711
3984
|
}
|
|
3712
3985
|
try {
|
|
@@ -3721,10 +3994,10 @@ var AptevaClient = class {
|
|
|
3721
3994
|
}
|
|
3722
3995
|
}
|
|
3723
3996
|
}
|
|
3724
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
3997
|
+
_optionalChain([onComplete, 'optionalCall', _87 => _87(threadId)]);
|
|
3725
3998
|
} catch (error) {
|
|
3726
3999
|
const err = error instanceof Error ? error : new Error("Unknown error");
|
|
3727
|
-
_optionalChain([onError, 'optionalCall',
|
|
4000
|
+
_optionalChain([onError, 'optionalCall', _88 => _88(err)]);
|
|
3728
4001
|
throw err;
|
|
3729
4002
|
}
|
|
3730
4003
|
}
|
|
@@ -3947,7 +4220,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3947
4220
|
}, [apiUrl, apiKey]);
|
|
3948
4221
|
_react.useEffect.call(void 0, () => {
|
|
3949
4222
|
if (threadId) {
|
|
3950
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4223
|
+
_optionalChain([onThreadChange, 'optionalCall', _89 => _89(threadId)]);
|
|
3951
4224
|
}
|
|
3952
4225
|
}, [threadId, onThreadChange]);
|
|
3953
4226
|
_react.useEffect.call(void 0, () => {
|
|
@@ -3965,7 +4238,7 @@ ${widgetContext}` : widgetContext;
|
|
|
3965
4238
|
}, [showSettingsMenu]);
|
|
3966
4239
|
const handleModeChange = (newMode) => {
|
|
3967
4240
|
setMode(newMode);
|
|
3968
|
-
_optionalChain([onModeChange, 'optionalCall',
|
|
4241
|
+
_optionalChain([onModeChange, 'optionalCall', _90 => _90(newMode)]);
|
|
3969
4242
|
if (newMode === "command") {
|
|
3970
4243
|
setCommandState("idle");
|
|
3971
4244
|
setCommandResult(null);
|
|
@@ -3974,8 +4247,8 @@ ${widgetContext}` : widgetContext;
|
|
|
3974
4247
|
};
|
|
3975
4248
|
const defaultPlaceholder = mode === "chat" ? "Type a message..." : "Enter your command...";
|
|
3976
4249
|
const handleWidgetAction = _react.useCallback.call(void 0, (action) => {
|
|
3977
|
-
_optionalChain([onAction, 'optionalCall',
|
|
3978
|
-
if (action.type === "submit" && _optionalChain([action, 'access',
|
|
4250
|
+
_optionalChain([onAction, 'optionalCall', _91 => _91(action)]);
|
|
4251
|
+
if (action.type === "submit" && _optionalChain([action, 'access', _92 => _92.payload, 'optionalAccess', _93 => _93.formData])) {
|
|
3979
4252
|
const formData = action.payload.formData;
|
|
3980
4253
|
const lines = [];
|
|
3981
4254
|
for (const [key, value] of Object.entries(formData)) {
|
|
@@ -4014,7 +4287,7 @@ ${widgetContext}` : widgetContext;
|
|
|
4014
4287
|
metadata: hasFiles ? { attachments } : void 0
|
|
4015
4288
|
};
|
|
4016
4289
|
setMessages((prev) => [...prev, userMessage]);
|
|
4017
|
-
_optionalChain([onMessageSent, 'optionalCall',
|
|
4290
|
+
_optionalChain([onMessageSent, 'optionalCall', _94 => _94(userMessage)]);
|
|
4018
4291
|
}
|
|
4019
4292
|
setIsLoading(true);
|
|
4020
4293
|
try {
|
|
@@ -4082,7 +4355,7 @@ ${widgetContext}` : widgetContext;
|
|
|
4082
4355
|
responseThreadId = chunk.thread_id;
|
|
4083
4356
|
if (!currentThreadId) {
|
|
4084
4357
|
setCurrentThreadId(chunk.thread_id);
|
|
4085
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4358
|
+
_optionalChain([onThreadChange, 'optionalCall', _95 => _95(chunk.thread_id)]);
|
|
4086
4359
|
}
|
|
4087
4360
|
}
|
|
4088
4361
|
break;
|
|
@@ -4114,7 +4387,7 @@ ${widgetContext}` : widgetContext;
|
|
|
4114
4387
|
contentSegments.push({ type: "tool", id: chunk.tool_id, name: displayName, status: "preparing" });
|
|
4115
4388
|
toolInputBuffers[chunk.tool_id] = "";
|
|
4116
4389
|
setChatToolName(displayName);
|
|
4117
|
-
_optionalChain([onToolCall, 'optionalCall',
|
|
4390
|
+
_optionalChain([onToolCall, 'optionalCall', _96 => _96(chunk.tool_name, chunk.tool_id)]);
|
|
4118
4391
|
updateMessage();
|
|
4119
4392
|
}
|
|
4120
4393
|
break;
|
|
@@ -4174,7 +4447,7 @@ ${widgetContext}` : widgetContext;
|
|
|
4174
4447
|
toolSegment.result = chunk.content;
|
|
4175
4448
|
toolSegment.status = "completed";
|
|
4176
4449
|
toolSegment.isReceiving = false;
|
|
4177
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
4450
|
+
_optionalChain([onToolResult, 'optionalCall', _97 => _97(toolSegment.name, chunk.content)]);
|
|
4178
4451
|
}
|
|
4179
4452
|
setChatToolName(null);
|
|
4180
4453
|
updateMessage();
|
|
@@ -4218,7 +4491,7 @@ ${widgetContext}` : widgetContext;
|
|
|
4218
4491
|
});
|
|
4219
4492
|
if (threadId2 && threadId2 !== currentThreadId) {
|
|
4220
4493
|
setCurrentThreadId(threadId2);
|
|
4221
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4494
|
+
_optionalChain([onThreadChange, 'optionalCall', _98 => _98(threadId2)]);
|
|
4222
4495
|
}
|
|
4223
4496
|
setIsLoading(false);
|
|
4224
4497
|
setCurrentRequestId(null);
|
|
@@ -4242,7 +4515,7 @@ ${widgetContext}` : widgetContext;
|
|
|
4242
4515
|
setIsLoading(false);
|
|
4243
4516
|
setCurrentRequestId(null);
|
|
4244
4517
|
setChatToolName(null);
|
|
4245
|
-
_optionalChain([onError, 'optionalCall',
|
|
4518
|
+
_optionalChain([onError, 'optionalCall', _99 => _99(error)]);
|
|
4246
4519
|
}
|
|
4247
4520
|
);
|
|
4248
4521
|
}
|
|
@@ -4255,7 +4528,7 @@ ${widgetContext}` : widgetContext;
|
|
|
4255
4528
|
metadata: { error: true }
|
|
4256
4529
|
};
|
|
4257
4530
|
setMessages((prev) => [...prev, errorMessage]);
|
|
4258
|
-
_optionalChain([onError, 'optionalCall',
|
|
4531
|
+
_optionalChain([onError, 'optionalCall', _100 => _100(error instanceof Error ? error : new Error("Unknown error"))]);
|
|
4259
4532
|
} finally {
|
|
4260
4533
|
setIsLoading(false);
|
|
4261
4534
|
}
|
|
@@ -4301,7 +4574,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4301
4574
|
const error = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
4302
4575
|
setCommandError(error);
|
|
4303
4576
|
setCommandState("error");
|
|
4304
|
-
_optionalChain([onError, 'optionalCall',
|
|
4577
|
+
_optionalChain([onError, 'optionalCall', _101 => _101(error)]);
|
|
4305
4578
|
}
|
|
4306
4579
|
}
|
|
4307
4580
|
return;
|
|
@@ -4334,12 +4607,12 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4334
4607
|
setCommandResult(result);
|
|
4335
4608
|
setCommandState("success");
|
|
4336
4609
|
setProgress(100);
|
|
4337
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4610
|
+
_optionalChain([onComplete, 'optionalCall', _102 => _102(result)]);
|
|
4338
4611
|
},
|
|
4339
4612
|
(error) => {
|
|
4340
4613
|
setCommandError(error);
|
|
4341
4614
|
setCommandState("error");
|
|
4342
|
-
_optionalChain([onError, 'optionalCall',
|
|
4615
|
+
_optionalChain([onError, 'optionalCall', _103 => _103(error)]);
|
|
4343
4616
|
}
|
|
4344
4617
|
);
|
|
4345
4618
|
} else {
|
|
@@ -4352,7 +4625,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4352
4625
|
setCommandResult(result);
|
|
4353
4626
|
setCommandState("success");
|
|
4354
4627
|
setProgress(100);
|
|
4355
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4628
|
+
_optionalChain([onComplete, 'optionalCall', _104 => _104(result)]);
|
|
4356
4629
|
}
|
|
4357
4630
|
} else {
|
|
4358
4631
|
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 +4655,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4382
4655
|
const displayName = chunk.tool_display_name || chunk.tool_name;
|
|
4383
4656
|
lastToolName = chunk.tool_name;
|
|
4384
4657
|
setCurrentToolName(displayName);
|
|
4385
|
-
_optionalChain([onToolCall, 'optionalCall',
|
|
4658
|
+
_optionalChain([onToolCall, 'optionalCall', _105 => _105(chunk.tool_name, chunk.tool_id || "")]);
|
|
4386
4659
|
accumulatedContent = "";
|
|
4387
4660
|
setStreamedContent("");
|
|
4388
4661
|
} else if (chunk.type === "tool_result") {
|
|
4389
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
4662
|
+
_optionalChain([onToolResult, 'optionalCall', _106 => _106(lastToolName, chunk.content)]);
|
|
4390
4663
|
setCurrentToolName(null);
|
|
4391
4664
|
} else if (chunk.type === "thread_id" && chunk.thread_id) {
|
|
4392
4665
|
if (!currentThreadId) {
|
|
4393
4666
|
setCurrentThreadId(chunk.thread_id);
|
|
4394
|
-
_optionalChain([onThreadChange, 'optionalCall',
|
|
4667
|
+
_optionalChain([onThreadChange, 'optionalCall', _107 => _107(chunk.thread_id)]);
|
|
4395
4668
|
}
|
|
4396
4669
|
} else if (chunk.type === "request_id" && chunk.request_id) {
|
|
4397
4670
|
setCurrentRequestId(chunk.request_id);
|
|
@@ -4407,13 +4680,13 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4407
4680
|
setCommandState("success");
|
|
4408
4681
|
setProgress(100);
|
|
4409
4682
|
setCurrentRequestId(null);
|
|
4410
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4683
|
+
_optionalChain([onComplete, 'optionalCall', _108 => _108(result)]);
|
|
4411
4684
|
},
|
|
4412
4685
|
(error) => {
|
|
4413
4686
|
setCommandError(error);
|
|
4414
4687
|
setCommandState("error");
|
|
4415
4688
|
setCurrentRequestId(null);
|
|
4416
|
-
_optionalChain([onError, 'optionalCall',
|
|
4689
|
+
_optionalChain([onError, 'optionalCall', _109 => _109(error)]);
|
|
4417
4690
|
}
|
|
4418
4691
|
);
|
|
4419
4692
|
} else {
|
|
@@ -4433,14 +4706,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4433
4706
|
setCommandResult(result);
|
|
4434
4707
|
setCommandState("success");
|
|
4435
4708
|
setProgress(100);
|
|
4436
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
4709
|
+
_optionalChain([onComplete, 'optionalCall', _110 => _110(result)]);
|
|
4437
4710
|
}
|
|
4438
4711
|
}
|
|
4439
4712
|
} catch (err) {
|
|
4440
4713
|
const error = err instanceof Error ? err : new Error("Unknown error");
|
|
4441
4714
|
setCommandError(error);
|
|
4442
4715
|
setCommandState("error");
|
|
4443
|
-
_optionalChain([onError, 'optionalCall',
|
|
4716
|
+
_optionalChain([onError, 'optionalCall', _111 => _111(error)]);
|
|
4444
4717
|
}
|
|
4445
4718
|
};
|
|
4446
4719
|
const resetCommand = () => {
|
|
@@ -4539,8 +4812,8 @@ ${planToExecute}`;
|
|
|
4539
4812
|
executeCommand(text, files);
|
|
4540
4813
|
},
|
|
4541
4814
|
state: commandState,
|
|
4542
|
-
response: _optionalChain([commandResult, 'optionalAccess',
|
|
4543
|
-
error: _optionalChain([commandError, 'optionalAccess',
|
|
4815
|
+
response: _optionalChain([commandResult, 'optionalAccess', _112 => _112.data, 'optionalAccess', _113 => _113.summary]) || _optionalChain([commandResult, 'optionalAccess', _114 => _114.message]),
|
|
4816
|
+
error: _optionalChain([commandError, 'optionalAccess', _115 => _115.message]),
|
|
4544
4817
|
plan,
|
|
4545
4818
|
streamedContent,
|
|
4546
4819
|
toolName: currentToolName,
|
|
@@ -4708,13 +4981,13 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4708
4981
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
4709
4982
|
setError(error2);
|
|
4710
4983
|
setState("error");
|
|
4711
|
-
_optionalChain([onError, 'optionalCall',
|
|
4984
|
+
_optionalChain([onError, 'optionalCall', _116 => _116(error2)]);
|
|
4712
4985
|
});
|
|
4713
4986
|
} catch (err) {
|
|
4714
4987
|
const error2 = err instanceof Error ? err : new Error("Failed to generate plan");
|
|
4715
4988
|
setError(error2);
|
|
4716
4989
|
setState("error");
|
|
4717
|
-
_optionalChain([onError, 'optionalCall',
|
|
4990
|
+
_optionalChain([onError, 'optionalCall', _117 => _117(error2)]);
|
|
4718
4991
|
}
|
|
4719
4992
|
}
|
|
4720
4993
|
return;
|
|
@@ -4725,7 +4998,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4725
4998
|
setStreamedContent("");
|
|
4726
4999
|
setCommand("");
|
|
4727
5000
|
setUploadedFiles([]);
|
|
4728
|
-
_optionalChain([onStart, 'optionalCall',
|
|
5001
|
+
_optionalChain([onStart, 'optionalCall', _118 => _118()]);
|
|
4729
5002
|
try {
|
|
4730
5003
|
if (useMock) {
|
|
4731
5004
|
if (enableStreaming) {
|
|
@@ -4736,16 +5009,16 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4736
5009
|
if (chunk.type === "token" && chunk.content) {
|
|
4737
5010
|
accumulatedContent += chunk.content;
|
|
4738
5011
|
setStreamedContent(accumulatedContent);
|
|
4739
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
5012
|
+
_optionalChain([onChunk, 'optionalCall', _119 => _119(chunk.content)]);
|
|
4740
5013
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
4741
5014
|
setProgress(estimatedProgress);
|
|
4742
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
5015
|
+
_optionalChain([onProgress, 'optionalCall', _120 => _120(estimatedProgress)]);
|
|
4743
5016
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
4744
5017
|
const widget = chunk.widget;
|
|
4745
5018
|
setResult((prev) => ({
|
|
4746
5019
|
success: true,
|
|
4747
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
4748
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
5020
|
+
data: _optionalChain([prev, 'optionalAccess', _121 => _121.data]) || {},
|
|
5021
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _122 => _122.widgets]) || [], widget],
|
|
4749
5022
|
message: accumulatedContent || "Command executed successfully"
|
|
4750
5023
|
}));
|
|
4751
5024
|
}
|
|
@@ -4765,19 +5038,19 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4765
5038
|
setResult(result2);
|
|
4766
5039
|
setState("success");
|
|
4767
5040
|
setProgress(100);
|
|
4768
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5041
|
+
_optionalChain([onComplete, 'optionalCall', _123 => _123(result2)]);
|
|
4769
5042
|
},
|
|
4770
5043
|
(error2) => {
|
|
4771
5044
|
setError(error2);
|
|
4772
5045
|
setState("error");
|
|
4773
|
-
_optionalChain([onError, 'optionalCall',
|
|
5046
|
+
_optionalChain([onError, 'optionalCall', _124 => _124(error2)]);
|
|
4774
5047
|
}
|
|
4775
5048
|
);
|
|
4776
5049
|
} else {
|
|
4777
5050
|
const progressInterval = setInterval(() => {
|
|
4778
5051
|
setProgress((prev) => {
|
|
4779
5052
|
const next = Math.min(prev + 10, 90);
|
|
4780
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
5053
|
+
_optionalChain([onProgress, 'optionalCall', _125 => _125(next)]);
|
|
4781
5054
|
return next;
|
|
4782
5055
|
});
|
|
4783
5056
|
}, 200);
|
|
@@ -4801,7 +5074,7 @@ ${planningInstruction}` : planningInstruction;
|
|
|
4801
5074
|
setResult(result2);
|
|
4802
5075
|
setState("success");
|
|
4803
5076
|
setProgress(100);
|
|
4804
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5077
|
+
_optionalChain([onComplete, 'optionalCall', _126 => _126(result2)]);
|
|
4805
5078
|
}
|
|
4806
5079
|
} else {
|
|
4807
5080
|
if (enableStreaming) {
|
|
@@ -4847,16 +5120,16 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4847
5120
|
if (chunk.type === "token" && chunk.content) {
|
|
4848
5121
|
accumulatedContent += chunk.content;
|
|
4849
5122
|
setStreamedContent(accumulatedContent);
|
|
4850
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
5123
|
+
_optionalChain([onChunk, 'optionalCall', _127 => _127(chunk.content)]);
|
|
4851
5124
|
const estimatedProgress = Math.min(Math.round(accumulatedContent.length / 10), 90);
|
|
4852
5125
|
setProgress(estimatedProgress);
|
|
4853
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
5126
|
+
_optionalChain([onProgress, 'optionalCall', _128 => _128(estimatedProgress)]);
|
|
4854
5127
|
} else if (chunk.type === "widget" && chunk.widget) {
|
|
4855
5128
|
const widget = chunk.widget;
|
|
4856
5129
|
setResult((prev) => ({
|
|
4857
5130
|
success: true,
|
|
4858
|
-
data: _optionalChain([prev, 'optionalAccess',
|
|
4859
|
-
widgets: [..._optionalChain([prev, 'optionalAccess',
|
|
5131
|
+
data: _optionalChain([prev, 'optionalAccess', _129 => _129.data]) || {},
|
|
5132
|
+
widgets: [..._optionalChain([prev, 'optionalAccess', _130 => _130.widgets]) || [], widget],
|
|
4860
5133
|
message: accumulatedContent || "Command executed successfully"
|
|
4861
5134
|
}));
|
|
4862
5135
|
}
|
|
@@ -4876,20 +5149,20 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4876
5149
|
setResult(result2);
|
|
4877
5150
|
setState("success");
|
|
4878
5151
|
setProgress(100);
|
|
4879
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5152
|
+
_optionalChain([onComplete, 'optionalCall', _131 => _131(result2)]);
|
|
4880
5153
|
},
|
|
4881
5154
|
(error2) => {
|
|
4882
5155
|
const err = error2 instanceof Error ? error2 : new Error("Unknown error");
|
|
4883
5156
|
setError(err);
|
|
4884
5157
|
setState("error");
|
|
4885
|
-
_optionalChain([onError, 'optionalCall',
|
|
5158
|
+
_optionalChain([onError, 'optionalCall', _132 => _132(err)]);
|
|
4886
5159
|
}
|
|
4887
5160
|
);
|
|
4888
5161
|
} else {
|
|
4889
5162
|
const progressInterval = setInterval(() => {
|
|
4890
5163
|
setProgress((prev) => {
|
|
4891
5164
|
const next = Math.min(prev + 10, 90);
|
|
4892
|
-
_optionalChain([onProgress, 'optionalCall',
|
|
5165
|
+
_optionalChain([onProgress, 'optionalCall', _133 => _133(next)]);
|
|
4893
5166
|
return next;
|
|
4894
5167
|
});
|
|
4895
5168
|
}, 200);
|
|
@@ -4945,14 +5218,14 @@ ${commandInstruction}` : commandInstruction;
|
|
|
4945
5218
|
setResult(result2);
|
|
4946
5219
|
setState("success");
|
|
4947
5220
|
setProgress(100);
|
|
4948
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5221
|
+
_optionalChain([onComplete, 'optionalCall', _134 => _134(result2)]);
|
|
4949
5222
|
}
|
|
4950
5223
|
}
|
|
4951
5224
|
} catch (err) {
|
|
4952
5225
|
const error2 = err instanceof Error ? err : new Error("Unknown error");
|
|
4953
5226
|
setError(error2);
|
|
4954
5227
|
setState("error");
|
|
4955
|
-
_optionalChain([onError, 'optionalCall',
|
|
5228
|
+
_optionalChain([onError, 'optionalCall', _135 => _135(error2)]);
|
|
4956
5229
|
}
|
|
4957
5230
|
};
|
|
4958
5231
|
const resetCommand = () => {
|
|
@@ -4985,14 +5258,14 @@ ${planToExecute}`;
|
|
|
4985
5258
|
};
|
|
4986
5259
|
const handleFileSelect = async (e) => {
|
|
4987
5260
|
if (e.target.files && e.target.files.length > 0) {
|
|
4988
|
-
_optionalChain([onFileUpload, 'optionalCall',
|
|
5261
|
+
_optionalChain([onFileUpload, 'optionalCall', _136 => _136(e.target.files)]);
|
|
4989
5262
|
const files = [];
|
|
4990
5263
|
for (let i = 0; i < e.target.files.length; i++) {
|
|
4991
5264
|
const file = e.target.files[i];
|
|
4992
5265
|
const reader = new FileReader();
|
|
4993
5266
|
await new Promise((resolve) => {
|
|
4994
5267
|
reader.onload = (event) => {
|
|
4995
|
-
if (_optionalChain([event, 'access',
|
|
5268
|
+
if (_optionalChain([event, 'access', _137 => _137.target, 'optionalAccess', _138 => _138.result])) {
|
|
4996
5269
|
const fullDataUrl = event.target.result;
|
|
4997
5270
|
const base64Data = fullDataUrl.split(",")[1];
|
|
4998
5271
|
if (file.type.startsWith("image/")) {
|
|
@@ -5086,7 +5359,7 @@ ${planToExecute}`;
|
|
|
5086
5359
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5087
5360
|
"button",
|
|
5088
5361
|
{
|
|
5089
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
5362
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _139 => _139.current, 'optionalAccess', _140 => _140.click, 'call', _141 => _141()]),
|
|
5090
5363
|
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
5364
|
title: "Attach file",
|
|
5092
5365
|
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 +5578,7 @@ ${planToExecute}`;
|
|
|
5305
5578
|
/* @__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
5579
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
5307
5580
|
/* @__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',
|
|
5581
|
+
/* @__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
5582
|
] })
|
|
5310
5583
|
] }) }),
|
|
5311
5584
|
allowInput && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -5333,7 +5606,7 @@ ${planToExecute}`;
|
|
|
5333
5606
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-green-700 dark:text-green-300 text-sm", children: "Command executed successfully" })
|
|
5334
5607
|
] })
|
|
5335
5608
|
] }),
|
|
5336
|
-
_optionalChain([result, 'access',
|
|
5609
|
+
_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
5610
|
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
5611
|
WidgetRenderer,
|
|
5339
5612
|
{
|
|
@@ -5384,7 +5657,7 @@ ${planToExecute}`;
|
|
|
5384
5657
|
enableFileUpload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5385
5658
|
"button",
|
|
5386
5659
|
{
|
|
5387
|
-
onClick: () => _optionalChain([fileInputRef, 'access',
|
|
5660
|
+
onClick: () => _optionalChain([fileInputRef, 'access', _145 => _145.current, 'optionalAccess', _146 => _146.click, 'call', _147 => _147()]),
|
|
5388
5661
|
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
5662
|
title: "Attach file",
|
|
5390
5663
|
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 +5843,25 @@ function Prompt({
|
|
|
5570
5843
|
const newValue = e.target.value;
|
|
5571
5844
|
if (!maxLength || newValue.length <= maxLength) {
|
|
5572
5845
|
setValue(newValue);
|
|
5573
|
-
_optionalChain([onChange, 'optionalCall',
|
|
5846
|
+
_optionalChain([onChange, 'optionalCall', _148 => _148(newValue)]);
|
|
5574
5847
|
}
|
|
5575
5848
|
};
|
|
5576
5849
|
const handleSubmit = async () => {
|
|
5577
5850
|
if (value.length < minLength) return;
|
|
5578
|
-
_optionalChain([onSubmit, 'optionalCall',
|
|
5851
|
+
_optionalChain([onSubmit, 'optionalCall', _149 => _149(value)]);
|
|
5579
5852
|
setIsLoading(true);
|
|
5580
5853
|
try {
|
|
5581
5854
|
if (useMock) {
|
|
5582
5855
|
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
5583
5856
|
const mockResult = `Enhanced version: ${value} [AI-generated content]`;
|
|
5584
|
-
_optionalChain([onResult, 'optionalCall',
|
|
5857
|
+
_optionalChain([onResult, 'optionalCall', _150 => _150(mockResult)]);
|
|
5585
5858
|
setValue("");
|
|
5586
5859
|
} else {
|
|
5587
5860
|
const response = await aptevaClient.chat({
|
|
5588
5861
|
agent_id: agentId,
|
|
5589
5862
|
message: value
|
|
5590
5863
|
});
|
|
5591
|
-
_optionalChain([onResult, 'optionalCall',
|
|
5864
|
+
_optionalChain([onResult, 'optionalCall', _151 => _151(response.message)]);
|
|
5592
5865
|
setValue("");
|
|
5593
5866
|
}
|
|
5594
5867
|
} catch (error) {
|
|
@@ -5683,7 +5956,7 @@ function Stream({
|
|
|
5683
5956
|
}, [autoStart]);
|
|
5684
5957
|
const startStreaming = async () => {
|
|
5685
5958
|
setIsStreaming(true);
|
|
5686
|
-
_optionalChain([onStart, 'optionalCall',
|
|
5959
|
+
_optionalChain([onStart, 'optionalCall', _152 => _152()]);
|
|
5687
5960
|
try {
|
|
5688
5961
|
if (useMock) {
|
|
5689
5962
|
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 +5964,13 @@ function Stream({
|
|
|
5691
5964
|
mockText,
|
|
5692
5965
|
(chunk) => {
|
|
5693
5966
|
setText((prev) => prev + chunk);
|
|
5694
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
5967
|
+
_optionalChain([onChunk, 'optionalCall', _153 => _153(chunk)]);
|
|
5695
5968
|
},
|
|
5696
5969
|
typingSpeed
|
|
5697
5970
|
);
|
|
5698
5971
|
setIsComplete(true);
|
|
5699
5972
|
setIsStreaming(false);
|
|
5700
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5973
|
+
_optionalChain([onComplete, 'optionalCall', _154 => _154(text + mockText)]);
|
|
5701
5974
|
} else {
|
|
5702
5975
|
let accumulatedText = "";
|
|
5703
5976
|
await aptevaClient.chatStream(
|
|
@@ -5710,24 +5983,24 @@ function Stream({
|
|
|
5710
5983
|
if (chunk.type === "token" && chunk.content) {
|
|
5711
5984
|
accumulatedText += chunk.content;
|
|
5712
5985
|
setText(accumulatedText);
|
|
5713
|
-
_optionalChain([onChunk, 'optionalCall',
|
|
5986
|
+
_optionalChain([onChunk, 'optionalCall', _155 => _155(chunk.content)]);
|
|
5714
5987
|
}
|
|
5715
5988
|
},
|
|
5716
5989
|
() => {
|
|
5717
5990
|
setIsComplete(true);
|
|
5718
5991
|
setIsStreaming(false);
|
|
5719
|
-
_optionalChain([onComplete, 'optionalCall',
|
|
5992
|
+
_optionalChain([onComplete, 'optionalCall', _156 => _156(accumulatedText)]);
|
|
5720
5993
|
},
|
|
5721
5994
|
(error) => {
|
|
5722
5995
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
5723
|
-
_optionalChain([onError, 'optionalCall',
|
|
5996
|
+
_optionalChain([onError, 'optionalCall', _157 => _157(err)]);
|
|
5724
5997
|
setIsStreaming(false);
|
|
5725
5998
|
}
|
|
5726
5999
|
);
|
|
5727
6000
|
}
|
|
5728
6001
|
} catch (error) {
|
|
5729
6002
|
const err = error instanceof Error ? error : new Error("Streaming error");
|
|
5730
|
-
_optionalChain([onError, 'optionalCall',
|
|
6003
|
+
_optionalChain([onError, 'optionalCall', _158 => _158(err)]);
|
|
5731
6004
|
setIsStreaming(false);
|
|
5732
6005
|
}
|
|
5733
6006
|
};
|
|
@@ -5819,7 +6092,7 @@ function ThreadList({
|
|
|
5819
6092
|
}) {
|
|
5820
6093
|
const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
|
|
5821
6094
|
const filteredThreads = threads.filter(
|
|
5822
|
-
(thread) => thread.title.toLowerCase().includes(searchQuery.toLowerCase()) || _optionalChain([thread, 'access',
|
|
6095
|
+
(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
6096
|
);
|
|
5824
6097
|
const groupedThreads = groupBy === "date" ? groupThreadsByDate(filteredThreads) : { All: filteredThreads };
|
|
5825
6098
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col h-full", children: [
|
|
@@ -5841,8 +6114,8 @@ function ThreadList({
|
|
|
5841
6114
|
{
|
|
5842
6115
|
thread,
|
|
5843
6116
|
isActive: thread.id === currentThreadId,
|
|
5844
|
-
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
5845
|
-
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall',
|
|
6117
|
+
onSelect: () => _optionalChain([onThreadSelect, 'optionalCall', _164 => _164(thread.id)]),
|
|
6118
|
+
onDelete: () => _optionalChain([onThreadDelete, 'optionalCall', _165 => _165(thread.id)])
|
|
5846
6119
|
},
|
|
5847
6120
|
thread.id
|
|
5848
6121
|
))
|
|
@@ -5904,7 +6177,7 @@ function Threads({
|
|
|
5904
6177
|
threads.slice(0, 5).map((thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5905
6178
|
"button",
|
|
5906
6179
|
{
|
|
5907
|
-
onClick: () => _optionalChain([onThreadSelect, 'optionalCall',
|
|
6180
|
+
onClick: () => _optionalChain([onThreadSelect, 'optionalCall', _166 => _166(thread.id)]),
|
|
5908
6181
|
className: cn(
|
|
5909
6182
|
"px-4 py-2 whitespace-nowrap font-medium transition-colors",
|
|
5910
6183
|
thread.id === currentThreadId ? "border-b-2 border-apteva-500 text-apteva-500" : "text-neutral-600 hover:text-neutral-900"
|
|
@@ -6089,7 +6362,7 @@ function TabsLayout({ node, renderNode }) {
|
|
|
6089
6362
|
var STRUCTURAL_KEYS = /* @__PURE__ */ new Set(["type", "id", "layout", "props", "children", "actions", "metadata", "isStreaming"]);
|
|
6090
6363
|
function normalizeNode(n) {
|
|
6091
6364
|
let node = { ...n };
|
|
6092
|
-
if (node.type === "widget" && _optionalChain([node, 'access',
|
|
6365
|
+
if (node.type === "widget" && _optionalChain([node, 'access', _167 => _167.props, 'optionalAccess', _168 => _168.widget])) {
|
|
6093
6366
|
node.type = node.props.widget;
|
|
6094
6367
|
const { widget: _, ...rest } = node.props;
|
|
6095
6368
|
node.props = rest;
|
|
@@ -6227,10 +6500,10 @@ function AutoInterface({
|
|
|
6227
6500
|
].filter(Boolean).join("\n\n");
|
|
6228
6501
|
const updateInterface = _react.useCallback.call(void 0, (newSpec) => {
|
|
6229
6502
|
setInterfaceSpec(newSpec);
|
|
6230
|
-
_optionalChain([onInterfaceChange, 'optionalCall',
|
|
6503
|
+
_optionalChain([onInterfaceChange, 'optionalCall', _169 => _169(newSpec)]);
|
|
6231
6504
|
}, [onInterfaceChange]);
|
|
6232
6505
|
const handleAction = _react.useCallback.call(void 0, (action) => {
|
|
6233
|
-
_optionalChain([onAction, 'optionalCall',
|
|
6506
|
+
_optionalChain([onAction, 'optionalCall', _170 => _170(action)]);
|
|
6234
6507
|
if (chatRef.current) {
|
|
6235
6508
|
chatRef.current.sendMessage(
|
|
6236
6509
|
`[Action: ${action.type} on widget ${action.widgetId || "unknown"}. Payload: ${JSON.stringify(action.payload)}]`
|
|
@@ -6238,7 +6511,7 @@ function AutoInterface({
|
|
|
6238
6511
|
}
|
|
6239
6512
|
}, [onAction]);
|
|
6240
6513
|
const handleMessageComplete = _react.useCallback.call(void 0, (result) => {
|
|
6241
|
-
if (!_optionalChain([result, 'optionalAccess',
|
|
6514
|
+
if (!_optionalChain([result, 'optionalAccess', _171 => _171.data])) return;
|
|
6242
6515
|
const text = typeof result.data === "string" ? result.data : result.data.message || "";
|
|
6243
6516
|
console.log("[AutoInterface] Chat message complete, text (" + text.length + " chars):", text.substring(0, 300));
|
|
6244
6517
|
const parsed = parseInterfaceFromText(text);
|
|
@@ -6278,7 +6551,7 @@ function AutoInterface({
|
|
|
6278
6551
|
}).catch((err) => {
|
|
6279
6552
|
if (cancelled) return;
|
|
6280
6553
|
console.error("[AutoInterface] Initial generation failed:", err);
|
|
6281
|
-
_optionalChain([onError, 'optionalCall',
|
|
6554
|
+
_optionalChain([onError, 'optionalCall', _172 => _172(err instanceof Error ? err : new Error(String(err)))]);
|
|
6282
6555
|
setIsGenerating(false);
|
|
6283
6556
|
});
|
|
6284
6557
|
return () => {
|
|
@@ -6444,7 +6717,7 @@ function useInterfaceAI({
|
|
|
6444
6717
|
}
|
|
6445
6718
|
const sendMessage = _react.useCallback.call(void 0, async (message) => {
|
|
6446
6719
|
accumulatedTextRef.current = "";
|
|
6447
|
-
_optionalChain([onStreamStart, 'optionalCall',
|
|
6720
|
+
_optionalChain([onStreamStart, 'optionalCall', _173 => _173()]);
|
|
6448
6721
|
const systemPrompt = [
|
|
6449
6722
|
generateInterfaceContext(),
|
|
6450
6723
|
context || ""
|
|
@@ -6467,27 +6740,27 @@ function useInterfaceAI({
|
|
|
6467
6740
|
accumulatedTextRef.current += chunk.content || "";
|
|
6468
6741
|
const parsed = parseInterfaceFromText(accumulatedTextRef.current);
|
|
6469
6742
|
if (parsed) {
|
|
6470
|
-
_optionalChain([onInterface, 'optionalCall',
|
|
6743
|
+
_optionalChain([onInterface, 'optionalCall', _174 => _174(parsed)]);
|
|
6471
6744
|
}
|
|
6472
6745
|
const updates = parseUpdatesFromText(accumulatedTextRef.current);
|
|
6473
6746
|
if (updates.length > 0) {
|
|
6474
|
-
_optionalChain([onUpdates, 'optionalCall',
|
|
6747
|
+
_optionalChain([onUpdates, 'optionalCall', _175 => _175(updates)]);
|
|
6475
6748
|
}
|
|
6476
6749
|
}
|
|
6477
6750
|
},
|
|
6478
6751
|
// onComplete
|
|
6479
6752
|
() => {
|
|
6480
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6753
|
+
_optionalChain([onStreamEnd, 'optionalCall', _176 => _176()]);
|
|
6481
6754
|
},
|
|
6482
6755
|
// onError
|
|
6483
6756
|
(error) => {
|
|
6484
|
-
_optionalChain([onError, 'optionalCall',
|
|
6485
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6757
|
+
_optionalChain([onError, 'optionalCall', _177 => _177(error)]);
|
|
6758
|
+
_optionalChain([onStreamEnd, 'optionalCall', _178 => _178()]);
|
|
6486
6759
|
}
|
|
6487
6760
|
);
|
|
6488
6761
|
} catch (error) {
|
|
6489
|
-
_optionalChain([onError, 'optionalCall',
|
|
6490
|
-
_optionalChain([onStreamEnd, 'optionalCall',
|
|
6762
|
+
_optionalChain([onError, 'optionalCall', _179 => _179(error instanceof Error ? error : new Error("Unknown error"))]);
|
|
6763
|
+
_optionalChain([onStreamEnd, 'optionalCall', _180 => _180()]);
|
|
6491
6764
|
}
|
|
6492
6765
|
}, [agentId, context, onInterface, onUpdates, onError, onStreamStart, onStreamEnd]);
|
|
6493
6766
|
return {
|