@aintela/chat 0.2.59 → 0.3.1

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