@useago/sdk 0.3.4 → 0.4.2

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.
Files changed (41) hide show
  1. package/dist/AgoClient-D4EL6nva.cjs +6 -0
  2. package/dist/{AgoClient-DF7M2WAz.js → AgoClient-rvTz2thR.js} +239 -218
  3. package/dist/angular.cjs +1 -1
  4. package/dist/angular.d.cts +27 -0
  5. package/dist/angular.d.ts +27 -0
  6. package/dist/angular.js +1 -1
  7. package/dist/createConversationSession-D9FesBQS.js +58 -0
  8. package/dist/createConversationSession-DtaeA418.cjs +1 -0
  9. package/dist/createFormCollector-BwvkKi48.js +211 -0
  10. package/dist/createFormCollector-Wb8Rr-U2.cjs +1 -0
  11. package/dist/{createMockClient-C50gjV0b.js → createMockClient-DwdxNwEn.js} +5 -2
  12. package/dist/createMockClient-zHQ0cjUH.cjs +1 -0
  13. package/dist/devtools.cjs +5 -4
  14. package/dist/devtools.d.cts +31 -26
  15. package/dist/devtools.d.ts +31 -26
  16. package/dist/devtools.js +39 -35
  17. package/dist/helpers.cjs +1 -1
  18. package/dist/helpers.js +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.cts +117 -1
  21. package/dist/index.d.ts +117 -1
  22. package/dist/index.js +44 -42
  23. package/dist/react.cjs +1 -1
  24. package/dist/react.d.cts +35 -0
  25. package/dist/react.d.ts +35 -0
  26. package/dist/react.js +4 -4
  27. package/dist/vue.cjs +1 -1
  28. package/dist/vue.d.cts +27 -0
  29. package/dist/vue.d.ts +27 -0
  30. package/dist/vue.js +1 -1
  31. package/dist/widget.cjs +1 -1
  32. package/dist/widget.d.cts +114 -0
  33. package/dist/widget.d.ts +114 -0
  34. package/dist/widget.js +170 -150
  35. package/package.json +58 -15
  36. package/dist/AgoClient-bjN-z2ZQ.cjs +0 -6
  37. package/dist/createFormCollector-ClzHfaBd.js +0 -185
  38. package/dist/createFormCollector-H4Me_2uj.cjs +0 -1
  39. package/dist/createMockClient-DQvFFWnc.cjs +0 -1
  40. /package/dist/{functions-CWSRi3xv.js → functions-C1-5vadY.js} +0 -0
  41. /package/dist/{functions-BH1X5kas.cjs → functions-DsmzgHjC.cjs} +0 -0
package/dist/widget.js CHANGED
@@ -1,42 +1,43 @@
1
- import { t as X } from "./AgoClient-DF7M2WAz.js";
2
- import { t as Z } from "./createFormCollector-ClzHfaBd.js";
3
- var G = '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
4
- function m(l, o) {
5
- Object.assign(l.style, o);
1
+ import { t as re } from "./AgoClient-rvTz2thR.js";
2
+ import { t as ae } from "./createFormCollector-BwvkKi48.js";
3
+ import { t as ie } from "./createConversationSession-D9FesBQS.js";
4
+ var Y = '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
5
+ function x(s, n) {
6
+ Object.assign(s.style, n);
6
7
  }
7
- function c(l = {}) {
8
- const o = document.createElement("div");
9
- return m(o, l), o;
8
+ function c(s = {}) {
9
+ const n = document.createElement("div");
10
+ return x(n, s), n;
10
11
  }
11
- var P = "ago-chat-widget-keyframes";
12
- function ee() {
13
- if (typeof document > "u" || document.getElementById(P)) return;
14
- const l = document.createElement("style");
15
- l.id = P, l.textContent = "@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }", document.head.appendChild(l);
12
+ var V = "ago-chat-widget-keyframes";
13
+ function se() {
14
+ if (typeof document > "u" || document.getElementById(V)) return;
15
+ const s = document.createElement("style");
16
+ s.id = V, s.textContent = "@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }", document.head.appendChild(s);
16
17
  }
17
- function te(l) {
18
- const o = typeof l == "string" ? document.querySelector(l) : l;
19
- if (!o) throw new Error(`mountChatWidget: target "${String(l)}" not found.`);
20
- return o;
18
+ function le(s) {
19
+ const n = typeof s == "string" ? document.querySelector(s) : s;
20
+ if (!n) throw new Error(`mountChatWidget: target "${String(s)}" not found.`);
21
+ return n;
21
22
  }
22
- function ae(l, o) {
23
- const { title: w = "Chat", welcomeMessage: I = "Hello! How can I help you today?", placeholder: R = "Type a message...", allowFiles: u = !1, height: x = 500, logoUrl: f, showAgentName: b = !1, forms: _, onFollowUpClick: k, onMessageSent: D, onMessageReceived: s } = o;
24
- if (!o.client && !o.config?.baseUrl) throw new Error("mountChatWidget requires either `client` or `config` (with a baseUrl).");
25
- const i = o.client ?? new X(o.config), z = te(l);
26
- let g = o.conversationId, n = [], y = !1, v = null;
27
- const N = c({
23
+ function ue(s, n) {
24
+ const { title: v = "Chat", welcomeMessage: _ = "Hello! How can I help you today?", placeholder: N = "Type a message...", allowFiles: g = !1, height: m = 500, logoUrl: f, showAgentName: b = !1, loadThreads: I = !1, forms: A, onFollowUpClick: R, onMessageSent: i, onMessageReceived: C } = n;
25
+ if (!n.client && !n.config?.baseUrl) throw new Error("mountChatWidget requires either `client` or `config` (with a baseUrl).");
26
+ const l = n.client ?? new re(n.config), L = le(s), y = n.persistConversation, D = y ? ie(y === !0 ? {} : y) : void 0;
27
+ let u = n.conversationId ?? D?.getLastActiveThread() ?? void 0, o = [], k = !1, z = null;
28
+ const T = [], W = c({
28
29
  display: "flex",
29
30
  flexDirection: "column",
30
- height: typeof x == "number" ? `${x}px` : x,
31
+ height: typeof m == "number" ? `${m}px` : m,
31
32
  border: "1px solid #dee3e8",
32
33
  borderRadius: "16px",
33
34
  overflow: "hidden",
34
35
  backgroundColor: "#fff",
35
- fontFamily: G,
36
+ fontFamily: Y,
36
37
  boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
37
38
  });
38
- N.className = "ago-chat-widget";
39
- const W = c({
39
+ W.className = "ago-chat-widget";
40
+ const F = c({
40
41
  padding: "14px 16px",
41
42
  borderBottom: "1px solid #dee3e8",
42
43
  backgroundColor: "#03182f",
@@ -45,19 +46,19 @@ function ae(l, o) {
45
46
  alignItems: "center",
46
47
  gap: "10px"
47
48
  });
48
- if (W.className = "ago-chat-widget__header", f) {
49
+ if (F.className = "ago-chat-widget__header", f) {
49
50
  const e = document.createElement("img");
50
- e.src = f, e.alt = "Logo", m(e, {
51
+ e.src = f, e.alt = "Logo", x(e, {
51
52
  height: "24px",
52
53
  width: "auto"
53
- }), W.appendChild(e);
54
+ }), F.appendChild(e);
54
55
  }
55
- const F = document.createElement("h3");
56
- F.textContent = w, m(F, {
56
+ const M = document.createElement("h3");
57
+ M.textContent = v, x(M, {
57
58
  margin: "0",
58
59
  fontSize: "15px",
59
60
  fontWeight: "600"
60
- }), W.appendChild(F);
61
+ }), F.appendChild(M);
61
62
  const E = c({
62
63
  flex: "1",
63
64
  overflow: "auto",
@@ -65,18 +66,18 @@ function ae(l, o) {
65
66
  backgroundColor: "#fbfbfb"
66
67
  });
67
68
  E.className = "ago-chat-widget__messages";
68
- const { inputRow: K, setDisabled: j, focus: q } = ne({
69
- placeholder: R,
70
- allowFiles: u,
69
+ const { inputRow: J, setDisabled: Q, focus: X } = de({
70
+ placeholder: N,
71
+ allowFiles: g,
71
72
  onSend: (e, t) => {
72
- L(e, t);
73
+ H(e, t);
73
74
  }
74
75
  });
75
- ee(), N.append(W, E, K), z.appendChild(N);
76
- const U = k !== !1, A = k === !1 ? void 0 : k ?? ((e) => {
77
- L(e);
76
+ se(), W.append(F, E, J), L.appendChild(W);
77
+ const O = R !== !1, $ = R === !1 ? void 0 : R ?? ((e) => {
78
+ H(e);
78
79
  });
79
- function V(e) {
80
+ function Z(e) {
80
81
  const t = e.role === "user", d = c({
81
82
  display: "flex",
82
83
  flexDirection: "column",
@@ -84,17 +85,17 @@ function ae(l, o) {
84
85
  marginBottom: "16px"
85
86
  });
86
87
  if (d.className = `ago-message ago-message--${e.role}`, !t && b && e.agent) {
87
- const a = c({
88
+ const r = c({
88
89
  fontSize: "13px",
89
90
  fontWeight: "500",
90
91
  color: "#30373e",
91
92
  marginBottom: "6px",
92
93
  padding: "0 4px"
93
94
  });
94
- a.className = "ago-message__agent", a.textContent = e.agent.displayName || e.agent.name, d.appendChild(a);
95
+ r.className = "ago-message__agent", r.textContent = e.agent.displayName || e.agent.name, d.appendChild(r);
95
96
  }
96
97
  if (!t && e.sources && e.sources.length > 0) {
97
- const a = c({
98
+ const r = c({
98
99
  display: "grid",
99
100
  gridTemplateColumns: "1fr 1fr",
100
101
  gap: "6px",
@@ -102,9 +103,9 @@ function ae(l, o) {
102
103
  width: "100%",
103
104
  maxWidth: "85%"
104
105
  });
105
- a.className = "ago-message__sources", e.sources.forEach((p, r) => {
106
- const C = p.url ? document.createElement("a") : document.createElement("div");
107
- p.url && C instanceof HTMLAnchorElement && (C.href = p.url, C.target = "_blank", C.rel = "noopener noreferrer"), m(C, {
106
+ r.className = "ago-message__sources", e.sources.forEach((p, a) => {
107
+ const w = p.url ? document.createElement("a") : document.createElement("div");
108
+ p.url && w instanceof HTMLAnchorElement && (w.href = p.url, w.target = "_blank", w.rel = "noopener noreferrer"), x(w, {
108
109
  display: "flex",
109
110
  alignItems: "center",
110
111
  gap: "8px",
@@ -117,7 +118,7 @@ function ae(l, o) {
117
118
  fontSize: "12px",
118
119
  overflow: "hidden"
119
120
  });
120
- const $ = c({
121
+ const q = c({
121
122
  flexShrink: "0",
122
123
  width: "18px",
123
124
  height: "18px",
@@ -131,14 +132,14 @@ function ae(l, o) {
131
132
  justifyContent: "center",
132
133
  backgroundColor: "#f0f4ff"
133
134
  });
134
- $.textContent = String(r + 1);
135
- const M = c({
135
+ q.textContent = String(a + 1);
136
+ const B = c({
136
137
  overflow: "hidden",
137
138
  textOverflow: "ellipsis",
138
139
  whiteSpace: "nowrap"
139
140
  });
140
- M.textContent = p.title, M.title = p.title, C.append($, M), a.appendChild(C);
141
- }), d.appendChild(a);
141
+ B.textContent = p.title, B.title = p.title, w.append(q, B), r.appendChild(w);
142
+ }), d.appendChild(r);
142
143
  }
143
144
  const h = c({
144
145
  maxWidth: t ? "75%" : "100%",
@@ -151,37 +152,37 @@ function ae(l, o) {
151
152
  lineHeight: "1.6",
152
153
  whiteSpace: "pre-wrap"
153
154
  });
154
- if (h.className = "ago-message__content", e.content ? h.textContent = e.content : e.status === "IN_PROGRESS" && h.appendChild(Q()), d.appendChild(h), e.followUpReplies && e.followUpReplies.length > 0) {
155
- const a = c({
155
+ if (h.className = "ago-message__content", e.content ? h.textContent = e.content : e.status === "IN_PROGRESS" && h.appendChild(oe()), d.appendChild(h), e.followUpReplies && e.followUpReplies.length > 0) {
156
+ const r = c({
156
157
  display: "flex",
157
158
  flexWrap: "wrap",
158
159
  gap: "8px",
159
160
  marginTop: "10px"
160
161
  });
161
- a.className = "ago-message__followups";
162
+ r.className = "ago-message__followups";
162
163
  for (const p of e.followUpReplies) {
163
- const r = document.createElement("button");
164
- r.type = "button", r.className = "ago-message__followup-btn", r.textContent = p, r.disabled = !U, m(r, {
164
+ const a = document.createElement("button");
165
+ a.type = "button", a.className = "ago-message__followup-btn", a.textContent = p, a.disabled = !O, x(a, {
165
166
  padding: "6px 14px",
166
167
  fontSize: "13px",
167
168
  borderRadius: "16px",
168
169
  border: "1px solid #dee3e8",
169
170
  backgroundColor: "#fff",
170
171
  color: "#30373e",
171
- cursor: U ? "pointer" : "default",
172
+ cursor: O ? "pointer" : "default",
172
173
  transition: "border-color 0.15s"
173
- }), A && r.addEventListener("click", () => A(p)), r.addEventListener("mouseenter", () => {
174
- r.style.borderColor = "#1b5fc4";
175
- }), r.addEventListener("mouseleave", () => {
176
- r.style.borderColor = "#dee3e8";
177
- }), a.appendChild(r);
174
+ }), $ && a.addEventListener("click", () => $(p)), a.addEventListener("mouseenter", () => {
175
+ a.style.borderColor = "#1b5fc4";
176
+ }), a.addEventListener("mouseleave", () => {
177
+ a.style.borderColor = "#dee3e8";
178
+ }), r.appendChild(a);
178
179
  }
179
- d.appendChild(a);
180
+ d.appendChild(r);
180
181
  }
181
182
  return d;
182
183
  }
183
184
  function S() {
184
- if (E.replaceChildren(), n.length === 0) {
185
+ if (E.replaceChildren(), o.length === 0) {
185
186
  const e = c({
186
187
  textAlign: "center",
187
188
  color: "#6b6d6f",
@@ -189,9 +190,9 @@ function ae(l, o) {
189
190
  fontSize: "14px",
190
191
  lineHeight: "1.5"
191
192
  });
192
- e.textContent = I, E.appendChild(e);
193
- } else for (const e of n) E.appendChild(V(e));
194
- if (v) {
193
+ e.textContent = _, E.appendChild(e);
194
+ } else for (const e of o) E.appendChild(Z(e));
195
+ if (z) {
195
196
  const e = c({
196
197
  padding: "10px 14px",
197
198
  backgroundColor: "#fef2f2",
@@ -201,77 +202,96 @@ function ae(l, o) {
201
202
  fontSize: "13px",
202
203
  border: "1px solid #fecaca"
203
204
  });
204
- e.textContent = v, E.appendChild(e);
205
+ e.textContent = z, E.appendChild(e);
205
206
  }
206
- E.scrollTop = E.scrollHeight, j(y);
207
+ E.scrollTop = E.scrollHeight, Q(k);
207
208
  }
208
- function Y() {
209
- for (let e = n.length - 1; e >= 0; e--) {
210
- const t = n[e];
209
+ function ee() {
210
+ for (let e = o.length - 1; e >= 0; e--) {
211
+ const t = o[e];
211
212
  if (t.role === "assistant" && t.status === "IN_PROGRESS") return t;
212
213
  }
213
214
  }
214
- const B = (e) => {
215
- g || (g = e.conversationId);
216
- }, H = (e) => {
217
- const t = Y();
215
+ const P = (e) => {
216
+ u || (u = e.conversationId);
217
+ }, G = (e) => {
218
+ const t = ee();
218
219
  t && (t.content += e.content, S());
219
- }, O = (e) => {
220
- const t = n.findIndex((d) => d.id === e.id || d.role === "assistant" && d.status === "IN_PROGRESS");
221
- t >= 0 ? n[t] = e : n.push(e), y = !1, S(), e.status === "DONE" && s?.({
220
+ }, K = (e) => {
221
+ const t = o.findIndex((d) => d.id === e.id || d.role === "assistant" && d.status === "IN_PROGRESS");
222
+ t >= 0 ? o[t] = e : o.push(e), k = !1, S(), e.status === "DONE" && C?.({
222
223
  id: e.id,
223
224
  content: e.content
224
225
  });
225
- }, T = (e) => {
226
- v = e.error, y = !1, n = n.filter((t) => !t.id.startsWith("temp-")), S();
226
+ }, j = (e) => {
227
+ z = e.error, k = !1, o = o.filter((t) => !t.id.startsWith("temp-")), S();
227
228
  };
228
- i.on("message:start", B), i.on("message:chunk", H), i.on("message:complete", O), i.on("message:error", T);
229
- const J = (_ ?? []).map((e) => Z(e).install(i));
230
- async function L(e, t) {
229
+ l.on("message:start", P), l.on("message:chunk", G), l.on("message:complete", K), l.on("message:error", j);
230
+ const te = (A ?? []).map((e) => ae(e).install(l));
231
+ async function H(e, t) {
231
232
  const d = e.trim();
232
- if (!d && !t?.length || y) return;
233
- D?.(d), y = !0, v = null;
233
+ if (!d && !t?.length || k) return;
234
+ i?.(d), k = !0, z = null;
234
235
  const h = Date.now();
235
- n.push({
236
+ o.push({
236
237
  id: `temp-user-${h}`,
237
- conversationId: g || "",
238
+ conversationId: u || "",
238
239
  content: d,
239
240
  role: "user",
240
241
  status: "DONE",
241
242
  createdAt: /* @__PURE__ */ new Date()
242
- }), n.push({
243
+ }), o.push({
243
244
  id: `temp-assistant-${h}`,
244
- conversationId: g || "",
245
+ conversationId: u || "",
245
246
  content: "",
246
247
  role: "assistant",
247
248
  status: "IN_PROGRESS",
248
249
  createdAt: /* @__PURE__ */ new Date()
249
250
  }), S();
250
251
  try {
251
- const a = await i.sendMessage(d, {
252
- conversationId: g,
252
+ const r = await l.sendMessage(d, {
253
+ conversationId: u,
253
254
  files: t
254
255
  });
255
- a.conversationId && !g && (g = a.conversationId);
256
- const p = n.find((r) => r.id === `temp-user-${h}`);
257
- if (p && (p.id = `user-${h}`, p.conversationId = a.conversationId), !n.some((r) => r.id === a.id)) {
258
- const r = n.findIndex((C) => C.id === `temp-assistant-${h}`);
259
- r >= 0 ? n[r] = a : n.push(a);
256
+ r.conversationId && (u || (u = r.conversationId), D?.setActiveThread(r.conversationId, r.createdAt));
257
+ const p = o.find((a) => a.id === `temp-user-${h}`);
258
+ if (p && (p.id = `user-${h}`, p.conversationId = r.conversationId), !o.some((a) => a.id === r.id)) {
259
+ const a = o.findIndex((w) => w.id === `temp-assistant-${h}`);
260
+ a >= 0 ? o[a] = r : o.push(r);
260
261
  }
261
- n = n.filter((r) => !r.id.startsWith("temp-")), y = !1, S();
262
- } catch (a) {
263
- v = a instanceof Error ? a.message : "Failed to send message", y = !1, n = n.filter((p) => !p.id.startsWith("temp-")), S();
262
+ o = o.filter((a) => !a.id.startsWith("temp-")), k = !1, S(), I && U();
263
+ } catch (r) {
264
+ z = r instanceof Error ? r.message : "Failed to send message", k = !1, o = o.filter((p) => !p.id.startsWith("temp-")), S();
264
265
  }
265
266
  }
266
- return S(), q(), {
267
- client: i,
268
- element: N,
269
- sendMessage: L,
267
+ async function U() {
268
+ try {
269
+ const e = await l.getConversations();
270
+ T.splice(0, T.length, ...e);
271
+ } catch {
272
+ }
273
+ return T;
274
+ }
275
+ async function ne(e) {
276
+ try {
277
+ const t = (await l.getConversation(e))?.messages ?? [];
278
+ t.length > 0 && o.length === 0 && (o = t, S());
279
+ } catch {
280
+ o.length === 0 && (D?.clear(), u = void 0);
281
+ }
282
+ }
283
+ return S(), X(), u && ne(u), I && U(), {
284
+ client: l,
285
+ element: W,
286
+ sendMessage: H,
287
+ session: D,
288
+ threads: T,
289
+ refreshThreads: U,
270
290
  destroy() {
271
- i.off("message:start", B), i.off("message:chunk", H), i.off("message:complete", O), i.off("message:error", T), J.forEach((e) => e()), N.remove(), o.client || i.destroy();
291
+ l.off("message:start", P), l.off("message:chunk", G), l.off("message:complete", K), l.off("message:error", j), te.forEach((e) => e()), W.remove(), n.client || l.destroy();
272
292
  }
273
293
  };
274
- function Q() {
294
+ function oe() {
275
295
  const e = c({
276
296
  display: "flex",
277
297
  gap: "4px",
@@ -291,40 +311,40 @@ function ae(l, o) {
291
311
  return e;
292
312
  }
293
313
  }
294
- function ne(l) {
295
- let o = [];
296
- const w = document.createElement("form");
297
- m(w, {
314
+ function de(s) {
315
+ let n = [];
316
+ const v = document.createElement("form");
317
+ x(v, {
298
318
  display: "flex",
299
319
  flexDirection: "column",
300
320
  gap: "8px",
301
321
  padding: "12px",
302
322
  borderTop: "1px solid #dee3e8",
303
323
  backgroundColor: "#fff"
304
- }), w.className = "ago-chat-input";
305
- const I = c({
324
+ }), v.className = "ago-chat-input";
325
+ const _ = c({
306
326
  display: "flex",
307
327
  flexWrap: "wrap",
308
328
  gap: "6px"
309
- }), R = c({
329
+ }), N = c({
310
330
  display: "flex",
311
331
  gap: "8px",
312
332
  alignItems: "flex-end"
313
- }), u = document.createElement("textarea");
314
- u.placeholder = l.placeholder, u.rows = 1, m(u, {
333
+ }), g = document.createElement("textarea");
334
+ g.placeholder = s.placeholder, g.rows = 1, x(g, {
315
335
  flex: "1",
316
336
  resize: "none",
317
337
  padding: "10px 12px",
318
338
  border: "1px solid #dee3e8",
319
339
  borderRadius: "12px",
320
340
  fontSize: "14px",
321
- fontFamily: G,
341
+ fontFamily: Y,
322
342
  lineHeight: "1.4",
323
343
  maxHeight: "120px",
324
344
  outline: "none"
325
345
  });
326
- const x = document.createElement("button");
327
- x.type = "submit", x.textContent = "Send", m(x, {
346
+ const m = document.createElement("button");
347
+ m.type = "submit", m.textContent = "Send", x(m, {
328
348
  padding: "10px 16px",
329
349
  border: "none",
330
350
  borderRadius: "12px",
@@ -335,7 +355,7 @@ function ne(l) {
335
355
  cursor: "pointer"
336
356
  });
337
357
  let f = null, b = null;
338
- l.allowFiles && (f = document.createElement("input"), f.type = "file", f.multiple = !0, m(f, { display: "none" }), b = document.createElement("button"), b.type = "button", b.textContent = "📎", m(b, {
358
+ s.allowFiles && (f = document.createElement("input"), f.type = "file", f.multiple = !0, x(f, { display: "none" }), b = document.createElement("button"), b.type = "button", b.textContent = "📎", x(b, {
339
359
  padding: "10px 12px",
340
360
  border: "1px solid #dee3e8",
341
361
  borderRadius: "12px",
@@ -343,11 +363,11 @@ function ne(l) {
343
363
  cursor: "pointer",
344
364
  fontSize: "14px"
345
365
  }), b.addEventListener("click", () => f?.click()), f.addEventListener("change", () => {
346
- o = [...o, ...Array.from(f?.files ?? [])], _();
366
+ n = [...n, ...Array.from(f?.files ?? [])], I();
347
367
  }));
348
- function _() {
349
- I.replaceChildren(), o.forEach((s, i) => {
350
- const z = c({
368
+ function I() {
369
+ _.replaceChildren(), n.forEach((i, C) => {
370
+ const l = c({
351
371
  display: "flex",
352
372
  alignItems: "center",
353
373
  gap: "4px",
@@ -356,43 +376,43 @@ function ne(l) {
356
376
  border: "1px solid #dee3e8",
357
377
  borderRadius: "8px",
358
378
  fontSize: "12px"
359
- }), g = document.createElement("span");
360
- g.textContent = s.name;
361
- const n = document.createElement("button");
362
- n.type = "button", n.textContent = "×", m(n, {
379
+ }), L = document.createElement("span");
380
+ L.textContent = i.name;
381
+ const y = document.createElement("button");
382
+ y.type = "button", y.textContent = "×", x(y, {
363
383
  border: "none",
364
384
  background: "transparent",
365
385
  cursor: "pointer",
366
386
  fontSize: "14px",
367
387
  lineHeight: "1"
368
- }), n.addEventListener("click", () => {
369
- o = o.filter((y, v) => v !== i), _();
370
- }), z.append(g, n), I.appendChild(z);
388
+ }), y.addEventListener("click", () => {
389
+ n = n.filter((D, u) => u !== C), I();
390
+ }), l.append(L, y), _.appendChild(l);
371
391
  });
372
392
  }
373
- const k = () => {
374
- const s = u.value, i = o;
375
- return u.value = "", o = [], _(), {
376
- content: s,
377
- files: i
393
+ const A = () => {
394
+ const i = g.value, C = n;
395
+ return g.value = "", n = [], I(), {
396
+ content: i,
397
+ files: C
378
398
  };
379
- }, D = () => {
380
- const { content: s, files: i } = k();
381
- (s.trim() || i.length > 0) && l.onSend(s.trim(), i.length > 0 ? i : void 0);
399
+ }, R = () => {
400
+ const { content: i, files: C } = A();
401
+ (i.trim() || C.length > 0) && s.onSend(i.trim(), C.length > 0 ? C : void 0);
382
402
  };
383
- return w.addEventListener("submit", (s) => {
384
- s.preventDefault(), D();
385
- }), u.addEventListener("keydown", (s) => {
386
- s.key === "Enter" && !s.shiftKey && (s.preventDefault(), D());
387
- }), b && R.appendChild(b), R.append(u, x), f && w.appendChild(f), w.append(I, R), {
388
- inputRow: w,
389
- getValueAndClear: k,
390
- setDisabled: (s) => {
391
- u.disabled = s, x.disabled = s, x.style.opacity = s ? "0.6" : "1", x.style.cursor = s ? "not-allowed" : "pointer";
403
+ return v.addEventListener("submit", (i) => {
404
+ i.preventDefault(), R();
405
+ }), g.addEventListener("keydown", (i) => {
406
+ i.key === "Enter" && !i.shiftKey && (i.preventDefault(), R());
407
+ }), b && N.appendChild(b), N.append(g, m), f && v.appendChild(f), v.append(_, N), {
408
+ inputRow: v,
409
+ getValueAndClear: A,
410
+ setDisabled: (i) => {
411
+ g.disabled = i, m.disabled = i, m.style.opacity = i ? "0.6" : "1", m.style.cursor = i ? "not-allowed" : "pointer";
392
412
  },
393
- focus: () => u.focus()
413
+ focus: () => g.focus()
394
414
  };
395
415
  }
396
416
  export {
397
- ae as mountChatWidget
417
+ ue as mountChatWidget
398
418
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useago/sdk",
3
- "version": "0.3.4",
3
+ "version": "0.4.2",
4
4
  "description": "JavaScript SDK for AGO Chat integration",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -9,32 +9,74 @@
9
9
  "types": "dist/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
- "import": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
13
- "require": { "types": "./dist/index.d.cts", "default": "./dist/index.cjs" }
12
+ "import": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ },
16
+ "require": {
17
+ "types": "./dist/index.d.cts",
18
+ "default": "./dist/index.cjs"
19
+ }
14
20
  },
15
21
  "./react": {
16
- "import": { "types": "./dist/react.d.ts", "default": "./dist/react.js" },
17
- "require": { "types": "./dist/react.d.cts", "default": "./dist/react.cjs" }
22
+ "import": {
23
+ "types": "./dist/react.d.ts",
24
+ "default": "./dist/react.js"
25
+ },
26
+ "require": {
27
+ "types": "./dist/react.d.cts",
28
+ "default": "./dist/react.cjs"
29
+ }
18
30
  },
19
31
  "./vue": {
20
- "import": { "types": "./dist/vue.d.ts", "default": "./dist/vue.js" },
21
- "require": { "types": "./dist/vue.d.cts", "default": "./dist/vue.cjs" }
32
+ "import": {
33
+ "types": "./dist/vue.d.ts",
34
+ "default": "./dist/vue.js"
35
+ },
36
+ "require": {
37
+ "types": "./dist/vue.d.cts",
38
+ "default": "./dist/vue.cjs"
39
+ }
22
40
  },
23
41
  "./angular": {
24
- "import": { "types": "./dist/angular.d.ts", "default": "./dist/angular.js" },
25
- "require": { "types": "./dist/angular.d.cts", "default": "./dist/angular.cjs" }
42
+ "import": {
43
+ "types": "./dist/angular.d.ts",
44
+ "default": "./dist/angular.js"
45
+ },
46
+ "require": {
47
+ "types": "./dist/angular.d.cts",
48
+ "default": "./dist/angular.cjs"
49
+ }
26
50
  },
27
51
  "./helpers": {
28
- "import": { "types": "./dist/helpers.d.ts", "default": "./dist/helpers.js" },
29
- "require": { "types": "./dist/helpers.d.cts", "default": "./dist/helpers.cjs" }
52
+ "import": {
53
+ "types": "./dist/helpers.d.ts",
54
+ "default": "./dist/helpers.js"
55
+ },
56
+ "require": {
57
+ "types": "./dist/helpers.d.cts",
58
+ "default": "./dist/helpers.cjs"
59
+ }
30
60
  },
31
61
  "./widget": {
32
- "import": { "types": "./dist/widget.d.ts", "default": "./dist/widget.js" },
33
- "require": { "types": "./dist/widget.d.cts", "default": "./dist/widget.cjs" }
62
+ "import": {
63
+ "types": "./dist/widget.d.ts",
64
+ "default": "./dist/widget.js"
65
+ },
66
+ "require": {
67
+ "types": "./dist/widget.d.cts",
68
+ "default": "./dist/widget.cjs"
69
+ }
34
70
  },
35
71
  "./devtools": {
36
- "import": { "types": "./dist/devtools.d.ts", "default": "./dist/devtools.js" },
37
- "require": { "types": "./dist/devtools.d.cts", "default": "./dist/devtools.cjs" }
72
+ "import": {
73
+ "types": "./dist/devtools.d.ts",
74
+ "default": "./dist/devtools.js"
75
+ },
76
+ "require": {
77
+ "types": "./dist/devtools.d.cts",
78
+ "default": "./dist/devtools.cjs"
79
+ }
38
80
  }
39
81
  },
40
82
  "publishConfig": {
@@ -94,6 +136,7 @@
94
136
  "@types/react-dom": "^18.0.0",
95
137
  "@typescript-eslint/eslint-plugin": "^7.0.0",
96
138
  "@typescript-eslint/parser": "^7.0.0",
139
+ "esbuild": "^0.28.0",
97
140
  "eslint": "^8.0.0",
98
141
  "eslint-plugin-react-hooks": "^4.6.2",
99
142
  "jsdom": "^28.0.0",