@aintela/chat 0.2.58 → 0.3.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.
Files changed (87) hide show
  1. package/README.md +63 -0
  2. package/dist/{ClientMessage-EKgfuTp8.js → ClientMessage-DUby3KyC.js} +16 -22
  3. package/dist/{ClientMessage-EKgfuTp8.js.map → ClientMessage-DUby3KyC.js.map} +1 -1
  4. package/dist/Memory-CjrYSkzB.js +47 -0
  5. package/dist/Memory-CjrYSkzB.js.map +1 -0
  6. package/dist/atMentions-CCNBOf5W.js +954 -0
  7. package/dist/atMentions-CCNBOf5W.js.map +1 -0
  8. package/dist/components.js +5291 -5145
  9. package/dist/components.js.map +1 -1
  10. package/dist/environmentUtils-VZNTCzEE.js +88 -0
  11. package/dist/environmentUtils-VZNTCzEE.js.map +1 -0
  12. package/dist/hooks.js +4 -5
  13. package/dist/{httpArtifactService-JtkC1T7n.js → httpArtifactService-kXjuQtGa.js} +518 -643
  14. package/dist/httpArtifactService-kXjuQtGa.js.map +1 -0
  15. package/dist/{httpSessionService-BDlqebW2.js → httpSessionService-CMT6k-Nu.js} +2 -3
  16. package/dist/{httpSessionService-BDlqebW2.js.map → httpSessionService-CMT6k-Nu.js.map} +1 -1
  17. package/dist/index.js +243 -258
  18. package/dist/models.js +48 -51
  19. package/dist/models.js.map +1 -1
  20. package/dist/serializer-D2W42bdT.js +1730 -0
  21. package/dist/serializer-D2W42bdT.js.map +1 -0
  22. package/dist/services.js +2 -2
  23. package/dist/src/components/AiChat/AiChatProvider.agent.test.d.ts +1 -0
  24. package/dist/src/components/AiChat/AiChatProvider.d.ts +2 -2
  25. package/dist/src/components/AiChat/AiChatTypes.d.ts +45 -16
  26. package/dist/src/components/AiChat/ChatPane/parts/ServerErrorPart.d.ts +19 -0
  27. package/dist/src/components/AiChat/ChatPane/parts/ThoughtRun.d.ts +28 -0
  28. package/dist/src/components/AiChat/ChatPane/parts/ThoughtRunContext.d.ts +18 -0
  29. package/dist/src/components/AiChat/ChatPane/parts/index.d.ts +13 -4
  30. package/dist/src/components/AiChat/ChatPane/parts/thoughtRun.test.d.ts +1 -0
  31. package/dist/src/components/AiChat/ChatPane/parts/types.d.ts +1 -1
  32. package/dist/src/components/AiChat/aiChatEngine.d.ts +24 -5
  33. package/dist/src/components/AiChat/sessionStateManagerService.bind.test.d.ts +1 -0
  34. package/dist/src/components/AiChat/sessionStateManagerService.d.ts +22 -10
  35. package/dist/src/components/AiChat/useAgentEngine.d.ts +69 -0
  36. package/dist/src/components/AiChat/useAgentEngine.test.d.ts +1 -0
  37. package/dist/src/components/index.d.ts +4 -4
  38. package/dist/src/hooks/index.d.ts +1 -1
  39. package/dist/src/hooks/useContainerWidth.d.ts +0 -1
  40. package/dist/src/models/ArtifactData.d.ts +0 -7
  41. package/dist/src/models/ChatSession.d.ts +0 -32
  42. package/dist/src/models/ClientMessage.d.ts +0 -4
  43. package/dist/src/models/ServerEvent.d.ts +7 -36
  44. package/dist/src/models/enums.d.ts +0 -1
  45. package/dist/src/models/index.d.ts +1 -2
  46. package/dist/src/models/interactionPartUtils.test.d.ts +1 -0
  47. package/dist/src/models/semanticKernelModel/sanitizeJsonString.test.d.ts +0 -0
  48. package/dist/src/models/serverEventDecode.test.d.ts +0 -0
  49. package/dist/src/services/WebSocketConnection/webSocketConnectionV2.reconnect.test.d.ts +0 -0
  50. package/dist/src/services/interactionService.d.ts +11 -0
  51. package/dist/src/services/interactionServiceGrouping.test.d.ts +1 -0
  52. package/dist/src/services/servers/AgentGatewayService.d.ts +25 -18
  53. package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +0 -1
  54. package/dist/src/services/servers/agentGatewayAgentContext.test.d.ts +1 -0
  55. package/dist/src/services/storageService.d.ts +16 -59
  56. package/dist/src/services/storageService.test.d.ts +1 -0
  57. package/dist/src/utils/index.d.ts +2 -6
  58. package/dist/src/utils/urlParser.d.ts +0 -1
  59. package/dist/tests/fakes/fakeRawWebSocket.d.ts +51 -0
  60. package/dist/tests/fakes/fakeStorage.d.ts +7 -0
  61. package/dist/tests/fakes/makeGateway.d.ts +24 -1
  62. package/dist/{useChatSessions-sbBneRk9.js → useChatSessions-CpHq0e1n.js} +2 -2
  63. package/dist/{useChatSessions-sbBneRk9.js.map → useChatSessions-CpHq0e1n.js.map} +1 -1
  64. package/dist/useContainerWidth-B40_i-NW.js +295 -0
  65. package/dist/{useContainerWidth-B3t1ZTlo.js.map → useContainerWidth-B40_i-NW.js.map} +1 -1
  66. package/dist/utils.js +340 -57
  67. package/dist/utils.js.map +1 -1
  68. package/package.json +1 -1
  69. package/dist/Memory-DjLZqgbF.js +0 -84
  70. package/dist/Memory-DjLZqgbF.js.map +0 -1
  71. package/dist/atMentions-C0dza8DD.js +0 -1000
  72. package/dist/atMentions-C0dza8DD.js.map +0 -1
  73. package/dist/auth-lluJZyQO.js +0 -524
  74. package/dist/auth-lluJZyQO.js.map +0 -1
  75. package/dist/environmentUtils-CUVZ6Dq1.js +0 -478
  76. package/dist/environmentUtils-CUVZ6Dq1.js.map +0 -1
  77. package/dist/httpArtifactService-JtkC1T7n.js.map +0 -1
  78. package/dist/serializer-DNt8QqNO.js +0 -1358
  79. package/dist/serializer-DNt8QqNO.js.map +0 -1
  80. package/dist/src/components/AiChat/useLiveSession.d.ts +0 -52
  81. package/dist/src/utils/jsonDetector.d.ts +0 -50
  82. package/dist/src/utils/jsonUtils.d.ts +0 -1
  83. package/dist/src/utils/materialIconsSvg.d.ts +0 -51
  84. package/dist/src/utils/objectUtils.d.ts +0 -31
  85. package/dist/src/utils/parseArtifact.d.ts +0 -3
  86. package/dist/src/utils/uriUtils.d.ts +0 -39
  87. package/dist/useContainerWidth-B3t1ZTlo.js +0 -309
@@ -0,0 +1,954 @@
1
+ var A = Object.defineProperty;
2
+ var d = (n, t) => A(n, "name", { value: t, configurable: !0 });
3
+ const H = /* @__PURE__ */ d((n, t, e) => {
4
+ let s = "URL", o = null, i = null, r = null;
5
+ if (n[0] == "#") {
6
+ const a = n.indexOf("-"), l = n.slice(1, a);
7
+ switch (r = n.slice(a + 1), l.toLowerCase()) {
8
+ case "opendashboard":
9
+ s = "OpenDashboard";
10
+ break;
11
+ case "ask":
12
+ s = "Question", o = e;
13
+ break;
14
+ }
15
+ } else
16
+ n.indexOf("http") > -1 ? (s = "URL", i = n) : (n = n.replaceAll("exported/", `exported/${t}/`), s = "Export");
17
+ return { action: s, url: i, question: o, parameter: r };
18
+ }, "extractLinkAction"), k = /* @__PURE__ */ d((n, t) => Array.from(
19
+ { length: Math.ceil(n.length / t) },
20
+ (e, s) => n.slice(s * t, s * t + t)
21
+ ), "chunkArray"), _ = /* @__PURE__ */ d((n) => {
22
+ n = n.replaceAll("\\n", `
23
+ `);
24
+ const t = 90, e = n.split(" "), s = [];
25
+ let o = !1;
26
+ for (const i of e)
27
+ if (i.length > t) {
28
+ o = !0;
29
+ const r = [...i], l = k(r, t).map((c) => c.join("")).join(`
30
+ `);
31
+ s.push(l);
32
+ } else
33
+ s.push(i);
34
+ return o ? s.join(" ") : n;
35
+ }, "splitBigLinesWithSpaces");
36
+ function $(n) {
37
+ let t = parseFloat(n);
38
+ if (!isNaN(t))
39
+ return n = n.replaceAll(/[,\.]/g, ""), parseInt(n);
40
+ var e = "";
41
+ for (const o of n)
42
+ o.match(/[0-9]/) && (e += o);
43
+ const s = e.length / n.length;
44
+ return t = parseInt(e), !isNaN(t) && s > 0.5 ? t : NaN;
45
+ }
46
+ d($, "parseRawNumber");
47
+ const I = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i, N = /^[0-9a-f]{32}/i;
48
+ function z(n) {
49
+ if (!n || typeof n != "string")
50
+ return !1;
51
+ const t = W(n);
52
+ return t === null ? !1 : n.startsWith(t);
53
+ }
54
+ d(z, "startsWithInteractionId");
55
+ function W(n) {
56
+ if (!n || typeof n != "string")
57
+ return null;
58
+ const t = n.match(I);
59
+ if (t)
60
+ return t[0];
61
+ const e = n.match(N);
62
+ return e ? e[0] : null;
63
+ }
64
+ d(W, "extractInteractionId");
65
+ function B(n) {
66
+ if (n.length == 0)
67
+ return n;
68
+ const t = n.replaceAll("_", " ").replaceAll("-", " ");
69
+ return t[0].toUpperCase() + t.slice(1);
70
+ }
71
+ d(B, "prettiffyPythonFunctionName");
72
+ function F(n) {
73
+ return !n || typeof n != "string" ? !1 : !!(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n) || /^[0-9a-f]{32}$/i.test(n));
74
+ }
75
+ d(F, "isValidInteractionId");
76
+ const x = /* @__PURE__ */ new Set(), C = class C {
77
+ constructor(t = {}) {
78
+ this.options = {
79
+ // CSS class for sortable headers
80
+ sortableClass: "sortable-header",
81
+ // CSS class for active sort
82
+ activeSortClass: "active-sort",
83
+ // CSS class for ascending sort
84
+ ascendingClass: "sort-asc",
85
+ // CSS class for descending sort
86
+ descendingClass: "sort-desc",
87
+ // Icon for unsorted state
88
+ unsortedIcon: "unfold_more",
89
+ // Icon for ascending sort
90
+ ascendingIcon: "keyboard_arrow_up",
91
+ // Icon for descending sort
92
+ descendingIcon: "keyboard_arrow_down",
93
+ // Whether to sort on first click (true) or cycle through states (false)
94
+ sortOnFirstClick: !0,
95
+ // Custom sort functions for specific columns
96
+ customSorters: {},
97
+ // Columns to exclude from sorting (0-based index)
98
+ excludeColumns: [],
99
+ // Whether to preserve existing icons in headers
100
+ preserveExistingIcons: !1,
101
+ // Enable column resizing
102
+ enableResizing: !0,
103
+ // Enable column reordering
104
+ enableReordering: !0,
105
+ // CSS class for resizable columns
106
+ resizableClass: "resizable-column",
107
+ // CSS class for draggable columns
108
+ draggableClass: "draggable-column",
109
+ // CSS class for drag placeholder
110
+ dragPlaceholderClass: "drag-placeholder",
111
+ // CSS class for drag over state
112
+ dragOverClass: "drag-over",
113
+ theme: {
114
+ palette: {
115
+ primary: {
116
+ main: "#999"
117
+ },
118
+ background: {
119
+ default: "#fff",
120
+ paper: "#555"
121
+ },
122
+ text: {
123
+ primary: "#000",
124
+ secondary: "#999",
125
+ disabled: "#BBB"
126
+ },
127
+ surface: {
128
+ panel: "#999",
129
+ raised: "#999",
130
+ hover: "#444"
131
+ },
132
+ divider: "#999",
133
+ border: {
134
+ default: "#999",
135
+ soft: "#BBB"
136
+ }
137
+ },
138
+ shape: {
139
+ borderRadius: 7,
140
+ radiusSm: 1,
141
+ radiusLg: 10
142
+ }
143
+ },
144
+ ...t
145
+ }, this.tables = [], this.sortStates = /* @__PURE__ */ new Map(), this.originalColumnOrder = /* @__PURE__ */ new Map(), this.isDragging = !1, this.dragSource = null, this.dragTarget = null, this.charWidth = 0;
146
+ }
147
+ /**
148
+ * Initialize the library - scan document for tables and make them sortable
149
+ * @param {HTMLElement} container - Optional container element to limit search scope
150
+ */
151
+ init(t = null) {
152
+ this.charWidth == 0 && (this.charWidth = this.getCharWidth(this.options.theme.typography.fontFamily, this.options.theme.typography.fontMono)), this.scanTables(t), this.makeTablesSortable(), this.addStyles();
153
+ }
154
+ /**
155
+ * Scan for tables in the document or within a specific container
156
+ * @param {HTMLElement} container - Optional container element to limit search scope
157
+ */
158
+ scanTables(t = null) {
159
+ const s = (t || document).querySelectorAll("table");
160
+ this.tables = Array.from(s);
161
+ }
162
+ /**
163
+ * Make all found tables sortable
164
+ */
165
+ makeTablesSortable() {
166
+ this.tables.forEach((t, e) => {
167
+ this.makeTableSortable(t, e);
168
+ });
169
+ }
170
+ /**
171
+ * Make a specific table sortable
172
+ */
173
+ makeTableSortable(t, e) {
174
+ let s = t.querySelector("thead"), o = null, i = [];
175
+ if (s && (o = s.querySelector("tr"), o && (i = o.querySelectorAll("th"))), i.length === 0) {
176
+ console.warn("Table has no sortable columns, skipping");
177
+ return;
178
+ }
179
+ const r = !t.hasAttribute("data-sortable-arrived");
180
+ t.classList.add("sortable-table"), r && (t.setAttribute("data-sortable-arrived", "true"), t.classList.add("sortable-table-arriving"), setTimeout(() => {
181
+ t.classList.remove("sortable-table-arriving");
182
+ }, 400)), this.sortStates.set(e, {
183
+ currentColumn: -1,
184
+ direction: "none"
185
+ }), t.hasAttribute("data-original-width") || t.setAttribute("data-original-width", t.getBoundingClientRect().width), this.applyTableStyles(t), this.originalColumnOrder.set(e, Array.from(i).map((a, l) => l)), i.forEach((a, l) => {
186
+ this.options.excludeColumns.includes(l) || this.makeHeaderSortable(a, t, e, l);
187
+ }), this.replaceExponentialValues(t), x.add(t);
188
+ }
189
+ /**
190
+ * Replace exponential values in table cells with full numbers
191
+ * @param {HTMLElement} table - The table to process
192
+ */
193
+ replaceExponentialValues(t) {
194
+ const e = t.querySelector("tbody");
195
+ if (!e) return;
196
+ e.querySelectorAll("tr").forEach((o) => {
197
+ o.querySelectorAll("td, th").forEach((r) => {
198
+ const l = r.textContent.trim().match(/^([\d,]+\.?\d*)[eE][+-]?(\d+)$/);
199
+ if (l) {
200
+ const c = parseFloat(l[1].replace(/,/g, "")), p = parseInt(l[2]), u = c * Math.pow(10, p), h = this.formatNumber(u);
201
+ r.textContent = h;
202
+ }
203
+ });
204
+ });
205
+ }
206
+ /**
207
+ * Format a number with commas for readability
208
+ * @param {number} num - The number to format
209
+ * @returns {string} The formatted number
210
+ */
211
+ formatNumber(t) {
212
+ return t === 0 ? "0" : Math.abs(t) >= 1e12 ? (t / 1e12).toFixed(2) + "T" : Math.abs(t) >= 1e9 ? (t / 1e9).toFixed(2) + "B" : Math.abs(t) >= 1e6 ? (t / 1e6).toFixed(2) + "M" : Math.abs(t) >= 1e3 ? (t / 1e3).toFixed(2) + "K" : Math.abs(t) < 0.01 && t !== 0 ? t.toExponential(2) : t.toLocaleString();
213
+ }
214
+ /**
215
+ * Convert the first row to a header row
216
+ * @param {HTMLElement} firstRow - The first row to convert
217
+ * @param {HTMLElement} thead - The thead element to append to
218
+ * @param {HTMLElement} tbody - The tbody element to remove from
219
+ * @returns {HTMLElement} The converted header row
220
+ */
221
+ convertRowToHeader(t, e, s) {
222
+ try {
223
+ const o = t.cloneNode(!0);
224
+ return o.querySelectorAll("td").forEach((r) => {
225
+ const a = document.createElement("th");
226
+ Array.from(r.attributes).forEach((l) => {
227
+ a.setAttribute(l.name, l.value);
228
+ }), a.innerHTML = r.innerHTML, a.style.cssText = r.style.cssText, r.parentNode.replaceChild(a, r);
229
+ }), s && s.contains(t) ? s.removeChild(t) : t.parentNode && t.parentNode.removeChild(t), e.appendChild(o), o;
230
+ } catch (o) {
231
+ return console.error("Error converting row to header:", o), null;
232
+ }
233
+ }
234
+ /**
235
+ * Make a specific header sortable
236
+ */
237
+ makeHeaderSortable(t, e, s, o) {
238
+ t.classList.add(this.options.sortableClass), t.style.cursor = "pointer", (!this.options.preserveExistingIcons || !t.querySelector(".material-icons")) && this.addSortIcon(t), this.options.enableResizing && this.addResizing(t, e, s, o), this.options.enableReordering && this.addDragAndDrop(t, e, s, o);
239
+ const i = /* @__PURE__ */ d((l) => {
240
+ l.preventDefault(), this.sortTable(e, s, o);
241
+ }, "clickListener"), r = /* @__PURE__ */ d((l) => {
242
+ t.classList.contains(this.options.activeSortClass) || (t.style.background = this.options.theme.palette.surface.hover);
243
+ }, "mouseEnterListener"), a = /* @__PURE__ */ d((l) => {
244
+ t.classList.contains(this.options.activeSortClass) || (t.style.background = "");
245
+ }, "mouseLeaveListener");
246
+ t.removeEventListener("click", i), t.addEventListener("click", i), t.removeEventListener("mouseenter", r), t.addEventListener("mouseenter", r), t.removeEventListener("mouseleave", a), t.addEventListener("mouseleave", a);
247
+ }
248
+ /**
249
+ * Add sort icon to header
250
+ */
251
+ addSortIcon(t) {
252
+ if (t.querySelector(".sortable-table-icon"))
253
+ return;
254
+ const e = document.createElement("i");
255
+ e.id = "sortable-table-icon", e.className = "material-icons", e.textContent = this.options.unsortedIcon, e.style.marginRight = "2px", e.style.fontSize = "12px", e.style.verticalAlign = "middle", e.style.opacity = "0", t.querySelector(".material-icons") || (t.insertBefore(e, t.firstChild), requestAnimationFrame(() => {
256
+ requestAnimationFrame(() => {
257
+ e.style.opacity = "0.6";
258
+ });
259
+ }));
260
+ }
261
+ /**
262
+ * Sort table by column
263
+ */
264
+ sortTable(t, e, s) {
265
+ const o = t.querySelector("tbody");
266
+ if (!o) {
267
+ console.warn("Table has no tbody element");
268
+ return;
269
+ }
270
+ const i = Array.from(o.querySelectorAll("tr"));
271
+ if (i.length === 0) {
272
+ console.warn("Table has no data rows");
273
+ return;
274
+ }
275
+ const r = this.sortStates.get(e);
276
+ t.querySelector(`thead tr th:nth-child(${s + 1})`);
277
+ let a;
278
+ if (this.options.sortOnFirstClick ? a = r.currentColumn === s && r.direction === "asc" ? "desc" : "asc" : r.currentColumn !== s ? a = "asc" : a = r.direction === "none" ? "asc" : r.direction === "asc" ? "desc" : "none", r.currentColumn = s, r.direction = a, this.sortStates.set(e, r), this.updateSortIndicators(t, e, s, a), a === "none") {
279
+ this.restoreOriginalOrder(t, i);
280
+ return;
281
+ }
282
+ this.sortRows(i, s, a).forEach((c) => o.appendChild(c));
283
+ }
284
+ /**
285
+ * Sort rows based on column data
286
+ */
287
+ sortRows(t, e, s) {
288
+ return t.sort((o, i) => {
289
+ const r = o.cells[e], a = i.cells[e];
290
+ if (!r || !a) return 0;
291
+ const l = this.extractValue(r), c = this.extractValue(a);
292
+ if (this.options.customSorters[e])
293
+ return this.options.customSorters[e](l, c, s);
294
+ const p = this.compareValues(l, c);
295
+ return s === "asc" ? p : -p;
296
+ });
297
+ }
298
+ /**
299
+ * Extract sortable value from cell
300
+ */
301
+ extractValue(t) {
302
+ let e = t.textContent.trim(), s = $(e);
303
+ if (!isNaN(s))
304
+ return console.log(s), s;
305
+ if (e = e.replace(/arrow_upward|arrow_downward|remove|keyboard_arrow_up|keyboard_arrow_down|unfold_more|expand_more|expand_less|trending_up|trending_down|↗|↘|↑|↓|→|←/g, "").trim(), /^(N\/A|N\/D|ND|N\/A|n\/a|n\/d|nd|N\/A|N\/D|ND|\s*)$/i.test(e))
306
+ return -1;
307
+ const i = e.match(/^([\d,]+\.?\d*)\s*%$/);
308
+ if (i)
309
+ return parseFloat(i[1].replace(/,/g, ""));
310
+ const r = e.match(/^([\d,]+\.?\d*)[eE][+-]?(\d+)$/);
311
+ if (r) {
312
+ const p = parseFloat(r[1].replace(/,/g, "")), u = parseInt(r[2]);
313
+ return p * Math.pow(10, u);
314
+ }
315
+ if (e.match(/^[\d,]+\.?\d*[KMB]?$/))
316
+ return this.parseNumber(e);
317
+ const l = e.match(/^R\$\s*([\d,]+\.?\d*)$/);
318
+ if (l)
319
+ return this.parseNumber(l[1]);
320
+ const c = new Date(e);
321
+ return isNaN(c.getTime()) ? e.toLowerCase() : c.getTime();
322
+ }
323
+ /**
324
+ * Compare two values for sorting
325
+ */
326
+ compareValues(t, e) {
327
+ return t == null && e == null ? 0 : t == null ? -1 : e == null ? 1 : typeof t != typeof e ? String(t).localeCompare(String(e)) : typeof t == "number" ? t - e : t instanceof Date ? t.getTime() - e.getTime() : t.localeCompare(e);
328
+ }
329
+ /**
330
+ * Update visual indicators for sort state
331
+ */
332
+ updateSortIndicators(t, e, s, o) {
333
+ const i = t.querySelectorAll("thead tr th");
334
+ if (i.forEach((r, a) => {
335
+ r.classList.remove(this.options.activeSortClass, this.options.ascendingClass, this.options.descendingClass);
336
+ const l = r.querySelector(".material-icons");
337
+ l && (l.textContent = this.options.unsortedIcon, l.style.opacity = "0.6");
338
+ }), o !== "none") {
339
+ const r = i[s];
340
+ r.classList.add(this.options.activeSortClass);
341
+ const a = r.querySelector(".material-icons");
342
+ a && (o === "asc" ? (r.classList.add(this.options.ascendingClass), a.textContent = this.options.ascendingIcon) : (r.classList.add(this.options.descendingClass), a.textContent = this.options.descendingIcon), a.style.opacity = "1");
343
+ }
344
+ }
345
+ /**
346
+ * Restore original order (when sort direction is 'none')
347
+ */
348
+ restoreOriginalOrder(t, e) {
349
+ const s = t.querySelector("tbody");
350
+ e.forEach((o) => s.appendChild(o));
351
+ }
352
+ /**
353
+ * Add resizing functionality to a header
354
+ */
355
+ addResizing(t, e, s, o) {
356
+ if (t.classList.add(this.options.resizableClass), t.style.position = "relative", t.querySelector(".resize-handle"))
357
+ return;
358
+ const i = document.createElement("div");
359
+ i.className = "resize-handle", i.style.cssText = `
360
+ position: absolute;
361
+ top: 0;
362
+ right: 0;
363
+ width: 4px;
364
+ height: 100%;
365
+ background: transparent;
366
+ cursor: col-resize;
367
+ z-index: 10;
368
+ `, t.appendChild(i);
369
+ let r = !1, a = 0, l = 0;
370
+ i.addEventListener("mousedown", (u) => {
371
+ u.preventDefault(), u.stopPropagation(), u.stopImmediatePropagation(), r = !0, a = u.clientX, l = t.offsetWidth, t.style.borderRight = "2px solid var(--primary-main, #2196F3)", t.style.background = "var(--background-active, rgba(255, 255, 255, 0.1))", document.addEventListener("mousemove", c), document.addEventListener("mouseup", p), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
372
+ });
373
+ const c = /* @__PURE__ */ d((u) => {
374
+ if (!r) return;
375
+ const h = l + (u.clientX - a);
376
+ if (h > 30) {
377
+ t.style.width = h + "px";
378
+ const g = Array.from(t.parentNode.children).indexOf(t), f = e.querySelector("tbody");
379
+ f && f.querySelectorAll("tr").forEach((y) => {
380
+ const b = y.children[g];
381
+ b && (b.style.width = h + "px");
382
+ }), this.updateTableWidth(e);
383
+ }
384
+ }, "handleResize"), p = /* @__PURE__ */ d(() => {
385
+ r = !1, t.style.borderRight = "", t.style.background = "", document.removeEventListener("mousemove", c), document.removeEventListener("mouseup", p), document.body.style.cursor = "", document.body.style.userSelect = "";
386
+ }, "stopResize");
387
+ }
388
+ /**
389
+ * Add drag and drop functionality to a header
390
+ */
391
+ addDragAndDrop(t, e, s, o) {
392
+ if (t.querySelector(".drag-handle"))
393
+ return;
394
+ t.classList.add(this.options.draggableClass), t.draggable = !0;
395
+ const i = e.querySelector("thead tr");
396
+ t.addEventListener("dragstart", (r) => {
397
+ this.isDragging = !0;
398
+ const a = Array.from(i.children).indexOf(t);
399
+ this.dragSource = { table: e, tableIndex: s, columnIndex: a }, r.dataTransfer.effectAllowed = "move", r.dataTransfer.setData("text/html", t.outerHTML);
400
+ const l = t.outerHTML;
401
+ t.style.opacity = "0.5", this.createCustomDragImage(r, t, l);
402
+ }), t.addEventListener("dragend", (r) => {
403
+ this.isDragging = !1, this.dragSource = null, t.style.opacity = "", this.clearAllColumnHighlights(e);
404
+ }), t.addEventListener("dragover", (r) => {
405
+ r.preventDefault(), r.dataTransfer.dropEffect = "move";
406
+ }), t.addEventListener("dragenter", (r) => {
407
+ if (r.preventDefault(), this.dragSource && this.dragSource.tableIndex === s) {
408
+ const a = Array.from(i.children).indexOf(t);
409
+ this.dragSource.columnIndex !== a && this.highlightColumn(e, a, !0);
410
+ }
411
+ }), t.addEventListener("dragleave", (r) => {
412
+ if (!t.contains(r.relatedTarget)) {
413
+ const a = Array.from(i.children).indexOf(t);
414
+ this.highlightColumn(e, a, !1);
415
+ }
416
+ }), t.addEventListener("drop", (r) => {
417
+ if (r.preventDefault(), this.dragSource && this.dragSource.tableIndex === s) {
418
+ const a = Array.from(i.children).indexOf(t);
419
+ this.dragSource.columnIndex !== a && this.reorderColumns(e, s, this.dragSource.columnIndex, a);
420
+ }
421
+ this.clearAllColumnHighlights(e);
422
+ });
423
+ }
424
+ /**
425
+ * Create a custom drag image for better UX
426
+ */
427
+ createCustomDragImage(t, e, s) {
428
+ const o = document.createElement("div");
429
+ o.style.cssText = `
430
+ position: absolute;
431
+ top: -1000px;
432
+ left: -1000px;
433
+ background: var(--background-elevated, #333);
434
+ border: 2px solid var(--primary-main, #2196F3);
435
+ border-radius: 4px;
436
+ padding: 8px 12px;
437
+ font-size: 12px;
438
+ font-weight: bold;
439
+ color: var(--text-primary, #fff);
440
+ white-space: nowrap;
441
+ max-width: 150px;
442
+ min-width: 60px;
443
+ overflow: hidden;
444
+ text-overflow: ellipsis;
445
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
446
+ z-index: 10000;
447
+ pointer-events: none;
448
+ min-height: 50px;
449
+ display: flex;
450
+ align-items: center;
451
+ `;
452
+ const i = s;
453
+ o.innerHTML = `
454
+ <div style="display: flex; align-items: center; gap: 5px; align-content: center;color:white;">
455
+ <span style="overflow: hidden; text-overflow: ellipsis">${i}</span>
456
+ <svg style="fill: grey; font-size: 10px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 20 20" ><defs><path id="a" d="M0 0h24v24H0V0z"/></defs><clipPath id="b"><use xlink:href="#a" overflow="visible"/></clipPath><path clip-path="url(#b)" d="M9.01 14H2v2h7.01v3L13 15l-3.99-4v3zm5.98-1v-3H22V8h-7.01V5L11 9l3.99 4z"/></svg>
457
+ </div>
458
+ `, document.body.appendChild(o), t.dataTransfer.setDragImage(o, 50, 12), setTimeout(() => {
459
+ document.body.contains(o) && document.body.removeChild(o);
460
+ }, 100);
461
+ }
462
+ /**
463
+ * Highlight an entire column during drag operations
464
+ */
465
+ highlightColumn(t, e, s) {
466
+ const o = t.querySelector("thead tr"), i = t.querySelector("tbody");
467
+ if (!o || !i) return;
468
+ const r = o.children[e];
469
+ if (r)
470
+ if (s) {
471
+ r.classList.add(this.options.dragOverClass);
472
+ const a = i.children;
473
+ for (let l = 0; l < a.length; l++) {
474
+ const c = a[l].children[e];
475
+ c && c.classList.add(this.options.dragOverClass);
476
+ }
477
+ } else {
478
+ r.classList.remove(this.options.dragOverClass);
479
+ const a = i.children;
480
+ for (let l = 0; l < a.length; l++) {
481
+ const c = a[l].children[e];
482
+ c && c.classList.remove(this.options.dragOverClass);
483
+ }
484
+ }
485
+ }
486
+ /**
487
+ * Clear all column highlights
488
+ */
489
+ clearAllColumnHighlights(t) {
490
+ const e = t.querySelector("thead tr"), s = t.querySelector("tbody");
491
+ if (!e || !s) return;
492
+ const o = e.children;
493
+ for (let r = 0; r < o.length; r++)
494
+ o[r].classList.remove(this.options.dragOverClass);
495
+ const i = s.children;
496
+ for (let r = 0; r < i.length; r++) {
497
+ const a = i[r].children;
498
+ for (let l = 0; l < a.length; l++)
499
+ a[l].classList.remove(this.options.dragOverClass);
500
+ }
501
+ }
502
+ /**
503
+ * Reorder columns in a table
504
+ */
505
+ reorderColumns(t, e, s, o) {
506
+ const i = t.querySelector("thead tr"), r = t.querySelector("tbody");
507
+ if (!i || !r) return;
508
+ const a = Array.from(i.children), l = Array.from(r.children);
509
+ if (s < 0 || s >= a.length || o < 0 || o >= a.length) {
510
+ console.warn("Invalid column indices for reordering");
511
+ return;
512
+ }
513
+ if (s === o)
514
+ return;
515
+ const c = a[s], p = a[o];
516
+ s < o ? i.insertBefore(c, p.nextSibling) : i.insertBefore(c, p), l.forEach((h, g) => {
517
+ const f = Array.from(h.children), m = f[s], y = f[o];
518
+ s < o ? h.insertBefore(m, y.nextSibling) : h.insertBefore(m, y);
519
+ });
520
+ const u = this.originalColumnOrder.get(e);
521
+ if (u) {
522
+ const h = [...u], g = h[s];
523
+ h.splice(s, 1), h.splice(o, 0, g), this.originalColumnOrder.set(e, h);
524
+ }
525
+ this.applyTableStyles(t), this.refreshDragAndDropListeners(t, e);
526
+ }
527
+ /**
528
+ * Refresh drag and drop listeners after column reordering
529
+ */
530
+ refreshDragAndDropListeners(t, e) {
531
+ const s = t.querySelector("thead tr");
532
+ if (!s) return;
533
+ Array.from(s.children).forEach((i, r) => {
534
+ if (i.classList.contains(this.options.draggableClass)) {
535
+ i.style.opacity = "", i.style.background = "", i.style.borderRight = "";
536
+ const a = i.cloneNode(!0);
537
+ i.parentNode.replaceChild(a, i), this.makeHeaderSortable(a, t, e, r);
538
+ }
539
+ });
540
+ }
541
+ /**
542
+ * Update table width based on current column widths
543
+ */
544
+ updateTableWidth(t) {
545
+ const e = t.querySelectorAll("th");
546
+ let s = 0;
547
+ e.forEach((o) => {
548
+ const i = o.style.width;
549
+ if (i) {
550
+ const r = parseInt(i.replace("px", ""));
551
+ s += r;
552
+ } else {
553
+ const r = o.textContent.replace(/[📊🔍]/g, "").trim();
554
+ s += r.length;
555
+ }
556
+ }), t.style.width = `${s}px`;
557
+ }
558
+ /**
559
+ * Calculate intelligent table width based on header text length
560
+ */
561
+ calculateTableWidth(t) {
562
+ var u;
563
+ const e = t.getAttribute("data-original-width"), s = e ? parseFloat(e) : 0, o = t.querySelectorAll("th");
564
+ let i = 0;
565
+ t.parentElement.clientWidth;
566
+ const r = [];
567
+ o.forEach((h) => {
568
+ let f = h.textContent.replace(/[📊🔍]/g, "").trim().length * this.charWidth + 15;
569
+ r.push(f), i += f;
570
+ });
571
+ const a = t.querySelectorAll("tr"), l = ((u = t.parentElement) == null ? void 0 : u.getBoundingClientRect().width) ?? i;
572
+ var c = 0;
573
+ for (const h of a)
574
+ h.querySelectorAll("td").forEach((f, m) => {
575
+ const b = f.textContent.length * this.charWidth + 15;
576
+ b > r[m] && m < r.length && (r[m] = b);
577
+ });
578
+ c = r.reduce((h, g) => h += g, 0), o.forEach((h, g) => {
579
+ if (c > l) {
580
+ const f = r[g] / c;
581
+ h.style.width = `${l * f}px`;
582
+ } else
583
+ h.style.width = `${r[g]}px`;
584
+ });
585
+ let p = 0;
586
+ return c > l ? p = "100%" : p = `${Math.max(c, s)}px`, p;
587
+ }
588
+ /**
589
+ * Apply inline styles to ensure text clipping and horizontal scroll work
590
+ */
591
+ applyTableStyles(t) {
592
+ const e = this.calculateTableWidth(t);
593
+ t.style.width = e, t.style.maxWidth = "100%";
594
+ }
595
+ getCharWidth(t, e, s) {
596
+ const i = document.createElement("canvas").getContext("2d");
597
+ return i.fontFamily = e, i.fontMono = s, i.measureText("A ").width;
598
+ }
599
+ /**
600
+ * Add CSS styles for sortable tables
601
+ */
602
+ addStyles() {
603
+ if (document.getElementById("sortable-table-styles"))
604
+ return;
605
+ const t = document.createElement("style");
606
+ t.id = "sortable-table-styles", t.textContent = `
607
+ .${this.options.sortableClass} {
608
+ position: relative;
609
+ user-select: none;
610
+ transition: background-color 0.2s ease;
611
+ }
612
+
613
+ .${this.options.sortableClass}:hover {
614
+ background-color: ${this.options.theme.palette.surface.hover} !important;
615
+ }
616
+
617
+ .${this.options.activeSortClass} {
618
+ background-color: ${this.options.theme.palette.surface.raised} !important;
619
+ font-weight: bold;
620
+ }
621
+
622
+ .${this.options.ascendingClass} {
623
+ border-bottom: 2px solid var(${this.options.theme.palette.primary.main}, #3a3a3a);
624
+ }
625
+
626
+ .${this.options.descendingClass} {
627
+ border-bottom: 2px solid var(${this.options.theme.palette.primary.main}, #3a3a3a);
628
+ }
629
+
630
+ .${this.options.sortableClass} .material-icons {
631
+ transition: opacity 0.2s ease, transform 0.2s ease;
632
+ }
633
+
634
+ .${this.options.activeSortClass} .material-icons {
635
+ color: var(${this.options.theme.palette.primary.main}, #3a3a3a);
636
+ }
637
+
638
+ .${this.options.resizableClass} .resize-handle:hover {
639
+ background-color: var(${this.options.theme.palette.primary.light}, #64B5F6);
640
+ }
641
+
642
+ .${this.options.draggableClass} {
643
+ cursor: move;
644
+ position: relative;
645
+ }
646
+
647
+ .${this.options.draggableClass}::before {
648
+ content: '';
649
+ position: absolute;
650
+ top: 0;
651
+ left: -5px;
652
+ right: -5px;
653
+ bottom: 0;
654
+ z-index: 1;
655
+ pointer-events: none;
656
+ }
657
+
658
+ .${this.options.dragOverClass} {
659
+ background-color: rgba(128, 128, 128, 0.2) !important;
660
+ border: 2px dashed rgba(128, 128, 128, 0.8);
661
+ }
662
+
663
+ .${this.options.draggableClass}:hover {
664
+ background-color: var(${this.options.theme.palette.surface.raised}, rgba(100, 181, 246, 0.1)) !important;
665
+ }
666
+
667
+ .sortable-table tbody td {
668
+ width: auto
669
+ }
670
+
671
+ .sortable-table {
672
+ /* Cross-fade bg/row stripes when the .sortable-table
673
+ * class flip lands on a freshly-streamed markdown
674
+ * table. Width is NOT animated: column widths set
675
+ * by calculateTableWidth can be narrower than the
676
+ * content currently fills, so animating them down
677
+ * causes mid-transition cell wrap. Snap widths,
678
+ * animate only colours. */
679
+ transition: background-color 280ms ease-out;
680
+ }
681
+
682
+ .sortable-table th {
683
+ transition: background-color 280ms ease-out;
684
+ }
685
+
686
+ /* Zebra striping for table rows */
687
+ .sortable-table tbody tr:nth-child(odd) {
688
+ background-color: ${this.options.theme.palette.background.defalt};
689
+ color: ${this.options.theme.palette.text.primary};
690
+ }
691
+
692
+ .sortable-table tbody tr:nth-child(even) {
693
+ background-color: ${this.options.theme.palette.background.defalt};
694
+ color: ${this.options.theme.palette.text.primary};
695
+ }
696
+
697
+ /* One-shot arrival animation. Applied via a transient
698
+ * class (added by makeTableSortable on first mount only)
699
+ * so it does NOT re-fire on every destroy/init cycle.
700
+ * scaleX with origin top-left gives the "right edge
701
+ * grows outward" feel the user asked for; the 0.96
702
+ * start is subtle enough that text compression isn't
703
+ * obvious. */
704
+ @keyframes sortable-table-arrive {
705
+ from {
706
+ opacity: 0.35;
707
+ transform: scaleX(0.96);
708
+ transform-origin: top left;
709
+ }
710
+ to {
711
+ opacity: 1;
712
+ transform: scaleX(1);
713
+ }
714
+ }
715
+
716
+ .sortable-table-arriving {
717
+ animation: sortable-table-arrive 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
718
+ }
719
+
720
+ /* Ensure hover effects work with zebra striping */
721
+ .sortable-table tbody tr:hover {
722
+ background-color: ${this.options.theme.palette.surface.hover} !important;
723
+ }
724
+
725
+
726
+ /* Fix table-container overflow issue */
727
+ .table-container {
728
+ overflow: auto !important;
729
+ overflow-x: auto !important;
730
+ overflow-y: auto !important;
731
+ }
732
+ `, document.getElementById("sortable-table-styles") || document.head.appendChild(t);
733
+ }
734
+ /**
735
+ * Destroy the sortable functionality
736
+ */
737
+ destroy() {
738
+ this.tables.forEach((e) => {
739
+ e.querySelectorAll(`.${this.options.sortableClass}`).forEach((o) => {
740
+ o.classList.remove(
741
+ this.options.sortableClass,
742
+ this.options.activeSortClass,
743
+ this.options.ascendingClass,
744
+ this.options.descendingClass
745
+ ), o.style.cursor = "", o.style.background = "";
746
+ const i = o.cloneNode(!0);
747
+ o.parentNode.replaceChild(i, o);
748
+ });
749
+ });
750
+ const t = document.getElementById("sortable-table-styles");
751
+ t && t.remove(), this.tables = [], this.sortStates.clear(), x.clear();
752
+ }
753
+ /**
754
+ * Refresh the library (useful after DOM changes)
755
+ */
756
+ refresh() {
757
+ this.destroy(), this.init();
758
+ }
759
+ };
760
+ d(C, "SortableTable");
761
+ let S = C;
762
+ typeof window < "u" && (window.SortableTable = S);
763
+ const E = /* @__PURE__ */ new Set(["/", "@", "#"]), q = /* @__PURE__ */ d((n) => n === "/" ? "slash" : n === "@" ? "at" : "hash", "triggerTypeFor"), w = /[ \t\r\n\f\v]/, D = /\[[^\]\n]+\]/g, L = /* @__PURE__ */ d((n, t, e) => {
764
+ let s = 0;
765
+ const o = /* @__PURE__ */ d((i) => {
766
+ const r = i === 0 ? t : n[i - 1];
767
+ return r === void 0 || w.test(r);
768
+ }, "boundaryBefore");
769
+ for (; s < n.length; ) {
770
+ const i = n[s];
771
+ if (o(s) && E.has(i)) {
772
+ let r = s + 1;
773
+ for (; r < n.length && !w.test(n[r]); ) r += 1;
774
+ e.push({ type: q(i), text: n.slice(s, r) }), s = r;
775
+ } else {
776
+ let r = s + 1;
777
+ for (; r < n.length; ) {
778
+ const a = n[r];
779
+ if (E.has(a) && w.test(n[r - 1])) break;
780
+ r += 1;
781
+ }
782
+ e.push({ type: "plain", text: n.slice(s, r) }), s = r;
783
+ }
784
+ }
785
+ }, "tokenizeSegment"), V = /* @__PURE__ */ d((n) => {
786
+ if (!n) return [];
787
+ const t = [], e = new RegExp(D.source, "g");
788
+ let s = 0;
789
+ for (let o = e.exec(n); o; o = e.exec(n))
790
+ o.index > s && L(n.slice(s, o.index), s === 0 ? void 0 : n[s - 1], t), t.push({ type: "placeholder", text: o[0] }), s = o.index + o[0].length;
791
+ return s < n.length && L(n.slice(s), s === 0 ? void 0 : n[s - 1], t), t;
792
+ }, "tokenizeForHighlight"), P = /* @__PURE__ */ d((n, t) => {
793
+ const e = t.filter((o) => o.trim().length > 0).sort((o, i) => i.length - o.length);
794
+ if (e.length === 0) return n;
795
+ const s = [];
796
+ for (const o of n) {
797
+ if (o.type !== "plain") {
798
+ s.push(o);
799
+ continue;
800
+ }
801
+ let i = o.text;
802
+ for (; i.length > 0; ) {
803
+ let r = -1, a = 0;
804
+ for (const l of e) {
805
+ const c = i.indexOf(l);
806
+ c >= 0 && (r === -1 || c < r) && (r = c, a = l.length);
807
+ }
808
+ if (r === -1) {
809
+ s.push({ type: "plain", text: i });
810
+ break;
811
+ }
812
+ r > 0 && s.push({ type: "plain", text: i.slice(0, r) }), s.push({ type: "at", text: i.slice(r, r + a) }), i = i.slice(r + a);
813
+ }
814
+ }
815
+ return s;
816
+ }, "chipLocations");
817
+ function X(n, t, e = t, s = 600) {
818
+ const o = n.value;
819
+ let i = !1;
820
+ const r = /* @__PURE__ */ d(() => {
821
+ i || (i = !0, document.removeEventListener("selectionchange", l), n.removeEventListener("keydown", r), n.removeEventListener("input", r), n.removeEventListener("pointerdown", r), window.clearTimeout(c), window.clearInterval(p));
822
+ }, "stop"), a = /* @__PURE__ */ d(() => {
823
+ if (n.value !== o) {
824
+ r();
825
+ return;
826
+ }
827
+ n.selectionStart === t && n.selectionEnd === e || n.setSelectionRange(t, e);
828
+ }, "apply"), l = /* @__PURE__ */ d(() => {
829
+ document.activeElement === n && a();
830
+ }, "onSelectionChange");
831
+ a();
832
+ const c = window.setTimeout(r, s), p = window.setInterval(a, 50);
833
+ return document.addEventListener("selectionchange", l), n.addEventListener("keydown", r), n.addEventListener("input", r), n.addEventListener("pointerdown", r), r;
834
+ }
835
+ d(X, "placeCaret");
836
+ const M = 2;
837
+ function U(n, t) {
838
+ let e = 0;
839
+ for (let s = t - 1; s >= 0; s -= 1) {
840
+ const o = n[s];
841
+ if (o === "/" || o === "@" || o === "#")
842
+ return !(s === 0 || /\s/.test(n[s - 1])) || o !== "@" && e > 0 ? null : {
843
+ trigger: o,
844
+ query: n.slice(s + 1, t),
845
+ startIdx: s,
846
+ endIdx: t
847
+ };
848
+ if (o === " ") return null;
849
+ if (o === " " || o === " ") {
850
+ if (e += 1, e > M) return null;
851
+ continue;
852
+ }
853
+ if (/\s/.test(o)) return null;
854
+ }
855
+ return null;
856
+ }
857
+ d(U, "detectTrigger");
858
+ const O = /\[[^\]\n]+\]/g;
859
+ function v(n, t = 0) {
860
+ const e = new RegExp(O.source, "g");
861
+ e.lastIndex = t;
862
+ const s = e.exec(n);
863
+ if (!s) return null;
864
+ const o = s[0].slice(1, -1), i = o[0], r = i === "@" || i === "#" || i === "/";
865
+ return {
866
+ trigger: r ? i : null,
867
+ label: (r ? o.slice(1) : o).trim(),
868
+ startIdx: s.index,
869
+ endIdx: s.index + s[0].length
870
+ };
871
+ }
872
+ d(v, "findPlaceholder");
873
+ function G(n, t) {
874
+ for (let e = 0; ; ) {
875
+ const s = v(n, e);
876
+ if (!s || s.startIdx > t) return null;
877
+ if (t <= s.endIdx) return s;
878
+ e = s.endIdx;
879
+ }
880
+ }
881
+ d(G, "placeholderAt");
882
+ function T(n, t) {
883
+ if (t.trigger) {
884
+ const e = n.slice(0, t.startIdx) + t.trigger + n.slice(t.endIdx), s = t.startIdx + 1;
885
+ return { next: e, selectionStart: s, selectionEnd: s, reopenTrigger: !0 };
886
+ }
887
+ return { next: n, selectionStart: t.startIdx, selectionEnd: t.endIdx, reopenTrigger: !1 };
888
+ }
889
+ d(T, "activatePlaceholder");
890
+ function j(n, t) {
891
+ const e = v(n, t) ?? v(n, 0);
892
+ return e ? T(n, e) : null;
893
+ }
894
+ d(j, "advanceToPlaceholder");
895
+ function K(n, t, e) {
896
+ const s = n.slice(0, t.startIdx), o = n.slice(t.endIdx), i = v(e);
897
+ if (i) {
898
+ const c = T(e, i);
899
+ return {
900
+ next: `${s}${c.next}${o}`,
901
+ selectionStart: s.length + c.selectionStart,
902
+ selectionEnd: s.length + c.selectionEnd,
903
+ reopenTrigger: c.reopenTrigger
904
+ };
905
+ }
906
+ const r = e[e.length - 1];
907
+ if (r === "@" || r === "#" || r === "/") {
908
+ const c = s.length + e.length;
909
+ return { next: `${s}${e}${o}`, selectionStart: c, selectionEnd: c, reopenTrigger: !0 };
910
+ }
911
+ const a = `${e} `, l = s.length + a.length;
912
+ return { next: `${s}${a}${o}`, selectionStart: l, selectionEnd: l, reopenTrigger: !1 };
913
+ }
914
+ d(K, "applyTriggerInsertion");
915
+ async function Z(n, { onAtQuery: t, onAtPersonQuery: e }, { personConfidence: s = 0, locationConfidence: o = 0, personFirstThreshold: i = 0.5 } = {}) {
916
+ const [r, a] = await Promise.all([
917
+ t ? t(n).catch(() => []) : Promise.resolve([]),
918
+ e ? e(n).catch(() => []) : Promise.resolve([])
919
+ ]);
920
+ if (t && e) {
921
+ const l = a.map((u) => ({ ...u, group: "person" })), c = r.map((u) => ({ ...u, group: "location" }));
922
+ return s >= i && s >= o ? [...l, ...c] : [...c, ...l];
923
+ }
924
+ return [...a, ...r];
925
+ }
926
+ d(Z, "fetchAtMentions");
927
+ function J(n, t) {
928
+ var s, o;
929
+ const e = (s = n[t]) == null ? void 0 : s.group;
930
+ return e !== void 0 && (t === 0 || ((o = n[t - 1]) == null ? void 0 : o.group) !== e);
931
+ }
932
+ d(J, "isSectionStart");
933
+ export {
934
+ S,
935
+ T as a,
936
+ j as b,
937
+ K as c,
938
+ P as d,
939
+ k as e,
940
+ U as f,
941
+ W as g,
942
+ H as h,
943
+ Z as i,
944
+ v as j,
945
+ J as k,
946
+ F as l,
947
+ G as m,
948
+ B as n,
949
+ z as o,
950
+ X as p,
951
+ _ as s,
952
+ V as t
953
+ };
954
+ //# sourceMappingURL=atMentions-CCNBOf5W.js.map