@amodalai/chat-widget 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/chat-widget.css +5 -0
- package/dist/chat-widget.js +2311 -0
- package/dist/chat-widget.js.map +1 -0
- package/dist/client/ChatClient.d.ts +76 -0
- package/dist/client/ChatClient.d.ts.map +1 -0
- package/dist/client/ChatStream.d.ts +63 -0
- package/dist/client/ChatStream.d.ts.map +1 -0
- package/dist/client/EventEmitter.d.ts +16 -0
- package/dist/client/EventEmitter.d.ts.map +1 -0
- package/dist/client/index.d.ts +13 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client.d.ts +85 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +9 -0
- package/dist/client.js.map +1 -0
- package/dist/components/AskUserCard.d.ts +8 -0
- package/dist/components/AskUserCard.d.ts.map +1 -0
- package/dist/components/ChatWidget.d.ts +9 -0
- package/dist/components/ChatWidget.d.ts.map +1 -0
- package/dist/components/FormattedText.d.ts +12 -0
- package/dist/components/FormattedText.d.ts.map +1 -0
- package/dist/components/InputBar.d.ts +15 -0
- package/dist/components/InputBar.d.ts.map +1 -0
- package/dist/components/KBProposalCard.d.ts +7 -0
- package/dist/components/KBProposalCard.d.ts.map +1 -0
- package/dist/components/MessageList.d.ts +15 -0
- package/dist/components/MessageList.d.ts.map +1 -0
- package/dist/components/SessionHistory.d.ts +12 -0
- package/dist/components/SessionHistory.d.ts.map +1 -0
- package/dist/components/SkillPill.d.ts +11 -0
- package/dist/components/SkillPill.d.ts.map +1 -0
- package/dist/components/StreamingIndicator.d.ts +7 -0
- package/dist/components/StreamingIndicator.d.ts.map +1 -0
- package/dist/components/TagEditor.d.ts +11 -0
- package/dist/components/TagEditor.d.ts.map +1 -0
- package/dist/components/ToolCallCard.d.ts +7 -0
- package/dist/components/ToolCallCard.d.ts.map +1 -0
- package/dist/components/widgets/AlertCard.d.ts +3 -0
- package/dist/components/widgets/AlertCard.d.ts.map +1 -0
- package/dist/components/widgets/Comparison.d.ts +3 -0
- package/dist/components/widgets/Comparison.d.ts.map +1 -0
- package/dist/components/widgets/CredentialInput.d.ts +3 -0
- package/dist/components/widgets/CredentialInput.d.ts.map +1 -0
- package/dist/components/widgets/DataTable.d.ts +3 -0
- package/dist/components/widgets/DataTable.d.ts.map +1 -0
- package/dist/components/widgets/DocumentPreview.d.ts +3 -0
- package/dist/components/widgets/DocumentPreview.d.ts.map +1 -0
- package/dist/components/widgets/EntityCard.d.ts +3 -0
- package/dist/components/widgets/EntityCard.d.ts.map +1 -0
- package/dist/components/widgets/EntityList.d.ts +3 -0
- package/dist/components/widgets/EntityList.d.ts.map +1 -0
- package/dist/components/widgets/InfoCard.d.ts +3 -0
- package/dist/components/widgets/InfoCard.d.ts.map +1 -0
- package/dist/components/widgets/Metric.d.ts +3 -0
- package/dist/components/widgets/Metric.d.ts.map +1 -0
- package/dist/components/widgets/ScopeMap.d.ts +3 -0
- package/dist/components/widgets/ScopeMap.d.ts.map +1 -0
- package/dist/components/widgets/ScoreBreakdown.d.ts +3 -0
- package/dist/components/widgets/ScoreBreakdown.d.ts.map +1 -0
- package/dist/components/widgets/StatusBoard.d.ts +3 -0
- package/dist/components/widgets/StatusBoard.d.ts.map +1 -0
- package/dist/components/widgets/Timeline.d.ts +3 -0
- package/dist/components/widgets/Timeline.d.ts.map +1 -0
- package/dist/components/widgets/WidgetRenderer.d.ts +28 -0
- package/dist/components/widgets/WidgetRenderer.d.ts.map +1 -0
- package/dist/events/entity-extractor.d.ts +7 -0
- package/dist/events/entity-extractor.d.ts.map +1 -0
- package/dist/events/event-bus.d.ts +27 -0
- package/dist/events/event-bus.d.ts.map +1 -0
- package/dist/events/index.d.ts +9 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/types.d.ts +72 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/hooks/useChat.d.ts +52 -0
- package/dist/hooks/useChat.d.ts.map +1 -0
- package/dist/hooks/useSessionHistory.d.ts +17 -0
- package/dist/hooks/useSessionHistory.d.ts.map +1 -0
- package/dist/hooks/useWidgetEvents.d.ts +17 -0
- package/dist/hooks/useWidgetEvents.d.ts.map +1 -0
- package/dist/index-m6lGOMRo.js +641 -0
- package/dist/index-m6lGOMRo.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/theme.d.ts +11 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/types.d.ts +298 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/umd-entry.d.ts +21 -0
- package/dist/umd-entry.d.ts.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,2311 @@
|
|
|
1
|
+
import { jsx as e, jsxs as i, Fragment as $e } from "react/jsx-runtime";
|
|
2
|
+
import { useReducer as Re, useRef as A, useCallback as b, useEffect as V, useState as f, Component as Me } from "react";
|
|
3
|
+
import { W as Ie, s as Be, g as Le, l as Oe, u as we } from "./index-m6lGOMRo.js";
|
|
4
|
+
import { C as Bt, a as Lt, T as Ot, c as Dt, b as Pt, d as Ht, p as Ut } from "./index-m6lGOMRo.js";
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
8
|
+
* SPDX-License-Identifier: MIT
|
|
9
|
+
*/
|
|
10
|
+
const ie = {
|
|
11
|
+
messages: [],
|
|
12
|
+
sessionId: null,
|
|
13
|
+
isStreaming: !1,
|
|
14
|
+
error: null,
|
|
15
|
+
activeToolCalls: [],
|
|
16
|
+
isHistorical: !1
|
|
17
|
+
};
|
|
18
|
+
let ge = 0;
|
|
19
|
+
function ye() {
|
|
20
|
+
return ge++, `msg-${Date.now()}-${String(ge)}`;
|
|
21
|
+
}
|
|
22
|
+
function De(s, n) {
|
|
23
|
+
switch (n.type) {
|
|
24
|
+
case "SEND_MESSAGE": {
|
|
25
|
+
const t = {
|
|
26
|
+
type: "user",
|
|
27
|
+
id: ye(),
|
|
28
|
+
text: n.text,
|
|
29
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
30
|
+
}, a = {
|
|
31
|
+
type: "assistant_text",
|
|
32
|
+
id: ye(),
|
|
33
|
+
text: "",
|
|
34
|
+
toolCalls: [],
|
|
35
|
+
skillActivations: [],
|
|
36
|
+
kbProposals: [],
|
|
37
|
+
widgets: [],
|
|
38
|
+
contentBlocks: [],
|
|
39
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
...s,
|
|
43
|
+
messages: [...s.messages, t, a],
|
|
44
|
+
isStreaming: !0,
|
|
45
|
+
error: null,
|
|
46
|
+
activeToolCalls: [],
|
|
47
|
+
isHistorical: !1
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
case "STREAM_INIT":
|
|
51
|
+
return { ...s, sessionId: n.sessionId };
|
|
52
|
+
case "STREAM_TEXT_DELTA": {
|
|
53
|
+
const t = [...s.messages], a = t[t.length - 1];
|
|
54
|
+
if (a && a.type === "assistant_text") {
|
|
55
|
+
const c = [...a.contentBlocks], l = c[c.length - 1];
|
|
56
|
+
l && l.type === "text" ? c[c.length - 1] = { type: "text", text: l.text + n.content } : c.push({ type: "text", text: n.content }), t[t.length - 1] = { ...a, text: a.text + n.content, contentBlocks: c };
|
|
57
|
+
}
|
|
58
|
+
return { ...s, messages: t };
|
|
59
|
+
}
|
|
60
|
+
case "STREAM_TOOL_CALL_START": {
|
|
61
|
+
const t = [...s.messages], a = t[t.length - 1], c = {
|
|
62
|
+
toolId: n.toolId,
|
|
63
|
+
toolName: n.toolName,
|
|
64
|
+
parameters: n.parameters,
|
|
65
|
+
status: "running"
|
|
66
|
+
};
|
|
67
|
+
if (a && a.type === "assistant_text") {
|
|
68
|
+
const l = [...a.toolCalls, c], o = [...a.contentBlocks], r = o[o.length - 1];
|
|
69
|
+
r && r.type === "tool_calls" ? o[o.length - 1] = { type: "tool_calls", calls: [...r.calls, c] } : o.push({ type: "tool_calls", calls: [c] }), t[t.length - 1] = { ...a, toolCalls: l, contentBlocks: o };
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
...s,
|
|
73
|
+
messages: t,
|
|
74
|
+
activeToolCalls: [...s.activeToolCalls, c]
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
case "STREAM_TOOL_CALL_RESULT": {
|
|
78
|
+
const t = [...s.messages], a = t[t.length - 1];
|
|
79
|
+
if (a && a.type === "assistant_text") {
|
|
80
|
+
const l = (d) => d.toolId === n.toolId ? {
|
|
81
|
+
...d,
|
|
82
|
+
status: n.status,
|
|
83
|
+
result: n.result,
|
|
84
|
+
duration_ms: n.duration_ms,
|
|
85
|
+
error: n.error
|
|
86
|
+
} : d, o = a.toolCalls.map(l), r = a.contentBlocks.map(
|
|
87
|
+
(d) => d.type === "tool_calls" ? { ...d, calls: d.calls.map(l) } : d
|
|
88
|
+
);
|
|
89
|
+
t[t.length - 1] = { ...a, toolCalls: o, contentBlocks: r };
|
|
90
|
+
}
|
|
91
|
+
const c = s.activeToolCalls.filter(
|
|
92
|
+
(l) => l.toolId !== n.toolId
|
|
93
|
+
);
|
|
94
|
+
return { ...s, messages: t, activeToolCalls: c };
|
|
95
|
+
}
|
|
96
|
+
case "STREAM_SUBAGENT_EVENT": {
|
|
97
|
+
const t = [...s.messages], a = t[t.length - 1];
|
|
98
|
+
if (a && a.type === "assistant_text") {
|
|
99
|
+
const c = (r) => r.toolId === n.parentToolId ? { ...r, subagentEvents: [...r.subagentEvents ?? [], n.event] } : r, l = a.toolCalls.map(c), o = a.contentBlocks.map(
|
|
100
|
+
(r) => r.type === "tool_calls" ? { ...r, calls: r.calls.map(c) } : r
|
|
101
|
+
);
|
|
102
|
+
t[t.length - 1] = { ...a, toolCalls: l, contentBlocks: o };
|
|
103
|
+
}
|
|
104
|
+
return { ...s, messages: t };
|
|
105
|
+
}
|
|
106
|
+
case "STREAM_SKILL_ACTIVATED": {
|
|
107
|
+
const t = [...s.messages], a = t[t.length - 1];
|
|
108
|
+
return a && a.type === "assistant_text" && (t[t.length - 1] = {
|
|
109
|
+
...a,
|
|
110
|
+
skillActivations: [...a.skillActivations, n.skill]
|
|
111
|
+
}), { ...s, messages: t };
|
|
112
|
+
}
|
|
113
|
+
case "STREAM_KB_PROPOSAL": {
|
|
114
|
+
const t = [...s.messages], a = t[t.length - 1], c = {
|
|
115
|
+
scope: n.scope,
|
|
116
|
+
title: n.title,
|
|
117
|
+
reasoning: n.reasoning
|
|
118
|
+
};
|
|
119
|
+
return a && a.type === "assistant_text" && (t[t.length - 1] = {
|
|
120
|
+
...a,
|
|
121
|
+
kbProposals: [...a.kbProposals, c]
|
|
122
|
+
}), { ...s, messages: t };
|
|
123
|
+
}
|
|
124
|
+
case "STREAM_WIDGET": {
|
|
125
|
+
const t = [...s.messages], a = t[t.length - 1];
|
|
126
|
+
if (a && a.type === "assistant_text") {
|
|
127
|
+
const c = {
|
|
128
|
+
widgetType: n.widgetType,
|
|
129
|
+
data: n.data
|
|
130
|
+
}, l = {
|
|
131
|
+
type: "widget",
|
|
132
|
+
widgetType: n.widgetType,
|
|
133
|
+
data: n.data
|
|
134
|
+
};
|
|
135
|
+
t[t.length - 1] = {
|
|
136
|
+
...a,
|
|
137
|
+
widgets: [...a.widgets, c],
|
|
138
|
+
contentBlocks: [...a.contentBlocks, l]
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
return { ...s, messages: t };
|
|
142
|
+
}
|
|
143
|
+
case "STREAM_ASK_USER": {
|
|
144
|
+
const t = [...s.messages], a = t[t.length - 1];
|
|
145
|
+
if (a && a.type === "assistant_text") {
|
|
146
|
+
const c = {
|
|
147
|
+
type: "ask_user",
|
|
148
|
+
askId: n.askId,
|
|
149
|
+
questions: n.questions,
|
|
150
|
+
status: "pending"
|
|
151
|
+
};
|
|
152
|
+
t[t.length - 1] = {
|
|
153
|
+
...a,
|
|
154
|
+
contentBlocks: [...a.contentBlocks, c]
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return { ...s, messages: t };
|
|
158
|
+
}
|
|
159
|
+
case "ASK_USER_SUBMITTED": {
|
|
160
|
+
const t = [...s.messages], a = t[t.length - 1];
|
|
161
|
+
if (a && a.type === "assistant_text") {
|
|
162
|
+
const c = a.contentBlocks.map(
|
|
163
|
+
(l) => l.type === "ask_user" && l.askId === n.askId ? { ...l, status: "submitted", answers: n.answers } : l
|
|
164
|
+
);
|
|
165
|
+
t[t.length - 1] = { ...a, contentBlocks: c };
|
|
166
|
+
}
|
|
167
|
+
return { ...s, messages: t };
|
|
168
|
+
}
|
|
169
|
+
case "STREAM_ERROR":
|
|
170
|
+
return { ...s, isStreaming: !1, error: n.message, activeToolCalls: [] };
|
|
171
|
+
case "STREAM_DONE": {
|
|
172
|
+
const t = [...s.messages], a = t[t.length - 1];
|
|
173
|
+
if (a && a.type === "assistant_text") {
|
|
174
|
+
const c = (r) => r.status === "running" ? { ...r, status: "error", error: "Stopped" } : r, l = a.toolCalls.map(c), o = a.contentBlocks.map(
|
|
175
|
+
(r) => r.type === "tool_calls" ? { ...r, calls: r.calls.map(c) } : r
|
|
176
|
+
);
|
|
177
|
+
t[t.length - 1] = { ...a, toolCalls: l, contentBlocks: o };
|
|
178
|
+
}
|
|
179
|
+
return { ...s, messages: t, isStreaming: !1, activeToolCalls: [] };
|
|
180
|
+
}
|
|
181
|
+
case "LOAD_HISTORY":
|
|
182
|
+
return {
|
|
183
|
+
...ie,
|
|
184
|
+
messages: n.messages,
|
|
185
|
+
sessionId: n.sessionId,
|
|
186
|
+
isHistorical: !0
|
|
187
|
+
};
|
|
188
|
+
case "RESET":
|
|
189
|
+
return { ...ie };
|
|
190
|
+
default:
|
|
191
|
+
return s;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function Pe(s) {
|
|
195
|
+
const { serverUrl: n, user: t, getToken: a, onToolCall: c, onKBProposal: l, onEvent: o, entityExtractors: r, sessionType: d, deployId: u, initialMessage: p, resumeSessionId: m, onStreamEnd: y, onSessionCreated: w } = s, [g, h] = Re(De, ie), $ = A(null), S = A(null), N = A({ onToolCall: c, onKBProposal: l, getToken: a, onEvent: o, onStreamEnd: y, onSessionCreated: w });
|
|
196
|
+
N.current = { onToolCall: c, onKBProposal: l, getToken: a, onEvent: o, onStreamEnd: y, onSessionCreated: w };
|
|
197
|
+
const P = A(null);
|
|
198
|
+
P.current || (P.current = new Ie(), r && P.current.setExtractors(r));
|
|
199
|
+
const R = P.current, x = A(null);
|
|
200
|
+
x.current || (x.current = (T) => {
|
|
201
|
+
var I, B;
|
|
202
|
+
(B = (I = N.current).onEvent) == null || B.call(I, T);
|
|
203
|
+
}, R.on("entity_referenced", x.current));
|
|
204
|
+
const H = A(/* @__PURE__ */ new Map());
|
|
205
|
+
$.current = g.sessionId;
|
|
206
|
+
const G = b(
|
|
207
|
+
(T) => {
|
|
208
|
+
if (g.isStreaming) return;
|
|
209
|
+
h({ type: "SEND_MESSAGE", text: T });
|
|
210
|
+
const I = new AbortController();
|
|
211
|
+
S.current = I, (async () => {
|
|
212
|
+
var k, K, U, v, O, M, Q, z, C, D, ee, Z, ae, te, oe, de, pe, ue, me, _e;
|
|
213
|
+
let L = !1;
|
|
214
|
+
try {
|
|
215
|
+
const se = ((K = (k = N.current).getToken) == null ? void 0 : K.call(k)) ?? void 0, Ae = Be(
|
|
216
|
+
n,
|
|
217
|
+
{
|
|
218
|
+
message: T,
|
|
219
|
+
session_id: $.current ?? void 0,
|
|
220
|
+
role: t.role,
|
|
221
|
+
session_type: d,
|
|
222
|
+
deploy_id: u
|
|
223
|
+
},
|
|
224
|
+
I.signal,
|
|
225
|
+
se
|
|
226
|
+
);
|
|
227
|
+
for await (const _ of Ae)
|
|
228
|
+
switch (_.type) {
|
|
229
|
+
case "init":
|
|
230
|
+
h({ type: "STREAM_INIT", sessionId: _.session_id }), (v = (U = N.current).onSessionCreated) == null || v.call(U, _.session_id);
|
|
231
|
+
break;
|
|
232
|
+
case "text_delta":
|
|
233
|
+
h({ type: "STREAM_TEXT_DELTA", content: _.content });
|
|
234
|
+
break;
|
|
235
|
+
case "tool_call_start":
|
|
236
|
+
h({
|
|
237
|
+
type: "STREAM_TOOL_CALL_START",
|
|
238
|
+
toolId: _.tool_id,
|
|
239
|
+
toolName: _.tool_name,
|
|
240
|
+
parameters: _.parameters
|
|
241
|
+
}), H.current.set(_.tool_id, {
|
|
242
|
+
toolName: _.tool_name,
|
|
243
|
+
parameters: _.parameters
|
|
244
|
+
});
|
|
245
|
+
break;
|
|
246
|
+
case "tool_call_result": {
|
|
247
|
+
const E = H.current.get(_.tool_id), X = {
|
|
248
|
+
toolId: _.tool_id,
|
|
249
|
+
toolName: (E == null ? void 0 : E.toolName) ?? "",
|
|
250
|
+
parameters: (E == null ? void 0 : E.parameters) ?? {},
|
|
251
|
+
status: _.status,
|
|
252
|
+
result: _.result,
|
|
253
|
+
duration_ms: _.duration_ms,
|
|
254
|
+
error: _.error
|
|
255
|
+
};
|
|
256
|
+
H.current.delete(_.tool_id), h({
|
|
257
|
+
type: "STREAM_TOOL_CALL_RESULT",
|
|
258
|
+
toolId: _.tool_id,
|
|
259
|
+
status: _.status,
|
|
260
|
+
result: _.result,
|
|
261
|
+
duration_ms: _.duration_ms,
|
|
262
|
+
error: _.error
|
|
263
|
+
}), (M = (O = N.current).onToolCall) == null || M.call(O, X);
|
|
264
|
+
const he = {
|
|
265
|
+
type: "tool_executed",
|
|
266
|
+
toolName: X.toolName,
|
|
267
|
+
toolId: X.toolId,
|
|
268
|
+
parameters: X.parameters,
|
|
269
|
+
status: _.status,
|
|
270
|
+
result: _.result,
|
|
271
|
+
duration_ms: _.duration_ms,
|
|
272
|
+
error: _.error,
|
|
273
|
+
timestamp: _.timestamp
|
|
274
|
+
};
|
|
275
|
+
R.processEvent(he), (z = (Q = N.current).onEvent) == null || z.call(Q, he);
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
case "subagent_event":
|
|
279
|
+
h({
|
|
280
|
+
type: "STREAM_SUBAGENT_EVENT",
|
|
281
|
+
parentToolId: _.parent_tool_id,
|
|
282
|
+
event: {
|
|
283
|
+
agentName: _.agent_name,
|
|
284
|
+
eventType: _.event_type,
|
|
285
|
+
toolName: _.tool_name,
|
|
286
|
+
toolArgs: _.tool_args,
|
|
287
|
+
result: _.result,
|
|
288
|
+
text: _.text,
|
|
289
|
+
error: _.error,
|
|
290
|
+
timestamp: _.timestamp
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
break;
|
|
294
|
+
case "skill_activated": {
|
|
295
|
+
h({ type: "STREAM_SKILL_ACTIVATED", skill: _.skill });
|
|
296
|
+
const E = {
|
|
297
|
+
type: "skill_activated",
|
|
298
|
+
skill: _.skill,
|
|
299
|
+
timestamp: _.timestamp
|
|
300
|
+
};
|
|
301
|
+
R.processEvent(E), (D = (C = N.current).onEvent) == null || D.call(C, E);
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
case "kb_proposal": {
|
|
305
|
+
const E = {
|
|
306
|
+
scope: _.scope,
|
|
307
|
+
title: _.title,
|
|
308
|
+
reasoning: _.reasoning
|
|
309
|
+
};
|
|
310
|
+
h({
|
|
311
|
+
type: "STREAM_KB_PROPOSAL",
|
|
312
|
+
scope: _.scope,
|
|
313
|
+
title: _.title,
|
|
314
|
+
reasoning: _.reasoning
|
|
315
|
+
}), (Z = (ee = N.current).onKBProposal) == null || Z.call(ee, E);
|
|
316
|
+
const X = {
|
|
317
|
+
type: "kb_proposal",
|
|
318
|
+
proposal: E,
|
|
319
|
+
timestamp: _.timestamp
|
|
320
|
+
};
|
|
321
|
+
R.processEvent(X), (te = (ae = N.current).onEvent) == null || te.call(ae, X);
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
case "widget": {
|
|
325
|
+
h({
|
|
326
|
+
type: "STREAM_WIDGET",
|
|
327
|
+
widgetType: _.widget_type,
|
|
328
|
+
data: _.data
|
|
329
|
+
});
|
|
330
|
+
const E = {
|
|
331
|
+
type: "widget_rendered",
|
|
332
|
+
widgetType: _.widget_type,
|
|
333
|
+
data: _.data,
|
|
334
|
+
timestamp: _.timestamp
|
|
335
|
+
};
|
|
336
|
+
R.processEvent(E), (de = (oe = N.current).onEvent) == null || de.call(oe, E);
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
case "ask_user":
|
|
340
|
+
h({
|
|
341
|
+
type: "STREAM_ASK_USER",
|
|
342
|
+
askId: _.ask_id,
|
|
343
|
+
questions: _.questions
|
|
344
|
+
});
|
|
345
|
+
break;
|
|
346
|
+
case "credential_saved":
|
|
347
|
+
h({ type: "STREAM_CREDENTIAL_SAVED", connectionName: _.connection_name });
|
|
348
|
+
break;
|
|
349
|
+
case "approved":
|
|
350
|
+
h({ type: "STREAM_APPROVED", resourceType: _.resource_type, previewId: _.preview_id });
|
|
351
|
+
break;
|
|
352
|
+
case "error":
|
|
353
|
+
h({ type: "STREAM_ERROR", message: _.message });
|
|
354
|
+
break;
|
|
355
|
+
case "done":
|
|
356
|
+
L = !0, h({ type: "STREAM_DONE" }), (ue = (pe = N.current).onStreamEnd) == null || ue.call(pe);
|
|
357
|
+
break;
|
|
358
|
+
default:
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
} catch (se) {
|
|
362
|
+
se instanceof DOMException && se.name === "AbortError" || h({
|
|
363
|
+
type: "STREAM_ERROR",
|
|
364
|
+
message: se instanceof Error ? se.message : "Unknown error"
|
|
365
|
+
});
|
|
366
|
+
} finally {
|
|
367
|
+
S.current = null, !L && !I.signal.aborted && (h({ type: "STREAM_DONE" }), (_e = (me = N.current).onStreamEnd) == null || _e.call(me));
|
|
368
|
+
}
|
|
369
|
+
})();
|
|
370
|
+
},
|
|
371
|
+
[n, t.role, g.isStreaming, R, d, u]
|
|
372
|
+
), j = A(!1);
|
|
373
|
+
V(() => {
|
|
374
|
+
!m || j.current || (j.current = !0, F.current = !0, Y(m));
|
|
375
|
+
}, [m]);
|
|
376
|
+
const J = A(!1), F = A(!1);
|
|
377
|
+
V(() => {
|
|
378
|
+
if (m || g.isHistorical || !p || F.current) return;
|
|
379
|
+
J.current = !1;
|
|
380
|
+
const T = setTimeout(() => {
|
|
381
|
+
!J.current && !F.current && (J.current = !0, G(p));
|
|
382
|
+
}, 0);
|
|
383
|
+
return () => {
|
|
384
|
+
clearTimeout(T);
|
|
385
|
+
};
|
|
386
|
+
}, [p, g.isHistorical]), V(() => {
|
|
387
|
+
p && J.current && !g.isStreaming && g.messages.length > 0 && (F.current = !0);
|
|
388
|
+
}, [p, g.isStreaming, g.messages.length]);
|
|
389
|
+
const ce = b(() => {
|
|
390
|
+
S.current && (S.current.abort(), S.current = null), h({ type: "STREAM_DONE" });
|
|
391
|
+
}, []), W = b(() => {
|
|
392
|
+
S.current && (S.current.abort(), S.current = null), h({ type: "RESET" });
|
|
393
|
+
}, []), q = b(
|
|
394
|
+
(T, I) => {
|
|
395
|
+
const B = $.current;
|
|
396
|
+
if (!B) return;
|
|
397
|
+
h({ type: "ASK_USER_SUBMITTED", askId: T, answers: I }), (async () => {
|
|
398
|
+
var k, K;
|
|
399
|
+
try {
|
|
400
|
+
const U = ((K = (k = N.current).getToken) == null ? void 0 : K.call(k)) ?? void 0, v = { "Content-Type": "application/json" };
|
|
401
|
+
U && (v.Authorization = `Bearer ${U}`), await fetch(
|
|
402
|
+
`${n}/chat/sessions/${B}/ask-user-response`,
|
|
403
|
+
{
|
|
404
|
+
method: "POST",
|
|
405
|
+
headers: v,
|
|
406
|
+
body: JSON.stringify({ ask_id: T, answers: I })
|
|
407
|
+
}
|
|
408
|
+
);
|
|
409
|
+
} catch {
|
|
410
|
+
}
|
|
411
|
+
})();
|
|
412
|
+
},
|
|
413
|
+
[n]
|
|
414
|
+
), Y = b(
|
|
415
|
+
(T) => {
|
|
416
|
+
F.current = !0, (async () => {
|
|
417
|
+
var B, L;
|
|
418
|
+
try {
|
|
419
|
+
const k = ((L = (B = N.current).getToken) == null ? void 0 : L.call(B)) ?? void 0, U = (await Le(n, T, k)).messages.map((v) => {
|
|
420
|
+
if (v.type === "assistant_text") {
|
|
421
|
+
const O = (v.toolCalls ?? []).map((C) => ({
|
|
422
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- stored tool call from DB
|
|
423
|
+
toolId: C.toolId ?? "",
|
|
424
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- stored tool call from DB
|
|
425
|
+
toolName: C.toolName ?? "",
|
|
426
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- stored args from DB
|
|
427
|
+
parameters: C.args ?? {},
|
|
428
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- stored tool call from DB
|
|
429
|
+
status: C.status ?? "success",
|
|
430
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- stored tool call from DB
|
|
431
|
+
duration_ms: C.duration_ms,
|
|
432
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- stored tool call from DB
|
|
433
|
+
error: C.error,
|
|
434
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- stored tool call from DB
|
|
435
|
+
result: C.result
|
|
436
|
+
})), M = v.widgets ?? [], Q = v.contentBlocks, z = [];
|
|
437
|
+
if (Q && Q.length > 0) {
|
|
438
|
+
const C = new Map(O.map((D) => [D.toolId, D]));
|
|
439
|
+
for (const D of Q) {
|
|
440
|
+
const ee = D.type;
|
|
441
|
+
if (ee === "text") {
|
|
442
|
+
const Z = D.text;
|
|
443
|
+
Z.length > 0 && z.push({ type: "text", text: Z });
|
|
444
|
+
} else if (ee === "tool_calls") {
|
|
445
|
+
const Z = D.callIds, ae = Z ? Z.map((te) => C.get(te)).filter(
|
|
446
|
+
(te) => te != null
|
|
447
|
+
) : O;
|
|
448
|
+
ae.length > 0 && z.push({ type: "tool_calls", calls: ae });
|
|
449
|
+
} else ee === "widget" && z.push({
|
|
450
|
+
type: "widget",
|
|
451
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- stored block from DB
|
|
452
|
+
widgetType: D.widgetType,
|
|
453
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- stored widget data from DB
|
|
454
|
+
data: D.data ?? {}
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
} else {
|
|
458
|
+
O.length > 0 && z.push({ type: "tool_calls", calls: O }), v.text.length > 0 && z.push({ type: "text", text: v.text });
|
|
459
|
+
for (const C of M)
|
|
460
|
+
z.push({ type: "widget", widgetType: C.widgetType, data: C.data });
|
|
461
|
+
}
|
|
462
|
+
return {
|
|
463
|
+
type: "assistant_text",
|
|
464
|
+
id: v.id,
|
|
465
|
+
text: v.text,
|
|
466
|
+
toolCalls: O,
|
|
467
|
+
skillActivations: v.skillActivations ?? [],
|
|
468
|
+
kbProposals: [],
|
|
469
|
+
widgets: M,
|
|
470
|
+
contentBlocks: z,
|
|
471
|
+
timestamp: v.timestamp
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
return v.type === "error" ? {
|
|
475
|
+
type: "error",
|
|
476
|
+
id: v.id,
|
|
477
|
+
message: v.text,
|
|
478
|
+
timestamp: v.timestamp
|
|
479
|
+
} : {
|
|
480
|
+
type: "user",
|
|
481
|
+
id: v.id,
|
|
482
|
+
text: v.text,
|
|
483
|
+
timestamp: v.timestamp
|
|
484
|
+
};
|
|
485
|
+
});
|
|
486
|
+
h({ type: "LOAD_HISTORY", sessionId: T, messages: U });
|
|
487
|
+
} catch (k) {
|
|
488
|
+
h({
|
|
489
|
+
type: "STREAM_ERROR",
|
|
490
|
+
message: k instanceof Error ? k.message : "Failed to load session"
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
})();
|
|
494
|
+
},
|
|
495
|
+
[n]
|
|
496
|
+
);
|
|
497
|
+
return V(
|
|
498
|
+
() => () => {
|
|
499
|
+
S.current && S.current.abort();
|
|
500
|
+
},
|
|
501
|
+
[]
|
|
502
|
+
), {
|
|
503
|
+
messages: g.messages,
|
|
504
|
+
send: G,
|
|
505
|
+
stop: ce,
|
|
506
|
+
isStreaming: g.isStreaming,
|
|
507
|
+
activeToolCalls: g.activeToolCalls,
|
|
508
|
+
session: { id: g.sessionId, role: t.role },
|
|
509
|
+
error: g.error,
|
|
510
|
+
reset: W,
|
|
511
|
+
eventBus: R,
|
|
512
|
+
submitAskUserResponse: q,
|
|
513
|
+
loadSession: Y,
|
|
514
|
+
isHistorical: g.isHistorical
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* @license
|
|
519
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
520
|
+
* SPDX-License-Identifier: MIT
|
|
521
|
+
*/
|
|
522
|
+
function He(s) {
|
|
523
|
+
const { serverUrl: n, getToken: t, enabled: a } = s, [c, l] = f([]), [o, r] = f(!1), [d, u] = f(null), p = A(t);
|
|
524
|
+
p.current = t;
|
|
525
|
+
const m = b(() => {
|
|
526
|
+
if (!a) return;
|
|
527
|
+
r(!0), u(null), (async () => {
|
|
528
|
+
var $;
|
|
529
|
+
try {
|
|
530
|
+
const S = (($ = p.current) == null ? void 0 : $.call(p)) ?? void 0, N = await Oe(n, S);
|
|
531
|
+
l(N);
|
|
532
|
+
} catch (S) {
|
|
533
|
+
u(S instanceof Error ? S.message : "Failed to load sessions");
|
|
534
|
+
} finally {
|
|
535
|
+
r(!1);
|
|
536
|
+
}
|
|
537
|
+
})();
|
|
538
|
+
}, [n, a]), y = b(
|
|
539
|
+
(h, $) => {
|
|
540
|
+
(async () => {
|
|
541
|
+
var N;
|
|
542
|
+
try {
|
|
543
|
+
const P = ((N = p.current) == null ? void 0 : N.call(p)) ?? void 0;
|
|
544
|
+
await we(n, h, { tags: $ }, P), l(
|
|
545
|
+
(R) => R.map((x) => x.id === h ? { ...x, tags: $ } : x)
|
|
546
|
+
);
|
|
547
|
+
} catch {
|
|
548
|
+
}
|
|
549
|
+
})();
|
|
550
|
+
},
|
|
551
|
+
[n]
|
|
552
|
+
), w = b(
|
|
553
|
+
(h, $) => {
|
|
554
|
+
(async () => {
|
|
555
|
+
var N;
|
|
556
|
+
try {
|
|
557
|
+
const P = ((N = p.current) == null ? void 0 : N.call(p)) ?? void 0;
|
|
558
|
+
await we(n, h, { title: $ }, P), l(
|
|
559
|
+
(R) => R.map((x) => x.id === h ? { ...x, title: $ } : x)
|
|
560
|
+
);
|
|
561
|
+
} catch {
|
|
562
|
+
}
|
|
563
|
+
})();
|
|
564
|
+
},
|
|
565
|
+
[n]
|
|
566
|
+
), g = [...new Set(c.flatMap((h) => h.tags))].sort();
|
|
567
|
+
return V(() => {
|
|
568
|
+
a && m();
|
|
569
|
+
}, [a, m]), { sessions: c, isLoading: o, error: d, refresh: m, updateTags: y, updateTitle: w, allTags: g };
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* @license
|
|
573
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
574
|
+
* SPDX-License-Identifier: MIT
|
|
575
|
+
*/
|
|
576
|
+
const Ee = {
|
|
577
|
+
primaryColor: "#1e40af",
|
|
578
|
+
backgroundColor: "#ffffff",
|
|
579
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
580
|
+
fontSize: "14px",
|
|
581
|
+
borderRadius: "8px",
|
|
582
|
+
userBubbleColor: "#1e40af",
|
|
583
|
+
agentBubbleColor: "#f3f4f6",
|
|
584
|
+
toolCallColor: "#f9fafb",
|
|
585
|
+
headerText: "AI Assistant",
|
|
586
|
+
placeholder: "Type a message...",
|
|
587
|
+
emptyStateText: "Send a message to start a conversation."
|
|
588
|
+
}, Ue = {
|
|
589
|
+
primaryColor: "--pcw-primary",
|
|
590
|
+
backgroundColor: "--pcw-bg",
|
|
591
|
+
fontFamily: "--pcw-font",
|
|
592
|
+
fontSize: "--pcw-font-size",
|
|
593
|
+
borderRadius: "--pcw-radius",
|
|
594
|
+
userBubbleColor: "--pcw-user-bubble",
|
|
595
|
+
agentBubbleColor: "--pcw-agent-bubble",
|
|
596
|
+
toolCallColor: "--pcw-tool-call-bg",
|
|
597
|
+
headerText: "--pcw-header-text",
|
|
598
|
+
placeholder: "--pcw-placeholder",
|
|
599
|
+
emptyStateText: "--pcw-empty-state-text"
|
|
600
|
+
};
|
|
601
|
+
function ze(s, n) {
|
|
602
|
+
const t = { ...Ee, ...n };
|
|
603
|
+
for (const [a, c] of Object.entries(Ue)) {
|
|
604
|
+
const l = t[a];
|
|
605
|
+
l !== void 0 && s.style.setProperty(c, l);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
function je(s) {
|
|
609
|
+
return { ...Ee, ...s };
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* @license
|
|
613
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
614
|
+
* SPDX-License-Identifier: MIT
|
|
615
|
+
*/
|
|
616
|
+
function le(s) {
|
|
617
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
618
|
+
}
|
|
619
|
+
function re(s) {
|
|
620
|
+
let n = le(s);
|
|
621
|
+
return n = n.replace(/`([^`]+)`/g, '<code class="pcw-md-code">$1</code>'), n = n.replace(/\*\*\*(.+?)\*\*\*/g, "<strong><em>$1</em></strong>"), n = n.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>"), n = n.replace(/__(.+?)__/g, "<strong>$1</strong>"), n = n.replace(/\*(.+?)\*/g, "<em>$1</em>"), n = n.replace(new RegExp("(?<!\\w)_(.+?)_(?!\\w)", "g"), "<em>$1</em>"), n = n.replace(
|
|
622
|
+
/\[([^\]]+)\]\(([^)]+)\)/g,
|
|
623
|
+
'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'
|
|
624
|
+
), n;
|
|
625
|
+
}
|
|
626
|
+
function Fe(s) {
|
|
627
|
+
const n = s.split(`
|
|
628
|
+
`), t = [];
|
|
629
|
+
let a = !1, c = [], l = !1;
|
|
630
|
+
for (let o = 0; o < n.length; o++) {
|
|
631
|
+
const r = n[o];
|
|
632
|
+
if (r.startsWith("```")) {
|
|
633
|
+
a ? (t.push(`<pre class="pcw-md-codeblock"><code>${le(c.join(`
|
|
634
|
+
`))}</code></pre>`), c = [], a = !1) : (l && (t.push("</ul>"), l = !1), a = !0);
|
|
635
|
+
continue;
|
|
636
|
+
}
|
|
637
|
+
if (a) {
|
|
638
|
+
c.push(r);
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
641
|
+
if (r.trim() === "") {
|
|
642
|
+
l && (t.push("</ul>"), l = !1);
|
|
643
|
+
continue;
|
|
644
|
+
}
|
|
645
|
+
const d = /^(#{1,4})\s+(.+)$/.exec(r);
|
|
646
|
+
if (d) {
|
|
647
|
+
l && (t.push("</ul>"), l = !1);
|
|
648
|
+
const p = d[1].length;
|
|
649
|
+
t.push(`<h${String(p)} class="pcw-md-h${String(p)}">${re(d[2])}</h${String(p)}>`);
|
|
650
|
+
continue;
|
|
651
|
+
}
|
|
652
|
+
const u = /^(\s*)[-*]\s+(.+)$/.exec(r) ?? /^(\s*)\d+\.\s+(.+)$/.exec(r);
|
|
653
|
+
if (u) {
|
|
654
|
+
l || (t.push('<ul class="pcw-md-list">'), l = !0), t.push(`<li>${re(u[2])}</li>`);
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
l && (t.push("</ul>"), l = !1), t.push(`<p>${re(r)}</p>`);
|
|
658
|
+
}
|
|
659
|
+
return a && t.push(`<pre class="pcw-md-codeblock"><code>${le(c.join(`
|
|
660
|
+
`))}</code></pre>`), l && t.push("</ul>"), t.join(`
|
|
661
|
+
`);
|
|
662
|
+
}
|
|
663
|
+
function ne({ text: s, className: n }) {
|
|
664
|
+
const t = Fe(s);
|
|
665
|
+
return /* @__PURE__ */ e(
|
|
666
|
+
"div",
|
|
667
|
+
{
|
|
668
|
+
className: `pcw-formatted-text${n ? ` ${n}` : ""}`,
|
|
669
|
+
dangerouslySetInnerHTML: { __html: t }
|
|
670
|
+
}
|
|
671
|
+
);
|
|
672
|
+
}
|
|
673
|
+
function Ke({ event: s }) {
|
|
674
|
+
const [n, t] = f(!1), a = !!(s.result || s.error || s.toolArgs);
|
|
675
|
+
return /* @__PURE__ */ i("div", { className: "pcw-subagent-row", children: [
|
|
676
|
+
/* @__PURE__ */ i(
|
|
677
|
+
"button",
|
|
678
|
+
{
|
|
679
|
+
type: "button",
|
|
680
|
+
className: `pcw-subagent-row__header${a ? "" : " pcw-subagent-row__header--static"}`,
|
|
681
|
+
onClick: () => {
|
|
682
|
+
a && t(!n);
|
|
683
|
+
},
|
|
684
|
+
children: [
|
|
685
|
+
a && /* @__PURE__ */ e("span", { className: "pcw-subagent-row__chevron", children: n ? "▼" : "▶" }),
|
|
686
|
+
/* @__PURE__ */ e("span", { className: `pcw-subagent-row__icon${s.error ? " pcw-subagent-row__icon--error" : ""}`, children: s.error ? "✗" : "✓" }),
|
|
687
|
+
/* @__PURE__ */ e("span", { className: "pcw-subagent-row__name", children: s.toolName ?? "unknown" })
|
|
688
|
+
]
|
|
689
|
+
}
|
|
690
|
+
),
|
|
691
|
+
n && /* @__PURE__ */ i("div", { className: "pcw-subagent-row__detail", children: [
|
|
692
|
+
s.error && /* @__PURE__ */ e("pre", { className: "pcw-subagent-row__error", children: s.error }),
|
|
693
|
+
s.result && /* @__PURE__ */ e("pre", { className: "pcw-subagent-row__result", children: s.result }),
|
|
694
|
+
s.toolArgs && /* @__PURE__ */ e("pre", { className: "pcw-subagent-row__args", children: JSON.stringify(s.toolArgs, null, 2) })
|
|
695
|
+
] })
|
|
696
|
+
] });
|
|
697
|
+
}
|
|
698
|
+
function Ve({ params: s }) {
|
|
699
|
+
const n = s.subagent, t = s.task, a = s.instruction, c = s.kb_tags, l = s.tools;
|
|
700
|
+
return /* @__PURE__ */ i("div", { className: "pcw-dispatch-args", children: [
|
|
701
|
+
n && /* @__PURE__ */ i("div", { className: "pcw-dispatch-args__row", children: [
|
|
702
|
+
/* @__PURE__ */ e("span", { className: "pcw-dispatch-args__label", children: "agent" }),
|
|
703
|
+
/* @__PURE__ */ e("span", { className: "pcw-dispatch-args__value pcw-dispatch-args__value--mono", children: n })
|
|
704
|
+
] }),
|
|
705
|
+
t && /* @__PURE__ */ i("div", { className: "pcw-dispatch-args__row", children: [
|
|
706
|
+
/* @__PURE__ */ e("span", { className: "pcw-dispatch-args__label", children: "task" }),
|
|
707
|
+
/* @__PURE__ */ e("span", { className: "pcw-dispatch-args__value", children: t })
|
|
708
|
+
] }),
|
|
709
|
+
a && !t && /* @__PURE__ */ i("div", { className: "pcw-dispatch-args__row", children: [
|
|
710
|
+
/* @__PURE__ */ e("span", { className: "pcw-dispatch-args__label", children: "instruction" }),
|
|
711
|
+
/* @__PURE__ */ e("span", { className: "pcw-dispatch-args__value", children: a })
|
|
712
|
+
] }),
|
|
713
|
+
c && c.length > 0 && /* @__PURE__ */ i("div", { className: "pcw-dispatch-args__row", children: [
|
|
714
|
+
/* @__PURE__ */ e("span", { className: "pcw-dispatch-args__label", children: "kb" }),
|
|
715
|
+
/* @__PURE__ */ e("span", { className: "pcw-dispatch-args__value pcw-dispatch-args__tags", children: c.map((o) => /* @__PURE__ */ e("span", { className: "pcw-dispatch-args__tag", children: o }, o)) })
|
|
716
|
+
] }),
|
|
717
|
+
l && l.length > 0 && /* @__PURE__ */ i("div", { className: "pcw-dispatch-args__row", children: [
|
|
718
|
+
/* @__PURE__ */ e("span", { className: "pcw-dispatch-args__label", children: "tools" }),
|
|
719
|
+
/* @__PURE__ */ e("span", { className: "pcw-dispatch-args__value pcw-dispatch-args__tags", children: l.map((o) => /* @__PURE__ */ e("span", { className: "pcw-dispatch-args__tag", children: o }, o)) })
|
|
720
|
+
] })
|
|
721
|
+
] });
|
|
722
|
+
}
|
|
723
|
+
function We(s) {
|
|
724
|
+
if (!s || s.length === 0) return [];
|
|
725
|
+
const n = [];
|
|
726
|
+
let t = "";
|
|
727
|
+
for (const a of s)
|
|
728
|
+
a.eventType === "thought" && a.text ? t += a.text : (a.eventType === "tool_call_start" || a.eventType === "tool_call_end") && (t && (n.push({ kind: "text", text: t }), t = ""), n.push({ kind: "tool", event: a }));
|
|
729
|
+
return t && n.push({ kind: "text", text: t }), n;
|
|
730
|
+
}
|
|
731
|
+
function Ze({ event: s }) {
|
|
732
|
+
const n = s.eventType === "tool_call_end", t = s.error ? "✗" : n ? "✓" : "⦿", a = s.error ? "pcw-subagent-row__icon--error" : n ? "" : "pcw-subagent-row__icon--running";
|
|
733
|
+
return /* @__PURE__ */ i("div", { className: "pcw-subagent-inline-tool", children: [
|
|
734
|
+
/* @__PURE__ */ e("span", { className: `pcw-subagent-row__icon ${a}`, children: t }),
|
|
735
|
+
/* @__PURE__ */ e("span", { className: "pcw-subagent-row__name", children: s.toolName ?? "unknown" })
|
|
736
|
+
] });
|
|
737
|
+
}
|
|
738
|
+
function Ge({ toolCall: s }) {
|
|
739
|
+
var p;
|
|
740
|
+
const [n, t] = f(!1), a = `pcw-tool-call__status pcw-tool-call__status--${s.status}`, c = s.duration_ms ? `dispatch (${String(s.duration_ms)}ms)` : "dispatch", l = (p = s.subagentEvents) == null ? void 0 : p.find(
|
|
741
|
+
(m) => m.eventType === "complete"
|
|
742
|
+
), o = We(s.subagentEvents), r = o.length > 0, d = o.filter((m) => m.kind === "tool" && m.event.eventType === "tool_call_end").length, u = r || !!(l != null && l.text);
|
|
743
|
+
return /* @__PURE__ */ i("div", { className: "pcw-tool-call", children: [
|
|
744
|
+
/* @__PURE__ */ i("div", { className: "pcw-tool-call__header pcw-tool-call__header--static", children: [
|
|
745
|
+
/* @__PURE__ */ e("span", { className: "pcw-tool-call__name", children: c }),
|
|
746
|
+
/* @__PURE__ */ e("span", { className: a, children: s.status })
|
|
747
|
+
] }),
|
|
748
|
+
s.parameters && /* @__PURE__ */ e(Ve, { params: s.parameters }),
|
|
749
|
+
s.status === "running" && r && /* @__PURE__ */ e("div", { className: "pcw-dispatch-streaming", children: o.map(
|
|
750
|
+
(m, y) => m.kind === "text" ? /* @__PURE__ */ e(ne, { text: m.text }, y) : /* @__PURE__ */ e(Ze, { event: m.event }, y)
|
|
751
|
+
) }),
|
|
752
|
+
s.status !== "running" && u && /* @__PURE__ */ i("div", { className: "pcw-dispatch-details", children: [
|
|
753
|
+
/* @__PURE__ */ i(
|
|
754
|
+
"button",
|
|
755
|
+
{
|
|
756
|
+
type: "button",
|
|
757
|
+
className: "pcw-dispatch-details__toggle",
|
|
758
|
+
onClick: () => t(!n),
|
|
759
|
+
children: [
|
|
760
|
+
/* @__PURE__ */ e("span", { className: "pcw-tool-call__chevron", children: n ? "▼" : "▶" }),
|
|
761
|
+
/* @__PURE__ */ e("span", { children: "details" }),
|
|
762
|
+
d > 0 && /* @__PURE__ */ i("span", { className: "pcw-dispatch-details__count", children: [
|
|
763
|
+
String(d),
|
|
764
|
+
" tool calls"
|
|
765
|
+
] })
|
|
766
|
+
]
|
|
767
|
+
}
|
|
768
|
+
),
|
|
769
|
+
n && /* @__PURE__ */ i("div", { className: "pcw-dispatch-details__body", children: [
|
|
770
|
+
(l == null ? void 0 : l.text) && /* @__PURE__ */ e(ne, { text: l.text, className: "pcw-tool-call__subagent-summary" }),
|
|
771
|
+
o.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-tool-call__subagent", children: o.map(
|
|
772
|
+
(m, y) => m.kind === "text" ? /* @__PURE__ */ e(ne, { text: m.text, className: "pcw-dispatch-inline-text" }, y) : /* @__PURE__ */ e(Ke, { event: m.event }, y)
|
|
773
|
+
) })
|
|
774
|
+
] })
|
|
775
|
+
] }),
|
|
776
|
+
s.error && /* @__PURE__ */ e("p", { className: "pcw-tool-call__error", children: s.error })
|
|
777
|
+
] });
|
|
778
|
+
}
|
|
779
|
+
function be({ toolCall: s }) {
|
|
780
|
+
const [n, t] = f(!1);
|
|
781
|
+
if (s.toolName === "dispatch")
|
|
782
|
+
return /* @__PURE__ */ e(Ge, { toolCall: s });
|
|
783
|
+
const a = `pcw-tool-call__status pcw-tool-call__status--${s.status}`, c = s.duration_ms ? `${s.toolName} (${String(s.duration_ms)}ms)` : s.toolName;
|
|
784
|
+
return /* @__PURE__ */ i("div", { className: "pcw-tool-call", children: [
|
|
785
|
+
/* @__PURE__ */ i(
|
|
786
|
+
"button",
|
|
787
|
+
{
|
|
788
|
+
type: "button",
|
|
789
|
+
className: "pcw-tool-call__header",
|
|
790
|
+
onClick: () => t(!n),
|
|
791
|
+
children: [
|
|
792
|
+
/* @__PURE__ */ e("span", { className: "pcw-tool-call__chevron", children: n ? "▼" : "▶" }),
|
|
793
|
+
/* @__PURE__ */ e("span", { className: "pcw-tool-call__name", children: c }),
|
|
794
|
+
/* @__PURE__ */ e("span", { className: a, children: s.status })
|
|
795
|
+
]
|
|
796
|
+
}
|
|
797
|
+
),
|
|
798
|
+
n && s.parameters && /* @__PURE__ */ e("pre", { className: "pcw-tool-call__details", children: JSON.stringify(s.parameters, null, 2) }),
|
|
799
|
+
s.error && /* @__PURE__ */ e("p", { className: "pcw-tool-call__error", children: s.error })
|
|
800
|
+
] });
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* @license
|
|
804
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
805
|
+
* SPDX-License-Identifier: MIT
|
|
806
|
+
*/
|
|
807
|
+
function ve({ proposal: s }) {
|
|
808
|
+
return /* @__PURE__ */ i("div", { className: "pcw-kb-proposal", children: [
|
|
809
|
+
/* @__PURE__ */ i("div", { className: "pcw-kb-proposal__header", children: [
|
|
810
|
+
/* @__PURE__ */ e("span", { className: "pcw-kb-proposal__icon", children: "💡" }),
|
|
811
|
+
/* @__PURE__ */ e("span", { className: "pcw-kb-proposal__title", children: s.title }),
|
|
812
|
+
/* @__PURE__ */ e("span", { className: "pcw-kb-proposal__scope", children: s.scope })
|
|
813
|
+
] }),
|
|
814
|
+
/* @__PURE__ */ e("p", { className: "pcw-kb-proposal__reasoning", children: s.reasoning })
|
|
815
|
+
] });
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* @license
|
|
819
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
820
|
+
* SPDX-License-Identifier: MIT
|
|
821
|
+
*/
|
|
822
|
+
function fe({ skill: s }) {
|
|
823
|
+
return /* @__PURE__ */ i("span", { className: "pcw-skill-pill", children: [
|
|
824
|
+
"Using: ",
|
|
825
|
+
s
|
|
826
|
+
] });
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* @license
|
|
830
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
831
|
+
* SPDX-License-Identifier: MIT
|
|
832
|
+
*/
|
|
833
|
+
function Je() {
|
|
834
|
+
return /* @__PURE__ */ i("div", { className: "pcw-streaming", "aria-label": "Streaming", children: [
|
|
835
|
+
/* @__PURE__ */ e("span", { className: "pcw-streaming__dot" }),
|
|
836
|
+
/* @__PURE__ */ e("span", { className: "pcw-streaming__dot" }),
|
|
837
|
+
/* @__PURE__ */ e("span", { className: "pcw-streaming__dot" })
|
|
838
|
+
] });
|
|
839
|
+
}
|
|
840
|
+
function Ye({
|
|
841
|
+
question: s,
|
|
842
|
+
index: n,
|
|
843
|
+
value: t,
|
|
844
|
+
onChange: a,
|
|
845
|
+
disabled: c
|
|
846
|
+
}) {
|
|
847
|
+
const l = `ask-user-q-${String(n)}`;
|
|
848
|
+
switch (s.type) {
|
|
849
|
+
case "text":
|
|
850
|
+
return /* @__PURE__ */ i("div", { className: "pcw-ask-user__field", children: [
|
|
851
|
+
/* @__PURE__ */ i("label", { htmlFor: l, className: "pcw-ask-user__label", children: [
|
|
852
|
+
s.header && /* @__PURE__ */ e("span", { className: "pcw-ask-user__header", children: s.header }),
|
|
853
|
+
s.question
|
|
854
|
+
] }),
|
|
855
|
+
/* @__PURE__ */ e(
|
|
856
|
+
"textarea",
|
|
857
|
+
{
|
|
858
|
+
id: l,
|
|
859
|
+
className: "pcw-ask-user__textarea",
|
|
860
|
+
value: t,
|
|
861
|
+
onChange: (o) => a(o.target.value),
|
|
862
|
+
placeholder: s.placeholder ?? "",
|
|
863
|
+
disabled: c,
|
|
864
|
+
rows: 3
|
|
865
|
+
}
|
|
866
|
+
)
|
|
867
|
+
] });
|
|
868
|
+
case "yesno":
|
|
869
|
+
return /* @__PURE__ */ i("div", { className: "pcw-ask-user__field", children: [
|
|
870
|
+
/* @__PURE__ */ i("span", { className: "pcw-ask-user__label", children: [
|
|
871
|
+
s.header && /* @__PURE__ */ e("span", { className: "pcw-ask-user__header", children: s.header }),
|
|
872
|
+
s.question
|
|
873
|
+
] }),
|
|
874
|
+
/* @__PURE__ */ i("div", { className: "pcw-ask-user__yesno", children: [
|
|
875
|
+
/* @__PURE__ */ e(
|
|
876
|
+
"button",
|
|
877
|
+
{
|
|
878
|
+
type: "button",
|
|
879
|
+
className: `pcw-ask-user__yesno-btn ${t === "yes" ? "pcw-ask-user__yesno-btn--active" : ""}`,
|
|
880
|
+
onClick: () => a("yes"),
|
|
881
|
+
disabled: c,
|
|
882
|
+
children: "Yes"
|
|
883
|
+
}
|
|
884
|
+
),
|
|
885
|
+
/* @__PURE__ */ e(
|
|
886
|
+
"button",
|
|
887
|
+
{
|
|
888
|
+
type: "button",
|
|
889
|
+
className: `pcw-ask-user__yesno-btn ${t === "no" ? "pcw-ask-user__yesno-btn--active" : ""}`,
|
|
890
|
+
onClick: () => a("no"),
|
|
891
|
+
disabled: c,
|
|
892
|
+
children: "No"
|
|
893
|
+
}
|
|
894
|
+
)
|
|
895
|
+
] })
|
|
896
|
+
] });
|
|
897
|
+
case "choice": {
|
|
898
|
+
const o = s.options ?? [];
|
|
899
|
+
if (s.multiSelect) {
|
|
900
|
+
const r = t ? t.split(",").filter(Boolean) : [], d = (u) => {
|
|
901
|
+
const p = r.includes(u) ? r.filter((m) => m !== u) : [...r, u];
|
|
902
|
+
a(p.join(","));
|
|
903
|
+
};
|
|
904
|
+
return /* @__PURE__ */ i("div", { className: "pcw-ask-user__field", children: [
|
|
905
|
+
/* @__PURE__ */ i("span", { className: "pcw-ask-user__label", children: [
|
|
906
|
+
s.header && /* @__PURE__ */ e("span", { className: "pcw-ask-user__header", children: s.header }),
|
|
907
|
+
s.question
|
|
908
|
+
] }),
|
|
909
|
+
/* @__PURE__ */ e("div", { className: "pcw-ask-user__choices", children: o.map((u) => /* @__PURE__ */ i("label", { className: "pcw-ask-user__choice", children: [
|
|
910
|
+
/* @__PURE__ */ e(
|
|
911
|
+
"input",
|
|
912
|
+
{
|
|
913
|
+
type: "checkbox",
|
|
914
|
+
checked: r.includes(u.label),
|
|
915
|
+
onChange: () => d(u.label),
|
|
916
|
+
disabled: c
|
|
917
|
+
}
|
|
918
|
+
),
|
|
919
|
+
/* @__PURE__ */ e("span", { className: "pcw-ask-user__choice-label", children: u.label }),
|
|
920
|
+
u.description && /* @__PURE__ */ e("span", { className: "pcw-ask-user__choice-desc", children: u.description })
|
|
921
|
+
] }, u.label)) })
|
|
922
|
+
] });
|
|
923
|
+
}
|
|
924
|
+
return /* @__PURE__ */ i("div", { className: "pcw-ask-user__field", children: [
|
|
925
|
+
/* @__PURE__ */ i("span", { className: "pcw-ask-user__label", children: [
|
|
926
|
+
s.header && /* @__PURE__ */ e("span", { className: "pcw-ask-user__header", children: s.header }),
|
|
927
|
+
s.question
|
|
928
|
+
] }),
|
|
929
|
+
/* @__PURE__ */ e("div", { className: "pcw-ask-user__choices", children: o.map((r) => /* @__PURE__ */ i("label", { className: "pcw-ask-user__choice", children: [
|
|
930
|
+
/* @__PURE__ */ e(
|
|
931
|
+
"input",
|
|
932
|
+
{
|
|
933
|
+
type: "radio",
|
|
934
|
+
name: l,
|
|
935
|
+
checked: t === r.label,
|
|
936
|
+
onChange: () => a(r.label),
|
|
937
|
+
disabled: c
|
|
938
|
+
}
|
|
939
|
+
),
|
|
940
|
+
/* @__PURE__ */ e("span", { className: "pcw-ask-user__choice-label", children: r.label }),
|
|
941
|
+
r.description && /* @__PURE__ */ e("span", { className: "pcw-ask-user__choice-desc", children: r.description })
|
|
942
|
+
] }, r.label)) })
|
|
943
|
+
] });
|
|
944
|
+
}
|
|
945
|
+
default:
|
|
946
|
+
return null;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
function Xe({ block: s, onSubmit: n }) {
|
|
950
|
+
const [t, a] = f({}), [c, l] = f(!1), o = s.status === "submitted", r = o || c, d = () => {
|
|
951
|
+
l(!0), n(s.askId, t);
|
|
952
|
+
};
|
|
953
|
+
return o && s.answers ? /* @__PURE__ */ e("div", { className: "pcw-ask-user pcw-ask-user--submitted", children: s.questions.map((u, p) => {
|
|
954
|
+
var m;
|
|
955
|
+
return /* @__PURE__ */ i("div", { className: "pcw-ask-user__summary", children: [
|
|
956
|
+
/* @__PURE__ */ e("span", { className: "pcw-ask-user__summary-q", children: u.question }),
|
|
957
|
+
/* @__PURE__ */ e("span", { className: "pcw-ask-user__summary-a", children: ((m = s.answers) == null ? void 0 : m[String(p)]) ?? "" })
|
|
958
|
+
] }, `${u.header}-${String(p)}`);
|
|
959
|
+
}) }) : /* @__PURE__ */ i("div", { className: "pcw-ask-user", children: [
|
|
960
|
+
s.questions.map((u, p) => /* @__PURE__ */ e(
|
|
961
|
+
Ye,
|
|
962
|
+
{
|
|
963
|
+
question: u,
|
|
964
|
+
index: p,
|
|
965
|
+
value: t[String(p)] ?? "",
|
|
966
|
+
onChange: (m) => a((y) => ({ ...y, [String(p)]: m })),
|
|
967
|
+
disabled: r
|
|
968
|
+
},
|
|
969
|
+
`${u.header}-${String(p)}`
|
|
970
|
+
)),
|
|
971
|
+
/* @__PURE__ */ e(
|
|
972
|
+
"button",
|
|
973
|
+
{
|
|
974
|
+
type: "button",
|
|
975
|
+
className: "pcw-ask-user__submit",
|
|
976
|
+
onClick: d,
|
|
977
|
+
disabled: r,
|
|
978
|
+
children: c ? "Submitting..." : "Submit"
|
|
979
|
+
}
|
|
980
|
+
)
|
|
981
|
+
] });
|
|
982
|
+
}
|
|
983
|
+
function qe({ data: s, sendMessage: n, onInteraction: t }) {
|
|
984
|
+
const a = s, c = Math.min(100, Math.max(0, a.suspicion_score)), l = b(() => {
|
|
985
|
+
const d = {
|
|
986
|
+
type: "entity_hovered",
|
|
987
|
+
entity: { entityType: "device", entityId: a.mac, source: "widget:entity-card" },
|
|
988
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
989
|
+
};
|
|
990
|
+
t == null || t(d);
|
|
991
|
+
}, [a.mac, t]), o = b(() => {
|
|
992
|
+
const d = {
|
|
993
|
+
type: "entity_unhovered",
|
|
994
|
+
entity: { entityType: "device", entityId: a.mac, source: "widget:entity-card" },
|
|
995
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
996
|
+
};
|
|
997
|
+
t == null || t(d);
|
|
998
|
+
}, [a.mac, t]), r = b(() => {
|
|
999
|
+
const d = {
|
|
1000
|
+
type: "entity_clicked",
|
|
1001
|
+
entity: { entityType: "device", entityId: a.mac, source: "widget:entity-card" },
|
|
1002
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1003
|
+
};
|
|
1004
|
+
t == null || t(d);
|
|
1005
|
+
}, [a.mac, t]);
|
|
1006
|
+
return /* @__PURE__ */ i(
|
|
1007
|
+
"div",
|
|
1008
|
+
{
|
|
1009
|
+
className: "pcw-widget-card pcw-entity-card",
|
|
1010
|
+
onMouseEnter: l,
|
|
1011
|
+
onMouseLeave: o,
|
|
1012
|
+
onClick: r,
|
|
1013
|
+
"data-testid": "entity-card",
|
|
1014
|
+
children: [
|
|
1015
|
+
/* @__PURE__ */ i("div", { className: "pcw-entity-card__header", children: [
|
|
1016
|
+
/* @__PURE__ */ e("span", { className: "pcw-entity-card__mac", children: a.mac }),
|
|
1017
|
+
/* @__PURE__ */ e("span", { className: "pcw-entity-card__mfr", children: a.manufacturer })
|
|
1018
|
+
] }),
|
|
1019
|
+
Array.isArray(a.protocols) && a.protocols.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-entity-card__protocols", children: a.protocols.map((d) => /* @__PURE__ */ e("span", { className: "pcw-entity-card__protocol-badge", children: d }, d)) }),
|
|
1020
|
+
/* @__PURE__ */ i("div", { className: "pcw-entity-card__zone", children: [
|
|
1021
|
+
"Zone ",
|
|
1022
|
+
a.zone,
|
|
1023
|
+
a.zone_name ? ` (${a.zone_name})` : ""
|
|
1024
|
+
] }),
|
|
1025
|
+
/* @__PURE__ */ i("div", { className: "pcw-score-bar", children: [
|
|
1026
|
+
/* @__PURE__ */ i("div", { className: "pcw-score-bar__label", children: [
|
|
1027
|
+
"Score: ",
|
|
1028
|
+
a.suspicion_score
|
|
1029
|
+
] }),
|
|
1030
|
+
/* @__PURE__ */ e("div", { className: "pcw-score-bar__track", children: /* @__PURE__ */ e(
|
|
1031
|
+
"div",
|
|
1032
|
+
{
|
|
1033
|
+
className: "pcw-score-bar__fill",
|
|
1034
|
+
style: { width: `${String(c)}%` }
|
|
1035
|
+
}
|
|
1036
|
+
) })
|
|
1037
|
+
] }),
|
|
1038
|
+
a.score_factors && Object.keys(a.score_factors).length > 0 && /* @__PURE__ */ e("div", { className: "pcw-entity-card__factors", children: Object.entries(a.score_factors).map(([d, u]) => /* @__PURE__ */ i("div", { className: "pcw-entity-card__factor", children: [
|
|
1039
|
+
/* @__PURE__ */ e("span", { children: d.replace(/_/g, " ") }),
|
|
1040
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1041
|
+
"+",
|
|
1042
|
+
u
|
|
1043
|
+
] })
|
|
1044
|
+
] }, d)) }),
|
|
1045
|
+
/* @__PURE__ */ i("div", { className: "pcw-entity-card__meta", children: [
|
|
1046
|
+
/* @__PURE__ */ i("span", { children: [
|
|
1047
|
+
"Tag: ",
|
|
1048
|
+
a.tag_status
|
|
1049
|
+
] }),
|
|
1050
|
+
a.dwell_time_minutes != null && /* @__PURE__ */ i("span", { children: [
|
|
1051
|
+
"Dwell: ",
|
|
1052
|
+
a.dwell_time_minutes,
|
|
1053
|
+
"min"
|
|
1054
|
+
] })
|
|
1055
|
+
] }),
|
|
1056
|
+
/* @__PURE__ */ i("div", { className: "pcw-entity-card__actions", children: [
|
|
1057
|
+
/* @__PURE__ */ e(
|
|
1058
|
+
"button",
|
|
1059
|
+
{
|
|
1060
|
+
type: "button",
|
|
1061
|
+
className: "pcw-entity-card__btn",
|
|
1062
|
+
onClick: () => n(`Investigate device ${a.mac} in Zone ${a.zone}`),
|
|
1063
|
+
children: "Investigate"
|
|
1064
|
+
}
|
|
1065
|
+
),
|
|
1066
|
+
/* @__PURE__ */ e(
|
|
1067
|
+
"button",
|
|
1068
|
+
{
|
|
1069
|
+
type: "button",
|
|
1070
|
+
className: "pcw-entity-card__btn pcw-entity-card__btn--secondary",
|
|
1071
|
+
onClick: () => n(`Tag device ${a.mac} as suspicious`),
|
|
1072
|
+
children: "Tag"
|
|
1073
|
+
}
|
|
1074
|
+
)
|
|
1075
|
+
] })
|
|
1076
|
+
]
|
|
1077
|
+
}
|
|
1078
|
+
);
|
|
1079
|
+
}
|
|
1080
|
+
function Qe({ data: s, sendMessage: n }) {
|
|
1081
|
+
const t = s, [a, c] = f(null), [l, o] = f(t.sort ?? "suspicion_score"), r = [...t.devices].sort((p, m) => l === "suspicion_score" ? m.suspicion_score - p.suspicion_score : l === "mac" ? p.mac.localeCompare(m.mac) : l === "zone" ? p.zone.localeCompare(m.zone) : 0), d = t.max_display ?? r.length, u = r.slice(0, d);
|
|
1082
|
+
return /* @__PURE__ */ i("div", { className: "pcw-widget-card pcw-entity-list", children: [
|
|
1083
|
+
t.title && /* @__PURE__ */ e("div", { className: "pcw-entity-list__title", children: t.title }),
|
|
1084
|
+
/* @__PURE__ */ i("div", { className: "pcw-entity-list__sort", children: [
|
|
1085
|
+
"Sort:",
|
|
1086
|
+
["suspicion_score", "mac", "zone"].map((p) => /* @__PURE__ */ e(
|
|
1087
|
+
"button",
|
|
1088
|
+
{
|
|
1089
|
+
type: "button",
|
|
1090
|
+
className: `pcw-entity-list__sort-btn ${l === p ? "pcw-entity-list__sort-btn--active" : ""}`,
|
|
1091
|
+
onClick: () => o(p),
|
|
1092
|
+
children: p.replace(/_/g, " ")
|
|
1093
|
+
},
|
|
1094
|
+
p
|
|
1095
|
+
))
|
|
1096
|
+
] }),
|
|
1097
|
+
/* @__PURE__ */ i("table", { className: "pcw-data-table__table", children: [
|
|
1098
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ i("tr", { children: [
|
|
1099
|
+
/* @__PURE__ */ e("th", { children: "MAC" }),
|
|
1100
|
+
/* @__PURE__ */ e("th", { children: "Mfr" }),
|
|
1101
|
+
/* @__PURE__ */ e("th", { children: "Zone" }),
|
|
1102
|
+
/* @__PURE__ */ e("th", { children: "Score" }),
|
|
1103
|
+
/* @__PURE__ */ e("th", { children: "Tag" })
|
|
1104
|
+
] }) }),
|
|
1105
|
+
/* @__PURE__ */ e("tbody", { children: u.map((p) => /* @__PURE__ */ i(
|
|
1106
|
+
"tr",
|
|
1107
|
+
{
|
|
1108
|
+
className: `pcw-entity-list__row ${a === p.mac ? "pcw-entity-list__row--expanded" : ""}`,
|
|
1109
|
+
onClick: () => c(a === p.mac ? null : p.mac),
|
|
1110
|
+
children: [
|
|
1111
|
+
/* @__PURE__ */ e("td", { className: "pcw-entity-list__mac", children: p.mac }),
|
|
1112
|
+
/* @__PURE__ */ e("td", { children: p.manufacturer }),
|
|
1113
|
+
/* @__PURE__ */ e("td", { children: p.zone }),
|
|
1114
|
+
/* @__PURE__ */ e("td", { children: p.suspicion_score }),
|
|
1115
|
+
/* @__PURE__ */ e("td", { children: p.tag_status })
|
|
1116
|
+
]
|
|
1117
|
+
},
|
|
1118
|
+
p.mac
|
|
1119
|
+
)) })
|
|
1120
|
+
] }),
|
|
1121
|
+
a && /* @__PURE__ */ e("div", { className: "pcw-entity-list__detail", children: /* @__PURE__ */ i(
|
|
1122
|
+
"button",
|
|
1123
|
+
{
|
|
1124
|
+
type: "button",
|
|
1125
|
+
className: "pcw-entity-card__btn",
|
|
1126
|
+
onClick: () => n(`Tell me more about device ${a}`),
|
|
1127
|
+
children: [
|
|
1128
|
+
"Investigate ",
|
|
1129
|
+
a
|
|
1130
|
+
]
|
|
1131
|
+
}
|
|
1132
|
+
) }),
|
|
1133
|
+
r.length > d && /* @__PURE__ */ i("div", { className: "pcw-entity-list__more", children: [
|
|
1134
|
+
"+",
|
|
1135
|
+
r.length - d,
|
|
1136
|
+
" more devices"
|
|
1137
|
+
] })
|
|
1138
|
+
] });
|
|
1139
|
+
}
|
|
1140
|
+
const et = {
|
|
1141
|
+
A: { x: 10, y: 10, w: 80, h: 60 },
|
|
1142
|
+
B: { x: 100, y: 10, w: 80, h: 60 },
|
|
1143
|
+
C: { x: 190, y: 10, w: 80, h: 60 },
|
|
1144
|
+
D: { x: 10, y: 80, w: 125, h: 60 },
|
|
1145
|
+
E: { x: 145, y: 80, w: 125, h: 60 }
|
|
1146
|
+
}, tt = {
|
|
1147
|
+
A: "Lobby",
|
|
1148
|
+
B: "Offices",
|
|
1149
|
+
C: "Server Room",
|
|
1150
|
+
D: "Warehouse",
|
|
1151
|
+
E: "Parking"
|
|
1152
|
+
};
|
|
1153
|
+
function st({ data: s, onInteraction: n }) {
|
|
1154
|
+
const t = s, a = new Set(t.highlight_zones ?? []), c = b(
|
|
1155
|
+
(o, r) => {
|
|
1156
|
+
const d = {
|
|
1157
|
+
type: o,
|
|
1158
|
+
entity: { entityType: "zone", entityId: r, source: "widget:scope-map" },
|
|
1159
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1160
|
+
};
|
|
1161
|
+
n == null || n(d);
|
|
1162
|
+
},
|
|
1163
|
+
[n]
|
|
1164
|
+
), l = b(
|
|
1165
|
+
(o, r) => {
|
|
1166
|
+
const d = {
|
|
1167
|
+
type: o,
|
|
1168
|
+
entity: { entityType: "device", entityId: r, source: "widget:scope-map" },
|
|
1169
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1170
|
+
};
|
|
1171
|
+
n == null || n(d);
|
|
1172
|
+
},
|
|
1173
|
+
[n]
|
|
1174
|
+
);
|
|
1175
|
+
return /* @__PURE__ */ i("div", { className: "pcw-widget-card pcw-scope-map", children: [
|
|
1176
|
+
t.label && /* @__PURE__ */ e("div", { className: "pcw-scope-map__label", children: t.label }),
|
|
1177
|
+
/* @__PURE__ */ e("svg", { viewBox: "0 0 280 150", className: "pcw-scope-map__svg", children: Object.entries(et).map(([o, r]) => /* @__PURE__ */ i("g", { children: [
|
|
1178
|
+
/* @__PURE__ */ e(
|
|
1179
|
+
"rect",
|
|
1180
|
+
{
|
|
1181
|
+
x: r.x,
|
|
1182
|
+
y: r.y,
|
|
1183
|
+
width: r.w,
|
|
1184
|
+
height: r.h,
|
|
1185
|
+
rx: 4,
|
|
1186
|
+
className: a.has(o) ? "pcw-scope-map__zone pcw-scope-map__zone--highlight" : "pcw-scope-map__zone",
|
|
1187
|
+
"data-testid": `zone-${o}`,
|
|
1188
|
+
onMouseEnter: () => c("entity_hovered", o),
|
|
1189
|
+
onMouseLeave: () => c("entity_unhovered", o),
|
|
1190
|
+
onClick: () => c("entity_clicked", o),
|
|
1191
|
+
style: { cursor: "pointer" }
|
|
1192
|
+
}
|
|
1193
|
+
),
|
|
1194
|
+
/* @__PURE__ */ i(
|
|
1195
|
+
"text",
|
|
1196
|
+
{
|
|
1197
|
+
x: r.x + r.w / 2,
|
|
1198
|
+
y: r.y + r.h / 2 - 6,
|
|
1199
|
+
textAnchor: "middle",
|
|
1200
|
+
className: "pcw-scope-map__zone-label",
|
|
1201
|
+
style: { pointerEvents: "none" },
|
|
1202
|
+
children: [
|
|
1203
|
+
"Zone ",
|
|
1204
|
+
o
|
|
1205
|
+
]
|
|
1206
|
+
}
|
|
1207
|
+
),
|
|
1208
|
+
/* @__PURE__ */ e(
|
|
1209
|
+
"text",
|
|
1210
|
+
{
|
|
1211
|
+
x: r.x + r.w / 2,
|
|
1212
|
+
y: r.y + r.h / 2 + 8,
|
|
1213
|
+
textAnchor: "middle",
|
|
1214
|
+
className: "pcw-scope-map__zone-name",
|
|
1215
|
+
style: { pointerEvents: "none" },
|
|
1216
|
+
children: tt[o] ?? ""
|
|
1217
|
+
}
|
|
1218
|
+
)
|
|
1219
|
+
] }, o)) }),
|
|
1220
|
+
t.highlight_devices && t.highlight_devices.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-scope-map__devices", children: t.highlight_devices.map((o) => /* @__PURE__ */ e(
|
|
1221
|
+
"span",
|
|
1222
|
+
{
|
|
1223
|
+
className: "pcw-scope-map__device-badge",
|
|
1224
|
+
"data-testid": `device-badge-${o}`,
|
|
1225
|
+
onMouseEnter: () => l("entity_hovered", o),
|
|
1226
|
+
onMouseLeave: () => l("entity_unhovered", o),
|
|
1227
|
+
onClick: () => l("entity_clicked", o),
|
|
1228
|
+
style: { cursor: "pointer" },
|
|
1229
|
+
children: o
|
|
1230
|
+
},
|
|
1231
|
+
o
|
|
1232
|
+
)) })
|
|
1233
|
+
] });
|
|
1234
|
+
}
|
|
1235
|
+
/**
|
|
1236
|
+
* @license
|
|
1237
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
1238
|
+
* SPDX-License-Identifier: MIT
|
|
1239
|
+
*/
|
|
1240
|
+
const at = {
|
|
1241
|
+
low: "pcw-alert-card__severity--low",
|
|
1242
|
+
medium: "pcw-alert-card__severity--medium",
|
|
1243
|
+
high: "pcw-alert-card__severity--high",
|
|
1244
|
+
critical: "pcw-alert-card__severity--critical"
|
|
1245
|
+
};
|
|
1246
|
+
function nt({ data: s, sendMessage: n }) {
|
|
1247
|
+
const t = s;
|
|
1248
|
+
return /* @__PURE__ */ i("div", { className: "pcw-widget-card pcw-alert-card", children: [
|
|
1249
|
+
/* @__PURE__ */ i("div", { className: "pcw-alert-card__header", children: [
|
|
1250
|
+
/* @__PURE__ */ e("span", { className: `pcw-alert-card__severity ${at[t.severity] ?? ""}`, children: t.severity.toUpperCase() }),
|
|
1251
|
+
/* @__PURE__ */ e("span", { className: "pcw-alert-card__type", children: t.type.replace(/_/g, " ") }),
|
|
1252
|
+
/* @__PURE__ */ i("span", { className: "pcw-alert-card__zone", children: [
|
|
1253
|
+
"Zone ",
|
|
1254
|
+
t.zone
|
|
1255
|
+
] })
|
|
1256
|
+
] }),
|
|
1257
|
+
/* @__PURE__ */ e("p", { className: "pcw-alert-card__description", children: t.description }),
|
|
1258
|
+
/* @__PURE__ */ e("div", { className: "pcw-alert-card__devices", children: t.involved_devices.map((a) => /* @__PURE__ */ e(
|
|
1259
|
+
"button",
|
|
1260
|
+
{
|
|
1261
|
+
type: "button",
|
|
1262
|
+
className: "pcw-alert-card__device-link",
|
|
1263
|
+
onClick: () => n(`Tell me about device ${a}`),
|
|
1264
|
+
children: a
|
|
1265
|
+
},
|
|
1266
|
+
a
|
|
1267
|
+
)) }),
|
|
1268
|
+
t.protocols_involved && t.protocols_involved.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-alert-card__protocols", children: t.protocols_involved.map((a) => /* @__PURE__ */ e("span", { className: "pcw-entity-card__protocol-badge", children: a }, a)) }),
|
|
1269
|
+
/* @__PURE__ */ e("div", { className: "pcw-alert-card__time", children: new Date(t.detected_at).toLocaleString() })
|
|
1270
|
+
] });
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* @license
|
|
1274
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
1275
|
+
* SPDX-License-Identifier: MIT
|
|
1276
|
+
*/
|
|
1277
|
+
const Ne = {
|
|
1278
|
+
device_seen: "#3b82f6",
|
|
1279
|
+
zone_change: "#8b5cf6",
|
|
1280
|
+
alert: "#ef4444",
|
|
1281
|
+
tag_change: "#10b981",
|
|
1282
|
+
custom: "#6b7280"
|
|
1283
|
+
};
|
|
1284
|
+
function ct({ data: s, sendMessage: n }) {
|
|
1285
|
+
const t = s;
|
|
1286
|
+
return /* @__PURE__ */ i("div", { className: "pcw-widget-card pcw-timeline", children: [
|
|
1287
|
+
t.label && /* @__PURE__ */ e("div", { className: "pcw-timeline__label", children: t.label }),
|
|
1288
|
+
/* @__PURE__ */ e("div", { className: "pcw-timeline__events", children: t.events.map((a, c) => {
|
|
1289
|
+
const l = Ne[a.type ?? "custom"] ?? Ne.custom;
|
|
1290
|
+
return /* @__PURE__ */ i("div", { className: "pcw-timeline__event", children: [
|
|
1291
|
+
/* @__PURE__ */ e("div", { className: "pcw-timeline__marker", style: { backgroundColor: l } }),
|
|
1292
|
+
/* @__PURE__ */ i("div", { className: "pcw-timeline__content", children: [
|
|
1293
|
+
/* @__PURE__ */ e("span", { className: "pcw-timeline__time", children: new Date(a.timestamp).toLocaleTimeString(void 0, {
|
|
1294
|
+
hour: "2-digit",
|
|
1295
|
+
minute: "2-digit"
|
|
1296
|
+
}) }),
|
|
1297
|
+
/* @__PURE__ */ e("span", { className: "pcw-timeline__event-label", children: a.label }),
|
|
1298
|
+
a.device && /* @__PURE__ */ e(
|
|
1299
|
+
"button",
|
|
1300
|
+
{
|
|
1301
|
+
type: "button",
|
|
1302
|
+
className: "pcw-alert-card__device-link",
|
|
1303
|
+
onClick: () => n(`Tell me about device ${a.device}`),
|
|
1304
|
+
children: a.device
|
|
1305
|
+
}
|
|
1306
|
+
)
|
|
1307
|
+
] })
|
|
1308
|
+
] }, `${a.timestamp}-${String(c)}`);
|
|
1309
|
+
}) })
|
|
1310
|
+
] });
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* @license
|
|
1314
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
1315
|
+
* SPDX-License-Identifier: MIT
|
|
1316
|
+
*/
|
|
1317
|
+
function rt({ data: s, sendMessage: n }) {
|
|
1318
|
+
const t = s;
|
|
1319
|
+
return /* @__PURE__ */ i("div", { className: "pcw-widget-card pcw-comparison", children: [
|
|
1320
|
+
t.title && /* @__PURE__ */ e("div", { className: "pcw-comparison__title", children: t.title }),
|
|
1321
|
+
/* @__PURE__ */ e("div", { className: "pcw-comparison__grid", children: t.items.map((a) => /* @__PURE__ */ i("div", { className: "pcw-comparison__item", children: [
|
|
1322
|
+
/* @__PURE__ */ e("div", { className: "pcw-comparison__mac", children: a.mac }),
|
|
1323
|
+
/* @__PURE__ */ e("div", { className: "pcw-comparison__detail", children: a.manufacturer }),
|
|
1324
|
+
/* @__PURE__ */ e("div", { className: "pcw-comparison__detail", children: a.protocols.join(", ") }),
|
|
1325
|
+
/* @__PURE__ */ i("div", { className: "pcw-comparison__detail", children: [
|
|
1326
|
+
"Zone ",
|
|
1327
|
+
a.zone
|
|
1328
|
+
] }),
|
|
1329
|
+
/* @__PURE__ */ i("div", { className: "pcw-comparison__score", children: [
|
|
1330
|
+
"Score: ",
|
|
1331
|
+
a.suspicion_score
|
|
1332
|
+
] }),
|
|
1333
|
+
/* @__PURE__ */ i("div", { className: "pcw-comparison__detail", children: [
|
|
1334
|
+
"Tag: ",
|
|
1335
|
+
a.tag_status
|
|
1336
|
+
] }),
|
|
1337
|
+
/* @__PURE__ */ e(
|
|
1338
|
+
"button",
|
|
1339
|
+
{
|
|
1340
|
+
type: "button",
|
|
1341
|
+
className: "pcw-entity-card__btn",
|
|
1342
|
+
onClick: () => n(`Investigate device ${a.mac}`),
|
|
1343
|
+
children: "Investigate"
|
|
1344
|
+
}
|
|
1345
|
+
)
|
|
1346
|
+
] }, a.mac)) })
|
|
1347
|
+
] });
|
|
1348
|
+
}
|
|
1349
|
+
function it({ data: s }) {
|
|
1350
|
+
const n = s, t = n.columns ?? [], a = n.rows ?? [], [c, l] = f(null), [o, r] = f("asc"), d = b(
|
|
1351
|
+
(p) => {
|
|
1352
|
+
n.sortable && (c === p ? r((m) => m === "asc" ? "desc" : "asc") : (l(p), r("asc")));
|
|
1353
|
+
},
|
|
1354
|
+
[n.sortable, c]
|
|
1355
|
+
), u = c ? [...a].sort((p, m) => {
|
|
1356
|
+
const y = p[c], w = m[c];
|
|
1357
|
+
if (typeof y == "number" && typeof w == "number")
|
|
1358
|
+
return o === "asc" ? y - w : w - y;
|
|
1359
|
+
const g = String(y ?? ""), h = String(w ?? "");
|
|
1360
|
+
return o === "asc" ? g.localeCompare(h) : h.localeCompare(g);
|
|
1361
|
+
}) : a;
|
|
1362
|
+
return /* @__PURE__ */ i("div", { className: "pcw-widget-card pcw-data-table", children: [
|
|
1363
|
+
n.title && /* @__PURE__ */ e("div", { className: "pcw-data-table__title", children: n.title }),
|
|
1364
|
+
/* @__PURE__ */ e("div", { className: "pcw-data-table__scroll", children: /* @__PURE__ */ i("table", { className: "pcw-data-table__table", children: [
|
|
1365
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { children: t.map((p) => /* @__PURE__ */ i(
|
|
1366
|
+
"th",
|
|
1367
|
+
{
|
|
1368
|
+
onClick: () => d(p.key),
|
|
1369
|
+
className: n.sortable ? "pcw-data-table__sortable" : "",
|
|
1370
|
+
children: [
|
|
1371
|
+
p.label,
|
|
1372
|
+
c === p.key && (o === "asc" ? " ▲" : " ▼")
|
|
1373
|
+
]
|
|
1374
|
+
},
|
|
1375
|
+
p.key
|
|
1376
|
+
)) }) }),
|
|
1377
|
+
/* @__PURE__ */ e("tbody", { children: u.map((p, m) => /* @__PURE__ */ e("tr", { children: t.map((y) => /* @__PURE__ */ e("td", { children: String(p[y.key] ?? "") }, y.key)) }, String(m))) })
|
|
1378
|
+
] }) })
|
|
1379
|
+
] });
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* @license
|
|
1383
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
1384
|
+
* SPDX-License-Identifier: MIT
|
|
1385
|
+
*/
|
|
1386
|
+
function lt({ data: s }) {
|
|
1387
|
+
const n = s, t = n.max_score ?? 100, a = Math.min(100, Math.max(0, n.total_score / t * 100));
|
|
1388
|
+
return /* @__PURE__ */ i("div", { className: "pcw-widget-card pcw-score-breakdown", children: [
|
|
1389
|
+
n.label && /* @__PURE__ */ e("div", { className: "pcw-score-breakdown__label", children: n.label }),
|
|
1390
|
+
/* @__PURE__ */ i("div", { className: "pcw-score-bar", children: [
|
|
1391
|
+
/* @__PURE__ */ i("div", { className: "pcw-score-bar__label", children: [
|
|
1392
|
+
"Score: ",
|
|
1393
|
+
n.total_score,
|
|
1394
|
+
t !== 100 ? ` / ${t}` : ""
|
|
1395
|
+
] }),
|
|
1396
|
+
/* @__PURE__ */ e("div", { className: "pcw-score-bar__track", children: /* @__PURE__ */ e(
|
|
1397
|
+
"div",
|
|
1398
|
+
{
|
|
1399
|
+
className: "pcw-score-bar__fill",
|
|
1400
|
+
style: { width: `${String(a)}%` }
|
|
1401
|
+
}
|
|
1402
|
+
) })
|
|
1403
|
+
] }),
|
|
1404
|
+
/* @__PURE__ */ e("div", { className: "pcw-score-breakdown__factors", children: n.factors.map((c) => {
|
|
1405
|
+
const l = c.max ?? t, o = Math.min(100, Math.max(0, c.value / l * 100));
|
|
1406
|
+
return /* @__PURE__ */ i("div", { className: "pcw-score-breakdown__factor", children: [
|
|
1407
|
+
/* @__PURE__ */ i("div", { className: "pcw-score-breakdown__factor-header", children: [
|
|
1408
|
+
/* @__PURE__ */ e("span", { className: "pcw-score-breakdown__factor-name", children: c.name.replace(/_/g, " ") }),
|
|
1409
|
+
/* @__PURE__ */ i("span", { className: "pcw-score-breakdown__factor-value", children: [
|
|
1410
|
+
"+",
|
|
1411
|
+
c.value
|
|
1412
|
+
] })
|
|
1413
|
+
] }),
|
|
1414
|
+
/* @__PURE__ */ e("div", { className: "pcw-score-breakdown__factor-bar", children: /* @__PURE__ */ e(
|
|
1415
|
+
"div",
|
|
1416
|
+
{
|
|
1417
|
+
className: "pcw-score-breakdown__factor-fill",
|
|
1418
|
+
style: { width: `${String(o)}%` }
|
|
1419
|
+
}
|
|
1420
|
+
) }),
|
|
1421
|
+
c.description && /* @__PURE__ */ e("div", { className: "pcw-score-breakdown__factor-desc", children: c.description })
|
|
1422
|
+
] }, c.name);
|
|
1423
|
+
}) })
|
|
1424
|
+
] });
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* @license
|
|
1428
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
1429
|
+
* SPDX-License-Identifier: MIT
|
|
1430
|
+
*/
|
|
1431
|
+
const Se = {
|
|
1432
|
+
critical: 0,
|
|
1433
|
+
high: 1,
|
|
1434
|
+
medium: 2,
|
|
1435
|
+
low: 3
|
|
1436
|
+
};
|
|
1437
|
+
function ot({ data: s, sendMessage: n }) {
|
|
1438
|
+
const t = s, a = [...t.items].sort(
|
|
1439
|
+
(c, l) => (Se[c.severity] ?? 4) - (Se[l.severity] ?? 4)
|
|
1440
|
+
);
|
|
1441
|
+
return /* @__PURE__ */ i("div", { className: "pcw-widget-card pcw-status-board", children: [
|
|
1442
|
+
t.title && /* @__PURE__ */ e("div", { className: "pcw-status-board__title", children: t.title }),
|
|
1443
|
+
/* @__PURE__ */ e("div", { className: "pcw-status-board__items", children: a.map((c) => /* @__PURE__ */ i(
|
|
1444
|
+
"div",
|
|
1445
|
+
{
|
|
1446
|
+
className: `pcw-status-board__item pcw-status-board__item--${c.severity}`,
|
|
1447
|
+
onClick: () => n(`Tell me more about ${c.label}`),
|
|
1448
|
+
style: { cursor: "pointer" },
|
|
1449
|
+
children: [
|
|
1450
|
+
/* @__PURE__ */ i("div", { className: "pcw-status-board__item-header", children: [
|
|
1451
|
+
/* @__PURE__ */ e("span", { className: `pcw-status-board__severity pcw-status-board__severity--${c.severity}`, children: c.severity.toUpperCase() }),
|
|
1452
|
+
/* @__PURE__ */ e("span", { className: "pcw-status-board__item-label", children: c.label }),
|
|
1453
|
+
/* @__PURE__ */ e("span", { className: "pcw-status-board__item-status", children: c.status })
|
|
1454
|
+
] }),
|
|
1455
|
+
c.description && /* @__PURE__ */ e("div", { className: "pcw-status-board__item-desc", children: c.description })
|
|
1456
|
+
]
|
|
1457
|
+
},
|
|
1458
|
+
c.id
|
|
1459
|
+
)) })
|
|
1460
|
+
] });
|
|
1461
|
+
}
|
|
1462
|
+
function dt({ data: s, sendMessage: n }) {
|
|
1463
|
+
const t = s, [a, c] = f({}), [l, o] = f("idle"), [r, d] = f(""), u = b((m, y) => {
|
|
1464
|
+
c((w) => ({ ...w, [m]: y }));
|
|
1465
|
+
}, []), p = b(
|
|
1466
|
+
async (m) => {
|
|
1467
|
+
m.preventDefault(), o("submitting"), d("");
|
|
1468
|
+
try {
|
|
1469
|
+
const w = `${window.location.origin}/api/tenants/${t.tenant_id}/secrets`;
|
|
1470
|
+
for (const g of t.fields) {
|
|
1471
|
+
const h = await fetch(w, {
|
|
1472
|
+
method: "POST",
|
|
1473
|
+
headers: { "Content-Type": "application/json" },
|
|
1474
|
+
body: JSON.stringify({
|
|
1475
|
+
name: g.name,
|
|
1476
|
+
value: a[g.name] ?? "",
|
|
1477
|
+
connection_name: t.connection_name
|
|
1478
|
+
})
|
|
1479
|
+
});
|
|
1480
|
+
if (!h.ok)
|
|
1481
|
+
throw new Error(`Failed to save ${g.label}: ${String(h.status)}`);
|
|
1482
|
+
}
|
|
1483
|
+
o("success"), c({}), n(`Credentials for ${t.connection_name} have been saved.`);
|
|
1484
|
+
} catch (y) {
|
|
1485
|
+
o("error"), d(y instanceof Error ? y.message : "Failed to save credentials");
|
|
1486
|
+
}
|
|
1487
|
+
},
|
|
1488
|
+
[t.tenant_id, t.connection_name, t.fields, a, n]
|
|
1489
|
+
);
|
|
1490
|
+
return l === "success" ? /* @__PURE__ */ e("div", { className: "pcw-widget-card pcw-widget-card--credential-input", children: /* @__PURE__ */ i("div", { className: "pcw-credential-input__status pcw-credential-input__status--success", children: [
|
|
1491
|
+
"Credentials for ",
|
|
1492
|
+
t.connection_name,
|
|
1493
|
+
" saved successfully."
|
|
1494
|
+
] }) }) : /* @__PURE__ */ i("div", { className: "pcw-widget-card pcw-widget-card--credential-input", children: [
|
|
1495
|
+
/* @__PURE__ */ i("div", { className: "pcw-credential-input__title", children: [
|
|
1496
|
+
"Configure ",
|
|
1497
|
+
t.connection_name
|
|
1498
|
+
] }),
|
|
1499
|
+
/* @__PURE__ */ i(
|
|
1500
|
+
"form",
|
|
1501
|
+
{
|
|
1502
|
+
onSubmit: (m) => {
|
|
1503
|
+
p(m);
|
|
1504
|
+
},
|
|
1505
|
+
children: [
|
|
1506
|
+
t.fields.map((m) => /* @__PURE__ */ i("div", { className: "pcw-credential-input__field", children: [
|
|
1507
|
+
/* @__PURE__ */ i("label", { className: "pcw-credential-input__label", htmlFor: `pcw-cred-${m.name}`, children: [
|
|
1508
|
+
m.label,
|
|
1509
|
+
m.required && /* @__PURE__ */ e("span", { "aria-hidden": "true", children: " *" })
|
|
1510
|
+
] }),
|
|
1511
|
+
/* @__PURE__ */ e(
|
|
1512
|
+
"input",
|
|
1513
|
+
{
|
|
1514
|
+
id: `pcw-cred-${m.name}`,
|
|
1515
|
+
className: "pcw-credential-input__input",
|
|
1516
|
+
type: m.type,
|
|
1517
|
+
required: m.required,
|
|
1518
|
+
autoComplete: m.type === "password" ? "new-password" : "off",
|
|
1519
|
+
value: a[m.name] ?? "",
|
|
1520
|
+
disabled: l === "submitting",
|
|
1521
|
+
onChange: (y) => u(m.name, y.target.value)
|
|
1522
|
+
}
|
|
1523
|
+
)
|
|
1524
|
+
] }, m.name)),
|
|
1525
|
+
l === "error" && /* @__PURE__ */ e("div", { className: "pcw-credential-input__status pcw-credential-input__status--error", children: r }),
|
|
1526
|
+
/* @__PURE__ */ e(
|
|
1527
|
+
"button",
|
|
1528
|
+
{
|
|
1529
|
+
type: "submit",
|
|
1530
|
+
className: "pcw-credential-input__submit",
|
|
1531
|
+
disabled: l === "submitting",
|
|
1532
|
+
children: l === "submitting" ? "Saving..." : "Save Credentials"
|
|
1533
|
+
}
|
|
1534
|
+
)
|
|
1535
|
+
]
|
|
1536
|
+
}
|
|
1537
|
+
)
|
|
1538
|
+
] });
|
|
1539
|
+
}
|
|
1540
|
+
const pt = {
|
|
1541
|
+
create: "New",
|
|
1542
|
+
update: "Update"
|
|
1543
|
+
};
|
|
1544
|
+
function ut({ data: s, sendMessage: n }) {
|
|
1545
|
+
const t = s, [a, c] = f(!1), [l, o] = f(t.body), [r, d] = f(!1), u = b(() => {
|
|
1546
|
+
d(!0), n(`I've approved the ${t.resource_type} '${t.preview_id}'.`);
|
|
1547
|
+
}, [t.resource_type, t.preview_id, n]), p = b(() => {
|
|
1548
|
+
c(!0);
|
|
1549
|
+
}, []), m = b(() => {
|
|
1550
|
+
d(!0), c(!1), n(
|
|
1551
|
+
`I've approved the ${t.resource_type} '${t.preview_id}' with edits:
|
|
1552
|
+
|
|
1553
|
+
${l}`
|
|
1554
|
+
);
|
|
1555
|
+
}, [t.resource_type, t.preview_id, l, n]);
|
|
1556
|
+
return r ? /* @__PURE__ */ e("div", { className: "pcw-widget-card pcw-widget-card--document-preview", children: /* @__PURE__ */ i("div", { className: "pcw-document-preview__header", children: [
|
|
1557
|
+
/* @__PURE__ */ e("span", { className: "pcw-document-preview__title", children: t.title }),
|
|
1558
|
+
/* @__PURE__ */ e("span", { className: "pcw-document-preview__badge pcw-document-preview__badge--approved", children: "Approved" })
|
|
1559
|
+
] }) }) : /* @__PURE__ */ i("div", { className: "pcw-widget-card pcw-widget-card--document-preview", children: [
|
|
1560
|
+
/* @__PURE__ */ i("div", { className: "pcw-document-preview__header", children: [
|
|
1561
|
+
/* @__PURE__ */ e("span", { className: "pcw-document-preview__title", children: t.title }),
|
|
1562
|
+
t.category && /* @__PURE__ */ e("span", { className: "pcw-document-preview__badge pcw-document-preview__badge--category", children: t.category }),
|
|
1563
|
+
/* @__PURE__ */ e("span", { className: "pcw-document-preview__badge pcw-document-preview__badge--action", children: pt[t.action] ?? t.action })
|
|
1564
|
+
] }),
|
|
1565
|
+
a ? /* @__PURE__ */ i("div", { className: "pcw-document-preview__editor-container", children: [
|
|
1566
|
+
/* @__PURE__ */ e(
|
|
1567
|
+
"textarea",
|
|
1568
|
+
{
|
|
1569
|
+
className: "pcw-document-preview__editor",
|
|
1570
|
+
value: l,
|
|
1571
|
+
onChange: (y) => o(y.target.value),
|
|
1572
|
+
rows: 12
|
|
1573
|
+
}
|
|
1574
|
+
),
|
|
1575
|
+
/* @__PURE__ */ i("div", { className: "pcw-document-preview__actions", children: [
|
|
1576
|
+
/* @__PURE__ */ e(
|
|
1577
|
+
"button",
|
|
1578
|
+
{
|
|
1579
|
+
type: "button",
|
|
1580
|
+
className: "pcw-document-preview__btn pcw-document-preview__btn--primary",
|
|
1581
|
+
onClick: m,
|
|
1582
|
+
children: "Approve with edits"
|
|
1583
|
+
}
|
|
1584
|
+
),
|
|
1585
|
+
/* @__PURE__ */ e(
|
|
1586
|
+
"button",
|
|
1587
|
+
{
|
|
1588
|
+
type: "button",
|
|
1589
|
+
className: "pcw-document-preview__btn pcw-document-preview__btn--secondary",
|
|
1590
|
+
onClick: () => {
|
|
1591
|
+
c(!1), o(t.body);
|
|
1592
|
+
},
|
|
1593
|
+
children: "Cancel"
|
|
1594
|
+
}
|
|
1595
|
+
)
|
|
1596
|
+
] })
|
|
1597
|
+
] }) : /* @__PURE__ */ i($e, { children: [
|
|
1598
|
+
/* @__PURE__ */ e("pre", { className: "pcw-document-preview__body", children: /* @__PURE__ */ e("code", { children: t.body }) }),
|
|
1599
|
+
/* @__PURE__ */ i("div", { className: "pcw-document-preview__actions", children: [
|
|
1600
|
+
/* @__PURE__ */ e(
|
|
1601
|
+
"button",
|
|
1602
|
+
{
|
|
1603
|
+
type: "button",
|
|
1604
|
+
className: "pcw-document-preview__btn pcw-document-preview__btn--primary",
|
|
1605
|
+
onClick: u,
|
|
1606
|
+
children: "Approve"
|
|
1607
|
+
}
|
|
1608
|
+
),
|
|
1609
|
+
/* @__PURE__ */ e(
|
|
1610
|
+
"button",
|
|
1611
|
+
{
|
|
1612
|
+
type: "button",
|
|
1613
|
+
className: "pcw-document-preview__btn pcw-document-preview__btn--secondary",
|
|
1614
|
+
onClick: p,
|
|
1615
|
+
children: "Edit First"
|
|
1616
|
+
}
|
|
1617
|
+
)
|
|
1618
|
+
] })
|
|
1619
|
+
] })
|
|
1620
|
+
] });
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* @license
|
|
1624
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
1625
|
+
* SPDX-License-Identifier: MIT
|
|
1626
|
+
*/
|
|
1627
|
+
function mt({ data: s, sendMessage: n }) {
|
|
1628
|
+
const t = s, a = t.title ?? "Untitled", c = Array.isArray(t.fields) ? t.fields : [], l = Array.isArray(t.tags) ? t.tags : [], o = Array.isArray(t.actions) ? t.actions : [];
|
|
1629
|
+
return /* @__PURE__ */ i("div", { className: "pcw-widget-card pcw-info-card", "data-testid": "info-card", children: [
|
|
1630
|
+
/* @__PURE__ */ i("div", { className: "pcw-info-card__header", children: [
|
|
1631
|
+
/* @__PURE__ */ e("span", { className: "pcw-info-card__title", children: a }),
|
|
1632
|
+
t.status && /* @__PURE__ */ e("span", { className: `pcw-info-card__status pcw-info-card__status--${t.status}`, children: t.status })
|
|
1633
|
+
] }),
|
|
1634
|
+
t.subtitle && /* @__PURE__ */ e("div", { className: "pcw-info-card__subtitle", children: t.subtitle }),
|
|
1635
|
+
t.description && /* @__PURE__ */ e("p", { className: "pcw-info-card__description", children: t.description }),
|
|
1636
|
+
c.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-info-card__fields", children: c.map((r) => /* @__PURE__ */ i("div", { className: "pcw-info-card__field", children: [
|
|
1637
|
+
/* @__PURE__ */ e("span", { className: "pcw-info-card__field-label", children: r.label }),
|
|
1638
|
+
/* @__PURE__ */ e("span", { className: "pcw-info-card__field-value", children: String(r.value) })
|
|
1639
|
+
] }, r.label)) }),
|
|
1640
|
+
l.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-info-card__tags", children: l.map((r) => /* @__PURE__ */ e("span", { className: "pcw-info-card__tag", children: r }, r)) }),
|
|
1641
|
+
o.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-info-card__actions", children: o.map((r) => /* @__PURE__ */ e(
|
|
1642
|
+
"button",
|
|
1643
|
+
{
|
|
1644
|
+
type: "button",
|
|
1645
|
+
className: "pcw-info-card__btn",
|
|
1646
|
+
onClick: () => n(r.message),
|
|
1647
|
+
children: r.label
|
|
1648
|
+
},
|
|
1649
|
+
r.label
|
|
1650
|
+
)) })
|
|
1651
|
+
] });
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* @license
|
|
1655
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
1656
|
+
* SPDX-License-Identifier: MIT
|
|
1657
|
+
*/
|
|
1658
|
+
const _t = {
|
|
1659
|
+
up: "↑",
|
|
1660
|
+
down: "↓",
|
|
1661
|
+
flat: "→"
|
|
1662
|
+
};
|
|
1663
|
+
function ht({ data: s }) {
|
|
1664
|
+
const n = s, t = n.label ?? "Metric", a = n.value ?? "—";
|
|
1665
|
+
return /* @__PURE__ */ i("div", { className: "pcw-widget-card pcw-metric", "data-testid": "metric", children: [
|
|
1666
|
+
/* @__PURE__ */ e("div", { className: "pcw-metric__label", children: t }),
|
|
1667
|
+
/* @__PURE__ */ i("div", { className: "pcw-metric__value-row", children: [
|
|
1668
|
+
/* @__PURE__ */ e("span", { className: "pcw-metric__value", children: String(a) }),
|
|
1669
|
+
n.unit && /* @__PURE__ */ e("span", { className: "pcw-metric__unit", children: n.unit }),
|
|
1670
|
+
n.trend && /* @__PURE__ */ e("span", { className: `pcw-metric__trend pcw-metric__trend--${n.trend}`, children: _t[n.trend] ?? "" })
|
|
1671
|
+
] }),
|
|
1672
|
+
n.description && /* @__PURE__ */ e("div", { className: "pcw-metric__description", children: n.description }),
|
|
1673
|
+
n.previous_value != null && /* @__PURE__ */ i("div", { className: "pcw-metric__previous", children: [
|
|
1674
|
+
"Previous: ",
|
|
1675
|
+
String(n.previous_value),
|
|
1676
|
+
n.unit ? ` ${n.unit}` : ""
|
|
1677
|
+
] })
|
|
1678
|
+
] });
|
|
1679
|
+
}
|
|
1680
|
+
const wt = {
|
|
1681
|
+
"entity-card": qe,
|
|
1682
|
+
"entity-list": Qe,
|
|
1683
|
+
"scope-map": st,
|
|
1684
|
+
"alert-card": nt,
|
|
1685
|
+
timeline: ct,
|
|
1686
|
+
comparison: rt,
|
|
1687
|
+
"data-table": it,
|
|
1688
|
+
"score-breakdown": lt,
|
|
1689
|
+
"status-board": ot,
|
|
1690
|
+
"credential-input": dt,
|
|
1691
|
+
"document-preview": ut,
|
|
1692
|
+
"info-card": mt,
|
|
1693
|
+
metric: ht
|
|
1694
|
+
};
|
|
1695
|
+
class gt extends Me {
|
|
1696
|
+
constructor(n) {
|
|
1697
|
+
super(n), this.state = { error: null };
|
|
1698
|
+
}
|
|
1699
|
+
static getDerivedStateFromError(n) {
|
|
1700
|
+
return { error: n };
|
|
1701
|
+
}
|
|
1702
|
+
render() {
|
|
1703
|
+
return this.state.error ? /* @__PURE__ */ i("div", { className: "pcw-widget-card pcw-widget-card--generic", children: [
|
|
1704
|
+
/* @__PURE__ */ i("div", { className: "pcw-widget-card__header", children: [
|
|
1705
|
+
/* @__PURE__ */ e("span", { className: "pcw-widget-card__type", children: this.props.widgetType }),
|
|
1706
|
+
/* @__PURE__ */ e("span", { style: { color: "var(--pcw-error, #ef4444)", fontSize: "12px", marginLeft: "8px" }, children: "render error" })
|
|
1707
|
+
] }),
|
|
1708
|
+
/* @__PURE__ */ e("pre", { className: "pcw-widget-card__json", children: JSON.stringify(this.props.data, null, 2) })
|
|
1709
|
+
] }) : this.props.children;
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
function yt({
|
|
1713
|
+
widgetType: s,
|
|
1714
|
+
data: n,
|
|
1715
|
+
sendMessage: t,
|
|
1716
|
+
customWidgets: a,
|
|
1717
|
+
onInteraction: c
|
|
1718
|
+
}) {
|
|
1719
|
+
const l = (a == null ? void 0 : a[s]) ?? wt[s];
|
|
1720
|
+
return l ? /* @__PURE__ */ e(gt, { widgetType: s, data: n, children: /* @__PURE__ */ e(l, { data: n, sendMessage: t, onInteraction: c }) }) : /* @__PURE__ */ i("div", { className: "pcw-widget-card pcw-widget-card--generic", children: [
|
|
1721
|
+
/* @__PURE__ */ e("div", { className: "pcw-widget-card__header", children: /* @__PURE__ */ e("span", { className: "pcw-widget-card__type", children: s }) }),
|
|
1722
|
+
/* @__PURE__ */ e("pre", { className: "pcw-widget-card__json", children: JSON.stringify(n, null, 2) })
|
|
1723
|
+
] });
|
|
1724
|
+
}
|
|
1725
|
+
function bt({
|
|
1726
|
+
message: s,
|
|
1727
|
+
sendMessage: n,
|
|
1728
|
+
customWidgets: t,
|
|
1729
|
+
onInteraction: a,
|
|
1730
|
+
onAskUserSubmit: c
|
|
1731
|
+
}) {
|
|
1732
|
+
const l = s.contentBlocks && s.contentBlocks.length > 0, o = s.toolCalls.length > 0 || s.skillActivations.length > 0 || s.kbProposals.length > 0;
|
|
1733
|
+
if (l) {
|
|
1734
|
+
const r = s.kbProposals.length > 0;
|
|
1735
|
+
return /* @__PURE__ */ i("div", { className: "pcw-bubble pcw-bubble--assistant", children: [
|
|
1736
|
+
s.skillActivations.map((d) => /* @__PURE__ */ e(fe, { skill: d }, d)),
|
|
1737
|
+
s.contentBlocks.map((d, u) => {
|
|
1738
|
+
switch (d.type) {
|
|
1739
|
+
case "text":
|
|
1740
|
+
return d.text.length > 0 ? /* @__PURE__ */ e(ne, { text: d.text, className: "pcw-bubble__text" }, `text-${String(u)}`) : null;
|
|
1741
|
+
case "widget":
|
|
1742
|
+
return /* @__PURE__ */ e(
|
|
1743
|
+
yt,
|
|
1744
|
+
{
|
|
1745
|
+
widgetType: d.widgetType,
|
|
1746
|
+
data: d.data,
|
|
1747
|
+
sendMessage: n ?? (() => {
|
|
1748
|
+
}),
|
|
1749
|
+
customWidgets: t,
|
|
1750
|
+
onInteraction: a
|
|
1751
|
+
},
|
|
1752
|
+
`widget-${String(u)}`
|
|
1753
|
+
);
|
|
1754
|
+
case "tool_calls":
|
|
1755
|
+
return /* @__PURE__ */ e("div", { className: "pcw-bubble__extras", children: d.calls.map((p) => /* @__PURE__ */ e(be, { toolCall: p }, p.toolId)) }, `tools-${String(u)}`);
|
|
1756
|
+
case "ask_user":
|
|
1757
|
+
return /* @__PURE__ */ e(
|
|
1758
|
+
Xe,
|
|
1759
|
+
{
|
|
1760
|
+
block: d,
|
|
1761
|
+
onSubmit: c ?? (() => {
|
|
1762
|
+
})
|
|
1763
|
+
},
|
|
1764
|
+
`ask-${d.askId}`
|
|
1765
|
+
);
|
|
1766
|
+
default:
|
|
1767
|
+
return null;
|
|
1768
|
+
}
|
|
1769
|
+
}),
|
|
1770
|
+
r && /* @__PURE__ */ e("div", { className: "pcw-bubble__extras", children: s.kbProposals.map((d, u) => /* @__PURE__ */ e(ve, { proposal: d }, `${d.title}-${String(u)}`)) })
|
|
1771
|
+
] });
|
|
1772
|
+
}
|
|
1773
|
+
return /* @__PURE__ */ i("div", { className: "pcw-bubble pcw-bubble--assistant", children: [
|
|
1774
|
+
s.skillActivations.map((r) => /* @__PURE__ */ e(fe, { skill: r }, r)),
|
|
1775
|
+
s.text.length > 0 && /* @__PURE__ */ e(ne, { className: "pcw-bubble__text", text: s.text }),
|
|
1776
|
+
o && /* @__PURE__ */ i("div", { className: "pcw-bubble__extras", children: [
|
|
1777
|
+
s.toolCalls.map((r) => /* @__PURE__ */ e(be, { toolCall: r }, r.toolId)),
|
|
1778
|
+
s.kbProposals.map((r, d) => /* @__PURE__ */ e(ve, { proposal: r }, `${r.title}-${String(d)}`))
|
|
1779
|
+
] })
|
|
1780
|
+
] });
|
|
1781
|
+
}
|
|
1782
|
+
function ke({ messages: s, isStreaming: n, sendMessage: t, customWidgets: a, onInteraction: c, onAskUserSubmit: l, emptyStateText: o }) {
|
|
1783
|
+
const r = A(null), d = A(!0);
|
|
1784
|
+
return V(() => {
|
|
1785
|
+
const u = r.current;
|
|
1786
|
+
if (!u) return;
|
|
1787
|
+
const p = () => {
|
|
1788
|
+
d.current = u.scrollHeight - u.scrollTop - u.clientHeight < 100;
|
|
1789
|
+
};
|
|
1790
|
+
return u.addEventListener("scroll", p), () => u.removeEventListener("scroll", p);
|
|
1791
|
+
}, []), V(() => {
|
|
1792
|
+
d.current && r.current && (r.current.scrollTop = r.current.scrollHeight);
|
|
1793
|
+
}, [s, n]), s.length === 0 ? /* @__PURE__ */ e("div", { className: "pcw-messages--empty", children: /* @__PURE__ */ e("p", { children: o ?? "Send a message to start a conversation." }) }) : /* @__PURE__ */ i("div", { ref: r, className: "pcw-messages", children: [
|
|
1794
|
+
s.map((u) => {
|
|
1795
|
+
switch (u.type) {
|
|
1796
|
+
case "user":
|
|
1797
|
+
return /* @__PURE__ */ e("div", { className: "pcw-bubble pcw-bubble--user", children: /* @__PURE__ */ e("p", { className: "pcw-bubble__text", children: u.text }) }, u.id);
|
|
1798
|
+
case "assistant_text":
|
|
1799
|
+
return /* @__PURE__ */ e(
|
|
1800
|
+
bt,
|
|
1801
|
+
{
|
|
1802
|
+
message: u,
|
|
1803
|
+
sendMessage: t,
|
|
1804
|
+
customWidgets: a,
|
|
1805
|
+
onInteraction: c,
|
|
1806
|
+
onAskUserSubmit: l
|
|
1807
|
+
},
|
|
1808
|
+
u.id
|
|
1809
|
+
);
|
|
1810
|
+
case "error":
|
|
1811
|
+
return /* @__PURE__ */ e("div", { className: "pcw-error", children: u.message }, u.id);
|
|
1812
|
+
default:
|
|
1813
|
+
return null;
|
|
1814
|
+
}
|
|
1815
|
+
}),
|
|
1816
|
+
n && /* @__PURE__ */ e(Je, {})
|
|
1817
|
+
] });
|
|
1818
|
+
}
|
|
1819
|
+
function vt() {
|
|
1820
|
+
return /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1821
|
+
/* @__PURE__ */ e("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
|
|
1822
|
+
/* @__PURE__ */ e("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
|
|
1823
|
+
] });
|
|
1824
|
+
}
|
|
1825
|
+
function ft() {
|
|
1826
|
+
return /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("rect", { x: "6", y: "6", width: "12", height: "12", rx: "2" }) });
|
|
1827
|
+
}
|
|
1828
|
+
function xe({ onSend: s, onStop: n, disabled: t, isStreaming: a, placeholder: c }) {
|
|
1829
|
+
const [l, o] = f(""), r = A(null), d = b(() => {
|
|
1830
|
+
const m = l.trim();
|
|
1831
|
+
m.length !== 0 && (s(m), o(""), r.current && (r.current.style.height = "auto"));
|
|
1832
|
+
}, [l, s]), u = b(
|
|
1833
|
+
(m) => {
|
|
1834
|
+
m.key === "Enter" && !m.shiftKey && (m.preventDefault(), d());
|
|
1835
|
+
},
|
|
1836
|
+
[d]
|
|
1837
|
+
), p = b(() => {
|
|
1838
|
+
const m = r.current;
|
|
1839
|
+
m && (m.style.height = "auto", m.style.height = `${String(Math.min(m.scrollHeight, 120))}px`);
|
|
1840
|
+
}, []);
|
|
1841
|
+
return /* @__PURE__ */ i("div", { className: "pcw-input", children: [
|
|
1842
|
+
/* @__PURE__ */ e(
|
|
1843
|
+
"textarea",
|
|
1844
|
+
{
|
|
1845
|
+
ref: r,
|
|
1846
|
+
className: "pcw-input__textarea",
|
|
1847
|
+
value: l,
|
|
1848
|
+
onChange: (m) => o(m.target.value),
|
|
1849
|
+
onKeyDown: u,
|
|
1850
|
+
onInput: p,
|
|
1851
|
+
placeholder: c,
|
|
1852
|
+
disabled: t && !a,
|
|
1853
|
+
rows: 1
|
|
1854
|
+
}
|
|
1855
|
+
),
|
|
1856
|
+
a ? /* @__PURE__ */ e(
|
|
1857
|
+
"button",
|
|
1858
|
+
{
|
|
1859
|
+
type: "button",
|
|
1860
|
+
className: "pcw-input__send pcw-input__stop",
|
|
1861
|
+
onClick: n,
|
|
1862
|
+
"aria-label": "Stop generating",
|
|
1863
|
+
children: /* @__PURE__ */ e(ft, {})
|
|
1864
|
+
}
|
|
1865
|
+
) : /* @__PURE__ */ e(
|
|
1866
|
+
"button",
|
|
1867
|
+
{
|
|
1868
|
+
type: "button",
|
|
1869
|
+
className: "pcw-input__send",
|
|
1870
|
+
onClick: d,
|
|
1871
|
+
disabled: t || l.trim().length === 0,
|
|
1872
|
+
"aria-label": "Send message",
|
|
1873
|
+
children: /* @__PURE__ */ e(vt, {})
|
|
1874
|
+
}
|
|
1875
|
+
)
|
|
1876
|
+
] });
|
|
1877
|
+
}
|
|
1878
|
+
function Nt({ tags: s, onSave: n }) {
|
|
1879
|
+
const [t, a] = f(!1), [c, l] = f(""), o = b(
|
|
1880
|
+
(u) => {
|
|
1881
|
+
n(s.filter((p) => p !== u));
|
|
1882
|
+
},
|
|
1883
|
+
[s, n]
|
|
1884
|
+
), r = b(() => {
|
|
1885
|
+
const u = c.trim();
|
|
1886
|
+
u && !s.includes(u) && n([...s, u]), l(""), a(!1);
|
|
1887
|
+
}, [c, s, n]), d = b(
|
|
1888
|
+
(u) => {
|
|
1889
|
+
u.key === "Enter" ? (u.preventDefault(), r()) : u.key === "Escape" && (l(""), a(!1));
|
|
1890
|
+
},
|
|
1891
|
+
[r]
|
|
1892
|
+
);
|
|
1893
|
+
return /* @__PURE__ */ i("div", { className: "pcw-tag-editor", children: [
|
|
1894
|
+
s.map((u) => /* @__PURE__ */ i("span", { className: "pcw-tag-badge", children: [
|
|
1895
|
+
u,
|
|
1896
|
+
/* @__PURE__ */ e(
|
|
1897
|
+
"button",
|
|
1898
|
+
{
|
|
1899
|
+
type: "button",
|
|
1900
|
+
className: "pcw-tag-remove",
|
|
1901
|
+
onClick: () => o(u),
|
|
1902
|
+
"aria-label": `Remove tag ${u}`,
|
|
1903
|
+
children: "x"
|
|
1904
|
+
}
|
|
1905
|
+
)
|
|
1906
|
+
] }, u)),
|
|
1907
|
+
t ? /* @__PURE__ */ e(
|
|
1908
|
+
"input",
|
|
1909
|
+
{
|
|
1910
|
+
className: "pcw-tag-input",
|
|
1911
|
+
type: "text",
|
|
1912
|
+
value: c,
|
|
1913
|
+
onChange: (u) => l(u.target.value),
|
|
1914
|
+
onKeyDown: d,
|
|
1915
|
+
onBlur: r,
|
|
1916
|
+
placeholder: "Add tag...",
|
|
1917
|
+
autoFocus: !0
|
|
1918
|
+
}
|
|
1919
|
+
) : /* @__PURE__ */ e(
|
|
1920
|
+
"button",
|
|
1921
|
+
{
|
|
1922
|
+
type: "button",
|
|
1923
|
+
className: "pcw-tag-add-btn",
|
|
1924
|
+
onClick: () => a(!0),
|
|
1925
|
+
"aria-label": "Add tag",
|
|
1926
|
+
children: "+"
|
|
1927
|
+
}
|
|
1928
|
+
)
|
|
1929
|
+
] });
|
|
1930
|
+
}
|
|
1931
|
+
function St(s) {
|
|
1932
|
+
const n = Date.now(), t = new Date(s).getTime(), a = n - t, c = Math.floor(a / 6e4);
|
|
1933
|
+
if (c < 1) return "just now";
|
|
1934
|
+
if (c < 60) return `${String(c)}m ago`;
|
|
1935
|
+
const l = Math.floor(c / 60);
|
|
1936
|
+
if (l < 24) return `${String(l)}h ago`;
|
|
1937
|
+
const o = Math.floor(l / 24);
|
|
1938
|
+
return `${String(o)}d ago`;
|
|
1939
|
+
}
|
|
1940
|
+
function Te({
|
|
1941
|
+
sessions: s,
|
|
1942
|
+
isLoading: n,
|
|
1943
|
+
allTags: t,
|
|
1944
|
+
onSelectSession: a,
|
|
1945
|
+
onNewChat: c,
|
|
1946
|
+
onClose: l,
|
|
1947
|
+
onUpdateTags: o
|
|
1948
|
+
}) {
|
|
1949
|
+
const [r, d] = f([]), [u, p] = f(null), m = b((w) => {
|
|
1950
|
+
d(
|
|
1951
|
+
(g) => g.includes(w) ? g.filter((h) => h !== w) : [...g, w]
|
|
1952
|
+
);
|
|
1953
|
+
}, []), y = r.length > 0 ? s.filter((w) => r.some((g) => w.tags.includes(g))) : s;
|
|
1954
|
+
return /* @__PURE__ */ i("div", { className: "pcw-history-drawer", "data-testid": "session-history", children: [
|
|
1955
|
+
/* @__PURE__ */ i("div", { className: "pcw-history-header", children: [
|
|
1956
|
+
/* @__PURE__ */ e("h3", { className: "pcw-history-title", children: "Session History" }),
|
|
1957
|
+
/* @__PURE__ */ e(
|
|
1958
|
+
"button",
|
|
1959
|
+
{
|
|
1960
|
+
type: "button",
|
|
1961
|
+
className: "pcw-history-close",
|
|
1962
|
+
onClick: l,
|
|
1963
|
+
"aria-label": "Close history",
|
|
1964
|
+
children: /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, width: 16, height: 16, children: [
|
|
1965
|
+
/* @__PURE__ */ e("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
1966
|
+
/* @__PURE__ */ e("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
1967
|
+
] })
|
|
1968
|
+
}
|
|
1969
|
+
)
|
|
1970
|
+
] }),
|
|
1971
|
+
/* @__PURE__ */ e(
|
|
1972
|
+
"button",
|
|
1973
|
+
{
|
|
1974
|
+
type: "button",
|
|
1975
|
+
className: "pcw-history-new-chat",
|
|
1976
|
+
onClick: c,
|
|
1977
|
+
children: "+ New Chat"
|
|
1978
|
+
}
|
|
1979
|
+
),
|
|
1980
|
+
t.length > 0 && /* @__PURE__ */ e("div", { className: "pcw-history-filters", children: t.map((w) => /* @__PURE__ */ e(
|
|
1981
|
+
"button",
|
|
1982
|
+
{
|
|
1983
|
+
type: "button",
|
|
1984
|
+
className: `pcw-filter-chip ${r.includes(w) ? "pcw-filter-chip--active" : ""}`,
|
|
1985
|
+
onClick: () => m(w),
|
|
1986
|
+
children: w
|
|
1987
|
+
},
|
|
1988
|
+
w
|
|
1989
|
+
)) }),
|
|
1990
|
+
/* @__PURE__ */ i("div", { className: "pcw-history-list", children: [
|
|
1991
|
+
n && /* @__PURE__ */ e("div", { className: "pcw-history-loading", children: "Loading sessions..." }),
|
|
1992
|
+
!n && y.length === 0 && /* @__PURE__ */ e("div", { className: "pcw-history-empty", children: "No past sessions" }),
|
|
1993
|
+
y.map((w) => /* @__PURE__ */ i(
|
|
1994
|
+
"div",
|
|
1995
|
+
{
|
|
1996
|
+
className: "pcw-history-item",
|
|
1997
|
+
children: [
|
|
1998
|
+
/* @__PURE__ */ i(
|
|
1999
|
+
"button",
|
|
2000
|
+
{
|
|
2001
|
+
type: "button",
|
|
2002
|
+
className: "pcw-history-item-content",
|
|
2003
|
+
onClick: () => a(w.id),
|
|
2004
|
+
children: [
|
|
2005
|
+
/* @__PURE__ */ e("div", { className: "pcw-history-item-title", children: w.title ?? `Session ${w.id.slice(0, 8)}` }),
|
|
2006
|
+
/* @__PURE__ */ i("div", { className: "pcw-history-item-meta", children: [
|
|
2007
|
+
/* @__PURE__ */ e("span", { className: "pcw-history-item-time", children: St(w.created_at) }),
|
|
2008
|
+
/* @__PURE__ */ i("span", { className: "pcw-history-item-count", children: [
|
|
2009
|
+
String(w.message_count),
|
|
2010
|
+
" msg",
|
|
2011
|
+
w.message_count !== 1 ? "s" : ""
|
|
2012
|
+
] })
|
|
2013
|
+
] })
|
|
2014
|
+
]
|
|
2015
|
+
}
|
|
2016
|
+
),
|
|
2017
|
+
/* @__PURE__ */ e("div", { className: "pcw-history-item-tags", children: u === w.id ? /* @__PURE__ */ e(
|
|
2018
|
+
Nt,
|
|
2019
|
+
{
|
|
2020
|
+
tags: w.tags,
|
|
2021
|
+
onSave: (g) => {
|
|
2022
|
+
o(w.id, g), p(null);
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
) : /* @__PURE__ */ i("div", { className: "pcw-history-item-tag-list", children: [
|
|
2026
|
+
w.tags.map((g) => /* @__PURE__ */ e("span", { className: "pcw-tag-badge pcw-tag-badge--small", children: g }, g)),
|
|
2027
|
+
/* @__PURE__ */ e(
|
|
2028
|
+
"button",
|
|
2029
|
+
{
|
|
2030
|
+
type: "button",
|
|
2031
|
+
className: "pcw-tag-edit-btn",
|
|
2032
|
+
onClick: (g) => {
|
|
2033
|
+
g.stopPropagation(), p(w.id);
|
|
2034
|
+
},
|
|
2035
|
+
"aria-label": "Edit tags",
|
|
2036
|
+
children: /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, width: 12, height: 12, children: [
|
|
2037
|
+
/* @__PURE__ */ e("path", { d: "M20.59 13.41l-7.17 7.17a2 2 0 01-2.83 0L2 12V2h10l8.59 8.59a2 2 0 010 2.82z" }),
|
|
2038
|
+
/* @__PURE__ */ e("line", { x1: "7", y1: "7", x2: "7.01", y2: "7" })
|
|
2039
|
+
] })
|
|
2040
|
+
}
|
|
2041
|
+
)
|
|
2042
|
+
] }) })
|
|
2043
|
+
]
|
|
2044
|
+
},
|
|
2045
|
+
w.id
|
|
2046
|
+
))
|
|
2047
|
+
] })
|
|
2048
|
+
] });
|
|
2049
|
+
}
|
|
2050
|
+
function kt() {
|
|
2051
|
+
return /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) });
|
|
2052
|
+
}
|
|
2053
|
+
function xt() {
|
|
2054
|
+
return /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2055
|
+
/* @__PURE__ */ e("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
2056
|
+
/* @__PURE__ */ e("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
2057
|
+
] });
|
|
2058
|
+
}
|
|
2059
|
+
function $t({
|
|
2060
|
+
serverUrl: s,
|
|
2061
|
+
user: n,
|
|
2062
|
+
getToken: t,
|
|
2063
|
+
theme: a,
|
|
2064
|
+
position: c = "floating",
|
|
2065
|
+
defaultOpen: l = !1,
|
|
2066
|
+
onToolCall: o,
|
|
2067
|
+
onKBProposal: r,
|
|
2068
|
+
onEvent: d,
|
|
2069
|
+
entityExtractors: u,
|
|
2070
|
+
widgets: p,
|
|
2071
|
+
historyEnabled: m = !1,
|
|
2072
|
+
showInput: y = !0,
|
|
2073
|
+
sessionType: w,
|
|
2074
|
+
deployId: g,
|
|
2075
|
+
initialMessage: h,
|
|
2076
|
+
resumeSessionId: $,
|
|
2077
|
+
onStreamEnd: S,
|
|
2078
|
+
onSessionCreated: N
|
|
2079
|
+
}) {
|
|
2080
|
+
const [P, R] = f(l), [x, H] = f(!1), G = A(null), j = je(a), { messages: J, send: F, stop: ce, isStreaming: W, error: q, reset: Y, eventBus: T, submitAskUserResponse: I, loadSession: B, isHistorical: L } = Pe({
|
|
2081
|
+
serverUrl: s,
|
|
2082
|
+
user: n,
|
|
2083
|
+
getToken: t,
|
|
2084
|
+
onToolCall: o,
|
|
2085
|
+
onKBProposal: r,
|
|
2086
|
+
onEvent: d,
|
|
2087
|
+
entityExtractors: u,
|
|
2088
|
+
sessionType: w,
|
|
2089
|
+
deployId: g,
|
|
2090
|
+
initialMessage: h,
|
|
2091
|
+
resumeSessionId: $,
|
|
2092
|
+
onStreamEnd: S,
|
|
2093
|
+
onSessionCreated: N
|
|
2094
|
+
}), k = He({
|
|
2095
|
+
serverUrl: s,
|
|
2096
|
+
getToken: t,
|
|
2097
|
+
enabled: m && x
|
|
2098
|
+
}), K = b(
|
|
2099
|
+
(M) => {
|
|
2100
|
+
T.emitInteraction(M), d == null || d(M);
|
|
2101
|
+
},
|
|
2102
|
+
[T, d]
|
|
2103
|
+
), U = b(
|
|
2104
|
+
(M) => {
|
|
2105
|
+
B(M), H(!1);
|
|
2106
|
+
},
|
|
2107
|
+
[B]
|
|
2108
|
+
), v = b(() => {
|
|
2109
|
+
Y(), H(!1);
|
|
2110
|
+
}, [Y]);
|
|
2111
|
+
V(() => {
|
|
2112
|
+
G.current && a && ze(G.current, a);
|
|
2113
|
+
}, [a]);
|
|
2114
|
+
const O = `pcw-widget pcw-widget--${c}`;
|
|
2115
|
+
return c === "inline" ? /* @__PURE__ */ i("div", { ref: G, className: O, "data-testid": "chat-widget", children: [
|
|
2116
|
+
/* @__PURE__ */ e(
|
|
2117
|
+
Ce,
|
|
2118
|
+
{
|
|
2119
|
+
title: j.headerText,
|
|
2120
|
+
onReset: Y,
|
|
2121
|
+
historyEnabled: m,
|
|
2122
|
+
onToggleHistory: () => H((M) => !M),
|
|
2123
|
+
isHistorical: L
|
|
2124
|
+
}
|
|
2125
|
+
),
|
|
2126
|
+
x && /* @__PURE__ */ e(
|
|
2127
|
+
Te,
|
|
2128
|
+
{
|
|
2129
|
+
sessions: k.sessions,
|
|
2130
|
+
isLoading: k.isLoading,
|
|
2131
|
+
allTags: k.allTags,
|
|
2132
|
+
onSelectSession: U,
|
|
2133
|
+
onNewChat: v,
|
|
2134
|
+
onClose: () => H(!1),
|
|
2135
|
+
onUpdateTags: k.updateTags
|
|
2136
|
+
}
|
|
2137
|
+
),
|
|
2138
|
+
/* @__PURE__ */ e(ke, { messages: J, isStreaming: W, sendMessage: F, customWidgets: p, onInteraction: K, onAskUserSubmit: I, emptyStateText: j.emptyStateText }),
|
|
2139
|
+
q && /* @__PURE__ */ e("div", { className: "pcw-error", children: q }),
|
|
2140
|
+
y && /* @__PURE__ */ e(
|
|
2141
|
+
xe,
|
|
2142
|
+
{
|
|
2143
|
+
onSend: F,
|
|
2144
|
+
onStop: ce,
|
|
2145
|
+
disabled: W,
|
|
2146
|
+
isStreaming: W,
|
|
2147
|
+
placeholder: L ? "Send a message to start a new chat..." : j.placeholder
|
|
2148
|
+
}
|
|
2149
|
+
)
|
|
2150
|
+
] }) : P ? /* @__PURE__ */ i("div", { ref: G, className: O, "data-testid": "chat-widget", children: [
|
|
2151
|
+
/* @__PURE__ */ e(
|
|
2152
|
+
Ce,
|
|
2153
|
+
{
|
|
2154
|
+
title: j.headerText,
|
|
2155
|
+
onClose: () => R(!1),
|
|
2156
|
+
onReset: Y,
|
|
2157
|
+
showClose: !0,
|
|
2158
|
+
historyEnabled: m,
|
|
2159
|
+
onToggleHistory: () => H((M) => !M),
|
|
2160
|
+
isHistorical: L
|
|
2161
|
+
}
|
|
2162
|
+
),
|
|
2163
|
+
x && /* @__PURE__ */ e(
|
|
2164
|
+
Te,
|
|
2165
|
+
{
|
|
2166
|
+
sessions: k.sessions,
|
|
2167
|
+
isLoading: k.isLoading,
|
|
2168
|
+
allTags: k.allTags,
|
|
2169
|
+
onSelectSession: U,
|
|
2170
|
+
onNewChat: v,
|
|
2171
|
+
onClose: () => H(!1),
|
|
2172
|
+
onUpdateTags: k.updateTags
|
|
2173
|
+
}
|
|
2174
|
+
),
|
|
2175
|
+
/* @__PURE__ */ e(ke, { messages: J, isStreaming: W, onInteraction: K, onAskUserSubmit: I, emptyStateText: j.emptyStateText }),
|
|
2176
|
+
q && /* @__PURE__ */ e("div", { className: "pcw-error", children: q }),
|
|
2177
|
+
y && /* @__PURE__ */ e(
|
|
2178
|
+
xe,
|
|
2179
|
+
{
|
|
2180
|
+
onSend: F,
|
|
2181
|
+
onStop: ce,
|
|
2182
|
+
disabled: W,
|
|
2183
|
+
isStreaming: W,
|
|
2184
|
+
placeholder: L ? "Send a message to start a new chat..." : j.placeholder
|
|
2185
|
+
}
|
|
2186
|
+
)
|
|
2187
|
+
] }) : c === "floating" ? /* @__PURE__ */ e(
|
|
2188
|
+
"button",
|
|
2189
|
+
{
|
|
2190
|
+
type: "button",
|
|
2191
|
+
className: "pcw-toggle",
|
|
2192
|
+
onClick: () => R(!0),
|
|
2193
|
+
"aria-label": "Open chat",
|
|
2194
|
+
children: /* @__PURE__ */ e(kt, {})
|
|
2195
|
+
}
|
|
2196
|
+
) : null;
|
|
2197
|
+
}
|
|
2198
|
+
function Tt() {
|
|
2199
|
+
return /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", width: 16, height: 16, children: [
|
|
2200
|
+
/* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10" }),
|
|
2201
|
+
/* @__PURE__ */ e("polyline", { points: "12 6 12 12 16 14" })
|
|
2202
|
+
] });
|
|
2203
|
+
}
|
|
2204
|
+
function Ce({ title: s, onClose: n, onReset: t, showClose: a = !1, historyEnabled: c, onToggleHistory: l, isHistorical: o }) {
|
|
2205
|
+
return /* @__PURE__ */ i("div", { className: "pcw-header", children: [
|
|
2206
|
+
/* @__PURE__ */ i("div", { style: { display: "flex", gap: "4px", alignItems: "center" }, children: [
|
|
2207
|
+
c && l && /* @__PURE__ */ e(
|
|
2208
|
+
"button",
|
|
2209
|
+
{
|
|
2210
|
+
type: "button",
|
|
2211
|
+
className: "pcw-header__close",
|
|
2212
|
+
onClick: l,
|
|
2213
|
+
"aria-label": "Session history",
|
|
2214
|
+
title: "Session history",
|
|
2215
|
+
children: /* @__PURE__ */ e(Tt, {})
|
|
2216
|
+
}
|
|
2217
|
+
),
|
|
2218
|
+
/* @__PURE__ */ i("h3", { className: "pcw-header__title", children: [
|
|
2219
|
+
s,
|
|
2220
|
+
o && /* @__PURE__ */ e("span", { className: "pcw-header__badge", children: "History" })
|
|
2221
|
+
] })
|
|
2222
|
+
] }),
|
|
2223
|
+
/* @__PURE__ */ i("div", { style: { display: "flex", gap: "4px", alignItems: "center" }, children: [
|
|
2224
|
+
t && /* @__PURE__ */ e(
|
|
2225
|
+
"button",
|
|
2226
|
+
{
|
|
2227
|
+
type: "button",
|
|
2228
|
+
className: "pcw-header__close",
|
|
2229
|
+
onClick: t,
|
|
2230
|
+
"aria-label": "New conversation",
|
|
2231
|
+
title: "New conversation",
|
|
2232
|
+
children: "↻"
|
|
2233
|
+
}
|
|
2234
|
+
),
|
|
2235
|
+
a && n && /* @__PURE__ */ e(
|
|
2236
|
+
"button",
|
|
2237
|
+
{
|
|
2238
|
+
type: "button",
|
|
2239
|
+
className: "pcw-header__close",
|
|
2240
|
+
onClick: n,
|
|
2241
|
+
"aria-label": "Close chat",
|
|
2242
|
+
children: /* @__PURE__ */ e(xt, {})
|
|
2243
|
+
}
|
|
2244
|
+
)
|
|
2245
|
+
] })
|
|
2246
|
+
] });
|
|
2247
|
+
}
|
|
2248
|
+
/**
|
|
2249
|
+
* @license
|
|
2250
|
+
* Copyright 2025 Amodal Labs, Inc.
|
|
2251
|
+
* SPDX-License-Identifier: MIT
|
|
2252
|
+
*/
|
|
2253
|
+
function Rt(s) {
|
|
2254
|
+
const n = A([]);
|
|
2255
|
+
V(
|
|
2256
|
+
() => () => {
|
|
2257
|
+
for (const c of n.current)
|
|
2258
|
+
c();
|
|
2259
|
+
n.current = [];
|
|
2260
|
+
},
|
|
2261
|
+
[]
|
|
2262
|
+
);
|
|
2263
|
+
const t = b(
|
|
2264
|
+
(c, l) => {
|
|
2265
|
+
if (!s)
|
|
2266
|
+
return () => {
|
|
2267
|
+
};
|
|
2268
|
+
s.on(c, l);
|
|
2269
|
+
const o = () => {
|
|
2270
|
+
s.off(c, l);
|
|
2271
|
+
};
|
|
2272
|
+
return n.current.push(o), o;
|
|
2273
|
+
},
|
|
2274
|
+
[s]
|
|
2275
|
+
), a = b(
|
|
2276
|
+
(c) => {
|
|
2277
|
+
if (!s)
|
|
2278
|
+
return () => {
|
|
2279
|
+
};
|
|
2280
|
+
s.on("*", c);
|
|
2281
|
+
const l = () => {
|
|
2282
|
+
s.off("*", c);
|
|
2283
|
+
};
|
|
2284
|
+
return n.current.push(l), l;
|
|
2285
|
+
},
|
|
2286
|
+
[s]
|
|
2287
|
+
);
|
|
2288
|
+
return { on: t, onAny: a };
|
|
2289
|
+
}
|
|
2290
|
+
export {
|
|
2291
|
+
Bt as ChatClient,
|
|
2292
|
+
Lt as ChatStream,
|
|
2293
|
+
$t as ChatWidget,
|
|
2294
|
+
Ot as TypedEventEmitter,
|
|
2295
|
+
Ie as WidgetEventBus,
|
|
2296
|
+
ze as applyTheme,
|
|
2297
|
+
Dt as createChatClient,
|
|
2298
|
+
Pt as createSession,
|
|
2299
|
+
Ht as defaultEntityExtractor,
|
|
2300
|
+
Ee as defaultTheme,
|
|
2301
|
+
Le as getSessionHistory,
|
|
2302
|
+
Oe as listSessions,
|
|
2303
|
+
je as mergeTheme,
|
|
2304
|
+
Ut as parseSSELine,
|
|
2305
|
+
Be as streamChat,
|
|
2306
|
+
we as updateSession,
|
|
2307
|
+
Pe as useChat,
|
|
2308
|
+
He as useSessionHistory,
|
|
2309
|
+
Rt as useWidgetEvents
|
|
2310
|
+
};
|
|
2311
|
+
//# sourceMappingURL=chat-widget.js.map
|