@aintela/chat 0.2.54 → 0.2.56

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