aov-agent 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +250 -1
- package/dist/agent-ui/components/Assistant/AgentButton/AgentButton.js +28 -0
- package/dist/agent-ui/components/Assistant/AgentButton/AgentButton.scss +40 -0
- package/dist/agent-ui/components/Assistant/Assistant.js +73 -0
- package/dist/agent-ui/components/Assistant/Assistant.scss +3 -0
- package/dist/agent-ui/components/Assistant/AssistantWidget/AssistantWidget.js +187 -0
- package/dist/agent-ui/components/Assistant/AssistantWidget/AssistantWidget.scss +211 -0
- package/dist/agent-ui/components/Assistant/AssistantWidget/components/CampaignRendered.js +30 -0
- package/dist/agent-ui/components/Assistant/AssistantWidget/components/ListChat.js +129 -0
- package/dist/agent-ui/components/Assistant/Markdown/MarkdownText.js +228 -0
- package/dist/agent-ui/components/Assistant/Markdown/MarkdownText.scss +222 -0
- package/dist/agent-ui/components/Assistant/Markdown/MathRenderer.js +46 -0
- package/dist/agent-ui/components/Assistant/Suggestions/Suggestions.js +62 -0
- package/dist/agent-ui/components/Assistant/Suggestions/Suggestions.scss +22 -0
- package/dist/agent-ui/components/Assistant/ThreadProvider.js +482 -0
- package/dist/agent-ui/components/Assistant/ToolResult/CardTool.js +41 -0
- package/dist/agent-ui/components/Assistant/ToolResult/ToolResult.js +20 -0
- package/dist/agent-ui/components/ResizableModal/ResizableModal.js +262 -0
- package/dist/agent-ui/components/ResizableModal/ResizableModal.scss +117 -0
- package/dist/agent-ui/contexts/AgentContext.js +39 -0
- package/dist/agent-ui/contexts/SuggestionsContext.js +64 -0
- package/dist/agent-ui/contexts/ThreadContext.js +60 -0
- package/dist/agent-ui/hooks/useFetchApi.js +238 -0
- package/dist/agent-ui/hooks/useStreamApi.js +127 -0
- package/dist/agent-ui/index.js +1 -0
- package/dist/agent-ui/services/errorService.js +39 -0
- package/dist/agent-ui/utils/api.js +164 -0
- package/package.json +26 -9
- package/dist/index.js +0 -7
- package/types/index.d.ts +0 -5
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import React, { useEffect, useRef, useState, useCallback } from "react";
|
|
8
|
+
import { Portal } from "@shopify/polaris";
|
|
9
|
+
import PropTypes from "prop-types";
|
|
10
|
+
import "./ResizableModal.scss";
|
|
11
|
+
var MIN_WIDTH = 325;
|
|
12
|
+
var MIN_HEIGHT = 200;
|
|
13
|
+
var DEFAULT_WIDTH = 450;
|
|
14
|
+
var DEFAULT_HEIGHT = 400;
|
|
15
|
+
var MAX_WIDTH = 650;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* ResizableModal - A draggable and resizable modal component
|
|
19
|
+
*
|
|
20
|
+
* @param {boolean} open - Whether the modal is open
|
|
21
|
+
* @param {Function} onClose - Callback function when modal closes
|
|
22
|
+
* @param {string} accessibilityLabel - Accessibility label for screen readers
|
|
23
|
+
* @param {React.ReactNode} children - Modal content
|
|
24
|
+
* @param {boolean} disableClickOutsideClose - Disable closing when clicking outside
|
|
25
|
+
* @param {number} initialWidth - Initial width of modal
|
|
26
|
+
* @param {number} initialHeight - Initial height of modal
|
|
27
|
+
* @param {number} minWidth - Minimum width of modal
|
|
28
|
+
* @param {number} minHeight - Minimum height of modal
|
|
29
|
+
* @param {number} maxWidth - Maximum width of modal
|
|
30
|
+
* @returns {React.ReactElement|null} Resizable modal component
|
|
31
|
+
*/
|
|
32
|
+
var ResizableModal = function ResizableModal(_ref) {
|
|
33
|
+
var open = _ref.open,
|
|
34
|
+
onClose = _ref.onClose,
|
|
35
|
+
accessibilityLabel = _ref.accessibilityLabel,
|
|
36
|
+
children = _ref.children,
|
|
37
|
+
_ref$disableClickOuts = _ref.disableClickOutsideClose,
|
|
38
|
+
disableClickOutsideClose = _ref$disableClickOuts === void 0 ? false : _ref$disableClickOuts,
|
|
39
|
+
_ref$initialWidth = _ref.initialWidth,
|
|
40
|
+
initialWidth = _ref$initialWidth === void 0 ? DEFAULT_WIDTH : _ref$initialWidth,
|
|
41
|
+
_ref$initialHeight = _ref.initialHeight,
|
|
42
|
+
initialHeight = _ref$initialHeight === void 0 ? DEFAULT_HEIGHT : _ref$initialHeight,
|
|
43
|
+
_ref$minWidth = _ref.minWidth,
|
|
44
|
+
minWidth = _ref$minWidth === void 0 ? MIN_WIDTH : _ref$minWidth,
|
|
45
|
+
_ref$minHeight = _ref.minHeight,
|
|
46
|
+
minHeight = _ref$minHeight === void 0 ? MIN_HEIGHT : _ref$minHeight,
|
|
47
|
+
_ref$maxWidth = _ref.maxWidth,
|
|
48
|
+
maxWidth = _ref$maxWidth === void 0 ? MAX_WIDTH : _ref$maxWidth;
|
|
49
|
+
var modalRef = useRef(null);
|
|
50
|
+
var _useState = useState(false),
|
|
51
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
+
isClosing = _useState2[0],
|
|
53
|
+
setIsClosing = _useState2[1];
|
|
54
|
+
var _useState3 = useState(open),
|
|
55
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
56
|
+
isVisible = _useState4[0],
|
|
57
|
+
setIsVisible = _useState4[1];
|
|
58
|
+
var _useState5 = useState(false),
|
|
59
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
60
|
+
isDragging = _useState6[0],
|
|
61
|
+
setIsDragging = _useState6[1];
|
|
62
|
+
var _useState7 = useState(false),
|
|
63
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
64
|
+
isResizing = _useState8[0],
|
|
65
|
+
setIsResizing = _useState8[1];
|
|
66
|
+
var _useState9 = useState(""),
|
|
67
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
68
|
+
resizeDirection = _useState0[0],
|
|
69
|
+
setResizeDirection = _useState0[1];
|
|
70
|
+
var _useState1 = useState({
|
|
71
|
+
width: initialWidth,
|
|
72
|
+
height: initialHeight
|
|
73
|
+
}),
|
|
74
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
75
|
+
dimensions = _useState10[0],
|
|
76
|
+
setDimensions = _useState10[1];
|
|
77
|
+
var _useState11 = useState({
|
|
78
|
+
x: 0,
|
|
79
|
+
y: 0
|
|
80
|
+
}),
|
|
81
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
82
|
+
position = _useState12[0],
|
|
83
|
+
setPosition = _useState12[1];
|
|
84
|
+
var _useState13 = useState({
|
|
85
|
+
x: 0,
|
|
86
|
+
y: 0
|
|
87
|
+
}),
|
|
88
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
89
|
+
dragStart = _useState14[0],
|
|
90
|
+
setDragStart = _useState14[1];
|
|
91
|
+
useEffect(function () {
|
|
92
|
+
if (open) {
|
|
93
|
+
setIsVisible(true);
|
|
94
|
+
setIsClosing(false);
|
|
95
|
+
setPosition({
|
|
96
|
+
x: 0,
|
|
97
|
+
y: 0
|
|
98
|
+
});
|
|
99
|
+
setDimensions({
|
|
100
|
+
width: initialWidth,
|
|
101
|
+
height: window.innerHeight
|
|
102
|
+
});
|
|
103
|
+
} else if (isVisible) {
|
|
104
|
+
setIsClosing(true);
|
|
105
|
+
var timer = setTimeout(function () {
|
|
106
|
+
setIsVisible(false);
|
|
107
|
+
}, 200);
|
|
108
|
+
return function () {
|
|
109
|
+
return clearTimeout(timer);
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}, [open, isVisible, initialWidth]);
|
|
113
|
+
var handleMouseDown = useCallback(function (e, action) {
|
|
114
|
+
var direction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
if (action === "drag") {
|
|
117
|
+
setIsDragging(true);
|
|
118
|
+
setDragStart({
|
|
119
|
+
x: e.clientX - position.x,
|
|
120
|
+
y: e.clientY - position.y
|
|
121
|
+
});
|
|
122
|
+
} else if (action === "resize") {
|
|
123
|
+
setIsResizing(true);
|
|
124
|
+
setResizeDirection(direction);
|
|
125
|
+
}
|
|
126
|
+
}, [position]);
|
|
127
|
+
var handleMouseMove = useCallback(function (e) {
|
|
128
|
+
if (isDragging) {
|
|
129
|
+
var newX = Math.max(0, Math.min(window.innerWidth - dimensions.width, e.clientX - dragStart.x));
|
|
130
|
+
var newY = Math.max(0, Math.min(window.innerHeight - dimensions.height, e.clientY - dragStart.y));
|
|
131
|
+
setPosition({
|
|
132
|
+
x: newX,
|
|
133
|
+
y: newY
|
|
134
|
+
});
|
|
135
|
+
} else if (isResizing && modalRef.current) {
|
|
136
|
+
var rect = modalRef.current.getBoundingClientRect();
|
|
137
|
+
var newWidth = dimensions.width;
|
|
138
|
+
var newHeight = dimensions.height;
|
|
139
|
+
var _newX = position.x;
|
|
140
|
+
var _newY = position.y;
|
|
141
|
+
if (resizeDirection.includes("right")) {
|
|
142
|
+
newWidth = Math.max(minWidth, e.clientX - rect.left);
|
|
143
|
+
}
|
|
144
|
+
if (resizeDirection.includes("left")) {
|
|
145
|
+
var deltaX = rect.left - e.clientX;
|
|
146
|
+
newWidth = Math.max(minWidth, dimensions.width + deltaX);
|
|
147
|
+
if (newWidth > minWidth) {
|
|
148
|
+
_newX = e.clientX;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (resizeDirection.includes("bottom")) {
|
|
152
|
+
newHeight = Math.max(minHeight, e.clientY - rect.top);
|
|
153
|
+
}
|
|
154
|
+
if (resizeDirection.includes("top")) {
|
|
155
|
+
var deltaY = rect.top - e.clientY;
|
|
156
|
+
newHeight = Math.max(minHeight, dimensions.height + deltaY);
|
|
157
|
+
if (newHeight > minHeight) {
|
|
158
|
+
_newY = e.clientY;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (_newX + newWidth > window.innerWidth) {
|
|
162
|
+
newWidth = window.innerWidth - _newX;
|
|
163
|
+
}
|
|
164
|
+
newWidth = Math.min(newWidth, maxWidth);
|
|
165
|
+
if (_newY + newHeight > window.innerHeight) {
|
|
166
|
+
newHeight = window.innerHeight - _newY;
|
|
167
|
+
}
|
|
168
|
+
setDimensions({
|
|
169
|
+
width: newWidth,
|
|
170
|
+
height: newHeight
|
|
171
|
+
});
|
|
172
|
+
setPosition({
|
|
173
|
+
x: _newX,
|
|
174
|
+
y: _newY
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}, [isDragging, isResizing, dragStart, dimensions, position, resizeDirection, minWidth, minHeight, maxWidth]);
|
|
178
|
+
var handleMouseUp = useCallback(function () {
|
|
179
|
+
setIsDragging(false);
|
|
180
|
+
setIsResizing(false);
|
|
181
|
+
setResizeDirection("");
|
|
182
|
+
}, []);
|
|
183
|
+
useEffect(function () {
|
|
184
|
+
if (isDragging || isResizing) {
|
|
185
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
186
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
187
|
+
document.body.style.userSelect = "none";
|
|
188
|
+
}
|
|
189
|
+
return function () {
|
|
190
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
191
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
192
|
+
document.body.style.userSelect = "auto";
|
|
193
|
+
};
|
|
194
|
+
}, [isDragging, isResizing, handleMouseMove, handleMouseUp]);
|
|
195
|
+
var handleClose = useCallback(function () {
|
|
196
|
+
setIsClosing(true);
|
|
197
|
+
var timer = setTimeout(function () {
|
|
198
|
+
onClose();
|
|
199
|
+
}, 200);
|
|
200
|
+
return function () {
|
|
201
|
+
return clearTimeout(timer);
|
|
202
|
+
};
|
|
203
|
+
}, [onClose]);
|
|
204
|
+
useEffect(function () {
|
|
205
|
+
var handleEscapeKey = function handleEscapeKey(event) {
|
|
206
|
+
if (event.key === "Escape") {
|
|
207
|
+
handleClose();
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
if (open) {
|
|
211
|
+
document.addEventListener("keydown", handleEscapeKey);
|
|
212
|
+
document.body.style.overflow = "hidden";
|
|
213
|
+
}
|
|
214
|
+
return function () {
|
|
215
|
+
document.removeEventListener("keydown", handleEscapeKey);
|
|
216
|
+
document.body.style.overflow = "unset";
|
|
217
|
+
};
|
|
218
|
+
}, [open, handleClose]);
|
|
219
|
+
if (!isVisible) return null;
|
|
220
|
+
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement("div", {
|
|
221
|
+
className: "Avada-ResizableModal__Container"
|
|
222
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
223
|
+
className: "Avada-ResizableModal__Backdrop ".concat(isClosing ? "Avada-ResizableModal__Backdrop--closing" : ""),
|
|
224
|
+
onMouseDown: function onMouseDown() {
|
|
225
|
+
if (!disableClickOutsideClose) {
|
|
226
|
+
handleClose();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
230
|
+
ref: modalRef,
|
|
231
|
+
className: "Avada-ResizableModal__Content ".concat(isClosing ? "Avada-ResizableModal__Content--closing" : ""),
|
|
232
|
+
role: "dialog",
|
|
233
|
+
"aria-modal": "true",
|
|
234
|
+
"aria-label": accessibilityLabel,
|
|
235
|
+
style: {
|
|
236
|
+
width: dimensions.width,
|
|
237
|
+
height: dimensions.height,
|
|
238
|
+
left: position.x,
|
|
239
|
+
bottom: position.y
|
|
240
|
+
}
|
|
241
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
242
|
+
className: "Avada-ResizableModal__Body"
|
|
243
|
+
}, children), /*#__PURE__*/React.createElement("div", {
|
|
244
|
+
className: "Avada-ResizableModal__ResizeHandle Avada-ResizableModal__ResizeHandle--right",
|
|
245
|
+
onMouseDown: function onMouseDown(e) {
|
|
246
|
+
return handleMouseDown(e, "resize", "right");
|
|
247
|
+
}
|
|
248
|
+
}))));
|
|
249
|
+
};
|
|
250
|
+
ResizableModal.propTypes = {
|
|
251
|
+
open: PropTypes.bool.isRequired,
|
|
252
|
+
onClose: PropTypes.func.isRequired,
|
|
253
|
+
accessibilityLabel: PropTypes.string,
|
|
254
|
+
children: PropTypes.node,
|
|
255
|
+
disableClickOutsideClose: PropTypes.bool,
|
|
256
|
+
initialWidth: PropTypes.number,
|
|
257
|
+
initialHeight: PropTypes.number,
|
|
258
|
+
minWidth: PropTypes.number,
|
|
259
|
+
minHeight: PropTypes.number,
|
|
260
|
+
maxWidth: PropTypes.number
|
|
261
|
+
};
|
|
262
|
+
export default ResizableModal;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
.Avada-ResizableModal {
|
|
2
|
+
&__Container {
|
|
3
|
+
position: fixed;
|
|
4
|
+
top: 0;
|
|
5
|
+
right: 0;
|
|
6
|
+
bottom: 0;
|
|
7
|
+
left: 0;
|
|
8
|
+
z-index: 399;
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: flex-start;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&__Backdrop {
|
|
14
|
+
position: fixed;
|
|
15
|
+
top: 0;
|
|
16
|
+
right: 0;
|
|
17
|
+
bottom: 0;
|
|
18
|
+
left: 0;
|
|
19
|
+
z-index: 10000;
|
|
20
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
21
|
+
pointer-events: auto;
|
|
22
|
+
animation: fadeIn 0.2s ease-in-out;
|
|
23
|
+
|
|
24
|
+
&--closing {
|
|
25
|
+
animation: fadeOut 0.2s ease-in-out forwards;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&__Content {
|
|
30
|
+
position: fixed;
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
background-color: #FFFFFF;
|
|
34
|
+
z-index: 10001;
|
|
35
|
+
pointer-events: auto;
|
|
36
|
+
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
|
37
|
+
animation: slideInFromLeft 0.2s ease-in-out;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
|
|
40
|
+
&--closing {
|
|
41
|
+
animation: slideOutToLeft 0.2s ease-in-out forwards;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@media (max-width: 48em) {
|
|
45
|
+
width: 95vw !important;
|
|
46
|
+
height: 90vh !important;
|
|
47
|
+
left: 2.5vw !important;
|
|
48
|
+
top: 5vh !important;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&__Body {
|
|
53
|
+
flex: 1;
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
min-height: 0;
|
|
58
|
+
height: 100%;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&__ResizeHandle {
|
|
62
|
+
position: absolute;
|
|
63
|
+
background: transparent;
|
|
64
|
+
|
|
65
|
+
&--right {
|
|
66
|
+
top: 0;
|
|
67
|
+
right: 0;
|
|
68
|
+
bottom: 0;
|
|
69
|
+
width: 4px;
|
|
70
|
+
cursor: e-resize;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&:hover {
|
|
74
|
+
background-color: rgba(0, 123, 255, 0.2);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@keyframes fadeIn {
|
|
80
|
+
from {
|
|
81
|
+
opacity: 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
to {
|
|
85
|
+
opacity: 1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@keyframes fadeOut {
|
|
90
|
+
from {
|
|
91
|
+
opacity: 1;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
to {
|
|
95
|
+
opacity: 0;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@keyframes slideInFromLeft {
|
|
100
|
+
from {
|
|
101
|
+
transform: translateX(-100%);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
to {
|
|
105
|
+
transform: translateX(0);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@keyframes slideOutToLeft {
|
|
110
|
+
from {
|
|
111
|
+
transform: translateX(0);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
to {
|
|
115
|
+
transform: translateX(-100%);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import React, { createContext, useState } from "react";
|
|
8
|
+
import PropTypes from "prop-types";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Context for managing agent UI visibility state
|
|
12
|
+
*/
|
|
13
|
+
export var AgentContext = /*#__PURE__*/createContext({
|
|
14
|
+
openAgent: false,
|
|
15
|
+
setOpenAgent: function setOpenAgent() {}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* AgentProvider - Provides agent context to children
|
|
20
|
+
*
|
|
21
|
+
* @param {React.ReactNode} children - Child components
|
|
22
|
+
* @returns {React.ReactElement} AgentProvider component
|
|
23
|
+
*/
|
|
24
|
+
export var AgentProvider = function AgentProvider(_ref) {
|
|
25
|
+
var children = _ref.children;
|
|
26
|
+
var _useState = useState(false),
|
|
27
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
+
openAgent = _useState2[0],
|
|
29
|
+
setOpenAgent = _useState2[1];
|
|
30
|
+
return /*#__PURE__*/React.createElement(AgentContext.Provider, {
|
|
31
|
+
value: {
|
|
32
|
+
openAgent: openAgent,
|
|
33
|
+
setOpenAgent: setOpenAgent
|
|
34
|
+
}
|
|
35
|
+
}, children);
|
|
36
|
+
};
|
|
37
|
+
AgentProvider.propTypes = {
|
|
38
|
+
children: PropTypes.node.isRequired
|
|
39
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import React, { createContext, useState, useContext } from "react";
|
|
8
|
+
import PropTypes from "prop-types";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Context for managing AI suggestions state
|
|
12
|
+
*/
|
|
13
|
+
var SuggestionsContext = /*#__PURE__*/createContext({
|
|
14
|
+
suggestions: [],
|
|
15
|
+
isVisible: false,
|
|
16
|
+
updateSuggestions: function updateSuggestions() {},
|
|
17
|
+
clearSuggestions: function clearSuggestions() {}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* SuggestionsProvider - Provides suggestions context to children
|
|
22
|
+
*
|
|
23
|
+
* @param {React.ReactNode} children - Child components
|
|
24
|
+
* @returns {React.ReactElement} SuggestionsProvider component
|
|
25
|
+
*/
|
|
26
|
+
export var SuggestionsProvider = function SuggestionsProvider(_ref) {
|
|
27
|
+
var children = _ref.children;
|
|
28
|
+
var _useState = useState([]),
|
|
29
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
30
|
+
suggestions = _useState2[0],
|
|
31
|
+
setSuggestions = _useState2[1];
|
|
32
|
+
var _useState3 = useState(true),
|
|
33
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
34
|
+
isVisible = _useState4[0],
|
|
35
|
+
setIsVisible = _useState4[1];
|
|
36
|
+
var updateSuggestions = function updateSuggestions(newSuggestions) {
|
|
37
|
+
setSuggestions(newSuggestions);
|
|
38
|
+
setIsVisible(true);
|
|
39
|
+
};
|
|
40
|
+
var clearSuggestions = function clearSuggestions() {
|
|
41
|
+
setSuggestions([]);
|
|
42
|
+
setIsVisible(false);
|
|
43
|
+
};
|
|
44
|
+
return /*#__PURE__*/React.createElement(SuggestionsContext.Provider, {
|
|
45
|
+
value: {
|
|
46
|
+
suggestions: suggestions,
|
|
47
|
+
isVisible: isVisible,
|
|
48
|
+
updateSuggestions: updateSuggestions,
|
|
49
|
+
clearSuggestions: clearSuggestions
|
|
50
|
+
}
|
|
51
|
+
}, children);
|
|
52
|
+
};
|
|
53
|
+
SuggestionsProvider.propTypes = {
|
|
54
|
+
children: PropTypes.node.isRequired
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Custom hook to access suggestions context
|
|
59
|
+
*
|
|
60
|
+
* @returns {Object} Suggestions context value
|
|
61
|
+
*/
|
|
62
|
+
export var useSuggestions = function useSuggestions() {
|
|
63
|
+
return useContext(SuggestionsContext);
|
|
64
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
2
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
3
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
4
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
5
|
+
import React, { createContext } from "react";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Context for managing chat thread state and operations
|
|
9
|
+
* Provides thread list, loading states, and CRUD operations
|
|
10
|
+
*/
|
|
11
|
+
export var ThreadContext = /*#__PURE__*/createContext({
|
|
12
|
+
threads: [],
|
|
13
|
+
loadingThreads: false,
|
|
14
|
+
loadingMessages: false,
|
|
15
|
+
getThread: function () {
|
|
16
|
+
var _getThread = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
17
|
+
return _regenerator().w(function (_context) {
|
|
18
|
+
while (1) switch (_context.n) {
|
|
19
|
+
case 0:
|
|
20
|
+
return _context.a(2);
|
|
21
|
+
}
|
|
22
|
+
}, _callee);
|
|
23
|
+
}));
|
|
24
|
+
function getThread() {
|
|
25
|
+
return _getThread.apply(this, arguments);
|
|
26
|
+
}
|
|
27
|
+
return getThread;
|
|
28
|
+
}(),
|
|
29
|
+
thread: {},
|
|
30
|
+
setThread: function setThread() {},
|
|
31
|
+
resetThread: function resetThread() {},
|
|
32
|
+
deleteThread: function () {
|
|
33
|
+
var _deleteThread = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
34
|
+
return _regenerator().w(function (_context2) {
|
|
35
|
+
while (1) switch (_context2.n) {
|
|
36
|
+
case 0:
|
|
37
|
+
return _context2.a(2);
|
|
38
|
+
}
|
|
39
|
+
}, _callee2);
|
|
40
|
+
}));
|
|
41
|
+
function deleteThread() {
|
|
42
|
+
return _deleteThread.apply(this, arguments);
|
|
43
|
+
}
|
|
44
|
+
return deleteThread;
|
|
45
|
+
}(),
|
|
46
|
+
updateThread: function () {
|
|
47
|
+
var _updateThread = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
48
|
+
return _regenerator().w(function (_context3) {
|
|
49
|
+
while (1) switch (_context3.n) {
|
|
50
|
+
case 0:
|
|
51
|
+
return _context3.a(2);
|
|
52
|
+
}
|
|
53
|
+
}, _callee3);
|
|
54
|
+
}));
|
|
55
|
+
function updateThread() {
|
|
56
|
+
return _updateThread.apply(this, arguments);
|
|
57
|
+
}
|
|
58
|
+
return updateThread;
|
|
59
|
+
}()
|
|
60
|
+
});
|