@sevenfold/setto-client 0.37.0 → 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.
|
@@ -26,6 +26,16 @@ export interface LanguageRoute {
|
|
|
26
26
|
/** The path with the prefix removed, always starting with `/`. */
|
|
27
27
|
rest: string;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The address to navigate to, or null when it would leave this origin.
|
|
31
|
+
*
|
|
32
|
+
* A second lock behind `normalise`: whatever the routing above returns, the
|
|
33
|
+
* language switch and the first-visit redirect only ever go somewhere on the
|
|
34
|
+
* site they started on. Resolved by the URL parser itself rather than by a
|
|
35
|
+
* check on the string, so it agrees with the browser about what the address
|
|
36
|
+
* means.
|
|
37
|
+
*/
|
|
38
|
+
export declare function sameOriginUrl(target: string, origin: string): string | null;
|
|
29
39
|
/**
|
|
30
40
|
* Read the language out of a path.
|
|
31
41
|
*
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/** True for a single key segment that may be read or written. */
|
|
2
|
+
export declare function isSafeSegment(segment: string): boolean;
|
|
3
|
+
/** True when every segment of a dotted key may be read or written. */
|
|
4
|
+
export declare function isSafeKey(key: string): boolean;
|
|
1
5
|
/** Reads a dotted key path from a nested object. */
|
|
2
6
|
export declare function getNested(obj: unknown, key: string): unknown;
|
|
3
7
|
/** Sets a dotted key path on a nested object (mutates in place). */
|
|
@@ -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
|
}
|
|
@@ -20929,22 +20929,33 @@ function createApi(args) {
|
|
|
20929
20929
|
}
|
|
20930
20930
|
};
|
|
20931
20931
|
}
|
|
20932
|
+
const UNSAFE_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
20933
|
+
function isSafeSegment(segment) {
|
|
20934
|
+
return !UNSAFE_SEGMENTS.has(segment);
|
|
20935
|
+
}
|
|
20936
|
+
function isSafeKey(key) {
|
|
20937
|
+
return key.split(".").every(isSafeSegment);
|
|
20938
|
+
}
|
|
20932
20939
|
function getNested(obj, key) {
|
|
20933
20940
|
if (!obj || typeof obj !== "object") return void 0;
|
|
20941
|
+
if (!isSafeKey(key)) return void 0;
|
|
20934
20942
|
const parts = key.split(".");
|
|
20935
20943
|
let cur = obj;
|
|
20936
20944
|
for (const part of parts) {
|
|
20937
20945
|
if (!cur || typeof cur !== "object") return void 0;
|
|
20946
|
+
if (!Object.prototype.hasOwnProperty.call(cur, part)) return void 0;
|
|
20938
20947
|
cur = cur[part];
|
|
20939
20948
|
}
|
|
20940
20949
|
return cur;
|
|
20941
20950
|
}
|
|
20942
20951
|
function deleteNested(obj, key) {
|
|
20952
|
+
if (!isSafeKey(key)) return;
|
|
20943
20953
|
const parts = key.split(".");
|
|
20944
20954
|
const chain = [obj];
|
|
20945
20955
|
let cur = obj;
|
|
20946
20956
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
20947
20957
|
const part = parts[i];
|
|
20958
|
+
if (!Object.prototype.hasOwnProperty.call(cur, part)) return;
|
|
20948
20959
|
const next = cur[part];
|
|
20949
20960
|
if (!next || typeof next !== "object") return;
|
|
20950
20961
|
cur = next;
|
|
@@ -20959,7 +20970,7 @@ function deleteNested(obj, key) {
|
|
|
20959
20970
|
function collectKeysUnder(obj, prefix) {
|
|
20960
20971
|
const base = getNested(obj, prefix);
|
|
20961
20972
|
if (!base || typeof base !== "object" || Array.isArray(base)) return [];
|
|
20962
|
-
return Object.keys(base).sort(compareListKeys);
|
|
20973
|
+
return Object.keys(base).filter(isSafeSegment).sort(compareListKeys);
|
|
20963
20974
|
}
|
|
20964
20975
|
function compareListKeys(a, b) {
|
|
20965
20976
|
const na = Number(a);
|
|
@@ -21030,6 +21041,7 @@ class I18nStore {
|
|
|
21030
21041
|
* If the value is set back to the original, the draft entry is cleared.
|
|
21031
21042
|
*/
|
|
21032
21043
|
set(key, lng, value) {
|
|
21044
|
+
if (!isSafeKey(key)) return;
|
|
21033
21045
|
const id = `${lng}::${key}`;
|
|
21034
21046
|
const existing = this.drafts.get(id);
|
|
21035
21047
|
const resource = this.i18n.getResource(lng, this.ns, key);
|
|
@@ -21049,6 +21061,7 @@ class I18nStore {
|
|
|
21049
21061
|
* deletion counts as a change and reverts cleanly.
|
|
21050
21062
|
*/
|
|
21051
21063
|
delete(key, lng) {
|
|
21064
|
+
if (!isSafeKey(key)) return;
|
|
21052
21065
|
const id = `${lng}::${key}`;
|
|
21053
21066
|
const existing = this.drafts.get(id);
|
|
21054
21067
|
const resource = this.i18n.getResource(lng, this.ns, key);
|
|
@@ -21212,7 +21225,7 @@ class I18nStore {
|
|
|
21212
21225
|
const walk2 = (value, path2) => {
|
|
21213
21226
|
if (value && typeof value === "object") {
|
|
21214
21227
|
for (const [k, v] of Object.entries(value)) {
|
|
21215
|
-
walk2(v, `${path2}.${k}`);
|
|
21228
|
+
if (isSafeSegment(k)) walk2(v, `${path2}.${k}`);
|
|
21216
21229
|
}
|
|
21217
21230
|
} else if (value !== void 0) {
|
|
21218
21231
|
out.push(path2);
|
|
@@ -21245,8 +21258,16 @@ class I18nStore {
|
|
|
21245
21258
|
}
|
|
21246
21259
|
}
|
|
21247
21260
|
function normalise(pathname) {
|
|
21248
|
-
const
|
|
21249
|
-
return
|
|
21261
|
+
const collapsed = `/${pathname}`.replace(/[\\/]+/g, "/");
|
|
21262
|
+
return collapsed.length > 1 && collapsed.endsWith("/") ? collapsed.slice(0, -1) : collapsed;
|
|
21263
|
+
}
|
|
21264
|
+
function sameOriginUrl(target, origin) {
|
|
21265
|
+
try {
|
|
21266
|
+
const url = new URL(target, origin);
|
|
21267
|
+
return url.origin === origin ? url.href : null;
|
|
21268
|
+
} catch {
|
|
21269
|
+
return null;
|
|
21270
|
+
}
|
|
21250
21271
|
}
|
|
21251
21272
|
function languageFromPath(pathname, languages, primary = languages[0] ?? DEFAULT_LANGUAGE) {
|
|
21252
21273
|
const path2 = normalise(pathname);
|
|
@@ -21276,7 +21297,8 @@ function alternateLinks(origin, pathname, languages, primary = languages[0] ?? D
|
|
|
21276
21297
|
return links;
|
|
21277
21298
|
}
|
|
21278
21299
|
function isReservedPath(pathname) {
|
|
21279
|
-
|
|
21300
|
+
const path2 = normalise(pathname);
|
|
21301
|
+
return path2 === "/setto" || path2.startsWith("/setto/");
|
|
21280
21302
|
}
|
|
21281
21303
|
function redirectForVisitor(pathname, languages, browserLanguages, stored, primary = languages[0] ?? DEFAULT_LANGUAGE) {
|
|
21282
21304
|
if (languages.length < 2) return null;
|
|
@@ -35287,6 +35309,87 @@ function refreshOutcome(started, current) {
|
|
|
35287
35309
|
if (current.busy || started.turn !== current.turn) return "defer";
|
|
35288
35310
|
return "apply";
|
|
35289
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
|
+
}
|
|
35290
35393
|
const VISITOR_KEY = "setto-chat-visitor";
|
|
35291
35394
|
const ACTIVE_CONVERSATION_KEY = "setto-chat-active";
|
|
35292
35395
|
const NAVIGATION_KEY = "setto-chat-navigation";
|
|
@@ -35319,6 +35422,23 @@ function storedActiveConversation(siteId) {
|
|
|
35319
35422
|
return null;
|
|
35320
35423
|
}
|
|
35321
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
|
+
}
|
|
35322
35442
|
function nextWordBoundary(content2, visibleLength) {
|
|
35323
35443
|
if (visibleLength >= content2.length) return content2.length;
|
|
35324
35444
|
const match = content2.slice(visibleLength).match(/^\s*\S+\s*/u);
|
|
@@ -35458,7 +35578,25 @@ function PersonIcon() {
|
|
|
35458
35578
|
}
|
|
35459
35579
|
) });
|
|
35460
35580
|
}
|
|
35461
|
-
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);
|
|
35462
35600
|
return /* @__PURE__ */ jsxs("div", { className: "setto-chat__message setto-chat__message--system setto-chat__message--agent-joined", children: [
|
|
35463
35601
|
/* @__PURE__ */ jsx(
|
|
35464
35602
|
"span",
|
|
@@ -35468,7 +35606,17 @@ function AgentJoinedEvent({ message }) {
|
|
|
35468
35606
|
children: message.avatarUrl ? /* @__PURE__ */ jsx("img", { src: message.avatarUrl, alt: "" }) : /* @__PURE__ */ jsx(PersonIcon, {})
|
|
35469
35607
|
}
|
|
35470
35608
|
),
|
|
35471
|
-
/* @__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
|
+
] })
|
|
35472
35620
|
] });
|
|
35473
35621
|
}
|
|
35474
35622
|
function TeamTypingRow({ label, avatarUrl }) {
|
|
@@ -35982,6 +36130,7 @@ function SettoChat() {
|
|
|
35982
36130
|
const [queued, setQueued] = useState(false);
|
|
35983
36131
|
const [loadingConversation, setLoadingConversation] = useState(false);
|
|
35984
36132
|
const [humanJoined, setHumanJoined] = useState(false);
|
|
36133
|
+
const [originals, setOriginals] = useState(() => /* @__PURE__ */ new Set());
|
|
35985
36134
|
const [availability, setAvailability] = useState({
|
|
35986
36135
|
humanAvailable: false,
|
|
35987
36136
|
avatarUrl: null
|
|
@@ -36461,6 +36610,7 @@ function SettoChat() {
|
|
|
36461
36610
|
conversationId: conversationId.current ?? void 0,
|
|
36462
36611
|
visitorId: visitorIdValue,
|
|
36463
36612
|
locale,
|
|
36613
|
+
language: browserLanguage(),
|
|
36464
36614
|
page: window.location.href,
|
|
36465
36615
|
message: content2 || void 0,
|
|
36466
36616
|
attachmentIds: uploaded.map((attachment) => attachment.id)
|
|
@@ -36507,6 +36657,13 @@ function SettoChat() {
|
|
|
36507
36657
|
setSending(false);
|
|
36508
36658
|
}
|
|
36509
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
|
+
}
|
|
36510
36667
|
const seenIndex = seenVisitorMessageIndex(messages, humanJoined, realtime?.teamReadAt ?? null);
|
|
36511
36668
|
const typingIdentity = teamTypingUntil !== null ? teamTypingIdentity(messages) : null;
|
|
36512
36669
|
return /* @__PURE__ */ jsxs(
|
|
@@ -36606,8 +36763,20 @@ function SettoChat() {
|
|
|
36606
36763
|
"aria-live": "polite",
|
|
36607
36764
|
"aria-busy": loadingConversation,
|
|
36608
36765
|
children: /* @__PURE__ */ jsxs("div", { className: "setto-chat__message-list", children: [
|
|
36609
|
-
messages.map(
|
|
36610
|
-
(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(
|
|
36611
36780
|
"div",
|
|
36612
36781
|
{
|
|
36613
36782
|
className: `setto-chat__message setto-chat__message--${item.role}`,
|
|
@@ -36623,7 +36792,7 @@ function SettoChat() {
|
|
|
36623
36792
|
/* @__PURE__ */ jsxs("div", { className: "setto-chat__message-stack", children: [
|
|
36624
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,
|
|
36625
36794
|
/* @__PURE__ */ jsxs("div", { className: "setto-chat__message-bubble", children: [
|
|
36626
|
-
/* @__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: "···" }) }),
|
|
36627
36796
|
item.attachments?.map((attachment) => /* @__PURE__ */ jsx(
|
|
36628
36797
|
"a",
|
|
36629
36798
|
{
|
|
@@ -36636,13 +36805,21 @@ function SettoChat() {
|
|
|
36636
36805
|
attachment.id
|
|
36637
36806
|
))
|
|
36638
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,
|
|
36639
36816
|
index2 === seenIndex ? /* @__PURE__ */ jsx(SeenMarker, { label: labels.seen }) : null
|
|
36640
36817
|
] })
|
|
36641
36818
|
]
|
|
36642
36819
|
},
|
|
36643
36820
|
item.id ?? `${item.role}-${index2}`
|
|
36644
|
-
)
|
|
36645
|
-
),
|
|
36821
|
+
);
|
|
36822
|
+
}),
|
|
36646
36823
|
typingIdentity ? /* @__PURE__ */ jsx(
|
|
36647
36824
|
TeamTypingRow,
|
|
36648
36825
|
{
|
|
@@ -36730,7 +36907,7 @@ function useChatStyles() {
|
|
|
36730
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}
|
|
36731
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}
|
|
36732
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)}
|
|
36733
|
-
.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}}
|
|
36734
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)}
|
|
36735
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}}
|
|
36736
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}}
|
|
@@ -36789,8 +36966,14 @@ function SettoProvider({ config, children }) {
|
|
|
36789
36966
|
readStoredLanguage()
|
|
36790
36967
|
);
|
|
36791
36968
|
if (redirect && redirect !== window.location.pathname) {
|
|
36792
|
-
|
|
36793
|
-
|
|
36969
|
+
const url = sameOriginUrl(
|
|
36970
|
+
redirect + window.location.search + window.location.hash,
|
|
36971
|
+
window.location.origin
|
|
36972
|
+
);
|
|
36973
|
+
if (url) {
|
|
36974
|
+
window.location.replace(url);
|
|
36975
|
+
return;
|
|
36976
|
+
}
|
|
36794
36977
|
}
|
|
36795
36978
|
const { language } = languageFromPath(window.location.pathname, languages);
|
|
36796
36979
|
if (language !== i18n.language) void i18n.changeLanguage(language);
|
|
@@ -36941,7 +37124,8 @@ function SettoLanguages({ languages: given, inline = false }) {
|
|
|
36941
37124
|
if (tag === current) return;
|
|
36942
37125
|
storeLanguage(tag);
|
|
36943
37126
|
const target = pathForLanguage(window.location.pathname, tag, languages);
|
|
36944
|
-
|
|
37127
|
+
const url = sameOriginUrl(target + window.location.search + window.location.hash, window.location.origin);
|
|
37128
|
+
if (url) window.location.assign(url);
|
|
36945
37129
|
};
|
|
36946
37130
|
return /* @__PURE__ */ jsxs("div", { ref, style: inline ? inlineWrapStyle : floatingWrapStyle, children: [
|
|
36947
37131
|
/* @__PURE__ */ jsxs(
|
|
@@ -36953,12 +37137,12 @@ function SettoLanguages({ languages: given, inline = false }) {
|
|
|
36953
37137
|
onMouseLeave: () => setHover(false),
|
|
36954
37138
|
"aria-expanded": open,
|
|
36955
37139
|
"aria-haspopup": "listbox",
|
|
36956
|
-
"aria-label": `Språk: ${languageName(current)}`,
|
|
36957
|
-
title: inline ? languageName(current) : void 0,
|
|
37140
|
+
"aria-label": `Språk: ${languageName$1(current)}`,
|
|
37141
|
+
title: inline ? languageName$1(current) : void 0,
|
|
36958
37142
|
style: inline ? { ...inlineTriggerStyle, opacity: hover || open ? 1 : inlineTriggerStyle.opacity } : floatingTriggerStyle,
|
|
36959
37143
|
children: [
|
|
36960
37144
|
/* @__PURE__ */ jsx(GlobeIcon, {}),
|
|
36961
|
-
inline ? shortCode(current) : languageName(current)
|
|
37145
|
+
inline ? shortCode(current) : languageName$1(current)
|
|
36962
37146
|
]
|
|
36963
37147
|
}
|
|
36964
37148
|
),
|
|
@@ -36979,7 +37163,7 @@ function SettoLanguages({ languages: given, inline = false }) {
|
|
|
36979
37163
|
...inline ? { color: "inherit" } : {},
|
|
36980
37164
|
fontWeight: tag === current ? 600 : 400
|
|
36981
37165
|
},
|
|
36982
|
-
children: languageName(tag)
|
|
37166
|
+
children: languageName$1(tag)
|
|
36983
37167
|
}
|
|
36984
37168
|
) }, tag))
|
|
36985
37169
|
}
|
|
@@ -40964,7 +41148,7 @@ export {
|
|
|
40964
41148
|
isSafeHref,
|
|
40965
41149
|
isSettoMediaUrl,
|
|
40966
41150
|
languageFromPath,
|
|
40967
|
-
languageName,
|
|
41151
|
+
languageName$1 as languageName,
|
|
40968
41152
|
nodeChildren,
|
|
40969
41153
|
normalisePath,
|
|
40970
41154
|
optimizedSrcSet,
|