@aparte/core 1.0.2 → 1.1.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.
- package/dist/client/aparte-client.d.ts +2 -0
- package/dist/client/aparte-client.d.ts.map +1 -1
- package/dist/components/bubble/aparte-chat-bubble.d.ts +25 -0
- package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -1
- package/dist/components/bubble/bubble-sync.d.ts +2 -1
- package/dist/components/bubble/bubble-sync.d.ts.map +1 -1
- package/dist/components/bubble/feedback-reasons.d.ts +13 -0
- package/dist/components/bubble/feedback-reasons.d.ts.map +1 -0
- package/dist/components/bubble/message-tokens.d.ts +10 -0
- package/dist/components/bubble/message-tokens.d.ts.map +1 -0
- package/dist/components/bubble/turn-groups.d.ts +24 -0
- package/dist/components/bubble/turn-groups.d.ts.map +1 -0
- package/dist/components/composer/aparte-composer-attachments.d.ts +3 -0
- package/dist/components/composer/aparte-composer-attachments.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-input.d.ts +29 -0
- package/dist/components/composer/aparte-composer-input.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer-toolbar.d.ts +4 -0
- package/dist/components/composer/aparte-composer-toolbar.d.ts.map +1 -1
- package/dist/components/composer/aparte-composer.d.ts +15 -3
- package/dist/components/composer/aparte-composer.d.ts.map +1 -1
- package/dist/components/composer/composer-tokens.d.ts +21 -0
- package/dist/components/composer/composer-tokens.d.ts.map +1 -0
- package/dist/components/conversation-list/aparte-conversation-list.d.ts.map +1 -1
- package/dist/components/viewport/aparte-chat-viewport.d.ts +2 -0
- package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -1
- package/dist/config/aparte-config.d.ts +24 -1
- package/dist/config/aparte-config.d.ts.map +1 -1
- package/dist/config/locale.d.ts +44 -0
- package/dist/config/locale.d.ts.map +1 -1
- package/dist/conversations/conversation-controller.d.ts +19 -0
- package/dist/conversations/conversation-controller.d.ts.map +1 -1
- package/dist/conversations/conversation-manager.d.ts +2 -0
- package/dist/conversations/conversation-manager.d.ts.map +1 -1
- package/dist/conversations/types.d.ts +4 -0
- package/dist/conversations/types.d.ts.map +1 -1
- package/dist/custom-elements.json +1545 -6
- package/dist/{defer-hydration-_SZv5PeY.js → defer-hydration-BBdqAZej.js} +252 -61
- package/dist/defer-hydration-BBdqAZej.js.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +605 -94
- package/dist/index.js.map +1 -1
- package/dist/index.node.d.ts +3 -1
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +21 -20
- package/dist/index.node.js.map +1 -1
- package/dist/interop/element-props.d.ts +1 -1
- package/dist/interop/element-props.d.ts.map +1 -1
- package/dist/types/chat.d.ts +3 -0
- package/dist/types/chat.d.ts.map +1 -1
- package/dist/types/event-map.d.ts +4 -1
- package/dist/types/event-map.d.ts.map +1 -1
- package/dist/types/events.d.ts +93 -1
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/model-provider.d.ts +6 -0
- package/dist/types/model-provider.d.ts.map +1 -1
- package/dist/types/models.d.ts +44 -0
- package/dist/types/models.d.ts.map +1 -1
- package/dist/utils/place-floating.d.ts +20 -0
- package/dist/utils/place-floating.d.ts.map +1 -0
- package/dist/utils/plural.d.ts +7 -0
- package/dist/utils/plural.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/defer-hydration-_SZv5PeY.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { K as deferHydrationOf,
|
|
2
|
-
import { A, a, b, c, d, f, h, i, j, k, l, m, n, p, s, S, u, v, y, z, B, D, E, F, G, I, J, L, M, N, Q, R, T, U, W, _, a2, a3,
|
|
1
|
+
import { K as deferHydrationOf, ae as resolveConfig, ap as eventOrigin, aq as activeElementIn, ak as subscribeConfigChange, ag as runWithConfig, o as AparteElicitationAbortError, w as buildApprovalPanel, x as buildElicitationPanel, ar as gateGlide, O as escapeAttr, H as cssEscape, ai as segmentTiming, as as chatBoundaryOf, at as relabelCodeLanguages, au as relabelCitations, av as toolCallRenderer, aw as toolRendererThatDrew, t as aparteGlobalConfig, ax as isMountedRenderer, ay as renderingVersionOf, az as onRenderersChange, aA as renderSourceList, aB as mergeSegmentUpdate, a0 as isSegmentSettled, aC as formatDuration, P as escapeHtml, aD as writeStreamedMarkdown, aE as replaceHighlighted, $ as isSafeUrl, C as copyText, V as getSegmentRenderer, X as installDefaultRenderersOnce, r as AparteMessageRepository, aF as CheckpointStateWatcher, aG as chatIdOf, aH as stampSegmentActivity, aI as stampSegmentOnInsert, aJ as stampSegmentOnUpdate, aK as renumberSegments, aL as openSegmentIds, aM as isTerminalStatus, aN as adoptMessageSegments, Z as isAwaitingReply, a6 as populateBubbleFromMessage, ao as uuid, af as revokeAttachmentUrls, a4 as parseMarkdownToSegments, aO as APARTE_DERIVED_SEGMENTS, aP as rememberConversationStatus, aQ as tellConversationStatus, aR as conversationStatusOf, e as APARTE_DEFAULT_LOCALE, a5 as placeFloating, aS as visibleReply, aT as usageTokens, q as AparteErrorCode, a1 as measureContext, aU as rootOf, aV as inRenderedContent, g as APARTE_HOST_ATTR, Y as installDialogTriggersOnce } from "./defer-hydration-BBdqAZej.js";
|
|
2
|
+
import { A, a, b, c, d, f, h, i, j, k, l, m, n, p, s, S, u, v, y, z, B, D, E, F, G, I, J, L, M, N, Q, R, T, U, W, _, a2, a3, a7, a8, a9, aa, ab, ac, ad, ah, aj, al, am, an } from "./defer-hydration-BBdqAZej.js";
|
|
3
3
|
function presenceOn(value) {
|
|
4
4
|
return value === "" ? true : Boolean(value);
|
|
5
5
|
}
|
|
@@ -1307,6 +1307,112 @@ deferHydrationOf(AparteChat);
|
|
|
1307
1307
|
if (!customElements.get("aparte-chat")) {
|
|
1308
1308
|
customElements.define("aparte-chat", AparteChat);
|
|
1309
1309
|
}
|
|
1310
|
+
function pluralize(forms, n2, tag) {
|
|
1311
|
+
let category = "other";
|
|
1312
|
+
try {
|
|
1313
|
+
category = new Intl.PluralRules(tag).select(n2);
|
|
1314
|
+
} catch {
|
|
1315
|
+
}
|
|
1316
|
+
const options = forms.split("|");
|
|
1317
|
+
const named = (name) => options.find((form2) => form2.startsWith(`${name}:`));
|
|
1318
|
+
const form = named(category) ?? named("other") ?? forms;
|
|
1319
|
+
return form.slice(form.indexOf(":") + 1).replace("{n}", String(n2));
|
|
1320
|
+
}
|
|
1321
|
+
function planTurns(items, roleOf) {
|
|
1322
|
+
const runs = [];
|
|
1323
|
+
let from = -1;
|
|
1324
|
+
let last = -1;
|
|
1325
|
+
let members = 0;
|
|
1326
|
+
const close = () => {
|
|
1327
|
+
if (members >= 2) runs.push({ from, to: last });
|
|
1328
|
+
from = -1;
|
|
1329
|
+
last = -1;
|
|
1330
|
+
members = 0;
|
|
1331
|
+
};
|
|
1332
|
+
items.forEach((item, index) => {
|
|
1333
|
+
const role = roleOf(item);
|
|
1334
|
+
if (role === "stop") {
|
|
1335
|
+
close();
|
|
1336
|
+
} else if (role === "fold") {
|
|
1337
|
+
if (from < 0) from = index;
|
|
1338
|
+
last = index;
|
|
1339
|
+
members += 1;
|
|
1340
|
+
}
|
|
1341
|
+
});
|
|
1342
|
+
close();
|
|
1343
|
+
return runs;
|
|
1344
|
+
}
|
|
1345
|
+
function rowOf(container, segmentId) {
|
|
1346
|
+
const id = `[data-segment-id="${cssEscape(segmentId)}"]`;
|
|
1347
|
+
return container.querySelector(`:scope > ${id}, :scope > .aparte-turn > .aparte-turn__body > ${id}`);
|
|
1348
|
+
}
|
|
1349
|
+
function turnDuration(members) {
|
|
1350
|
+
let start = Infinity;
|
|
1351
|
+
let end = -Infinity;
|
|
1352
|
+
for (const member of members) {
|
|
1353
|
+
const { startedAt, endedAt } = segmentTiming(member) ?? {};
|
|
1354
|
+
if (startedAt == null || endedAt == null) return void 0;
|
|
1355
|
+
start = Math.min(start, startedAt);
|
|
1356
|
+
end = Math.max(end, endedAt);
|
|
1357
|
+
}
|
|
1358
|
+
return members.length > 0 ? end - start : void 0;
|
|
1359
|
+
}
|
|
1360
|
+
const count = (haystack, needle) => needle ? haystack.split(needle).length - 1 : 0;
|
|
1361
|
+
function pill(doc, token) {
|
|
1362
|
+
const el2 = doc.createElement("span");
|
|
1363
|
+
el2.className = "aparte-tag aparte-inline-token";
|
|
1364
|
+
if (token.kind) el2.dataset["kind"] = token.kind;
|
|
1365
|
+
const label = doc.createElement("span");
|
|
1366
|
+
label.className = "aparte-tag__label";
|
|
1367
|
+
label.textContent = token.label;
|
|
1368
|
+
el2.appendChild(label);
|
|
1369
|
+
return el2;
|
|
1370
|
+
}
|
|
1371
|
+
function draw(root, content, token) {
|
|
1372
|
+
let skip = count(content.slice(0, token.start), token.text);
|
|
1373
|
+
const doc = root.ownerDocument;
|
|
1374
|
+
const walker = doc.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
1375
|
+
while (walker.nextNode()) {
|
|
1376
|
+
const node = walker.currentNode;
|
|
1377
|
+
for (let at = node.data.indexOf(token.text); at >= 0; at = node.data.indexOf(token.text, at + token.text.length)) {
|
|
1378
|
+
if (skip-- > 0) continue;
|
|
1379
|
+
const range = doc.createRange();
|
|
1380
|
+
range.setStart(node, at);
|
|
1381
|
+
range.setEnd(node, at + token.text.length);
|
|
1382
|
+
range.deleteContents();
|
|
1383
|
+
range.insertNode(pill(doc, token));
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
function drawMessageTokens(root, content, tokens) {
|
|
1389
|
+
if (root.querySelector(".aparte-inline-token")) return;
|
|
1390
|
+
for (const token of [...tokens].sort((a4, b2) => b2.start - a4.start)) {
|
|
1391
|
+
if (token.text) draw(root, content, token);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
function button(label, className, onClick2) {
|
|
1395
|
+
const el2 = document.createElement("button");
|
|
1396
|
+
el2.type = "button";
|
|
1397
|
+
el2.className = `aparte-btn aparte-btn--sm ${className}`;
|
|
1398
|
+
el2.textContent = label;
|
|
1399
|
+
el2.addEventListener("click", onClick2);
|
|
1400
|
+
return el2;
|
|
1401
|
+
}
|
|
1402
|
+
function buildFeedbackReasons(options) {
|
|
1403
|
+
const root = document.createElement("div");
|
|
1404
|
+
root.className = "aparte-feedback-reasons";
|
|
1405
|
+
root.setAttribute("role", "group");
|
|
1406
|
+
root.setAttribute("aria-label", options.title);
|
|
1407
|
+
const title = document.createElement("span");
|
|
1408
|
+
title.textContent = options.title;
|
|
1409
|
+
root.appendChild(title);
|
|
1410
|
+
for (const reason of options.reasons) {
|
|
1411
|
+
root.appendChild(button(reason, "aparte-btn--surface", () => options.onPick(reason)));
|
|
1412
|
+
}
|
|
1413
|
+
root.appendChild(button(options.dismiss, "aparte-btn--ghost", options.onClose));
|
|
1414
|
+
return root;
|
|
1415
|
+
}
|
|
1310
1416
|
const isStore = (candidate) => !!candidate && typeof candidate.getMessages === "function" && typeof candidate.updateMessage === "function";
|
|
1311
1417
|
function storeOf(from) {
|
|
1312
1418
|
const boundary = chatBoundaryOf(from);
|
|
@@ -1332,10 +1438,10 @@ function el$1(tag, className, text) {
|
|
|
1332
1438
|
return node;
|
|
1333
1439
|
}
|
|
1334
1440
|
function action(name, label) {
|
|
1335
|
-
const
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
return
|
|
1441
|
+
const button2 = el$1("button", "aparte-btn aparte-btn--ghost aparte-btn--sm aparte-checkpoint__action", label);
|
|
1442
|
+
button2.type = "button";
|
|
1443
|
+
button2.setAttribute("data-checkpoint-action", name);
|
|
1444
|
+
return button2;
|
|
1339
1445
|
}
|
|
1340
1446
|
function buildCheckpointSeparator(options) {
|
|
1341
1447
|
const { kind, locale } = options;
|
|
@@ -1448,6 +1554,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1448
1554
|
_branchPickerEl = null;
|
|
1449
1555
|
_footerEl = null;
|
|
1450
1556
|
_content = "";
|
|
1557
|
+
_tokens;
|
|
1451
1558
|
_streaming = false;
|
|
1452
1559
|
_segments = [];
|
|
1453
1560
|
_role = "assistant";
|
|
@@ -1669,6 +1776,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1669
1776
|
if (!drawn || this._stillDrawnByCurrent(segment, drawn)) continue;
|
|
1670
1777
|
this._redrawSegment(segment);
|
|
1671
1778
|
}
|
|
1779
|
+
this._syncTurns();
|
|
1672
1780
|
}
|
|
1673
1781
|
/**
|
|
1674
1782
|
* The registries' channel: a renderer changed on our config — or on the global one, whose
|
|
@@ -1712,6 +1820,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1712
1820
|
if (this._keepsItsDrawing(segment, drawn)) continue;
|
|
1713
1821
|
this._redrawSegment(segment);
|
|
1714
1822
|
}
|
|
1823
|
+
this._syncTurns();
|
|
1715
1824
|
this._reflectError();
|
|
1716
1825
|
this._syncCopyAction();
|
|
1717
1826
|
}
|
|
@@ -1736,12 +1845,11 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1736
1845
|
for (const segment of this._segments) {
|
|
1737
1846
|
const renderer = resolveSegmentRenderer(segment.type, this._cfg);
|
|
1738
1847
|
if (!renderer?.relabel) continue;
|
|
1739
|
-
const el2 = this._segmentsEl.
|
|
1740
|
-
`:scope > [data-segment-id="${cssEscape(segment.id)}"]`
|
|
1741
|
-
);
|
|
1848
|
+
const el2 = rowOf(this._segmentsEl, segment.id);
|
|
1742
1849
|
if (!el2) continue;
|
|
1743
1850
|
runWithConfig(this._cfg, () => renderer.relabel(el2, segment));
|
|
1744
1851
|
}
|
|
1852
|
+
this._syncTurns();
|
|
1745
1853
|
}
|
|
1746
1854
|
/**
|
|
1747
1855
|
* Re-apply the locale strings written straight into the markup by `_render()` —
|
|
@@ -1879,6 +1987,36 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1879
1987
|
this._updateContent();
|
|
1880
1988
|
this._syncCopyAction();
|
|
1881
1989
|
}
|
|
1990
|
+
/** The row under the action bar that asks why, when the app listed reasons. */
|
|
1991
|
+
_askFeedbackReason(messageId) {
|
|
1992
|
+
const reasons = this._cfg.getBubbleActions().feedbackReasons;
|
|
1993
|
+
if (!reasons?.length || this.querySelector(".aparte-feedback-reasons")) return;
|
|
1994
|
+
const panel = buildFeedbackReasons({
|
|
1995
|
+
reasons,
|
|
1996
|
+
title: this._cfg.t("feedbackReasonTitle"),
|
|
1997
|
+
dismiss: this._cfg.t("feedbackReasonDismiss"),
|
|
1998
|
+
onPick: (reason) => {
|
|
1999
|
+
panel.remove();
|
|
2000
|
+
this.dispatchEvent(new CustomEvent("aparte-feedback-reason", {
|
|
2001
|
+
bubbles: true,
|
|
2002
|
+
composed: true,
|
|
2003
|
+
detail: { messageId, reason }
|
|
2004
|
+
}));
|
|
2005
|
+
},
|
|
2006
|
+
onClose: () => panel.remove()
|
|
2007
|
+
});
|
|
2008
|
+
this.querySelector(".aparte-footer")?.after(panel);
|
|
2009
|
+
}
|
|
2010
|
+
/** The tokens a user message was written with, drawn as they looked in the composer. */
|
|
2011
|
+
setTokens(tokens) {
|
|
2012
|
+
this._tokens = tokens;
|
|
2013
|
+
this._drawTokens();
|
|
2014
|
+
}
|
|
2015
|
+
_drawTokens() {
|
|
2016
|
+
if (this._contentEl && this._role === "user" && this._tokens?.length) {
|
|
2017
|
+
drawMessageTokens(this._contentEl, this._content, this._tokens);
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
1882
2020
|
/** Set content directly */
|
|
1883
2021
|
setContent(content) {
|
|
1884
2022
|
this._content = content;
|
|
@@ -1944,6 +2082,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1944
2082
|
if (kept.has(segment.id)) this._applySegmentUpdate(segment.id, segment, segment);
|
|
1945
2083
|
else this._redrawSegment(segment);
|
|
1946
2084
|
}
|
|
2085
|
+
this._syncTurns();
|
|
1947
2086
|
this._reflectError();
|
|
1948
2087
|
this._syncCopyAction();
|
|
1949
2088
|
return true;
|
|
@@ -1952,6 +2091,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1952
2091
|
addSegment(segment) {
|
|
1953
2092
|
this._segments.push(segment);
|
|
1954
2093
|
this._appendSegmentEl(segment);
|
|
2094
|
+
this._syncTurns();
|
|
1955
2095
|
if (segment.type === "text" && segment.sources) this._syncSources();
|
|
1956
2096
|
this._updateWaiting();
|
|
1957
2097
|
}
|
|
@@ -1966,7 +2106,10 @@ class AparteChatBubble extends HTMLElement {
|
|
|
1966
2106
|
this._applySegmentUpdate(segmentId, updated, updates);
|
|
1967
2107
|
if ("sources" in updates) this._syncSources();
|
|
1968
2108
|
this._syncCopyAction();
|
|
1969
|
-
if ("status" in updates || "isStreaming" in updates)
|
|
2109
|
+
if ("status" in updates || "isStreaming" in updates) {
|
|
2110
|
+
this._syncTurns();
|
|
2111
|
+
this._updateWaiting();
|
|
2112
|
+
}
|
|
1970
2113
|
}
|
|
1971
2114
|
}
|
|
1972
2115
|
/** Append content to a segment */
|
|
@@ -2024,8 +2167,9 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2024
2167
|
this._segments.splice(index, 1);
|
|
2025
2168
|
}
|
|
2026
2169
|
this._release(segmentId);
|
|
2027
|
-
const el2 = this._segmentsEl
|
|
2170
|
+
const el2 = this._segmentsEl ? rowOf(this._segmentsEl, segmentId) : null;
|
|
2028
2171
|
el2?.remove();
|
|
2172
|
+
this._syncTurns();
|
|
2029
2173
|
this._syncSources();
|
|
2030
2174
|
this._updateWaiting();
|
|
2031
2175
|
this._syncCopyAction();
|
|
@@ -2087,8 +2231,8 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2087
2231
|
* Prev/Next clicks dispatch `aparte-branch-navigate` (bubbles: true) so
|
|
2088
2232
|
* the viewport can handle the actual tree switch.
|
|
2089
2233
|
*/
|
|
2090
|
-
setSiblings(
|
|
2091
|
-
this._siblingCount =
|
|
2234
|
+
setSiblings(count2, index) {
|
|
2235
|
+
this._siblingCount = count2;
|
|
2092
2236
|
this._siblingIndex = index;
|
|
2093
2237
|
this._updateBranchPicker();
|
|
2094
2238
|
}
|
|
@@ -2100,6 +2244,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2100
2244
|
this._role = updates.role;
|
|
2101
2245
|
this._updateRole();
|
|
2102
2246
|
}
|
|
2247
|
+
if ("tokens" in updates) this._tokens = updates.tokens;
|
|
2103
2248
|
if ("content" in updates) {
|
|
2104
2249
|
this._content = updates.content;
|
|
2105
2250
|
this._updateContent();
|
|
@@ -2239,11 +2384,11 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2239
2384
|
* be lost with it.
|
|
2240
2385
|
*/
|
|
2241
2386
|
_onCheckpointClick = (event) => {
|
|
2242
|
-
const
|
|
2243
|
-
const separator =
|
|
2244
|
-
if (!
|
|
2245
|
-
if (
|
|
2246
|
-
switch (
|
|
2387
|
+
const button2 = event.target?.closest?.("[data-checkpoint-action]");
|
|
2388
|
+
const separator = button2?.closest(".aparte-checkpoint");
|
|
2389
|
+
if (!button2 || !separator || separator.parentElement !== this) return;
|
|
2390
|
+
if (button2.closest(".aparte-checkpoint__summary")) return;
|
|
2391
|
+
switch (button2.getAttribute("data-checkpoint-action")) {
|
|
2247
2392
|
case "toggle":
|
|
2248
2393
|
this._checkpointOpen = !this._checkpointOpen;
|
|
2249
2394
|
this._updateCheckpoint("toggle");
|
|
@@ -2309,8 +2454,124 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2309
2454
|
if (this._contentEl) this._contentEl.style.display = "none";
|
|
2310
2455
|
this._reflectError();
|
|
2311
2456
|
}
|
|
2457
|
+
/** Whether a segment joins a turn's fold, is passed over by it, or ends it. */
|
|
2458
|
+
_turnRole(segment) {
|
|
2459
|
+
if (segment.type === "thinking") return "fold";
|
|
2460
|
+
if (segment.type !== "tool_call") return "stop";
|
|
2461
|
+
const call = segment;
|
|
2462
|
+
if (this._cfg.isToolHidden(call.toolCall?.name ?? "")) return "skip";
|
|
2463
|
+
if (call.status === "awaiting-approval" || call.status === "failed") return "stop";
|
|
2464
|
+
return this._toolRendererFor(segment) ? "stop" : "fold";
|
|
2465
|
+
}
|
|
2466
|
+
/** The fold a drawn row sits in, or null when it is a direct child. */
|
|
2467
|
+
_turnHolding(row) {
|
|
2468
|
+
const turn = row?.parentElement?.parentElement;
|
|
2469
|
+
return turn?.classList.contains("aparte-turn") && turn.parentElement === this._segmentsEl ? turn : null;
|
|
2470
|
+
}
|
|
2471
|
+
_createTurn() {
|
|
2472
|
+
const turn = document.createElement("details");
|
|
2473
|
+
turn.className = "aparte-turn aparte-accordion__item";
|
|
2474
|
+
const summary = document.createElement("summary");
|
|
2475
|
+
summary.className = "aparte-accordion__header aparte-turn__summary";
|
|
2476
|
+
const label = document.createElement("span");
|
|
2477
|
+
label.className = "aparte-turn__label";
|
|
2478
|
+
const current = document.createElement("span");
|
|
2479
|
+
current.className = "aparte-turn__current";
|
|
2480
|
+
const icon = document.createElement("span");
|
|
2481
|
+
icon.className = "aparte-accordion__icon";
|
|
2482
|
+
icon.innerHTML = this._cfg.getIcon("expand");
|
|
2483
|
+
summary.append(label, current, icon);
|
|
2484
|
+
summary.addEventListener("click", () => {
|
|
2485
|
+
turn.dataset["touched"] = "";
|
|
2486
|
+
});
|
|
2487
|
+
const body = document.createElement("div");
|
|
2488
|
+
body.className = "aparte-accordion__panel aparte-turn__body";
|
|
2489
|
+
turn.append(summary, body);
|
|
2490
|
+
return turn;
|
|
2491
|
+
}
|
|
2492
|
+
/**
|
|
2493
|
+
* Fold each run of steps behind its line, by moving the rows already drawn: a moved
|
|
2494
|
+
* `<details>` keeps its open state, a redraw would lose it. Called whenever the plan can
|
|
2495
|
+
* change, never per token. A fold is found again by its members, not by its place, so one
|
|
2496
|
+
* that grows or splits keeps its own open state.
|
|
2497
|
+
*/
|
|
2498
|
+
_syncTurns() {
|
|
2499
|
+
const container = this._segmentsEl;
|
|
2500
|
+
if (!container || this._releasedWhileDetached) return;
|
|
2501
|
+
const options = this._cfg.getTurnSummary();
|
|
2502
|
+
const runs = options ? planTurns(this._segments, (segment) => this._turnRole(segment)) : [];
|
|
2503
|
+
if (runs.length === 0 && !container.querySelector(":scope > .aparte-turn")) return;
|
|
2504
|
+
const place = (parent, node, after) => {
|
|
2505
|
+
const expected = after ? after.nextSibling : parent.firstChild;
|
|
2506
|
+
if (node !== expected) parent.insertBefore(node, expected);
|
|
2507
|
+
return node;
|
|
2508
|
+
};
|
|
2509
|
+
const rowFor = (segment) => this._drawn.get(segment.id)?.el;
|
|
2510
|
+
const used = /* @__PURE__ */ new Set();
|
|
2511
|
+
const startsAt = new Map(runs.map((run) => [run.from, run]));
|
|
2512
|
+
let lastPlaced = null;
|
|
2513
|
+
for (let index = 0; index < this._segments.length; index += 1) {
|
|
2514
|
+
const run = startsAt.get(index);
|
|
2515
|
+
if (!run) {
|
|
2516
|
+
const row = rowFor(this._segments[index]);
|
|
2517
|
+
if (row) lastPlaced = place(container, row, lastPlaced);
|
|
2518
|
+
continue;
|
|
2519
|
+
}
|
|
2520
|
+
const members = this._segments.slice(run.from, run.to + 1);
|
|
2521
|
+
const existing = members.map((member) => this._turnHolding(rowFor(member))).find((held) => held && !used.has(held));
|
|
2522
|
+
const turn = existing ?? this._createTurn();
|
|
2523
|
+
used.add(turn);
|
|
2524
|
+
lastPlaced = place(container, turn, lastPlaced);
|
|
2525
|
+
const body = turn.querySelector(":scope > .aparte-turn__body");
|
|
2526
|
+
let lastInBody = null;
|
|
2527
|
+
for (const member of members) {
|
|
2528
|
+
const row = rowFor(member);
|
|
2529
|
+
if (row) lastInBody = place(body, row, lastInBody);
|
|
2530
|
+
}
|
|
2531
|
+
this._labelTurn(turn, members, run.to === this._segments.length - 1, options?.openWhileRunning === true);
|
|
2532
|
+
index = run.to;
|
|
2533
|
+
}
|
|
2534
|
+
for (const stale of container.querySelectorAll(":scope > .aparte-turn")) {
|
|
2535
|
+
if (!used.has(stale)) stale.remove();
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
/** The fold's one line: what it is doing while it works, what it did once it has. */
|
|
2539
|
+
_labelTurn(turn, members, trailing, openWhileRunning) {
|
|
2540
|
+
const cfg = this._cfg;
|
|
2541
|
+
const steps = members.filter((member) => this._turnRole(member) === "fold");
|
|
2542
|
+
const calls = steps.filter((step) => step.type === "tool_call");
|
|
2543
|
+
const running = this._streaming && trailing || calls.some((call) => !isSegmentSettled(call));
|
|
2544
|
+
const label = turn.querySelector(":scope > summary > .aparte-turn__label");
|
|
2545
|
+
const current = turn.querySelector(":scope > summary > .aparte-turn__current");
|
|
2546
|
+
label.classList.toggle("aparte-shimmer", running);
|
|
2547
|
+
label.textContent = running ? cfg.t("turnWorking") : this._turnOutcome(steps, calls.length);
|
|
2548
|
+
current.textContent = running && calls.length > 0 ? this._stepName(calls.at(-1)) : "";
|
|
2549
|
+
if (openWhileRunning && !("touched" in turn.dataset)) turn.open = running;
|
|
2550
|
+
}
|
|
2551
|
+
_turnOutcome(steps, callCount) {
|
|
2552
|
+
const cfg = this._cfg;
|
|
2553
|
+
const tag = cfg.getLocale().tag || void 0;
|
|
2554
|
+
const tools = callCount > 0 ? pluralize(cfg.t("turnTools"), callCount, tag) : "";
|
|
2555
|
+
const ms = turnDuration(steps);
|
|
2556
|
+
if (ms !== void 0) {
|
|
2557
|
+
const worked = cfg.t("turnWorked").replace("{duration}", () => formatDuration(ms, tag));
|
|
2558
|
+
return tools ? `${worked} · ${tools}` : worked;
|
|
2559
|
+
}
|
|
2560
|
+
return tools ? cfg.t("turnUsed").replace("{tools}", () => tools) : cfg.t("thought");
|
|
2561
|
+
}
|
|
2562
|
+
/** What a call goes by on screen: the label the app gave it, else its identifier. */
|
|
2563
|
+
_stepName(call) {
|
|
2564
|
+
const name = call.toolCall?.name ?? "";
|
|
2565
|
+
const label = this._cfg.getToolDisplay(name)?.label;
|
|
2566
|
+
if (typeof label !== "function") return label ?? name;
|
|
2567
|
+
try {
|
|
2568
|
+
return label(call);
|
|
2569
|
+
} catch {
|
|
2570
|
+
return name;
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2312
2573
|
_applySegmentUpdate(segmentId, segment, updates) {
|
|
2313
|
-
const el2 = this._segmentsEl
|
|
2574
|
+
const el2 = this._segmentsEl ? rowOf(this._segmentsEl, segmentId) : null;
|
|
2314
2575
|
if (!el2) {
|
|
2315
2576
|
this._renderSegments();
|
|
2316
2577
|
return;
|
|
@@ -2329,7 +2590,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2329
2590
|
const drawn = this._drawn.get(segmentId);
|
|
2330
2591
|
if (drawn) {
|
|
2331
2592
|
drawn.segment = segment;
|
|
2332
|
-
const now = this._segmentsEl
|
|
2593
|
+
const now = this._segmentsEl ? rowOf(this._segmentsEl, segmentId) : null;
|
|
2333
2594
|
if (now && now !== drawn.el) {
|
|
2334
2595
|
drawn.el = now;
|
|
2335
2596
|
drawn.tool = segment.type === "tool_call" ? toolRendererThatDrew(now) : null;
|
|
@@ -2482,7 +2743,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2482
2743
|
const last = this._segments.at(-1);
|
|
2483
2744
|
const lastEl = this._segmentsEl?.lastElementChild;
|
|
2484
2745
|
const asking = last?.type === "tool_call" && last.status === "awaiting-approval";
|
|
2485
|
-
const betweenSteps = last?.type === "tool_call" && (isSegmentSettled(last) || lastEl?.hidden === true);
|
|
2746
|
+
const betweenSteps = last?.type === "tool_call" && (isSegmentSettled(last) || lastEl?.hidden === true) && lastEl?.classList.contains("aparte-turn") !== true;
|
|
2486
2747
|
const waiting = this._streaming && this._role !== "user" && !asking && (empty || betweenSteps);
|
|
2487
2748
|
const box = this.querySelector(".aparte-message-content");
|
|
2488
2749
|
if (box) box.hidden = empty && !waiting;
|
|
@@ -2589,6 +2850,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2589
2850
|
this._cfg,
|
|
2590
2851
|
() => writeStreamedMarkdown(this, this._contentEl, this._content, this._streaming)
|
|
2591
2852
|
);
|
|
2853
|
+
this._drawTokens();
|
|
2592
2854
|
this._updateWaiting();
|
|
2593
2855
|
if (!this._streaming) this._highlightContentCode();
|
|
2594
2856
|
}
|
|
@@ -2642,6 +2904,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2642
2904
|
this._install(segment, el2, void 0);
|
|
2643
2905
|
}
|
|
2644
2906
|
}
|
|
2907
|
+
this._syncTurns();
|
|
2645
2908
|
if (this._contentEl) {
|
|
2646
2909
|
this._contentEl.style.display = this._segments.length > 0 ? "none" : "";
|
|
2647
2910
|
}
|
|
@@ -2782,9 +3045,9 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2782
3045
|
*/
|
|
2783
3046
|
_onBranchPickerClick = (event) => {
|
|
2784
3047
|
const target = event.target;
|
|
2785
|
-
const
|
|
2786
|
-
if (!
|
|
2787
|
-
const direction =
|
|
3048
|
+
const button2 = target?.closest?.(".aparte-branch-prev, .aparte-branch-next");
|
|
3049
|
+
if (!button2 || !this.contains(button2)) return;
|
|
3050
|
+
const direction = button2.classList.contains("aparte-branch-prev") ? "prev" : "next";
|
|
2788
3051
|
const messageId = this.getAttribute("message-id");
|
|
2789
3052
|
if (!messageId) return;
|
|
2790
3053
|
const detail = { messageId, direction };
|
|
@@ -2960,7 +3223,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2960
3223
|
const usable = buttons.filter((b2) => !b2.disabled);
|
|
2961
3224
|
const current = buttons.find((b2) => b2.tabIndex === 0 && !b2.disabled);
|
|
2962
3225
|
const stop = current ?? usable[0] ?? buttons[0];
|
|
2963
|
-
for (const
|
|
3226
|
+
for (const button2 of buttons) button2.tabIndex = button2 === stop ? 0 : -1;
|
|
2964
3227
|
}
|
|
2965
3228
|
/**
|
|
2966
3229
|
* Left/Right walk the bar, Home/End jump to its ends, and both wrap.
|
|
@@ -2987,7 +3250,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
2987
3250
|
else if (event.key === forward) next = (from + 1) % buttons.length;
|
|
2988
3251
|
else next = (from - 1 + buttons.length) % buttons.length;
|
|
2989
3252
|
event.preventDefault();
|
|
2990
|
-
for (const
|
|
3253
|
+
for (const button2 of this._rovingButtons()) button2.tabIndex = button2 === buttons[next] ? 0 : -1;
|
|
2991
3254
|
buttons[next]?.focus();
|
|
2992
3255
|
};
|
|
2993
3256
|
/**
|
|
@@ -3144,6 +3407,8 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3144
3407
|
composed: true,
|
|
3145
3408
|
detail
|
|
3146
3409
|
}));
|
|
3410
|
+
if (value === "negative") this._askFeedbackReason(messageId);
|
|
3411
|
+
else this.querySelector(".aparte-feedback-reasons")?.remove();
|
|
3147
3412
|
break;
|
|
3148
3413
|
}
|
|
3149
3414
|
case "info": {
|
|
@@ -3216,7 +3481,7 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3216
3481
|
const back = Array.from(this._actionBarEl.querySelectorAll("[data-action]")).find((btn) => btn.getAttribute("data-action") === returnTo);
|
|
3217
3482
|
const target = back && !back.disabled ? back : this._actionBarEl.querySelector("button:not([disabled])");
|
|
3218
3483
|
if (target) {
|
|
3219
|
-
for (const
|
|
3484
|
+
for (const button2 of this._rovingButtons()) button2.tabIndex = button2 === target ? 0 : -1;
|
|
3220
3485
|
target.focus();
|
|
3221
3486
|
}
|
|
3222
3487
|
}
|
|
@@ -3262,12 +3527,14 @@ class AparteChatBubble extends HTMLElement {
|
|
|
3262
3527
|
message.removeAttribute("aria-busy");
|
|
3263
3528
|
message.classList.remove("aparte-message-streaming");
|
|
3264
3529
|
}
|
|
3530
|
+
message.toggleAttribute("data-caret", streaming && this._cfg.getStreamingCaret());
|
|
3265
3531
|
}
|
|
3266
3532
|
this._updateWaiting();
|
|
3267
3533
|
this._updateFinishNote();
|
|
3268
3534
|
if (wasStreaming && !streaming) this._updateContent();
|
|
3269
3535
|
if (wasStreaming && !streaming) this._settleWrittenSegments();
|
|
3270
3536
|
if (wasStreaming && !streaming && this._segments.length > 0) this._redrawIfStale();
|
|
3537
|
+
this._syncTurns();
|
|
3271
3538
|
}
|
|
3272
3539
|
}
|
|
3273
3540
|
deferHydrationOf(AparteChatBubble);
|
|
@@ -3462,6 +3729,13 @@ function markDerivedSegments(message) {
|
|
|
3462
3729
|
function hasDerivedSegments(message) {
|
|
3463
3730
|
return message[APARTE_DERIVED_SEGMENTS] === true;
|
|
3464
3731
|
}
|
|
3732
|
+
function longDate(at, tag) {
|
|
3733
|
+
try {
|
|
3734
|
+
return new Intl.DateTimeFormat(tag || void 0, { dateStyle: "long" }).format(at);
|
|
3735
|
+
} catch {
|
|
3736
|
+
return at.toDateString();
|
|
3737
|
+
}
|
|
3738
|
+
}
|
|
3465
3739
|
class AparteChatViewport extends HTMLElement {
|
|
3466
3740
|
// The scroll surface: an internal `.aparte-viewport-container` div (core mode)
|
|
3467
3741
|
// or the host element itself (framework-managed mode). HTMLElement covers both.
|
|
@@ -3663,6 +3937,7 @@ class AparteChatViewport extends HTMLElement {
|
|
|
3663
3937
|
this._scrollBtn?.setAttribute("aria-label", resolveConfig(this).t("scrollToBottom"));
|
|
3664
3938
|
const surface = this._frameworkManagedDOM ? this : this.querySelector(".aparte-viewport-container");
|
|
3665
3939
|
surface?.setAttribute("aria-label", resolveConfig(this).t("transcript"));
|
|
3940
|
+
this._syncDateSeparators();
|
|
3666
3941
|
};
|
|
3667
3942
|
/**
|
|
3668
3943
|
* The transcript is a TAB STOP, with a name.
|
|
@@ -4373,6 +4648,30 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4373
4648
|
break;
|
|
4374
4649
|
}
|
|
4375
4650
|
}
|
|
4651
|
+
/** The day on the first bubble of each one, by what is on screen: a branch has its own days. */
|
|
4652
|
+
_syncDateSeparators() {
|
|
4653
|
+
const cfg = resolveConfig(this);
|
|
4654
|
+
const on = cfg.getDateSeparators();
|
|
4655
|
+
if (!on && !this.querySelector("aparte-chat-bubble[data-date]")) return;
|
|
4656
|
+
const now = /* @__PURE__ */ new Date();
|
|
4657
|
+
const dayOf = (at) => new Date(at.getFullYear(), at.getMonth(), at.getDate()).getTime();
|
|
4658
|
+
const today = dayOf(now);
|
|
4659
|
+
let previous = null;
|
|
4660
|
+
this.querySelectorAll("aparte-chat-bubble").forEach((bubble) => {
|
|
4661
|
+
const raw = Number(bubble.getAttribute("timestamp"));
|
|
4662
|
+
const at = raw ? new Date(raw) : null;
|
|
4663
|
+
const day = at ? dayOf(at) : null;
|
|
4664
|
+
const starts = on && at && day !== previous;
|
|
4665
|
+
if (day !== null) previous = day;
|
|
4666
|
+
if (!starts || !at) {
|
|
4667
|
+
if (bubble.hasAttribute("data-date")) bubble.removeAttribute("data-date");
|
|
4668
|
+
return;
|
|
4669
|
+
}
|
|
4670
|
+
const elapsed = Math.round((today - day) / 864e5);
|
|
4671
|
+
const label = elapsed === 0 ? cfg.t("conversationGroupToday") : elapsed === 1 ? cfg.t("conversationGroupYesterday") : longDate(at, cfg.getLocale().tag);
|
|
4672
|
+
if (bubble.getAttribute("data-date") !== label) bubble.setAttribute("data-date", label);
|
|
4673
|
+
});
|
|
4674
|
+
}
|
|
4376
4675
|
/**
|
|
4377
4676
|
* Re-render the active path: clears the messages wrapper and rebuilds bubbles
|
|
4378
4677
|
* for every message on the current active branch path (root → head).
|
|
@@ -4411,6 +4710,7 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4411
4710
|
wrapper.appendChild(bubble);
|
|
4412
4711
|
populateBubbleFromMessage(bubble, message, sibInfo);
|
|
4413
4712
|
}
|
|
4713
|
+
this._syncDateSeparators();
|
|
4414
4714
|
this._dispatchPathChanged(activeMessages, siblingsInfo);
|
|
4415
4715
|
this._syncBusy();
|
|
4416
4716
|
this._checkpointState?.reapply();
|
|
@@ -4638,6 +4938,9 @@ class AparteChatViewport extends HTMLElement {
|
|
|
4638
4938
|
}
|
|
4639
4939
|
this._mutationObserver = new MutationObserver((mutations) => {
|
|
4640
4940
|
this._lastMutationAt = performance.now();
|
|
4941
|
+
if (mutations.some((m2) => m2.type === "childList" && (m2.target === this || m2.target.classList?.contains("aparte-messages-wrapper")))) {
|
|
4942
|
+
this._syncDateSeparators();
|
|
4943
|
+
}
|
|
4641
4944
|
if (this._frameworkManagedDOM) this._keepScrollButtonLast();
|
|
4642
4945
|
if (this._isAutoScrollEnabled && !this._gliding()) {
|
|
4643
4946
|
const added = mutations.flatMap((m2) => Array.from(m2.addedNodes)).filter((n2) => n2 instanceof Element && n2.tagName === "APARTE-CHAT-BUBBLE");
|
|
@@ -5267,6 +5570,28 @@ class AparteComposer extends HTMLElement {
|
|
|
5267
5570
|
this._attachments = [...this._attachments, ...Array.from(files)];
|
|
5268
5571
|
this._emit("attachments-change", { attachments: this._attachments });
|
|
5269
5572
|
}
|
|
5573
|
+
/**
|
|
5574
|
+
* Show how an attachment's upload is going, for an app that uploads as soon as a file
|
|
5575
|
+
* is picked. While one is `uploading`, nothing is sent. `null` clears it.
|
|
5576
|
+
*/
|
|
5577
|
+
setAttachmentState(file, state) {
|
|
5578
|
+
if (state) this._attachmentStates.set(file, state);
|
|
5579
|
+
else this._attachmentStates.delete(file);
|
|
5580
|
+
this._syncUploading();
|
|
5581
|
+
this.querySelector("aparte-composer-attachments")?.showState(file, state);
|
|
5582
|
+
}
|
|
5583
|
+
/** The state {@link setAttachmentState} last gave this file. */
|
|
5584
|
+
getAttachmentState(file) {
|
|
5585
|
+
return this._attachmentStates.get(file);
|
|
5586
|
+
}
|
|
5587
|
+
_attachmentStates = /* @__PURE__ */ new WeakMap();
|
|
5588
|
+
get _uploading() {
|
|
5589
|
+
return this._attachments.some((file) => this._attachmentStates.get(file)?.status === "uploading");
|
|
5590
|
+
}
|
|
5591
|
+
/** Reflected for the shipped CSS, the way the model gate is. */
|
|
5592
|
+
_syncUploading() {
|
|
5593
|
+
this.toggleAttribute("data-uploading", this._uploading);
|
|
5594
|
+
}
|
|
5270
5595
|
/**
|
|
5271
5596
|
* Drop one pending attachment and notify. Matched by IDENTITY — pass the same
|
|
5272
5597
|
* `File` object the composer handed you, not an equal one; two picks of the same
|
|
@@ -5274,11 +5599,13 @@ class AparteComposer extends HTMLElement {
|
|
|
5274
5599
|
*/
|
|
5275
5600
|
removeAttachment(file) {
|
|
5276
5601
|
this._attachments = this._attachments.filter((f2) => f2 !== file);
|
|
5602
|
+
this._syncUploading();
|
|
5277
5603
|
this._emit("attachments-change", { attachments: this._attachments });
|
|
5278
5604
|
}
|
|
5279
5605
|
/** Drop every pending attachment and notify. */
|
|
5280
5606
|
clearAttachments() {
|
|
5281
5607
|
this._attachments = [];
|
|
5608
|
+
this._syncUploading();
|
|
5282
5609
|
this._emit("attachments-change", { attachments: [] });
|
|
5283
5610
|
}
|
|
5284
5611
|
/**
|
|
@@ -5461,7 +5788,9 @@ class AparteComposer extends HTMLElement {
|
|
|
5461
5788
|
if (!value && this._attachments.length === 0) return;
|
|
5462
5789
|
if (this.disabled) return;
|
|
5463
5790
|
if (this._modelGated) return;
|
|
5791
|
+
if (this._uploading) return;
|
|
5464
5792
|
this._emit("submit", { value, attachments: this._attachments });
|
|
5793
|
+
const tokens = this.querySelector("aparte-composer-input")?.getTokens?.();
|
|
5465
5794
|
const detail = {
|
|
5466
5795
|
content: value,
|
|
5467
5796
|
timestamp: Date.now(),
|
|
@@ -5473,7 +5802,8 @@ class AparteComposer extends HTMLElement {
|
|
|
5473
5802
|
* reply to whichever one the host resolved first.
|
|
5474
5803
|
*/
|
|
5475
5804
|
targetId: this._ownTargetId(),
|
|
5476
|
-
files: this._attachments.length > 0 ? [...this._attachments] : void 0
|
|
5805
|
+
files: this._attachments.length > 0 ? [...this._attachments] : void 0,
|
|
5806
|
+
...tokens?.length ? { tokens } : {}
|
|
5477
5807
|
};
|
|
5478
5808
|
this.dispatchEvent(new CustomEvent("aparte-send", {
|
|
5479
5809
|
bubbles: true,
|
|
@@ -5614,6 +5944,88 @@ function acceptsFile(accept, file) {
|
|
|
5614
5944
|
const type = file.type.toLowerCase();
|
|
5615
5945
|
return tokens.some((token) => token.startsWith(".") ? name.endsWith(token) : token.endsWith("/*") ? type.startsWith(token.slice(0, -1)) : type === token);
|
|
5616
5946
|
}
|
|
5947
|
+
const TOKEN_ATTR = "data-aparte-token";
|
|
5948
|
+
const TEXT_ATTR = "data-aparte-text";
|
|
5949
|
+
const TOKEN_CHAR = "";
|
|
5950
|
+
const isText = (node) => node.nodeType === Node.TEXT_NODE;
|
|
5951
|
+
const isToken = (node) => node.nodeType === Node.ELEMENT_NODE && node.hasAttribute(TOKEN_ATTR);
|
|
5952
|
+
const indexIn = (node) => Array.prototype.indexOf.call(node.parentNode.childNodes, node);
|
|
5953
|
+
function leaves(root, out = []) {
|
|
5954
|
+
root.childNodes.forEach((child) => {
|
|
5955
|
+
if (isText(child) || child.nodeName === "BR" || isToken(child)) out.push(child);
|
|
5956
|
+
else leaves(child, out);
|
|
5957
|
+
});
|
|
5958
|
+
return out;
|
|
5959
|
+
}
|
|
5960
|
+
const sizeOf = (leaf) => isText(leaf) ? leaf.data.length : 1;
|
|
5961
|
+
function flatText(editor) {
|
|
5962
|
+
return leaves(editor).map((leaf) => isText(leaf) ? leaf.data : leaf.nodeName === "BR" ? "\n" : TOKEN_CHAR).join("");
|
|
5963
|
+
}
|
|
5964
|
+
function flatOffset(editor, container, offset) {
|
|
5965
|
+
const point = editor.ownerDocument.createRange();
|
|
5966
|
+
point.setStart(container, offset);
|
|
5967
|
+
point.collapse(true);
|
|
5968
|
+
let flat = 0;
|
|
5969
|
+
for (const leaf of leaves(editor)) {
|
|
5970
|
+
if (leaf === container) return flat + offset;
|
|
5971
|
+
if (point.comparePoint(leaf.parentNode, indexIn(leaf)) >= 0) return flat;
|
|
5972
|
+
flat += sizeOf(leaf);
|
|
5973
|
+
}
|
|
5974
|
+
return flat;
|
|
5975
|
+
}
|
|
5976
|
+
function domPoint(editor, flat) {
|
|
5977
|
+
let left = flat;
|
|
5978
|
+
for (const leaf of leaves(editor)) {
|
|
5979
|
+
if (isText(leaf) && left <= leaf.data.length) return [leaf, left];
|
|
5980
|
+
if (left === 0) return [leaf.parentNode, indexIn(leaf)];
|
|
5981
|
+
left -= sizeOf(leaf);
|
|
5982
|
+
}
|
|
5983
|
+
return [editor, editor.childNodes.length];
|
|
5984
|
+
}
|
|
5985
|
+
function flatRange(editor, from, to) {
|
|
5986
|
+
const range = editor.ownerDocument.createRange();
|
|
5987
|
+
range.setStart(...domPoint(editor, from));
|
|
5988
|
+
range.setEnd(...domPoint(editor, to));
|
|
5989
|
+
return range;
|
|
5990
|
+
}
|
|
5991
|
+
function tokenElement(doc, id, token) {
|
|
5992
|
+
const el2 = doc.createElement("span");
|
|
5993
|
+
el2.className = "aparte-tag aparte-inline-token";
|
|
5994
|
+
el2.setAttribute("contenteditable", "false");
|
|
5995
|
+
el2.setAttribute(TOKEN_ATTR, id);
|
|
5996
|
+
el2.setAttribute(TEXT_ATTR, token.text ?? token.label);
|
|
5997
|
+
if (token.kind) el2.dataset["kind"] = token.kind;
|
|
5998
|
+
const label = doc.createElement("span");
|
|
5999
|
+
label.className = "aparte-tag__label";
|
|
6000
|
+
label.textContent = token.label;
|
|
6001
|
+
el2.appendChild(label);
|
|
6002
|
+
return el2;
|
|
6003
|
+
}
|
|
6004
|
+
function serializeDraft(editor, known) {
|
|
6005
|
+
let out = "";
|
|
6006
|
+
const tokens = [];
|
|
6007
|
+
for (const leaf of leaves(editor)) {
|
|
6008
|
+
if (isText(leaf)) out += leaf.data;
|
|
6009
|
+
else if (leaf.nodeName === "BR") out += "\n";
|
|
6010
|
+
else {
|
|
6011
|
+
const el2 = leaf;
|
|
6012
|
+
const source = known.get(el2.getAttribute(TOKEN_ATTR) ?? "");
|
|
6013
|
+
const text = el2.getAttribute(TEXT_ATTR) ?? el2.textContent ?? "";
|
|
6014
|
+
const start = out.length;
|
|
6015
|
+
out += text;
|
|
6016
|
+
tokens.push({
|
|
6017
|
+
label: el2.textContent ?? "",
|
|
6018
|
+
text,
|
|
6019
|
+
start,
|
|
6020
|
+
end: out.length,
|
|
6021
|
+
...el2.dataset["kind"] ? { kind: el2.dataset["kind"] } : {},
|
|
6022
|
+
...source?.data !== void 0 ? { data: source.data } : {}
|
|
6023
|
+
});
|
|
6024
|
+
}
|
|
6025
|
+
}
|
|
6026
|
+
const lead = out.length - out.trimStart().length;
|
|
6027
|
+
return { value: out.trim(), tokens: tokens.map((token) => ({ ...token, start: token.start - lead, end: token.end - lead })) };
|
|
6028
|
+
}
|
|
5617
6029
|
class AparteComposerInput extends HTMLElement {
|
|
5618
6030
|
_editor = null;
|
|
5619
6031
|
_maxHeight = 200;
|
|
@@ -5671,22 +6083,48 @@ class AparteComposerInput extends HTMLElement {
|
|
|
5671
6083
|
* alone would collapse a multi-line draft onto a single line.
|
|
5672
6084
|
*/
|
|
5673
6085
|
getValue() {
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
6086
|
+
return this._editor ? serializeDraft(this._editor, this._tokens).value : "";
|
|
6087
|
+
}
|
|
6088
|
+
/** The tokens in the draft, with their place in {@link getValue}. */
|
|
6089
|
+
getTokens() {
|
|
6090
|
+
return this._editor ? serializeDraft(this._editor, this._tokens).tokens : [];
|
|
6091
|
+
}
|
|
6092
|
+
/** The caret, or `null` when the editor does not hold a collapsed selection. */
|
|
6093
|
+
getCaret() {
|
|
6094
|
+
const sel = this.ownerDocument?.getSelection();
|
|
6095
|
+
if (!this._editor || !sel?.rangeCount || !sel.isCollapsed || !this._editor.contains(sel.anchorNode)) return null;
|
|
6096
|
+
return { text: flatText(this._editor), offset: flatOffset(this._editor, sel.anchorNode, sel.anchorOffset) };
|
|
6097
|
+
}
|
|
6098
|
+
/** The box of a range of the draft on screen, to anchor something to the text. */
|
|
6099
|
+
getRangeRect(from, to = from) {
|
|
6100
|
+
if (!this._editor) return null;
|
|
6101
|
+
const range = flatRange(this._editor, from, to);
|
|
6102
|
+
return range.getClientRects?.()[0] ?? null;
|
|
6103
|
+
}
|
|
6104
|
+
/** Replace a range of the draft with text, and leave the caret after it. */
|
|
6105
|
+
replaceRange(from, to, text) {
|
|
6106
|
+
this._write(from, to, () => text ? this._insertPlain(text) : this._exec("delete"), () => this.ownerDocument.createTextNode(text));
|
|
6107
|
+
}
|
|
6108
|
+
/**
|
|
6109
|
+
* Replace a range of the draft with a token, followed by a space for the caret to land
|
|
6110
|
+
* on: a caret cannot rest after something that is not editable at the end of a line.
|
|
6111
|
+
*/
|
|
6112
|
+
insertToken(from, to, token) {
|
|
6113
|
+
const id = String(++this._lastTokenId);
|
|
6114
|
+
this._tokens.set(id, token);
|
|
6115
|
+
const doc = this.ownerDocument;
|
|
6116
|
+
const fragment = () => {
|
|
6117
|
+
const out = doc.createDocumentFragment();
|
|
6118
|
+
out.append(tokenElement(doc, id, token), doc.createTextNode(" "));
|
|
6119
|
+
return out;
|
|
5682
6120
|
};
|
|
5683
|
-
|
|
5684
|
-
return out.trim();
|
|
6121
|
+
this._write(from, to, () => this._exec("insertHTML", `${tokenElement(doc, id, token).outerHTML} `), fragment);
|
|
5685
6122
|
}
|
|
5686
6123
|
/** Replace the editor's content and mirror the value onto the parent composer. */
|
|
5687
6124
|
setValue(value) {
|
|
5688
6125
|
if (!this._editor) return;
|
|
5689
6126
|
this._editor.textContent = value;
|
|
6127
|
+
this._tokens.clear();
|
|
5690
6128
|
this._updatePlaceholderVisibility();
|
|
5691
6129
|
this._adjustHeight();
|
|
5692
6130
|
this._getRoot()?.setValue(value);
|
|
@@ -5695,6 +6133,7 @@ class AparteComposerInput extends HTMLElement {
|
|
|
5695
6133
|
clear() {
|
|
5696
6134
|
if (!this._editor) return;
|
|
5697
6135
|
this._editor.innerHTML = "";
|
|
6136
|
+
this._tokens.clear();
|
|
5698
6137
|
this._updatePlaceholderVisibility();
|
|
5699
6138
|
this._adjustHeight();
|
|
5700
6139
|
this._getRoot()?.setValue("");
|
|
@@ -5731,6 +6170,48 @@ class AparteComposerInput extends HTMLElement {
|
|
|
5731
6170
|
_getRoot() {
|
|
5732
6171
|
return this.closest("aparte-composer");
|
|
5733
6172
|
}
|
|
6173
|
+
/** What each pill in the editor stands for; a pill brought back by Undo finds its data here. */
|
|
6174
|
+
_tokens = /* @__PURE__ */ new Map();
|
|
6175
|
+
_lastTokenId = 0;
|
|
6176
|
+
/**
|
|
6177
|
+
* Through the browser's own edit commands, or Undo would not know about the change;
|
|
6178
|
+
* straight on the DOM where it has none.
|
|
6179
|
+
*/
|
|
6180
|
+
_write(from, to, edit, fallback) {
|
|
6181
|
+
const editor = this._editor;
|
|
6182
|
+
const sel = this.ownerDocument?.getSelection();
|
|
6183
|
+
if (!editor || !sel) return;
|
|
6184
|
+
editor.focus();
|
|
6185
|
+
const range = flatRange(editor, from, to);
|
|
6186
|
+
sel.removeAllRanges();
|
|
6187
|
+
sel.addRange(range);
|
|
6188
|
+
if (edit()) return;
|
|
6189
|
+
range.deleteContents();
|
|
6190
|
+
const node = fallback();
|
|
6191
|
+
const last = node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? node.lastChild : node;
|
|
6192
|
+
range.insertNode(node);
|
|
6193
|
+
range.setStartAfter(last);
|
|
6194
|
+
range.collapse(true);
|
|
6195
|
+
sel.removeAllRanges();
|
|
6196
|
+
sel.addRange(range);
|
|
6197
|
+
this._handleInput();
|
|
6198
|
+
}
|
|
6199
|
+
/** A browser edit command, or `false` where there is none: a caller then edits the DOM. */
|
|
6200
|
+
_exec(command, value) {
|
|
6201
|
+
try {
|
|
6202
|
+
return this.ownerDocument.execCommand(command, false, value);
|
|
6203
|
+
} catch {
|
|
6204
|
+
return false;
|
|
6205
|
+
}
|
|
6206
|
+
}
|
|
6207
|
+
/**
|
|
6208
|
+
* Plain text, as one edit. Several lines go as `<br>`s, because `insertText` makes each
|
|
6209
|
+
* line a block, and the draft is read flat: the lines would be sent run together.
|
|
6210
|
+
*/
|
|
6211
|
+
_insertPlain(text) {
|
|
6212
|
+
if (!/[\r\n]/.test(text)) return this._exec("insertText", text);
|
|
6213
|
+
return this._exec("insertHTML", escapeHtml(text).replace(/\r\n?|\n/g, "<br>"));
|
|
6214
|
+
}
|
|
5734
6215
|
_getPlaceholder() {
|
|
5735
6216
|
return this.getAttribute("placeholder") || this._getRoot()?.placeholder || resolveConfig(this).t("inputPlaceholder") || "Type a message...";
|
|
5736
6217
|
}
|
|
@@ -5776,6 +6257,7 @@ class AparteComposerInput extends HTMLElement {
|
|
|
5776
6257
|
}
|
|
5777
6258
|
_handleKeydown(e) {
|
|
5778
6259
|
if (e.isComposing || e.keyCode === 229) return;
|
|
6260
|
+
if (e.defaultPrevented) return;
|
|
5779
6261
|
if (e.key !== "Enter") return;
|
|
5780
6262
|
const submitOnEnter = this._getRoot()?.submitOnEnter ?? true;
|
|
5781
6263
|
const submits = submitOnEnter ? !e.shiftKey : e.shiftKey;
|
|
@@ -5812,9 +6294,7 @@ class AparteComposerInput extends HTMLElement {
|
|
|
5812
6294
|
return;
|
|
5813
6295
|
}
|
|
5814
6296
|
const text = cd.getData("text/plain");
|
|
5815
|
-
if (text)
|
|
5816
|
-
document.execCommand("insertText", false, text);
|
|
5817
|
-
}
|
|
6297
|
+
if (text) this._insertPlain(text);
|
|
5818
6298
|
}
|
|
5819
6299
|
_adjustHeight() {
|
|
5820
6300
|
if (!this._editor) return;
|
|
@@ -6123,6 +6603,36 @@ class AparteComposerAttachments extends HTMLElement {
|
|
|
6123
6603
|
);
|
|
6124
6604
|
this._render(root.attachments);
|
|
6125
6605
|
}
|
|
6606
|
+
/** Draw how a file's upload is going on its tile. */
|
|
6607
|
+
showState(file, state) {
|
|
6608
|
+
const index = this._getRoot()?.attachments.indexOf(file) ?? -1;
|
|
6609
|
+
const tile = this.querySelectorAll(".aparte-thumb")[index];
|
|
6610
|
+
if (!tile) return;
|
|
6611
|
+
tile.toggleAttribute("data-failed", state?.status === "error");
|
|
6612
|
+
let bar = tile.querySelector(".aparte-progress");
|
|
6613
|
+
if (state?.status !== "uploading") {
|
|
6614
|
+
bar?.remove();
|
|
6615
|
+
return;
|
|
6616
|
+
}
|
|
6617
|
+
if (!bar) {
|
|
6618
|
+
bar = document.createElement("div");
|
|
6619
|
+
bar.className = "aparte-progress aparte-thumb__progress";
|
|
6620
|
+
bar.setAttribute("role", "progressbar");
|
|
6621
|
+
bar.setAttribute("aria-label", file.name);
|
|
6622
|
+
bar.innerHTML = '<div class="aparte-progress__bar"></div>';
|
|
6623
|
+
tile.appendChild(bar);
|
|
6624
|
+
}
|
|
6625
|
+
const known = state.progress !== void 0;
|
|
6626
|
+
bar.classList.toggle("aparte-progress--indeterminate", !known);
|
|
6627
|
+
if (known) {
|
|
6628
|
+
bar.setAttribute("aria-valuenow", String(state.progress));
|
|
6629
|
+
bar.setAttribute("aria-valuemin", "0");
|
|
6630
|
+
bar.setAttribute("aria-valuemax", "100");
|
|
6631
|
+
bar.style.setProperty("--aparte-progress-value", String(state.progress));
|
|
6632
|
+
} else {
|
|
6633
|
+
bar.removeAttribute("aria-valuenow");
|
|
6634
|
+
}
|
|
6635
|
+
}
|
|
6126
6636
|
/** Release the previous render's blob URLs so they don't leak. */
|
|
6127
6637
|
_revokeUrls() {
|
|
6128
6638
|
this._objectUrls.forEach((url) => URL.revokeObjectURL(url));
|
|
@@ -6143,6 +6653,11 @@ class AparteComposerAttachments extends HTMLElement {
|
|
|
6143
6653
|
}
|
|
6144
6654
|
return `<div class="aparte-thumbnail aparte-thumb aparte-thumb--file" title="${name}"><span class="aparte-thumbnail__label">${escapeHtml(this._ext(file.name))}</span><span class="aparte-thumb__name">${name}</span>${remove}</div>`;
|
|
6145
6655
|
}).join("");
|
|
6656
|
+
const composer = this._getRoot();
|
|
6657
|
+
if (composer) for (const file of files) {
|
|
6658
|
+
const state = composer.getAttachmentState(file);
|
|
6659
|
+
if (state) this.showState(file, state);
|
|
6660
|
+
}
|
|
6146
6661
|
this.querySelectorAll(".aparte-thumb__remove").forEach((btn, i2) => {
|
|
6147
6662
|
btn.addEventListener("click", (e) => {
|
|
6148
6663
|
e.stopPropagation();
|
|
@@ -6862,7 +7377,7 @@ class AparteConversationList extends HTMLElement {
|
|
|
6862
7377
|
</div>
|
|
6863
7378
|
</div>`;
|
|
6864
7379
|
}
|
|
6865
|
-
_openMenu(row,
|
|
7380
|
+
_openMenu(row, button2) {
|
|
6866
7381
|
this._closeMenu();
|
|
6867
7382
|
const id = row.dataset["convId"];
|
|
6868
7383
|
const conv = this._conversations.find((c2) => c2.id === id);
|
|
@@ -6873,9 +7388,9 @@ class AparteConversationList extends HTMLElement {
|
|
|
6873
7388
|
menu.setAttribute("aria-label", conv.title || this._t("newChat"));
|
|
6874
7389
|
menu.innerHTML = this._menuMarkup(conv);
|
|
6875
7390
|
row.appendChild(menu);
|
|
6876
|
-
|
|
6877
|
-
this._open = { id, row, button, menu };
|
|
6878
|
-
this._placeMenu(
|
|
7391
|
+
button2.setAttribute("aria-expanded", "true");
|
|
7392
|
+
this._open = { id, row, button: button2, menu };
|
|
7393
|
+
this._placeMenu(button2, menu);
|
|
6879
7394
|
menu.querySelector('[role="menuitem"]')?.focus();
|
|
6880
7395
|
document.addEventListener("pointerdown", this._onDocumentPointerDown, true);
|
|
6881
7396
|
document.addEventListener("pointerup", this._onDocumentPointerUp, true);
|
|
@@ -6890,18 +7405,13 @@ class AparteConversationList extends HTMLElement {
|
|
|
6890
7405
|
* the menu closes on any scroll or resize, which is what makes the arithmetic
|
|
6891
7406
|
* safe to do once.
|
|
6892
7407
|
*/
|
|
6893
|
-
_placeMenu(
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
}
|
|
6900
|
-
const rtl = getComputedStyle(this).direction === "rtl";
|
|
6901
|
-
let left = rtl ? r.left : r.right - m2.width;
|
|
6902
|
-
left = Math.max(VIEWPORT_MARGIN, Math.min(left, window.innerWidth - m2.width - VIEWPORT_MARGIN));
|
|
6903
|
-
menu.style.top = `${top}px`;
|
|
6904
|
-
menu.style.left = `${left}px`;
|
|
7408
|
+
_placeMenu(button2, menu) {
|
|
7409
|
+
placeFloating(button2.getBoundingClientRect(), menu, {
|
|
7410
|
+
gap: MENU_GAP,
|
|
7411
|
+
margin: VIEWPORT_MARGIN,
|
|
7412
|
+
align: "end",
|
|
7413
|
+
rtl: getComputedStyle(this).direction === "rtl"
|
|
7414
|
+
});
|
|
6905
7415
|
}
|
|
6906
7416
|
_closeMenu(returnFocus = false) {
|
|
6907
7417
|
const open = this._open;
|
|
@@ -7417,14 +7927,14 @@ class AparteSuggestions extends HTMLElement {
|
|
|
7417
7927
|
row.setAttribute("role", "group");
|
|
7418
7928
|
row.setAttribute("aria-label", this._groupLabel());
|
|
7419
7929
|
for (const suggestion of this._suggestions) {
|
|
7420
|
-
const
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7930
|
+
const button2 = document.createElement("button");
|
|
7931
|
+
button2.type = "button";
|
|
7932
|
+
button2.className = "aparte-btn aparte-btn--surface aparte-btn--pill aparte-suggestion";
|
|
7933
|
+
button2.textContent = labelOf(suggestion);
|
|
7424
7934
|
const prompt = promptOf(suggestion);
|
|
7425
|
-
if (prompt !==
|
|
7426
|
-
|
|
7427
|
-
row.appendChild(
|
|
7935
|
+
if (prompt !== button2.textContent) button2.title = prompt;
|
|
7936
|
+
button2.addEventListener("click", () => this._activate(suggestion));
|
|
7937
|
+
row.appendChild(button2);
|
|
7428
7938
|
}
|
|
7429
7939
|
this.appendChild(row);
|
|
7430
7940
|
}
|
|
@@ -7995,10 +8505,10 @@ class AparteContext extends HTMLElement {
|
|
|
7995
8505
|
}
|
|
7996
8506
|
}
|
|
7997
8507
|
_action(name, label) {
|
|
7998
|
-
const
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
return
|
|
8508
|
+
const button2 = el("button", "aparte-btn aparte-btn--sm aparte-btn--surface aparte-context__action", label);
|
|
8509
|
+
button2.type = "button";
|
|
8510
|
+
button2.setAttribute("data-context-action", name);
|
|
8511
|
+
return button2;
|
|
8002
8512
|
}
|
|
8003
8513
|
/**
|
|
8004
8514
|
* Ask the registered compactor to compact this chat now, as a person asked. With none
|
|
@@ -8683,13 +9193,13 @@ class AparteScrollRail extends HTMLElement {
|
|
|
8683
9193
|
this._write("--aparte-scroll-rail-gap", "");
|
|
8684
9194
|
}
|
|
8685
9195
|
const height = this.clientHeight;
|
|
8686
|
-
const
|
|
8687
|
-
if (!
|
|
9196
|
+
const count2 = this._list()?.children.length ?? 0;
|
|
9197
|
+
if (!count2 || !height || count2 * hit <= height) {
|
|
8688
9198
|
this._write("--aparte-scroll-rail-hit-size", "");
|
|
8689
9199
|
this._write("--aparte-scroll-rail-gap", "");
|
|
8690
9200
|
return;
|
|
8691
9201
|
}
|
|
8692
|
-
const pitch = Math.max(MIN_PITCH, Math.floor(height /
|
|
9202
|
+
const pitch = Math.max(MIN_PITCH, Math.floor(height / count2));
|
|
8693
9203
|
this._write("--aparte-scroll-rail-hit-size", `${pitch}px`);
|
|
8694
9204
|
this._write("--aparte-scroll-rail-gap", `${Math.max(0, pitch - thickness)}px`);
|
|
8695
9205
|
}
|
|
@@ -10093,18 +10603,18 @@ class AparteLauncher extends HTMLElement {
|
|
|
10093
10603
|
* writing an id on the host's card is the launcher itself, the button's own ancestor.
|
|
10094
10604
|
*/
|
|
10095
10605
|
_renderButton() {
|
|
10096
|
-
const
|
|
10097
|
-
if (!
|
|
10606
|
+
const button2 = this._button;
|
|
10607
|
+
if (!button2) return;
|
|
10098
10608
|
this._keepButton();
|
|
10099
10609
|
const config = this._config();
|
|
10100
10610
|
const locale = config.getLocale();
|
|
10101
10611
|
const open = this.open;
|
|
10102
10612
|
const label = open ? "" : (this.getAttribute("label") ?? "").trim();
|
|
10103
10613
|
const shape = label ? "aparte-btn--pill" : "aparte-btn--circle";
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
if (label)
|
|
10107
|
-
else
|
|
10614
|
+
button2.className = ["aparte-btn", "aparte-btn--primary", "aparte-btn--solid", "aparte-btn--lg", shape, "aparte-launcher__button"].join(" ");
|
|
10615
|
+
button2.setAttribute("aria-expanded", String(open));
|
|
10616
|
+
if (label) button2.removeAttribute("aria-label");
|
|
10617
|
+
else button2.setAttribute("aria-label", open ? locale.launcherClose ?? "Close the chat" : locale.launcherOpen ?? "Open the chat");
|
|
10108
10618
|
const icon = document.createElement("span");
|
|
10109
10619
|
icon.className = "aparte-launcher__icon";
|
|
10110
10620
|
icon.setAttribute("aria-hidden", "true");
|
|
@@ -10116,7 +10626,7 @@ class AparteLauncher extends HTMLElement {
|
|
|
10116
10626
|
text.textContent = label;
|
|
10117
10627
|
parts.push(text);
|
|
10118
10628
|
}
|
|
10119
|
-
|
|
10629
|
+
button2.replaceChildren(...parts);
|
|
10120
10630
|
}
|
|
10121
10631
|
// ─── Sheet ────────────────────────────────────────────────────────────
|
|
10122
10632
|
_onMediaChange = (e) => this._applySheet(e.matches);
|
|
@@ -10233,11 +10743,11 @@ function onClick(event) {
|
|
|
10233
10743
|
}
|
|
10234
10744
|
function onKeyDown(event) {
|
|
10235
10745
|
if (event.key !== "Enter" && event.key !== " ") return;
|
|
10236
|
-
const
|
|
10237
|
-
if (!
|
|
10746
|
+
const button2 = event.target;
|
|
10747
|
+
if (!button2?.matches?.(`span${HELD}`)) return;
|
|
10238
10748
|
event.preventDefault();
|
|
10239
10749
|
event.stopPropagation();
|
|
10240
|
-
showHeldImage(
|
|
10750
|
+
showHeldImage(button2);
|
|
10241
10751
|
}
|
|
10242
10752
|
function installImageHoldsOnce() {
|
|
10243
10753
|
const doc = document;
|
|
@@ -10374,25 +10884,26 @@ export {
|
|
|
10374
10884
|
a2 as overrideSegmentRenderer,
|
|
10375
10885
|
a3 as parseAparteEventStream,
|
|
10376
10886
|
parseMarkdownToSegments,
|
|
10887
|
+
placeFloating,
|
|
10377
10888
|
populateBubbleFromMessage,
|
|
10378
|
-
|
|
10889
|
+
a7 as readableToAsyncIterable,
|
|
10379
10890
|
registerAllComponents,
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10891
|
+
a8 as registerDefaultRenderers,
|
|
10892
|
+
a9 as registerSegmentRenderer,
|
|
10893
|
+
aa as releaseDeferredHydration,
|
|
10894
|
+
ab as renderCitations,
|
|
10895
|
+
ac as renderCodeLanguages,
|
|
10896
|
+
ad as requestUserInput,
|
|
10386
10897
|
resolveConfig,
|
|
10387
10898
|
revokeAttachmentUrls,
|
|
10388
10899
|
runWithConfig,
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10900
|
+
ah as segmentDuration,
|
|
10901
|
+
segmentTiming,
|
|
10902
|
+
aj as setupSuggestionBlocks,
|
|
10392
10903
|
subscribeConfigChange,
|
|
10393
|
-
|
|
10394
|
-
|
|
10395
|
-
|
|
10904
|
+
al as toToolCallView,
|
|
10905
|
+
am as toolRefusal,
|
|
10906
|
+
an as unregisterSegmentRenderer,
|
|
10396
10907
|
uuid
|
|
10397
10908
|
};
|
|
10398
10909
|
//# sourceMappingURL=index.js.map
|