@sevenfold/setto-client 0.37.1 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type MessageTranslation } from './translation-caption.js';
|
|
1
2
|
type Attachment = {
|
|
2
3
|
id: string;
|
|
3
4
|
url: string;
|
|
@@ -18,13 +19,48 @@ type Message = {
|
|
|
18
19
|
type: 'navigate';
|
|
19
20
|
url: string;
|
|
20
21
|
} | null;
|
|
22
|
+
/**
|
|
23
|
+
* The message in the visitor's language. Only team, Barista and system
|
|
24
|
+
* messages carry one, and only from a server with live-chat translation;
|
|
25
|
+
* a row that lands later rings the same 'changed' doorbell.
|
|
26
|
+
*/
|
|
27
|
+
translation?: MessageTranslation | null;
|
|
21
28
|
};
|
|
29
|
+
/** The browser's language for the server's translation, within its 35-character limit. */
|
|
30
|
+
export declare function browserLanguage(): string | undefined;
|
|
31
|
+
export type ShownMessage = {
|
|
32
|
+
/** What the bubble shows: the translation unless the visitor asked for the original. */
|
|
33
|
+
content: string;
|
|
34
|
+
/** The language of `content`, when known, for the bubble's `lang`. */
|
|
35
|
+
lang: string | undefined;
|
|
36
|
+
/** The translation to caption, or null when the message has none. */
|
|
37
|
+
translation: MessageTranslation | null;
|
|
38
|
+
showingOriginal: boolean;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Which text a message shows. A translation is shown by default; the
|
|
42
|
+
* visitor's choice to see the original is kept per message id, so it
|
|
43
|
+
* survives every refetch. The visitor's own messages are never translated.
|
|
44
|
+
*/
|
|
45
|
+
export declare function shownMessage(message: Message, originals: ReadonlySet<string>): ShownMessage;
|
|
22
46
|
export declare function nextWordBoundary(content: string, visibleLength: number): number;
|
|
23
47
|
export declare function sineOut(progress: number): number;
|
|
24
48
|
export declare function isAtChatBottom(scrollHeight: number, scrollTop: number, clientHeight: number): boolean;
|
|
25
49
|
export declare function chatComposerSpace(height: number): number;
|
|
26
|
-
|
|
50
|
+
/**
|
|
51
|
+
* «Translated from English · Show original» under a translated message, in
|
|
52
|
+
* the visitor's language. The toggle is a real button; the line is left out
|
|
53
|
+
* of the transcript's live region so each new message is not followed by it.
|
|
54
|
+
*/
|
|
55
|
+
export declare function TranslationNote({ translation, showingOriginal, onToggle, }: {
|
|
56
|
+
translation: Pick<MessageTranslation, 'language' | 'from'>;
|
|
57
|
+
showingOriginal: boolean;
|
|
58
|
+
onToggle: () => void;
|
|
59
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
export declare function AgentJoinedEvent({ message, originals, onToggleOriginal, }: {
|
|
27
61
|
message: Message;
|
|
62
|
+
originals?: ReadonlySet<string>;
|
|
63
|
+
onToggleOriginal?: (id: string) => void;
|
|
28
64
|
}): import("react/jsx-runtime").JSX.Element;
|
|
29
65
|
/**
|
|
30
66
|
* A teammate is composing. The row opts out of the transcript's polite live
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The caption under a translated chat message: «Translated from English ·
|
|
3
|
+
* Show original», like YouTube's. The visitor reads it, so it is written in
|
|
4
|
+
* the language the translation is in, never in the site's i18n bundle (a
|
|
5
|
+
* site's locales are its own, and a visitor may write in any language).
|
|
6
|
+
*/
|
|
7
|
+
/** A translation the server attached to a team, Barista or system message. */
|
|
8
|
+
export interface MessageTranslation {
|
|
9
|
+
/** The language `content` is in: the visitor's. */
|
|
10
|
+
language: string;
|
|
11
|
+
/** The original's language (ISO 639 base, Norwegian is `no`); `und` when unknown. */
|
|
12
|
+
from: string;
|
|
13
|
+
content: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CaptionStrings {
|
|
16
|
+
/** `{language}` is replaced by the source language's name. */
|
|
17
|
+
translatedFrom: string;
|
|
18
|
+
/** When the source language is unknown. */
|
|
19
|
+
translated: string;
|
|
20
|
+
showOriginal: string;
|
|
21
|
+
showTranslation: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Templates avoid grammatical case where the language would inflect the name
|
|
25
|
+
* (German, Polish, Finnish, the Slavic and Baltic ones), so the plain name
|
|
26
|
+
* from `Intl.DisplayNames` always reads correctly.
|
|
27
|
+
*/
|
|
28
|
+
export declare const CAPTION_STRINGS: Readonly<Record<string, CaptionStrings>>;
|
|
29
|
+
/** `en-GB` → `en`; Norwegian in any form (`nb`, `nn`, `no-NO`) → `no`. */
|
|
30
|
+
export declare function baseLanguage(tag: string | null | undefined): string;
|
|
31
|
+
/** The caption dictionary for a language, English when there is none. */
|
|
32
|
+
export declare function captionStrings(language: string | null | undefined): CaptionStrings;
|
|
33
|
+
/**
|
|
34
|
+
* The name of language `code`, written in language `inLanguage`
|
|
35
|
+
* (`languageName('en', 'no')` → `engelsk`, `languageName('no', 'en')` →
|
|
36
|
+
* `Norwegian`). Norwegian falls back to the name of `nb` where the engine has
|
|
37
|
+
* none for `no`. Falls back to the code when the runtime has no name for it,
|
|
38
|
+
* or no `Intl.DisplayNames` at all.
|
|
39
|
+
*/
|
|
40
|
+
export declare function languageName(code: string, inLanguage: string): string;
|
|
41
|
+
export interface TranslationCaption {
|
|
42
|
+
/** «Translated from English», in the visitor's language. */
|
|
43
|
+
label: string;
|
|
44
|
+
/** The toggle's text for the current view. */
|
|
45
|
+
toggle: string;
|
|
46
|
+
/** The BCP 47 tag the caption is written in, for `lang`. */
|
|
47
|
+
lang: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The caption for one translated message. `showingOriginal` picks the
|
|
51
|
+
* toggle's text: «Show original» while the translation is shown, «Show
|
|
52
|
+
* translation» once the visitor has switched. The line starts with a capital
|
|
53
|
+
* where the script has case; a language name in the middle of the sentence
|
|
54
|
+
* keeps the case the language gives it («Oversatt fra engelsk»).
|
|
55
|
+
*/
|
|
56
|
+
export declare function translationCaption(translation: Pick<MessageTranslation, 'language' | 'from'>, showingOriginal: boolean): TranslationCaption;
|
package/dist/setto-client.js
CHANGED
|
@@ -34,7 +34,7 @@ const ENDONYMS = {
|
|
|
34
34
|
zh: "中文",
|
|
35
35
|
ja: "日本語"
|
|
36
36
|
};
|
|
37
|
-
function languageName(tag) {
|
|
37
|
+
function languageName$1(tag) {
|
|
38
38
|
const base = tag.toLowerCase().split("-")[0] ?? tag;
|
|
39
39
|
return ENDONYMS[base] ?? tag.toUpperCase();
|
|
40
40
|
}
|
|
@@ -35309,6 +35309,87 @@ function refreshOutcome(started, current) {
|
|
|
35309
35309
|
if (current.busy || started.turn !== current.turn) return "defer";
|
|
35310
35310
|
return "apply";
|
|
35311
35311
|
}
|
|
35312
|
+
const CAPTION_STRINGS = {
|
|
35313
|
+
en: { translatedFrom: "Translated from {language}", translated: "Translated", showOriginal: "Show original", showTranslation: "Show translation" },
|
|
35314
|
+
no: { translatedFrom: "Oversatt fra {language}", translated: "Oversatt", showOriginal: "Vis original", showTranslation: "Vis oversettelse" },
|
|
35315
|
+
sv: { translatedFrom: "Översatt från {language}", translated: "Översatt", showOriginal: "Visa original", showTranslation: "Visa översättning" },
|
|
35316
|
+
da: { translatedFrom: "Oversat fra {language}", translated: "Oversat", showOriginal: "Vis original", showTranslation: "Vis oversættelse" },
|
|
35317
|
+
de: { translatedFrom: "Übersetzt aus: {language}", translated: "Übersetzt", showOriginal: "Original anzeigen", showTranslation: "Übersetzung anzeigen" },
|
|
35318
|
+
fr: { translatedFrom: "Traduit de : {language}", translated: "Traduit", showOriginal: "Afficher l’original", showTranslation: "Afficher la traduction" },
|
|
35319
|
+
es: { translatedFrom: "Traducido del {language}", translated: "Traducido", showOriginal: "Ver original", showTranslation: "Ver traducción" },
|
|
35320
|
+
it: { translatedFrom: "Tradotto da: {language}", translated: "Tradotto", showOriginal: "Mostra originale", showTranslation: "Mostra traduzione" },
|
|
35321
|
+
pl: { translatedFrom: "Przetłumaczono z języka: {language}", translated: "Przetłumaczono", showOriginal: "Pokaż oryginał", showTranslation: "Pokaż tłumaczenie" },
|
|
35322
|
+
uk: { translatedFrom: "Перекладено з мови: {language}", translated: "Перекладено", showOriginal: "Показати оригінал", showTranslation: "Показати переклад" },
|
|
35323
|
+
ru: { translatedFrom: "Переведено с языка: {language}", translated: "Переведено", showOriginal: "Показать оригинал", showTranslation: "Показать перевод" },
|
|
35324
|
+
pt: { translatedFrom: "Traduzido do {language}", translated: "Traduzido", showOriginal: "Ver original", showTranslation: "Ver tradução" },
|
|
35325
|
+
nl: { translatedFrom: "Vertaald uit het {language}", translated: "Vertaald", showOriginal: "Origineel tonen", showTranslation: "Vertaling tonen" },
|
|
35326
|
+
fi: { translatedFrom: "Käännetty kielestä {language}", translated: "Käännetty", showOriginal: "Näytä alkuperäinen", showTranslation: "Näytä käännös" },
|
|
35327
|
+
lt: { translatedFrom: "Išversta iš kalbos: {language}", translated: "Išversta", showOriginal: "Rodyti originalą", showTranslation: "Rodyti vertimą" },
|
|
35328
|
+
ar: { translatedFrom: "مترجم من {language}", translated: "مترجم", showOriginal: "عرض النص الأصلي", showTranslation: "عرض الترجمة" },
|
|
35329
|
+
zh: { translatedFrom: "翻译自{language}", translated: "已翻译", showOriginal: "显示原文", showTranslation: "显示译文" },
|
|
35330
|
+
ja: { translatedFrom: "{language}から翻訳", translated: "翻訳済み", showOriginal: "原文を表示", showTranslation: "翻訳を表示" },
|
|
35331
|
+
tr: { translatedFrom: "{language} dilinden çevrildi", translated: "Çevrildi", showOriginal: "Orijinali göster", showTranslation: "Çeviriyi göster" },
|
|
35332
|
+
so: { translatedFrom: "Laga turjumay {language}", translated: "La turjumay", showOriginal: "Muuji asalka", showTranslation: "Muuji turjumaadda" },
|
|
35333
|
+
ti: { translatedFrom: "ካብ {language} ዝተተርጎመ", translated: "ዝተተርጎመ", showOriginal: "ናይ መበቆል ኣርኢ", showTranslation: "ትርጉም ኣርኢ" }
|
|
35334
|
+
};
|
|
35335
|
+
function baseLanguage(tag) {
|
|
35336
|
+
const base = (tag ?? "").trim().toLowerCase().split(/[-_]/)[0] ?? "";
|
|
35337
|
+
return base === "nb" || base === "nn" ? "no" : base;
|
|
35338
|
+
}
|
|
35339
|
+
function captionStrings(language) {
|
|
35340
|
+
return CAPTION_STRINGS[baseLanguage(language)] ?? CAPTION_STRINGS.en;
|
|
35341
|
+
}
|
|
35342
|
+
function displayLocales(tag) {
|
|
35343
|
+
const trimmed = tag.trim();
|
|
35344
|
+
const locales = [];
|
|
35345
|
+
try {
|
|
35346
|
+
locales.push(...Intl.getCanonicalLocales(trimmed));
|
|
35347
|
+
} catch {
|
|
35348
|
+
}
|
|
35349
|
+
if (baseLanguage(trimmed) === "no") locales.push("nb");
|
|
35350
|
+
locales.push("en");
|
|
35351
|
+
return locales;
|
|
35352
|
+
}
|
|
35353
|
+
function nameOf(names, code2) {
|
|
35354
|
+
try {
|
|
35355
|
+
const name2 = names.of(code2);
|
|
35356
|
+
return name2 && name2.trim() && name2.toLowerCase() !== code2.toLowerCase() ? name2 : null;
|
|
35357
|
+
} catch {
|
|
35358
|
+
return null;
|
|
35359
|
+
}
|
|
35360
|
+
}
|
|
35361
|
+
function languageName(code2, inLanguage) {
|
|
35362
|
+
const fallback = code2.trim();
|
|
35363
|
+
try {
|
|
35364
|
+
const names = new Intl.DisplayNames(displayLocales(inLanguage), { type: "language", fallback: "code" });
|
|
35365
|
+
const name2 = nameOf(names, fallback) ?? (baseLanguage(fallback) === "no" ? nameOf(names, "nb") : null);
|
|
35366
|
+
return name2 ?? fallback;
|
|
35367
|
+
} catch {
|
|
35368
|
+
return fallback;
|
|
35369
|
+
}
|
|
35370
|
+
}
|
|
35371
|
+
function capitaliseFirst(text2, locale) {
|
|
35372
|
+
if (!text2) return text2;
|
|
35373
|
+
const [first = "", ...rest] = Array.from(text2);
|
|
35374
|
+
let upper;
|
|
35375
|
+
try {
|
|
35376
|
+
upper = first.toLocaleUpperCase(locale);
|
|
35377
|
+
} catch {
|
|
35378
|
+
upper = first.toUpperCase();
|
|
35379
|
+
}
|
|
35380
|
+
return upper + rest.join("");
|
|
35381
|
+
}
|
|
35382
|
+
function translationCaption(translation, showingOriginal) {
|
|
35383
|
+
const strings = captionStrings(translation.language);
|
|
35384
|
+
const lang = CAPTION_STRINGS[baseLanguage(translation.language)] ? translation.language : "en";
|
|
35385
|
+
const from = baseLanguage(translation.from);
|
|
35386
|
+
const label = !from || from === "und" ? strings.translated : strings.translatedFrom.replace("{language}", languageName(from, lang));
|
|
35387
|
+
return {
|
|
35388
|
+
label: capitaliseFirst(label, lang),
|
|
35389
|
+
toggle: showingOriginal ? strings.showTranslation : strings.showOriginal,
|
|
35390
|
+
lang
|
|
35391
|
+
};
|
|
35392
|
+
}
|
|
35312
35393
|
const VISITOR_KEY = "setto-chat-visitor";
|
|
35313
35394
|
const ACTIVE_CONVERSATION_KEY = "setto-chat-active";
|
|
35314
35395
|
const NAVIGATION_KEY = "setto-chat-navigation";
|
|
@@ -35341,6 +35422,23 @@ function storedActiveConversation(siteId) {
|
|
|
35341
35422
|
return null;
|
|
35342
35423
|
}
|
|
35343
35424
|
}
|
|
35425
|
+
function browserLanguage() {
|
|
35426
|
+
try {
|
|
35427
|
+
const language = typeof navigator === "undefined" ? "" : navigator.language?.trim() ?? "";
|
|
35428
|
+
return language ? language.slice(0, 35) : void 0;
|
|
35429
|
+
} catch {
|
|
35430
|
+
return void 0;
|
|
35431
|
+
}
|
|
35432
|
+
}
|
|
35433
|
+
function shownMessage(message, originals) {
|
|
35434
|
+
const translation = message.id && message.role !== "visitor" && message.translation?.content ? message.translation : null;
|
|
35435
|
+
if (!translation) {
|
|
35436
|
+
return { content: message.content, lang: void 0, translation: null, showingOriginal: false };
|
|
35437
|
+
}
|
|
35438
|
+
const showingOriginal = originals.has(message.id);
|
|
35439
|
+
const from = translation.from?.trim();
|
|
35440
|
+
return showingOriginal ? { content: message.content, lang: from && from !== "und" ? from : void 0, translation, showingOriginal } : { content: translation.content, lang: translation.language || void 0, translation, showingOriginal };
|
|
35441
|
+
}
|
|
35344
35442
|
function nextWordBoundary(content2, visibleLength) {
|
|
35345
35443
|
if (visibleLength >= content2.length) return content2.length;
|
|
35346
35444
|
const match = content2.slice(visibleLength).match(/^\s*\S+\s*/u);
|
|
@@ -35480,7 +35578,25 @@ function PersonIcon() {
|
|
|
35480
35578
|
}
|
|
35481
35579
|
) });
|
|
35482
35580
|
}
|
|
35483
|
-
function
|
|
35581
|
+
function TranslationNote({
|
|
35582
|
+
translation,
|
|
35583
|
+
showingOriginal,
|
|
35584
|
+
onToggle
|
|
35585
|
+
}) {
|
|
35586
|
+
const caption = translationCaption(translation, showingOriginal);
|
|
35587
|
+
return /* @__PURE__ */ jsxs("div", { className: "setto-chat__translation", lang: caption.lang, dir: "auto", "aria-live": "off", children: [
|
|
35588
|
+
/* @__PURE__ */ jsx("span", { children: caption.label }),
|
|
35589
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "·" }),
|
|
35590
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: onToggle, children: caption.toggle })
|
|
35591
|
+
] });
|
|
35592
|
+
}
|
|
35593
|
+
const NO_ORIGINALS = /* @__PURE__ */ new Set();
|
|
35594
|
+
function AgentJoinedEvent({
|
|
35595
|
+
message,
|
|
35596
|
+
originals = NO_ORIGINALS,
|
|
35597
|
+
onToggleOriginal
|
|
35598
|
+
}) {
|
|
35599
|
+
const shown = shownMessage(message, originals);
|
|
35484
35600
|
return /* @__PURE__ */ jsxs("div", { className: "setto-chat__message setto-chat__message--system setto-chat__message--agent-joined", children: [
|
|
35485
35601
|
/* @__PURE__ */ jsx(
|
|
35486
35602
|
"span",
|
|
@@ -35490,7 +35606,17 @@ function AgentJoinedEvent({ message }) {
|
|
|
35490
35606
|
children: message.avatarUrl ? /* @__PURE__ */ jsx("img", { src: message.avatarUrl, alt: "" }) : /* @__PURE__ */ jsx(PersonIcon, {})
|
|
35491
35607
|
}
|
|
35492
35608
|
),
|
|
35493
|
-
/* @__PURE__ */
|
|
35609
|
+
/* @__PURE__ */ jsxs("div", { className: "setto-chat__message-stack", children: [
|
|
35610
|
+
/* @__PURE__ */ jsx("div", { className: "setto-chat__message-bubble", children: /* @__PURE__ */ jsx("span", { className: "setto-chat__message-copy", lang: shown.lang, children: shown.content }) }),
|
|
35611
|
+
shown.translation && message.id && onToggleOriginal ? /* @__PURE__ */ jsx(
|
|
35612
|
+
TranslationNote,
|
|
35613
|
+
{
|
|
35614
|
+
translation: shown.translation,
|
|
35615
|
+
showingOriginal: shown.showingOriginal,
|
|
35616
|
+
onToggle: () => onToggleOriginal(message.id)
|
|
35617
|
+
}
|
|
35618
|
+
) : null
|
|
35619
|
+
] })
|
|
35494
35620
|
] });
|
|
35495
35621
|
}
|
|
35496
35622
|
function TeamTypingRow({ label, avatarUrl }) {
|
|
@@ -36004,6 +36130,7 @@ function SettoChat() {
|
|
|
36004
36130
|
const [queued, setQueued] = useState(false);
|
|
36005
36131
|
const [loadingConversation, setLoadingConversation] = useState(false);
|
|
36006
36132
|
const [humanJoined, setHumanJoined] = useState(false);
|
|
36133
|
+
const [originals, setOriginals] = useState(() => /* @__PURE__ */ new Set());
|
|
36007
36134
|
const [availability, setAvailability] = useState({
|
|
36008
36135
|
humanAvailable: false,
|
|
36009
36136
|
avatarUrl: null
|
|
@@ -36483,6 +36610,7 @@ function SettoChat() {
|
|
|
36483
36610
|
conversationId: conversationId.current ?? void 0,
|
|
36484
36611
|
visitorId: visitorIdValue,
|
|
36485
36612
|
locale,
|
|
36613
|
+
language: browserLanguage(),
|
|
36486
36614
|
page: window.location.href,
|
|
36487
36615
|
message: content2 || void 0,
|
|
36488
36616
|
attachmentIds: uploaded.map((attachment) => attachment.id)
|
|
@@ -36529,6 +36657,13 @@ function SettoChat() {
|
|
|
36529
36657
|
setSending(false);
|
|
36530
36658
|
}
|
|
36531
36659
|
}
|
|
36660
|
+
function toggleOriginal(id) {
|
|
36661
|
+
setOriginals((current) => {
|
|
36662
|
+
const next = new Set(current);
|
|
36663
|
+
if (!next.delete(id)) next.add(id);
|
|
36664
|
+
return next;
|
|
36665
|
+
});
|
|
36666
|
+
}
|
|
36532
36667
|
const seenIndex = seenVisitorMessageIndex(messages, humanJoined, realtime?.teamReadAt ?? null);
|
|
36533
36668
|
const typingIdentity = teamTypingUntil !== null ? teamTypingIdentity(messages) : null;
|
|
36534
36669
|
return /* @__PURE__ */ jsxs(
|
|
@@ -36628,8 +36763,20 @@ function SettoChat() {
|
|
|
36628
36763
|
"aria-live": "polite",
|
|
36629
36764
|
"aria-busy": loadingConversation,
|
|
36630
36765
|
children: /* @__PURE__ */ jsxs("div", { className: "setto-chat__message-list", children: [
|
|
36631
|
-
messages.map(
|
|
36632
|
-
(item
|
|
36766
|
+
messages.map((item, index2) => {
|
|
36767
|
+
if (item.role === "system" && item.kind === "agent_joined") {
|
|
36768
|
+
return /* @__PURE__ */ jsx(
|
|
36769
|
+
AgentJoinedEvent,
|
|
36770
|
+
{
|
|
36771
|
+
message: item,
|
|
36772
|
+
originals,
|
|
36773
|
+
onToggleOriginal: toggleOriginal
|
|
36774
|
+
},
|
|
36775
|
+
item.id ?? `agent-joined-${index2}`
|
|
36776
|
+
);
|
|
36777
|
+
}
|
|
36778
|
+
const shown = shownMessage(item, originals);
|
|
36779
|
+
return /* @__PURE__ */ jsxs(
|
|
36633
36780
|
"div",
|
|
36634
36781
|
{
|
|
36635
36782
|
className: `setto-chat__message setto-chat__message--${item.role}`,
|
|
@@ -36645,7 +36792,7 @@ function SettoChat() {
|
|
|
36645
36792
|
/* @__PURE__ */ jsxs("div", { className: "setto-chat__message-stack", children: [
|
|
36646
36793
|
item.role === "assistant" || item.role === "human" ? /* @__PURE__ */ jsx("span", { className: "setto-chat__speaker", children: item.role === "human" ? item.authorName || labels.team : `${agentName} · ${labels.ai}` }) : null,
|
|
36647
36794
|
/* @__PURE__ */ jsxs("div", { className: "setto-chat__message-bubble", children: [
|
|
36648
|
-
/* @__PURE__ */ jsx("div", { className: "setto-chat__message-copy", children:
|
|
36795
|
+
/* @__PURE__ */ jsx("div", { className: "setto-chat__message-copy", lang: shown.lang, children: shown.content ? item.role === "assistant" ? /* @__PURE__ */ jsx(SiteChatMarkdown, { content: shown.content, reveal: item.reveal }) : shown.content : /* @__PURE__ */ jsx("span", { className: "setto-chat__typing", children: "···" }) }),
|
|
36649
36796
|
item.attachments?.map((attachment) => /* @__PURE__ */ jsx(
|
|
36650
36797
|
"a",
|
|
36651
36798
|
{
|
|
@@ -36658,13 +36805,21 @@ function SettoChat() {
|
|
|
36658
36805
|
attachment.id
|
|
36659
36806
|
))
|
|
36660
36807
|
] }),
|
|
36808
|
+
shown.translation && item.id ? /* @__PURE__ */ jsx(
|
|
36809
|
+
TranslationNote,
|
|
36810
|
+
{
|
|
36811
|
+
translation: shown.translation,
|
|
36812
|
+
showingOriginal: shown.showingOriginal,
|
|
36813
|
+
onToggle: () => toggleOriginal(item.id)
|
|
36814
|
+
}
|
|
36815
|
+
) : null,
|
|
36661
36816
|
index2 === seenIndex ? /* @__PURE__ */ jsx(SeenMarker, { label: labels.seen }) : null
|
|
36662
36817
|
] })
|
|
36663
36818
|
]
|
|
36664
36819
|
},
|
|
36665
36820
|
item.id ?? `${item.role}-${index2}`
|
|
36666
|
-
)
|
|
36667
|
-
),
|
|
36821
|
+
);
|
|
36822
|
+
}),
|
|
36668
36823
|
typingIdentity ? /* @__PURE__ */ jsx(
|
|
36669
36824
|
TeamTypingRow,
|
|
36670
36825
|
{
|
|
@@ -36752,7 +36907,7 @@ function useChatStyles() {
|
|
|
36752
36907
|
.setto-chat__main{position:relative;z-index:1;display:flex;flex:1;min-width:0;max-width:820px;height:100%;margin:0 auto;flex-direction:column;background:var(--setto-chat-canvas)}.setto-chat__header{position:absolute;inset:0 0 auto;z-index:30;min-height:58px;padding:.35rem .75rem;display:flex;align-items:center;gap:.5rem;background:linear-gradient(to bottom,color-mix(in srgb,var(--setto-chat-crema) 88%,transparent),color-mix(in srgb,var(--setto-chat-crema) 72%,transparent));border-bottom:1px solid color-mix(in srgb,var(--setto-chat-ink) 12%,transparent);backdrop-filter:blur(20px) saturate(150%);-webkit-backdrop-filter:blur(20px) saturate(150%);isolation:isolate}.setto-chat__round-button{flex:none;width:46px;height:46px;padding:0;border:1px solid color-mix(in srgb,var(--setto-chat-ink) 12%,transparent);border-radius:50%;background:var(--setto-chat-raised);color:var(--setto-chat-ink);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:background 160ms ease,border-color 160ms ease,color 160ms ease}.setto-chat__round-button:hover{background:var(--setto-chat-crema);border-color:var(--setto-chat-accent);color:var(--setto-chat-accent)}.setto-chat__round-button:active{transform:scale(.96)}.setto-chat__brand{flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;line-height:1.15;text-align:center}.setto-chat__brand h2{margin:0;color:var(--setto-chat-ink);font-size:1.02rem;font-weight:600;line-height:1.15}.setto-chat__brand p{max-width:100%;margin:2px 0 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:color-mix(in srgb,var(--setto-chat-ink) 56%,transparent);font-size:.78rem;line-height:1.15}
|
|
36753
36908
|
.setto-chat__body{position:relative;display:flex;flex:1 1 auto;min-height:0;height:100%;flex-direction:column}.setto-chat__log{display:flex;flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;flex-direction:column;padding:calc(58px + 1.3rem) .75rem var(--setto-chat-composer-space,8rem);scroll-padding-bottom:var(--setto-chat-composer-space,8rem);scroll-behavior:auto;-webkit-overflow-scrolling:touch}.setto-chat__message-list{display:flex;flex-direction:column}.setto-chat__message{--setto-chat-bubble:color-mix(in srgb,var(--setto-chat-ink) 7%,var(--setto-chat-canvas));display:flex;align-items:flex-end;gap:.55rem;width:100%;margin-bottom:1rem;color:color-mix(in srgb,var(--setto-chat-ink) 92%,transparent);font-size:16px;line-height:1.5;overflow-wrap:anywhere}.setto-chat__message-stack{display:flex;min-width:0;max-width:min(78%,36rem);flex-direction:column;align-items:flex-start}.setto-chat__message-bubble{position:relative;min-width:2.5rem;padding:.58rem .82rem;border-radius:19px 19px 19px 5px;background:var(--setto-chat-bubble);white-space:pre-wrap}.setto-chat__message--assistant .setto-chat__message-bubble::before,.setto-chat__message--human .setto-chat__message-bubble::before{content:"";position:absolute;z-index:0;left:-7px;bottom:0;width:16px;height:17px;border-bottom-right-radius:14px;background:var(--setto-chat-bubble)}.setto-chat__message--assistant .setto-chat__message-bubble::after,.setto-chat__message--human .setto-chat__message-bubble::after{content:"";position:absolute;z-index:1;left:-10px;bottom:0;width:10px;height:18px;border-bottom-right-radius:10px;background:var(--setto-chat-canvas)}.setto-chat__message-copy,.setto-chat__image{position:relative;z-index:2}.setto-chat__message--visitor{--setto-chat-bubble:var(--setto-chat-accent);justify-content:flex-end;color:var(--setto-chat-on-accent)}.setto-chat__message--visitor .setto-chat__message-stack{align-items:flex-end}.setto-chat__message--visitor .setto-chat__message-bubble{border-radius:19px 19px 5px 19px}.setto-chat__message--visitor .setto-chat__message-bubble::before{content:"";position:absolute;z-index:0;right:-7px;bottom:0;width:16px;height:17px;border-bottom-left-radius:14px;background:var(--setto-chat-bubble)}.setto-chat__message--visitor .setto-chat__message-bubble::after{content:"";position:absolute;z-index:1;right:-10px;bottom:0;width:10px;height:18px;border-bottom-left-radius:10px;background:var(--setto-chat-canvas)}.setto-chat__message--system{justify-content:center;color:color-mix(in srgb,var(--setto-chat-ink) 55%,transparent);font-size:.78rem;line-height:1.45;text-align:center}.setto-chat__message--system .setto-chat__message-stack{max-width:85%;align-items:center}.setto-chat__message--system .setto-chat__message-bubble{padding:.25rem .6rem;background:transparent}.setto-chat__avatar{position:relative;z-index:3;display:grid;place-items:center;flex:0 0 34px;width:34px;height:34px;margin-bottom:1px;overflow:hidden;border:2px solid var(--setto-chat-canvas);border-radius:50%;background:var(--setto-chat-crema);color:var(--setto-chat-ink);box-shadow:0 2px 8px color-mix(in srgb,var(--setto-chat-ink) 14%,transparent)}.setto-chat__avatar--assistant{background:var(--setto-chat-accent);color:var(--setto-chat-on-accent)}.setto-chat__avatar img{display:block;width:100%;height:100%;object-fit:cover}.setto-chat__speaker{display:block;margin:0 0 .2rem .4rem;color:color-mix(in srgb,var(--setto-chat-ink) 52%,transparent);font-size:.69rem;font-weight:500;line-height:1.2}.setto-chat__typing{display:inline-block;min-width:1.8rem;animation:setto-chat-pulse 1s ease-in-out infinite}.setto-chat__image{display:block;width:max-content;max-width:100%;margin-top:.65rem;overflow:hidden;border-radius:13px}.setto-chat__image img{display:block;width:min(280px,100%);max-height:260px;object-fit:cover}
|
|
36754
36909
|
.setto-chat__message--agent-joined{justify-content:flex-start;align-items:center;gap:.55rem;padding:.1rem .4rem;color:color-mix(in srgb,var(--setto-chat-ink) 62%,transparent);font-size:.8rem;line-height:1.4;text-align:left}.setto-chat__message--agent-joined .setto-chat__message-stack{max-width:calc(100% - 38px);align-items:flex-start}.setto-chat__message--agent-joined .setto-chat__message-bubble{min-width:0;padding:.2rem 0;background:transparent;white-space:normal}.setto-chat__avatar--joined{flex-basis:30px;width:30px;height:30px;margin:0;border-width:1px;box-shadow:0 2px 7px color-mix(in srgb,var(--setto-chat-ink) 12%,transparent)}
|
|
36755
|
-
.setto-chat__receipt{display:block;margin:.26rem .45rem 0 0;color:color-mix(in srgb,var(--setto-chat-ink) 52%,transparent);font-size:.69rem;font-weight:500;line-height:1.2}.setto-chat__message--typing{animation:setto-chat-typing-in 180ms cubic-bezier(.2,.8,.2,1) both}.setto-chat__message--typing .setto-chat__message-bubble{min-width:3.25rem;text-align:center}.setto-chat__message--typing .setto-chat__typing{font-weight:700;letter-spacing:.06em}@keyframes setto-chat-typing-in{from{opacity:0;transform:translateY(4px)}}@media(prefers-reduced-motion:reduce){.setto-chat__message--typing{animation:none}}
|
|
36910
|
+
.setto-chat__receipt{display:block;margin:.26rem .45rem 0 0;color:color-mix(in srgb,var(--setto-chat-ink) 52%,transparent);font-size:.69rem;font-weight:500;line-height:1.2}.setto-chat__translation{display:flex;flex-wrap:wrap;align-items:baseline;gap:0 .3rem;margin:.3rem .4rem 0;color:color-mix(in srgb,var(--setto-chat-ink) 52%,transparent);font-size:.69rem;font-weight:500;line-height:1.3}.setto-chat__translation button{padding:0;border:0;border-radius:2px;background:transparent;color:inherit;font:inherit;line-height:inherit;text-decoration:underline;text-decoration-color:color-mix(in srgb,var(--setto-chat-ink) 30%,transparent);text-underline-offset:2px;cursor:pointer;transition:color 140ms ease}.setto-chat__translation button:hover{color:var(--setto-chat-ink);text-decoration-color:currentColor}.setto-chat__translation button:focus-visible{outline:2px solid var(--setto-chat-accent);outline-offset:2px}.setto-chat__message--system .setto-chat__translation{justify-content:center}.setto-chat__message--typing{animation:setto-chat-typing-in 180ms cubic-bezier(.2,.8,.2,1) both}.setto-chat__message--typing .setto-chat__message-bubble{min-width:3.25rem;text-align:center}.setto-chat__message--typing .setto-chat__typing{font-weight:700;letter-spacing:.06em}@keyframes setto-chat-typing-in{from{opacity:0;transform:translateY(4px)}}@media(prefers-reduced-motion:reduce){.setto-chat__message--typing{animation:none}}
|
|
36756
36911
|
.setto-chat__composer-shell{position:absolute;left:0;right:0;bottom:0;z-index:25;display:grid;grid-template-columns:minmax(0,1fr);padding:1.5rem .75rem 0;background:transparent;isolation:isolate}.setto-chat__composer-shell::before{content:"";position:absolute;inset:0;pointer-events:none;background:linear-gradient(to bottom,transparent 0%,color-mix(in srgb,var(--setto-chat-canvas) 82%,transparent) 46%,var(--setto-chat-canvas) 66%);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);-webkit-mask-image:linear-gradient(to bottom,rgba(0,0,0,0) 0%,rgba(0,0,0,.4) 34%,rgba(0,0,0,1) 66%);mask-image:linear-gradient(to bottom,rgba(0,0,0,0) 0%,rgba(0,0,0,.4) 34%,rgba(0,0,0,1) 66%)}.setto-chat__composer{position:relative;z-index:1;display:flex;flex-direction:column;gap:.15rem;width:100%;min-width:0;margin:0;padding:.35rem .4rem;border:2px solid color-mix(in srgb,var(--setto-chat-ink) 10%,transparent);border-radius:24px;background:var(--setto-chat-canvas);box-shadow:0 8px 24px -16px color-mix(in srgb,var(--setto-chat-ink) 28%,transparent);transition:padding 220ms cubic-bezier(.16,1,.3,1),border-color 200ms ease,box-shadow 360ms cubic-bezier(.16,1,.3,1)}.setto-chat__composer.is-open{padding:.55rem .5rem}.setto-chat__composer:focus-within{border-color:var(--setto-chat-accent)}.setto-chat__composer textarea,.setto-chat__composer textarea:hover,.setto-chat__composer textarea:focus,.setto-chat__composer textarea:focus-visible{width:100%;min-height:36px;max-height:${MAX_COMPOSER_HEIGHT}px;overflow-y:auto;padding:.45rem .25rem;resize:none;-webkit-appearance:none!important;appearance:none!important;border:0!important;border-radius:0!important;outline:0!important;box-shadow:none!important;background:transparent!important;color:var(--setto-chat-ink);font-family:"Archivo Variable",Archivo,system-ui,sans-serif;font-size:16px;line-height:1.35;transition:min-height 220ms cubic-bezier(.16,1,.3,1)}.setto-chat__composer.is-open textarea{min-height:40px}.setto-chat__composer textarea::placeholder{color:color-mix(in srgb,var(--setto-chat-ink) 52%,transparent)}.setto-chat__composer textarea::-webkit-scrollbar{width:6px}.setto-chat__composer textarea::-webkit-scrollbar-track{background:transparent}.setto-chat__composer textarea::-webkit-scrollbar-thumb{border-radius:999px;background:color-mix(in srgb,var(--setto-chat-ink) 24%,transparent)}.setto-chat__composer textarea::-webkit-scrollbar-button{display:none;height:0}@supports not selector(::-webkit-scrollbar){.setto-chat__composer textarea{scrollbar-width:thin;scrollbar-color:color-mix(in srgb,var(--setto-chat-ink) 24%,transparent) transparent}}.setto-chat__composer-tools{display:flex;align-items:center;gap:.4rem;width:100%;min-width:0}.setto-chat__attach{flex:none;width:34px;height:34px;padding:0;border:0;border-radius:50%;background:transparent;color:color-mix(in srgb,var(--setto-chat-ink) 58%,transparent);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:background 160ms ease,color 160ms ease}.setto-chat__attach:hover:not(:disabled){background:color-mix(in srgb,var(--setto-chat-ink) 6%,transparent);color:var(--setto-chat-ink)}.setto-chat__attach:disabled{opacity:.4;cursor:default}.setto-chat__send{flex:none;width:36px;height:36px;margin-left:auto;padding:0;border:0;border-radius:50%;background:var(--setto-chat-accent);color:var(--setto-chat-on-accent);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:transform 360ms cubic-bezier(.16,1,.3,1),box-shadow 360ms cubic-bezier(.16,1,.3,1),background 200ms ease,opacity 200ms ease}.setto-chat__send:hover:not(:disabled){transform:translateY(-2px);box-shadow:0 12px 24px -12px color-mix(in srgb,var(--setto-chat-ink) 45%,transparent)}.setto-chat__send:active:not(:disabled){transform:translateY(0);box-shadow:0 4px 10px -8px color-mix(in srgb,var(--setto-chat-ink) 40%,transparent);transition-duration:90ms}.setto-chat__send:disabled{opacity:.35;cursor:default}.setto-chat__send.is-queued{animation:setto-chat-queued 1.1s ease-in-out infinite}.setto-chat__attachments{display:flex;flex-wrap:wrap;gap:.4rem;list-style:none;margin:0;padding:.15rem .15rem 0}.setto-chat__attachments li{position:relative;width:56px;height:56px;border-radius:10px;overflow:hidden;border:1px solid color-mix(in srgb,var(--setto-chat-ink) 12%,transparent);background:var(--setto-chat-crema)}.setto-chat__attachments img{display:block;width:100%;height:100%;object-fit:cover}.setto-chat__attachments button{position:absolute;top:2px;right:2px;width:18px;height:18px;padding:0;border:0;border-radius:50%;background:color-mix(in srgb,var(--setto-chat-ink) 72%,transparent);color:var(--setto-chat-canvas);display:inline-flex;align-items:center;justify-content:center;cursor:pointer}.setto-chat__composer-floor{position:relative;z-index:1;width:calc(100% + 1.5rem);height:max(.35rem,env(safe-area-inset-bottom));margin-left:-.75rem;background:var(--setto-chat-canvas)}
|
|
36757
36912
|
.setto-chat__launcher{width:58px;height:58px;padding:3px;border:1px solid color-mix(in srgb,var(--setto-chat-canvas) 54%,transparent);border-radius:50%;background:color-mix(in srgb,var(--setto-chat-raised) 35%,transparent);box-shadow:0 10px 30px color-mix(in srgb,var(--setto-chat-ink) 24%,transparent),inset 0 0 0 1px color-mix(in srgb,var(--setto-chat-ink) 9%,transparent);backdrop-filter:blur(14px) saturate(115%);-webkit-backdrop-filter:blur(14px) saturate(115%);color:var(--setto-chat-ink);display:grid;place-items:center;cursor:pointer;transition:transform 180ms ease,box-shadow 180ms ease}.setto-chat__launcher:hover{transform:translateY(-2px);box-shadow:0 15px 35px color-mix(in srgb,var(--setto-chat-ink) 28%,transparent),inset 0 0 0 1px color-mix(in srgb,var(--setto-chat-ink) 9%,transparent)}.setto-chat__launcher span{width:46px;height:46px;border-radius:50%;display:grid;place-items:center;background:var(--setto-chat-accent);color:var(--setto-chat-on-accent)}.setto-chat__launcher img{display:block;width:50px;height:50px;border-radius:50%;object-fit:cover}.setto-chat__launcher span{overflow:hidden}.setto-chat__launcher span img{width:100%;height:100%}.setto-chat__launcher:focus-visible,.setto-chat button:focus-visible,.setto-chat input:focus-visible{outline:2px solid var(--setto-chat-accent);outline-offset:2px}@keyframes setto-chat-pulse{50%{opacity:.35}}@keyframes setto-chat-queued{50%{opacity:.55}}
|
|
36758
36913
|
@media(max-width:700px){.setto-chat__chats{position:absolute;inset:0 auto 0 0;transform:translateX(-100%);transition:transform 260ms cubic-bezier(.16,1,.3,1);box-shadow:14px 0 35px color-mix(in srgb,var(--setto-chat-ink) 16%,transparent)}.setto-chat__chats--open{transform:none}.setto-chat__main{width:100%;max-width:none;margin:0}.setto-chat__log{padding-left:.75rem;padding-right:.75rem}}@media(min-width:701px){.setto-chat--mounted{top:auto;right:max(18px,env(safe-area-inset-right));bottom:max(18px,env(safe-area-inset-bottom));left:auto;width:min(440px,calc(100vw - 36px));height:min(720px,calc(100dvh - 36px));overflow:visible;background:transparent}.setto-chat__shell{position:relative;top:auto;left:auto;width:100%;height:100%;border:1px solid color-mix(in srgb,var(--setto-chat-ink) 14%,transparent);border-radius:26px;background:var(--setto-chat-canvas);box-shadow:0 28px 80px -24px color-mix(in srgb,var(--setto-chat-ink) 42%,transparent),0 8px 24px -12px color-mix(in srgb,var(--setto-chat-ink) 24%,transparent);transform:translateY(16px) scale(.975);transform-origin:right bottom}.setto-chat--visible .setto-chat__shell{transform:none}.setto-chat__chats{position:absolute;inset:0 auto 0 0;width:min(82%,280px);height:100%;transform:translateX(-100%);transition:transform 260ms cubic-bezier(.16,1,.3,1);box-shadow:14px 0 35px color-mix(in srgb,var(--setto-chat-ink) 16%,transparent)}.setto-chat__chats--open{transform:none}.setto-chat__main{width:100%;max-width:none;margin:0}.setto-chat__header,.setto-chat__log{padding-left:.9rem;padding-right:.9rem}.setto-chat__composer-shell{padding-left:.9rem;padding-right:.9rem}.setto-chat__composer-floor{width:calc(100% + 1.8rem);height:.45rem;margin-left:-.9rem}.setto-chat__message{font-size:15.5px}.setto-chat__message-stack{max-width:82%}}@media(prefers-reduced-motion:reduce){.setto-chat,.setto-chat__shell,.setto-chat__chats,.setto-chat__launcher,.setto-chat__composer,.setto-chat__composer textarea,.setto-chat__send{transition:none!important}.setto-chat__typing,.setto-chat__send.is-queued{animation:none}}
|
|
@@ -36982,12 +37137,12 @@ function SettoLanguages({ languages: given, inline = false }) {
|
|
|
36982
37137
|
onMouseLeave: () => setHover(false),
|
|
36983
37138
|
"aria-expanded": open,
|
|
36984
37139
|
"aria-haspopup": "listbox",
|
|
36985
|
-
"aria-label": `Språk: ${languageName(current)}`,
|
|
36986
|
-
title: inline ? languageName(current) : void 0,
|
|
37140
|
+
"aria-label": `Språk: ${languageName$1(current)}`,
|
|
37141
|
+
title: inline ? languageName$1(current) : void 0,
|
|
36987
37142
|
style: inline ? { ...inlineTriggerStyle, opacity: hover || open ? 1 : inlineTriggerStyle.opacity } : floatingTriggerStyle,
|
|
36988
37143
|
children: [
|
|
36989
37144
|
/* @__PURE__ */ jsx(GlobeIcon, {}),
|
|
36990
|
-
inline ? shortCode(current) : languageName(current)
|
|
37145
|
+
inline ? shortCode(current) : languageName$1(current)
|
|
36991
37146
|
]
|
|
36992
37147
|
}
|
|
36993
37148
|
),
|
|
@@ -37008,7 +37163,7 @@ function SettoLanguages({ languages: given, inline = false }) {
|
|
|
37008
37163
|
...inline ? { color: "inherit" } : {},
|
|
37009
37164
|
fontWeight: tag === current ? 600 : 400
|
|
37010
37165
|
},
|
|
37011
|
-
children: languageName(tag)
|
|
37166
|
+
children: languageName$1(tag)
|
|
37012
37167
|
}
|
|
37013
37168
|
) }, tag))
|
|
37014
37169
|
}
|
|
@@ -40993,7 +41148,7 @@ export {
|
|
|
40993
41148
|
isSafeHref,
|
|
40994
41149
|
isSettoMediaUrl,
|
|
40995
41150
|
languageFromPath,
|
|
40996
|
-
languageName,
|
|
41151
|
+
languageName$1 as languageName,
|
|
40997
41152
|
nodeChildren,
|
|
40998
41153
|
normalisePath,
|
|
40999
41154
|
optimizedSrcSet,
|